agent-relay-server 0.111.0 → 0.112.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/docs/openapi.json +1 -1
- package/package.json +2 -2
- package/public/assets/{MessageBubble-WYqSyKPM.js → MessageBubble-DtLlfBAK.js} +2 -2
- package/public/assets/{MessageBubble-WYqSyKPM.js.map → MessageBubble-DtLlfBAK.js.map} +1 -1
- package/public/assets/{PlanGraphPanel-Dvu17jGe.js → PlanGraphPanel-pcKJ4q_4.js} +2 -2
- package/public/assets/{PlanGraphPanel-Dvu17jGe.js.map → PlanGraphPanel-pcKJ4q_4.js.map} +1 -1
- package/public/assets/{activity-wAN_upn7.js → activity-DRAeL0Jq.js} +2 -2
- package/public/assets/{activity-wAN_upn7.js.map → activity-DRAeL0Jq.js.map} +1 -1
- package/public/assets/{agent-profiles-D8WLdTCs.js → agent-profiles-cnWPANzx.js} +2 -2
- package/public/assets/{agent-profiles-D8WLdTCs.js.map → agent-profiles-cnWPANzx.js.map} +1 -1
- package/public/assets/{agents-C5FajNPw.js → agents-DgUjmk_D.js} +2 -2
- package/public/assets/{agents-C5FajNPw.js.map → agents-DgUjmk_D.js.map} +1 -1
- package/public/assets/{automation-ShdXg0pX.js → automation-CuTlgY1E.js} +2 -2
- package/public/assets/{automation-ShdXg0pX.js.map → automation-CuTlgY1E.js.map} +1 -1
- package/public/assets/{chat-aRCk0pLJ.js → chat-C7XCmaZz.js} +2 -2
- package/public/assets/{chat-aRCk0pLJ.js.map → chat-C7XCmaZz.js.map} +1 -1
- package/public/assets/{formatted-body-impl-DZc7C4-2.js → formatted-body-impl-rLDPgdmJ.js} +2 -2
- package/public/assets/{formatted-body-impl-DZc7C4-2.js.map → formatted-body-impl-rLDPgdmJ.js.map} +1 -1
- package/public/assets/{index-DXEYz_JV.js → index-DGyeTLPg.js} +5 -5
- package/public/assets/index-DGyeTLPg.js.map +1 -0
- package/public/assets/{insights-FzTX2wNh.js → insights-C0dDL4El.js} +2 -2
- package/public/assets/{insights-FzTX2wNh.js.map → insights-C0dDL4El.js.map} +1 -1
- package/public/assets/{maintenance-C8Uw8XiI.js → maintenance-DkOkcEkb.js} +2 -2
- package/public/assets/{maintenance-C8Uw8XiI.js.map → maintenance-DkOkcEkb.js.map} +1 -1
- package/public/assets/{managed-agents-DVbJ2hqh.js → managed-agents-C7Czinaz.js} +2 -2
- package/public/assets/{managed-agents-DVbJ2hqh.js.map → managed-agents-C7Czinaz.js.map} +1 -1
- package/public/assets/{markdown-preview-impl-C5D-B-9S.js → markdown-preview-impl-BZ7sigEc.js} +2 -2
- package/public/assets/{markdown-preview-impl-C5D-B-9S.js.map → markdown-preview-impl-BZ7sigEc.js.map} +1 -1
- package/public/assets/{memory-Bp-D_V80.js → memory-Bys-M7GK.js} +2 -2
- package/public/assets/{memory-Bp-D_V80.js.map → memory-Bys-M7GK.js.map} +1 -1
- package/public/assets/{messages-DE1QSeHI.js → messages-COSJ6trN.js} +2 -2
- package/public/assets/{messages-DE1QSeHI.js.map → messages-COSJ6trN.js.map} +1 -1
- package/public/assets/{orchestrators-B0u2lQfw.js → orchestrators-BjLl1Z0L.js} +2 -2
- package/public/assets/{orchestrators-B0u2lQfw.js.map → orchestrators-BjLl1Z0L.js.map} +1 -1
- package/public/assets/{overview-DpaEvvLT.js → overview-BmU7twic.js} +2 -2
- package/public/assets/{overview-DpaEvvLT.js.map → overview-BmU7twic.js.map} +1 -1
- package/public/assets/{pairs-DRp_qAu8.js → pairs-xclXjw-c.js} +2 -2
- package/public/assets/{pairs-DRp_qAu8.js.map → pairs-xclXjw-c.js.map} +1 -1
- package/public/assets/{prompt-settings-CNoBiymk.js → prompt-settings-CtQd0nz0.js} +2 -2
- package/public/assets/{prompt-settings-CNoBiymk.js.map → prompt-settings-CtQd0nz0.js.map} +1 -1
- package/public/assets/{registry-0A4QFMWC.js → registry-CDe6vjKI.js} +2 -2
- package/public/assets/{registry-0A4QFMWC.js.map → registry-CDe6vjKI.js.map} +1 -1
- package/public/assets/{security-C9P6yiQ3.js → security-C9mBNQMZ.js} +2 -2
- package/public/assets/{security-C9P6yiQ3.js.map → security-C9mBNQMZ.js.map} +1 -1
- package/public/assets/{select-B1PVUj6D.js → select-BJDKQk4q.js} +2 -2
- package/public/assets/{select-B1PVUj6D.js.map → select-BJDKQk4q.js.map} +1 -1
- package/public/assets/{settings-TnHlB9-t.js → settings-BmZjWJkI.js} +2 -2
- package/public/assets/{settings-TnHlB9-t.js.map → settings-BmZjWJkI.js.map} +1 -1
- package/public/assets/{tasks-1oK_ggFC.js → tasks-DNjZKSM2.js} +2 -2
- package/public/assets/tasks-DNjZKSM2.js.map +1 -0
- package/public/assets/{teams-BBb0ZYiF.js → teams-KNzmdolE.js} +2 -2
- package/public/assets/{teams-BBb0ZYiF.js.map → teams-KNzmdolE.js.map} +1 -1
- package/public/assets/{terminal-viewer-impl-DzvaRjkp.js → terminal-viewer-impl-DnFJDl9N.js} +2 -2
- package/public/assets/{terminal-viewer-impl-DzvaRjkp.js.map → terminal-viewer-impl-DnFJDl9N.js.map} +1 -1
- package/public/assets/{user-avatar-X1pfizLv.js → user-avatar-C8sbjQke.js} +2 -2
- package/public/assets/{user-avatar-X1pfizLv.js.map → user-avatar-C8sbjQke.js.map} +1 -1
- package/public/assets/{work-queue-DQMbkSD8.js → work-queue-DINvPVPn.js} +2 -2
- package/public/assets/{work-queue-DQMbkSD8.js.map → work-queue-DINvPVPn.js.map} +1 -1
- package/public/assets/{workspaces-BNLP4IlV.js → workspaces-CSNdUg15.js} +2 -2
- package/public/assets/{workspaces-BNLP4IlV.js.map → workspaces-CSNdUg15.js.map} +1 -1
- package/public/index.html +1 -1
- package/runner/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/src/mcp-task-tools.ts +2 -1
- package/src/services/spawn-registration-watchdog.ts +5 -5
- package/src/services/task-done-when.ts +21 -0
- package/src/services/task-entity.ts +10 -1
- package/src/services/task-lifecycle.ts +9 -39
- package/public/assets/index-DXEYz_JV.js.map +0 -1
- package/public/assets/tasks-1oK_ggFC.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./bundle-web-BLavPdXe.js","./chunk-CilyBKbf.js","./preload-helper-C_JMBXql.js","./lib-DHj_xjQT.js","./markdown-preview-impl-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./bundle-web-BLavPdXe.js","./chunk-CilyBKbf.js","./preload-helper-C_JMBXql.js","./lib-DHj_xjQT.js","./markdown-preview-impl-BZ7sigEc.js","./lib-DRRHEqRZ.js","./lucide-react-DmbfpRvJ.js","./terminal-viewer-impl-DnFJDl9N.js","./store-DDWg67Pg.js","./display-_5kFrHJh.js","./types-DSwhOFcJ.js","./button-BKFvNXa3.js","./dist-DKoRwEZq.js","./use-keyboard-viewport-Dw2CHZ50.js","./terminal-viewer-impl-BrP-ENHg.css","./formatted-body-impl-rLDPgdmJ.js","./overview-BmU7twic.js","./badge-kdQDWO6e.js","./card-B0y1i_2D.js","./chat-C7XCmaZz.js","./react-dom-jQ4Vs380.js","./MessageBubble-DtLlfBAK.js","./user-avatar-C8sbjQke.js","./PlanGraphPanel-pcKJ4q_4.js","./branch-state-badge-BRjUWyMT.js","./copy-button-aLaiAkv2.js","./input-DfN6sUbX.js","./agents-DgUjmk_D.js","./dist-BDYU37NZ.js","./dist-DQPz52Zx.js","./dist-DnyQI0qt.js","./dist-cyag2tir.js","./dist-avJPT3qF.js","./es2015-C9FSEGd7.js","./dist-D_qcpfbI.js","./dist-EO8jbi2F.js","./managed-agents-C7Czinaz.js","./teams-KNzmdolE.js","./select-BJDKQk4q.js","./dist-BiLuYU6G.js","./dist-DDh8a_SK.js","./dist-CF28Y5wI.js","./dist-BnfqT2cl.js","./agent-profiles-cnWPANzx.js","./orchestrators-BjLl1Z0L.js","./workspaces-CSNdUg15.js","./channels-DOYB1iiA.js","./connectors-C5CeK-2M.js","./integrations-CztQfrI7.js","./security-C9mBNQMZ.js","./memory-Bys-M7GK.js","./activity-DRAeL0Jq.js","./pairs-xclXjw-c.js","./messages-COSJ6trN.js","./work-queue-DINvPVPn.js","./tasks-DNjZKSM2.js","./automation-CuTlgY1E.js","./analytics-Q6Dl_CE9.js","./themes-DjSwmAZN.js","./insights-C0dDL4El.js","./projects-cOeuiMjl.js","./prompt-settings-CtQd0nz0.js","./registry-CDe6vjKI.js","./maintenance-DkOkcEkb.js","./settings-BmZjWJkI.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e,t}from"./chunk-CilyBKbf.js";import{$ as n,$n as r,$t as i,A as a,An as o,At as s,B as c,Cn as l,Ct as u,D as d,Dn as f,E as p,Et as m,F as h,Fn as g,Ft as _,G as v,H as y,Ht as b,In as x,It as ee,K as S,Kn as C,L as te,Lt as ne,Mn as w,N as re,Nn as ie,Pt as ae,R as oe,Rn as se,T,Tn as E,Tt as ce,U as le,V as ue,Vt as de,W as fe,X as D,Xn as pe,Xt as me,Y as he,Yt as ge,Zn as O,Zt as _e,_ as ve,_n as ye,a as be,an as xe,ar as k,bt as Se,d as Ce,dn as we,dt as Te,er as Ee,fn as De,fr as Oe,ft as ke,g as Ae,gt as je,h as Me,hn as Ne,ht as Pe,i as Fe,it as Ie,jn as Le,jt as Re,k as ze,ln as Be,mn as Ve,mt as He,n as Ue,nn as We,nt as Ge,o as Ke,on as qe,ot as Je,p as Ye,pt as Xe,q as Ze,qt as Qe,r as $e,s as et,sn as tt,st as nt,t as rt,tt as it,u as at,vt as ot,w as st,wn as ct,x as lt,xn as ut,y as dt,yn as ft,yt as pt,z as mt,zn as ht,zt as gt}from"./lucide-react-DmbfpRvJ.js";import{t as _t}from"./react-dom-jQ4Vs380.js";import{c as vt,d as yt,f as bt,p as xt,s as St,t as A}from"./store-DDWg67Pg.js";import{a as Ct,d as wt,f as Tt,h as Et,i as Dt,n as Ot,p as kt,r as At,u as jt}from"./types-DSwhOFcJ.js";import{B as Mt,C as Nt,D as Pt,E as Ft,G as It,J as Lt,K as j,O as Rt,Q as zt,S as Bt,T as Vt,W as Ht,X as Ut,Y as Wt,a as Gt,c as Kt,ct as qt,d as M,f as Jt,h as Yt,i as Xt,j as Zt,k as Qt,lt as $t,m as en,n as tn,o as nn,ot as rn,p as an,q as on,r as sn,t as cn,u as ln,w as un,x as dn,y as fn}from"./display-_5kFrHJh.js";import{n as pn,t as mn}from"./themes-DjSwmAZN.js";import{a as hn,i as gn,o as _n,r as vn,t as yn}from"./dist-DKoRwEZq.js";import{n as bn,t as N}from"./dist-DnyQI0qt.js";import{i as xn,n as P,r as Sn,t as Cn}from"./dist-DQPz52Zx.js";import{t as wn}from"./dist-DDh8a_SK.js";import{t as Tn}from"./dist-EO8jbi2F.js";import{t as En}from"./dist-D_qcpfbI.js";import{a as Dn,i as On,n as kn,o as An,r as jn,s as Mn,t as Nn}from"./es2015-C9FSEGd7.js";import{t as Pn}from"./dist-CF28Y5wI.js";import{t as Fn}from"./dist-cyag2tir.js";import{t as In}from"./dist-BnfqT2cl.js";import{t as Ln}from"./dist-avJPT3qF.js";import{a as Rn,i as zn,n as Bn,r as Vn,t as Hn}from"./dist-BDYU37NZ.js";import{t as Un}from"./dist-BiLuYU6G.js";import{t as F}from"./badge-kdQDWO6e.js";import{t as I}from"./button-BKFvNXa3.js";import{t as L}from"./input-DfN6sUbX.js";import{t as Wn}from"./copy-button-aLaiAkv2.js";import{t as R}from"./preload-helper-C_JMBXql.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Gn=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,ee||(ee=!0,re());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}var ee=!1,S=-1,C=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-te<C)}function w(){if(g=!1,ee){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(S),S=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ne());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?re():ee=!1}}}var re;if(typeof y==`function`)re=function(){y(w)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=w,re=function(){ae.postMessage(null)}}else re=function(){_(w,0)};function oe(t,n){S=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):C=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(S),S=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,re()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Kn=t(((e,t)=>{t.exports=Gn()})),qn=t((e=>{var t=Kn(),n=Oe(),r=_t();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),ee=Symbol.for(`react.suspense`),S=Symbol.for(`react.suspense_list`),C=Symbol.for(`react.memo`),te=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),w=Symbol.for(`react.memo_cache_sentinel`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case ee:return`Suspense`;case S:return`SuspenseList`;case ne:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case C:return t=e.displayName||null,t===null?oe(e.type)||`Memo`:t;case te:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var se=Array.isArray,T=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce={pending:!1,data:null,method:null,action:null},le=[],ue=-1;function de(e){return{current:e}}function fe(e){0>ue||(e.current=le[ue],le[ue]=null,ue--)}function D(e,t){ue++,le[ue]=e.current,e.current=t}var pe=de(null),me=de(null),he=de(null),ge=de(null);function O(e,t){switch(D(he,t),D(me,e),D(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}fe(pe),D(pe,e)}function _e(){fe(pe),fe(me),fe(he)}function ve(e){e.memoizedState!==null&&D(ge,e);var t=pe.current,n=Ud(t,e.type);t!==n&&(D(me,e),D(pe,n))}function ye(e){me.current===e&&(fe(pe),fe(me)),ge.current===e&&(fe(ge),Qf._currentValue=ce)}var be,xe;function k(e){if(be===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);be=t&&t[1]||``,xe=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+be+e+xe}var Se=!1;function Ce(e,t){if(!e||Se)return``;Se=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -11,13 +11,13 @@ Error generating stack: `+e.message+`
|
|
|
11
11
|
|
|
12
12
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
13
13
|
|
|
14
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return z.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Rr=`DialogDescriptionWarning`,zr=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ir(Rr).contentName}}.`;return z.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Br=dr,Vr=_r,Hr=yr,Ur=Cr,Wr=Or,Gr=Ar,Kr=Mr,qr=`rovingFocusGroup.onEntryFocus`,Jr={bubbles:!1,cancelable:!0},Yr=`RovingFocusGroup`,[Xr,Zr,Qr]=wn(Yr),[$r,ei]=xn(Yr,[Qr]),[ti,ni]=$r(Yr),ri=z.forwardRef((e,t)=>(0,B.jsx)(Xr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(Xr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(ii,{...e,ref:t})})}));ri.displayName=Yr;var ii=z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=z.useRef(null),p=_n(t,f),m=Pn(a),[h,g]=Tn({prop:o,defaultProp:s??null,onChange:c,caller:Yr}),[_,v]=z.useState(!1),y=Fn(l),b=Zr(n),x=z.useRef(!1),[ee,S]=z.useState(0);return z.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(qr,y),()=>e.removeEventListener(qr,y)},[y]),(0,B.jsx)(ti,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:z.useCallback(e=>g(e),[g]),onItemShiftTab:z.useCallback(()=>v(!0),[]),onFocusableItemAdd:z.useCallback(()=>S(e=>e+1),[]),onFocusableItemRemove:z.useCallback(()=>S(e=>e-1),[]),children:(0,B.jsx)(N.div,{tabIndex:_||ee===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:P(e.onMouseDown,()=>{x.current=!0}),onFocus:P(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(qr,Jr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);ui([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:P(e.onBlur,()=>v(!1))})})}),ai=`RovingFocusGroupItem`,oi=z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Mn(),l=a||c,u=ni(ai,n),d=u.currentTabStopId===l,f=Zr(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return z.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,B.jsx)(Xr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,B.jsx)(N.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:P(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:P(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:P(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=li(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?di(n,r+1):n.slice(r+1)}setTimeout(()=>ui(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});oi.displayName=ai;var si={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function ci(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function li(e,t,n){let r=ci(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return si[r]}function ui(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function di(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fi=ri,pi=oi,mi=[`Enter`,` `],hi=[`ArrowDown`,`PageUp`,`Home`],gi=[`ArrowUp`,`PageDown`,`End`],_i=[...hi,...gi],vi={ltr:[...mi,`ArrowRight`],rtl:[...mi,`ArrowLeft`]},yi={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},bi=`Menu`,[xi,Si,Ci]=wn(bi),[wi,Ti]=xn(bi,[Ci,Rn,ei]),Ei=Rn(),Di=ei(),[Oi,ki]=wi(bi),[Ai,ji]=wi(bi),Mi=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Ei(t),[c,l]=z.useState(null),u=z.useRef(!1),d=Fn(a),f=Pn(i);return z.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,B.jsx)(zn,{...s,children:(0,B.jsx)(Oi,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,B.jsx)(Ai,{scope:t,onClose:z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Mi.displayName=bi;var V=`MenuAnchor`,Ni=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Ei(n);return(0,B.jsx)(Hn,{...i,...r,ref:t})});Ni.displayName=V;var Pi=`MenuPortal`,[Fi,Ii]=wi(Pi,{forceMount:void 0}),Li=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ki(Pi,t);return(0,B.jsx)(Fi,{scope:t,forceMount:n,children:(0,B.jsx)(En,{present:n||a.open,children:(0,B.jsx)(On,{asChild:!0,container:i,children:r})})})};Li.displayName=Pi;var Ri=`MenuContent`,[zi,Bi]=wi(Ri),Vi=z.forwardRef((e,t)=>{let n=Ii(Ri,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ki(Ri,e.__scopeMenu),o=ji(Ri,e.__scopeMenu);return(0,B.jsx)(xi.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(En,{present:r||a.open,children:(0,B.jsx)(xi.Slot,{scope:e.__scopeMenu,children:o.modal?(0,B.jsx)(Hi,{...i,ref:t}):(0,B.jsx)(Ui,{...i,ref:t})})})})}),Hi=z.forwardRef((e,t)=>{let n=ki(Ri,e.__scopeMenu),r=z.useRef(null),i=_n(t,r);return z.useEffect(()=>{let e=r.current;if(e)return Nn(e)},[]),(0,B.jsx)(Gi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ui=z.forwardRef((e,t)=>{let n=ki(Ri,e.__scopeMenu);return(0,B.jsx)(Gi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Wi=vn(`MenuContent.ScrollLock`),Gi=z.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=ki(Ri,n),_=ji(Ri,n),v=Ei(n),y=Di(n),b=Si(n),[x,ee]=z.useState(null),S=z.useRef(null),C=_n(t,S,g.onContentChange),te=z.useRef(0),ne=z.useRef(``),w=z.useRef(0),re=z.useRef(null),ie=z.useRef(`right`),ae=z.useRef(0),oe=m?kn:z.Fragment,se=m?{as:Wi,allowPinchZoom:!0}:void 0,T=e=>{let t=ne.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=ka(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){ne.current=t,window.clearTimeout(te.current),t!==``&&(te.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};z.useEffect(()=>()=>window.clearTimeout(te.current),[]),jn();let E=z.useCallback(e=>ie.current===re.current?.side&&ja(e,re.current?.area),[]);return(0,B.jsx)(zi,{scope:n,searchRef:ne,onItemEnter:z.useCallback(e=>{E(e)&&e.preventDefault()},[E]),onItemLeave:z.useCallback(e=>{E(e)||(S.current?.focus(),ee(null))},[E]),onTriggerLeave:z.useCallback(e=>{E(e)&&e.preventDefault()},[E]),pointerGraceTimerRef:w,onPointerGraceIntentChange:z.useCallback(e=>{re.current=e},[]),children:(0,B.jsx)(oe,{...se,children:(0,B.jsx)(Dn,{asChild:!0,trapped:i,onMountAutoFocus:P(a,e=>{e.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,B.jsx)(An,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,B.jsx)(fi,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:ee,onEntryFocus:P(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,B.jsx)(Vn,{role:`menu`,"aria-orientation":`vertical`,"data-state":wa(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:C,style:{outline:`none`,...h.style},onKeyDown:P(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&T(e.key));let i=S.current;if(e.target!==i||!_i.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);gi.includes(e.key)&&a.reverse(),Da(a)}),onBlur:P(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(te.current),ne.current=``)}),onPointerMove:P(e.onPointerMove,Ma(e=>{let t=e.target,n=ae.current!==e.clientX;e.currentTarget.contains(t)&&n&&(ie.current=e.clientX>ae.current?`right`:`left`,ae.current=e.clientX)}))})})})})})})});Vi.displayName=Ri;var Ki=`MenuGroup`,qi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`group`,...r,ref:t})});qi.displayName=Ki;var Ji=`MenuLabel`,Yi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{...r,ref:t})});Yi.displayName=Ji;var Xi=`MenuItem`,Zi=`menu.itemSelect`,Qi=z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=z.useRef(null),o=ji(Xi,e.__scopeMenu),s=Bi(Xi,e.__scopeMenu),c=_n(t,a),l=z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Zi,{bubbles:!0,cancelable:!0});e.addEventListener(Zi,e=>r?.(e),{once:!0}),bn(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,B.jsx)($i,{...i,ref:c,disabled:n,onClick:P(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:P(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:P(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||mi.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Qi.displayName=Xi;var $i=z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Bi(Xi,n),s=Di(n),c=z.useRef(null),l=_n(t,c),[u,d]=z.useState(!1),[f,p]=z.useState(``);return z.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,B.jsx)(xi.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,B.jsx)(pi,{asChild:!0,...s,focusable:!r,children:(0,B.jsx)(N.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:P(e.onPointerMove,Ma(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:P(e.onPointerLeave,Ma(e=>o.onItemLeave(e))),onFocus:P(e.onFocus,()=>d(!0)),onBlur:P(e.onBlur,()=>d(!1))})})})}),ea=`MenuCheckboxItem`,ta=z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,B.jsx)(la,{scope:e.__scopeMenu,checked:n,children:(0,B.jsx)(Qi,{role:`menuitemcheckbox`,"aria-checked":Ta(n)?`mixed`:n,...i,ref:t,"data-state":Ea(n),onSelect:P(i.onSelect,()=>r?.(Ta(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ta.displayName=ea;var na=`MenuRadioGroup`,[ra,ia]=wi(na,{value:void 0,onValueChange:()=>{}}),aa=z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Fn(r);return(0,B.jsx)(ra,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,B.jsx)(qi,{...i,ref:t})})});aa.displayName=na;var oa=`MenuRadioItem`,sa=z.forwardRef((e,t)=>{let{value:n,...r}=e,i=ia(oa,e.__scopeMenu),a=n===i.value;return(0,B.jsx)(la,{scope:e.__scopeMenu,checked:a,children:(0,B.jsx)(Qi,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ea(a),onSelect:P(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});sa.displayName=oa;var ca=`MenuItemIndicator`,[la,ua]=wi(ca,{checked:!1}),da=z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=ua(ca,n);return(0,B.jsx)(En,{present:r||Ta(a.checked)||a.checked===!0,children:(0,B.jsx)(N.span,{...i,ref:t,"data-state":Ea(a.checked)})})});da.displayName=ca;var fa=`MenuSeparator`,pa=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});pa.displayName=fa;var ma=`MenuArrow`,ha=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Ei(n);return(0,B.jsx)(Bn,{...i,...r,ref:t})});ha.displayName=ma;var ga=`MenuSub`,[_a,va]=wi(ga),ya=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=ki(ga,t),o=Ei(t),[s,c]=z.useState(null),[l,u]=z.useState(null),d=Fn(i);return z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,B.jsx)(zn,{...o,children:(0,B.jsx)(Oi,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,B.jsx)(_a,{scope:t,contentId:Mn(),triggerId:Mn(),trigger:s,onTriggerChange:c,children:n})})})};ya.displayName=ga;var ba=`MenuSubTrigger`,xa=z.forwardRef((e,t)=>{let n=ki(ba,e.__scopeMenu),r=ji(ba,e.__scopeMenu),i=va(ba,e.__scopeMenu),a=Bi(ba,e.__scopeMenu),o=z.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=z.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return z.useEffect(()=>u,[u]),z.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,B.jsx)(Ni,{asChild:!0,...l,children:(0,B.jsx)($i,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":wa(n.open),...e,ref:hn(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:P(e.onPointerMove,Ma(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:P(e.onPointerLeave,Ma(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:P(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||vi[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});xa.displayName=ba;var Sa=`MenuSubContent`,Ca=z.forwardRef((e,t)=>{let n=Ii(Ri,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ki(Ri,e.__scopeMenu),o=ji(Ri,e.__scopeMenu),s=va(Sa,e.__scopeMenu),c=z.useRef(null),l=_n(t,c);return(0,B.jsx)(xi.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(En,{present:r||a.open,children:(0,B.jsx)(xi.Slot,{scope:e.__scopeMenu,children:(0,B.jsx)(Gi,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:P(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:P(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:P(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=yi[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Ca.displayName=Sa;function wa(e){return e?`open`:`closed`}function Ta(e){return e===`indeterminate`}function Ea(e){return Ta(e)?`indeterminate`:e?`checked`:`unchecked`}function Da(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Oa(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function ka(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Oa(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Aa(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function ja(e,t){return t?Aa({x:e.clientX,y:e.clientY},t):!1}function Ma(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Na=Mi,Pa=Ni,Fa=Li,Ia=Vi,La=qi,Ra=Yi,za=Qi,Ba=ta,Va=aa,Ha=sa,Ua=da,Wa=pa,Ga=ha,Ka=xa,qa=Ca,Ja=`DropdownMenu`,[Ya,Xa]=xn(Ja,[Ti]),Za=Ti(),[Qa,$a]=Ya(Ja),eo=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Za(t),l=z.useRef(null),[u,d]=Tn({prop:i,defaultProp:a??!1,onChange:o,caller:Ja});return(0,B.jsx)(Qa,{scope:t,triggerId:Mn(),triggerRef:l,contentId:Mn(),open:u,onOpenChange:d,onOpenToggle:z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,B.jsx)(Na,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};eo.displayName=Ja;var to=`DropdownMenuTrigger`,no=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=$a(to,n),o=Za(n);return(0,B.jsx)(Pa,{asChild:!0,...o,children:(0,B.jsx)(N.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:hn(t,a.triggerRef),onPointerDown:P(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:P(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});no.displayName=to;var ro=`DropdownMenuPortal`,io=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Za(t);return(0,B.jsx)(Fa,{...r,...n})};io.displayName=ro;var ao=`DropdownMenuContent`,oo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$a(ao,n),a=Za(n),o=z.useRef(!1);return(0,B.jsx)(Ia,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:P(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:P(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});oo.displayName=ao;var so=`DropdownMenuGroup`,co=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(La,{...i,...r,ref:t})});co.displayName=so;var lo=`DropdownMenuLabel`,uo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ra,{...i,...r,ref:t})});uo.displayName=lo;var H=`DropdownMenuItem`,U=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(za,{...i,...r,ref:t})});U.displayName=H;var fo=`DropdownMenuCheckboxItem`,po=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ba,{...i,...r,ref:t})});po.displayName=fo;var mo=`DropdownMenuRadioGroup`,ho=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Va,{...i,...r,ref:t})});ho.displayName=mo;var go=`DropdownMenuRadioItem`,_o=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ha,{...i,...r,ref:t})});_o.displayName=go;var vo=`DropdownMenuItemIndicator`,yo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ua,{...i,...r,ref:t})});yo.displayName=vo;var bo=`DropdownMenuSeparator`,xo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Wa,{...i,...r,ref:t})});xo.displayName=bo;var So=`DropdownMenuArrow`,Co=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ga,{...i,...r,ref:t})});Co.displayName=So;var wo=`DropdownMenuSubTrigger`,To=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ka,{...i,...r,ref:t})});To.displayName=wo;var Eo=`DropdownMenuSubContent`,Do=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(qa,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Do.displayName=Eo;var Oo=eo,ko=no,Ao=io,jo=oo,Mo=uo,No=U,Po=xo,Fo=`Label`,Io=z.forwardRef((e,t)=>(0,B.jsx)(N.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Io.displayName=Fo;var Lo=Io;function Ro(e,t){return z.useReducer((e,n)=>t[e][n]??e,e)}var zo=`ScrollArea`,[Bo,Vo]=xn(zo),[Ho,Uo]=Bo(zo),Wo=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=z.useState(null),[l,u]=z.useState(null),[d,f]=z.useState(null),[p,m]=z.useState(null),[h,g]=z.useState(null),[_,v]=z.useState(0),[y,b]=z.useState(0),[x,ee]=z.useState(!1),[S,C]=z.useState(!1),te=_n(t,e=>c(e)),ne=Pn(i);return(0,B.jsx)(Ho,{scope:n,type:r,dir:ne,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:ee,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:S,onScrollbarYEnabledChange:C,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,B.jsx)(N.div,{dir:ne,...o,ref:te,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});Wo.displayName=zo;var Go=`ScrollAreaViewport`,Ko=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=Uo(Go,n),s=_n(t,z.useRef(null),o.onViewportChange);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,B.jsx)(N.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,B.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});Ko.displayName=Go;var qo=`ScrollAreaScrollbar`,Jo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Uo(qo,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return z.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,B.jsx)(Yo,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,B.jsx)(Xo,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,B.jsx)(Zo,{...r,ref:t,forceMount:n}):i.type===`always`?(0,B.jsx)(Qo,{...r,ref:t}):null});Jo.displayName=qo;var Yo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Uo(qo,e.__scopeScrollArea),[a,o]=z.useState(!1);return z.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,B.jsx)(En,{present:n||a,children:(0,B.jsx)(Zo,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Xo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Uo(qo,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=vs(()=>c(`SCROLL_END`),100),[s,c]=Ro(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return z.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),z.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,B.jsx)(En,{present:n||s!==`hidden`,children:(0,B.jsx)(Qo,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:P(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:P(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),Zo=z.forwardRef((e,t)=>{let n=Uo(qo,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=z.useState(!1),s=e.orientation===`horizontal`,c=vs(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return ys(n.viewport,c),ys(n.content,c),(0,B.jsx)(En,{present:r||a,children:(0,B.jsx)(Qo,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),Qo=z.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=Uo(qo,e.__scopeScrollArea),a=z.useRef(null),o=z.useRef(0),[s,c]=z.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=ds(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return ps(e,o.current,s,t)}return n===`horizontal`?(0,B.jsx)($o,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=ms(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,B.jsx)(es,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=ms(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),$o=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Uo(qo,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=_n(t,c,a.onScrollbarXChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(rs,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":fs(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),gs(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:us(o.paddingLeft),paddingEnd:us(o.paddingRight)}})}})}),es=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Uo(qo,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=_n(t,c,a.onScrollbarYChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(rs,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":fs(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),gs(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:us(o.paddingTop),paddingEnd:us(o.paddingBottom)}})}})}),[ts,ns]=Bo(qo),rs=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=Uo(qo,n),[m,h]=z.useState(null),g=_n(t,e=>h(e)),_=z.useRef(null),v=z.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Fn(u),ee=Fn(c),S=vs(d,10);function C(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return z.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&x(e,b)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,b,x]),z.useEffect(ee,[r,ee]),ys(m,S),ys(p.content,S),(0,B.jsx)(ts,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Fn(a),onThumbPointerUp:Fn(o),onThumbPositionChange:ee,onThumbPointerDown:Fn(s),children:(0,B.jsx)(N.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:P(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),C(e))}),onPointerMove:P(e.onPointerMove,C),onPointerUp:P(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})}),is=`ScrollAreaThumb`,as=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=ns(is,e.__scopeScrollArea);return(0,B.jsx)(En,{present:n||i.hasThumb,children:(0,B.jsx)(os,{ref:t,...r})})}),os=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=Uo(is,n),o=ns(is,n),{onThumbPositionChange:s}=o,c=_n(t,e=>o.onThumbChange(e)),l=z.useRef(void 0),u=vs(()=>{l.current&&=(l.current(),void 0)},100);return z.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=_s(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,B.jsx)(N.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:P(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:P(e.onPointerUp,o.onThumbPointerUp)})});as.displayName=is;var ss=`ScrollAreaCorner`,cs=z.forwardRef((e,t)=>{let n=Uo(ss,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,B.jsx)(ls,{...e,ref:t}):null});cs.displayName=ss;var ls=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=Uo(ss,n),[a,o]=z.useState(0),[s,c]=z.useState(0),l=!!(a&&s);return ys(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),ys(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,B.jsx)(N.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function us(e){return e?parseInt(e,10):0}function ds(e,t){let n=e/t;return isNaN(n)?0:n}function fs(e){let t=ds(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function ps(e,t,n,r=`ltr`){let i=fs(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return hs([c,l],d)(e)}function ms(e,t,n=`ltr`){let r=fs(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Un(e,n===`ltr`?[0,o]:[o*-1,0]);return hs([0,o],[0,s])(c)}function hs(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function gs(e,t){return e>0&&e<t}var _s=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function vs(e,t){let n=Fn(e),r=z.useRef(0);return z.useEffect(()=>()=>window.clearTimeout(r.current),[]),z.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function ys(e,t){let n=Fn(t);Cn(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var bs=Wo,xs=Ko,Ss=cs,Cs=`Separator`,ws=`horizontal`,Ts=[`horizontal`,`vertical`],Es=z.forwardRef((e,t)=>{let{decorative:n,orientation:r=ws,...i}=e,a=Ds(r)?r:ws,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,B.jsx)(N.div,{"data-orientation":a,...o,...i,ref:t})});Es.displayName=Cs;function Ds(e){return Ts.includes(e)}var Os=Es,ks=`Switch`,[As,js]=xn(ks),[Ms,Ns]=As(ks),Ps=z.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=z.useState(null),m=_n(t,e=>p(e)),h=z.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=Tn({prop:i,defaultProp:a??!1,onChange:l,caller:ks});return(0,B.jsxs)(Ms,{scope:n,checked:_,disabled:s,children:[(0,B.jsx)(N.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":zs(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:P(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,B.jsx)(Rs,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Ps.displayName=ks;var Fs=`SwitchThumb`,Is=z.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Ns(Fs,n);return(0,B.jsx)(N.span,{"data-state":zs(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Is.displayName=Fs;var Ls=`SwitchBubbleInput`,Rs=z.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=z.useRef(null),s=_n(o,a),c=In(n),l=Ln(t);return z.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,B.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});Rs.displayName=Ls;function zs(e){return e?`checked`:`unchecked`}var Bs=Ps,Vs=Is,Hs=`Tabs`,[Us,Ws]=xn(Hs,[ei]),Gs=ei(),[Ks,qs]=Us(Hs),Js=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Pn(s),[d,f]=Tn({prop:r,onChange:i,defaultProp:a??``,caller:Hs});return(0,B.jsx)(Ks,{scope:n,baseId:Mn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,B.jsx)(N.div,{dir:u,"data-orientation":o,...l,ref:t})})});Js.displayName=Hs;var Ys=`TabsList`,Xs=z.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=qs(Ys,n),o=Gs(n);return(0,B.jsx)(fi,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,B.jsx)(N.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Xs.displayName=Ys;var Zs=`TabsTrigger`,Qs=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=qs(Zs,n),s=Gs(n),c=tc(o.baseId,r),l=nc(o.baseId,r),u=r===o.value;return(0,B.jsx)(pi,{asChild:!0,...s,focusable:!i,active:u,children:(0,B.jsx)(N.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:P(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:P(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:P(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Qs.displayName=Zs;var $s=`TabsContent`,ec=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=qs($s,n),c=tc(s.baseId,r),l=nc(s.baseId,r),u=r===s.value,d=z.useRef(u);return z.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,B.jsx)(En,{present:i||u,children:({present:n})=>(0,B.jsx)(N.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});ec.displayName=$s;function tc(e,t){return`${e}-trigger-${t}`}function nc(e,t){return`${e}-content-${t}`}var rc=Js,ic=Xs,ac=Qs,oc=ec,[sc,cc]=xn(`Tooltip`,[Rn]),lc=Rn(),uc=`TooltipProvider`,dc=700,fc=`tooltip.open`,[pc,mc]=sc(uc),hc=e=>{let{__scopeTooltip:t,delayDuration:n=dc,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=z.useRef(!0),s=z.useRef(!1),c=z.useRef(0);return z.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,B.jsx)(pc,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:z.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:z.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:z.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};hc.displayName=uc;var gc=`Tooltip`,[_c,vc]=sc(gc),yc=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=mc(gc,e.__scopeTooltip),l=lc(t),[u,d]=z.useState(null),f=Mn(),p=z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=z.useRef(!1),[_,v]=Tn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(fc))):c.onClose(),a?.(e)},caller:gc}),y=z.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),ee=z.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return z.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,B.jsx)(zn,{...l,children:(0,B.jsx)(_c,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:z.useCallback(()=>{c.isOpenDelayedRef.current?ee():b()},[c.isOpenDelayedRef,ee,b]),onTriggerLeave:z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};yc.displayName=gc;var bc=`TooltipTrigger`,xc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=vc(bc,n),a=mc(bc,n),o=lc(n),s=_n(t,z.useRef(null),i.onTriggerChange),c=z.useRef(!1),l=z.useRef(!1),u=z.useCallback(()=>c.current=!1,[]);return z.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,B.jsx)(Hn,{asChild:!0,...o,children:(0,B.jsx)(N.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:P(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:P(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:P(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:P(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:P(e.onBlur,i.onClose),onClick:P(e.onClick,i.onClose)})})});xc.displayName=bc;var Sc=`TooltipPortal`,[Cc,wc]=sc(Sc,{forceMount:void 0}),Tc=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=vc(Sc,t);return(0,B.jsx)(Cc,{scope:t,forceMount:n,children:(0,B.jsx)(En,{present:n||a.open,children:(0,B.jsx)(On,{asChild:!0,container:i,children:r})})})};Tc.displayName=Sc;var Ec=`TooltipContent`,Dc=z.forwardRef((e,t)=>{let n=wc(Ec,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=vc(Ec,e.__scopeTooltip);return(0,B.jsx)(En,{present:r||o.open,children:o.disableHoverableContent?(0,B.jsx)(Mc,{side:i,...a,ref:t}):(0,B.jsx)(Oc,{side:i,...a,ref:t})})}),Oc=z.forwardRef((e,t)=>{let n=vc(Ec,e.__scopeTooltip),r=mc(Ec,e.__scopeTooltip),i=z.useRef(null),a=_n(t,i),[o,s]=z.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=z.useCallback(()=>{s(null),d(!1)},[d]),p=z.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Ic(r,Fc(r,n.getBoundingClientRect())),a=Lc(t.getBoundingClientRect());s(zc([...i,...a])),d(!0)},[d]);return z.useEffect(()=>()=>f(),[f]),z.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),z.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Rc(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,B.jsx)(Mc,{...e,ref:a})}),[kc,Ac]=sc(gc,{isInside:!1}),jc=gn(`TooltipContent`),Mc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=vc(Ec,n),l=lc(n),{onClose:u}=c;return z.useEffect(()=>(document.addEventListener(fc,u),()=>document.removeEventListener(fc,u)),[u]),z.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,B.jsx)(An,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,B.jsxs)(Vn,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,B.jsx)(jc,{children:r}),(0,B.jsx)(kc,{scope:n,isInside:!0,children:(0,B.jsx)(ar,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Dc.displayName=Ec;var Nc=`TooltipArrow`,Pc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=lc(n);return Ac(Nc,n).isInside?null:(0,B.jsx)(Bn,{...i,...r,ref:t})});Pc.displayName=Nc;function Fc(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Ic(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Lc(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Rc(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function zc(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Bc(t)}function Bc(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Vc=hc,Hc=yc,Uc=xc,Wc=Tc,Gc=Dc,Kc=Pc;function qc({delayDuration:e=0,...t}){return(0,B.jsx)(Vc,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Jc({...e}){return(0,B.jsx)(Hc,{"data-slot":`tooltip`,...e})}function Yc({...e}){return(0,B.jsx)(Uc,{"data-slot":`tooltip-trigger`,...e})}function Xc({className:e,sideOffset:t=0,children:n,...r}){return(0,B.jsx)(Wc,{children:(0,B.jsxs)(Gc,{"data-slot":`tooltip-content`,sideOffset:t,className:O(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[n,(0,B.jsx)(Kc,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function W(e){return A(e)}function Zc(){let e=W(e=>e.pairs);return(0,z.useMemo)(()=>{let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t},[e])}function Qc(e){let t=W(e=>e.messages),n=W(e=>e.tasks),r=W(e=>e.pairs),i=W(e=>e.inboxReadCursors),a=W(e=>e.inboxArchivedThreads);return(0,z.useMemo)(()=>{if(!e)return{unread:0,needsHumanResponse:!1,pendingPairInvite:!1,claimableTasks:0,total:0,score:0};let o=t.filter(t=>fn(t)===e.id&&!Ft(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>Vt(e)&&Bt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>Rt(i,e.id,t)).length,l=sn(e),u=r.find(t=>(t.status===`active`||t.status===`pending`)&&(t.requesterId===e.id||t.targetId===e.id))?.status===`pending`,d=n.filter(t=>un(t)&&ln(t.target,e)).length+t.filter(t=>Nt(t)&&ln(t.to,e)).length;return{unread:c,needsHumanResponse:l,pendingPairInvite:u,claimableTasks:d,total:c+ +!!l+ +!!u+d,score:c*10+(l?8:0)+(u?4:0)+d*2}},[e,t,n,r,i,a])}function $c(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.showOffline),r=W(e=>e.agentSort),i=W(e=>e.agentSortDir),a=W(e=>e.agentPresetFilter),o=W(e=>e.agentStatusFilter),s=W(e=>e.agentTagFilter),c=W(e=>e.agentHostFilter),l=W(e=>e.managedPolicies),u=W(e=>e.pairs);return(0,z.useMemo)(()=>{let d=Ut(e,t,l);if(a){let e=el(u);d=tl(d,a,yt.getState().now,e)}n||(d=d.filter(e=>e.status!==`offline`)),o===`starting`?d=d.filter(e=>e.status!==`offline`&&!e.ready):o&&(d=d.filter(e=>e.status===o)),s&&(d=d.filter(e=>(e.tags||[]).includes(s))),c&&(d=d.filter(e=>(e.machine||``)===c));let f=i===`desc`?-1:1;return[...d].sort((e,t)=>r===`name`?M(e).localeCompare(M(t))*f:r===`lastSeen`?(new Date(t.lastSeen).getTime()-new Date(e.lastSeen).getTime())*f||M(e).localeCompare(M(t)):r===`created`?(new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())*f||M(e).localeCompare(M(t)):(($t[e.status]??9)-($t[t.status]??9))*f||M(e).localeCompare(M(t)))},[e,t,n,l,r,i,a,o,s,c,u,xt()])}function el(e){let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t}function tl(e,t,n,r){switch(t){case`active`:return e.filter(e=>e.status!==`offline`);case`offline_stale`:return e.filter(e=>e.status===`offline`||dn(n,e));case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return kt().includes(t)?e.filter(e=>nn(e)===t):e}}function nl(){let e=W(e=>e.messages),t=W(e=>e.inboxReadCursors),n=W(e=>e.inboxArchivedThreads),r=W(e=>e.inboxDrafts),i=W(e=>e.agentsById),a=W(e=>e.coordinatorMutes);return(0,z.useMemo)(()=>{let o=new Map;for(let t of e){if(Ft(t))continue;let e=fn(t);e&&(o.has(e)||o.set(e,{id:e,peer:e,messages:[],lastMessage:null,previewMessage:null,attention:{unread:0,needsHumanResponse:!1,score:0},archived:!1,draft:``}),o.get(e).messages.push(t))}for(let e of o.values()){e.messages.sort((e,t)=>e.id-t.id),e.lastMessage=e.messages[e.messages.length-1]||null;let o=null;for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n&&!Pt(n)){o=n;break}}e.previewMessage=o||e.lastMessage;let s=a.includes(e.peer),c=s?0:e.messages.filter(n=>Rt(t,e.peer,n)).length,l=s?!1:sn(i[e.peer]);e.attention={unread:c,needsHumanResponse:l,score:c*10+(l?8:0)};let u=Number(n[e.peer]||0);e.archived=!!(e.lastMessage?.id&&u>=e.lastMessage.id),e.draft=r[e.peer]||``}return[...o.values()].sort((e,t)=>{let n=(t.attention.score||0)-(e.attention.score||0);return n===0?(t.lastMessage?.id||0)-(e.lastMessage?.id||0):n})},[e,t,n,r,i,a])}function rl(){let e=nl(),t=W(e=>e.agents),n=W(e=>e.showBuiltIns),r=W(e=>e.showOffline),i=W(e=>e.managedPolicies),a=W(e=>e.pairs),o=W(e=>e.tasks),s=W(e=>e.messages),c=(0,z.useMemo)(()=>new Set(Ut(t,n,i).filter(e=>r||e.status!==`offline`).map(e=>e.id)),[t,n,r,i]);return(0,z.useMemo)(()=>{let l=e.filter(e=>!e.archived&&c.has(e.peer)).reduce((e,t)=>e+(t.attention.unread||0),0),u=Ut(t,n,i).filter(e=>(r||e.status!==`offline`)&&sn(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(un).length+s.filter(Nt).length;return{unreadInbox:l,needsHumanResponse:u,pendingPairInvites:d,claimableTasks:f,total:l+u+d+f}},[e,c,t,n,r,i,a,o,s])}function il(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>Ut(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function al(){let e=W(e=>e.agents);return(0,z.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function ol(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.showOffline),r=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let i=Ut(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function sl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(Ut(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function cl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(Ut(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function ll(){let e=W(e=>e.tasks),t=W(e=>e.messages);return(0,z.useMemo)(()=>{let n=e.filter(e=>(e.kind??`claim`)===`claim`).filter(e=>!zt.has(e.status)).map(e=>({id:`task-`+e.id,sourceType:`task`,title:e.title,body:e.body,severity:e.severity||`info`,status:e.status,owner:e.claimedBy||``,target:e.target,source:e.source,channel:e.channel||``,updatedAt:e.updatedAt||e.createdAt,createdAt:e.createdAt,claimable:un(e),task:e})),r=t.filter(Nt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:Qt(e),severity:`warning`,status:e.claimedBy?`claimed`:`open`,owner:e.claimedBy||``,target:e.to,source:`message`,channel:e.channel||``,updatedAt:e.claimedAt||e.createdAt,createdAt:e.createdAt,claimable:Nt(e),message:e}));return[...n,...r].sort((e,t)=>{let n=Number(t.claimable)-Number(e.claimable);if(n!==0)return n;let r={critical:0,warning:1,info:2},i=(r[e.severity]??9)-(r[t.severity]??9);return i===0?on(e.updatedAt)-on(t.updatedAt):i})},[e,t])}function ul(){let e=W(e=>e.commandQuery),t=W(e=>e.agents),n=W(e=>e.agentsById),r=W(e=>e.showBuiltIns),i=W(e=>e.showOffline),a=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let n=Ut(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=k(),c=[dl(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),dl(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),dl(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),dl(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),dl(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),dl(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),dl(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>dl(`msg-`+e.id,`Message agent: `+M(e),e.id,`Send`,`messageAgent`,{agentId:e.id})),...n.filter(e=>e.providerCapabilities?.liveSession?.inject===!0).slice(0,8).map(e=>dl(`pair-`+e.id,`Pair: `+M(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>dl(`tag-`+e,`Filter tag: `+e,`#`+e,`Tag`,`filterTag`,{tag:e}))],l=e.trim().toLowerCase();return(l?c.filter(e=>e.search.includes(l)):c).slice(0,24)},[e,t,n,r,i,a])}function dl(e,t,n,r,i,a){return{id:e,title:t,subtitle:n,icon:r,action:i,payload:a,search:`${t}\n${n}\n${i}`.toLowerCase()}}function fl({className:e,size:t=`default`,...n}){return(0,B.jsx)(Bs,{"data-slot":`switch`,"data-size":t,className:O(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,B.jsx)(Vs,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function pl({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,B.jsx)(Os,{"data-slot":`separator`,decorative:n,orientation:t,className:O(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}function ml({...e}){return(0,B.jsx)(Oo,{"data-slot":`dropdown-menu`,...e})}function hl({...e}){return(0,B.jsx)(ko,{"data-slot":`dropdown-menu-trigger`,...e})}function gl({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,B.jsx)(Ao,{children:(0,B.jsx)(jo,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:O(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function _l({className:e,inset:t,variant:n=`default`,...r}){return(0,B.jsx)(No,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:O(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function vl({className:e,inset:t,...n}){return(0,B.jsx)(Mo,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:O(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function yl({className:e,...t}){return(0,B.jsx)(Po,{"data-slot":`dropdown-menu-separator`,className:O(`-mx-1 my-1 h-px bg-border`,e),...t})}var bl={LayoutDashboard:pt,MessageCircle:Ie,Bot:x,Server:d,MessagesSquare:it,Plug:c,PlugZap:y,Activity:pe,Link:Pe,Mail:nt,ListChecks:He,ClipboardList:Be,CalendarClock:o,AreaChart:f,Settings:p,Workflow:et,BrainCircuit:ie,FolderTree:_,Shield:st,Wrench:Ke,UserCog:Ye,Lightbulb:ot,Users:at,Boxes:g,PackagePlus:D,FileText:b};function xl(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var Sl=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function Cl(){let e=A(e=>e.notifications),t=A(e=>e.notificationUnread),n=A(e=>e.notificationSettings),r=A(e=>e.notificationPermission),i=A(e=>e.set),a=A(e=>e.openNotification),o=A(e=>e.markNotificationsRead),s=A(e=>e.clearNotifications),c=A(e=>e.requestBrowserNotifications),l=t>0?ht:se;function u(e){i({notificationSettings:{...n,...e}})}return(0,B.jsxs)(ml,{onOpenChange:e=>{e&&o()},children:[(0,B.jsx)(hl,{asChild:!0,children:(0,B.jsxs)(`button`,{className:`relative flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,B.jsx)(l,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Notifications`}),t>0&&(0,B.jsx)(F,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:t})]})}),(0,B.jsxs)(gl,{align:`start`,side:`right`,className:`w-80 p-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 py-1`,children:[(0,B.jsx)(vl,{className:`p-0`,children:`Notifications`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`button`,{type:`button`,title:`Mark read`,onClick:o,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,B.jsx)(E,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(`button`,{type:`button`,title:`Clear`,onClick:s,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,B.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})]}),(0,B.jsxs)(`div`,{className:`px-1.5 py-1.5 space-y-2`,children:[(0,B.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app notifications`}),(0,B.jsx)(fl,{size:`sm`,checked:n.enabled,onCheckedChange:e=>u({enabled:e})})]}),(0,B.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Browser notifications`}),(0,B.jsx)(fl,{size:`sm`,checked:n.browserEnabled&&r===`granted`,disabled:r===`unsupported`,onCheckedChange:e=>{e&&r!==`granted`?c():u({browserEnabled:e})}})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Sl.map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>u({[e]:!n[e]}),className:O(`rounded border px-2 py-1 text-[11px] transition-colors`,n[e]?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-accent`),children:t},e))})]}),(0,B.jsx)(yl,{}),(0,B.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:e.length===0?(0,B.jsx)(`div`,{className:`px-1.5 py-8 text-center text-xs text-muted-foreground`,children:`No notifications`}):e.slice(0,20).map(e=>(0,B.jsxs)(_l,{onSelect:t=>{t.preventDefault(),a(e)},className:`flex flex-col items-start gap-0.5 px-2 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,B.jsx)(`span`,{className:O(`h-1.5 w-1.5 rounded-full`,e.severity===`error`?`bg-red-400`:e.severity===`warning`?`bg-yellow-400`:`bg-blue-400`)}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.title}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:xl(e)})]}),(0,B.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.body}),e.routing?.reason&&(0,B.jsxs)(`span`,{className:`line-clamp-1 text-[10px] text-muted-foreground/80`,children:[`routed because `,e.routing.reason]})]},e.id))})]})]})}function wl(){let e=A(e=>e.theme),t=A(e=>e.set);return(0,B.jsxs)(ml,{children:[(0,B.jsx)(hl,{asChild:!0,children:(0,B.jsxs)(`button`,{className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,B.jsx)(he,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Theme`}),(0,B.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:mn.find(t=>t.id===e)?.label})]})}),(0,B.jsx)(gl,{align:`start`,side:`right`,className:`w-40`,children:mn.map(n=>(0,B.jsxs)(_l,{onSelect:()=>t({theme:n.id}),children:[(0,B.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,B.jsx)(ct,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function Tl(){let e=A(e=>e.view),t=A(e=>e.switchView),n=A(e=>e.connected),r=A(e=>e.showOffline),i=A(e=>e.showBuiltIns),a=A(e=>e.autoRefresh),o=A(e=>e.stats),s=A(e=>e.openCommandPalette),c=A(e=>e.set),l=A(e=>e.startAutoRefresh),u=A(e=>e.stopAutoRefresh),d=rl(),f=il();function p(e){return e===`overview`&&d.total>0?(0,B.jsx)(F,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.total}):e===`chat`&&d.unreadInbox>0?(0,B.jsx)(F,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.unreadInbox}):e===`agents`?(0,B.jsx)(F,{variant:`secondary`,className:`ml-auto text-[10px] px-1.5 py-0`,children:f}):e===`pairs`&&d.pendingPairInvites>0?(0,B.jsx)(F,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.pendingPairInvites}):e===`work`&&d.claimableTasks>0?(0,B.jsx)(F,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.claimableTasks}):null}return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`nav`,{className:`flex-1 overflow-y-auto py-2 px-2`,children:rn.map(n=>{let r=bl[n.icon]||x;return(0,B.jsxs)(`button`,{onClick:()=>t(n.key),className:O(`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors my-0.5`,e===n.key?`bg-primary text-primary-foreground`:`text-foreground hover:bg-accent`),children:[(0,B.jsx)(r,{className:`w-4 h-4 shrink-0`}),n.label,p(n.key)]},n.key)})}),(0,B.jsxs)(`div`,{className:`mt-auto border-t border-border p-4 space-y-3 text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:O(`w-2 h-2 rounded-full`,n?`bg-emerald-500`:`bg-red-500 animate-pulse`)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:n?`Live`:`Reconnecting...`})]}),(0,B.jsxs)(`button`,{onClick:s,className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,B.jsx)(xe,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Command palette`}),(0,B.jsx)(`kbd`,{className:`ml-auto text-[10px] bg-muted px-1.5 py-0.5 rounded`,children:`⌘K`})]}),(0,B.jsx)(Cl,{}),(0,B.jsx)(wl,{}),(0,B.jsx)(pl,{}),(0,B.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Show offline`}),(0,B.jsx)(fl,{checked:r,onCheckedChange:e=>c({showOffline:e})})]}),(0,B.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`System agents`}),(0,B.jsx)(fl,{checked:i,onCheckedChange:e=>c({showBuiltIns:e})})]}),(0,B.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Auto refresh`}),(0,B.jsx)(fl,{checked:a,onCheckedChange:e=>{c({autoRefresh:e}),e?l():u()}})]}),o.version&&(0,B.jsxs)(`div`,{className:`text-muted-foreground pt-1`,children:[`v`,o.version]})]})]})}function El(){return(0,B.jsxs)(`aside`,{className:`hidden xl:flex w-[250px] min-w-[250px] h-[calc(100dvh-var(--sat))] sticky top-[var(--sat)] flex-col border-r border-border bg-card`,children:[(0,B.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,B.jsx)(oe,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,B.jsx)(Tl,{})]})}function Dl(){let e=A(e=>e.mobileMenuOpen),t=A(e=>e.set);return(0,z.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&t({mobileMenuOpen:!1})}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:O(`xl:hidden fixed inset-0 z-40 bg-black/50 transition-opacity duration-200`,e?`opacity-100`:`opacity-0 pointer-events-none`),onClick:()=>t({mobileMenuOpen:!1})}),(0,B.jsxs)(`aside`,{inert:!e,className:O(`xl:hidden fixed inset-y-0 left-0 z-50 w-[280px] flex flex-col pt-[var(--sat)] bg-card border-r border-border transition-transform duration-200 ease-out`,e?`translate-x-0`:`-translate-x-full`),children:[(0,B.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,B.jsx)(oe,{className:`w-4 h-4 text-primary`}),`Agent Relay`,(0,B.jsx)(`button`,{onClick:()=>t({mobileMenuOpen:!1}),className:`ml-auto p-1 text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Close menu`,children:(0,B.jsx)(be,{className:`w-4 h-4`})})]}),(0,B.jsx)(Tl,{})]})]})}var Ol=500*1024,kl={bash:`bash`,c:`c`,conf:`properties`,cpp:`cpp`,cs:`csharp`,css:`css`,csv:`csv`,cts:`typescript`,diff:`diff`,dockerfile:`dockerfile`,env:`dotenv`,gemspec:`ruby`,go:`go`,graphql:`graphql`,h:`c`,hcl:`hcl`,hpp:`cpp`,html:`html`,ini:`ini`,java:`java`,js:`javascript`,json:`json`,jsonc:`jsonc`,jsx:`jsx`,kt:`kotlin`,less:`less`,log:`log`,lua:`lua`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,plist:`xml`,podspec:`ruby`,properties:`properties`,py:`python`,rake:`ruby`,rb:`ruby`,rs:`rust`,scss:`scss`,sh:`bash`,sql:`sql`,svelte:`svelte`,swift:`swift`,toml:`toml`,ts:`typescript`,tsx:`tsx`,txt:`text`,vue:`vue`,webmanifest:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},Al={".bashrc":`bash`,".env":`dotenv`,".eslintrc":`json`,".gitignore":`gitignore`,".npmrc":`properties`,".prettierrc":`json`,".swiftformat":`properties`,".swiftlint.yml":`yaml`,".watchmanconfig":`json`,"app.config":`json`,"app.webmanifest":`json`,berksfile:`ruby`,brewfile:`ruby`,"bun.lock":`json`,capfile:`ruby`,cartfile:`ruby`,"composer.lock":`json`,dangerfile:`ruby`,"deno.lock":`json`,fastfile:`ruby`,"flake.lock":`json`,gemfile:`ruby`,guardfile:`ruby`,podfile:`ruby`,rakefile:`ruby`,dockerfile:`dockerfile`,makefile:`make`},jl=null;function Ml(){return jl??=R(()=>import(`./bundle-web-BLavPdXe.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),jl}function Nl(e){return new TextEncoder().encode(e).length}function Pl(e){return e.split(`/`).filter(Boolean).pop()||e}function Fl(e){let t=e?.slice(0,240).split(/\r?\n/,1)[0]?.toLowerCase()||``;return t.startsWith(`#!`)?/\b(bash|dash|ksh|sh|zsh)\b/.test(t)?`bash`:/\bfish\b/.test(t)?`fish`:/\b(ts-node|tsx)\b/.test(t)?`typescript`:/\b(node|bun|deno)\b/.test(t)?`javascript`:/\bpython[0-9.]*\b/.test(t)?`python`:/\bruby\b/.test(t)?`ruby`:/\bswift\b/.test(t)?`swift`:/\bperl\b/.test(t)?`perl`:/\bphp\b/.test(t)?`php`:null:null}function Il(e,t,n,r){if(n)return n;let i=Pl(e).toLowerCase();if(Al[i])return Al[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=Fl(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&kl[o]?kl[o]:t?.includes(`json`)?`json`:t?.includes(`javascript`)?`javascript`:t?.includes(`typescript`)?`typescript`:t?.includes(`xml`)?`xml`:t?.includes(`yaml`)||t?.includes(`yml`)?`yaml`:t?.includes(`shellscript`)?`bash`:null}function Ll(e,t,n,r){let i=Il(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var Rl=(0,z.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=A(e=>e.theme),o=mn.find(e=>e.id===a)?.dark??!0,s=(0,z.useMemo)(()=>Il(t,n,r,e)||`text`,[e,r,n,t]),c=Nl(e)>Ol,[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(!1);function h(){return(0,B.jsx)(Wn,{value:e,label:`Copy code`,copiedLabel:`Copied code`,size:`icon`,variant:`ghost`,className:`absolute right-2 top-2 h-7 w-7 bg-background/80 opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted group-hover/code:opacity-100 focus-visible:opacity-100`})}return(0,z.useEffect)(()=>{if(c||s===`text`||s===`log`){u(``),f(!1),m(!1);return}let t=!1;return f(!0),m(!1),Ml().then(({codeToHtml:t})=>t(e,{lang:s,theme:o?`github-dark-default`:`github-light-default`})).then(e=>{t||u(e)}).catch(()=>{t||(u(``),m(!0))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[e,o,s,c]),d?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(Xe,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):c||p||!l?(0,B.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,B.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,children:e||` `})]}):(0,B.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,B.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:l}})]})}),zl=(0,z.lazy)(()=>R(()=>import(`./markdown-preview-impl-C5D-B-9S.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function G(e){return(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading preview…`}),children:(0,B.jsx)(zl,{...e})})}var Bl=e(_t(),1);function K({src:e,alt:t,onClose:n}){let[r,i]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let e=document.body.style.overflow;document.body.style.overflow=`hidden`;function t(e){e.key===`Escape`&&n()}return document.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,document.removeEventListener(`keydown`,t)}},[n]),(0,B.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/95`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 p-2`,children:[(0,B.jsx)(`button`,{type:`button`,className:`rounded-full bg-white/10 p-2 text-white/70 hover:bg-white/20 hover:text-white`,onClick:()=>i(!r),title:r?`Fit to screen`:`Actual size`,children:r?(0,B.jsx)(Ue,{className:`h-4 w-4`}):(0,B.jsx)($e,{className:`h-4 w-4`})}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-full bg-white/10 p-2 text-white/70 hover:bg-white/20 hover:text-white`,onClick:n,title:`Close`,children:(0,B.jsx)(be,{className:`h-4 w-4`})})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 ${r?`overflow-auto`:`flex items-center justify-center overflow-hidden p-4`}`,onClick:r?void 0:n,children:(0,B.jsx)(`img`,{src:e,alt:t,className:r?`max-w-none`:`max-h-full max-w-full cursor-zoom-in object-contain`,onClick:e=>{e.stopPropagation(),i(!r)}})})]})}function q({src:e,alt:t=``,className:n,style:r}){let[i,a]=(0,z.useState)(!1);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`img`,{src:e,alt:t,className:`${n||``} cursor-zoom-in`,style:r,onClick:()=>a(!0)}),i&&(0,Bl.createPortal)((0,B.jsx)(K,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var J=`agent-relay:file-git-status`;function Vl(){try{return window.localStorage.getItem(J)!==`off`}catch{return!0}}function Hl(e){try{window.localStorage.setItem(J,e?`on`:`off`)}catch{}}function Ul(e){switch(e){case`staged`:return{dot:`bg-green-500`,text:`text-green-400`,label:`Staged`};case`unstaged`:return{dot:`bg-amber-500`,text:`text-amber-400`,label:`Modified (unstaged)`};case`staged-unstaged`:return{dot:`bg-amber-500`,text:`text-green-400`,label:`Staged + unstaged changes`};case`untracked`:return{dot:`bg-sky-500`,text:`text-sky-400`,label:`Untracked`};default:return null}}function Wl(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function Gl({status:e}){let t=Ul(e);return t?(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.dot}`,title:t.label}):null}function Kl(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function ql(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function Jl(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function Yl(e,t,n){return Jl(e,t)?`markdown`:Ll(e,t,void 0,n)?`code`:null}function Xl(e){return`agent-relay:file-view-mode:${e}`}function Zl(e){try{let t=window.localStorage.getItem(Xl(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function Ql(e,t){try{window.localStorage.setItem(Xl(e),t)}catch{}}function $l(e,t){let n=ql(e,t);if(n===`/`)return[{label:`/`,path:t}];let r=n.split(`/`).filter(Boolean),i=[{label:`/`,path:t}];for(let e=0;e<r.length;e++)i.push({label:r[e],path:`${t.replace(/\/+$/,``)}/${r.slice(0,e+1).join(`/`)}`});return i}function eu(e,t){let n=A(e=>e.apiCall),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(``);return(0,z.useEffect)(()=>{if(!e||!t){i(null),c(``);return}let r=!1;return o(!0),c(``),n(`GET`,`/orchestrators/${encodeURIComponent(e)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{r||i(e)}).catch(e=>{r||(i(null),c(jt(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function tu(e,t,n=!1){let r=A(e=>e.apiCall),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(``);return(0,z.useEffect)(()=>{if(!e||!t){a(null),l(``);return}let i=!1;return s(!0),l(``),r(`GET`,Wl(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(jt(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function nu({content:e,line:t,lineRef:n}){return(0,B.jsx)(`div`,{className:`w-full py-2 font-mono text-xs leading-5`,children:e.split(`
|
|
15
|
-
`).map((e,r)=>{let i=r+1,a=i===t;return(0,B.jsxs)(`div`,{ref:a?n:void 0,className:`grid grid-cols-[2.5rem_minmax(0,1fr)] px-1 sm:grid-cols-[4rem_minmax(0,1fr)] sm:px-2 ${a?`bg-primary/15`:``}`,children:[(0,B.jsx)(`div`,{className:`select-none pr-2 text-right text-muted-foreground sm:pr-3`,children:i}),(0,B.jsx)(`pre`,{className:`overflow-hidden whitespace-pre-wrap break-words`,children:e||` `})]},i)})})}function ru({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:a,error:o}=tu(e,t,r);return(0,z.useEffect)(()=>{n(o)},[o,n]),t?a?(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Xe,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):o?(0,B.jsx)(`div`,{className:`h-full bg-muted/20`}):i?(0,B.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(ae,{className:`h-3.5 w-3.5 text-blue-400`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,B.jsxs)(F,{variant:`outline`,className:`text-[10px]`,children:[i.entries.length,` items`]})]}),(0,B.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[i.entries.map(e=>{let t=e.type===`directory`?ae:de,n=Ul(e.gitStatus);return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[(0,B.jsx)(t,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${n?.text??``}`,children:e.name}),e.symlink&&(0,B.jsx)(je,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(Gl,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Kl(e.size)})]},e.path)}),i.entries.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]})]}):null:(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a directory to preview`})}function iu({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:a,error:o}=eu(e,t),s=(0,z.useRef)(null),[c,l]=(0,z.useState)(`raw`);(0,z.useEffect)(()=>{r(o)},[o,r]),(0,z.useEffect)(()=>{n>0&&s.current?.scrollIntoView({block:`center`})},[i,n]),(0,z.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){l(`raw`);return}let e=Yl(i.path,i.mediaType,i.content);l(e?Zl(e):`raw`)},[i?.path,i?.encoding,i?.mediaType,i?.content,n]);function u(e,t){l(e),t&&Ql(t,e)}if(!t)return(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a file to preview`});if(a)return(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Xe,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(o)return(0,B.jsx)(`div`,{className:`h-full bg-muted/20`});if(!i)return null;if(i.encoding===`base64`)return(0,B.jsxs)(`div`,{className:`flex h-full flex-col bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(de,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,B.jsx)(Wn,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:Kl(i.size)})]}),(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,B.jsx)(q,{src:`data:${i.mediaType};base64,${i.content??``}`,alt:i.name,className:`max-h-full max-w-full object-contain`,style:{imageRendering:i.mediaType===`image/svg+xml`?`auto`:void 0}})})]});if(i.encoding===`binary`)return(0,B.jsxs)(`div`,{className:`p-4 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:i.name}),(0,B.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:i.truncated?`File too large to preview.`:`Binary file preview is not available.`}),(0,B.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,B.jsx)(F,{variant:`secondary`,children:i.mediaType}),(0,B.jsx)(F,{variant:`outline`,children:Kl(i.size)})]})]});let d=i.content??``,f=Jl(i.path,i.mediaType),p=!f&&Ll(i.path,i.mediaType,void 0,d),m=f||p,h=f?`markdown`:p?`code`:null;return(0,B.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(de,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,B.jsx)(Wn,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),i.truncated&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:`truncated`}),(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:Kl(i.size)}),m&&(0,B.jsxs)(`div`,{className:`flex shrink-0 rounded-md border border-border bg-muted/40 p-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`raw`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`raw`,h),children:`Raw`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`rendered`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`rendered`,h),children:f?`Rendered`:`Highlighted`})]})]}),c===`rendered`&&f&&(0,B.jsx)(G,{content:d,path:i.path}),c===`rendered`&&p&&(0,B.jsx)(Rl,{content:d,path:i.path,mediaType:i.mediaType}),c===`raw`&&(0,B.jsx)(nu,{content:d,line:n,lineRef:s})]})}function au({overlay:e=!1}){let t=A(e=>e.apiCall),n=A(e=>e.orchestrators),r=A(e=>e.fileOrchestratorId),i=A(e=>e.filePath),a=A(e=>e.fileSelectedPath),o=A(e=>e.fileSelectedLine),s=A(e=>e.set),c=A(e=>e.closeFileOverlay),l=A(e=>e.openOrchestratorSpawnAt),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(i),[m,h]=(0,z.useState)(!1),[g,v]=(0,z.useState)(``),[y,b]=(0,z.useState)(``),[x,ee]=(0,z.useState)(Vl),S=(0,z.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),C=n.find(e=>e.id===r)||S[0];(0,z.useEffect)(()=>{if(!C)return;let e={};r||(e.fileOrchestratorId=C.id),i||(e.filePath=C.baseDir),Object.keys(e).length&&s(e)},[r,i,C,s]),(0,z.useEffect)(()=>p(i),[i]);async function ne(e=i){if(!(!C||!e)){h(!0),v(``);try{let n=await t(`GET`,Wl(C.id,e,x));d(n),s({filePath:n.path}),p(n.path),b(``)}catch(e){v(jt(e))}finally{h(!1)}}}(0,z.useEffect)(()=>{ne(i)},[C?.id,i,x]);function w(e){ee(e),Hl(e)}function re(e){s({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function ie(e){b(``),e.type===`directory`?s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):s({fileSelectedPath:e.path,fileSelectedLine:0})}function oe(){if(!C)return;let t=f.trim()||i||C.baseDir;e&&c(),l({orchestratorId:C.id,cwd:t})}let se=u?$l(u.path,u.baseDir):[],T=g||y;return(0,B.jsxs)(`div`,{className:e?`flex h-full flex-col`:`flex h-[calc(100dvh-5rem)] flex-col gap-3 md:gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,B.jsx)(_,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,B.jsxs)(`select`,{value:C?.id||``,onChange:e=>re(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[S.length===0&&(0,B.jsx)(`option`,{value:``,children:`No online orchestrators`}),S.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.hostname||e.id},e.id))]}),e&&(0,B.jsx)(I,{size:`icon`,variant:`ghost`,className:`ml-auto h-8 w-8`,onClick:c,title:`Close`,children:(0,B.jsx)(be,{className:`h-4 w-4`})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,B.jsx)(L,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s({filePath:f,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:C?.baseDir||`Path`}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>ne(f),disabled:m||!C,children:[m?(0,B.jsx)(Xe,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(te,{className:`h-3.5 w-3.5`}),`Open`]}),(0,B.jsxs)(I,{size:`sm`,className:`gap-1`,onClick:oe,disabled:!C,children:[(0,B.jsx)(ue,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`sm:hidden`,children:`Spawn`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:`Spawn from here`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:`Show git status colors`,children:[(0,B.jsx)(Re,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,B.jsx)(fl,{checked:x,onCheckedChange:w})]})]}),se.length>0&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${a?`hidden md:flex`:``}`,children:se.map((e,t)=>(0,B.jsxs)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 font-mono hover:bg-accent hover:text-foreground`,onClick:()=>s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}),children:[e.label,t<se.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),T&&(0,B.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:T}),(0,B.jsxs)(`div`,{className:`grid min-h-0 flex-1 overflow-hidden md:rounded-md md:border md:border-border md:grid-cols-[22rem_minmax(0,1fr)] ${a?``:`rounded-md border border-border`}`,children:[(0,B.jsxs)(`div`,{className:`min-h-0 overflow-auto border-b border-border bg-card md:border-b-0 md:border-r ${a?`hidden md:block`:``}`,children:[u?.parent&&(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent`,onClick:()=>s({filePath:u.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(We,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{children:`Parent directory`})]}),u?.entries.map(e=>{let t=a===e.path||i===e.path,n=e.type===`directory`?ae:de,r=Ul(e.gitStatus);return(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent ${t?`bg-accent`:``}`,onClick:()=>ie(e),children:[(0,B.jsx)(n,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${r?.text??``}`,children:e.name}),e.symlink&&(0,B.jsx)(je,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(Gl,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Kl(e.size)})]},e.path)}),!m&&u&&u.entries.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden ${a?``:`hidden md:flex`}`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs text-muted-foreground hover:text-foreground md:hidden`,onClick:()=>s({fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(We,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(iu,{orchestratorId:C?.id||``,selectedPath:a,line:o,onReadError:b})})]})]})]})}function ou(){return(0,B.jsx)(au,{})}function su(){return A(e=>e.fileOverlayOpen)?(0,B.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/80 backdrop-blur-sm`,children:(0,B.jsx)(`div`,{className:`absolute inset-4 overflow-hidden rounded-md border border-border bg-background p-4 shadow-xl`,children:(0,B.jsx)(au,{overlay:!0})})}):null}function cu(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;window.history.pushState({sheetGuard:!0},``),n.current=!0;function t(){n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,window.history.back())}},[e])}function lu({...e}){return cu(e.open,e.onOpenChange),(0,B.jsx)(Br,{"data-slot":`sheet`,...e})}function uu({...e}){return(0,B.jsx)(Kr,{"data-slot":`sheet-close`,...e})}function du({...e}){return(0,B.jsx)(Vr,{"data-slot":`sheet-portal`,...e})}function fu({className:e,...t}){return(0,B.jsx)(Hr,{"data-slot":`sheet-overlay`,className:O(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function pu({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,B.jsxs)(du,{children:[(0,B.jsx)(fu,{}),(0,B.jsxs)(Ur,{"data-slot":`sheet-content`,"data-side":n,className:O(`fixed z-50 flex flex-col bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out overflow-hidden max-w-[100dvw] data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,e),...i,children:[t,r&&(0,B.jsx)(Kr,{"data-slot":`sheet-close`,asChild:!0,children:(0,B.jsxs)(I,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,B.jsx)(be,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function mu({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`sheet-header`,className:O(`flex flex-col gap-0.5 p-4`,e),...t})}function hu({className:e,...t}){return(0,B.jsx)(Wr,{"data-slot":`sheet-title`,className:O(`font-heading text-base font-medium text-foreground`,e),...t})}function gu({className:e,orientation:t=`horizontal`,...n}){return(0,B.jsx)(rc,{"data-slot":`tabs`,"data-orientation":t,className:O(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var _u=yn(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function vu({className:e,variant:t=`default`,...n}){return(0,B.jsx)(ic,{"data-slot":`tabs-list`,"data-variant":t,className:O(_u({variant:t}),e),...n})}function yu({className:e,...t}){return(0,B.jsx)(ac,{"data-slot":`tabs-trigger`,className:O(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function bu({className:e,...t}){return(0,B.jsx)(oc,{"data-slot":`tabs-content`,className:O(`flex-1 text-sm outline-none`,e),...t})}function xu({agent:e,now:t,className:n}){return(0,B.jsx)(`span`,{className:O(`inline-block w-2.5 h-2.5 rounded-full shrink-0`,It(e,t),n)})}function Su({className:e}){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,B.jsx)(`path`,{d:`m3.127 10.604 3.135-1.76.053-.153-.053-.085H6.11l-.525-.032-1.791-.048-1.554-.065-1.505-.08-.38-.081L0 7.832l.036-.234.32-.214.455.04 1.009.069 1.513.105 1.097.064 1.626.17h.259l.036-.105-.089-.065-.068-.064-1.566-1.062-1.695-1.121-.887-.646-.48-.327-.243-.306-.104-.67.435-.48.585.04.15.04.593.456 1.267.981 1.654 1.218.242.202.097-.068.012-.049-.109-.181-.9-1.626-.96-1.655-.428-.686-.113-.411a2 2 0 0 1-.068-.484l.496-.674L4.446 0l.662.089.279.242.411.94.666 1.48 1.033 2.014.302.597.162.553.06.17h.105v-.097l.085-1.134.157-1.392.154-1.792.052-.504.25-.605.497-.327.387.186.319.456-.045.294-.19 1.23-.37 1.93-.243 1.29h.142l.161-.16.654-.868 1.097-1.372.484-.545.565-.601.363-.287h.686l.505.751-.226.775-.707.895-.585.759-.839 1.13-.524.904.048.072.125-.012 1.897-.403 1.024-.186 1.223-.21.553.258.06.263-.218.536-1.307.323-1.533.307-2.284.54-.028.02.032.04 1.029.098.44.024h1.077l2.005.15.525.346.315.424-.053.323-.807.411-3.631-.863-.872-.218h-.12v.073l.726.71 1.331 1.202 1.667 1.55.084.383-.214.302-.226-.032-1.464-1.101-.565-.497-1.28-1.077h-.084v.113l.295.432 1.557 2.34.08.718-.112.234-.404.141-.444-.08-.911-1.28-.94-1.44-.759-1.291-.093.053-.448 4.821-.21.246-.484.186-.403-.307-.214-.496.214-.98.258-1.28.21-1.016.19-1.263.112-.42-.008-.028-.092.012-.953 1.307-1.448 1.957-1.146 1.227-.274.109-.477-.247.045-.44.266-.39 1.586-2.018.956-1.25.617-.723-.004-.105h-.036l-4.212 2.736-.75.096-.324-.302.04-.496.154-.162 1.267-.871z`})})}function Cu({className:e}){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,B.jsx)(`path`,{d:`M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365 2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5z`})})}var wu={claude:Su,anthropic:Su,codex:Cu,openai:Cu},Tu={claude:`text-orange-400`,anthropic:`text-orange-400`};function Eu({provider:e,className:t}){let n=e.toLowerCase(),r=wu[n];return r?(0,B.jsx)(`span`,{role:`img`,"aria-label":e,title:e,className:`inline-flex shrink-0`,children:(0,B.jsx)(r,{className:O(Tu[n],t)})}):(0,B.jsx)(`span`,{className:`capitalize`,children:e})}var Du={codex:`text-blue-400 bg-blue-500/10 border-blue-500/25`,claude:`text-orange-400 bg-orange-500/10 border-orange-500/25`,user:`text-emerald-400 bg-emerald-500/10 border-emerald-500/25`,system:`text-purple-400 bg-purple-500/10 border-purple-500/25`,channel:`text-blue-400 bg-blue-500/10 border-blue-500/25`,agent:`text-zinc-400 bg-zinc-500/10 border-zinc-500/25`},Ou={codex:ve,claude:Su,user:Ce,system:d,channel:it,agent:x};function ku({agent:e,className:t}){let n=nn(e),r=Ou[n]||x;return(0,B.jsx)(`span`,{className:O(`inline-flex items-center justify-center w-5 h-5 rounded-md border text-sm`,Du[n]||Du.agent,t),children:(0,B.jsx)(r,{className:`w-3.5 h-3.5`})})}function Au({agent:e,compact:t=!1}){let n=Bu(e);return n.length===0?null:(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.slice(0,t?4:void 0).map(e=>(0,B.jsx)(F,{variant:`outline`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))})}function ju({agent:e,compact:t=!1,className:n=``}){let r=Nu(e);return(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 ${n}`,children:r.map(e=>{let n=e.Icon;return(0,B.jsxs)(`span`,{title:e.title,className:`inline-flex h-5 min-w-5 items-center justify-center gap-1 rounded-md border px-1.5 text-[10px] leading-none ${e.className}`,children:[(0,B.jsx)(n,{className:`h-3 w-3 shrink-0`}),!t&&(0,B.jsx)(`span`,{children:e.label})]},e.key)})})}function Mu({agent:e}){let t=e.context;if(!t)return null;let n=Uu(t);if(n===null)return(0,B.jsxs)(`div`,{className:`space-y-1`,title:Wu(t),children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:`collecting`}),(0,B.jsx)(`span`,{children:`--`})]}),(0,B.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,B.jsx)(`div`,{className:`h-full w-0 bg-muted-foreground/30`})})]});let r=Math.round(n*100),i=r>=80?`bg-red-500`:r>=60?`bg-yellow-500`:`bg-emerald-500`;return(0,B.jsxs)(`div`,{className:`space-y-1`,title:Wu(t),children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:t.lifecycleState}),(0,B.jsxs)(`span`,{children:[r,`%`]})]}),(0,B.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,B.jsx)(`div`,{className:`h-full ${i}`,style:{width:`${Math.max(0,Math.min(100,r))}%`}})})]})}function Nu(e){let t=Pu(e),n=Fu(e),r=Iu(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?h:Le,className:t?`border-sky-500/30 bg-sky-500/10 text-sky-300`:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`},n,r]}function Pu(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Fu(e){let t=String(e.providerCapabilities?.session?.approvalMode||e.meta?.approvalMode||`guarded`).toLowerCase();return t===`open`?{key:`approval`,label:`Open`,title:`Approval mode: open`,Icon:ke,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`}:t===`read-only`?{key:`approval`,label:`Read-only`,title:`Approval mode: read-only`,Icon:Qe,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:Te,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Iu(e){let t=Lu(e.meta?.workspace),n=Tt(t.requestedMode)||Tt(e.meta?.workspaceMode),r=Tt(t.mode),i=n&&n!==`inherit`?n:r&&n!==`inherit`?r:`default`;return i===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:Re,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:i===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:T,iconColor:`text-cyan-300`,className:`border-cyan-500/30 bg-cyan-500/10 text-cyan-300`}:{key:`workspace`,label:`Default`,title:r?`Workspace: default/inherit, resolved to ${r}`:`Workspace: default/inherit`,Icon:Se,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function Lu(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Ru(e){let t=Lu(e.meta?.workspace),n=Tt(t.repoRoot)||Tt(t.sourceCwd)||Tt(e.meta?.cwd);return n?Ht(n,2):``}function zu(e){return!!(e.context||e.providerCapabilities?.context)}function Bu(e){let t=e.providerCapabilities,n=e.context,r=[];t?.lifecycle.managed?r.push(`managed`):t&&r.push(`bridge`),t?.session?.approvalMode===`read-only`?r.push(`read-only`):t?.session?.fileWrite&&r.push(`write`),t?.session?.shell&&r.push(`shell`),(t?.model?.alias||t?.model?.id)&&r.push(String(t.model.alias||t.model.id));let i=cn(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=Uu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function Vu({context:e,expected:t=!!e,size:n=26,className:r}){let i=Uu(e);if(i===null&&!t)return null;let a=n>=24?3:2.5,o=n/2,s=o-a,c=2*Math.PI*s,l=i===null?c:c*(1-i),u=i===null,d=u?`text-muted-foreground`:i>.8?`text-red-400`:i>.5?`text-yellow-400`:`text-emerald-400`,f=u?null:Math.round(i*100);return(0,B.jsxs)(`div`,{className:`relative shrink-0 ${u?`opacity-70`:``} ${r??``}`,style:{width:n,height:n},title:Wu(e),children:[(0,B.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:`rotate-[-90deg]`,children:[(0,B.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,className:`stroke-muted-foreground/20`}),(0,B.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,strokeDasharray:c,strokeDashoffset:l,strokeLinecap:`round`,className:`${d} stroke-current transition-all duration-500`})]}),(0,B.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center font-semibold leading-none ${u?`text-muted-foreground`:d}`,style:{fontSize:n>=24?8:7},children:u?`?`:f})]})}function Hu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${Gu(t.tokensUsed)} / ${Gu(t.tokensMax)}`:t.tokensUsed?Gu(t.tokensUsed):t.tokensMax?Gu(t.tokensMax):null}function Uu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function Wu(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=Uu(e),n=`${e.source}/${e.confidence}`,r=Number.isFinite(e.lastUpdatedAt)?new Date(e.lastUpdatedAt).toLocaleString():`unknown`;return t===null?`Context: unknown; ${n}; updated ${r}`:`Context: ${Math.round(t*100)}%; ${n}; updated ${r}`}function Gu(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var Ku=(0,z.lazy)(()=>R(()=>import(`./terminal-viewer-impl-DzvaRjkp.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13,14]),import.meta.url));function Y(e){return e.open?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(Ku,{...e})}):null}function qu({orchestratorId:e,session:t,lines:n=200}){let r=A(e=>e.apiCall),[o,s]=(0,z.useState)([]),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(`provider`),[m,h]=(0,z.useState)(null);async function g(){if(!u)try{s((await r(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${n}${f===`mirror`?`&stream=mirror`:``}`)).lines||[]),h(null)}catch(e){h(jt(e))}}(0,z.useEffect)(()=>{g();let e=setInterval(()=>void g(),1500);return()=>clearInterval(e)},[e,t,u,f]);let _=c?o.filter(e=>e.toLowerCase().includes(c.toLowerCase())):o;return(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`relative min-w-48 flex-1`,children:[(0,B.jsx)(a,{className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground`}),(0,B.jsx)(L,{className:`pl-8`,value:c,onChange:e=>l(e.target.value),placeholder:`Search logs`})]}),(0,B.jsxs)(`div`,{className:`flex rounded-md border border-border overflow-hidden`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>p(`provider`),title:`Provider output`,className:O(`flex items-center gap-1 px-2 py-1.5 text-xs`,f===`provider`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,B.jsx)(ve,{className:`h-3.5 w-3.5`}),` Output`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>p(`mirror`),title:`Session-mirror diagnostics (clean)`,className:O(`flex items-center gap-1 px-2 py-1.5 text-xs border-l border-border`,f===`mirror`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,B.jsx)(w,{className:`h-3.5 w-3.5`}),` Mirror`]})]}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>d(e=>!e),title:u?`Resume logs`:`Pause logs`,children:u?(0,B.jsx)(le,{className:`h-4 w-4`}):(0,B.jsx)(Ze,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>an(`${t}.log`,o.join(`
|
|
14
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return z.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Rr=`DialogDescriptionWarning`,zr=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ir(Rr).contentName}}.`;return z.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Br=dr,Vr=_r,Hr=yr,Ur=Cr,Wr=Or,Gr=Ar,Kr=Mr,qr=`rovingFocusGroup.onEntryFocus`,Jr={bubbles:!1,cancelable:!0},Yr=`RovingFocusGroup`,[Xr,Zr,Qr]=wn(Yr),[$r,ei]=xn(Yr,[Qr]),[ti,ni]=$r(Yr),ri=z.forwardRef((e,t)=>(0,B.jsx)(Xr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(Xr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(ii,{...e,ref:t})})}));ri.displayName=Yr;var ii=z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=z.useRef(null),p=_n(t,f),m=Pn(a),[h,g]=Tn({prop:o,defaultProp:s??null,onChange:c,caller:Yr}),[_,v]=z.useState(!1),y=Fn(l),b=Zr(n),x=z.useRef(!1),[ee,S]=z.useState(0);return z.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(qr,y),()=>e.removeEventListener(qr,y)},[y]),(0,B.jsx)(ti,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:z.useCallback(e=>g(e),[g]),onItemShiftTab:z.useCallback(()=>v(!0),[]),onFocusableItemAdd:z.useCallback(()=>S(e=>e+1),[]),onFocusableItemRemove:z.useCallback(()=>S(e=>e-1),[]),children:(0,B.jsx)(N.div,{tabIndex:_||ee===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:P(e.onMouseDown,()=>{x.current=!0}),onFocus:P(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(qr,Jr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);ui([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:P(e.onBlur,()=>v(!1))})})}),ai=`RovingFocusGroupItem`,oi=z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Mn(),l=a||c,u=ni(ai,n),d=u.currentTabStopId===l,f=Zr(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return z.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,B.jsx)(Xr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,B.jsx)(N.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:P(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:P(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:P(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=li(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?di(n,r+1):n.slice(r+1)}setTimeout(()=>ui(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});oi.displayName=ai;var si={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function ci(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function li(e,t,n){let r=ci(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return si[r]}function ui(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function di(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fi=ri,pi=oi,mi=[`Enter`,` `],hi=[`ArrowDown`,`PageUp`,`Home`],gi=[`ArrowUp`,`PageDown`,`End`],_i=[...hi,...gi],vi={ltr:[...mi,`ArrowRight`],rtl:[...mi,`ArrowLeft`]},yi={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},bi=`Menu`,[xi,Si,Ci]=wn(bi),[wi,Ti]=xn(bi,[Ci,Rn,ei]),Ei=Rn(),Di=ei(),[Oi,ki]=wi(bi),[Ai,ji]=wi(bi),Mi=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Ei(t),[c,l]=z.useState(null),u=z.useRef(!1),d=Fn(a),f=Pn(i);return z.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,B.jsx)(zn,{...s,children:(0,B.jsx)(Oi,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,B.jsx)(Ai,{scope:t,onClose:z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Mi.displayName=bi;var V=`MenuAnchor`,Ni=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Ei(n);return(0,B.jsx)(Hn,{...i,...r,ref:t})});Ni.displayName=V;var Pi=`MenuPortal`,[Fi,Ii]=wi(Pi,{forceMount:void 0}),Li=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ki(Pi,t);return(0,B.jsx)(Fi,{scope:t,forceMount:n,children:(0,B.jsx)(En,{present:n||a.open,children:(0,B.jsx)(On,{asChild:!0,container:i,children:r})})})};Li.displayName=Pi;var Ri=`MenuContent`,[zi,Bi]=wi(Ri),Vi=z.forwardRef((e,t)=>{let n=Ii(Ri,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ki(Ri,e.__scopeMenu),o=ji(Ri,e.__scopeMenu);return(0,B.jsx)(xi.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(En,{present:r||a.open,children:(0,B.jsx)(xi.Slot,{scope:e.__scopeMenu,children:o.modal?(0,B.jsx)(Hi,{...i,ref:t}):(0,B.jsx)(Ui,{...i,ref:t})})})})}),Hi=z.forwardRef((e,t)=>{let n=ki(Ri,e.__scopeMenu),r=z.useRef(null),i=_n(t,r);return z.useEffect(()=>{let e=r.current;if(e)return Nn(e)},[]),(0,B.jsx)(Gi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ui=z.forwardRef((e,t)=>{let n=ki(Ri,e.__scopeMenu);return(0,B.jsx)(Gi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Wi=vn(`MenuContent.ScrollLock`),Gi=z.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=ki(Ri,n),_=ji(Ri,n),v=Ei(n),y=Di(n),b=Si(n),[x,ee]=z.useState(null),S=z.useRef(null),C=_n(t,S,g.onContentChange),te=z.useRef(0),ne=z.useRef(``),w=z.useRef(0),re=z.useRef(null),ie=z.useRef(`right`),ae=z.useRef(0),oe=m?kn:z.Fragment,se=m?{as:Wi,allowPinchZoom:!0}:void 0,T=e=>{let t=ne.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=ka(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){ne.current=t,window.clearTimeout(te.current),t!==``&&(te.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};z.useEffect(()=>()=>window.clearTimeout(te.current),[]),jn();let E=z.useCallback(e=>ie.current===re.current?.side&&ja(e,re.current?.area),[]);return(0,B.jsx)(zi,{scope:n,searchRef:ne,onItemEnter:z.useCallback(e=>{E(e)&&e.preventDefault()},[E]),onItemLeave:z.useCallback(e=>{E(e)||(S.current?.focus(),ee(null))},[E]),onTriggerLeave:z.useCallback(e=>{E(e)&&e.preventDefault()},[E]),pointerGraceTimerRef:w,onPointerGraceIntentChange:z.useCallback(e=>{re.current=e},[]),children:(0,B.jsx)(oe,{...se,children:(0,B.jsx)(Dn,{asChild:!0,trapped:i,onMountAutoFocus:P(a,e=>{e.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,B.jsx)(An,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,B.jsx)(fi,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:ee,onEntryFocus:P(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,B.jsx)(Vn,{role:`menu`,"aria-orientation":`vertical`,"data-state":wa(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:C,style:{outline:`none`,...h.style},onKeyDown:P(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&T(e.key));let i=S.current;if(e.target!==i||!_i.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);gi.includes(e.key)&&a.reverse(),Da(a)}),onBlur:P(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(te.current),ne.current=``)}),onPointerMove:P(e.onPointerMove,Ma(e=>{let t=e.target,n=ae.current!==e.clientX;e.currentTarget.contains(t)&&n&&(ie.current=e.clientX>ae.current?`right`:`left`,ae.current=e.clientX)}))})})})})})})});Vi.displayName=Ri;var Ki=`MenuGroup`,qi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`group`,...r,ref:t})});qi.displayName=Ki;var Ji=`MenuLabel`,Yi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{...r,ref:t})});Yi.displayName=Ji;var Xi=`MenuItem`,Zi=`menu.itemSelect`,Qi=z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=z.useRef(null),o=ji(Xi,e.__scopeMenu),s=Bi(Xi,e.__scopeMenu),c=_n(t,a),l=z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Zi,{bubbles:!0,cancelable:!0});e.addEventListener(Zi,e=>r?.(e),{once:!0}),bn(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,B.jsx)($i,{...i,ref:c,disabled:n,onClick:P(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:P(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:P(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||mi.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Qi.displayName=Xi;var $i=z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Bi(Xi,n),s=Di(n),c=z.useRef(null),l=_n(t,c),[u,d]=z.useState(!1),[f,p]=z.useState(``);return z.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,B.jsx)(xi.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,B.jsx)(pi,{asChild:!0,...s,focusable:!r,children:(0,B.jsx)(N.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:P(e.onPointerMove,Ma(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:P(e.onPointerLeave,Ma(e=>o.onItemLeave(e))),onFocus:P(e.onFocus,()=>d(!0)),onBlur:P(e.onBlur,()=>d(!1))})})})}),ea=`MenuCheckboxItem`,ta=z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,B.jsx)(la,{scope:e.__scopeMenu,checked:n,children:(0,B.jsx)(Qi,{role:`menuitemcheckbox`,"aria-checked":Ta(n)?`mixed`:n,...i,ref:t,"data-state":Ea(n),onSelect:P(i.onSelect,()=>r?.(Ta(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ta.displayName=ea;var na=`MenuRadioGroup`,[ra,ia]=wi(na,{value:void 0,onValueChange:()=>{}}),aa=z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Fn(r);return(0,B.jsx)(ra,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,B.jsx)(qi,{...i,ref:t})})});aa.displayName=na;var oa=`MenuRadioItem`,sa=z.forwardRef((e,t)=>{let{value:n,...r}=e,i=ia(oa,e.__scopeMenu),a=n===i.value;return(0,B.jsx)(la,{scope:e.__scopeMenu,checked:a,children:(0,B.jsx)(Qi,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ea(a),onSelect:P(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});sa.displayName=oa;var ca=`MenuItemIndicator`,[la,ua]=wi(ca,{checked:!1}),da=z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=ua(ca,n);return(0,B.jsx)(En,{present:r||Ta(a.checked)||a.checked===!0,children:(0,B.jsx)(N.span,{...i,ref:t,"data-state":Ea(a.checked)})})});da.displayName=ca;var fa=`MenuSeparator`,pa=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});pa.displayName=fa;var ma=`MenuArrow`,ha=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Ei(n);return(0,B.jsx)(Bn,{...i,...r,ref:t})});ha.displayName=ma;var ga=`MenuSub`,[_a,va]=wi(ga),ya=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=ki(ga,t),o=Ei(t),[s,c]=z.useState(null),[l,u]=z.useState(null),d=Fn(i);return z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,B.jsx)(zn,{...o,children:(0,B.jsx)(Oi,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,B.jsx)(_a,{scope:t,contentId:Mn(),triggerId:Mn(),trigger:s,onTriggerChange:c,children:n})})})};ya.displayName=ga;var ba=`MenuSubTrigger`,xa=z.forwardRef((e,t)=>{let n=ki(ba,e.__scopeMenu),r=ji(ba,e.__scopeMenu),i=va(ba,e.__scopeMenu),a=Bi(ba,e.__scopeMenu),o=z.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=z.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return z.useEffect(()=>u,[u]),z.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,B.jsx)(Ni,{asChild:!0,...l,children:(0,B.jsx)($i,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":wa(n.open),...e,ref:hn(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:P(e.onPointerMove,Ma(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:P(e.onPointerLeave,Ma(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:P(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||vi[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});xa.displayName=ba;var Sa=`MenuSubContent`,Ca=z.forwardRef((e,t)=>{let n=Ii(Ri,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ki(Ri,e.__scopeMenu),o=ji(Ri,e.__scopeMenu),s=va(Sa,e.__scopeMenu),c=z.useRef(null),l=_n(t,c);return(0,B.jsx)(xi.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(En,{present:r||a.open,children:(0,B.jsx)(xi.Slot,{scope:e.__scopeMenu,children:(0,B.jsx)(Gi,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:P(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:P(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:P(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=yi[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Ca.displayName=Sa;function wa(e){return e?`open`:`closed`}function Ta(e){return e===`indeterminate`}function Ea(e){return Ta(e)?`indeterminate`:e?`checked`:`unchecked`}function Da(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Oa(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function ka(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Oa(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Aa(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function ja(e,t){return t?Aa({x:e.clientX,y:e.clientY},t):!1}function Ma(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Na=Mi,Pa=Ni,Fa=Li,Ia=Vi,La=qi,Ra=Yi,za=Qi,Ba=ta,Va=aa,Ha=sa,Ua=da,Wa=pa,Ga=ha,Ka=xa,qa=Ca,Ja=`DropdownMenu`,[Ya,Xa]=xn(Ja,[Ti]),Za=Ti(),[Qa,$a]=Ya(Ja),eo=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Za(t),l=z.useRef(null),[u,d]=Tn({prop:i,defaultProp:a??!1,onChange:o,caller:Ja});return(0,B.jsx)(Qa,{scope:t,triggerId:Mn(),triggerRef:l,contentId:Mn(),open:u,onOpenChange:d,onOpenToggle:z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,B.jsx)(Na,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};eo.displayName=Ja;var to=`DropdownMenuTrigger`,no=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=$a(to,n),o=Za(n);return(0,B.jsx)(Pa,{asChild:!0,...o,children:(0,B.jsx)(N.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:hn(t,a.triggerRef),onPointerDown:P(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:P(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});no.displayName=to;var ro=`DropdownMenuPortal`,io=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Za(t);return(0,B.jsx)(Fa,{...r,...n})};io.displayName=ro;var ao=`DropdownMenuContent`,oo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$a(ao,n),a=Za(n),o=z.useRef(!1);return(0,B.jsx)(Ia,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:P(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:P(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});oo.displayName=ao;var so=`DropdownMenuGroup`,co=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(La,{...i,...r,ref:t})});co.displayName=so;var lo=`DropdownMenuLabel`,uo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ra,{...i,...r,ref:t})});uo.displayName=lo;var H=`DropdownMenuItem`,U=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(za,{...i,...r,ref:t})});U.displayName=H;var fo=`DropdownMenuCheckboxItem`,po=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ba,{...i,...r,ref:t})});po.displayName=fo;var mo=`DropdownMenuRadioGroup`,ho=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Va,{...i,...r,ref:t})});ho.displayName=mo;var go=`DropdownMenuRadioItem`,_o=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ha,{...i,...r,ref:t})});_o.displayName=go;var vo=`DropdownMenuItemIndicator`,yo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ua,{...i,...r,ref:t})});yo.displayName=vo;var bo=`DropdownMenuSeparator`,xo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Wa,{...i,...r,ref:t})});xo.displayName=bo;var So=`DropdownMenuArrow`,Co=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ga,{...i,...r,ref:t})});Co.displayName=So;var wo=`DropdownMenuSubTrigger`,To=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(Ka,{...i,...r,ref:t})});To.displayName=wo;var Eo=`DropdownMenuSubContent`,Do=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Za(n);return(0,B.jsx)(qa,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Do.displayName=Eo;var Oo=eo,ko=no,Ao=io,jo=oo,Mo=uo,No=U,Po=xo,Fo=`Label`,Io=z.forwardRef((e,t)=>(0,B.jsx)(N.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Io.displayName=Fo;var Lo=Io;function Ro(e,t){return z.useReducer((e,n)=>t[e][n]??e,e)}var zo=`ScrollArea`,[Bo,Vo]=xn(zo),[Ho,Uo]=Bo(zo),Wo=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=z.useState(null),[l,u]=z.useState(null),[d,f]=z.useState(null),[p,m]=z.useState(null),[h,g]=z.useState(null),[_,v]=z.useState(0),[y,b]=z.useState(0),[x,ee]=z.useState(!1),[S,C]=z.useState(!1),te=_n(t,e=>c(e)),ne=Pn(i);return(0,B.jsx)(Ho,{scope:n,type:r,dir:ne,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:ee,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:S,onScrollbarYEnabledChange:C,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,B.jsx)(N.div,{dir:ne,...o,ref:te,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});Wo.displayName=zo;var Go=`ScrollAreaViewport`,Ko=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=Uo(Go,n),s=_n(t,z.useRef(null),o.onViewportChange);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,B.jsx)(N.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,B.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});Ko.displayName=Go;var qo=`ScrollAreaScrollbar`,Jo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Uo(qo,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return z.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,B.jsx)(Yo,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,B.jsx)(Xo,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,B.jsx)(Zo,{...r,ref:t,forceMount:n}):i.type===`always`?(0,B.jsx)(Qo,{...r,ref:t}):null});Jo.displayName=qo;var Yo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Uo(qo,e.__scopeScrollArea),[a,o]=z.useState(!1);return z.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,B.jsx)(En,{present:n||a,children:(0,B.jsx)(Zo,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Xo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Uo(qo,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=vs(()=>c(`SCROLL_END`),100),[s,c]=Ro(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return z.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),z.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,B.jsx)(En,{present:n||s!==`hidden`,children:(0,B.jsx)(Qo,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:P(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:P(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),Zo=z.forwardRef((e,t)=>{let n=Uo(qo,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=z.useState(!1),s=e.orientation===`horizontal`,c=vs(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return ys(n.viewport,c),ys(n.content,c),(0,B.jsx)(En,{present:r||a,children:(0,B.jsx)(Qo,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),Qo=z.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=Uo(qo,e.__scopeScrollArea),a=z.useRef(null),o=z.useRef(0),[s,c]=z.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=ds(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return ps(e,o.current,s,t)}return n===`horizontal`?(0,B.jsx)($o,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=ms(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,B.jsx)(es,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=ms(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),$o=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Uo(qo,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=_n(t,c,a.onScrollbarXChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(rs,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":fs(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),gs(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:us(o.paddingLeft),paddingEnd:us(o.paddingRight)}})}})}),es=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Uo(qo,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=_n(t,c,a.onScrollbarYChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(rs,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":fs(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),gs(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:us(o.paddingTop),paddingEnd:us(o.paddingBottom)}})}})}),[ts,ns]=Bo(qo),rs=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=Uo(qo,n),[m,h]=z.useState(null),g=_n(t,e=>h(e)),_=z.useRef(null),v=z.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Fn(u),ee=Fn(c),S=vs(d,10);function C(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return z.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&x(e,b)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,b,x]),z.useEffect(ee,[r,ee]),ys(m,S),ys(p.content,S),(0,B.jsx)(ts,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Fn(a),onThumbPointerUp:Fn(o),onThumbPositionChange:ee,onThumbPointerDown:Fn(s),children:(0,B.jsx)(N.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:P(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),C(e))}),onPointerMove:P(e.onPointerMove,C),onPointerUp:P(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})}),is=`ScrollAreaThumb`,as=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=ns(is,e.__scopeScrollArea);return(0,B.jsx)(En,{present:n||i.hasThumb,children:(0,B.jsx)(os,{ref:t,...r})})}),os=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=Uo(is,n),o=ns(is,n),{onThumbPositionChange:s}=o,c=_n(t,e=>o.onThumbChange(e)),l=z.useRef(void 0),u=vs(()=>{l.current&&=(l.current(),void 0)},100);return z.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=_s(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,B.jsx)(N.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:P(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:P(e.onPointerUp,o.onThumbPointerUp)})});as.displayName=is;var ss=`ScrollAreaCorner`,cs=z.forwardRef((e,t)=>{let n=Uo(ss,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,B.jsx)(ls,{...e,ref:t}):null});cs.displayName=ss;var ls=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=Uo(ss,n),[a,o]=z.useState(0),[s,c]=z.useState(0),l=!!(a&&s);return ys(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),ys(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,B.jsx)(N.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function us(e){return e?parseInt(e,10):0}function ds(e,t){let n=e/t;return isNaN(n)?0:n}function fs(e){let t=ds(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function ps(e,t,n,r=`ltr`){let i=fs(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return hs([c,l],d)(e)}function ms(e,t,n=`ltr`){let r=fs(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Un(e,n===`ltr`?[0,o]:[o*-1,0]);return hs([0,o],[0,s])(c)}function hs(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function gs(e,t){return e>0&&e<t}var _s=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function vs(e,t){let n=Fn(e),r=z.useRef(0);return z.useEffect(()=>()=>window.clearTimeout(r.current),[]),z.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function ys(e,t){let n=Fn(t);Cn(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var bs=Wo,xs=Ko,Ss=cs,Cs=`Separator`,ws=`horizontal`,Ts=[`horizontal`,`vertical`],Es=z.forwardRef((e,t)=>{let{decorative:n,orientation:r=ws,...i}=e,a=Ds(r)?r:ws,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,B.jsx)(N.div,{"data-orientation":a,...o,...i,ref:t})});Es.displayName=Cs;function Ds(e){return Ts.includes(e)}var Os=Es,ks=`Switch`,[As,js]=xn(ks),[Ms,Ns]=As(ks),Ps=z.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=z.useState(null),m=_n(t,e=>p(e)),h=z.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=Tn({prop:i,defaultProp:a??!1,onChange:l,caller:ks});return(0,B.jsxs)(Ms,{scope:n,checked:_,disabled:s,children:[(0,B.jsx)(N.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":zs(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:P(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,B.jsx)(Rs,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Ps.displayName=ks;var Fs=`SwitchThumb`,Is=z.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Ns(Fs,n);return(0,B.jsx)(N.span,{"data-state":zs(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Is.displayName=Fs;var Ls=`SwitchBubbleInput`,Rs=z.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=z.useRef(null),s=_n(o,a),c=In(n),l=Ln(t);return z.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,B.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});Rs.displayName=Ls;function zs(e){return e?`checked`:`unchecked`}var Bs=Ps,Vs=Is,Hs=`Tabs`,[Us,Ws]=xn(Hs,[ei]),Gs=ei(),[Ks,qs]=Us(Hs),Js=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Pn(s),[d,f]=Tn({prop:r,onChange:i,defaultProp:a??``,caller:Hs});return(0,B.jsx)(Ks,{scope:n,baseId:Mn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,B.jsx)(N.div,{dir:u,"data-orientation":o,...l,ref:t})})});Js.displayName=Hs;var Ys=`TabsList`,Xs=z.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=qs(Ys,n),o=Gs(n);return(0,B.jsx)(fi,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,B.jsx)(N.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Xs.displayName=Ys;var Zs=`TabsTrigger`,Qs=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=qs(Zs,n),s=Gs(n),c=tc(o.baseId,r),l=nc(o.baseId,r),u=r===o.value;return(0,B.jsx)(pi,{asChild:!0,...s,focusable:!i,active:u,children:(0,B.jsx)(N.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:P(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:P(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:P(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Qs.displayName=Zs;var $s=`TabsContent`,ec=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=qs($s,n),c=tc(s.baseId,r),l=nc(s.baseId,r),u=r===s.value,d=z.useRef(u);return z.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,B.jsx)(En,{present:i||u,children:({present:n})=>(0,B.jsx)(N.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});ec.displayName=$s;function tc(e,t){return`${e}-trigger-${t}`}function nc(e,t){return`${e}-content-${t}`}var rc=Js,ic=Xs,ac=Qs,oc=ec,[sc,cc]=xn(`Tooltip`,[Rn]),lc=Rn(),uc=`TooltipProvider`,dc=700,fc=`tooltip.open`,[pc,mc]=sc(uc),hc=e=>{let{__scopeTooltip:t,delayDuration:n=dc,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=z.useRef(!0),s=z.useRef(!1),c=z.useRef(0);return z.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,B.jsx)(pc,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:z.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:z.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:z.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};hc.displayName=uc;var gc=`Tooltip`,[_c,vc]=sc(gc),yc=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=mc(gc,e.__scopeTooltip),l=lc(t),[u,d]=z.useState(null),f=Mn(),p=z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=z.useRef(!1),[_,v]=Tn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(fc))):c.onClose(),a?.(e)},caller:gc}),y=z.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),ee=z.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return z.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,B.jsx)(zn,{...l,children:(0,B.jsx)(_c,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:z.useCallback(()=>{c.isOpenDelayedRef.current?ee():b()},[c.isOpenDelayedRef,ee,b]),onTriggerLeave:z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};yc.displayName=gc;var bc=`TooltipTrigger`,xc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=vc(bc,n),a=mc(bc,n),o=lc(n),s=_n(t,z.useRef(null),i.onTriggerChange),c=z.useRef(!1),l=z.useRef(!1),u=z.useCallback(()=>c.current=!1,[]);return z.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,B.jsx)(Hn,{asChild:!0,...o,children:(0,B.jsx)(N.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:P(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:P(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:P(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:P(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:P(e.onBlur,i.onClose),onClick:P(e.onClick,i.onClose)})})});xc.displayName=bc;var Sc=`TooltipPortal`,[Cc,wc]=sc(Sc,{forceMount:void 0}),Tc=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=vc(Sc,t);return(0,B.jsx)(Cc,{scope:t,forceMount:n,children:(0,B.jsx)(En,{present:n||a.open,children:(0,B.jsx)(On,{asChild:!0,container:i,children:r})})})};Tc.displayName=Sc;var Ec=`TooltipContent`,Dc=z.forwardRef((e,t)=>{let n=wc(Ec,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=vc(Ec,e.__scopeTooltip);return(0,B.jsx)(En,{present:r||o.open,children:o.disableHoverableContent?(0,B.jsx)(Mc,{side:i,...a,ref:t}):(0,B.jsx)(Oc,{side:i,...a,ref:t})})}),Oc=z.forwardRef((e,t)=>{let n=vc(Ec,e.__scopeTooltip),r=mc(Ec,e.__scopeTooltip),i=z.useRef(null),a=_n(t,i),[o,s]=z.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=z.useCallback(()=>{s(null),d(!1)},[d]),p=z.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Ic(r,Fc(r,n.getBoundingClientRect())),a=Lc(t.getBoundingClientRect());s(zc([...i,...a])),d(!0)},[d]);return z.useEffect(()=>()=>f(),[f]),z.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),z.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Rc(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,B.jsx)(Mc,{...e,ref:a})}),[kc,Ac]=sc(gc,{isInside:!1}),jc=gn(`TooltipContent`),Mc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=vc(Ec,n),l=lc(n),{onClose:u}=c;return z.useEffect(()=>(document.addEventListener(fc,u),()=>document.removeEventListener(fc,u)),[u]),z.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,B.jsx)(An,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,B.jsxs)(Vn,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,B.jsx)(jc,{children:r}),(0,B.jsx)(kc,{scope:n,isInside:!0,children:(0,B.jsx)(ar,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Dc.displayName=Ec;var Nc=`TooltipArrow`,Pc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=lc(n);return Ac(Nc,n).isInside?null:(0,B.jsx)(Bn,{...i,...r,ref:t})});Pc.displayName=Nc;function Fc(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Ic(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Lc(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Rc(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function zc(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Bc(t)}function Bc(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Vc=hc,Hc=yc,Uc=xc,Wc=Tc,Gc=Dc,Kc=Pc;function qc({delayDuration:e=0,...t}){return(0,B.jsx)(Vc,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Jc({...e}){return(0,B.jsx)(Hc,{"data-slot":`tooltip`,...e})}function Yc({...e}){return(0,B.jsx)(Uc,{"data-slot":`tooltip-trigger`,...e})}function Xc({className:e,sideOffset:t=0,children:n,...r}){return(0,B.jsx)(Wc,{children:(0,B.jsxs)(Gc,{"data-slot":`tooltip-content`,sideOffset:t,className:O(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[n,(0,B.jsx)(Kc,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function W(e){return A(e)}function Zc(){let e=W(e=>e.pairs);return(0,z.useMemo)(()=>{let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t},[e])}function Qc(e){let t=W(e=>e.messages),n=W(e=>e.tasks),r=W(e=>e.pairs),i=W(e=>e.inboxReadCursors),a=W(e=>e.inboxArchivedThreads);return(0,z.useMemo)(()=>{if(!e)return{unread:0,needsHumanResponse:!1,pendingPairInvite:!1,claimableTasks:0,total:0,score:0};let o=t.filter(t=>fn(t)===e.id&&!Ft(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>Vt(e)&&Bt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>Rt(i,e.id,t)).length,l=sn(e),u=r.find(t=>(t.status===`active`||t.status===`pending`)&&(t.requesterId===e.id||t.targetId===e.id))?.status===`pending`,d=n.filter(t=>un(t)&&ln(t.target,e)).length+t.filter(t=>Nt(t)&&ln(t.to,e)).length;return{unread:c,needsHumanResponse:l,pendingPairInvite:u,claimableTasks:d,total:c+ +!!l+ +!!u+d,score:c*10+(l?8:0)+(u?4:0)+d*2}},[e,t,n,r,i,a])}function $c(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.showOffline),r=W(e=>e.agentSort),i=W(e=>e.agentSortDir),a=W(e=>e.agentPresetFilter),o=W(e=>e.agentStatusFilter),s=W(e=>e.agentTagFilter),c=W(e=>e.agentHostFilter),l=W(e=>e.managedPolicies),u=W(e=>e.pairs);return(0,z.useMemo)(()=>{let d=Ut(e,t,l);if(a){let e=el(u);d=tl(d,a,yt.getState().now,e)}n||(d=d.filter(e=>e.status!==`offline`)),o===`starting`?d=d.filter(e=>e.status!==`offline`&&!e.ready):o&&(d=d.filter(e=>e.status===o)),s&&(d=d.filter(e=>(e.tags||[]).includes(s))),c&&(d=d.filter(e=>(e.machine||``)===c));let f=i===`desc`?-1:1;return[...d].sort((e,t)=>r===`name`?M(e).localeCompare(M(t))*f:r===`lastSeen`?(new Date(t.lastSeen).getTime()-new Date(e.lastSeen).getTime())*f||M(e).localeCompare(M(t)):r===`created`?(new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())*f||M(e).localeCompare(M(t)):(($t[e.status]??9)-($t[t.status]??9))*f||M(e).localeCompare(M(t)))},[e,t,n,l,r,i,a,o,s,c,u,xt()])}function el(e){let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t}function tl(e,t,n,r){switch(t){case`active`:return e.filter(e=>e.status!==`offline`);case`offline_stale`:return e.filter(e=>e.status===`offline`||dn(n,e));case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return kt().includes(t)?e.filter(e=>nn(e)===t):e}}function nl(){let e=W(e=>e.messages),t=W(e=>e.inboxReadCursors),n=W(e=>e.inboxArchivedThreads),r=W(e=>e.inboxDrafts),i=W(e=>e.agentsById),a=W(e=>e.coordinatorMutes);return(0,z.useMemo)(()=>{let o=new Map;for(let t of e){if(Ft(t))continue;let e=fn(t);e&&(o.has(e)||o.set(e,{id:e,peer:e,messages:[],lastMessage:null,previewMessage:null,attention:{unread:0,needsHumanResponse:!1,score:0},archived:!1,draft:``}),o.get(e).messages.push(t))}for(let e of o.values()){e.messages.sort((e,t)=>e.id-t.id),e.lastMessage=e.messages[e.messages.length-1]||null;let o=null;for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n&&!Pt(n)){o=n;break}}e.previewMessage=o||e.lastMessage;let s=a.includes(e.peer),c=s?0:e.messages.filter(n=>Rt(t,e.peer,n)).length,l=s?!1:sn(i[e.peer]);e.attention={unread:c,needsHumanResponse:l,score:c*10+(l?8:0)};let u=Number(n[e.peer]||0);e.archived=!!(e.lastMessage?.id&&u>=e.lastMessage.id),e.draft=r[e.peer]||``}return[...o.values()].sort((e,t)=>{let n=(t.attention.score||0)-(e.attention.score||0);return n===0?(t.lastMessage?.id||0)-(e.lastMessage?.id||0):n})},[e,t,n,r,i,a])}function rl(){let e=nl(),t=W(e=>e.agents),n=W(e=>e.showBuiltIns),r=W(e=>e.showOffline),i=W(e=>e.managedPolicies),a=W(e=>e.pairs),o=W(e=>e.tasks),s=W(e=>e.messages),c=(0,z.useMemo)(()=>new Set(Ut(t,n,i).filter(e=>r||e.status!==`offline`).map(e=>e.id)),[t,n,r,i]);return(0,z.useMemo)(()=>{let l=e.filter(e=>!e.archived&&c.has(e.peer)).reduce((e,t)=>e+(t.attention.unread||0),0),u=Ut(t,n,i).filter(e=>(r||e.status!==`offline`)&&sn(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(un).length+s.filter(Nt).length;return{unreadInbox:l,needsHumanResponse:u,pendingPairInvites:d,claimableTasks:f,total:l+u+d+f}},[e,c,t,n,r,i,a,o,s])}function il(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>Ut(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function al(){let e=W(e=>e.agents);return(0,z.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function ol(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.showOffline),r=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let i=Ut(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function sl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(Ut(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function cl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(Ut(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function ll(){let e=W(e=>e.tasks),t=W(e=>e.messages);return(0,z.useMemo)(()=>{let n=e.filter(e=>(e.kind??`claim`)===`claim`).filter(e=>!zt.has(e.status)).map(e=>({id:`task-`+e.id,sourceType:`task`,title:e.title,body:e.body,severity:e.severity||`info`,status:e.status,owner:e.claimedBy||``,target:e.target,source:e.source,channel:e.channel||``,updatedAt:e.updatedAt||e.createdAt,createdAt:e.createdAt,claimable:un(e),task:e})),r=t.filter(Nt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:Qt(e),severity:`warning`,status:e.claimedBy?`claimed`:`open`,owner:e.claimedBy||``,target:e.to,source:`message`,channel:e.channel||``,updatedAt:e.claimedAt||e.createdAt,createdAt:e.createdAt,claimable:Nt(e),message:e}));return[...n,...r].sort((e,t)=>{let n=Number(t.claimable)-Number(e.claimable);if(n!==0)return n;let r={critical:0,warning:1,info:2},i=(r[e.severity]??9)-(r[t.severity]??9);return i===0?on(e.updatedAt)-on(t.updatedAt):i})},[e,t])}function ul(){let e=W(e=>e.commandQuery),t=W(e=>e.agents),n=W(e=>e.agentsById),r=W(e=>e.showBuiltIns),i=W(e=>e.showOffline),a=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let n=Ut(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=k(),c=[dl(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),dl(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),dl(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),dl(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),dl(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),dl(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),dl(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>dl(`msg-`+e.id,`Message agent: `+M(e),e.id,`Send`,`messageAgent`,{agentId:e.id})),...n.filter(e=>e.providerCapabilities?.liveSession?.inject===!0).slice(0,8).map(e=>dl(`pair-`+e.id,`Pair: `+M(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>dl(`tag-`+e,`Filter tag: `+e,`#`+e,`Tag`,`filterTag`,{tag:e}))],l=e.trim().toLowerCase();return(l?c.filter(e=>e.search.includes(l)):c).slice(0,24)},[e,t,n,r,i,a])}function dl(e,t,n,r,i,a){return{id:e,title:t,subtitle:n,icon:r,action:i,payload:a,search:`${t}\n${n}\n${i}`.toLowerCase()}}function fl({className:e,size:t=`default`,...n}){return(0,B.jsx)(Bs,{"data-slot":`switch`,"data-size":t,className:O(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,B.jsx)(Vs,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function pl({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,B.jsx)(Os,{"data-slot":`separator`,decorative:n,orientation:t,className:O(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}function ml({...e}){return(0,B.jsx)(Oo,{"data-slot":`dropdown-menu`,...e})}function hl({...e}){return(0,B.jsx)(ko,{"data-slot":`dropdown-menu-trigger`,...e})}function gl({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,B.jsx)(Ao,{children:(0,B.jsx)(jo,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:O(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function _l({className:e,inset:t,variant:n=`default`,...r}){return(0,B.jsx)(No,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:O(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function vl({className:e,inset:t,...n}){return(0,B.jsx)(Mo,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:O(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function yl({className:e,...t}){return(0,B.jsx)(Po,{"data-slot":`dropdown-menu-separator`,className:O(`-mx-1 my-1 h-px bg-border`,e),...t})}var bl={LayoutDashboard:pt,MessageCircle:Ie,Bot:x,Server:d,MessagesSquare:it,Plug:c,PlugZap:y,Activity:pe,Link:Pe,Mail:nt,ListChecks:He,ClipboardList:Be,CalendarClock:o,AreaChart:f,Settings:p,Workflow:et,BrainCircuit:ie,FolderTree:_,Shield:st,Wrench:Ke,UserCog:Ye,Lightbulb:ot,Users:at,Boxes:g,PackagePlus:D,FileText:b};function xl(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var Sl=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function Cl(){let e=A(e=>e.notifications),t=A(e=>e.notificationUnread),n=A(e=>e.notificationSettings),r=A(e=>e.notificationPermission),i=A(e=>e.set),a=A(e=>e.openNotification),o=A(e=>e.markNotificationsRead),s=A(e=>e.clearNotifications),c=A(e=>e.requestBrowserNotifications),l=t>0?ht:se;function u(e){i({notificationSettings:{...n,...e}})}return(0,B.jsxs)(ml,{onOpenChange:e=>{e&&o()},children:[(0,B.jsx)(hl,{asChild:!0,children:(0,B.jsxs)(`button`,{className:`relative flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,B.jsx)(l,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Notifications`}),t>0&&(0,B.jsx)(F,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:t})]})}),(0,B.jsxs)(gl,{align:`start`,side:`right`,className:`w-80 p-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 py-1`,children:[(0,B.jsx)(vl,{className:`p-0`,children:`Notifications`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`button`,{type:`button`,title:`Mark read`,onClick:o,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,B.jsx)(E,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(`button`,{type:`button`,title:`Clear`,onClick:s,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,B.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})]}),(0,B.jsxs)(`div`,{className:`px-1.5 py-1.5 space-y-2`,children:[(0,B.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app notifications`}),(0,B.jsx)(fl,{size:`sm`,checked:n.enabled,onCheckedChange:e=>u({enabled:e})})]}),(0,B.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Browser notifications`}),(0,B.jsx)(fl,{size:`sm`,checked:n.browserEnabled&&r===`granted`,disabled:r===`unsupported`,onCheckedChange:e=>{e&&r!==`granted`?c():u({browserEnabled:e})}})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Sl.map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>u({[e]:!n[e]}),className:O(`rounded border px-2 py-1 text-[11px] transition-colors`,n[e]?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-accent`),children:t},e))})]}),(0,B.jsx)(yl,{}),(0,B.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:e.length===0?(0,B.jsx)(`div`,{className:`px-1.5 py-8 text-center text-xs text-muted-foreground`,children:`No notifications`}):e.slice(0,20).map(e=>(0,B.jsxs)(_l,{onSelect:t=>{t.preventDefault(),a(e)},className:`flex flex-col items-start gap-0.5 px-2 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,B.jsx)(`span`,{className:O(`h-1.5 w-1.5 rounded-full`,e.severity===`error`?`bg-red-400`:e.severity===`warning`?`bg-yellow-400`:`bg-blue-400`)}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.title}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:xl(e)})]}),(0,B.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.body}),e.routing?.reason&&(0,B.jsxs)(`span`,{className:`line-clamp-1 text-[10px] text-muted-foreground/80`,children:[`routed because `,e.routing.reason]})]},e.id))})]})]})}function wl(){let e=A(e=>e.theme),t=A(e=>e.set);return(0,B.jsxs)(ml,{children:[(0,B.jsx)(hl,{asChild:!0,children:(0,B.jsxs)(`button`,{className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,B.jsx)(he,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Theme`}),(0,B.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:mn.find(t=>t.id===e)?.label})]})}),(0,B.jsx)(gl,{align:`start`,side:`right`,className:`w-40`,children:mn.map(n=>(0,B.jsxs)(_l,{onSelect:()=>t({theme:n.id}),children:[(0,B.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,B.jsx)(ct,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function Tl(){let e=A(e=>e.view),t=A(e=>e.switchView),n=A(e=>e.connected),r=A(e=>e.showOffline),i=A(e=>e.showBuiltIns),a=A(e=>e.autoRefresh),o=A(e=>e.stats),s=A(e=>e.openCommandPalette),c=A(e=>e.set),l=A(e=>e.startAutoRefresh),u=A(e=>e.stopAutoRefresh),d=rl(),f=il();function p(e){return e===`overview`&&d.total>0?(0,B.jsx)(F,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.total}):e===`chat`&&d.unreadInbox>0?(0,B.jsx)(F,{variant:`destructive`,className:`ml-auto text-[10px] px-1.5 py-0`,children:d.unreadInbox}):e===`agents`?(0,B.jsx)(F,{variant:`secondary`,className:`ml-auto text-[10px] px-1.5 py-0`,children:f}):e===`pairs`&&d.pendingPairInvites>0?(0,B.jsx)(F,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.pendingPairInvites}):e===`work`&&d.claimableTasks>0?(0,B.jsx)(F,{className:`ml-auto text-[10px] px-1.5 py-0 bg-yellow-500/20 text-yellow-400`,children:d.claimableTasks}):null}return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`nav`,{className:`flex-1 overflow-y-auto py-2 px-2`,children:rn.map(n=>{let r=bl[n.icon]||x;return(0,B.jsxs)(`button`,{onClick:()=>t(n.key),className:O(`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors my-0.5`,e===n.key?`bg-primary text-primary-foreground`:`text-foreground hover:bg-accent`),children:[(0,B.jsx)(r,{className:`w-4 h-4 shrink-0`}),n.label,p(n.key)]},n.key)})}),(0,B.jsxs)(`div`,{className:`mt-auto border-t border-border p-4 space-y-3 text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:O(`w-2 h-2 rounded-full`,n?`bg-emerald-500`:`bg-red-500 animate-pulse`)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:n?`Live`:`Reconnecting...`})]}),(0,B.jsxs)(`button`,{onClick:s,className:`flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors w-full`,children:[(0,B.jsx)(xe,{className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{children:`Command palette`}),(0,B.jsx)(`kbd`,{className:`ml-auto text-[10px] bg-muted px-1.5 py-0.5 rounded`,children:`⌘K`})]}),(0,B.jsx)(Cl,{}),(0,B.jsx)(wl,{}),(0,B.jsx)(pl,{}),(0,B.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Show offline`}),(0,B.jsx)(fl,{checked:r,onCheckedChange:e=>c({showOffline:e})})]}),(0,B.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`System agents`}),(0,B.jsx)(fl,{checked:i,onCheckedChange:e=>c({showBuiltIns:e})})]}),(0,B.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Auto refresh`}),(0,B.jsx)(fl,{checked:a,onCheckedChange:e=>{c({autoRefresh:e}),e?l():u()}})]}),o.version&&(0,B.jsxs)(`div`,{className:`text-muted-foreground pt-1`,children:[`v`,o.version]})]})]})}function El(){return(0,B.jsxs)(`aside`,{className:`hidden xl:flex w-[250px] min-w-[250px] h-[calc(100dvh-var(--sat))] sticky top-[var(--sat)] flex-col border-r border-border bg-card`,children:[(0,B.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,B.jsx)(oe,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,B.jsx)(Tl,{})]})}function Dl(){let e=A(e=>e.mobileMenuOpen),t=A(e=>e.set);return(0,z.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&t({mobileMenuOpen:!1})}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:O(`xl:hidden fixed inset-0 z-40 bg-black/50 transition-opacity duration-200`,e?`opacity-100`:`opacity-0 pointer-events-none`),onClick:()=>t({mobileMenuOpen:!1})}),(0,B.jsxs)(`aside`,{inert:!e,className:O(`xl:hidden fixed inset-y-0 left-0 z-50 w-[280px] flex flex-col pt-[var(--sat)] bg-card border-r border-border transition-transform duration-200 ease-out`,e?`translate-x-0`:`-translate-x-full`),children:[(0,B.jsxs)(`div`,{className:`px-5 py-4 font-bold text-base border-b border-border flex items-center gap-2`,children:[(0,B.jsx)(oe,{className:`w-4 h-4 text-primary`}),`Agent Relay`,(0,B.jsx)(`button`,{onClick:()=>t({mobileMenuOpen:!1}),className:`ml-auto p-1 text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Close menu`,children:(0,B.jsx)(be,{className:`w-4 h-4`})})]}),(0,B.jsx)(Tl,{})]})]})}var Ol=500*1024,kl={bash:`bash`,c:`c`,conf:`properties`,cpp:`cpp`,cs:`csharp`,css:`css`,csv:`csv`,cts:`typescript`,diff:`diff`,dockerfile:`dockerfile`,env:`dotenv`,gemspec:`ruby`,go:`go`,graphql:`graphql`,h:`c`,hcl:`hcl`,hpp:`cpp`,html:`html`,ini:`ini`,java:`java`,js:`javascript`,json:`json`,jsonc:`jsonc`,jsx:`jsx`,kt:`kotlin`,less:`less`,log:`log`,lua:`lua`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,plist:`xml`,podspec:`ruby`,properties:`properties`,py:`python`,rake:`ruby`,rb:`ruby`,rs:`rust`,scss:`scss`,sh:`bash`,sql:`sql`,svelte:`svelte`,swift:`swift`,toml:`toml`,ts:`typescript`,tsx:`tsx`,txt:`text`,vue:`vue`,webmanifest:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},Al={".bashrc":`bash`,".env":`dotenv`,".eslintrc":`json`,".gitignore":`gitignore`,".npmrc":`properties`,".prettierrc":`json`,".swiftformat":`properties`,".swiftlint.yml":`yaml`,".watchmanconfig":`json`,"app.config":`json`,"app.webmanifest":`json`,berksfile:`ruby`,brewfile:`ruby`,"bun.lock":`json`,capfile:`ruby`,cartfile:`ruby`,"composer.lock":`json`,dangerfile:`ruby`,"deno.lock":`json`,fastfile:`ruby`,"flake.lock":`json`,gemfile:`ruby`,guardfile:`ruby`,podfile:`ruby`,rakefile:`ruby`,dockerfile:`dockerfile`,makefile:`make`},jl=null;function Ml(){return jl??=R(()=>import(`./bundle-web-BLavPdXe.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),jl}function Nl(e){return new TextEncoder().encode(e).length}function Pl(e){return e.split(`/`).filter(Boolean).pop()||e}function Fl(e){let t=e?.slice(0,240).split(/\r?\n/,1)[0]?.toLowerCase()||``;return t.startsWith(`#!`)?/\b(bash|dash|ksh|sh|zsh)\b/.test(t)?`bash`:/\bfish\b/.test(t)?`fish`:/\b(ts-node|tsx)\b/.test(t)?`typescript`:/\b(node|bun|deno)\b/.test(t)?`javascript`:/\bpython[0-9.]*\b/.test(t)?`python`:/\bruby\b/.test(t)?`ruby`:/\bswift\b/.test(t)?`swift`:/\bperl\b/.test(t)?`perl`:/\bphp\b/.test(t)?`php`:null:null}function Il(e,t,n,r){if(n)return n;let i=Pl(e).toLowerCase();if(Al[i])return Al[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=Fl(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&kl[o]?kl[o]:t?.includes(`json`)?`json`:t?.includes(`javascript`)?`javascript`:t?.includes(`typescript`)?`typescript`:t?.includes(`xml`)?`xml`:t?.includes(`yaml`)||t?.includes(`yml`)?`yaml`:t?.includes(`shellscript`)?`bash`:null}function Ll(e,t,n,r){let i=Il(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var Rl=(0,z.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=A(e=>e.theme),o=mn.find(e=>e.id===a)?.dark??!0,s=(0,z.useMemo)(()=>Il(t,n,r,e)||`text`,[e,r,n,t]),c=Nl(e)>Ol,[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(!1);function h(){return(0,B.jsx)(Wn,{value:e,label:`Copy code`,copiedLabel:`Copied code`,size:`icon`,variant:`ghost`,className:`absolute right-2 top-2 h-7 w-7 bg-background/80 opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted group-hover/code:opacity-100 focus-visible:opacity-100`})}return(0,z.useEffect)(()=>{if(c||s===`text`||s===`log`){u(``),f(!1),m(!1);return}let t=!1;return f(!0),m(!1),Ml().then(({codeToHtml:t})=>t(e,{lang:s,theme:o?`github-dark-default`:`github-light-default`})).then(e=>{t||u(e)}).catch(()=>{t||(u(``),m(!0))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[e,o,s,c]),d?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(Xe,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):c||p||!l?(0,B.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,B.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,children:e||` `})]}):(0,B.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,B.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:l}})]})}),zl=(0,z.lazy)(()=>R(()=>import(`./markdown-preview-impl-BZ7sigEc.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function G(e){return(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading preview…`}),children:(0,B.jsx)(zl,{...e})})}var Bl=e(_t(),1);function K({src:e,alt:t,onClose:n}){let[r,i]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let e=document.body.style.overflow;document.body.style.overflow=`hidden`;function t(e){e.key===`Escape`&&n()}return document.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,document.removeEventListener(`keydown`,t)}},[n]),(0,B.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/95`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 p-2`,children:[(0,B.jsx)(`button`,{type:`button`,className:`rounded-full bg-white/10 p-2 text-white/70 hover:bg-white/20 hover:text-white`,onClick:()=>i(!r),title:r?`Fit to screen`:`Actual size`,children:r?(0,B.jsx)(Ue,{className:`h-4 w-4`}):(0,B.jsx)($e,{className:`h-4 w-4`})}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-full bg-white/10 p-2 text-white/70 hover:bg-white/20 hover:text-white`,onClick:n,title:`Close`,children:(0,B.jsx)(be,{className:`h-4 w-4`})})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 ${r?`overflow-auto`:`flex items-center justify-center overflow-hidden p-4`}`,onClick:r?void 0:n,children:(0,B.jsx)(`img`,{src:e,alt:t,className:r?`max-w-none`:`max-h-full max-w-full cursor-zoom-in object-contain`,onClick:e=>{e.stopPropagation(),i(!r)}})})]})}function q({src:e,alt:t=``,className:n,style:r}){let[i,a]=(0,z.useState)(!1);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`img`,{src:e,alt:t,className:`${n||``} cursor-zoom-in`,style:r,onClick:()=>a(!0)}),i&&(0,Bl.createPortal)((0,B.jsx)(K,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var J=`agent-relay:file-git-status`;function Vl(){try{return window.localStorage.getItem(J)!==`off`}catch{return!0}}function Hl(e){try{window.localStorage.setItem(J,e?`on`:`off`)}catch{}}function Ul(e){switch(e){case`staged`:return{dot:`bg-green-500`,text:`text-green-400`,label:`Staged`};case`unstaged`:return{dot:`bg-amber-500`,text:`text-amber-400`,label:`Modified (unstaged)`};case`staged-unstaged`:return{dot:`bg-amber-500`,text:`text-green-400`,label:`Staged + unstaged changes`};case`untracked`:return{dot:`bg-sky-500`,text:`text-sky-400`,label:`Untracked`};default:return null}}function Wl(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function Gl({status:e}){let t=Ul(e);return t?(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.dot}`,title:t.label}):null}function Kl(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function ql(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function Jl(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function Yl(e,t,n){return Jl(e,t)?`markdown`:Ll(e,t,void 0,n)?`code`:null}function Xl(e){return`agent-relay:file-view-mode:${e}`}function Zl(e){try{let t=window.localStorage.getItem(Xl(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function Ql(e,t){try{window.localStorage.setItem(Xl(e),t)}catch{}}function $l(e,t){let n=ql(e,t);if(n===`/`)return[{label:`/`,path:t}];let r=n.split(`/`).filter(Boolean),i=[{label:`/`,path:t}];for(let e=0;e<r.length;e++)i.push({label:r[e],path:`${t.replace(/\/+$/,``)}/${r.slice(0,e+1).join(`/`)}`});return i}function eu(e,t){let n=A(e=>e.apiCall),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(``);return(0,z.useEffect)(()=>{if(!e||!t){i(null),c(``);return}let r=!1;return o(!0),c(``),n(`GET`,`/orchestrators/${encodeURIComponent(e)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{r||i(e)}).catch(e=>{r||(i(null),c(jt(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function tu(e,t,n=!1){let r=A(e=>e.apiCall),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(``);return(0,z.useEffect)(()=>{if(!e||!t){a(null),l(``);return}let i=!1;return s(!0),l(``),r(`GET`,Wl(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(jt(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function nu({content:e,line:t,lineRef:n}){return(0,B.jsx)(`div`,{className:`w-full py-2 font-mono text-xs leading-5`,children:e.split(`
|
|
15
|
+
`).map((e,r)=>{let i=r+1,a=i===t;return(0,B.jsxs)(`div`,{ref:a?n:void 0,className:`grid grid-cols-[2.5rem_minmax(0,1fr)] px-1 sm:grid-cols-[4rem_minmax(0,1fr)] sm:px-2 ${a?`bg-primary/15`:``}`,children:[(0,B.jsx)(`div`,{className:`select-none pr-2 text-right text-muted-foreground sm:pr-3`,children:i}),(0,B.jsx)(`pre`,{className:`overflow-hidden whitespace-pre-wrap break-words`,children:e||` `})]},i)})})}function ru({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:a,error:o}=tu(e,t,r);return(0,z.useEffect)(()=>{n(o)},[o,n]),t?a?(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Xe,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):o?(0,B.jsx)(`div`,{className:`h-full bg-muted/20`}):i?(0,B.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(ae,{className:`h-3.5 w-3.5 text-blue-400`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,B.jsxs)(F,{variant:`outline`,className:`text-[10px]`,children:[i.entries.length,` items`]})]}),(0,B.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[i.entries.map(e=>{let t=e.type===`directory`?ae:de,n=Ul(e.gitStatus);return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[(0,B.jsx)(t,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${n?.text??``}`,children:e.name}),e.symlink&&(0,B.jsx)(je,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(Gl,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Kl(e.size)})]},e.path)}),i.entries.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]})]}):null:(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a directory to preview`})}function iu({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:a,error:o}=eu(e,t),s=(0,z.useRef)(null),[c,l]=(0,z.useState)(`raw`);(0,z.useEffect)(()=>{r(o)},[o,r]),(0,z.useEffect)(()=>{n>0&&s.current?.scrollIntoView({block:`center`})},[i,n]),(0,z.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){l(`raw`);return}let e=Yl(i.path,i.mediaType,i.content);l(e?Zl(e):`raw`)},[i?.path,i?.encoding,i?.mediaType,i?.content,n]);function u(e,t){l(e),t&&Ql(t,e)}if(!t)return(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a file to preview`});if(a)return(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Xe,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(o)return(0,B.jsx)(`div`,{className:`h-full bg-muted/20`});if(!i)return null;if(i.encoding===`base64`)return(0,B.jsxs)(`div`,{className:`flex h-full flex-col bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(de,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,B.jsx)(Wn,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:Kl(i.size)})]}),(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,B.jsx)(q,{src:`data:${i.mediaType};base64,${i.content??``}`,alt:i.name,className:`max-h-full max-w-full object-contain`,style:{imageRendering:i.mediaType===`image/svg+xml`?`auto`:void 0}})})]});if(i.encoding===`binary`)return(0,B.jsxs)(`div`,{className:`p-4 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:i.name}),(0,B.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:i.truncated?`File too large to preview.`:`Binary file preview is not available.`}),(0,B.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,B.jsx)(F,{variant:`secondary`,children:i.mediaType}),(0,B.jsx)(F,{variant:`outline`,children:Kl(i.size)})]})]});let d=i.content??``,f=Jl(i.path,i.mediaType),p=!f&&Ll(i.path,i.mediaType,void 0,d),m=f||p,h=f?`markdown`:p?`code`:null;return(0,B.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(de,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:i.path}),(0,B.jsx)(Wn,{value:i.path,label:`Copy path`,copiedLabel:`Copied path`,size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0`}),i.truncated&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:`truncated`}),(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:Kl(i.size)}),m&&(0,B.jsxs)(`div`,{className:`flex shrink-0 rounded-md border border-border bg-muted/40 p-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`raw`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`raw`,h),children:`Raw`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`rendered`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`rendered`,h),children:f?`Rendered`:`Highlighted`})]})]}),c===`rendered`&&f&&(0,B.jsx)(G,{content:d,path:i.path}),c===`rendered`&&p&&(0,B.jsx)(Rl,{content:d,path:i.path,mediaType:i.mediaType}),c===`raw`&&(0,B.jsx)(nu,{content:d,line:n,lineRef:s})]})}function au({overlay:e=!1}){let t=A(e=>e.apiCall),n=A(e=>e.orchestrators),r=A(e=>e.fileOrchestratorId),i=A(e=>e.filePath),a=A(e=>e.fileSelectedPath),o=A(e=>e.fileSelectedLine),s=A(e=>e.set),c=A(e=>e.closeFileOverlay),l=A(e=>e.openOrchestratorSpawnAt),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(i),[m,h]=(0,z.useState)(!1),[g,v]=(0,z.useState)(``),[y,b]=(0,z.useState)(``),[x,ee]=(0,z.useState)(Vl),S=(0,z.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),C=n.find(e=>e.id===r)||S[0];(0,z.useEffect)(()=>{if(!C)return;let e={};r||(e.fileOrchestratorId=C.id),i||(e.filePath=C.baseDir),Object.keys(e).length&&s(e)},[r,i,C,s]),(0,z.useEffect)(()=>p(i),[i]);async function ne(e=i){if(!(!C||!e)){h(!0),v(``);try{let n=await t(`GET`,Wl(C.id,e,x));d(n),s({filePath:n.path}),p(n.path),b(``)}catch(e){v(jt(e))}finally{h(!1)}}}(0,z.useEffect)(()=>{ne(i)},[C?.id,i,x]);function w(e){ee(e),Hl(e)}function re(e){s({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function ie(e){b(``),e.type===`directory`?s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):s({fileSelectedPath:e.path,fileSelectedLine:0})}function oe(){if(!C)return;let t=f.trim()||i||C.baseDir;e&&c(),l({orchestratorId:C.id,cwd:t})}let se=u?$l(u.path,u.baseDir):[],T=g||y;return(0,B.jsxs)(`div`,{className:e?`flex h-full flex-col`:`flex h-[calc(100dvh-5rem)] flex-col gap-3 md:gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,B.jsx)(_,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,B.jsxs)(`select`,{value:C?.id||``,onChange:e=>re(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[S.length===0&&(0,B.jsx)(`option`,{value:``,children:`No online orchestrators`}),S.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.hostname||e.id},e.id))]}),e&&(0,B.jsx)(I,{size:`icon`,variant:`ghost`,className:`ml-auto h-8 w-8`,onClick:c,title:`Close`,children:(0,B.jsx)(be,{className:`h-4 w-4`})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,B.jsx)(L,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s({filePath:f,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:C?.baseDir||`Path`}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>ne(f),disabled:m||!C,children:[m?(0,B.jsx)(Xe,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(te,{className:`h-3.5 w-3.5`}),`Open`]}),(0,B.jsxs)(I,{size:`sm`,className:`gap-1`,onClick:oe,disabled:!C,children:[(0,B.jsx)(ue,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`sm:hidden`,children:`Spawn`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:`Spawn from here`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:`Show git status colors`,children:[(0,B.jsx)(Re,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,B.jsx)(fl,{checked:x,onCheckedChange:w})]})]}),se.length>0&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${a?`hidden md:flex`:``}`,children:se.map((e,t)=>(0,B.jsxs)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 font-mono hover:bg-accent hover:text-foreground`,onClick:()=>s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}),children:[e.label,t<se.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),T&&(0,B.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:T}),(0,B.jsxs)(`div`,{className:`grid min-h-0 flex-1 overflow-hidden md:rounded-md md:border md:border-border md:grid-cols-[22rem_minmax(0,1fr)] ${a?``:`rounded-md border border-border`}`,children:[(0,B.jsxs)(`div`,{className:`min-h-0 overflow-auto border-b border-border bg-card md:border-b-0 md:border-r ${a?`hidden md:block`:``}`,children:[u?.parent&&(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent`,onClick:()=>s({filePath:u.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(We,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{children:`Parent directory`})]}),u?.entries.map(e=>{let t=a===e.path||i===e.path,n=e.type===`directory`?ae:de,r=Ul(e.gitStatus);return(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent ${t?`bg-accent`:``}`,onClick:()=>ie(e),children:[(0,B.jsx)(n,{className:`h-4 w-4 shrink-0 ${e.type===`directory`?`text-blue-400`:`text-muted-foreground`}`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs ${r?.text??``}`,children:e.name}),e.symlink&&(0,B.jsx)(je,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(Gl,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Kl(e.size)})]},e.path)}),!m&&u&&u.entries.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden ${a?``:`hidden md:flex`}`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs text-muted-foreground hover:text-foreground md:hidden`,onClick:()=>s({fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(We,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(iu,{orchestratorId:C?.id||``,selectedPath:a,line:o,onReadError:b})})]})]})]})}function ou(){return(0,B.jsx)(au,{})}function su(){return A(e=>e.fileOverlayOpen)?(0,B.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/80 backdrop-blur-sm`,children:(0,B.jsx)(`div`,{className:`absolute inset-4 overflow-hidden rounded-md border border-border bg-background p-4 shadow-xl`,children:(0,B.jsx)(au,{overlay:!0})})}):null}function cu(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;window.history.pushState({sheetGuard:!0},``),n.current=!0;function t(){n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,window.history.back())}},[e])}function lu({...e}){return cu(e.open,e.onOpenChange),(0,B.jsx)(Br,{"data-slot":`sheet`,...e})}function uu({...e}){return(0,B.jsx)(Kr,{"data-slot":`sheet-close`,...e})}function du({...e}){return(0,B.jsx)(Vr,{"data-slot":`sheet-portal`,...e})}function fu({className:e,...t}){return(0,B.jsx)(Hr,{"data-slot":`sheet-overlay`,className:O(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function pu({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,B.jsxs)(du,{children:[(0,B.jsx)(fu,{}),(0,B.jsxs)(Ur,{"data-slot":`sheet-content`,"data-side":n,className:O(`fixed z-50 flex flex-col bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out overflow-hidden max-w-[100dvw] data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,e),...i,children:[t,r&&(0,B.jsx)(Kr,{"data-slot":`sheet-close`,asChild:!0,children:(0,B.jsxs)(I,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,B.jsx)(be,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function mu({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`sheet-header`,className:O(`flex flex-col gap-0.5 p-4`,e),...t})}function hu({className:e,...t}){return(0,B.jsx)(Wr,{"data-slot":`sheet-title`,className:O(`font-heading text-base font-medium text-foreground`,e),...t})}function gu({className:e,orientation:t=`horizontal`,...n}){return(0,B.jsx)(rc,{"data-slot":`tabs`,"data-orientation":t,className:O(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var _u=yn(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function vu({className:e,variant:t=`default`,...n}){return(0,B.jsx)(ic,{"data-slot":`tabs-list`,"data-variant":t,className:O(_u({variant:t}),e),...n})}function yu({className:e,...t}){return(0,B.jsx)(ac,{"data-slot":`tabs-trigger`,className:O(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function bu({className:e,...t}){return(0,B.jsx)(oc,{"data-slot":`tabs-content`,className:O(`flex-1 text-sm outline-none`,e),...t})}function xu({agent:e,now:t,className:n}){return(0,B.jsx)(`span`,{className:O(`inline-block w-2.5 h-2.5 rounded-full shrink-0`,It(e,t),n)})}function Su({className:e}){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,B.jsx)(`path`,{d:`m3.127 10.604 3.135-1.76.053-.153-.053-.085H6.11l-.525-.032-1.791-.048-1.554-.065-1.505-.08-.38-.081L0 7.832l.036-.234.32-.214.455.04 1.009.069 1.513.105 1.097.064 1.626.17h.259l.036-.105-.089-.065-.068-.064-1.566-1.062-1.695-1.121-.887-.646-.48-.327-.243-.306-.104-.67.435-.48.585.04.15.04.593.456 1.267.981 1.654 1.218.242.202.097-.068.012-.049-.109-.181-.9-1.626-.96-1.655-.428-.686-.113-.411a2 2 0 0 1-.068-.484l.496-.674L4.446 0l.662.089.279.242.411.94.666 1.48 1.033 2.014.302.597.162.553.06.17h.105v-.097l.085-1.134.157-1.392.154-1.792.052-.504.25-.605.497-.327.387.186.319.456-.045.294-.19 1.23-.37 1.93-.243 1.29h.142l.161-.16.654-.868 1.097-1.372.484-.545.565-.601.363-.287h.686l.505.751-.226.775-.707.895-.585.759-.839 1.13-.524.904.048.072.125-.012 1.897-.403 1.024-.186 1.223-.21.553.258.06.263-.218.536-1.307.323-1.533.307-2.284.54-.028.02.032.04 1.029.098.44.024h1.077l2.005.15.525.346.315.424-.053.323-.807.411-3.631-.863-.872-.218h-.12v.073l.726.71 1.331 1.202 1.667 1.55.084.383-.214.302-.226-.032-1.464-1.101-.565-.497-1.28-1.077h-.084v.113l.295.432 1.557 2.34.08.718-.112.234-.404.141-.444-.08-.911-1.28-.94-1.44-.759-1.291-.093.053-.448 4.821-.21.246-.484.186-.403-.307-.214-.496.214-.98.258-1.28.21-1.016.19-1.263.112-.42-.008-.028-.092.012-.953 1.307-1.448 1.957-1.146 1.227-.274.109-.477-.247.045-.44.266-.39 1.586-2.018.956-1.25.617-.723-.004-.105h-.036l-4.212 2.736-.75.096-.324-.302.04-.496.154-.162 1.267-.871z`})})}function Cu({className:e}){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,B.jsx)(`path`,{d:`M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365 2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5z`})})}var wu={claude:Su,anthropic:Su,codex:Cu,openai:Cu},Tu={claude:`text-orange-400`,anthropic:`text-orange-400`};function Eu({provider:e,className:t}){let n=e.toLowerCase(),r=wu[n];return r?(0,B.jsx)(`span`,{role:`img`,"aria-label":e,title:e,className:`inline-flex shrink-0`,children:(0,B.jsx)(r,{className:O(Tu[n],t)})}):(0,B.jsx)(`span`,{className:`capitalize`,children:e})}var Du={codex:`text-blue-400 bg-blue-500/10 border-blue-500/25`,claude:`text-orange-400 bg-orange-500/10 border-orange-500/25`,user:`text-emerald-400 bg-emerald-500/10 border-emerald-500/25`,system:`text-purple-400 bg-purple-500/10 border-purple-500/25`,channel:`text-blue-400 bg-blue-500/10 border-blue-500/25`,agent:`text-zinc-400 bg-zinc-500/10 border-zinc-500/25`},Ou={codex:ve,claude:Su,user:Ce,system:d,channel:it,agent:x};function ku({agent:e,className:t}){let n=nn(e),r=Ou[n]||x;return(0,B.jsx)(`span`,{className:O(`inline-flex items-center justify-center w-5 h-5 rounded-md border text-sm`,Du[n]||Du.agent,t),children:(0,B.jsx)(r,{className:`w-3.5 h-3.5`})})}function Au({agent:e,compact:t=!1}){let n=Bu(e);return n.length===0?null:(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.slice(0,t?4:void 0).map(e=>(0,B.jsx)(F,{variant:`outline`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))})}function ju({agent:e,compact:t=!1,className:n=``}){let r=Nu(e);return(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 ${n}`,children:r.map(e=>{let n=e.Icon;return(0,B.jsxs)(`span`,{title:e.title,className:`inline-flex h-5 min-w-5 items-center justify-center gap-1 rounded-md border px-1.5 text-[10px] leading-none ${e.className}`,children:[(0,B.jsx)(n,{className:`h-3 w-3 shrink-0`}),!t&&(0,B.jsx)(`span`,{children:e.label})]},e.key)})})}function Mu({agent:e}){let t=e.context;if(!t)return null;let n=Uu(t);if(n===null)return(0,B.jsxs)(`div`,{className:`space-y-1`,title:Wu(t),children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:`collecting`}),(0,B.jsx)(`span`,{children:`--`})]}),(0,B.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,B.jsx)(`div`,{className:`h-full w-0 bg-muted-foreground/30`})})]});let r=Math.round(n*100),i=r>=80?`bg-red-500`:r>=60?`bg-yellow-500`:`bg-emerald-500`;return(0,B.jsxs)(`div`,{className:`space-y-1`,title:Wu(t),children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:t.lifecycleState}),(0,B.jsxs)(`span`,{children:[r,`%`]})]}),(0,B.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,B.jsx)(`div`,{className:`h-full ${i}`,style:{width:`${Math.max(0,Math.min(100,r))}%`}})})]})}function Nu(e){let t=Pu(e),n=Fu(e),r=Iu(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?h:Le,className:t?`border-sky-500/30 bg-sky-500/10 text-sky-300`:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`},n,r]}function Pu(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Fu(e){let t=String(e.providerCapabilities?.session?.approvalMode||e.meta?.approvalMode||`guarded`).toLowerCase();return t===`open`?{key:`approval`,label:`Open`,title:`Approval mode: open`,Icon:ke,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`}:t===`read-only`?{key:`approval`,label:`Read-only`,title:`Approval mode: read-only`,Icon:Qe,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:Te,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Iu(e){let t=Lu(e.meta?.workspace),n=Tt(t.requestedMode)||Tt(e.meta?.workspaceMode),r=Tt(t.mode),i=n&&n!==`inherit`?n:r&&n!==`inherit`?r:`default`;return i===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:Re,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:i===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:T,iconColor:`text-cyan-300`,className:`border-cyan-500/30 bg-cyan-500/10 text-cyan-300`}:{key:`workspace`,label:`Default`,title:r?`Workspace: default/inherit, resolved to ${r}`:`Workspace: default/inherit`,Icon:Se,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function Lu(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Ru(e){let t=Lu(e.meta?.workspace),n=Tt(t.repoRoot)||Tt(t.sourceCwd)||Tt(e.meta?.cwd);return n?Ht(n,2):``}function zu(e){return!!(e.context||e.providerCapabilities?.context)}function Bu(e){let t=e.providerCapabilities,n=e.context,r=[];t?.lifecycle.managed?r.push(`managed`):t&&r.push(`bridge`),t?.session?.approvalMode===`read-only`?r.push(`read-only`):t?.session?.fileWrite&&r.push(`write`),t?.session?.shell&&r.push(`shell`),(t?.model?.alias||t?.model?.id)&&r.push(String(t.model.alias||t.model.id));let i=cn(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=Uu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function Vu({context:e,expected:t=!!e,size:n=26,className:r}){let i=Uu(e);if(i===null&&!t)return null;let a=n>=24?3:2.5,o=n/2,s=o-a,c=2*Math.PI*s,l=i===null?c:c*(1-i),u=i===null,d=u?`text-muted-foreground`:i>.8?`text-red-400`:i>.5?`text-yellow-400`:`text-emerald-400`,f=u?null:Math.round(i*100);return(0,B.jsxs)(`div`,{className:`relative shrink-0 ${u?`opacity-70`:``} ${r??``}`,style:{width:n,height:n},title:Wu(e),children:[(0,B.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:`rotate-[-90deg]`,children:[(0,B.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,className:`stroke-muted-foreground/20`}),(0,B.jsx)(`circle`,{cx:o,cy:o,r:s,fill:`none`,strokeWidth:a,strokeDasharray:c,strokeDashoffset:l,strokeLinecap:`round`,className:`${d} stroke-current transition-all duration-500`})]}),(0,B.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center font-semibold leading-none ${u?`text-muted-foreground`:d}`,style:{fontSize:n>=24?8:7},children:u?`?`:f})]})}function Hu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${Gu(t.tokensUsed)} / ${Gu(t.tokensMax)}`:t.tokensUsed?Gu(t.tokensUsed):t.tokensMax?Gu(t.tokensMax):null}function Uu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function Wu(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=Uu(e),n=`${e.source}/${e.confidence}`,r=Number.isFinite(e.lastUpdatedAt)?new Date(e.lastUpdatedAt).toLocaleString():`unknown`;return t===null?`Context: unknown; ${n}; updated ${r}`:`Context: ${Math.round(t*100)}%; ${n}; updated ${r}`}function Gu(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var Ku=(0,z.lazy)(()=>R(()=>import(`./terminal-viewer-impl-DnFJDl9N.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13,14]),import.meta.url));function Y(e){return e.open?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(Ku,{...e})}):null}function qu({orchestratorId:e,session:t,lines:n=200}){let r=A(e=>e.apiCall),[o,s]=(0,z.useState)([]),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(`provider`),[m,h]=(0,z.useState)(null);async function g(){if(!u)try{s((await r(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${n}${f===`mirror`?`&stream=mirror`:``}`)).lines||[]),h(null)}catch(e){h(jt(e))}}(0,z.useEffect)(()=>{g();let e=setInterval(()=>void g(),1500);return()=>clearInterval(e)},[e,t,u,f]);let _=c?o.filter(e=>e.toLowerCase().includes(c.toLowerCase())):o;return(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`relative min-w-48 flex-1`,children:[(0,B.jsx)(a,{className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground`}),(0,B.jsx)(L,{className:`pl-8`,value:c,onChange:e=>l(e.target.value),placeholder:`Search logs`})]}),(0,B.jsxs)(`div`,{className:`flex rounded-md border border-border overflow-hidden`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>p(`provider`),title:`Provider output`,className:O(`flex items-center gap-1 px-2 py-1.5 text-xs`,f===`provider`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,B.jsx)(ve,{className:`h-3.5 w-3.5`}),` Output`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>p(`mirror`),title:`Session-mirror diagnostics (clean)`,className:O(`flex items-center gap-1 px-2 py-1.5 text-xs border-l border-border`,f===`mirror`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,B.jsx)(w,{className:`h-3.5 w-3.5`}),` Mirror`]})]}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>d(e=>!e),title:u?`Resume logs`:`Pause logs`,children:u?(0,B.jsx)(le,{className:`h-4 w-4`}):(0,B.jsx)(Ze,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>an(`${t}.log`,o.join(`
|
|
16
16
|
`),`text/plain`),title:`Download logs`,children:(0,B.jsx)(i,{className:`h-4 w-4`})})]}),m&&(0,B.jsx)(`div`,{className:`text-sm text-destructive`,children:m}),(0,B.jsx)(`pre`,{className:`max-h-96 overflow-auto rounded-md border border-border bg-zinc-950 p-3 text-xs leading-5 text-zinc-100`,children:_.join(`
|
|
17
17
|
`)||`No log output`})]})}function Ju(e,t){let n=t?.meta?.busyHealth;if(!t||t.status!==`busy`||!wt(n)||n.status!==`stuck-busy`)return null;let r=typeof n.activeWorkStartedAt==`number`?n.activeWorkStartedAt:0;if(!r)return null;let i=typeof n.lastProgressAt==`number`?n.lastProgressAt:r;return{kind:typeof n.kind==`string`?n.kind:`provider-turn`,thresholdMs:typeof n.thresholdMs==`number`&&n.thresholdMs>0?n.thresholdMs:0,activeWorkId:typeof n.activeWorkId==`string`?n.activeWorkId:void 0,activeWorkLabel:typeof n.activeWorkLabel==`string`?n.activeWorkLabel:void 0,activeWorkStartedAt:r,activeWorkAgeMs:Math.max(0,e-r),lastProgressAt:i,staleForMs:Math.max(0,e-i)}}var Yu={running:`bg-emerald-500/20 text-emerald-400`,starting:`bg-blue-500/20 text-blue-400`,stopping:`bg-yellow-500/20 text-yellow-400`,stopped:`bg-zinc-500/20 text-zinc-400`,backoff:`bg-red-500/20 text-red-400`};function Xu({agent:e,orchestrators:t}){let n=bt(),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)({spawn:!0,workspace:!0,runtime:!0,profile:!0,lifecycle:!0,activity:!1}),l=typeof e.meta?.policyName==`string`?e.meta.policyName:null,u=typeof e.meta?.profile==`string`?e.meta.profile:null,d=wt(e.meta?.agentProfile)?e.meta.agentProfile:null,f=Qu(d?.projection)?d.projection:null,p=t.find(t=>t.managedAgents.some(t=>t.agentId===e.id)),m=p?.managedAgents.find(t=>t.agentId===e.id);(0,z.useEffect)(()=>{if(!l)return;let e=!1;return Ee(`GET`,`/spawn-policies/`+encodeURIComponent(l)+`/status`).then(t=>{e||i(t)}).catch(()=>{e||i(null)}),()=>{e=!0}},[l,e.lastSeen]),(0,z.useEffect)(()=>{let t=!1;return Ee(`GET`,`/activity?agentId=`+encodeURIComponent(e.id)+`&limit=20`).then(e=>{t||o(e)}).catch(()=>{t||o([])}),()=>{t=!0}},[e.id,e.lastSeen]);function h(e){c(t=>({...t,[e]:!t[e]}))}function g(){let t=r?.policy,n=r?.state,i=[`# Agent Diagnostics`,`Agent: ${e.id}`,`Status: ${e.status}`,`Provider: ${e.meta?.provider||`unknown`}`,`Machine: ${e.machine||`unknown`}`];if(l&&i.push(`Policy: ${l}`),u&&i.push(`Agent Profile: ${u}`),t&&(i.push(``,`## Spawn Config`),i.push(`Provider: ${t.provider}`),t.model&&i.push(`Model: ${t.model}`),t.effort&&i.push(`Effort: ${t.effort}`),i.push(`CWD: ${t.cwd}`),i.push(`Permission: ${t.permissionMode}`),i.push(`Mode: ${t.mode}`),t.rig&&i.push(`Rig: ${t.rig}`),t.tags.length&&i.push(`Tags: ${t.tags.join(`, `)}`),t.capabilities.length&&i.push(`Caps: ${t.capabilities.join(`, `)}`)),f){i.push(``,`## Agent Profile Projection`),i.push(`Profile: ${f.profileName}`),i.push(`Provider: ${f.provider}`),i.push(`Base: ${f.base}`),f.warnings.length&&i.push(`Warnings: ${f.warnings.length}`);for(let e of f.entries)i.push(`- ${e.capability}: requested=${e.requested} result=${e.result} detail=${e.detail}`)}if(m&&(i.push(``,`## Runtime`),m.pid&&i.push(`PID: ${m.pid}`),m.sessionName&&i.push(`Session: ${m.sessionName}`),m.supervisor&&i.push(`Supervisor: ${m.supervisor}`),m.systemdUnit&&i.push(`Systemd: ${m.systemdUnit}`),m.terminalSession&&i.push(`Terminal: ${m.terminalSession} (${m.terminalAvailable?`available`:`unavailable`})`),m.tmuxSession&&m.tmuxSession!==m.sessionName&&i.push(`Legacy tmux: ${m.tmuxSession}`),m.spawnRequestId&&i.push(`Spawn Request: ${m.spawnRequestId}`),m.startedAt&&i.push(`Started: ${new Date(m.startedAt).toISOString()}`),p&&i.push(`Orchestrator: ${p.hostname} (${p.id.slice(-8)})`)),m?.workspace&&(i.push(``,`## Workspace`),i.push(`Mode: ${m.workspace.mode}`),m.workspace.status&&i.push(`Status: ${m.workspace.status}`),m.workspace.worktreePath&&i.push(`Worktree: ${m.workspace.worktreePath}`),m.workspace.repoRoot&&i.push(`Repo: ${m.workspace.repoRoot}`),m.workspace.branch&&i.push(`Branch: ${m.workspace.branch}`),m.workspace.baseRef&&i.push(`Base: ${m.workspace.baseRef}`),m.workspace.baseSha&&i.push(`Base SHA: ${m.workspace.baseSha}`),m.workspace.stewardAgentId&&i.push(`Steward: ${m.workspace.stewardAgentId}`)),n&&(i.push(``,`## Lifecycle`),i.push(`Status: ${n.status}`),i.push(`Restarts: ${n.restartCount}`),i.push(`Consecutive failures: ${n.consecutiveFailures}`),n.lastSpawnAt&&i.push(`Last spawn: ${new Date(n.lastSpawnAt).toISOString()}`),n.lastStopAt&&i.push(`Last stop: ${new Date(n.lastStopAt).toISOString()}`),n.healthySince&&i.push(`Healthy since: ${new Date(n.healthySince).toISOString()}`),n.backoffUntil&&i.push(`Backoff until: ${new Date(n.backoffUntil).toISOString()}`),n.lastError&&i.push(`Last error: ${n.lastError}`)),a.length>0){i.push(``,`## Recent Activity`);for(let e of a.slice(0,10))i.push(`- [${new Date(typeof e.createdAt==`number`?e.createdAt:Date.parse(String(e.createdAt))).toISOString()}] ${e.title}${e.body?`: `+e.body.slice(0,100):``}`)}let o=e.meta?.package;o?.name&&o?.version&&(i.push(``,`## Versions`),i.push(`Runner: ${o.name}@${o.version}`));let s=e.meta?.contracts;if(s)for(let[e,t]of Object.entries(s))i.push(`Contract ${e}: ${t}`);return i.join(`
|
|
18
18
|
`)}let _=r?.policy,v=r?.state;return(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-1.5`,children:[(0,B.jsx)(dt,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Diagnostics`]}),(0,B.jsx)(Wn,{value:g,label:`Copy Bundle`,showText:!0,size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,iconClassName:`w-3 h-3`})]}),_&&(0,B.jsx)(Zu,{title:`Spawn Config`,expanded:!!s.spawn,onToggle:()=>h(`spawn`),children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs`,children:[(0,B.jsx)(X,{label:`Provider`,value:_.provider}),_.model&&(0,B.jsx)(X,{label:`Model`,value:_.model}),_.effort&&(0,B.jsx)(X,{label:`Effort`,value:_.effort}),(0,B.jsx)(X,{label:`Permission`,value:_.permissionMode}),(0,B.jsx)(X,{label:`Mode`,value:_.mode}),_.rig&&(0,B.jsx)(X,{label:`Rig`,value:_.rig}),(0,B.jsx)(X,{label:`CWD`,value:_.cwd,className:`col-span-2`,mono:!0}),_.tags.length>0&&(0,B.jsxs)(`div`,{className:`col-span-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Tags`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:_.tags.map(e=>(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:e},e))})]}),_.capabilities.length>0&&(0,B.jsxs)(`div`,{className:`col-span-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Capabilities`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:_.capabilities.map(e=>(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]}),_.providerArgs.length>0&&(0,B.jsx)(X,{label:`Provider Args`,value:_.providerArgs.join(` `),className:`col-span-2`,mono:!0}),_.binding&&(0,B.jsx)(X,{label:`Channel`,value:`${_.binding.type}:${_.binding.channelId}`,className:`col-span-2`})]})}),(u||f)&&(0,B.jsx)(Zu,{title:`Agent Profile`,expanded:!!s.profile,onToggle:()=>h(`profile`),children:(0,B.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[u&&(0,B.jsx)(X,{label:`Profile`,value:u}),f?.base&&(0,B.jsx)(X,{label:`Base`,value:f.base}),f?.provider&&(0,B.jsx)(X,{label:`Provider`,value:f.provider}),f&&(0,B.jsx)(X,{label:`Unsupported`,value:String(f.unsupported.length)})]}),f?.warnings.length?(0,B.jsxs)(`div`,{className:`rounded border border-yellow-500/20 bg-yellow-500/5 px-2 py-1.5`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Projection warnings`}),(0,B.jsx)(`div`,{className:`mt-1 space-y-1`,children:f.warnings.slice(0,4).map(e=>(0,B.jsx)(`div`,{className:`break-words text-yellow-200/80`,children:e},e))})]}):null,f&&(0,B.jsx)(`div`,{className:`space-y-1`,children:f.entries.map(e=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`font-mono text-[11px]`,children:e.capability}),(0,B.jsx)(`div`,{className:`break-words text-muted-foreground`,children:e.detail})]}),(0,B.jsx)(F,{variant:e.result===`unsupported`?`destructive`:e.result===`partial`?`outline`:`secondary`,className:`h-5 text-[10px]`,children:e.result})]},e.capability))})]})}),m?.workspace&&(0,B.jsx)(Zu,{title:`Workspace`,expanded:!!s.workspace,onToggle:()=>h(`workspace`),children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs`,children:[(0,B.jsx)(X,{label:`Mode`,value:m.workspace.mode}),m.workspace.status&&(0,B.jsx)(X,{label:`Status`,value:m.workspace.status}),m.workspace.worktreePath&&(0,B.jsx)(X,{label:`Worktree`,value:m.workspace.worktreePath,className:`col-span-2`,mono:!0}),m.workspace.repoRoot&&(0,B.jsx)(X,{label:`Repo`,value:m.workspace.repoRoot,className:`col-span-2`,mono:!0}),m.workspace.branch&&(0,B.jsx)(X,{label:`Branch`,value:m.workspace.branch,className:`col-span-2`,mono:!0}),m.workspace.baseRef&&(0,B.jsx)(X,{label:`Base`,value:m.workspace.baseRef}),m.workspace.baseSha&&(0,B.jsx)(X,{label:`Base SHA`,value:m.workspace.baseSha.slice(0,12),mono:!0}),m.workspace.stewardAgentId&&(0,B.jsx)(X,{label:`Steward`,value:m.workspace.stewardAgentId,className:`col-span-2`,mono:!0})]})}),m&&(0,B.jsx)(Zu,{title:`Runtime`,expanded:!!s.runtime,onToggle:()=>h(`runtime`),children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs`,children:[m.pid&&(0,B.jsx)(X,{label:`PID`,value:String(m.pid),mono:!0}),m.sessionName&&(0,B.jsx)(X,{label:`Session`,value:m.sessionName,mono:!0}),m.supervisor&&(0,B.jsx)(X,{label:`Supervisor`,value:m.supervisor}),m.systemdUnit&&(0,B.jsx)(X,{label:`Systemd`,value:m.systemdUnit,mono:!0}),m.terminalSession&&(0,B.jsx)(X,{label:`Terminal`,value:`${m.terminalSession} (${m.terminalAvailable?`available`:`unavailable`})`,mono:!0}),m.tmuxSession&&m.tmuxSession!==m.sessionName&&(0,B.jsx)(X,{label:`Legacy tmux`,value:m.tmuxSession,mono:!0}),m.spawnRequestId&&(0,B.jsx)(X,{label:`Spawn ID`,value:m.spawnRequestId.slice(0,12),mono:!0}),m.startedAt&&(0,B.jsx)(X,{label:`Started`,value:Yt(m.startedAt)}),p&&(0,B.jsx)(X,{label:`Orchestrator`,value:`${p.hostname} (${p.id.slice(-8)})`}),p&&(0,B.jsx)(X,{label:`Orch Status`,value:p.status})]})}),v&&(0,B.jsx)(Zu,{title:`Lifecycle`,expanded:!!s.lifecycle,onToggle:()=>h(`lifecycle`),children:(0,B.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Status`}),(0,B.jsx)(F,{className:Yu[v.status]||`bg-zinc-500/20 text-zinc-400`,children:v.status})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[(0,B.jsx)(X,{label:`Restarts`,value:String(v.restartCount)}),(0,B.jsx)(X,{label:`Failures`,value:String(v.consecutiveFailures)}),v.lastSpawnAt&&(0,B.jsx)(X,{label:`Last spawn`,value:j(n,v.lastSpawnAt)}),v.lastStopAt&&(0,B.jsx)(X,{label:`Last stop`,value:j(n,v.lastStopAt)}),v.healthySince&&(0,B.jsx)(X,{label:`Healthy since`,value:j(n,v.healthySince)}),v.backoffUntil&&(0,B.jsx)(X,{label:`Backoff until`,value:v.backoffUntil>n?j(n,v.backoffUntil):`expired`})]}),v.lastError&&(0,B.jsxs)(`div`,{className:`rounded border border-red-500/20 bg-red-500/5 px-2 py-1.5`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Last error`}),(0,B.jsx)(`div`,{className:`mt-0.5 break-words text-red-300/80`,children:v.lastError})]})]})}),(0,B.jsx)(Zu,{title:`Activity (${a.length})`,expanded:!!s.activity,onToggle:()=>h(`activity`),children:a.length===0?(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No recent events`}):(0,B.jsx)(`div`,{className:`space-y-1`,children:a.slice(0,15).map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,B.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums w-14`,children:j(n,typeof e.createdAt==`number`?e.createdAt:Date.parse(String(e.createdAt)))}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.title}),e.body&&(0,B.jsx)(`span`,{className:`text-muted-foreground ml-1 break-words`,children:e.body.length>80?e.body.slice(0,80)+`...`:e.body})]})]},e.id))})}),!_&&!m&&!v&&a.length===0&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No managed-agent diagnostics available for this agent.`})]})}function Zu({title:e,expanded:t,onToggle:n,children:r}){return(0,B.jsxs)(`div`,{className:`rounded-md border border-border`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium hover:bg-muted/50`,onClick:n,children:[t?(0,B.jsx)(l,{className:`w-3 h-3`}):(0,B.jsx)(ut,{className:`w-3 h-3`}),e]}),t&&(0,B.jsx)(`div`,{className:`px-2.5 pb-2.5`,children:r})]})}function Qu(e){return wt(e)&&typeof e.profileName==`string`&&typeof e.provider==`string`&&typeof e.base==`string`&&Array.isArray(e.entries)&&Array.isArray(e.warnings)&&Array.isArray(e.unsupported)}function X({label:e,value:t,className:n=``,mono:r=!1}){return(0,B.jsxs)(`div`,{className:`min-w-0 ${n}`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,B.jsx)(`div`,{className:`truncate ${r?`font-mono`:``}`,title:t,children:t})]})}function $u({agent:e,className:t=``,onNavigate:n}){let r=typeof e.meta?.cwd==`string`?e.meta.cwd:``,i=A(e=>r?e.projectByCwd[r]:null),a=A(e=>e.fetchProjectForCwd),o=A(e=>e.openProjectFocus);return(0,z.useEffect)(()=>{r&&a(r)},[r,a]),i?(0,B.jsxs)(`button`,{type:`button`,title:`Project: ${i.title||i.slug} — open in Projects`,onClick:e=>{e.stopPropagation(),n?.(),o(i.id)},className:`inline-flex h-5 max-w-full items-center gap-1 rounded-full border border-indigo-500/30 bg-indigo-500/10 px-1.5 text-[10px] font-medium text-indigo-300 transition-colors hover:bg-indigo-500/20 ${t}`,children:[(0,B.jsx)(g,{className:`h-3 w-3 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:i.title||i.slug})]}):null}function ed({className:e}){return(0,B.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,B.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.65 7.65 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z`})})}var td={github:ed},nd=Ne;function rd({provider:e,className:t}){return(0,B.jsx)(td[e]??nd,{className:O(`shrink-0`,t)})}var id={open:`border-emerald-500/25 bg-emerald-500/10 text-emerald-300`,closed:`border-zinc-500/25 bg-zinc-500/10 text-zinc-300`,unknown:`border-amber-500/25 bg-amber-500/10 text-amber-300`},ad=1440*60*1e3;function od(e){return`${e.repo}#${e.externalKey}`}function sd(e,t){return e.statusSyncedAt?`Status synced ${j(t,e.statusSyncedAt)} (${Yt(e.statusSyncedAt)})`:`Status not yet synced`}function cd({issueRef:e,now:t=Date.now(),compact:n=!1,showSync:r=!1,className:i}){let a=od(e),o=!e.statusSyncedAt||t-e.statusSyncedAt>ad,s=[e.title?`${a}: ${e.title}`:a,`Status: ${e.status}`,sd(e,t)].join(`
|
|
19
19
|
`);return(0,B.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,title:s,"aria-label":`Open ${a}`,onClick:e=>e.stopPropagation(),className:O(`inline-flex h-5 max-w-full items-center gap-1.5 rounded-full border pl-1.5 pr-2 text-[10px] font-medium leading-none transition-colors hover:brightness-125 focus:outline-none focus-visible:ring-1 focus-visible:ring-current`,id[e.status],i),children:[(0,B.jsx)(rd,{provider:e.provider,className:`h-3 w-3 opacity-90`}),(0,B.jsx)(`span`,{className:`truncate font-mono tracking-tight`,children:a}),!n&&(0,B.jsx)(`span`,{className:`shrink-0 opacity-70`,children:e.status}),r&&!n&&(0,B.jsxs)(`span`,{className:O(`shrink-0 tabular-nums`,o?`opacity-45`:`opacity-65`),children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`mr-1 opacity-60`,children:`·`}),e.statusSyncedAt?j(t,e.statusSyncedAt):`unsynced`]}),(0,B.jsx)(ge,{className:`ml-0.5 h-2.5 w-2.5 shrink-0 opacity-60`})]})}var ld={read:`read`,edit:`edited`,done:`completed`},ud={done:`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`},dd=[];function fd(e){let t=new Map;for(let n of e){let e=t.get(n.issueRef.id),r={action:n.action,count:n.count,firstAt:n.firstAt,lastAt:n.lastAt};e?(e.actions.push(r),e.lastAt=Math.max(e.lastAt,n.lastAt)):t.set(n.issueRef.id,{issueRef:n.issueRef,actions:[r],lastAt:n.lastAt})}return[...t.values()].sort((e,t)=>t.lastAt-e.lastAt||e.issueRef.id.localeCompare(t.issueRef.id))}function pd({agentId:e,now:t}){let n=A(e=>e.fetchAgentIssueActivity),r=A(t=>t.issueActivityByAgent[e]??dd),i=A(e=>e.issueRefsById),a=A(t=>!!t.issueLoading[`agent:${e}`]),o=A(t=>t.issueErrors[`agent:${e}`]??null),s=(0,z.useMemo)(()=>fd(r.map(e=>({...e,issueRef:i[e.issueRef.id]??e.issueRef}))),[r,i]);return(0,z.useEffect)(()=>{n(e)},[e,n]),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium`,children:`Issues`}),a?(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:`loading`}):(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:s.length})]}),o?(0,B.jsx)(`div`,{className:`text-xs text-destructive`,children:o}):s.length===0?(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No issue activity recorded for this agent.`}):(0,B.jsx)(`div`,{className:`space-y-2`,children:s.map(e=>(0,B.jsxs)(`div`,{className:`rounded-md border border-border px-2.5 py-2 text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(cd,{issueRef:e.issueRef,now:t}),(0,B.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,title:Yt(e.lastAt),children:j(t,e.lastAt)})]}),(0,B.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:e.actions.map(e=>(0,B.jsxs)(F,{variant:`outline`,className:O(`text-[10px]`,ud[e.action]),title:`${e.count} event${e.count===1?``:`s`} since ${Yt(e.firstAt)}`,children:[ld[e.action],e.count>1?` ${e.count}`:``]},e.action))})]},e.issueRef.id))})]})]})}function md(e){let t=e?.meta?.tmuxSession;return typeof t==`string`&&t.trim()?t:null}function hd(e,t,n){return e?n.find(n=>n.managedAgents.some(n=>n.agentId===e.id||n.tmuxSession===t))??null:null}function gd({agent:e,health:t,showLogs:n,setTab:r,openConfirm:i,doAgentAction:a}){let o=Gt(e,`interrupt`),s=Gt(e,`restart`),c=Gt(e,`shutdown`),l=t.activeWorkLabel||t.kind;return(0,B.jsxs)(`div`,{className:`shrink-0 mx-4 mt-3 rounded-md border border-red-500/35 bg-red-500/10 px-3 py-2 text-xs text-red-100`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,B.jsx)(Me,{className:`w-3.5 h-3.5`}),`Stuck busy`]}),(0,B.jsxs)(`div`,{className:`mt-1 text-red-50/85`,children:[`No provider progress for `,Math.max(1,Math.floor(t.staleForMs/6e4)),` min while `,l,` is active.`]}),(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[o&&(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>a(e,`interrupt`,`agent-detail-drawer`),children:[(0,B.jsx)(De,{className:`w-3 h-3 mr-1`}),`Interrupt`]}),s&&(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>i(`Restart Agent`,`Restart ${M(e)}?`,()=>a(e,`restart`,`agent-detail-drawer`)),children:[(0,B.jsx)(re,{className:`w-3 h-3 mr-1`}),`Restart`]}),c&&(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>i(`Shutdown Agent`,`Shutdown ${M(e)}?`,()=>a(e,`shutdown`,`agent-detail-drawer`)),children:[(0,B.jsx)(mt,{className:`w-3 h-3 mr-1`}),`Shutdown`]}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>r(n?`logs`:`timeline`),children:[(0,B.jsx)(b,{className:`w-3 h-3 mr-1`}),`Diagnostics`]})]})]})}function _d(e){return!e||e.status!==`offline`&&e.status!==`stale`?!1:!!(typeof e.meta?.provider==`string`?e.meta.provider:e.providerCapabilities?.model?.provider)}function vd(e){for(let t of e){let e=t.metadata,n=typeof e?.claudeResumeId==`string`?e.claudeResumeId:``;if(n)return{resumeId:n,timestamp:t.ts}}return null}function yd(e,t){return!!e.spawnedBy&&e.status!==`offline`&&!dn(t,e)}function bd(e,t){let n=new Map;for(let r of e){if(!r.spawnedBy||!yd(r,t))continue;let e=n.get(r.spawnedBy);e?e.push(r):n.set(r.spawnedBy,[r])}return n}function Z(e,t,n){let r=new Set(e.map(e=>e.id)),i=bd(e,n),a=[],o=new Set;for(let s of e){if(o.has(s.id)||s.spawnedBy&&!yd(s,n))continue;let e=!!(s.spawnedBy&&r.has(s.spawnedBy));if(yd(s,n)&&e)continue;let c=i.get(s.id)??[];a.push({agent:s,depth:0,parent:s.spawnedBy?t[s.spawnedBy]??null:null,children:c}),o.add(s.id);for(let e of c)o.has(e.id)||(a.push({agent:e,depth:1,parent:s,children:[]}),o.add(e.id))}return a}function xd(e,t){let n=new Set(e.map(e=>e.id));return e.filter(e=>e.spawnedBy&&!yd(e,t)?!1:!yd(e,t)||!e.spawnedBy||!n.has(e.spawnedBy))}function Sd(e){return[...e].sort((e,t)=>M(e).localeCompare(M(t)))}var Cd={open:`bg-blue-400`,claimed:`bg-purple-300`,in_progress:`bg-purple-400`,blocked:`bg-yellow-400`,orphaned:`bg-zinc-400`,done:`bg-emerald-400`,failed:`bg-red-400`,canceled:`bg-zinc-400`};function wd({id:e,title:t,status:n,onClick:r,className:i}){let a=n?Cd[n]:void 0;return(0,B.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(e)},title:t?`Task #${e}: ${t}`:`Task #${e}`,"aria-label":`Open task #${e}`,className:O(`inline-flex h-5 max-w-full items-center gap-1.5 rounded-full border pl-1.5 pr-2 text-[10px] font-medium leading-none transition-colors hover:brightness-125 focus:outline-none focus-visible:ring-1 focus-visible:ring-current`,`border-orange-500/25 bg-orange-500/10 text-orange-300`,i),children:[a&&(0,B.jsx)(`span`,{className:O(`h-1.5 w-1.5 shrink-0 rounded-full`,a)}),(0,B.jsx)(Be,{className:`h-3 w-3 shrink-0 opacity-90`}),(0,B.jsxs)(`span`,{className:`truncate font-mono tracking-tight`,children:[`#`,e]}),t&&(0,B.jsx)(`span`,{className:`max-w-[8rem] truncate opacity-70`,children:t})]})}var Td=new Set([`done`,`failed`,`canceled`]);function Ed(e,t,n){if(n){let t=e.find(e=>e.branch&&e.branch===n);if(t)return t}if(!t)return null;let r=e.filter(e=>e.ownerAgentId===t);return r.length===0?null:r.length===1?r[0]:null}function Dd(e,t){return e.filter(e=>e.ownerAgentId===t&&!Td.has(e.status)).sort((e,t)=>Number(t.updatedAt)-Number(e.updatedAt))[0]??null}function Od(){let e=A(e=>e.agentDetailOpen),t=A(e=>e.agentDetailId),r=A(e=>e.agentsById),i=A(e=>e.messages),a=A(e=>e.orchestrators),o=A(e=>e.fetchOrchestrators),s=bt(),c=A(e=>e.set),l=A(e=>e.closeAgentDetail),u=A(e=>e.openAgentDetail),d=A(e=>e.openComposeToAgent),f=A(e=>e.openInboxThread),p=A(e=>e.openRename),h=A(e=>e.openPairInvite),g=A(e=>e.switchView),_=A(e=>e.openConfirm),v=A(e=>e.showError),y=A(e=>e.showNotification),x=A(e=>e.doAgentAction),ee=A(e=>e.doDeleteAgent),C=A(e=>e.openFilesForAgent),ne=A(e=>e.deliverableTasks),w=A(e=>e.openTaskDetail),[ae,oe]=(0,z.useState)([]),[se,T]=(0,z.useState)(null),[E,ce]=(0,z.useState)(null),[le,ue]=(0,z.useState)(`overview`),[de,fe]=(0,z.useState)(!1),[D,pe]=(0,z.useState)(null),[he,ge]=(0,z.useState)(!1),[O,ye]=(0,z.useState)(null),be=A(e=>e.livenessMismatches),xe=A(e=>e.commandStalls),k=r[t]||null,Se=Zc(),Ce=k?Se[k.id]??null:null,we=(0,z.useMemo)(()=>Object.values(r),[r]),Te=(0,z.useMemo)(()=>t?i.filter(e=>e.from===t||e.to===t).sort((e,t)=>t.id-e.id).slice(0,8):[],[i,t]);(0,z.useEffect)(()=>{if(!e||!k?.context){oe([]);return}let t=!1;return Ee(`GET`,`/agents/`+encodeURIComponent(k.id)+`/context-snapshots?limit=24`).then(e=>{t||oe(e)}).catch(()=>{t||oe([])}),()=>{t=!0}},[e,k?.id,k?.context?.lastUpdatedAt]),(0,z.useEffect)(()=>{if(ye(null),!e||!k||!_d(k))return;let t=!1;return Ee(`GET`,`/agents/`+encodeURIComponent(k.id)+`/timeline?limit=50`).then(e=>{t||ye(vd(e))}).catch(()=>{t||ye(null)}),()=>{t=!0}},[e,k?.id,k?.status,k?.meta?.provider]),(0,z.useEffect)(()=>{if(!e||!k){T(null);return}let t=!1;return Ee(`GET`,`/agents/`+encodeURIComponent(k.id)+`/active-memories`).then(e=>{t||T(e)}).catch(()=>{t||T(null)}),()=>{t=!0}},[e,k?.id]),(0,z.useEffect)(()=>{if(!e||!k){ce(null);return}let t=!1;return Ee(`GET`,`/agents/`+encodeURIComponent(k.id)+`/crash-report`).then(e=>{t||ce(e.report)}).catch(()=>{t||ce(null)}),()=>{t=!0}},[e,k?.id]),(0,z.useEffect)(()=>{ue(`overview`),fe(!1),pe(null)},[t]),(0,z.useEffect)(()=>{e&&k?.meta?.tmuxSession&&a.length===0&&o()},[e,k?.id,k?.meta?.tmuxSession,a.length]);async function De(){if(k)try{if(!(await Ee(`DELETE`,`/agents/`+encodeURIComponent(k.id)+`/active-memories`)).supported){v(`Memory Clear Unavailable`,`The active memory broker does not support clearing active memories.`);return}T({agentId:k.id,supported:!0,memories:[],total:0}),y(`Active memories cleared`)}catch(e){v(`Memory Clear Failed`,e.message)}}async function Oe(){if(!(!k||he)){ge(!0);try{pe(await Ee(`POST`,`/agents/`+encodeURIComponent(k.id)+`/terminal-session`)),fe(!0)}catch(e){v(`Terminal Failed`,e.message)}finally{ge(!1)}}}async function ke(e){if(e){fe(!0);return}fe(!1);let t=D;if(pe(null),k&&t?.mode===`guest`)try{await Ee(`DELETE`,`/agents/`+encodeURIComponent(k.id)+`/terminal-session/`+encodeURIComponent(t.session))}catch{}}if(!k)return(0,B.jsx)(lu,{open:e,onOpenChange:e=>!e&&l(),children:(0,B.jsx)(pu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg`,children:(0,B.jsx)(mu,{children:(0,B.jsx)(hu,{children:`Agent`})})})});let je=Xt(s,k,en(),Ce),Ne=Gt(k,`restart`),Fe=Gt(k,`shutdown`),Ie=Gt(k,`reconnect`),Le=Gt(k,`compact`),Re=Gt(k,`clearContext`),Be=!!(O&&_d(k)),He=tn(k),Ue=Id(k.meta?.package),We=Ld(k.meta?.contracts),Ke=k.providerCapabilities,qe=Mt(k),Je=Hu(k),Ye=cn(k),Xe=md(k),Ze=Xe?hd(k,Xe,a):null,Qe=!!(Xe&&Ze?.status===`online`&&k.providerCapabilities?.terminal?.live?.read),$e=!!(Qe&&k.providerCapabilities?.terminal?.live?.write),et=k.providerCapabilities?.terminal?.attach?.create===!0,tt=Qe||et,nt=Bd(k.meta?.lastExit),rt=typeof k.meta?.lastError==`string`?k.meta.lastError:nt?.lastError,it=k.spawnedBy?r[k.spawnedBy]??null:null,ot=Sd(bd(we,s).get(k.id)??[]),st=be[k.id]??null,ct=(je.tone===`offline`||je.tone===`stale`)&&Qe,lt=!!st||ct,ut=xe[k.id]??null,dt=Ju(s,k),pt=Dd(ne,k.id);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(lu,{open:e,onOpenChange:e=>!e&&l(),children:(0,B.jsxs)(pu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,B.jsxs)(mu,{className:`shrink-0 p-4 border-b border-border`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(xu,{agent:k,now:s}),(0,B.jsx)(ku,{agent:k}),(0,B.jsx)(hu,{className:`text-base truncate`,children:M(k)}),zu(k)&&(0,B.jsx)(Vu,{context:k.context,expected:!0})]}),(0,B.jsx)(ju,{agent:k,className:`mt-2`})]}),(0,B.jsxs)(`div`,{className:`shrink-0 flex flex-wrap items-center gap-2 p-4 border-b border-border`,children:[(0,B.jsxs)(I,{size:`sm`,variant:`outline`,onClick:()=>{d(k),l()},children:[(0,B.jsx)(ze,{className:`w-3 h-3 mr-1`}),`Message`]}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,onClick:()=>{f(k.id),g(`chat`),l()},children:[(0,B.jsx)(Ge,{className:`w-3 h-3 mr-1`}),`Chat`]}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,onClick:()=>{h(k.id),l()},children:[(0,B.jsx)(Pe,{className:`w-3 h-3 mr-1`}),`Pair`]}),tt&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,disabled:he,title:et?`Open guest terminal`:`Open live terminal`,onClick:()=>void Oe(),children:(0,B.jsx)(ve,{className:`w-3.5 h-3.5`})}),Be&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Resume session`,onClick:()=>_(`Resume Session`,`Resume ${M(k)} from session ${O?.resumeId}? This can reload a large prior context and consume tokens.`,()=>x(k,`resume`,`agent-detail-drawer`)),children:(0,B.jsx)(Ve,{className:`w-3.5 h-3.5`})}),Le&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Compact context`,onClick:()=>_(`Compact Agent`,`Compact context for ${M(k)}?`,()=>x(k,`compact`,`agent-detail-drawer`)),children:(0,B.jsx)(n,{className:`w-3.5 h-3.5`})}),Ne&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Restart`,onClick:()=>_(`Restart Agent`,`Restart ${M(k)}?`,()=>x(k,`restart`,`agent-detail-drawer`)),children:(0,B.jsx)(re,{className:`w-3.5 h-3.5`})}),Fe&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Shutdown`,onClick:()=>_(`Shutdown Agent`,`Shutdown ${M(k)}?`,()=>x(k,`shutdown`,`agent-detail-drawer`)),children:(0,B.jsx)(mt,{className:`w-3.5 h-3.5`})}),(0,B.jsxs)(ml,{children:[(0,B.jsx)(hl,{asChild:!0,children:(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`px-2`,children:(0,B.jsx)(_e,{className:`w-3.5 h-3.5`})})}),(0,B.jsxs)(gl,{align:`end`,children:[tt&&(0,B.jsxs)(_l,{className:`sm:hidden`,disabled:he,onClick:()=>void Oe(),children:[(0,B.jsx)(ve,{className:`w-3.5 h-3.5`}),`Terminal`]}),Be&&(0,B.jsxs)(_l,{className:`sm:hidden`,onClick:()=>_(`Resume Session`,`Resume ${M(k)} from session ${O?.resumeId}? This can reload a large prior context and consume tokens.`,()=>x(k,`resume`,`agent-detail-drawer`)),children:[(0,B.jsx)(Ve,{className:`w-3.5 h-3.5`}),`Resume`]}),Le&&(0,B.jsxs)(_l,{className:`sm:hidden`,onClick:()=>_(`Compact Agent`,`Compact context for ${M(k)}?`,()=>x(k,`compact`,`agent-detail-drawer`)),children:[(0,B.jsx)(n,{className:`w-3.5 h-3.5`}),`Compact`]}),Ne&&(0,B.jsxs)(_l,{className:`sm:hidden`,onClick:()=>_(`Restart Agent`,`Restart ${M(k)}?`,()=>x(k,`restart`,`agent-detail-drawer`)),children:[(0,B.jsx)(re,{className:`w-3.5 h-3.5`}),`Restart`]}),Fe&&(0,B.jsxs)(_l,{className:`sm:hidden`,onClick:()=>_(`Shutdown Agent`,`Shutdown ${M(k)}?`,()=>x(k,`shutdown`,`agent-detail-drawer`)),children:[(0,B.jsx)(mt,{className:`w-3.5 h-3.5`}),`Shutdown`]}),(tt||Be||Le||Ne||Fe)&&(0,B.jsx)(yl,{className:`sm:hidden`}),(0,B.jsxs)(_l,{onClick:()=>p(k),children:[(0,B.jsx)(S,{className:`w-3.5 h-3.5`}),`Rename`]}),Ie&&(0,B.jsxs)(_l,{onClick:()=>_(`Reconnect Agent`,`Reconnect ${M(k)}?`,()=>x(k,`reconnect`,`agent-detail-drawer`)),children:[(0,B.jsx)(te,{className:`w-3.5 h-3.5`}),`Reconnect`]}),Re&&(0,B.jsxs)(_l,{onClick:()=>_(`Clear Context`,`Clear context for ${M(k)}?`,()=>x(k,`clearContext`,`agent-detail-drawer`)),children:[(0,B.jsx)(me,{className:`w-3.5 h-3.5`}),`Clear Context`]}),He&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(yl,{}),(0,B.jsxs)(_l,{variant:`destructive`,onClick:()=>_(`Forget Agent`,`Forget ${M(k)}?`,()=>ee(k.id)),children:[(0,B.jsx)(Ae,{className:`w-3.5 h-3.5`}),`Forget`]})]})]})]})]}),lt&&(0,B.jsxs)(`div`,{className:`shrink-0 mx-4 mt-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,B.jsx)(Me,{className:`w-3.5 h-3.5`}),`Liveness mismatch`]}),(0,B.jsx)(`div`,{className:`mt-1 text-amber-50/85`,children:st?.detail??`Relay marks this agent offline, but a live terminal session is still reachable — the process may still be running.`}),tt&&(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`mt-2 h-7 text-xs`,disabled:he,onClick:()=>void Oe(),children:[(0,B.jsx)(ve,{className:`w-3 h-3 mr-1`}),`Open terminal`]})]}),ut&&(0,B.jsxs)(`div`,{className:`shrink-0 mx-4 mt-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,B.jsx)(Me,{className:`w-3.5 h-3.5`}),ut.kind===`clear`?`Context clear stalled`:`Compaction stalled`]}),(0,B.jsx)(`div`,{className:`mt-1 text-amber-50/85`,children:ut.detail}),tt&&(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`mt-2 h-7 text-xs`,disabled:he,onClick:()=>void Oe(),children:[(0,B.jsx)(ve,{className:`w-3 h-3 mr-1`}),`Open terminal`]})]}),dt&&(0,B.jsx)(gd,{agent:k,health:dt,showLogs:!!Xe,setTab:ue,openConfirm:_,doAgentAction:x}),(0,B.jsxs)(gu,{value:le,onValueChange:e=>ue(e),className:`flex-1 min-h-0 gap-0`,children:[(0,B.jsxs)(vu,{variant:`line`,className:`w-full shrink-0 px-4 pt-2`,children:[(0,B.jsx)(yu,{value:`overview`,children:`Overview`}),(0,B.jsxs)(yu,{value:`timeline`,children:[(0,B.jsx)(m,{className:`w-3.5 h-3.5`}),`Timeline`]}),(0,B.jsxs)(yu,{value:`logs`,children:[(0,B.jsx)(b,{className:`w-3.5 h-3.5`}),`Logs`]})]}),(0,B.jsx)(bu,{value:`overview`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:(0,B.jsxs)(`div`,{className:`p-4 space-y-4 min-w-0`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Status`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`State`}),(0,B.jsx)(F,{className:Lt(je.tone),children:je.label})]}),pt&&(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Working on`}),(0,B.jsx)(wd,{id:pt.id,title:pt.title,status:pt.status,onClick:()=>w(pt)})]}),qe?.recommendedAction&&(0,B.jsxs)(`div`,{className:`rounded-md border border-red-500/20 bg-red-500/10 px-2.5 py-2 text-xs text-red-200`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,B.jsx)(ft,{className:`w-3.5 h-3.5`}),`Recommended action`]}),(0,B.jsx)(`div`,{className:`mt-1 text-red-100/80`,children:qe.recommendedAction})]}),rt&&(0,B.jsxs)(`div`,{className:`rounded-md border border-amber-500/25 bg-amber-500/10 px-2.5 py-2 text-xs text-amber-100`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,B.jsx)(ft,{className:`w-3.5 h-3.5`}),`Last launch error`]}),(0,B.jsx)(`div`,{className:`mt-1 break-words text-amber-50/85`,children:rt}),nt&&(0,B.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-amber-50/70`,children:[nt.detectedAt&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-amber-100/55`,children:`Detected`}),(0,B.jsx)(`div`,{children:j(s,nt.detectedAt)})]}),typeof nt.runtimeMs==`number`&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-amber-100/55`,children:`Runtime`}),(0,B.jsxs)(`div`,{children:[Math.max(0,Math.round(nt.runtimeMs/1e3)),`s`]})]}),nt.systemd?.unit&&(0,B.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-amber-100/55`,children:`Unit`}),(0,B.jsx)(`div`,{className:`truncate font-mono`,children:nt.systemd.unit})]}),nt.systemd&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-amber-100/55`,children:`Systemd`}),(0,B.jsx)(`div`,{children:[nt.systemd.activeState,nt.systemd.subState].filter(Boolean).join(`/`)||`unknown`})]}),nt.systemd?.result&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-amber-100/55`,children:`Result`}),(0,B.jsx)(`div`,{children:nt.systemd.result})]}),nt.logFile&&(0,B.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-amber-100/55`,children:`Log`}),(0,B.jsxs)(`div`,{className:`truncate font-mono`,children:[nt.logFile,` (`,nt.logBytes??`unknown`,` bytes`,nt.logEmpty?`, empty`:``,`)`]})]})]}),nt?.logTail?.length?(0,B.jsx)(`pre`,{className:`mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded border border-amber-500/15 bg-black/20 p-2 text-[11px] text-amber-50/75`,children:nt.logTail.slice(-5).join(`
|
|
20
20
|
`)}):null,nt?.unavailable?.length?(0,B.jsx)(`div`,{className:`mt-1 text-amber-50/55`,children:nt.unavailable.join(`; `)}):null]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 pt-0.5 text-xs`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Last seen`}),(0,B.jsx)(`div`,{children:j(s,k.lastSeen)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Created`}),(0,B.jsx)(`div`,{title:Yt(k.createdAt),children:j(s,k.createdAt)})]})]})]})]}),E&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(zd,{report:E,now:s})]}),k.context&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(Md,{context:k.context,tokens:Je,history:ae,now:s})]}),(0,B.jsx)(pd,{agentId:k.id,now:s}),(k.spawnedBy||ot.length>0||Ce)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Relationships`}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[k.spawnedBy&&(0,B.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-muted-foreground`,children:`Spawned by`}),(0,B.jsx)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded px-1 py-1 text-left hover:bg-muted/50 disabled:pointer-events-none disabled:opacity-60`,disabled:!it,onClick:()=>it&&u(it),children:it?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(xu,{agent:it,now:s}),(0,B.jsx)(ku,{agent:it}),(0,B.jsx)(`span`,{className:`truncate font-medium`,children:M(it)})]}):(0,B.jsx)(`span`,{className:`truncate font-mono`,children:k.spawnedBy})})]}),ot.length>0&&(0,B.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Children`}),(0,B.jsx)(F,{variant:`secondary`,className:`h-4 px-1.5 text-[9px]`,children:ot.length})]}),(0,B.jsx)(`div`,{className:`space-y-1`,children:ot.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded px-1 py-1 text-left hover:bg-muted/50`,onClick:()=>u(e),children:[(0,B.jsx)(xu,{agent:e,now:s}),(0,B.jsx)(ku,{agent:e}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:M(e)}),(0,B.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.status})]},e.id))})]}),k.spawnedBy&&ot.length===0&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(at,{className:`h-3.5 w-3.5`}),`No live child agents`]}),Ce&&(0,B.jsxs)(`div`,{className:`rounded-md border border-border p-2 text-xs`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Pair`}),(0,B.jsx)(F,{className:Ce.status===`active`?`bg-emerald-500/20 text-emerald-400`:`bg-yellow-500/20 text-yellow-400`,children:Ce.status})]}),Ce.objective&&(0,B.jsx)(`p`,{className:`text-muted-foreground`,children:Ce.objective})]})]})]})]}),(Ke||Ye.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Runtime`}),(0,B.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[qe&&(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Provider state`}),(0,B.jsx)(`div`,{children:qe.state})]}),qe.reason&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Reason`}),(0,B.jsx)(`div`,{children:qe.reason})]}),qe.source&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Source`}),(0,B.jsx)(`div`,{children:qe.source})]}),qe.updatedAt&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Updated`}),(0,B.jsx)(`div`,{children:j(s,qe.updatedAt)})]})]}),Ke?.model&&(0,B.jsxs)(`div`,{className:`space-y-1`,children:[Ke.model.provider&&(0,B.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Provider`}),(0,B.jsx)(`span`,{className:`truncate`,children:Ke.model.provider})]}),(Ke.model.alias||Ke.model.id)&&(0,B.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Model`}),(0,B.jsx)(`span`,{className:`truncate`,children:Ke.model.alias||Ke.model.id})]}),Ke.model.effort&&(0,B.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Effort`}),(0,B.jsx)(`span`,{className:`truncate`,children:Ke.model.effort})]})]}),Ke?.session&&(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[Ke.session.approvalMode&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Mode`}),(0,B.jsx)(`div`,{children:Ke.session.approvalMode})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Files`}),(0,B.jsx)(`div`,{children:Ke.session.fileWrite?`read/write`:Ke.session.fileRead?`read-only`:`none`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Shell`}),(0,B.jsx)(`div`,{children:Ke.session.shell?`yes`:`no`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Confidence`}),(0,B.jsx)(`div`,{children:Ke.confidence})]})]}),Ke?.lifecycle&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Lifecycle`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[(0,B.jsx)(F,{variant:Ke.lifecycle.managed?`secondary`:`outline`,className:`text-[10px]`,children:Ke.lifecycle.managed?`managed`:`bridge`}),Ke.lifecycle.shutdownHard&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:`shutdown`}),Ke.lifecycle.restartHard&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:`restart`}),Ke.lifecycle.reconnect&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:`reconnect`})]})]}),Ye.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Subagents`}),(0,B.jsx)(`div`,{className:`space-y-1 mt-1`,children:Ye.map(e=>(0,B.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs rounded border border-border px-2 py-1`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:e.label}),e.role&&(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e.role})]},e.id))})]})]})]})]}),se&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2`,children:[(0,B.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-1.5`,children:[(0,B.jsx)(ie,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Memory`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[se.supported&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:se.memories.length}),se.supported&&se.memories.length>0&&(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,onClick:()=>_(`Clear Active Memories`,`Clear active memories for ${M(k)}?`,De),children:[(0,B.jsx)(me,{className:`w-3 h-3`}),`Clear`]})]})]}),se.supported?se.memories.length===0?(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No active memories`}):(0,B.jsx)(`div`,{className:`space-y-2`,children:se.memories.map(e=>(0,B.jsx)(kd,{memory:e,now:s,onOpen:()=>{c({selectedMemoryId:e.id}),g(`memory`),l()}},e.id))}):(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Active memory list unavailable`})]})]}),k.meta?.runnerManaged===!0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(Xu,{agent:k,orchestrators:a})]}),(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Identity`}),(0,B.jsxs)(`div`,{className:`space-y-2.5 text-sm min-w-0`,children:[(0,B.jsx)(jd,{label:`Agent ID`,value:k.id,copyLabel:`Copy agent ID`}),typeof k.meta?.cwd==`string`&&k.meta.cwd&&(0,B.jsx)(jd,{label:`Working dir`,value:k.meta.cwd,copyLabel:`Copy working dir`,title:`Open ${k.meta.cwd} in Files`,onClick:()=>{l(),C(k)}}),(0,B.jsx)($u,{agent:k,onNavigate:l}),(k.machine||k.rig||Ue)&&(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1.5 text-xs`,children:[k.machine&&(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Machine`}),(0,B.jsx)(`div`,{className:`truncate`,title:k.machine,children:k.machine})]}),k.rig&&(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Rig`}),(0,B.jsx)(`div`,{className:`truncate`,title:k.rig,children:k.rig})]}),Ue&&(0,B.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Package`}),(0,B.jsxs)(`div`,{className:`break-all font-mono`,children:[Ue.name,` v`,Ue.version]})]})]}),We.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Contracts`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:We.map(([e,t])=>(0,B.jsxs)(F,{variant:`secondary`,className:`text-[10px]`,children:[e,`=`,t]},e))})]}),k.tags.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Tags`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:k.tags.map(e=>(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:e},e))})]}),Wt(k.capabilities).length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Capabilities`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:Wt(k.capabilities).map(e=>(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]})]}),Te.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`details`,{className:`group`,children:[(0,B.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm font-medium`,children:[(0,B.jsx)(`span`,{children:`Recent messages`}),(0,B.jsxs)(`span`,{className:`text-[11px] font-normal text-muted-foreground`,children:[Te.length,` `,(0,B.jsx)(`span`,{className:`group-open:hidden`,children:`· show`}),(0,B.jsx)(`span`,{className:`hidden group-open:inline`,children:`· hide`})]})]}),(0,B.jsx)(`div`,{className:`mt-2 space-y-2`,children:Te.map(e=>(0,B.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:Jt(e.from,r)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,B.jsx)(`span`,{className:`truncate max-w-[40%]`,children:Jt(e.to,r)}),(0,B.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,B.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),j(s,e.createdAt)]})]}),(0,B.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:Qt(e)})]},e.id))})]})]})]})}),(0,B.jsx)(bu,{value:`timeline`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:(0,B.jsx)(Q,{agentId:k.id,open:e&&le===`timeline`,now:s})}),(0,B.jsx)(bu,{value:`logs`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:Xe&&Ze?(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsx)(qu,{orchestratorId:Ze.id,session:Xe})}):(0,B.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No session logs available for this agent.`})})]})]})}),D&&(0,B.jsx)(Y,{open:de,onOpenChange:e=>void ke(e),orchestratorId:D.orchestratorId,session:D.session,interactive:D.interactive||$e})]})}function kd({memory:e,now:t,onOpen:n}){let r=e.sensitivity===`secret`?`bg-red-500/10 text-red-400 border-red-500/30`:e.sensitivity===`sensitive`?`bg-yellow-500/10 text-yellow-400 border-yellow-500/30`:`bg-zinc-500/10 text-zinc-400 border-zinc-500/30`;return(0,B.jsx)(`button`,{onClick:n,className:`w-full rounded-md border border-border p-2 text-left text-xs hover:border-zinc-600 transition-colors`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:e.type}),(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] font-mono`,children:e.scope}),(0,B.jsx)(F,{className:`text-[10px] ${r}`,children:e.sensitivity})]}),(0,B.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),(0,B.jsx)(`div`,{className:`text-muted-foreground line-clamp-2 mt-0.5`,children:e.content})]}),(0,B.jsx)(`div`,{className:`shrink-0 text-right text-[10px] text-muted-foreground`,title:Yt(e.lastAccessedAt??e.updatedAt),children:j(t,e.lastAccessedAt??e.updatedAt)})]})})}function Ad(e){return e>=.8?`text-red-400`:e>=.6?`text-yellow-400`:`text-emerald-400`}function jd({label:e,value:t,onClick:n,title:r,copyLabel:i}){let a=`block w-full break-all text-left font-mono text-xs leading-snug ${n?`text-muted-foreground transition-colors hover:text-foreground`:`text-foreground`}`;return(0,B.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,B.jsx)(Wn,{value:t,label:i??`Copy ${e.toLowerCase()}`,size:`icon-xs`,className:`-my-1 shrink-0 text-muted-foreground`})]}),n?(0,B.jsx)(`button`,{type:`button`,className:a,title:r,onClick:n,children:t}):(0,B.jsx)(`div`,{className:a,title:r,children:t})]})}function Md({context:e,tokens:t,history:n,now:r}){let i=Number.isFinite(e.utilization)?Math.max(0,Math.min(1,e.utilization)):null,a=i===null?null:Math.round(i*100),o=i===null?`text-muted-foreground`:Ad(i);return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 min-w-0`,children:[(0,B.jsx)(`h3`,{className:`shrink-0 text-sm font-medium`,children:`Context`}),(0,B.jsxs)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:`source ${e.source}, confidence ${e.confidence}`,children:[e.lifecycleState,` · `,e.source,`/`,e.confidence]})]}),(0,B.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,B.jsx)(`span`,{className:`text-2xl font-semibold leading-none ${o}`,children:a===null?`—`:`${a}%`}),t&&(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t,` tokens`]})]}),n.length>1&&(0,B.jsx)(Nd,{snapshots:n,now:r}),e.warmTopics.length>0&&(0,B.jsxs)(`div`,{className:`mt-2`,children:[(0,B.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Warm topics`}),(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.warmTopics.map(e=>(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:e},e))})]})]})}function Nd({snapshots:e,now:t}){let n=e.slice(-24),[r,i]=(0,z.useState)(null);if(n.length<2)return null;let a=n.length,o=e=>Math.max(0,Math.min(1,e)),s=e=>({x:e/(a-1)*100,y:40-o(n[e].utilization)*40}),c=n.map((e,t)=>{let n=s(t);return`${n.x.toFixed(2)},${n.y.toFixed(2)}`}).join(` `),l=Ad(o(n[a-1].utilization)),u=r==null?n[a-1]:n[r],d=s(r??a-1);return(0,B.jsxs)(`div`,{className:`mt-2`,children:[(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsxs)(`svg`,{viewBox:`0 0 100 40`,preserveAspectRatio:`none`,className:`h-12 w-full`,"aria-label":`Context utilization history`,children:[(0,B.jsx)(`line`,{x1:`0`,y1:`20`,x2:`100`,y2:`20`,className:`stroke-muted-foreground/15`,strokeWidth:`0.5`,strokeDasharray:`2 2`}),(0,B.jsx)(`polygon`,{points:`0,40 ${c} 100,40`,className:`fill-current text-primary/10`}),(0,B.jsx)(`polyline`,{points:c,fill:`none`,className:`stroke-current ${l}`,strokeWidth:`1.25`,strokeLinejoin:`round`,strokeLinecap:`round`,vectorEffect:`non-scaling-stroke`}),(0,B.jsx)(`circle`,{cx:d.x,cy:d.y,r:`1.6`,className:`fill-current ${l}`,vectorEffect:`non-scaling-stroke`})]}),(0,B.jsx)(`div`,{className:`absolute inset-0 flex`,children:n.map((e,t)=>(0,B.jsx)(`button`,{type:`button`,"aria-label":`${Math.round(o(e.utilization)*100)}% utilization`,className:`h-full flex-1`,onClick:()=>i(t===r?null:t)},e.id))})]}),(0,B.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:r==null?(0,B.jsxs)(B.Fragment,{children:[a,` samples · since `,j(t,n[0].capturedAt)]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:l,children:[Math.round(o(u.utilization)*100),`%`]}),` · `,new Date(u.capturedAt).toLocaleTimeString()]})}),(0,B.jsx)(`span`,{children:`0–100%`})]})]})}function Q({agentId:e,open:t,now:n}){let[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(50),d=(0,z.useCallback)(t=>{o(!0),c(null);let n=!1;return Ee(`GET`,`/agents/`+encodeURIComponent(e)+`/timeline?limit=`+t).then(e=>{n||(i(e),u(t))}).catch(e=>{n||c(e.message)}).finally(()=>{n||o(!1)}),()=>{n=!0}},[e]);return(0,z.useEffect)(()=>{if(t)return d(50)},[t,e,d]),(0,B.jsxs)(`div`,{className:`p-4 space-y-3 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium`,children:`Timeline`}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,disabled:a,onClick:()=>d(l),children:[(0,B.jsx)(te,{className:`w-3 h-3 mr-1`}),`Refresh`]})]}),s&&(0,B.jsx)(`div`,{className:`text-xs text-red-300`,children:s}),!s&&r.length===0&&!a&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No timeline activity recorded for this agent.`}),(0,B.jsx)(`div`,{className:`space-y-1.5`,children:r.map((e,t)=>(0,B.jsx)(Fd,{entry:e,now:n},`${e.ts}:${e.source}:${t}`))}),r.length>=l&&l<200&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`w-full h-7 text-xs`,disabled:a,onClick:()=>d(200),children:`Load full timeline`})]})}function Pd(e){return e.metadata?.mismatch===!0||e.metadata?.stalled===!0?(0,B.jsx)(Me,{className:`w-3.5 h-3.5 text-amber-400`}):e.source===`command`?(0,B.jsx)(ve,{className:`w-3.5 h-3.5 text-sky-400`}):e.source===`delivery`?(0,B.jsx)(ze,{className:`w-3.5 h-3.5 text-violet-400`}):e.kind===`state`?(0,B.jsx)(C,{className:`w-3.5 h-3.5 text-emerald-400`}):(0,B.jsx)(pe,{className:`w-3.5 h-3.5 text-muted-foreground`})}function Fd({entry:e,now:t}){let n=typeof e.metadata?.status==`string`?e.metadata.status:``,r=/fail|error|poison|dead/i.test(n),i=e.metadata?.fromState,a=e.metadata?.toState,o=typeof i==`string`&&typeof a==`string`?`${i} → ${a}`:null;return(0,B.jsxs)(`div`,{className:`flex gap-2 rounded border border-border px-2 py-1.5 text-xs min-w-0`,children:[(0,B.jsx)(`div`,{className:`shrink-0 mt-0.5`,children:Pd(e)}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium truncate ${r?`text-red-300`:`text-foreground`}`,children:e.title}),(0,B.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground`,title:Yt(e.ts),children:j(t,e.ts)})]}),o&&(0,B.jsx)(`div`,{className:`text-muted-foreground font-mono text-[11px]`,children:o}),e.detail&&(0,B.jsx)(`div`,{className:`text-muted-foreground whitespace-pre-wrap break-words line-clamp-3`,children:e.detail})]})]})}function Id(e){return wt(e)&&typeof e.name==`string`&&typeof e.version==`string`?{name:e.name,version:e.version}:null}function Ld(e){return wt(e)?Object.entries(e).filter(e=>typeof e[1]==`number`):[]}var Rd={oom:`bg-red-500/20 text-red-400`,killed:`bg-red-500/20 text-red-400`,"provider-crash":`bg-orange-500/20 text-orange-400`,"token-401":`bg-amber-500/20 text-amber-400`,"onboarding-gate":`bg-amber-500/20 text-amber-400`,"transport-loss":`bg-sky-500/20 text-sky-400`,"clean-exit":`bg-emerald-500/20 text-emerald-400`,unknown:`bg-zinc-500/20 text-zinc-400`};function zd({report:e,now:t}){let n=e.diagnosis,r=Rd[n.cause]??`bg-zinc-500/20 text-zinc-400`;return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`h3`,{className:`text-sm font-medium mb-2 flex items-center gap-1.5`,children:[(0,B.jsx)(ft,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Why it died`]}),(0,B.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2.5 text-xs space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(F,{className:r,children:n.cause}),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[n.confidence,` confidence`]}),(0,B.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,title:Yt(n.detectedAt),children:j(t,n.detectedAt)})]}),(0,B.jsx)(`div`,{className:`font-medium text-foreground`,children:n.summary}),n.evidence.length>0&&(0,B.jsx)(`ul`,{className:`space-y-0.5 text-muted-foreground`,children:n.evidence.map((e,t)=>(0,B.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,B.jsx)(`span`,{className:`shrink-0 text-muted-foreground/50`,children:`·`}),(0,B.jsx)(`span`,{children:e})]},t))}),(n.signal!=null||n.exitCode!=null||n.oom===!0||n.heartbeatGapMs!=null||(n.activeWork?.length??0)>0)&&(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-[11px] pt-0.5`,children:[n.signal!=null&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Signal`}),(0,B.jsx)(`div`,{className:`font-mono`,children:n.signal})]}),n.exitCode!=null&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Exit code`}),(0,B.jsx)(`div`,{className:`font-mono`,children:n.exitCode})]}),n.oom===!0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`OOM`}),(0,B.jsx)(`div`,{children:`yes`})]}),n.heartbeatGapMs!=null&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Heartbeat gap`}),(0,B.jsxs)(`div`,{children:[Math.round(n.heartbeatGapMs/1e3),`s`]})]}),(n.activeWork?.length??0)>0&&(0,B.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Active work`}),(0,B.jsx)(`div`,{className:`truncate`,children:n.activeWork.join(`, `)})]})]}),n.logTail&&n.logTail.length>0&&(0,B.jsx)(`pre`,{className:`mt-1 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded border border-border bg-black/20 p-2 text-[11px] text-muted-foreground`,children:n.logTail.slice(-5).join(`
|
|
21
|
-
`)})]})]})}function Bd(e){if(!wt(e)||typeof e.lastError!=`string`)return null;let t=wt(e.systemd)?{unit:typeof e.systemd.unit==`string`?e.systemd.unit:void 0,activeState:typeof e.systemd.activeState==`string`?e.systemd.activeState:void 0,subState:typeof e.systemd.subState==`string`?e.systemd.subState:void 0,result:typeof e.systemd.result==`string`?e.systemd.result:void 0,execMainCode:typeof e.systemd.execMainCode==`string`?e.systemd.execMainCode:void 0,execMainStatus:typeof e.systemd.execMainStatus==`string`?e.systemd.execMainStatus:void 0}:void 0;return{lastError:e.lastError,detectedAt:typeof e.detectedAt==`number`?e.detectedAt:void 0,runtimeMs:typeof e.runtimeMs==`number`?e.runtimeMs:void 0,logFile:typeof e.logFile==`string`?e.logFile:void 0,logBytes:typeof e.logBytes==`number`?e.logBytes:void 0,logEmpty:typeof e.logEmpty==`boolean`?e.logEmpty:void 0,logTail:Array.isArray(e.logTail)?e.logTail.filter(e=>typeof e==`string`):void 0,systemd:t,unavailable:Array.isArray(e.unavailable)?e.unavailable.filter(e=>typeof e==`string`):void 0}}function Vd({className:e,children:t,...n}){return(0,B.jsxs)(bs,{"data-slot":`scroll-area`,className:O(`relative`,e),...n,children:[(0,B.jsx)(xs,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1`,children:t}),(0,B.jsx)(Hd,{}),(0,B.jsx)(Ss,{})]})}function Hd({className:e,orientation:t=`vertical`,...n}){return(0,B.jsx)(Jo,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:O(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,B.jsx)(as,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Ud(){let e=A(e=>e.channelDetailOpen),t=A(e=>e.channelDetailId),n=A(e=>e.channels),r=A(e=>e.messages),i=A(e=>e.agentsById),a=bt(),o=A(e=>e.closeChannelDetail),s=n.find(e=>e.id===t)||null,c=Kt(s),l=(0,z.useMemo)(()=>s?r.filter(e=>Zt(e,s)).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,s]);return(0,B.jsx)(lu,{open:e,onOpenChange:e=>!e&&o(),children:(0,B.jsxs)(pu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,B.jsx)(mu,{className:`shrink-0 p-4 border-b border-border`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(F,{className:Lt(c.tone),children:c.label}),(0,B.jsx)(hu,{className:`text-base truncate`,children:s?.name||`Channel`})]})}),(0,B.jsx)(Vd,{className:`flex-1 min-h-0`,children:(0,B.jsxs)(`div`,{className:`p-4 space-y-4`,children:[s&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Route`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Type`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.type})]}),(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Direction`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.direction})]}),s.target&&(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Target`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.target})]}),(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Agent`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.agentId})]}),(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Transport`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.transport})]}),(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Last seen`}),(0,B.jsx)(`span`,{className:`shrink-0`,children:j(a,s.lastSeen)})]})]})]}),Wt(s.capabilities).length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Capabilities`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Wt(s.capabilities).map(e=>(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]}),s.meta&&Object.keys(s.meta).length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,B.jsx)(`div`,{className:`space-y-1 text-sm`,children:Object.entries(s.meta).map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,B.jsx)(`span`,{className:`truncate`,children:String(t)})]},e))})]})]})]}),l.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Recent Messages`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:l.map(e=>(0,B.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:Jt(e.from,i)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,B.jsx)(`span`,{className:`truncate max-w-[40%]`,children:Jt(e.to,i)}),(0,B.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,B.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),j(a,e.createdAt)]})]}),(0,B.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:Qt(e)})]},e.id))})]})]})]})})]})})}function Wd({className:e,...t}){return(0,B.jsx)(`textarea`,{"data-slot":`textarea`,className:O(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function $({className:e,...t}){return(0,B.jsx)(Lo,{"data-slot":`label`,className:O(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var Gd={none:`None`,uncommitted:`Uncommitted`,"committed-on-branch":`On Branch`,"landed-on-main":`Landed`,deploying:`Deploying`,deployed:`Deployed`},Kd={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,claimed:`bg-purple-500/10 text-purple-300 border-purple-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,orphaned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,done:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,failed:`bg-red-500/10 text-red-400 border-red-500/20`,canceled:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`},qd={none:`bg-zinc-500/10 text-zinc-400`,uncommitted:`bg-yellow-500/10 text-yellow-400`,"committed-on-branch":`bg-blue-500/10 text-blue-400`,"landed-on-main":`bg-emerald-500/10 text-emerald-400`,deploying:`bg-purple-500/10 text-purple-400`,deployed:`bg-teal-500/10 text-teal-400`};function Jd(e){let t=e.dispatch;return{title:e.title??``,intent:e.intent??``,latestSteer:e.latestSteer??``,doneWhen:e.doneWhen??``,teamId:e.teamId??``,dispatchComplexity:t?.complexity??``,dispatchType:t?.type??``,dispatchFootprint:t?.contextFootprint??``,dispatchCriticality:t?.criticality??``}}function Yd(){let e=bt(),t=A(e=>e.taskDetailOpen),n=A(e=>e.taskDetailId),r=A(e=>e.taskDetailById),i=A(e=>e.taskMemoryById),a=A(e=>e.taskHistoryById),o=A(e=>e.taskDispatchResultById),c=A(e=>e.taskDispatchLoadingId),l=A(e=>e.agentsById),u=A(e=>e.providerCatalog),d=A(e=>e.closeTaskDetail),f=A(e=>e.doEditTask),p=A(e=>e.doDispatchTask),m=A(e=>e.doSpawnWithTask),h=u.map(e=>e.provider),[g,_]=(0,z.useState)(!1),[y,b]=(0,z.useState)(null),[x,ee]=(0,z.useState)(``),[S,C]=(0,z.useState)(``),[te,ne]=(0,z.useState)(``),w=n==null?null:r[n]??null,re=n==null?null:i[n]??null,ie=n==null?[]:a[n]??[],ae=n==null?null:o[n]??null,oe=n!=null&&c===n,se=w?Kd[w.status]??`bg-zinc-500/10 text-zinc-400`:``,T=w?.deliverableStage?qd[w.deliverableStage]??`bg-zinc-500/10 text-zinc-400`:``;function E(e){e||(d(),_(!1),b(null))}function ce(){w&&(b(Jd(w)),_(!0))}function le(){_(!1),b(null)}async function ue(){if(!w||!y)return;let e={};y.dispatchComplexity&&(e.complexity=y.dispatchComplexity),y.dispatchType&&(e.type=y.dispatchType),y.dispatchFootprint&&(e.contextFootprint=y.dispatchFootprint),y.dispatchCriticality&&(e.criticality=y.dispatchCriticality);let t={...y.title===w.title?{}:{title:y.title},...y.intent===(w.intent??``)?{}:{intent:y.intent},...y.latestSteer===(w.latestSteer??``)?{}:{latestSteer:y.latestSteer},...y.doneWhen===(w.doneWhen??``)?{}:{doneWhen:y.doneWhen},...y.teamId===(w.teamId??``)?{}:{teamId:y.teamId},...Object.keys(e).length||w.dispatch?{dispatch:Object.keys(e).length?e:null}:{}};if(!Object.keys(t).length){le();return}await f(w.id,t),_(!1),b(null)}function de(){if(!w)return;let e={};x&&(e.provider=x),S&&(e.model=S),te&&(e.effort=te),p(w.id,Object.keys(e).length?e:void 0)}return(0,B.jsx)(lu,{open:t,onOpenChange:E,children:(0,B.jsxs)(pu,{className:`w-full max-w-[100dvw] sm:max-w-lg lg:max-w-xl p-0 flex flex-col`,showCloseButton:!1,children:[(0,B.jsx)(mu,{className:`shrink-0 p-4 border-b border-border`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:w&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(F,{variant:`outline`,className:`text-xs border ${se}`,children:w.status}),w.deliverableStage&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs ${T}`,children:Gd[w.deliverableStage]??w.deliverableStage}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`#`,w.id]})]})}),(0,B.jsx)(hu,{className:`text-base leading-snug`,children:w?.title??`Task`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&!g&&(0,B.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:ce,title:`Edit task`,children:(0,B.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(uu,{asChild:!0,children:(0,B.jsxs)(I,{size:`icon-sm`,variant:`ghost`,title:`Close`,children:[(0,B.jsx)(be,{className:`w-4 h-4`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}),(0,B.jsx)(Vd,{className:`flex-1 min-h-0 overflow-x-hidden`,children:(0,B.jsxs)(`div`,{className:`p-4 space-y-5 min-w-0`,children:[!w&&(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:`Loading…`}),w&&g&&y&&(0,B.jsx)(Xd,{form:y,onChange:e=>b(t=>t&&{...t,...e}),onSave:()=>void ue(),onCancel:le}),w&&!g&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Status`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Execution`}),(0,B.jsx)(F,{variant:`outline`,className:`text-xs border ${se}`,children:w.status})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Deliverable stage`}),(0,B.jsx)(F,{variant:`secondary`,className:`text-xs ${T}`,children:Gd[w.deliverableStage??`none`]??w.deliverableStage??`none`})]})]}),w.blockedBy&&w.blockedBy.length>0&&(0,B.jsx)(`div`,{className:`mt-2 space-y-1`,children:w.blockedBy.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-yellow-400`,children:[(0,B.jsx)(`span`,{className:`font-medium capitalize`,children:e.type}),e.ref&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`→ `,e.ref]}),e.note&&(0,B.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e.note})]},t))})]}),(0,B.jsx)(pl,{}),(w.intent||w.doneWhen)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{className:`space-y-2`,children:[w.intent&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Intent`}),(0,B.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:w.intent})]}),w.doneWhen&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Done when`}),(0,B.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:w.doneWhen})]})]}),(0,B.jsx)(pl,{})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Ownership`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[w.ownerAgentId&&(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Owner`}),(0,B.jsx)(`span`,{className:`truncate`,children:l[w.ownerAgentId]?M(l[w.ownerAgentId]):w.ownerAgentId})]}),w.createdBy&&(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created by`}),(0,B.jsx)(`span`,{className:`truncate`,children:w.createdBy})]}),w.teamId&&(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Team`}),(0,B.jsx)(`span`,{className:`truncate font-mono text-xs`,children:w.teamId})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created`}),(0,B.jsx)(`span`,{title:Yt(w.createdAt),children:j(e,w.createdAt)})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Updated`}),(0,B.jsx)(`span`,{title:Yt(w.updatedAt),children:j(e,w.updatedAt)})]})]})]}),(w.dispatchWorkShape?.specified||w.dispatchDecision||w.boundWorkerModel)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(Zd,{detail:w})]}),(w.branch||w.commits&&w.commits.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Code`}),w.branch&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm mb-1`,children:[(0,B.jsx)(Re,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,B.jsx)(`span`,{className:`font-mono text-xs truncate`,children:w.branch})]}),w.commits?.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm ml-1`,children:[(0,B.jsx)(s,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,B.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:e.sha.slice(0,8)}),e.subject&&(0,B.jsx)(`span`,{className:`text-xs truncate`,children:e.subject})]},e.sha))]})]}),w.issues&&w.issues.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)($d,{issues:w.issues})]}),(w.dependsOn&&w.dependsOn.length>0||w.dependents&&w.dependents.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(ef,{dependsOn:w.dependsOn??[],dependents:w.dependents??[]})]}),w.gates&&w.gates.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(tf,{gates:w.gates,now:e})]}),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(Qd,{taskId:w.id,pinProvider:x,pinModel:S,pinEffort:te,onPinProvider:ee,onPinModel:C,onPinEffort:ne,onDispatch:de,onSpawn:e=>void m(w.id,e),loading:oe,result:ae,providers:h})]}),re&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(nf,{memory:re,now:e})]}),ie.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(rf,{history:ie,now:e})]})]})]})})]})})}function Xd({form:e,onChange:t,onSave:n,onCancel:r}){return(0,B.jsxs)(`section`,{className:`space-y-4`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Edit Task fields`}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-title`,children:`Title`}),(0,B.jsx)(L,{id:`edit-title`,value:e.title,onChange:e=>t({title:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-intent`,children:`Intent`}),(0,B.jsx)(Wd,{id:`edit-intent`,value:e.intent,onChange:e=>t({intent:e.target.value}),rows:3})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-steer`,children:`Latest steer`}),(0,B.jsx)(Wd,{id:`edit-steer`,value:e.latestSteer,onChange:e=>t({latestSteer:e.target.value}),rows:2,placeholder:`Redirect or re-scope in-flight work`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-done-when`,children:`Done when`}),(0,B.jsx)(Wd,{id:`edit-done-when`,value:e.doneWhen,onChange:e=>t({doneWhen:e.target.value}),rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-team`,children:`Team ID`}),(0,B.jsx)(L,{id:`edit-team`,value:e.teamId,onChange:e=>t({teamId:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-complexity`,className:`text-xs`,children:`Complexity`}),(0,B.jsxs)(`select`,{id:`edit-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchComplexity,onChange:e=>t({dispatchComplexity:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ot.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-type`,className:`text-xs`,children:`Type`}),(0,B.jsxs)(`select`,{id:`edit-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchType,onChange:e=>t({dispatchType:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ct.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-footprint`,className:`text-xs`,children:`Context footprint`}),(0,B.jsxs)(`select`,{id:`edit-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchFootprint,onChange:e=>t({dispatchFootprint:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Dt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-criticality`,className:`text-xs`,children:`Criticality`}),(0,B.jsxs)(`select`,{id:`edit-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchCriticality,onChange:e=>t({dispatchCriticality:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),At.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,B.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,B.jsx)(I,{size:`sm`,onClick:n,children:`Save`}),(0,B.jsx)(I,{size:`sm`,variant:`outline`,onClick:r,children:`Cancel`})]})]})}function Zd({detail:e}){let t=e.dispatchWorkShape,n=e.dispatchDecision,r=e.boundWorkerModel;return(0,B.jsxs)(`section`,{className:`space-y-3`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch`}),t&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Work shape`}),t.specified?(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.complexity&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.complexity}),t.type&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.type}),t.contextFootprint&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.contextFootprint}),t.criticality&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.criticality})]}):(0,B.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:`Not specified`})]}),n&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Decision`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[n.target.provider&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:n.target.provider}),n.target.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:n.target.model}),n.target.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:n.target.effort}),n.pinned&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),n.rationale&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.rationale}),n.warnings?.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400 mt-0.5`,children:[(0,B.jsx)(Me,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,B.jsx)(`span`,{children:e})]},t))]}),r&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Bound worker`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[r.provider&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:r.provider}),r.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:r.model}),r.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:r.effort})]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground font-mono truncate`,children:r.agentId})]})]})}function Qd({taskId:e,pinProvider:t,pinModel:n,pinEffort:r,onPinProvider:i,onPinModel:a,onPinEffort:o,onDispatch:s,onSpawn:c,loading:l,result:u,providers:d}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3`,children:`Spawn with task`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mb-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-provider-${e}`,className:`text-xs`,children:`Provider pin`}),(0,B.jsxs)(`select`,{id:`spawn-provider-${e}`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs`,value:t,onChange:e=>i(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`auto`}),d.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-model-${e}`,className:`text-xs`,children:`Model pin`}),(0,B.jsx)(L,{id:`spawn-model-${e}`,className:`mt-1 h-8 text-xs`,value:n,onChange:e=>a(e.target.value),placeholder:`auto`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-effort-${e}`,className:`text-xs`,children:`Effort pin`}),(0,B.jsx)(L,{id:`spawn-effort-${e}`,className:`mt-1 h-8 text-xs`,value:r,onChange:e=>o(e.target.value),placeholder:`auto`})]})]}),(0,B.jsxs)(I,{size:`sm`,onClick:s,disabled:l,className:`gap-1.5`,children:[(0,B.jsx)(Fe,{className:`w-3.5 h-3.5`}),l?`Planning…`:`Plan dispatch`]}),u&&(0,B.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/20 p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(Fe,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:u.decision.target.provider}),u.decision.target.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:u.decision.target.model}),u.decision.target.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:u.decision.target.effort}),u.decision.pinned&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.decision.rationale}),u.decision.factors.band&&(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Band: `,u.decision.factors.band,u.decision.factors.contextWindowTokens?` · ${(u.decision.factors.contextWindowTokens/1e3).toFixed(0)}k ctx`:``]}),u.decision.warnings.length>0&&(0,B.jsx)(`div`,{className:`space-y-0.5`,children:u.decision.warnings.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400`,children:[(0,B.jsx)(Me,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,B.jsx)(`span`,{children:e})]},t))}),u.decision.review&&(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Auto-review: `,u.decision.review.reason,` → `,u.decision.review.target.provider,`/`,u.decision.review.target.model??`default`,u.reviewTaskId&&(0,B.jsxs)(`span`,{className:`ml-1`,children:[`(task #`,u.reviewTaskId,`)`]})]})]})]}),(0,B.jsx)(`div`,{className:`pt-1 border-t border-border/50`,children:(0,B.jsxs)(I,{size:`sm`,className:`gap-1.5 w-full`,onClick:()=>c(u.decision.target),children:[(0,B.jsx)(Fe,{className:`w-3.5 h-3.5`}),`Spawn worker with task #`,e]})})]})]})}function $d({issues:e}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Linked Issues`}),(0,B.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:[e.provider,`/`,e.externalKey]}),e.title&&(0,B.jsx)(`span`,{className:`truncate flex-1`,children:e.title}),(0,B.jsx)(F,{variant:`secondary`,className:`text-xs shrink-0`,children:e.status}),e.url&&(0,B.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,B.jsx)(ge,{className:`w-3.5 h-3.5`})})]},e.issueRefId))})]})}function ef({dependsOn:e,dependents:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Dependencies`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[e.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Depends on: `}),e.map((t,n)=>(0,B.jsxs)(`span`,{className:`font-mono text-xs`,children:[`#`,t,n<e.length-1?`, `:``]},t))]}),t.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Blocks: `}),t.map((e,n)=>(0,B.jsxs)(`span`,{className:`font-mono text-xs`,children:[`#`,e,n<t.length-1?`, `:``]},e))]})]})]})}function tf({gates:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Gate Ledger`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:[...e].sort((e,t)=>t.ranAt-e.ranAt).map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`pass`?(0,B.jsx)(ye,{className:`w-4 h-4 text-emerald-400 shrink-0 mt-0.5`}):(0,B.jsx)(we,{className:`w-4 h-4 text-red-400 shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-mono text-xs font-medium`,children:e.gate}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto shrink-0`,title:Yt(e.ranAt),children:j(t,e.ranAt)})]}),e.detail&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.detail}),e.commitSha&&(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.commitSha.slice(0,8)})]})]},e.gate+e.ranAt))})]})}function nf({memory:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Task Memory`}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[e.workingState&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Working state`}),(0,B.jsx)(`p`,{className:`text-xs whitespace-pre-wrap bg-muted/30 rounded p-2`,children:e.workingState})]}),e.ledger.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Ruled out (`,e.ledger.length,`)`]}),(0,B.jsx)(`div`,{className:`space-y-1`,children:e.ledger.map((e,t)=>(0,B.jsxs)(`div`,{className:`text-xs bg-muted/20 rounded p-1.5`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.ruledOut}),e.why&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` — `,e.why]})]},t))})]}),e.decisions.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Decisions (`,e.decisions.length,`)`]}),(0,B.jsx)(`div`,{className:`space-y-1.5`,children:e.decisions.map((e,n)=>(0,B.jsxs)(`div`,{className:`text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.decision}),(0,B.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0`,title:Yt(e.at),children:j(t,e.at)})]}),e.rationale&&(0,B.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.rationale}),e.by&&(0,B.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`by `,e.by]})]},n))})]})]})]})}function rf({history:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`History`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:[...e].reverse().slice(0,30).map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,B.jsx)(tt,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-muted-foreground shrink-0`,children:e.type}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground shrink-0`,title:Yt(e.createdAt),children:j(t,e.createdAt)})]}),e.title&&e.title!==e.type&&(0,B.jsx)(`p`,{className:`text-foreground mt-0.5 truncate`,children:e.title})]})]},e.id))})]})}var af=!1;function of(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;af=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(af){af=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,af=!0,window.history.back())}},[e])}function sf({...e}){return of(e.open,e.onOpenChange),(0,B.jsx)(Br,{"data-slot":`dialog`,...e})}function cf({...e}){return(0,B.jsx)(Vr,{"data-slot":`dialog-portal`,...e})}function lf({className:e,blur:t=!0,...n}){return(0,B.jsx)(Hr,{"data-slot":`dialog-overlay`,className:O(`fixed inset-0 isolate z-50 bg-black/10 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,t&&`supports-backdrop-filter:backdrop-blur-xs`,e),...n})}function uf({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,B.jsxs)(cf,{children:[(0,B.jsx)(lf,{blur:r}),(0,B.jsxs)(Ur,{"data-slot":`dialog-content`,className:O(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i,children:[t,n&&(0,B.jsx)(Kr,{"data-slot":`dialog-close`,asChild:!0,children:(0,B.jsxs)(I,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,B.jsx)(be,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function df({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-header`,className:O(`flex flex-col gap-2`,e),...t})}function ff({className:e,showCloseButton:t=!1,children:n,...r}){return(0,B.jsxs)(`div`,{"data-slot":`dialog-footer`,className:O(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,B.jsx)(Kr,{asChild:!0,children:(0,B.jsx)(I,{variant:`outline`,children:`Close`})})]})}function pf({className:e,...t}){return(0,B.jsx)(Wr,{"data-slot":`dialog-title`,className:O(`font-heading text-base leading-none font-medium`,e),...t})}function mf({className:e,...t}){return(0,B.jsx)(Gr,{"data-slot":`dialog-description`,className:O(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function hf(){let e=A(e=>e.composeOpen),t=A(e=>e.compose),n=A(e=>e.replyTo),r=A(e=>e.set),i=A(e=>e.doSend),a=A(e=>e.cancelReply),o=ol();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&s(),children:(0,B.jsxs)(uf,{className:`max-w-lg`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:n?`Reply to #${n.id}`:`Compose Message`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`From`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.from,onChange:e=>c({from:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`Select agent...`}),o.map(e=>(0,B.jsx)(`option`,{value:e.id,children:M(e)},e.id))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`To`}),(0,B.jsx)(L,{value:t.to,onChange:e=>c({to:e.target.value}),placeholder:`agent-id, tag:name, cap:name, or broadcast`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Subject`}),(0,B.jsx)(L,{value:t.subject,onChange:e=>c({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Channel`}),(0,B.jsx)(L,{value:t.channel,onChange:e=>c({channel:e.target.value}),placeholder:`Optional channel...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Message`}),(0,B.jsx)(Wd,{value:t.body,onChange:e=>c({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(fl,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:s,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}function gf(){let e=A(e=>e.confirmModal),t=A(e=>e.set);function n(){t({confirmModal:{show:!1,title:``,message:``,action:null}})}return(0,B.jsx)(sf,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(df,{children:[(0,B.jsx)(pf,{children:e.title}),(0,B.jsx)(mf,{children:e.message})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function _f(){let e=A(e=>e.errorModal),t=A(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,B.jsx)(sf,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(df,{children:[(0,B.jsx)(pf,{children:e.title}),(0,B.jsx)(mf,{children:e.message})]}),(0,B.jsx)(ff,{children:(0,B.jsx)(I,{onClick:n,children:`OK`})})]})})}function vf(){let e=A(e=>e.renameModal),t=A(e=>e.set),n=A(e=>e.doRename);function r(){t({renameModal:{show:!1,agentId:``,label:``}})}return(0,B.jsx)(sf,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`Rename Agent`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)($,{children:`Label`}),(0,B.jsx)(L,{value:e.label,onChange:n=>t({renameModal:{...e,label:n.target.value}}),onKeyDown:e=>e.key===`Enter`&&n(),placeholder:`Human-friendly name...`,autoFocus:!0}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Leave empty to clear the label.`})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:n,children:`Save`})]})]})})}function yf(){let e=A(e=>e.pairInviteOpen),t=A(e=>e.pairInvite),n=A(e=>e.set),r=A(e=>e.closePairInvite),i=A(e=>e.doCreatePair),a=ol();function o(e){n({pairInvite:{...t,...e}})}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`Pair Agents`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Requester`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.requesterId,onChange:e=>o({requesterId:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:M(e)},e.id))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Target`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.targetId,onChange:e=>o({targetId:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:M(e)},e.id))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Objective`}),(0,B.jsx)(L,{value:t.objective,onChange:e=>o({objective:e.target.value}),placeholder:`What should they work on?`})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Create Pair`})]})]})})}function bf(){let e=A(e=>e.pairMessageOpen),t=A(e=>e.pairMessage),n=A(e=>e.set),r=A(e=>e.closePairMessage),i=A(e=>e.doSendPairMessage);function a(e){n({pairMessage:{...t,...e}})}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`Pair Message`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Subject`}),(0,B.jsx)(L,{value:t.subject,onChange:e=>a({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Message`}),(0,B.jsx)(Wd,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}var xf=(0,z.lazy)(()=>R(()=>import(`./formatted-body-impl-DZc7C4-2.js`).then(e=>({default:e.FormattedBody})),__vite__mapDeps([15,1,5,3,6,8,9,10]),import.meta.url));function Sf(e){return(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`span`,{className:e.className,children:e.text}),children:(0,B.jsx)(xf,{...e})})}function Cf(){let e=A(e=>e.threadOpen),t=A(e=>e.threadMessages),n=A(e=>e.agentsById),r=bt(),i=A(e=>e.set);return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,B.jsxs)(uf,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{children:[`Thread (`,t.length,` messages)`]})}),(0,B.jsx)(Vd,{className:`max-h-[60vh]`,children:(0,B.jsx)(`div`,{className:`space-y-3 pr-4`,children:t.map(e=>(0,B.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:Jt(e.from,n)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:Jt(e.to,n)}),(0,B.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:j(r,e.createdAt)})]}),e.subject&&(0,B.jsx)(`div`,{className:`text-sm font-medium`,children:e.subject}),(0,B.jsx)(Sf,{text:Qt(e),rawBody:e.body,issueRepo:n[e.from===`user`?e.to:e.from]?.issueRepo,className:`text-sm text-muted-foreground`}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[e.channel&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:e.channel}),e.claimedBy&&(0,B.jsxs)(F,{variant:`secondary`,className:`text-[10px]`,children:[`claimed by `,Jt(e.claimedBy,n)]})]})]},e.id))})})]})})}function wf(){let e=A(e=>e.taskEventsOpen),t=A(e=>e.taskEvents),n=A(e=>e.set),r=A(e=>e.switchView);function i(e){n({selectedMemoryId:e,taskEventsOpen:!1}),r(`memory`)}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,B.jsxs)(uf,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{children:[`Task Events (`,t.length,`)`]})}),(0,B.jsx)(Vd,{className:`max-h-[60vh]`,children:(0,B.jsxs)(`div`,{className:`space-y-2 pr-4`,children:[t.map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-border p-3`,children:[(0,B.jsx)(F,{className:qt[e.severity]||qt.info,children:e.severity}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:e.type})]}),e.body&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 whitespace-pre-wrap`,children:e.body}),(0,B.jsx)(Tf,{event:e,onOpen:i}),(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[Yt(e.createdAt),` · `,e.source]})]})]},e.id)),t.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:`No events recorded.`})]})})]})})}function Tf({event:e,onOpen:t}){if(e.type!==`memory.captured`)return null;let n=typeof e.metadata?.memoryId==`string`?e.metadata.memoryId:``,r=e.metadata?.memory&&typeof e.metadata.memory==`object`&&!Array.isArray(e.metadata.memory)?e.metadata.memory:{},i=typeof r.title==`string`?r.title:e.body||n,a=typeof r.scope==`string`?r.scope:``,o=typeof r.type==`string`?r.type:`memory`,s=typeof r.sensitivity==`string`?r.sensitivity:``;return(0,B.jsx)(`div`,{className:`mt-2 rounded-md border border-border bg-muted/20 p-2 text-xs`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(ie,{className:`w-3.5 h-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:o}),a&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] font-mono`,children:a}),s&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:s})]}),(0,B.jsx)(`div`,{className:`font-medium truncate`,children:i}),n&&(0,B.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground truncate`,children:n})]}),n&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7 text-xs shrink-0`,onClick:()=>t(n),children:`Open`})]})})}function Ef(){let e=A(e=>e.taskCreateOpen),t=A(e=>e.taskCreateForm),n=A(e=>e.closeTaskCreate),r=A(e=>e.setTaskCreateForm),i=A(e=>e.doCreateTask);return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(uf,{className:`max-w-lg`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`New Task`})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-title`,children:[`Title `,(0,B.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,B.jsx)(L,{id:`task-title`,value:t.title,onChange:e=>r({title:e.target.value}),placeholder:`Short description of the work`,autoFocus:!0})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`task-intent`,children:`Intent`}),(0,B.jsx)(Wd,{id:`task-intent`,value:t.intent,onChange:e=>r({intent:e.target.value}),placeholder:`What is this task trying to accomplish?`,rows:3})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`task-done-when`,children:`Done when`}),(0,B.jsx)(Wd,{id:`task-done-when`,value:t.doneWhen,onChange:e=>r({doneWhen:e.target.value}),placeholder:`Acceptance criteria`,rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-issue-refs`,children:[`Issue refs `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated, e.g. owner/repo#123)`})]}),(0,B.jsx)(L,{id:`task-issue-refs`,value:t.issueRefs,onChange:e=>r({issueRefs:e.target.value}),placeholder:`owner/repo#123, owner/repo#456`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-depends-on`,children:[`Depends on `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated task IDs)`})]}),(0,B.jsx)(L,{id:`task-depends-on`,value:t.dependsOn,onChange:e=>r({dependsOn:e.target.value}),placeholder:`42, 43`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape (optional)`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-complexity`,className:`text-xs`,children:`Complexity`}),(0,B.jsxs)(`select`,{id:`dispatch-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchComplexity,onChange:e=>r({dispatchComplexity:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ot.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-type`,className:`text-xs`,children:`Type`}),(0,B.jsxs)(`select`,{id:`dispatch-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchType,onChange:e=>r({dispatchType:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ct.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-footprint`,className:`text-xs`,children:`Context footprint`}),(0,B.jsxs)(`select`,{id:`dispatch-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchFootprint,onChange:e=>r({dispatchFootprint:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Dt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-criticality`,className:`text-xs`,children:`Criticality`}),(0,B.jsxs)(`select`,{id:`dispatch-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchCriticality,onChange:e=>r({dispatchCriticality:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),At.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{onClick:()=>void i(),disabled:!t.title.trim(),children:`Create`})]})]})})}function Df({open:e,onOpenChange:t,onSelect:n,orchestratorId:r,initialPath:i,title:a=`Select Directory`}){let o=A(e=>e.apiCall),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(``),[_,v]=(0,z.useState)(null),y=l?.path||i||``,b=(0,z.useMemo)(()=>y.split(`/`).filter(Boolean),[y]),x=(0,z.useCallback)(async e=>{if(r){c(!0),f(null),m(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;u(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){f(jt(e))}finally{c(!1)}}},[r,o]);(0,z.useEffect)(()=>{e&&r&&(u(null),f(null),m(!1),x(i||void 0))},[e,r]);async function S(){if(!(!h.trim()||!l)){v(null);try{u(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:l.path,name:h.trim()})),m(!1),g(``)}catch(e){v(jt(e))}}}function C(){y&&(n(y),t(!1))}function te(e){x(`/`+b.slice(0,e+1).join(`/`))}return(0,B.jsx)(sf,{open:e,onOpenChange:t,children:(0,B.jsxs)(uf,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ne,{className:`h-4 w-4`}),a]})}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-muted/50 px-2 py-1.5 text-xs overflow-x-auto`,children:[(0,B.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground shrink-0`,onClick:()=>l?.baseDir&&x(l.baseDir),children:`/`}),b.map((e,t)=>(0,B.jsxs)(`span`,{className:`shrink-0`,children:[(0,B.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground`,onClick:()=>te(t),children:e}),t<b.length-1&&(0,B.jsx)(`span`,{className:`text-muted-foreground/50 mx-0.5`,children:`/`})]},`${e}-${t}`))]}),(0,B.jsxs)(`div`,{className:`flex-1 min-h-0 rounded-md border border-border bg-background overflow-y-auto`,style:{maxHeight:`40dvh`},children:[s&&(0,B.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,B.jsx)(Xe,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&d&&(0,B.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:d}),!s&&l&&(0,B.jsxs)(`div`,{className:`p-1`,children:[l.parent&&(0,B.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>x(l.parent),children:[(0,B.jsx)(We,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),l.entries.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>x(e.path),children:[(0,B.jsx)(ae,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),l.entries.length===0&&!l.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),l.entries.length===0&&l.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),p?(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(L,{autoFocus:!0,value:h,onChange:e=>{g(e.target.value),v(null)},onKeyDown:e=>{e.key===`Enter`&&S(),e.key===`Escape`&&(m(!1),g(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`outline`,onClick:S,disabled:!h.trim(),children:(0,B.jsx)(ct,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{m(!1),g(``),v(null)},children:(0,B.jsx)(be,{className:`h-4 w-4`})})]}):(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(!0),disabled:!l||s,children:[(0,B.jsx)(ee,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),_&&(0,B.jsx)(`p`,{className:`text-xs text-destructive`,children:_}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(I,{onClick:C,disabled:!y,children:`Select`})]})]})})}function Of({value:e,onChange:t,orchestratorId:n,placeholder:r,disabled:i}){let[a,o]=(0,z.useState)(!1);return(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(L,{value:e,onChange:e=>t(e.target.value),placeholder:r,disabled:i,className:`flex-1 font-mono text-sm`}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>o(!0),disabled:i||!n,title:`Browse directories`,children:(0,B.jsx)(ne,{className:`h-4 w-4`})}),n&&(0,B.jsx)(Df,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function kf({model:e}){if(!e)return null;let t=Af(e);return t.length===0?null:(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,B.jsxs)(F,{variant:`outline`,className:`gap-1 text-[10px]`,children:[(0,B.jsx)(e.Icon,{className:`h-3 w-3`}),e.label]},e.label))})}function Af(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:jf(n),Icon:Qe}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:ce}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:ce}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:qe}),t}function jf(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function Mf(){let e=A(e=>e.orchestratorSpawnOpen),t=A(e=>e.orchestrators),n=A(e=>e.spawnOrchId),r=A(e=>e.spawnProvider),i=A(e=>e.spawnModel),a=A(e=>e.spawnEffort),o=A(e=>e.spawnProfile),s=A(e=>e.spawnCwd),c=A(e=>e.spawnLabel),l=A(e=>e.spawnApproval),u=A(e=>e.spawnWorkspaceMode),d=A(e=>e.spawnPrompt),f=A(e=>e.spawnSystemPromptAppend),p=A(e=>e.spawnCount),m=A(e=>e.spawnCwdHistory),h=A(e=>e.isSpawning),g=A(e=>!!e.pendingForkImport),_=A(e=>e.set),v=A(e=>e.submitOrchestratorSpawn),y=A(e=>e.selectSpawnHistory),b=A(e=>e.agentProfiles),x=A(e=>e.providerCatalog),ee=t.find(e=>e.id===n),S=ee?.providers||[],C=St(r,x),te=C.find(e=>e.alias===i),ne=te?.efforts||[],w=!!(ee&&S.length>0&&s.trim())&&!h,re=t.filter(e=>e.status===`online`),ie=re.length>1,ae=m.filter(e=>re.some(t=>t.id===e.orchId)).slice(0,5);function oe(e){let n=t.find(t=>t.id===e),r=n?.providers[0]||``;_({spawnOrchId:e,spawnProvider:r,spawnModel:r?vt(r,x):``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function se(e){_({spawnProvider:e,spawnModel:vt(e,x),spawnEffort:``})}function T(e){_({spawnModel:e,spawnEffort:``})}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,B.jsxs)(uf,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`Spawn Agent`})}),(0,B.jsxs)(`div`,{className:`space-y-3 overflow-y-auto flex-1 min-h-0 -mx-4 px-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Orchestrator`}),(0,B.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:n,onChange:e=>oe(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:r,onChange:e=>se(e.target.value),disabled:!S.length,children:[!S.length&&(0,B.jsx)(`option`,{value:r,children:`No providers available`}),S.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Model`}),(0,B.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:i,onChange:e=>T(e.target.value),disabled:!C.length,children:C.map(e=>(0,B.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Effort`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:a,onChange:e=>_({spawnEffort:e.target.value}),disabled:!ne.length,children:[(0,B.jsx)(`option`,{value:``,children:`Default`}),ne.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,B.jsx)(kf,{model:te}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Agent Profile`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:o||`default-relay`,onChange:e=>_({spawnProfile:e.target.value}),children:[!b.length&&(0,B.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),b.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Approval Mode`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:l,onChange:e=>_({spawnApproval:e.target.value}),children:[(0,B.jsx)(`option`,{value:`open`,children:`Open`}),(0,B.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,B.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Workspace`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:u,onChange:e=>_({spawnWorkspaceMode:e.target.value}),children:[(0,B.jsx)(`option`,{value:`inherit`,children:`Default`}),(0,B.jsx)(`option`,{value:`isolated`,children:`Isolated worktree`}),(0,B.jsx)(`option`,{value:`shared`,children:`Shared cwd`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Working Directory`}),(0,B.jsx)(`div`,{className:`mt-1`,children:(0,B.jsx)(Of,{value:s,onChange:e=>_({spawnCwd:e}),orchestratorId:n,placeholder:`Select a project directory`})}),ae.length>0&&(0,B.jsxs)(`div`,{className:`mt-2`,children:[(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:`Recent`}),(0,B.jsx)(`div`,{className:`flex gap-1.5 overflow-x-auto pb-1 sm:flex-wrap sm:overflow-x-visible sm:pb-0`,children:ae.map(e=>{let t=e.cwd.replace(/\/+$/,``).split(`/`).pop()||e.cwd,r=re.find(t=>t.id===e.orchId)?.hostname,i=e.orchId===n&&e.cwd===s;return(0,B.jsx)(`button`,{type:`button`,title:ie&&r?`${r}: ${e.cwd}`:e.cwd,onClick:()=>y(e.orchId,e.cwd),className:`shrink-0 rounded-full border px-2.5 py-1 text-xs font-mono transition-colors ${i?`border-primary bg-primary/10 text-foreground`:`border-input bg-background text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:ie&&r?`${r}: ${t}`:t},`${e.orchId}:${e.cwd}`)})})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Label`}),(0,B.jsx)(L,{value:c,onChange:e=>_({spawnLabel:e.target.value}),placeholder:`Optional label...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Initial Prompt`}),(0,B.jsx)(Wd,{value:d,onChange:e=>_({spawnPrompt:e.target.value}),rows:3,placeholder:`Optional initial task...`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Codex starts this as the first App Server turn; Claude receives it as a launch prompt.`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`System Prompt Append`}),(0,B.jsx)(Wd,{value:f,onChange:e=>_({spawnSystemPromptAppend:e.target.value}),rows:5,placeholder:`Optional launch context...`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Use for fork history or launch context. It informs the session but does not start work by itself.`})]}),!g&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)($,{children:`Number of Agents`}),(0,B.jsx)(`span`,{className:`text-sm font-mono tabular-nums text-muted-foreground`,children:p})]}),(0,B.jsx)(`input`,{type:`range`,min:1,max:10,step:1,value:p,onChange:e=>_({spawnCount:Number(e.target.value)}),className:`w-full mt-2 accent-primary`,"aria-label":`Number of agents to spawn`}),p>1&&(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Spawns `,p,` identical agents`,c.trim()?`, labelled "${c.trim()} 1"…"${c.trim()} ${p}"`:``,`.`]})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,B.jsx)(I,{onClick:v,disabled:!w,children:h?`Spawning…`:S.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function Nf(){return`host-${Math.random().toString(36).slice(2,8)}`}function Pf(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Ff(){let e=A(e=>e.orchestratorInstallOpen),t=A(e=>e.set),n=A(e=>e.showError),r=A(e=>e.showNotification),i=(0,z.useMemo)(()=>new URL(k()).origin,[]),[a,o]=(0,z.useState)(Nf),[s,c]=(0,z.useState)(`$HOME/projects`),[l,u]=(0,z.useState)(kt()),[f,p]=(0,z.useState)(`4860`),[m,h]=(0,z.useState)(``),[g,_]=(0,z.useState)(``),[v,y]=(0,z.useState)(),[b,x]=(0,z.useState)(!1);async function ee(){if(!a.trim()){n(`Validation`,`Orchestrator id is required`);return}if(!s.trim()){n(`Validation`,`Base directory is required`);return}if(!l.length){n(`Validation`,`Select at least one provider`);return}x(!0);try{let e=await Ee(`POST`,`/orchestrators/bootstrap`,{id:a.trim(),relayUrl:i,baseDir:s.trim(),providers:l,apiPort:Number(f)||4860,pathPrefix:m.split(`:`).map(e=>e.trim()).filter(Boolean)});_(e.command),y(e.expiresAt)}catch(e){n(`Install Command Failed`,e.message)}finally{x(!1)}}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,B.jsxs)(uf,{className:`max-w-2xl overflow-hidden`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{className:`flex items-center gap-2`,children:[(0,B.jsx)(d,{className:`w-4 h-4`}),`Add Orchestrator`]})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Orchestrator ID`}),(0,B.jsx)(L,{value:a,onChange:e=>o(e.target.value)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Relay URL`}),(0,B.jsx)(L,{value:i,readOnly:!0})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Base Directory`}),(0,B.jsx)(L,{value:s,onChange:e=>c(e.target.value)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`API Port`}),(0,B.jsx)(L,{value:f,onChange:e=>p(e.target.value),inputMode:`numeric`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Providers`}),(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:kt().map(e=>(0,B.jsx)(I,{type:`button`,size:`sm`,variant:l.includes(e)?`default`:`outline`,onClick:()=>u(Pf(l,e)),children:Et(e)},e))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Extra PATH Prefix`}),(0,B.jsx)(L,{value:m,onChange:e=>h(e.target.value),placeholder:`/opt/homebrew/bin:/custom/bin`})]}),g&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,B.jsx)($,{children:`Install Command`}),v&&(0,B.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Install token expires `,new Date(v*1e3).toLocaleString()]})]}),(0,B.jsx)(`pre`,{className:`max-h-40 w-full overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-input bg-muted/40 p-3 font-mono text-xs leading-relaxed`,children:g})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,B.jsx)(Wn,{value:g,label:`Copy`,showText:!0,size:`default`,variant:`outline`,className:`gap-1`,onCopied:()=>r(`Install command copied`)}),(0,B.jsxs)(I,{className:`gap-1`,onClick:ee,disabled:b,children:[(0,B.jsx)(ve,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function If(){let e=A(e=>e.policyModal),t=A(e=>e.orchestrators),n=A(e=>e.agentProfiles),r=A(e=>e.set),i=A(e=>e.submitPolicy),a=A(e=>e.providerCatalog),o=t.find(t=>t.id===e.orchestratorId),s=o?.providers||[],c=St(e.provider,a),l=c.find(t=>t.alias===e.model),u=l?.efforts||[],d=!!e.editing,f=o?.providerStatus?.find(t=>t.name===e.provider)?.features?.rig===!0;function p(t){r({policyModal:{...e,...t}})}function m(n){let r=t.find(e=>e.id===n)?.providers[0]||e.provider;p({orchestratorId:n,provider:r,model:vt(r,a),effort:``})}function h(e){p({provider:e,rig:``,model:vt(e,a),effort:``})}return(0,B.jsx)(sf,{open:e.open,onOpenChange:e=>!e&&p({open:!1}),children:(0,B.jsxs)(uf,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:d?`Edit Policy`:`Create Managed Agent`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Policy Name`}),(0,B.jsx)(L,{value:e.name,onChange:e=>p({name:e.target.value}),placeholder:`my-agent`,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Label`}),(0,B.jsx)(L,{value:e.label,onChange:e=>p({label:e.target.value}),placeholder:`Human-friendly name...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Description`}),(0,B.jsx)(L,{value:e.description,onChange:e=>p({description:e.target.value}),placeholder:`What does this agent do?`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Orchestrator`}),(0,B.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.orchestratorId,onChange:e=>m(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.provider,onChange:e=>h(e.target.value),disabled:!s.length,children:[!s.length&&(0,B.jsx)(`option`,{value:e.provider,children:`No providers available`}),s.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]}),f&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Rig`}),(0,B.jsx)(L,{value:e.rig,onChange:e=>p({rig:e.target.value}),placeholder:`Leave empty to auto-detect from .claude-rig`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`claude-rig profile name. Auto-detects from project's .claude-rig file if empty.`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Model`}),(0,B.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.model,onChange:e=>p({model:e.target.value,effort:``}),children:c.map(e=>(0,B.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Effort`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.effort,onChange:e=>p({effort:e.target.value}),disabled:!u.length,children:[(0,B.jsx)(`option`,{value:``,children:`Default`}),u.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,B.jsx)(kf,{model:l}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Agent Profile`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.profile||`default-relay`,onChange:e=>p({profile:e.target.value}),children:[!n.length&&(0,B.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),n.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Working Directory`}),(0,B.jsx)(`div`,{className:`mt-1`,children:(0,B.jsx)(Of,{value:e.cwd,onChange:e=>p({cwd:e}),orchestratorId:e.orchestratorId,placeholder:o?.baseDir||`/path/to/project`})})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Mode`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.mode,onChange:e=>p({mode:e.target.value}),children:[(0,B.jsx)(`option`,{value:`always-on`,children:`Always On`}),(0,B.jsx)(`option`,{value:`on-demand`,children:`On Demand`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Permission Mode`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.permissionMode,onChange:e=>p({permissionMode:e.target.value}),children:[(0,B.jsx)(`option`,{value:`open`,children:`Open`}),(0,B.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,B.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]})]}),e.mode===`on-demand`&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Keepalive (seconds)`}),(0,B.jsx)(L,{type:`number`,value:e.keepaliveSeconds,onChange:e=>p({keepaliveSeconds:e.target.value}),placeholder:`300`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Seconds to keep agent alive after last activity.`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Initial Prompt`}),(0,B.jsx)(Wd,{value:e.prompt,onChange:e=>p({prompt:e.target.value}),rows:3,placeholder:`Optional initial task or instructions...`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Codex starts this as the first App Server turn; Claude receives it as a launch prompt.`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Tags`}),(0,B.jsx)(L,{value:e.tags,onChange:e=>p({tags:e.target.value}),placeholder:`tag1, tag2`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Capabilities`}),(0,B.jsx)(L,{value:e.capabilities,onChange:e=>p({capabilities:e.target.value}),placeholder:`chat, review`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider Args`}),(0,B.jsx)(L,{value:e.providerArgs,onChange:e=>p({providerArgs:e.target.value}),placeholder:`--flag value`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Space-separated args passed to the provider CLI.`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Channel Binding`}),(0,B.jsx)(L,{value:e.channelId,onChange:e=>p({channelId:e.target.value}),placeholder:`Channel ID (optional)`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Backoff Schedule (seconds)`}),(0,B.jsx)(L,{value:e.backoffSchedule,onChange:e=>p({backoffSchedule:e.target.value}),placeholder:`5, 15, 60, 300`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Backoff Reset After (s)`}),(0,B.jsx)(L,{type:`number`,value:e.backoffResetAfterSeconds,onChange:e=>p({backoffResetAfterSeconds:e.target.value}),placeholder:`600`})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)($,{htmlFor:`restartOnUpdate`,children:`Restart on policy update`}),(0,B.jsx)(fl,{id:`restartOnUpdate`,checked:e.restartOnUpdate,onCheckedChange:e=>p({restartOnUpdate:e})})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)($,{htmlFor:`dailyRestart`,children:`Scheduled daily restart`}),(0,B.jsx)(fl,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>p({scheduledDailyRestart:e})})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>p({open:!1}),children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:d?`Save`:`Create`})]})]})})}function Lf({children:e}){return(0,B.jsxs)(Jc,{children:[(0,B.jsx)(Yc,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`More info`,className:`inline-flex shrink-0 text-muted-foreground transition-colors hover:text-foreground`,children:(0,B.jsx)(u,{className:`h-3 w-3`})})}),(0,B.jsx)(Xc,{className:`max-w-xs leading-relaxed`,children:e})]})}function Rf({children:e,tip:t,className:n}){return(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)($,{className:n,children:e}),(0,B.jsx)(Lf,{children:t})]})}var zf=[`core`,`workspace`,`memory`,`artifacts`,`blackboard`,`subscriptions`,`spawn-lifecycle`,`plans`,`teams`,`project`,`issues`],Bf=[{value:``,label:`Off`},{value:`all`,label:`All`}],Vf=[{value:``,label:`Off`},{value:`all`,label:`All safe settings`}],Hf=[{value:``,label:`Instance default`},{value:`direct`,label:`Direct`},{value:`pr`,label:`Pull request`}],Uf=[{value:`any`,label:`Any provider`},...kt().map(e=>({value:e,label:Et(e)}))],Wf={relay:`bg-blue-500/10 text-blue-400 border-blue-500/30`,repo:`bg-emerald-500/10 text-emerald-400 border-emerald-500/30`,inline:`bg-amber-500/10 text-amber-400 border-amber-500/30`,provider:`bg-fuchsia-500/10 text-fuchsia-400 border-fuchsia-500/30`,profile:`bg-slate-500/10 text-slate-400 border-slate-500/30`};function Gf(e){return e?e.policy??`all`:``}function Kf(e){if(e)return e===`all`?{policy:`all`}:{}}function qf({value:e,onChange:t,options:n,disabled:r}){return(0,B.jsx)(`select`,{className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e,onChange:e=>t(e.target.value),disabled:r,children:n.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function Jf(e,t){return`${e.source}:${e.provider??`any`}:${e.ref}:${t}`}function Yf({source:e}){return(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] ${Wf[e]}`,children:e})}function Xf({skills:e,plugins:t,mcp:n,onChangeSkills:r,onChangePlugins:i,onChangeMcp:a,projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l,readOnly:u}){let[d,f]=(0,z.useState)([]),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(null),[y,b]=(0,z.useState)(null),[x,ee]=(0,z.useState)(`repo`),[S,C]=(0,z.useState)(``),[te,ne]=(0,z.useState)(`any`);async function w(e){if(b(e),!p){g(!0),v(null);try{f((await Ee(`GET`,`/provisioning/capabilities`)).capabilities),m(!0)}catch(e){v(jt(e))}finally{g(!1)}}}function re(n){let a=S.trim();if(!a)return;let o={source:x,ref:a,enabled:!0,...te===`any`?{}:{provider:te}};n===`skill`?r([...e,o]):i([...t,o]),C(``),b(null)}function ie(n,a){let o=n===`skill`?e:t;if(o.some(e=>e.source===`relay`&&e.ref===a))return;let s=[...o,{source:`relay`,ref:a,enabled:!0}];n===`skill`?r(s):i(s),b(null)}function ae(e){let t=e.variants.find(e=>e.enabled);if(!t)return;let r=t.definition;a({...n,servers:{...n.servers??{},[e.capability.slug]:r?.server??{}}}),b(null)}function oe(t,n){r(e.map((e,r)=>r===t?{...e,...n}:e))}function se(e,n){i(t.map((t,r)=>r===e?{...t,...n}:t))}function T(e){let t={...n.servers??{}};delete t[e],a({...n,servers:t})}let E=d.filter(e=>e.capability.kind===`skill`),ce=d.filter(e=>e.capability.kind===`plugin`),le=d.filter(e=>e.capability.kind===`mcp`);return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(Zf,{projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l}),(0,B.jsx)($f,{title:`Skills from registry`,kind:`skill`,refs:e,readOnly:u,adding:y===`skill`,caps:E,loading:h,fetchError:_,empty:`No skills assigned`,manualRef:S,manualSource:x,manualProvider:te,onAddClick:()=>void w(`skill`),onCancel:()=>b(null),onManualRef:C,onManualSource:ee,onManualProvider:ne,onAddManual:()=>re(`skill`),onAddRelay:e=>ie(`skill`,e),onUpdate:oe,onRemove:t=>r(e.filter((e,n)=>n!==t))}),(0,B.jsx)($f,{title:`Plugins from registry`,kind:`plugin`,refs:t,readOnly:u,adding:y===`plugin`,caps:ce,loading:h,fetchError:_,empty:`No plugins assigned`,manualRef:S,manualSource:x,manualProvider:te,onAddClick:()=>void w(`plugin`),onCancel:()=>b(null),onManualRef:C,onManualSource:ee,onManualProvider:ne,onAddManual:()=>re(`plugin`),onAddRelay:e=>ie(`plugin`,e),onUpdate:se,onRemove:e=>i(t.filter((t,n)=>n!==e))}),(0,B.jsx)(np,{mcpKeys:Object.keys(n.servers??{}),caps:le,adding:y===`mcp`,loading:h,fetchError:_,readOnly:u,onAddClick:()=>void w(`mcp`),onAddMcp:ae,onCancel:()=>b(null),onRemove:T})]})}function Zf(e){return(0,B.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-2`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[`Project and shared injection`,(0,B.jsxs)(Lf,{children:[`Read-only mirror of the Provisioning Policies above — what this profile injects from the project's `,(0,B.jsx)(`code`,{children:`.mcp.json`}),`/`,(0,B.jsx)(`code`,{children:`.claude`}),` and how its MCP is routed.`]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,B.jsxs)(F,{variant:e.projectMcp?`default`:`outline`,className:`text-[10px]`,children:[`project MCP: `,Gf(e.projectMcp)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSkills?`default`:`outline`,className:`text-[10px]`,children:[`project skills: `,Gf(e.projectSkills)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSettings?`default`:`outline`,className:`text-[10px]`,children:[`project settings: `,Gf(e.projectSettings)||`off`]}),(0,B.jsxs)(F,{variant:e.sharedMcp?`default`:`outline`,className:`text-[10px]`,children:[`shared MCP: `,Gf(e.sharedMcp)||`off`]})]})]})}function Qf(e){return[...new Set(e.variants.map(e=>e.sourceType||`relay`))].join(`, `)}function $f(e){return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.title}),!e.readOnly&&(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 gap-1 text-xs`,onClick:e.onAddClick,children:[(0,B.jsx)(ue,{className:`h-3 w-3`}),`Add `,e.kind]})]}),e.refs.length===0&&!e.adding&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.empty}),e.refs.map((t,n)=>(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded border border-border bg-card/60 px-2 py-1`,children:[(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] ${e.kind===`skill`?`bg-blue-500/10 text-blue-400 border-blue-500/30`:`bg-violet-500/10 text-violet-400 border-violet-500/30`}`,children:e.kind}),(0,B.jsx)(Yf,{source:t.source}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.ref}),t.provider&&t.provider!==`any`&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:t.provider}),(0,B.jsx)(fl,{checked:t.enabled,onCheckedChange:t=>e.onUpdate(n,{enabled:t}),disabled:e.readOnly,size:`sm`}),!e.readOnly&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-5 w-5`,onClick:()=>e.onRemove(n),children:(0,B.jsx)(Ae,{className:`h-3 w-3`})})]},Jf(t,n))),e.adding&&(0,B.jsxs)(`div`,{className:`mt-1.5 space-y-2 rounded border border-border bg-card/60 p-2`,children:[e.loading&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Loading...`}),e.fetchError&&(0,B.jsx)(`div`,{className:`text-xs text-destructive`,children:e.fetchError}),!e.loading&&e.caps.length===0&&!e.fetchError&&(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`No `,e.kind,` capabilities in registry`]}),e.caps.length>0&&(0,B.jsx)(`div`,{className:`max-h-44 space-y-0.5 overflow-y-auto rounded border border-border/60 bg-background/40 p-1`,children:e.caps.map(t=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.onAddRelay(t.capability.slug),className:`w-full rounded px-2 py-1 text-left font-mono text-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[t.capability.slug,t.capability.title?` - ${t.capability.title}`:``,t.variants.length>0&&(0,B.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,Qf(t),`)`]})]},t.capability.id))}),(0,B.jsx)(ep,{}),(0,B.jsx)(tp,{...e}),(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function ep(){return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 pt-0.5`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`or add manually`}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function tp(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_1fr] gap-1.5`,children:[(0,B.jsx)(qf,{value:e.manualSource,onChange:t=>e.onManualSource(t),options:[{value:`repo`,label:`Repo ref`},{value:`inline`,label:`Inline ref`},{value:`provider`,label:`Provider ref`},{value:`relay`,label:`Relay ref`}]}),(0,B.jsx)(qf,{value:e.manualProvider,onChange:t=>e.onManualProvider(t),options:Uf})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:e.manualRef,onChange:t=>e.onManualRef(t.target.value),placeholder:e.kind===`skill`?`.claude/skills/name or registry slug`:`.relay/plugins/name or registry slug`,className:`font-mono text-xs`}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,onClick:e.onAddManual,children:`Add ref`})]})]})}function np(e){return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`MCP from registry`}),!e.readOnly&&(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 gap-1 text-xs`,onClick:e.onAddClick,children:[(0,B.jsx)(ue,{className:`h-3 w-3`}),`Add MCP`]})]}),e.mcpKeys.length===0&&!e.adding&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No MCP servers from registry`}),e.mcpKeys.map(t=>(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded border border-border bg-card/60 px-2 py-1`,children:[(0,B.jsx)(F,{variant:`outline`,className:`border-emerald-500/30 bg-emerald-500/10 text-[10px] text-emerald-400`,children:`mcp`}),(0,B.jsx)(Yf,{source:`profile`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t}),!e.readOnly&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-5 w-5`,onClick:()=>e.onRemove(t),children:(0,B.jsx)(Ae,{className:`h-3 w-3`})})]},t)),e.adding&&(0,B.jsxs)(`div`,{className:`mt-1.5 space-y-2 rounded border border-border bg-card/60 p-2`,children:[e.loading&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Loading...`}),e.fetchError&&(0,B.jsx)(`div`,{className:`text-xs text-destructive`,children:e.fetchError}),!e.loading&&e.caps.length===0&&!e.fetchError&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No MCP capabilities in registry`}),e.caps.length>0&&(0,B.jsx)(`div`,{className:`max-h-44 space-y-0.5 overflow-y-auto rounded border border-border/60 bg-background/40 p-1`,children:e.caps.map(t=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.onAddMcp(t),className:`w-full rounded px-2 py-1 text-left font-mono text-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[t.capability.slug,t.capability.title?` - ${t.capability.title}`:``,t.variants.length>0&&(0,B.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,Qf(t),`)`]})]},t.capability.id))}),(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function rp(e){let t=kt();return e&&e!==`any`&&t.includes(e)?e:t[0]??``}function ip({profile:e}){let[t,n]=(0,z.useState)(()=>rp(e.provider)),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null);async function l(r=t){if(e.name.trim()){o(!0),c(null);try{let t=await Ee(`GET`,`/agent-profiles/${encodeURIComponent(e.name)}/resolved?provider=${encodeURIComponent(r)}`);n(t.provider),i(t.profile.provisioning??{skills:[],plugins:[],mcpServers:{}})}catch(e){c(jt(e)),i(null)}finally{o(!1)}}}let u=e.relay.tools?.groups??[],d=u.length?u.join(`, `):`all groups`,f=Object.keys(r?.mcpServers??{});return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsx)(qf,{value:t,onChange:e=>{n(e),l(e)},options:kt().map(e=>({value:e,label:Et(e)}))})]}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void l(),disabled:a||!e.name.trim(),children:a?`Resolving...`:`Resolve`})]}),s&&(0,B.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:s}),(0,B.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-2`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Relay tool surface`}),(0,B.jsx)(`div`,{className:`mt-1 font-mono text-xs`,children:d})]}),!r&&!s&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Resolve this profile to inspect materialized provisioning.`}),r&&(0,B.jsxs)(`div`,{className:`grid gap-2`,children:[(0,B.jsx)(ap,{title:`Skills`,values:r.skills.map(e=>e.name),empty:`No resolved skills`}),(0,B.jsx)(ap,{title:`Plugins`,values:r.plugins.map(e=>e.name),empty:`No resolved plugins`}),(0,B.jsx)(ap,{title:`MCP Servers`,values:f,empty:`No resolved MCP servers`}),(r.skipped?.length??0)>0&&(0,B.jsxs)(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 p-2`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-amber-300`,children:`Skipped`}),(0,B.jsx)(`div`,{className:`mt-1 space-y-1`,children:r.skipped.map(e=>(0,B.jsxs)(`div`,{className:`text-xs`,children:[(0,B.jsxs)(`span`,{className:`font-mono`,children:[e.kind,`:`,e.ref]}),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` - `,e.detail]})]},`${e.kind}:${e.ref}:${e.reason}`))})]})]})]})}function ap({title:e,values:t,empty:n}){return(0,B.jsxs)(`div`,{className:`rounded border border-border bg-card/60 p-2`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:e}),t.length===0?(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n}):(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map((e,t)=>(0,B.jsx)(F,{variant:`outline`,className:`font-mono text-[10px]`,children:e},`${e}:${t}`))})]})}function op({title:e,children:t,defaultOpen:n=!0}){let[r,i]=(0,z.useState)(n);return(0,B.jsxs)(`div`,{className:`border border-border rounded-md`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium hover:bg-accent`,onClick:()=>i(!r),children:[r?(0,B.jsx)(l,{className:`h-3.5 w-3.5`}):(0,B.jsx)(ut,{className:`h-3.5 w-3.5`}),e]}),r&&(0,B.jsx)(`div`,{className:`space-y-3 border-t border-border px-3 py-3`,children:t})]})}function sp({value:e,onChange:t,options:n,disabled:r}){return(0,B.jsx)(`select`,{className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e,onChange:e=>t(e.target.value),disabled:r,children:n.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function cp({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(``);function c(){i.trim()&&(t({...e,[i.trim()]:o}),a(``),s(``))}function l(n){let r={...e};delete r[n],t(r)}return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[r.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsxs)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 text-xs`,children:[e,`=`,t]}),!n&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>l(e),children:(0,B.jsx)(Ae,{className:`h-3 w-3`})})]},e)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:i,onChange:e=>a(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,B.jsx)(L,{value:o,onChange:e=>s(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&c()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:c,children:(0,B.jsx)(ue,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var lp=[{value:`host`,label:`Host — full access, relay-aware`},{value:`minimal`,label:`Minimal — relay disabled, repo-scoped`},{value:`isolated`,label:`Isolated — strict isolation`},{value:`vanilla`,label:`Vanilla — zero host bleed (plugins/skills/hooks/MCP/CLAUDE.md off)`}],up=[{value:`any`,label:`Any provider`},...kt().map(e=>({value:e,label:Et(e)}))],dp=[{value:`host`,label:`Host — use host config`},{value:`profile`,label:`Profile — use profile config`},{value:`repo`,label:`Repo — use repo config only`},{value:`none`,label:`None — disabled`}],fp=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],pp=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],mp=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}],hp={context:`Injects relay's context preamble each turn (memory + situational awareness).`,skills:`Makes the bundled Agent Relay skills available to the agent.`,plugins:`Loads the bundled Agent Relay Claude plugin (session registration, approval hooks).`,statusLine:`Enables the relay status-line probe (quota + context-window reporting).`,mcp:`Master switch for relay's own MCP tools (relay_* — messaging, memory, spawn, etc.). One of three independent MCP sources, alongside Project MCP (the project's .mcp.json) and MCP Mode (the host's ambient MCP).`},gp={context:`Context`,skills:`Skills`,plugins:`Plugins`,statusLine:`Status Line`,mcp:`MCP Tools`};function _p({values:e,onChange:t,disabled:n,placeholder:r}){let[i,a]=(0,z.useState)(``);function o(){let n=i.trim();n&&(t([...e,n]),a(``))}function s(n,r){t(e.map((e,t)=>t===n?r:e))}function c(n){t(e.filter((e,t)=>t!==n))}return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[e.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:e,onChange:e=>s(t,e.target.value),disabled:n,className:`flex-1 text-xs`}),!n&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>c(t),children:(0,B.jsx)(Ae,{className:`h-3 w-3`})})]},`${e}-${t}`)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:i,onChange:e=>a(e.target.value),placeholder:r,className:`flex-1 text-xs`,onKeyDown:e=>e.key===`Enter`&&o()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:o,children:(0,B.jsx)(ue,{className:`h-3 w-3`})})]}),e.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`None`})]})}function vp(){let{open:e,mode:t,profile:n}=A(e=>e.profileModal),r=A(e=>e.closeProfileModal),i=A(e=>e.updateProfileModal),a=A(e=>e.saveProfile),o=t===`view`,s=t===`create`||t===`duplicate`,c=t===`view`?`Profile: ${n.name}`:t===`edit`?`Edit: ${n.name}`:t===`duplicate`?`Duplicate Profile`:`Create Profile`;function l(e){i({instructions:{...n.instructions,...e}})}function u(e){i({relay:{...n.relay,...e}})}function d(e,t){let r=n.relay.tools?.groups??[],i=t?[...new Set([...r,e])]:r.filter(t=>t!==e);u({tools:i.length?{groups:i}:void 0})}function f(e){i({projectMcp:Kf(e)})}function p(e){i({projectSkills:Kf(e)})}function m(e){i({projectSettings:Kf(e)})}function h(e){i({sharedMcp:Kf(e)})}function g(e){i({permissions:{...n.permissions,...e}})}function _(e){let t=n.providerOptions||{},r={...t.codex&&typeof t.codex==`object`&&!Array.isArray(t.codex)?t.codex:{}};if(!e.trim())delete r.toolOutputTokenLimit;else{let t=Number(e);if(!Number.isSafeInteger(t))return;r.toolOutputTokenLimit=t}i({providerOptions:{...t,codex:r}})}function v(e){if(!e.trim()){i({maxSpawnedAgents:void 0});return}let t=Number(e);!Number.isInteger(t)||t<0||i({maxSpawnedAgents:Math.min(t,100)})}function y(e){let t=e===`host`;i({base:e,relay:{context:t,skills:t,plugins:t,statusLine:t,mcp:t},mcp:{...n.mcp,mode:t?`host`:`none`},hooks:{mode:t?`host`:`none`},permissions:{...n.permissions,filesystem:t?`host`:`repo`},instructions:{...n.instructions,globalInstructions:t?`allow`:`ignore`}})}let b=n.providerOptions?.codex&&typeof n.providerOptions.codex==`object`&&!Array.isArray(n.providerOptions.codex)?n.providerOptions.codex:{},x=Number.isSafeInteger(b.toolOutputTokenLimit)?String(b.toolOutputTokenLimit):``;return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(uf,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{className:`flex items-center gap-2`,children:[c,n.builtIn&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:`Built-in`})]})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(op,{title:`General`,defaultOpen:!0,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Name`}),(0,B.jsx)(L,{value:n.name,onChange:e=>i({name:e.target.value}),placeholder:`my-profile`,disabled:o||t===`edit`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Description`}),(0,B.jsx)(L,{value:n.description||``,onChange:e=>i({description:e.target.value}),placeholder:`What this profile configures`,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Emoji shown across the dashboard wherever an agent on this profile appears (conversation rows, agent cards, chat header). A single emoji; leave blank for a neutral marker.`,children:`Icon`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(L,{value:n.icon||``,onChange:e=>i({icon:e.target.value}),placeholder:`🤖`,maxLength:8,disabled:o,className:`w-24 text-center text-base`}),(0,B.jsx)(`span`,{className:`text-2xl leading-none`,"aria-hidden":!0,children:n.icon?.trim()||`•`})]})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Base`}),(0,B.jsx)(sp,{value:n.base,onChange:e=>y(e),options:lp,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsx)(sp,{value:n.provider||`any`,onChange:e=>i({provider:e}),options:up,disabled:o})]})]})]}),(0,B.jsxs)(op,{title:`Instructions`,defaultOpen:!1,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`System Prompt`}),(0,B.jsx)(Wd,{value:n.instructions.system||``,onChange:e=>l({system:e.target.value}),placeholder:`Custom system prompt...`,rows:3,disabled:o,className:`font-mono text-xs`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Append Instructions`}),(0,B.jsx)(_p,{values:n.instructions.append??[],onChange:e=>l({append:e}),disabled:o,placeholder:`Append instruction fragment`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Repo Instructions`}),(0,B.jsx)(sp,{value:n.instructions.repoInstructions,onChange:e=>l({repoInstructions:e}),options:pp,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Global Instructions`}),(0,B.jsx)(sp,{value:n.instructions.globalInstructions,onChange:e=>l({globalInstructions:e}),options:pp,disabled:o})]})]})]}),(0,B.jsxs)(op,{title:`Relay Integration`,defaultOpen:!1,children:[(0,B.jsxs)(`p`,{className:`rounded border border-border bg-muted/20 px-2 py-1.5 text-xs text-muted-foreground`,children:[`MCP comes from three independent sources — relay (`,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`MCP Tools`}),` below), the project (`,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`Project MCP`}),` in Provisioning Policies), and the host (`,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`MCP Mode`}),` in MCP & Hooks). Toggle each separately and mix freely.`]}),(0,B.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[`context`,`skills`,`plugins`,`statusLine`,`mcp`].map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(Rf,{tip:hp[e],children:gp[e]}),(0,B.jsx)(fl,{checked:n.relay[e]??!0,onCheckedChange:t=>u({[e]:t}),disabled:o})]},e))}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Pick which subsets of relay's MCP tools the agent gets. No groups selected = the full relay tool surface.`,children:`Relay Tool Groups`}),(0,B.jsx)(`div`,{className:`mt-1 grid grid-cols-2 gap-1.5`,children:zf.map(e=>(0,B.jsxs)(`label`,{className:`flex items-center gap-2 rounded border border-border px-2 py-1 text-xs`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`rounded`,checked:(n.relay.tools?.groups??[]).includes(e),onChange:t=>d(e,t.target.checked),disabled:o}),(0,B.jsx)(`span`,{className:`font-mono`,children:e})]},e))}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`No groups selected means full relay MCP tool surface.`})]})]}),(0,B.jsx)(op,{title:`MCP & Hooks`,defaultOpen:!1,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`The host's ambient MCP servers (your rig's configured MCP). Host = inherit them; None = no host MCP (clean, no bleed). Separate from relay's own MCP and the project's MCP.`,children:`MCP Mode`}),(0,B.jsx)(sp,{value:n.mcp.mode,onChange:e=>i({mcp:{...n.mcp,mode:e}}),options:dp,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`The host's hook configuration. Host = inherit it; None = no host hooks.`,children:`Hooks Mode`}),(0,B.jsx)(sp,{value:n.hooks.mode,onChange:e=>i({hooks:{mode:e}}),options:dp,disabled:o})]})]})}),(0,B.jsx)(op,{title:`Provisioning Policies`,defaultOpen:!1,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Injects the MCP servers declared in the spawn directory's project .mcp.json, via relay's controlled config path (survives --strict-mcp-config, no trust modal). All = every declared server. This is the project's MCP source — distinct from relay's MCP Tools and the host's MCP Mode.`,children:`Project MCP`}),(0,B.jsx)(sp,{value:Gf(n.projectMcp),onChange:f,options:Bf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Injects skills committed under the project's .claude/skills.`,children:`Project Skills`}),(0,B.jsx)(sp,{value:Gf(n.projectSkills),onChange:p,options:Bf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Injects the project's .claude/settings.json (permission/security keys stripped).`,children:`Project Settings`}),(0,B.jsx)(sp,{value:Gf(n.projectSettings),onChange:m,options:Vf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Routes the agent's non-identity MCP through one shared orchestrator listener so the MCP session survives restarts and keeps correct worktree-cwd routing. A transport choice, not a source selector.`,children:`Shared MCP`}),(0,B.jsx)(sp,{value:Gf(n.sharedMcp),onChange:h,options:Bf,disabled:o})]}),(0,B.jsxs)(`div`,{className:`col-span-2`,children:[(0,B.jsx)(Rf,{tip:`How the agent's isolated branch lands: Direct (rebase/FF), Pull request, or the instance default.`,children:`Landing Strategy`}),(0,B.jsx)(sp,{value:n.landingStrategy??``,onChange:e=>i({landingStrategy:e||void 0}),options:Hf,disabled:o})]})]})}),(0,B.jsx)(op,{title:`Permissions`,defaultOpen:!1,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Approval Mode`}),(0,B.jsx)(sp,{value:n.permissions.mode||``,onChange:e=>g({mode:e||void 0}),options:mp,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Filesystem Scope`}),(0,B.jsx)(sp,{value:n.permissions.filesystem,onChange:e=>g({filesystem:e}),options:fp,disabled:o})]})]})}),(0,B.jsx)(op,{title:`Spawning`,defaultOpen:!1,children:(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Spawn Quota`}),(0,B.jsx)(L,{type:`number`,min:0,max:100,step:1,value:n.maxSpawnedAgents===void 0?``:String(n.maxSpawnedAgents),onChange:e=>v(e.target.value),placeholder:`0`,disabled:o}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Max concurrent live child agents this profile may spawn. Empty or 0 = cannot spawn (default). Children never inherit it (no grandchildren).`})]})}),(0,B.jsx)(op,{title:`Environment Variables`,defaultOpen:!1,children:(0,B.jsx)(cp,{env:n.env||{},onChange:e=>i({env:e}),disabled:o})}),(0,B.jsx)(op,{title:`Registry Capabilities`,defaultOpen:!1,children:(0,B.jsx)(Xf,{skills:n.skills??[],plugins:n.plugins??[],mcp:n.mcp,onChangeSkills:e=>i({skills:e}),onChangePlugins:e=>i({plugins:e}),onChangeMcp:e=>i({mcp:e}),projectMcp:n.projectMcp,projectSkills:n.projectSkills,projectSettings:n.projectSettings,sharedMcp:n.sharedMcp,readOnly:o})}),(0,B.jsx)(op,{title:`Resolved Provisioning`,defaultOpen:t===`view`,children:(0,B.jsx)(ip,{profile:n})}),(0,B.jsxs)(op,{title:`Provider Options`,defaultOpen:!1,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Codex Tool Output Limit`}),(0,B.jsx)(L,{type:`number`,min:1e3,max:2e5,value:x,onChange:e=>_(e.target.value),placeholder:`12000`,disabled:o})]}),(0,B.jsx)(Wd,{value:JSON.stringify(n.providerOptions||{},null,2),onChange:e=>{try{i({providerOptions:JSON.parse(e.target.value)})}catch{}},rows:3,disabled:o,className:`font-mono text-xs`,placeholder:`{}`})]})]}),!o&&(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:a,children:s?`Create`:`Save`})]})]})})}function yp(){let e=A(e=>e.commandPaletteOpen),t=A(e=>e.commandQuery),n=A(e=>e.set),r=A(e=>e.closeCommandPalette),i=A(e=>e.runCommand),a=ul(),o=(0,z.useRef)(null);return(0,z.useEffect)(()=>{e&&setTimeout(()=>o.current?.focus(),50)},[e]),e?(0,B.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,onClick:e=>{e.target===e.currentTarget&&r()},children:[(0,B.jsx)(`div`,{className:`fixed inset-0 bg-black/60`}),(0,B.jsxs)(`div`,{className:`relative w-full max-w-lg bg-card border border-border rounded-xl shadow-2xl overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`p-3 border-b border-border`,children:(0,B.jsx)(L,{ref:o,value:t,onChange:e=>n({commandQuery:e.target.value}),placeholder:`Type a command...`,className:`border-0 bg-transparent focus-visible:ring-0 text-base`})}),(0,B.jsxs)(`div`,{className:`max-h-80 overflow-y-auto p-2`,children:[a.map(e=>(0,B.jsxs)(`button`,{onClick:()=>i(e),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-accent text-left transition-colors`,children:[(0,B.jsx)(rt[e.icon]||ut,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-sm`,children:e.title}),e.subtitle&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.subtitle})]})]},e.id)),a.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No matching commands.`})]})]})]}):null}function bp(){let e=A(e=>e.set),t=A(e=>e.connected);return(0,B.jsxs)(`div`,{className:`xl:hidden shrink-0 sticky top-0 z-30 bg-card border-b border-border px-4 h-[var(--header-h)] flex items-center gap-3`,children:[(0,B.jsx)(`button`,{onClick:()=>e({mobileMenuOpen:!0}),className:`p-1 -ml-1 text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Open menu`,children:(0,B.jsx)(Je,{className:`w-5 h-5`})}),(0,B.jsx)(oe,{className:`w-4 h-4 text-primary`}),(0,B.jsx)(`span`,{className:`font-bold text-sm`,children:`Agent Relay`}),(0,B.jsx)(`span`,{className:`ml-auto w-2 h-2 rounded-full ${t?`bg-emerald-500`:`bg-red-500 animate-pulse`}`})]})}function xp(e){return e===`five_hour`?`5h burst`:e===`seven_day`?`7-day`:e===`seven_day_sonnet`?`7-day Sonnet`:e===`seven_day_opus`?`7-day Opus`:e===`primary`?`Primary`:e===`secondary`?`Secondary`:e}function Sp(e,t){if(!t)return``;let n=Math.max(0,(t-e)/1e3);if(n<60)return`${Math.floor(n)}s`;if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400){let e=Math.floor(n/3600),t=Math.round(n%3600/60);return t===60?`${e+1}h`:t>0?`${e}h ${t}m`:`${e}h`}return`${Math.floor(n/86400)}d`}var Cp=`agent-relay:quota-widget`,wp=300*1e3,Tp=8;function Ep(e){return!e.quota&&e.lastError?.type===`unavailable`}function Dp(e,t){let n=t===`5h`?[`five_hour`,`primary`]:[`seven_day`,`secondary`];return e.quota?.windows.find(e=>n.includes(e.name))}function Op(e,t){if(!t)return``;let n=Math.max(0,(t-e)/1e3);return n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.round(n/3600)}h`:`${(n/86400).toFixed(1).replace(/\.0$/,``)}d`}function kp({record:e,now:t,advisory:n}){let r=(0,B.jsx)(Eu,{provider:e.provider,className:`w-3.5 h-3.5`});if(Ep(e))return(0,B.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[r,(0,B.jsx)(`span`,{className:`italic`,children:`unavailable`})]});if(!e.quota){let n=e.lastAttemptAt?j(t,e.lastAttemptAt):``,i=e.lastError?.retryAfterMs,a=i==null?null:Math.ceil(Math.max(0,(e.lastAttemptAt+i-t)/1e3));return(0,B.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[r,n&&(0,B.jsx)(`span`,{children:n}),a!=null&&a>0&&(0,B.jsxs)(`span`,{className:`text-amber-400/70`,children:[`~`,a,`s`]})]})}let i=Dp(e,`5h`),a=Dp(e,`7d`);function o(e){if(!e)return null;let n=Math.round(e.utilization*100),r=Op(t,e.resetsAt);return(0,B.jsxs)(`span`,{className:`tabular-nums`,children:[n,`%`,r?`/${r}`:``]})}let s=(e.stale||e.lastError)&&e.lastAttemptAt?j(t,e.lastAttemptAt):``;return(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 shrink-0 text-foreground/70`,children:[r,(0,B.jsx)(Fp,{advisory:n}),o(i),o(a),s&&(0,B.jsx)(`span`,{className:`text-muted-foreground/70`,children:s})]})}function Ap(){try{let e=localStorage.getItem(Cp);return{open:!0,pinned:!1,...e?JSON.parse(e):{}}}catch{return{open:!0,pinned:!1}}}function jp(e){try{localStorage.setItem(Cp,JSON.stringify(e))}catch{}}function Mp(){let[{open:e,pinned:t},n]=(0,z.useState)(Ap),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(`loading`),d=bt(),f=A(e=>e.connected);(0,z.useEffect)(()=>{if(!f)return;let e=!1;async function t(){try{let[t,n,r]=await Promise.all([Ee(`GET`,`/provider-quotas`),Ee(`GET`,`/providers/quota-config`).catch(()=>null),Ee(`GET`,`/provider-quotas/advisory`).catch(()=>null)]);e||(i(t),o(n),c(r),u(`ok`))}catch{e||u(`error`)}}t();let n=setInterval(()=>void t(),wp);return()=>{e=!0,clearInterval(n)}},[f,A(e=>e.quotaSeq)]);let p=e||t,m=(r?.quotas??[]).filter(e=>a?.[e.provider]?.showInWidget!==!1),h=m.some(e=>e.stale&&!Ep(e)),g=m.some(e=>e.lastError&&!Ep(e));function _(){if(t)return;let r={open:!e,pinned:t};n(r),jp(r)}function v(){let r=t?{open:e,pinned:!1}:{open:!0,pinned:!0};n(r),jp(r)}return(0,B.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,B.jsxs)(`div`,{className:`w-full flex items-center gap-2 px-4 py-2 text-xs hover:bg-muted/30 transition-colors`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:_,"aria-expanded":p,className:`min-w-0 flex flex-1 items-center gap-2 text-left`,children:[(0,B.jsx)(ut,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground transition-transform ${p?`rotate-90`:``}`}),(0,B.jsx)(`span`,{className:`font-semibold text-foreground/80 shrink-0 ${p?``:`hidden sm:inline`}`,children:`Provider Quotas`}),l===`loading`&&(0,B.jsx)(Xe,{className:`w-3 h-3 text-muted-foreground animate-spin`}),l===`error`&&(0,B.jsx)(`span`,{className:`text-amber-400 text-[10px]`,children:`● unavailable`}),!p&&l===`ok`&&m.length>0&&(0,B.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-0.5 text-[10px]`,children:m.map(e=>(0,B.jsx)(kp,{record:e,now:d,advisory:s?.advisories[e.provider]},`${e.provider}:${e.accountKey}`))}),p&&h&&(0,B.jsx)(`span`,{className:`text-amber-400 text-[10px]`,children:`● stale`}),p&&g&&(0,B.jsx)(`span`,{className:`text-red-400 text-[10px]`,children:`● error`})]}),(0,B.jsx)(`button`,{type:`button`,onClick:v,"aria-pressed":t,title:t?`Unpin`:`Pin always-on`,className:`p-0.5 rounded hover:bg-muted transition-colors ${t?`text-primary`:`text-muted-foreground/50 hover:text-muted-foreground`}`,children:(0,B.jsx)(fe,{className:`w-3 h-3`})})]}),p&&(0,B.jsxs)(`div`,{className:`px-4 py-3`,children:[l===`loading`&&(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[(0,B.jsx)(Xe,{className:`w-3 h-3 animate-spin`}),`Loading quota data…`]}),l===`error`&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Quota data unavailable — check that you are authenticated and the server is reachable.`}),l===`ok`&&r!==null&&m.length===0&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No quota data yet — waiting for runner to report.`}),l===`ok`&&r!==null&&m.length>0&&(0,B.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3`,children:m.map(e=>{let t=a?.[e.provider],n={enabled:t?.sparklineEnabled??!0,rangeHours:t?.sparklineRangeHours??Tp};return(0,B.jsx)(zp,{record:e,now:d,advisory:s?.advisories[e.provider],sparklineCfg:n},`${e.provider}:${e.accountKey}`)})})]})]})}var Np={prefer:{icon:lt,badge:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,dot:`bg-emerald-400`},caution:{icon:gt,badge:`text-amber-400 bg-amber-500/10 border-amber-500/20`,dot:`bg-amber-400`},"avoid-large":{icon:gt,badge:`text-orange-400 bg-orange-500/10 border-orange-500/20`,dot:`bg-orange-400`},"hard-avoid":{icon:Me,badge:`text-red-400 bg-red-500/10 border-red-500/20`,dot:`bg-red-400`}};function Pp({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded px-1 py-0.5 shrink-0`,children:[(0,B.jsx)(Me,{className:`w-2.5 h-2.5`}),`at capacity`]});let t=e.quotaPenaltyBand;if(t===`normal`)return null;let n=Np[t],r=n.icon;return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-medium ${n.badge} border rounded px-1 py-0.5 shrink-0`,children:[(0,B.jsx)(r,{className:`w-2.5 h-2.5`}),t]})}function Fp({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-500 shrink-0`,title:`at capacity`});let t=e.quotaPenaltyBand;return t===`normal`?null:(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${Np[t].dot} shrink-0`,title:t})}function Ip(e,t){if(!e||e.confidence===`low`||e.burnRatio===null)return null;let n=e.burnRatio.toFixed(1);return!e.earlyWallMs||e.earlyWallMs<=0?`${n}× rate`:`${n}× · ~${Sp(t,t+e.earlyWallMs)} before reset`}function Lp({burnWindow:e,now:t}){if(!e)return null;if(e.confidence===`low`||e.burnRatio===null)return(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground/50`,children:[(0,B.jsx)(tt,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{className:`italic`,children:`building burn history…`})]});let n=Ip(e,t);return n?(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground/70 tabular-nums`,children:[(0,B.jsx)(gt,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{children:n})]}):null}function Rp({provider:e,windowName:t,rangeHours:n}){let[r,i]=(0,z.useState)([]);bt(),(0,z.useEffect)(()=>{let r=!1,a=Date.now()-n*36e5;return Ee(`GET`,`/provider-quotas/history?provider=${encodeURIComponent(e)}&sinceMs=${a}&limit=500`).then(e=>{r||i(e.filter(e=>!!e.quota).map(e=>{let n=e.quota.windows.find(e=>e.name===t);return n?{t:e.capturedAt,v:n.utilization}:null}).filter(Boolean))}).catch(()=>{}),()=>{r=!0}},[e,t,n]);let a=(0,z.useMemo)(()=>{if(r.length<2)return null;let e=r[0].t,t=r[r.length-1].t-e||1;return r.map(n=>{let r=1+(n.t-e)/t*118,i=1+(1-n.v)*22;return`${r.toFixed(1)},${i.toFixed(1)}`}).join(` `)},[r]);if(!a)return null;let o=r.length>0?Math.round(r[r.length-1].v*100):0;return(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`svg`,{width:120,height:24,viewBox:`0 0 120 24`,className:`shrink-0`,children:(0,B.jsx)(`polyline`,{points:a,fill:`none`,stroke:o>=90?`#ef4444`:o>=70?`#f59e0b`:`#10b981`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,opacity:.8})}),(0,B.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[n,`h`]})]})}function zp({record:e,now:t,advisory:n,sparklineCfg:r}){let{provider:i,accountKey:a,quota:o,stale:s,lastError:c,lastUpdatedAt:l,lastAttemptAt:u}=e;if(Ep(e))return(0,B.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-3 space-y-1.5 opacity-70`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,B.jsx)(Eu,{provider:i,className:`w-3.5 h-3.5 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground bg-muted border border-border rounded px-1 py-0.5 shrink-0`,children:`unavailable`})]}),(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Quota unavailable — `,c?.message??`no readable credentials`]})]});let d=c?.retryAfterMs,f=d==null?null:Math.max(0,u+d-t),p=f==null?null:Math.ceil(f/1e3),m=(s||!!c)&&u>0;return(0,B.jsxs)(`div`,{className:`rounded border ${c?`border-red-500/30`:s?`border-amber-500/30`:`border-border`} bg-card p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,B.jsx)(Eu,{provider:i,className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono truncate`,children:a})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,B.jsx)(Pp,{advisory:n}),s&&(0,B.jsx)(`span`,{className:`text-[9px] font-medium text-amber-400 bg-amber-500/10 border border-amber-500/20 rounded px-1 py-0.5`,children:`stale`}),c&&(0,B.jsx)(`span`,{className:`text-[9px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded px-1 py-0.5`,title:c.message,children:c.type===`rate_limited`?`429`:`err`})]})]}),o?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:o.windows.map(n=>{let i=Math.round(n.utilization*100),a=i>=90?`bg-red-500`:i>=70?`bg-amber-500`:`bg-emerald-500`,o=n.resetsAt?Sp(t,n.resetsAt):``,s=e.burn?.windows.find(e=>e.name===n.name);return(0,B.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:xp(n.name)}),(0,B.jsxs)(`span`,{children:[i,`%`,o?` · resets in ${o}`:``]})]}),(0,B.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,B.jsx)(`div`,{className:`h-full ${a} transition-all duration-500`,style:{width:`${Math.max(0,Math.min(100,i))}%`}})}),(0,B.jsx)(Lp,{burnWindow:s,now:t}),r?.enabled&&(0,B.jsx)(Rp,{provider:e.provider,windowName:n.name,rangeHours:r.rangeHours})]},n.name)})}):(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:c?c.message:`No quota data`}),(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2 text-[10px] text-muted-foreground/60`,children:[(0,B.jsxs)(`div`,{className:`space-y-0.5 min-w-0`,children:[m&&(0,B.jsxs)(`div`,{children:[`Attempted `,j(t,u)]}),(0,B.jsx)(`div`,{children:l?`Updated ${j(t,l)}`:`Never updated`})]}),p!=null&&(0,B.jsx)(`span`,{className:`text-amber-400/70 shrink-0 mt-0.5`,children:p>0?`retry in ~${p>60?`${Math.ceil(p/60)}m`:`${p}s`}`:`retrying…`})]})]})}function Bp(e){return(0,z.lazy)(()=>tr(e))}var Vp=Bp(()=>R(()=>import(`./overview-DpaEvvLT.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([16,1,6,8,9,10,17,12,18]),import.meta.url)),Hp=Bp(()=>R(()=>import(`./chat-aRCk0pLJ.js`).then(e=>({default:e.ChatView})),__vite__mapDeps([19,1,6,20,8,9,10,21,22,23,24,25,11,12,17,26,13]),import.meta.url)),Up=Bp(()=>R(()=>import(`./agents-C5FajNPw.js`).then(e=>({default:e.AgentsView})),__vite__mapDeps([27,1,28,29,6,12,30,20,31,32,33,34,35,8,9,10,24,25,11,17,18]),import.meta.url)),Wp=Bp(()=>R(()=>import(`./managed-agents-DVbJ2hqh.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([36,1,6,8,9,10,25,11,12,17]),import.meta.url)),Gp=Bp(()=>R(()=>import(`./teams-BBb0ZYiF.js`).then(e=>({default:e.TeamsView})),__vite__mapDeps([37,1,38,28,29,6,12,30,20,31,32,39,40,41,33,35,42,8,9,10,23,17,11,18,26]),import.meta.url)),Kp=Bp(()=>R(()=>import(`./agent-profiles-D8WLdTCs.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([43,1,6,8,9,10,17,12,11]),import.meta.url)),qp=Bp(()=>R(()=>import(`./orchestrators-B0u2lQfw.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([44,6,1,8,9,10,17,12,11,18]),import.meta.url)),Jp=Bp(()=>R(()=>import(`./workspaces-BNLP4IlV.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([45,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),Yp=Bp(()=>R(()=>import(`./channels-DOYB1iiA.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([46,6,1,8,9,10,17,12,11,18]),import.meta.url)),Xp=Bp(()=>R(()=>import(`./connectors-C5CeK-2M.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([47,6,1,8,9,10,17,12,11,18]),import.meta.url)),Zp=Bp(()=>R(()=>import(`./integrations-CztQfrI7.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([48,6,1,8,9,10,17,12,11,18]),import.meta.url)),Qp=Bp(()=>R(()=>import(`./security-C9P6yiQ3.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([49,1,6,25,11,12,17,18,26]),import.meta.url)),$p=Bp(()=>R(()=>import(`./memory-Bp-D_V80.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([50,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),em=Bp(()=>R(()=>import(`./activity-wAN_upn7.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([51,1,6,8,9,10,21,22,17,12,11,18]),import.meta.url)),tm=Bp(()=>R(()=>import(`./pairs-DRp_qAu8.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([52,6,1,8,9,10,17,12,11,18]),import.meta.url)),nm=Bp(()=>R(()=>import(`./messages-DE1QSeHI.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([53,1,6,8,9,10,17,12,11,18]),import.meta.url)),rm=Bp(()=>R(()=>import(`./work-queue-DQMbkSD8.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([54,6,1,8,9,10,17,12,11,18]),import.meta.url)),im=Bp(()=>R(()=>import(`./tasks-1oK_ggFC.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([55,6,1,8,9,10,17,12,11,18]),import.meta.url)),am=Bp(()=>R(()=>import(`./automation-ShdXg0pX.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([56,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),om=Bp(()=>R(()=>import(`./analytics-Q6Dl_CE9.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([57,1,6,8,9,10,18,58]),import.meta.url)),sm=Bp(()=>R(()=>import(`./insights-FzTX2wNh.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([59,1,6,17,12,11,18,26,9,10]),import.meta.url)),cm=Bp(()=>R(()=>import(`./projects-cOeuiMjl.js`).then(e=>({default:e.ProjectsView})),__vite__mapDeps([60,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),lm=Bp(()=>R(()=>import(`./prompt-settings-CNoBiymk.js`).then(e=>({default:e.PromptSettingsView})),__vite__mapDeps([61,1,6,17,12,11,18,9,10]),import.meta.url)),um=Bp(()=>R(()=>import(`./registry-0A4QFMWC.js`).then(e=>({default:e.RegistryView})),__vite__mapDeps([62,1,6,17,12,11,18,26,10]),import.meta.url)),dm=Bp(()=>R(()=>import(`./maintenance-C8Uw8XiI.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([63,1,6,8,9,10,17,12,11]),import.meta.url)),fm=Bp(()=>R(()=>import(`./settings-TnHlB9-t.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([64,1,38,28,29,6,12,30,20,31,32,39,40,41,33,35,42,8,9,10,22,17,11,18,26,58]),import.meta.url)),pm=class extends z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
|
|
21
|
+
`)})]})]})}function Bd(e){if(!wt(e)||typeof e.lastError!=`string`)return null;let t=wt(e.systemd)?{unit:typeof e.systemd.unit==`string`?e.systemd.unit:void 0,activeState:typeof e.systemd.activeState==`string`?e.systemd.activeState:void 0,subState:typeof e.systemd.subState==`string`?e.systemd.subState:void 0,result:typeof e.systemd.result==`string`?e.systemd.result:void 0,execMainCode:typeof e.systemd.execMainCode==`string`?e.systemd.execMainCode:void 0,execMainStatus:typeof e.systemd.execMainStatus==`string`?e.systemd.execMainStatus:void 0}:void 0;return{lastError:e.lastError,detectedAt:typeof e.detectedAt==`number`?e.detectedAt:void 0,runtimeMs:typeof e.runtimeMs==`number`?e.runtimeMs:void 0,logFile:typeof e.logFile==`string`?e.logFile:void 0,logBytes:typeof e.logBytes==`number`?e.logBytes:void 0,logEmpty:typeof e.logEmpty==`boolean`?e.logEmpty:void 0,logTail:Array.isArray(e.logTail)?e.logTail.filter(e=>typeof e==`string`):void 0,systemd:t,unavailable:Array.isArray(e.unavailable)?e.unavailable.filter(e=>typeof e==`string`):void 0}}function Vd({className:e,children:t,...n}){return(0,B.jsxs)(bs,{"data-slot":`scroll-area`,className:O(`relative`,e),...n,children:[(0,B.jsx)(xs,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1`,children:t}),(0,B.jsx)(Hd,{}),(0,B.jsx)(Ss,{})]})}function Hd({className:e,orientation:t=`vertical`,...n}){return(0,B.jsx)(Jo,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:O(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,B.jsx)(as,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Ud(){let e=A(e=>e.channelDetailOpen),t=A(e=>e.channelDetailId),n=A(e=>e.channels),r=A(e=>e.messages),i=A(e=>e.agentsById),a=bt(),o=A(e=>e.closeChannelDetail),s=n.find(e=>e.id===t)||null,c=Kt(s),l=(0,z.useMemo)(()=>s?r.filter(e=>Zt(e,s)).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,s]);return(0,B.jsx)(lu,{open:e,onOpenChange:e=>!e&&o(),children:(0,B.jsxs)(pu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,B.jsx)(mu,{className:`shrink-0 p-4 border-b border-border`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(F,{className:Lt(c.tone),children:c.label}),(0,B.jsx)(hu,{className:`text-base truncate`,children:s?.name||`Channel`})]})}),(0,B.jsx)(Vd,{className:`flex-1 min-h-0`,children:(0,B.jsxs)(`div`,{className:`p-4 space-y-4`,children:[s&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Route`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Type`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.type})]}),(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Direction`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.direction})]}),s.target&&(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Target`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.target})]}),(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Agent`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.agentId})]}),(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Transport`}),(0,B.jsx)(`span`,{className:`truncate`,children:s.transport})]}),(0,B.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Last seen`}),(0,B.jsx)(`span`,{className:`shrink-0`,children:j(a,s.lastSeen)})]})]})]}),Wt(s.capabilities).length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Capabilities`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Wt(s.capabilities).map(e=>(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]}),s.meta&&Object.keys(s.meta).length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,B.jsx)(`div`,{className:`space-y-1 text-sm`,children:Object.entries(s.meta).map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex justify-between gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,B.jsx)(`span`,{className:`truncate`,children:String(t)})]},e))})]})]})]}),l.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Recent Messages`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:l.map(e=>(0,B.jsxs)(`div`,{className:`rounded border border-border p-2 text-xs space-y-0.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground truncate shrink-0 max-w-[40%]`,children:Jt(e.from,i)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,B.jsx)(`span`,{className:`truncate max-w-[40%]`,children:Jt(e.to,i)}),(0,B.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,B.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),j(a,e.createdAt)]})]}),(0,B.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:Qt(e)})]},e.id))})]})]})]})})]})})}function Wd({className:e,...t}){return(0,B.jsx)(`textarea`,{"data-slot":`textarea`,className:O(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function $({className:e,...t}){return(0,B.jsx)(Lo,{"data-slot":`label`,className:O(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var Gd={none:`None`,uncommitted:`Uncommitted`,"committed-on-branch":`On Branch`,"landed-on-main":`Landed`,deploying:`Deploying`,deployed:`Deployed`},Kd={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,claimed:`bg-purple-500/10 text-purple-300 border-purple-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,orphaned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,done:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,failed:`bg-red-500/10 text-red-400 border-red-500/20`,canceled:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`},qd={none:`bg-zinc-500/10 text-zinc-400`,uncommitted:`bg-yellow-500/10 text-yellow-400`,"committed-on-branch":`bg-blue-500/10 text-blue-400`,"landed-on-main":`bg-emerald-500/10 text-emerald-400`,deploying:`bg-purple-500/10 text-purple-400`,deployed:`bg-teal-500/10 text-teal-400`};function Jd(e){let t=e.dispatch;return{title:e.title??``,intent:e.intent??``,latestSteer:e.latestSteer??``,doneWhen:e.doneWhen??``,teamId:e.teamId??``,dispatchComplexity:t?.complexity??``,dispatchType:t?.type??``,dispatchFootprint:t?.contextFootprint??``,dispatchCriticality:t?.criticality??``}}function Yd(){let e=bt(),t=A(e=>e.taskDetailOpen),n=A(e=>e.taskDetailId),r=A(e=>e.taskDetailById),i=A(e=>e.taskMemoryById),a=A(e=>e.taskHistoryById),o=A(e=>e.taskDispatchResultById),c=A(e=>e.taskDispatchLoadingId),l=A(e=>e.agentsById),u=A(e=>e.providerCatalog),d=A(e=>e.closeTaskDetail),f=A(e=>e.doEditTask),p=A(e=>e.doDispatchTask),m=A(e=>e.doSpawnWithTask),h=u.map(e=>e.provider),[g,_]=(0,z.useState)(!1),[y,b]=(0,z.useState)(null),[x,ee]=(0,z.useState)(``),[S,C]=(0,z.useState)(``),[te,ne]=(0,z.useState)(``),w=n==null?null:r[n]??null,re=n==null?null:i[n]??null,ie=n==null?[]:a[n]??[],ae=n==null?null:o[n]??null,oe=n!=null&&c===n,se=w?Kd[w.status]??`bg-zinc-500/10 text-zinc-400`:``,T=w?.deliverableStage?qd[w.deliverableStage]??`bg-zinc-500/10 text-zinc-400`:``;function E(e){e||(d(),_(!1),b(null))}function ce(){w&&(b(Jd(w)),_(!0))}function le(){_(!1),b(null)}async function ue(){if(!w||!y)return;let e={};y.dispatchComplexity&&(e.complexity=y.dispatchComplexity),y.dispatchType&&(e.type=y.dispatchType),y.dispatchFootprint&&(e.contextFootprint=y.dispatchFootprint),y.dispatchCriticality&&(e.criticality=y.dispatchCriticality);let t={...y.title===w.title?{}:{title:y.title},...y.intent===(w.intent??``)?{}:{intent:y.intent},...y.latestSteer===(w.latestSteer??``)?{}:{latestSteer:y.latestSteer},...y.doneWhen===(w.doneWhen??``)?{}:{doneWhen:y.doneWhen},...y.teamId===(w.teamId??``)?{}:{teamId:y.teamId},...Object.keys(e).length||w.dispatch?{dispatch:Object.keys(e).length?e:null}:{}};if(!Object.keys(t).length){le();return}await f(w.id,t),_(!1),b(null)}function de(){if(!w)return;let e={};x&&(e.provider=x),S&&(e.model=S),te&&(e.effort=te),p(w.id,Object.keys(e).length?e:void 0)}return(0,B.jsx)(lu,{open:t,onOpenChange:E,children:(0,B.jsxs)(pu,{className:`w-full max-w-[100dvw] sm:max-w-lg lg:max-w-xl p-0 flex flex-col`,showCloseButton:!1,children:[(0,B.jsx)(mu,{className:`shrink-0 p-4 border-b border-border`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:w&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(F,{variant:`outline`,className:`text-xs border ${se}`,children:w.status}),w.deliverableStage&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs ${T}`,children:Gd[w.deliverableStage]??w.deliverableStage}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`#`,w.id]})]})}),(0,B.jsx)(hu,{className:`text-base leading-snug`,children:w?.title??`Task`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&!g&&(0,B.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:ce,title:`Edit task`,children:(0,B.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(uu,{asChild:!0,children:(0,B.jsxs)(I,{size:`icon-sm`,variant:`ghost`,title:`Close`,children:[(0,B.jsx)(be,{className:`w-4 h-4`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}),(0,B.jsx)(Vd,{className:`flex-1 min-h-0 overflow-x-hidden`,children:(0,B.jsxs)(`div`,{className:`p-4 space-y-5 min-w-0`,children:[!w&&(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:`Loading…`}),w&&g&&y&&(0,B.jsx)(Xd,{form:y,onChange:e=>b(t=>t&&{...t,...e}),onSave:()=>void ue(),onCancel:le}),w&&!g&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Status`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Execution`}),(0,B.jsx)(F,{variant:`outline`,className:`text-xs border ${se}`,children:w.status})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Deliverable stage`}),(0,B.jsx)(F,{variant:`secondary`,className:`text-xs ${T}`,children:Gd[w.deliverableStage??`none`]??w.deliverableStage??`none`})]})]}),w.blockedBy&&w.blockedBy.length>0&&(0,B.jsx)(`div`,{className:`mt-2 space-y-1`,children:w.blockedBy.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-yellow-400`,children:[(0,B.jsx)(`span`,{className:`font-medium capitalize`,children:e.type}),e.ref&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`→ `,e.ref]}),e.note&&(0,B.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e.note})]},t))})]}),(0,B.jsx)(pl,{}),(w.intent||w.doneWhen)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{className:`space-y-2`,children:[w.intent&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Intent`}),(0,B.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-all`,children:w.intent})]}),w.doneWhen&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Done when`}),(0,B.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-all`,children:w.doneWhen})]})]}),(0,B.jsx)(pl,{})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Ownership`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[w.ownerAgentId&&(0,B.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Owner`}),(0,B.jsx)(`span`,{className:`truncate min-w-0`,title:w.ownerAgentId,children:l[w.ownerAgentId]?M(l[w.ownerAgentId]):w.ownerAgentId})]}),w.createdBy&&(0,B.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created by`}),(0,B.jsx)(`span`,{className:`truncate min-w-0`,title:w.createdBy,children:w.createdBy})]}),w.teamId&&(0,B.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Team`}),(0,B.jsx)(`span`,{className:`truncate min-w-0 font-mono text-xs`,title:w.teamId,children:w.teamId})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created`}),(0,B.jsx)(`span`,{title:Yt(w.createdAt),children:j(e,w.createdAt)})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Updated`}),(0,B.jsx)(`span`,{title:Yt(w.updatedAt),children:j(e,w.updatedAt)})]})]})]}),(w.dispatchWorkShape?.specified||w.dispatchDecision||w.boundWorkerModel)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(Zd,{detail:w})]}),(w.branch||w.commits&&w.commits.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Code`}),w.branch&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm mb-1 min-w-0`,children:[(0,B.jsx)(Re,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,B.jsx)(`span`,{className:`font-mono text-xs truncate min-w-0`,title:w.branch,children:w.branch})]}),w.commits?.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm ml-1 min-w-0`,children:[(0,B.jsx)(s,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,B.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:e.sha.slice(0,8)}),e.subject&&(0,B.jsx)(`span`,{className:`text-xs truncate min-w-0`,children:e.subject})]},e.sha))]})]}),w.issues&&w.issues.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)($d,{issues:w.issues})]}),(w.dependsOn&&w.dependsOn.length>0||w.dependents&&w.dependents.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(ef,{dependsOn:w.dependsOn??[],dependents:w.dependents??[]})]}),w.gates&&w.gates.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(tf,{gates:w.gates,now:e})]}),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(Qd,{taskId:w.id,pinProvider:x,pinModel:S,pinEffort:te,onPinProvider:ee,onPinModel:C,onPinEffort:ne,onDispatch:de,onSpawn:e=>void m(w.id,e),loading:oe,result:ae,providers:h})]}),re&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(nf,{memory:re,now:e})]}),ie.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pl,{}),(0,B.jsx)(rf,{history:ie,now:e})]})]})]})})]})})}function Xd({form:e,onChange:t,onSave:n,onCancel:r}){return(0,B.jsxs)(`section`,{className:`space-y-4`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Edit Task fields`}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-title`,children:`Title`}),(0,B.jsx)(L,{id:`edit-title`,value:e.title,onChange:e=>t({title:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-intent`,children:`Intent`}),(0,B.jsx)(Wd,{id:`edit-intent`,value:e.intent,onChange:e=>t({intent:e.target.value}),rows:3})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-steer`,children:`Latest steer`}),(0,B.jsx)(Wd,{id:`edit-steer`,value:e.latestSteer,onChange:e=>t({latestSteer:e.target.value}),rows:2,placeholder:`Redirect or re-scope in-flight work`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-done-when`,children:`Done when`}),(0,B.jsx)(Wd,{id:`edit-done-when`,value:e.doneWhen,onChange:e=>t({doneWhen:e.target.value}),rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-team`,children:`Team ID`}),(0,B.jsx)(L,{id:`edit-team`,value:e.teamId,onChange:e=>t({teamId:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-complexity`,className:`text-xs`,children:`Complexity`}),(0,B.jsxs)(`select`,{id:`edit-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchComplexity,onChange:e=>t({dispatchComplexity:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ot.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-type`,className:`text-xs`,children:`Type`}),(0,B.jsxs)(`select`,{id:`edit-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchType,onChange:e=>t({dispatchType:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ct.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-footprint`,className:`text-xs`,children:`Context footprint`}),(0,B.jsxs)(`select`,{id:`edit-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchFootprint,onChange:e=>t({dispatchFootprint:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Dt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-criticality`,className:`text-xs`,children:`Criticality`}),(0,B.jsxs)(`select`,{id:`edit-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchCriticality,onChange:e=>t({dispatchCriticality:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),At.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,B.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,B.jsx)(I,{size:`sm`,onClick:n,children:`Save`}),(0,B.jsx)(I,{size:`sm`,variant:`outline`,onClick:r,children:`Cancel`})]})]})}function Zd({detail:e}){let t=e.dispatchWorkShape,n=e.dispatchDecision,r=e.boundWorkerModel;return(0,B.jsxs)(`section`,{className:`space-y-3`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch`}),t&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Work shape`}),t.specified?(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.complexity&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.complexity}),t.type&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.type}),t.contextFootprint&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.contextFootprint}),t.criticality&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.criticality})]}):(0,B.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:`Not specified`})]}),n&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Decision`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[n.target.provider&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:n.target.provider}),n.target.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:n.target.model}),n.target.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:n.target.effort}),n.pinned&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),n.rationale&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.rationale}),n.warnings?.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400 mt-0.5`,children:[(0,B.jsx)(Me,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,B.jsx)(`span`,{children:e})]},t))]}),r&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Bound worker`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[r.provider&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:r.provider}),r.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:r.model}),r.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:r.effort})]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground font-mono truncate`,title:r.agentId,children:r.agentId})]})]})}function Qd({taskId:e,pinProvider:t,pinModel:n,pinEffort:r,onPinProvider:i,onPinModel:a,onPinEffort:o,onDispatch:s,onSpawn:c,loading:l,result:u,providers:d}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3`,children:`Spawn with task`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mb-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-provider-${e}`,className:`text-xs`,children:`Provider pin`}),(0,B.jsxs)(`select`,{id:`spawn-provider-${e}`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs`,value:t,onChange:e=>i(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`auto`}),d.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-model-${e}`,className:`text-xs`,children:`Model pin`}),(0,B.jsx)(L,{id:`spawn-model-${e}`,className:`mt-1 h-8 text-xs`,value:n,onChange:e=>a(e.target.value),placeholder:`auto`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-effort-${e}`,className:`text-xs`,children:`Effort pin`}),(0,B.jsx)(L,{id:`spawn-effort-${e}`,className:`mt-1 h-8 text-xs`,value:r,onChange:e=>o(e.target.value),placeholder:`auto`})]})]}),(0,B.jsxs)(I,{size:`sm`,onClick:s,disabled:l,className:`gap-1.5`,children:[(0,B.jsx)(Fe,{className:`w-3.5 h-3.5`}),l?`Planning…`:`Plan dispatch`]}),u&&(0,B.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/20 p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(Fe,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:u.decision.target.provider}),u.decision.target.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:u.decision.target.model}),u.decision.target.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:u.decision.target.effort}),u.decision.pinned&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.decision.rationale}),u.decision.factors.band&&(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Band: `,u.decision.factors.band,u.decision.factors.contextWindowTokens?` · ${(u.decision.factors.contextWindowTokens/1e3).toFixed(0)}k ctx`:``]}),u.decision.warnings.length>0&&(0,B.jsx)(`div`,{className:`space-y-0.5`,children:u.decision.warnings.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400`,children:[(0,B.jsx)(Me,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,B.jsx)(`span`,{children:e})]},t))}),u.decision.review&&(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Auto-review: `,u.decision.review.reason,` → `,u.decision.review.target.provider,`/`,u.decision.review.target.model??`default`,u.reviewTaskId&&(0,B.jsxs)(`span`,{className:`ml-1`,children:[`(task #`,u.reviewTaskId,`)`]})]})]})]}),(0,B.jsx)(`div`,{className:`pt-1 border-t border-border/50`,children:(0,B.jsxs)(I,{size:`sm`,className:`gap-1.5 w-full`,onClick:()=>c(u.decision.target),children:[(0,B.jsx)(Fe,{className:`w-3.5 h-3.5`}),`Spawn worker with task #`,e]})})]})]})}function $d({issues:e}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Linked Issues`}),(0,B.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:[e.provider,`/`,e.externalKey]}),e.title&&(0,B.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.title}),(0,B.jsx)(F,{variant:`secondary`,className:`text-xs shrink-0`,children:e.status}),e.url&&(0,B.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,B.jsx)(ge,{className:`w-3.5 h-3.5`})})]},e.issueRefId))})]})}function ef({dependsOn:e,dependents:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Dependencies`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[e.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Depends on: `}),e.map((t,n)=>(0,B.jsxs)(`span`,{className:`font-mono text-xs`,children:[`#`,t,n<e.length-1?`, `:``]},t))]}),t.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Blocks: `}),t.map((e,n)=>(0,B.jsxs)(`span`,{className:`font-mono text-xs`,children:[`#`,e,n<t.length-1?`, `:``]},e))]})]})]})}function tf({gates:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Gate Ledger`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:[...e].sort((e,t)=>t.ranAt-e.ranAt).map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`pass`?(0,B.jsx)(ye,{className:`w-4 h-4 text-emerald-400 shrink-0 mt-0.5`}):(0,B.jsx)(we,{className:`w-4 h-4 text-red-400 shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-mono text-xs font-medium`,children:e.gate}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto shrink-0`,title:Yt(e.ranAt),children:j(t,e.ranAt)})]}),e.detail&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.detail}),e.commitSha&&(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.commitSha.slice(0,8)})]})]},e.gate+e.ranAt))})]})}function nf({memory:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Task Memory`}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[e.workingState&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Working state`}),(0,B.jsx)(`p`,{className:`text-xs whitespace-pre-wrap bg-muted/30 rounded p-2`,children:e.workingState})]}),e.ledger.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Ruled out (`,e.ledger.length,`)`]}),(0,B.jsx)(`div`,{className:`space-y-1`,children:e.ledger.map((e,t)=>(0,B.jsxs)(`div`,{className:`text-xs bg-muted/20 rounded p-1.5`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.ruledOut}),e.why&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` — `,e.why]})]},t))})]}),e.decisions.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Decisions (`,e.decisions.length,`)`]}),(0,B.jsx)(`div`,{className:`space-y-1.5`,children:e.decisions.map((e,n)=>(0,B.jsxs)(`div`,{className:`text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.decision}),(0,B.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0`,title:Yt(e.at),children:j(t,e.at)})]}),e.rationale&&(0,B.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.rationale}),e.by&&(0,B.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`by `,e.by]})]},n))})]})]})]})}function rf({history:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`History`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:[...e].reverse().slice(0,30).map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,B.jsx)(tt,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-muted-foreground shrink-0`,children:e.type}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground shrink-0`,title:Yt(e.createdAt),children:j(t,e.createdAt)})]}),e.title&&e.title!==e.type&&(0,B.jsx)(`p`,{className:`text-foreground mt-0.5 truncate`,children:e.title})]})]},e.id))})]})}var af=!1;function of(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;af=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(af){af=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,af=!0,window.history.back())}},[e])}function sf({...e}){return of(e.open,e.onOpenChange),(0,B.jsx)(Br,{"data-slot":`dialog`,...e})}function cf({...e}){return(0,B.jsx)(Vr,{"data-slot":`dialog-portal`,...e})}function lf({className:e,blur:t=!0,...n}){return(0,B.jsx)(Hr,{"data-slot":`dialog-overlay`,className:O(`fixed inset-0 isolate z-50 bg-black/10 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,t&&`supports-backdrop-filter:backdrop-blur-xs`,e),...n})}function uf({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,B.jsxs)(cf,{children:[(0,B.jsx)(lf,{blur:r}),(0,B.jsxs)(Ur,{"data-slot":`dialog-content`,className:O(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i,children:[t,n&&(0,B.jsx)(Kr,{"data-slot":`dialog-close`,asChild:!0,children:(0,B.jsxs)(I,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,B.jsx)(be,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function df({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-header`,className:O(`flex flex-col gap-2`,e),...t})}function ff({className:e,showCloseButton:t=!1,children:n,...r}){return(0,B.jsxs)(`div`,{"data-slot":`dialog-footer`,className:O(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,B.jsx)(Kr,{asChild:!0,children:(0,B.jsx)(I,{variant:`outline`,children:`Close`})})]})}function pf({className:e,...t}){return(0,B.jsx)(Wr,{"data-slot":`dialog-title`,className:O(`font-heading text-base leading-none font-medium`,e),...t})}function mf({className:e,...t}){return(0,B.jsx)(Gr,{"data-slot":`dialog-description`,className:O(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function hf(){let e=A(e=>e.composeOpen),t=A(e=>e.compose),n=A(e=>e.replyTo),r=A(e=>e.set),i=A(e=>e.doSend),a=A(e=>e.cancelReply),o=ol();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&s(),children:(0,B.jsxs)(uf,{className:`max-w-lg`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:n?`Reply to #${n.id}`:`Compose Message`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`From`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.from,onChange:e=>c({from:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`Select agent...`}),o.map(e=>(0,B.jsx)(`option`,{value:e.id,children:M(e)},e.id))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`To`}),(0,B.jsx)(L,{value:t.to,onChange:e=>c({to:e.target.value}),placeholder:`agent-id, tag:name, cap:name, or broadcast`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Subject`}),(0,B.jsx)(L,{value:t.subject,onChange:e=>c({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Channel`}),(0,B.jsx)(L,{value:t.channel,onChange:e=>c({channel:e.target.value}),placeholder:`Optional channel...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Message`}),(0,B.jsx)(Wd,{value:t.body,onChange:e=>c({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(fl,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:s,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}function gf(){let e=A(e=>e.confirmModal),t=A(e=>e.set);function n(){t({confirmModal:{show:!1,title:``,message:``,action:null}})}return(0,B.jsx)(sf,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(df,{children:[(0,B.jsx)(pf,{children:e.title}),(0,B.jsx)(mf,{children:e.message})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function _f(){let e=A(e=>e.errorModal),t=A(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,B.jsx)(sf,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(df,{children:[(0,B.jsx)(pf,{children:e.title}),(0,B.jsx)(mf,{children:e.message})]}),(0,B.jsx)(ff,{children:(0,B.jsx)(I,{onClick:n,children:`OK`})})]})})}function vf(){let e=A(e=>e.renameModal),t=A(e=>e.set),n=A(e=>e.doRename);function r(){t({renameModal:{show:!1,agentId:``,label:``}})}return(0,B.jsx)(sf,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`Rename Agent`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)($,{children:`Label`}),(0,B.jsx)(L,{value:e.label,onChange:n=>t({renameModal:{...e,label:n.target.value}}),onKeyDown:e=>e.key===`Enter`&&n(),placeholder:`Human-friendly name...`,autoFocus:!0}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Leave empty to clear the label.`})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:n,children:`Save`})]})]})})}function yf(){let e=A(e=>e.pairInviteOpen),t=A(e=>e.pairInvite),n=A(e=>e.set),r=A(e=>e.closePairInvite),i=A(e=>e.doCreatePair),a=ol();function o(e){n({pairInvite:{...t,...e}})}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`Pair Agents`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Requester`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.requesterId,onChange:e=>o({requesterId:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:M(e)},e.id))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Target`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:t.targetId,onChange:e=>o({targetId:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`Select agent...`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:M(e)},e.id))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Objective`}),(0,B.jsx)(L,{value:t.objective,onChange:e=>o({objective:e.target.value}),placeholder:`What should they work on?`})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Create Pair`})]})]})})}function bf(){let e=A(e=>e.pairMessageOpen),t=A(e=>e.pairMessage),n=A(e=>e.set),r=A(e=>e.closePairMessage),i=A(e=>e.doSendPairMessage);function a(e){n({pairMessage:{...t,...e}})}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(uf,{className:`sm:max-w-sm`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`Pair Message`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Subject`}),(0,B.jsx)(L,{value:t.subject,onChange:e=>a({subject:e.target.value}),placeholder:`Optional subject...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Message`}),(0,B.jsx)(Wd,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}var xf=(0,z.lazy)(()=>R(()=>import(`./formatted-body-impl-rLDPgdmJ.js`).then(e=>({default:e.FormattedBody})),__vite__mapDeps([15,1,5,3,6,8,9,10]),import.meta.url));function Sf(e){return(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`span`,{className:e.className,children:e.text}),children:(0,B.jsx)(xf,{...e})})}function Cf(){let e=A(e=>e.threadOpen),t=A(e=>e.threadMessages),n=A(e=>e.agentsById),r=bt(),i=A(e=>e.set);return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,B.jsxs)(uf,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{children:[`Thread (`,t.length,` messages)`]})}),(0,B.jsx)(Vd,{className:`max-h-[60vh]`,children:(0,B.jsx)(`div`,{className:`space-y-3 pr-4`,children:t.map(e=>(0,B.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:Jt(e.from,n)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:Jt(e.to,n)}),(0,B.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:j(r,e.createdAt)})]}),e.subject&&(0,B.jsx)(`div`,{className:`text-sm font-medium`,children:e.subject}),(0,B.jsx)(Sf,{text:Qt(e),rawBody:e.body,issueRepo:n[e.from===`user`?e.to:e.from]?.issueRepo,className:`text-sm text-muted-foreground`}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[e.channel&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:e.channel}),e.claimedBy&&(0,B.jsxs)(F,{variant:`secondary`,className:`text-[10px]`,children:[`claimed by `,Jt(e.claimedBy,n)]})]})]},e.id))})})]})})}function wf(){let e=A(e=>e.taskEventsOpen),t=A(e=>e.taskEvents),n=A(e=>e.set),r=A(e=>e.switchView);function i(e){n({selectedMemoryId:e,taskEventsOpen:!1}),r(`memory`)}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,B.jsxs)(uf,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{children:[`Task Events (`,t.length,`)`]})}),(0,B.jsx)(Vd,{className:`max-h-[60vh]`,children:(0,B.jsxs)(`div`,{className:`space-y-2 pr-4`,children:[t.map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-border p-3`,children:[(0,B.jsx)(F,{className:qt[e.severity]||qt.info,children:e.severity}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:e.type})]}),e.body&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 whitespace-pre-wrap`,children:e.body}),(0,B.jsx)(Tf,{event:e,onOpen:i}),(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[Yt(e.createdAt),` · `,e.source]})]})]},e.id)),t.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:`No events recorded.`})]})})]})})}function Tf({event:e,onOpen:t}){if(e.type!==`memory.captured`)return null;let n=typeof e.metadata?.memoryId==`string`?e.metadata.memoryId:``,r=e.metadata?.memory&&typeof e.metadata.memory==`object`&&!Array.isArray(e.metadata.memory)?e.metadata.memory:{},i=typeof r.title==`string`?r.title:e.body||n,a=typeof r.scope==`string`?r.scope:``,o=typeof r.type==`string`?r.type:`memory`,s=typeof r.sensitivity==`string`?r.sensitivity:``;return(0,B.jsx)(`div`,{className:`mt-2 rounded-md border border-border bg-muted/20 p-2 text-xs`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(ie,{className:`w-3.5 h-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:o}),a&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] font-mono`,children:a}),s&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:s})]}),(0,B.jsx)(`div`,{className:`font-medium truncate`,children:i}),n&&(0,B.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground truncate`,children:n})]}),n&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7 text-xs shrink-0`,onClick:()=>t(n),children:`Open`})]})})}function Ef(){let e=A(e=>e.taskCreateOpen),t=A(e=>e.taskCreateForm),n=A(e=>e.closeTaskCreate),r=A(e=>e.setTaskCreateForm),i=A(e=>e.doCreateTask);return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(uf,{className:`max-w-lg`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`New Task`})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-title`,children:[`Title `,(0,B.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,B.jsx)(L,{id:`task-title`,value:t.title,onChange:e=>r({title:e.target.value}),placeholder:`Short description of the work`,autoFocus:!0})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`task-intent`,children:`Intent`}),(0,B.jsx)(Wd,{id:`task-intent`,value:t.intent,onChange:e=>r({intent:e.target.value}),placeholder:`What is this task trying to accomplish?`,rows:3})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`task-done-when`,children:`Done when`}),(0,B.jsx)(Wd,{id:`task-done-when`,value:t.doneWhen,onChange:e=>r({doneWhen:e.target.value}),placeholder:`Acceptance criteria`,rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-issue-refs`,children:[`Issue refs `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated, e.g. owner/repo#123)`})]}),(0,B.jsx)(L,{id:`task-issue-refs`,value:t.issueRefs,onChange:e=>r({issueRefs:e.target.value}),placeholder:`owner/repo#123, owner/repo#456`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-depends-on`,children:[`Depends on `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated task IDs)`})]}),(0,B.jsx)(L,{id:`task-depends-on`,value:t.dependsOn,onChange:e=>r({dependsOn:e.target.value}),placeholder:`42, 43`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape (optional)`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-complexity`,className:`text-xs`,children:`Complexity`}),(0,B.jsxs)(`select`,{id:`dispatch-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchComplexity,onChange:e=>r({dispatchComplexity:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ot.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-type`,className:`text-xs`,children:`Type`}),(0,B.jsxs)(`select`,{id:`dispatch-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchType,onChange:e=>r({dispatchType:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ct.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-footprint`,className:`text-xs`,children:`Context footprint`}),(0,B.jsxs)(`select`,{id:`dispatch-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchFootprint,onChange:e=>r({dispatchFootprint:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Dt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-criticality`,className:`text-xs`,children:`Criticality`}),(0,B.jsxs)(`select`,{id:`dispatch-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchCriticality,onChange:e=>r({dispatchCriticality:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),At.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{onClick:()=>void i(),disabled:!t.title.trim(),children:`Create`})]})]})})}function Df({open:e,onOpenChange:t,onSelect:n,orchestratorId:r,initialPath:i,title:a=`Select Directory`}){let o=A(e=>e.apiCall),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(``),[_,v]=(0,z.useState)(null),y=l?.path||i||``,b=(0,z.useMemo)(()=>y.split(`/`).filter(Boolean),[y]),x=(0,z.useCallback)(async e=>{if(r){c(!0),f(null),m(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;u(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){f(jt(e))}finally{c(!1)}}},[r,o]);(0,z.useEffect)(()=>{e&&r&&(u(null),f(null),m(!1),x(i||void 0))},[e,r]);async function S(){if(!(!h.trim()||!l)){v(null);try{u(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:l.path,name:h.trim()})),m(!1),g(``)}catch(e){v(jt(e))}}}function C(){y&&(n(y),t(!1))}function te(e){x(`/`+b.slice(0,e+1).join(`/`))}return(0,B.jsx)(sf,{open:e,onOpenChange:t,children:(0,B.jsxs)(uf,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ne,{className:`h-4 w-4`}),a]})}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-muted/50 px-2 py-1.5 text-xs overflow-x-auto`,children:[(0,B.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground shrink-0`,onClick:()=>l?.baseDir&&x(l.baseDir),children:`/`}),b.map((e,t)=>(0,B.jsxs)(`span`,{className:`shrink-0`,children:[(0,B.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground`,onClick:()=>te(t),children:e}),t<b.length-1&&(0,B.jsx)(`span`,{className:`text-muted-foreground/50 mx-0.5`,children:`/`})]},`${e}-${t}`))]}),(0,B.jsxs)(`div`,{className:`flex-1 min-h-0 rounded-md border border-border bg-background overflow-y-auto`,style:{maxHeight:`40dvh`},children:[s&&(0,B.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,B.jsx)(Xe,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&d&&(0,B.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:d}),!s&&l&&(0,B.jsxs)(`div`,{className:`p-1`,children:[l.parent&&(0,B.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>x(l.parent),children:[(0,B.jsx)(We,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),l.entries.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>x(e.path),children:[(0,B.jsx)(ae,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),l.entries.length===0&&!l.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),l.entries.length===0&&l.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),p?(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(L,{autoFocus:!0,value:h,onChange:e=>{g(e.target.value),v(null)},onKeyDown:e=>{e.key===`Enter`&&S(),e.key===`Escape`&&(m(!1),g(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`outline`,onClick:S,disabled:!h.trim(),children:(0,B.jsx)(ct,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{m(!1),g(``),v(null)},children:(0,B.jsx)(be,{className:`h-4 w-4`})})]}):(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(!0),disabled:!l||s,children:[(0,B.jsx)(ee,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),_&&(0,B.jsx)(`p`,{className:`text-xs text-destructive`,children:_}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(I,{onClick:C,disabled:!y,children:`Select`})]})]})})}function Of({value:e,onChange:t,orchestratorId:n,placeholder:r,disabled:i}){let[a,o]=(0,z.useState)(!1);return(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(L,{value:e,onChange:e=>t(e.target.value),placeholder:r,disabled:i,className:`flex-1 font-mono text-sm`}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>o(!0),disabled:i||!n,title:`Browse directories`,children:(0,B.jsx)(ne,{className:`h-4 w-4`})}),n&&(0,B.jsx)(Df,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function kf({model:e}){if(!e)return null;let t=Af(e);return t.length===0?null:(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,B.jsxs)(F,{variant:`outline`,className:`gap-1 text-[10px]`,children:[(0,B.jsx)(e.Icon,{className:`h-3 w-3`}),e.label]},e.label))})}function Af(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:jf(n),Icon:Qe}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:ce}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:ce}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:qe}),t}function jf(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function Mf(){let e=A(e=>e.orchestratorSpawnOpen),t=A(e=>e.orchestrators),n=A(e=>e.spawnOrchId),r=A(e=>e.spawnProvider),i=A(e=>e.spawnModel),a=A(e=>e.spawnEffort),o=A(e=>e.spawnProfile),s=A(e=>e.spawnCwd),c=A(e=>e.spawnLabel),l=A(e=>e.spawnApproval),u=A(e=>e.spawnWorkspaceMode),d=A(e=>e.spawnPrompt),f=A(e=>e.spawnSystemPromptAppend),p=A(e=>e.spawnCount),m=A(e=>e.spawnCwdHistory),h=A(e=>e.isSpawning),g=A(e=>!!e.pendingForkImport),_=A(e=>e.set),v=A(e=>e.submitOrchestratorSpawn),y=A(e=>e.selectSpawnHistory),b=A(e=>e.agentProfiles),x=A(e=>e.providerCatalog),ee=t.find(e=>e.id===n),S=ee?.providers||[],C=St(r,x),te=C.find(e=>e.alias===i),ne=te?.efforts||[],w=!!(ee&&S.length>0&&s.trim())&&!h,re=t.filter(e=>e.status===`online`),ie=re.length>1,ae=m.filter(e=>re.some(t=>t.id===e.orchId)).slice(0,5);function oe(e){let n=t.find(t=>t.id===e),r=n?.providers[0]||``;_({spawnOrchId:e,spawnProvider:r,spawnModel:r?vt(r,x):``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function se(e){_({spawnProvider:e,spawnModel:vt(e,x),spawnEffort:``})}function T(e){_({spawnModel:e,spawnEffort:``})}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,B.jsxs)(uf,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:`Spawn Agent`})}),(0,B.jsxs)(`div`,{className:`space-y-3 overflow-y-auto flex-1 min-h-0 -mx-4 px-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Orchestrator`}),(0,B.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:n,onChange:e=>oe(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:r,onChange:e=>se(e.target.value),disabled:!S.length,children:[!S.length&&(0,B.jsx)(`option`,{value:r,children:`No providers available`}),S.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Model`}),(0,B.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:i,onChange:e=>T(e.target.value),disabled:!C.length,children:C.map(e=>(0,B.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Effort`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:a,onChange:e=>_({spawnEffort:e.target.value}),disabled:!ne.length,children:[(0,B.jsx)(`option`,{value:``,children:`Default`}),ne.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,B.jsx)(kf,{model:te}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Agent Profile`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:o||`default-relay`,onChange:e=>_({spawnProfile:e.target.value}),children:[!b.length&&(0,B.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),b.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Approval Mode`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:l,onChange:e=>_({spawnApproval:e.target.value}),children:[(0,B.jsx)(`option`,{value:`open`,children:`Open`}),(0,B.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,B.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Workspace`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:u,onChange:e=>_({spawnWorkspaceMode:e.target.value}),children:[(0,B.jsx)(`option`,{value:`inherit`,children:`Default`}),(0,B.jsx)(`option`,{value:`isolated`,children:`Isolated worktree`}),(0,B.jsx)(`option`,{value:`shared`,children:`Shared cwd`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Working Directory`}),(0,B.jsx)(`div`,{className:`mt-1`,children:(0,B.jsx)(Of,{value:s,onChange:e=>_({spawnCwd:e}),orchestratorId:n,placeholder:`Select a project directory`})}),ae.length>0&&(0,B.jsxs)(`div`,{className:`mt-2`,children:[(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:`Recent`}),(0,B.jsx)(`div`,{className:`flex gap-1.5 overflow-x-auto pb-1 sm:flex-wrap sm:overflow-x-visible sm:pb-0`,children:ae.map(e=>{let t=e.cwd.replace(/\/+$/,``).split(`/`).pop()||e.cwd,r=re.find(t=>t.id===e.orchId)?.hostname,i=e.orchId===n&&e.cwd===s;return(0,B.jsx)(`button`,{type:`button`,title:ie&&r?`${r}: ${e.cwd}`:e.cwd,onClick:()=>y(e.orchId,e.cwd),className:`shrink-0 rounded-full border px-2.5 py-1 text-xs font-mono transition-colors ${i?`border-primary bg-primary/10 text-foreground`:`border-input bg-background text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:ie&&r?`${r}: ${t}`:t},`${e.orchId}:${e.cwd}`)})})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Label`}),(0,B.jsx)(L,{value:c,onChange:e=>_({spawnLabel:e.target.value}),placeholder:`Optional label...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Initial Prompt`}),(0,B.jsx)(Wd,{value:d,onChange:e=>_({spawnPrompt:e.target.value}),rows:3,placeholder:`Optional initial task...`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Codex starts this as the first App Server turn; Claude receives it as a launch prompt.`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`System Prompt Append`}),(0,B.jsx)(Wd,{value:f,onChange:e=>_({spawnSystemPromptAppend:e.target.value}),rows:5,placeholder:`Optional launch context...`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Use for fork history or launch context. It informs the session but does not start work by itself.`})]}),!g&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)($,{children:`Number of Agents`}),(0,B.jsx)(`span`,{className:`text-sm font-mono tabular-nums text-muted-foreground`,children:p})]}),(0,B.jsx)(`input`,{type:`range`,min:1,max:10,step:1,value:p,onChange:e=>_({spawnCount:Number(e.target.value)}),className:`w-full mt-2 accent-primary`,"aria-label":`Number of agents to spawn`}),p>1&&(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Spawns `,p,` identical agents`,c.trim()?`, labelled "${c.trim()} 1"…"${c.trim()} ${p}"`:``,`.`]})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,B.jsx)(I,{onClick:v,disabled:!w,children:h?`Spawning…`:S.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function Nf(){return`host-${Math.random().toString(36).slice(2,8)}`}function Pf(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Ff(){let e=A(e=>e.orchestratorInstallOpen),t=A(e=>e.set),n=A(e=>e.showError),r=A(e=>e.showNotification),i=(0,z.useMemo)(()=>new URL(k()).origin,[]),[a,o]=(0,z.useState)(Nf),[s,c]=(0,z.useState)(`$HOME/projects`),[l,u]=(0,z.useState)(kt()),[f,p]=(0,z.useState)(`4860`),[m,h]=(0,z.useState)(``),[g,_]=(0,z.useState)(``),[v,y]=(0,z.useState)(),[b,x]=(0,z.useState)(!1);async function ee(){if(!a.trim()){n(`Validation`,`Orchestrator id is required`);return}if(!s.trim()){n(`Validation`,`Base directory is required`);return}if(!l.length){n(`Validation`,`Select at least one provider`);return}x(!0);try{let e=await Ee(`POST`,`/orchestrators/bootstrap`,{id:a.trim(),relayUrl:i,baseDir:s.trim(),providers:l,apiPort:Number(f)||4860,pathPrefix:m.split(`:`).map(e=>e.trim()).filter(Boolean)});_(e.command),y(e.expiresAt)}catch(e){n(`Install Command Failed`,e.message)}finally{x(!1)}}return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,B.jsxs)(uf,{className:`max-w-2xl overflow-hidden`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{className:`flex items-center gap-2`,children:[(0,B.jsx)(d,{className:`w-4 h-4`}),`Add Orchestrator`]})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Orchestrator ID`}),(0,B.jsx)(L,{value:a,onChange:e=>o(e.target.value)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Relay URL`}),(0,B.jsx)(L,{value:i,readOnly:!0})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Base Directory`}),(0,B.jsx)(L,{value:s,onChange:e=>c(e.target.value)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`API Port`}),(0,B.jsx)(L,{value:f,onChange:e=>p(e.target.value),inputMode:`numeric`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Providers`}),(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:kt().map(e=>(0,B.jsx)(I,{type:`button`,size:`sm`,variant:l.includes(e)?`default`:`outline`,onClick:()=>u(Pf(l,e)),children:Et(e)},e))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Extra PATH Prefix`}),(0,B.jsx)(L,{value:m,onChange:e=>h(e.target.value),placeholder:`/opt/homebrew/bin:/custom/bin`})]}),g&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,B.jsx)($,{children:`Install Command`}),v&&(0,B.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Install token expires `,new Date(v*1e3).toLocaleString()]})]}),(0,B.jsx)(`pre`,{className:`max-h-40 w-full overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-input bg-muted/40 p-3 font-mono text-xs leading-relaxed`,children:g})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,B.jsx)(Wn,{value:g,label:`Copy`,showText:!0,size:`default`,variant:`outline`,className:`gap-1`,onCopied:()=>r(`Install command copied`)}),(0,B.jsxs)(I,{className:`gap-1`,onClick:ee,disabled:b,children:[(0,B.jsx)(ve,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function If(){let e=A(e=>e.policyModal),t=A(e=>e.orchestrators),n=A(e=>e.agentProfiles),r=A(e=>e.set),i=A(e=>e.submitPolicy),a=A(e=>e.providerCatalog),o=t.find(t=>t.id===e.orchestratorId),s=o?.providers||[],c=St(e.provider,a),l=c.find(t=>t.alias===e.model),u=l?.efforts||[],d=!!e.editing,f=o?.providerStatus?.find(t=>t.name===e.provider)?.features?.rig===!0;function p(t){r({policyModal:{...e,...t}})}function m(n){let r=t.find(e=>e.id===n)?.providers[0]||e.provider;p({orchestratorId:n,provider:r,model:vt(r,a),effort:``})}function h(e){p({provider:e,rig:``,model:vt(e,a),effort:``})}return(0,B.jsx)(sf,{open:e.open,onOpenChange:e=>!e&&p({open:!1}),children:(0,B.jsxs)(uf,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(df,{children:(0,B.jsx)(pf,{children:d?`Edit Policy`:`Create Managed Agent`})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Policy Name`}),(0,B.jsx)(L,{value:e.name,onChange:e=>p({name:e.target.value}),placeholder:`my-agent`,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Label`}),(0,B.jsx)(L,{value:e.label,onChange:e=>p({label:e.target.value}),placeholder:`Human-friendly name...`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Description`}),(0,B.jsx)(L,{value:e.description,onChange:e=>p({description:e.target.value}),placeholder:`What does this agent do?`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Orchestrator`}),(0,B.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.orchestratorId,onChange:e=>m(e.target.value),children:t.filter(e=>e.status===`online`).map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.hostname,` (`,e.id.slice(-8),`)`]},e.id))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.provider,onChange:e=>h(e.target.value),disabled:!s.length,children:[!s.length&&(0,B.jsx)(`option`,{value:e.provider,children:`No providers available`}),s.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]}),f&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Rig`}),(0,B.jsx)(L,{value:e.rig,onChange:e=>p({rig:e.target.value}),placeholder:`Leave empty to auto-detect from .claude-rig`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`claude-rig profile name. Auto-detects from project's .claude-rig file if empty.`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Model`}),(0,B.jsx)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.model,onChange:e=>p({model:e.target.value,effort:``}),children:c.map(e=>(0,B.jsx)(`option`,{value:e.alias,children:e.label},e.alias))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Effort`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.effort,onChange:e=>p({effort:e.target.value}),disabled:!u.length,children:[(0,B.jsx)(`option`,{value:``,children:`Default`}),u.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,B.jsx)(kf,{model:l}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Agent Profile`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.profile||`default-relay`,onChange:e=>p({profile:e.target.value}),children:[!n.length&&(0,B.jsx)(`option`,{value:`default-relay`,children:`default-relay`}),n.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Working Directory`}),(0,B.jsx)(`div`,{className:`mt-1`,children:(0,B.jsx)(Of,{value:e.cwd,onChange:e=>p({cwd:e}),orchestratorId:e.orchestratorId,placeholder:o?.baseDir||`/path/to/project`})})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Mode`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.mode,onChange:e=>p({mode:e.target.value}),children:[(0,B.jsx)(`option`,{value:`always-on`,children:`Always On`}),(0,B.jsx)(`option`,{value:`on-demand`,children:`On Demand`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Permission Mode`}),(0,B.jsxs)(`select`,{className:`w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e.permissionMode,onChange:e=>p({permissionMode:e.target.value}),children:[(0,B.jsx)(`option`,{value:`open`,children:`Open`}),(0,B.jsx)(`option`,{value:`guarded`,children:`Guarded`}),(0,B.jsx)(`option`,{value:`read-only`,children:`Read-only`})]})]})]}),e.mode===`on-demand`&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Keepalive (seconds)`}),(0,B.jsx)(L,{type:`number`,value:e.keepaliveSeconds,onChange:e=>p({keepaliveSeconds:e.target.value}),placeholder:`300`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Seconds to keep agent alive after last activity.`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Initial Prompt`}),(0,B.jsx)(Wd,{value:e.prompt,onChange:e=>p({prompt:e.target.value}),rows:3,placeholder:`Optional initial task or instructions...`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Codex starts this as the first App Server turn; Claude receives it as a launch prompt.`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Tags`}),(0,B.jsx)(L,{value:e.tags,onChange:e=>p({tags:e.target.value}),placeholder:`tag1, tag2`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Capabilities`}),(0,B.jsx)(L,{value:e.capabilities,onChange:e=>p({capabilities:e.target.value}),placeholder:`chat, review`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider Args`}),(0,B.jsx)(L,{value:e.providerArgs,onChange:e=>p({providerArgs:e.target.value}),placeholder:`--flag value`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Space-separated args passed to the provider CLI.`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Channel Binding`}),(0,B.jsx)(L,{value:e.channelId,onChange:e=>p({channelId:e.target.value}),placeholder:`Channel ID (optional)`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Backoff Schedule (seconds)`}),(0,B.jsx)(L,{value:e.backoffSchedule,onChange:e=>p({backoffSchedule:e.target.value}),placeholder:`5, 15, 60, 300`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Backoff Reset After (s)`}),(0,B.jsx)(L,{type:`number`,value:e.backoffResetAfterSeconds,onChange:e=>p({backoffResetAfterSeconds:e.target.value}),placeholder:`600`})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)($,{htmlFor:`restartOnUpdate`,children:`Restart on policy update`}),(0,B.jsx)(fl,{id:`restartOnUpdate`,checked:e.restartOnUpdate,onCheckedChange:e=>p({restartOnUpdate:e})})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)($,{htmlFor:`dailyRestart`,children:`Scheduled daily restart`}),(0,B.jsx)(fl,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>p({scheduledDailyRestart:e})})]})]}),(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>p({open:!1}),children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:d?`Save`:`Create`})]})]})})}function Lf({children:e}){return(0,B.jsxs)(Jc,{children:[(0,B.jsx)(Yc,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`More info`,className:`inline-flex shrink-0 text-muted-foreground transition-colors hover:text-foreground`,children:(0,B.jsx)(u,{className:`h-3 w-3`})})}),(0,B.jsx)(Xc,{className:`max-w-xs leading-relaxed`,children:e})]})}function Rf({children:e,tip:t,className:n}){return(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)($,{className:n,children:e}),(0,B.jsx)(Lf,{children:t})]})}var zf=[`core`,`workspace`,`memory`,`artifacts`,`blackboard`,`subscriptions`,`spawn-lifecycle`,`plans`,`teams`,`project`,`issues`],Bf=[{value:``,label:`Off`},{value:`all`,label:`All`}],Vf=[{value:``,label:`Off`},{value:`all`,label:`All safe settings`}],Hf=[{value:``,label:`Instance default`},{value:`direct`,label:`Direct`},{value:`pr`,label:`Pull request`}],Uf=[{value:`any`,label:`Any provider`},...kt().map(e=>({value:e,label:Et(e)}))],Wf={relay:`bg-blue-500/10 text-blue-400 border-blue-500/30`,repo:`bg-emerald-500/10 text-emerald-400 border-emerald-500/30`,inline:`bg-amber-500/10 text-amber-400 border-amber-500/30`,provider:`bg-fuchsia-500/10 text-fuchsia-400 border-fuchsia-500/30`,profile:`bg-slate-500/10 text-slate-400 border-slate-500/30`};function Gf(e){return e?e.policy??`all`:``}function Kf(e){if(e)return e===`all`?{policy:`all`}:{}}function qf({value:e,onChange:t,options:n,disabled:r}){return(0,B.jsx)(`select`,{className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e,onChange:e=>t(e.target.value),disabled:r,children:n.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function Jf(e,t){return`${e.source}:${e.provider??`any`}:${e.ref}:${t}`}function Yf({source:e}){return(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] ${Wf[e]}`,children:e})}function Xf({skills:e,plugins:t,mcp:n,onChangeSkills:r,onChangePlugins:i,onChangeMcp:a,projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l,readOnly:u}){let[d,f]=(0,z.useState)([]),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(null),[y,b]=(0,z.useState)(null),[x,ee]=(0,z.useState)(`repo`),[S,C]=(0,z.useState)(``),[te,ne]=(0,z.useState)(`any`);async function w(e){if(b(e),!p){g(!0),v(null);try{f((await Ee(`GET`,`/provisioning/capabilities`)).capabilities),m(!0)}catch(e){v(jt(e))}finally{g(!1)}}}function re(n){let a=S.trim();if(!a)return;let o={source:x,ref:a,enabled:!0,...te===`any`?{}:{provider:te}};n===`skill`?r([...e,o]):i([...t,o]),C(``),b(null)}function ie(n,a){let o=n===`skill`?e:t;if(o.some(e=>e.source===`relay`&&e.ref===a))return;let s=[...o,{source:`relay`,ref:a,enabled:!0}];n===`skill`?r(s):i(s),b(null)}function ae(e){let t=e.variants.find(e=>e.enabled);if(!t)return;let r=t.definition;a({...n,servers:{...n.servers??{},[e.capability.slug]:r?.server??{}}}),b(null)}function oe(t,n){r(e.map((e,r)=>r===t?{...e,...n}:e))}function se(e,n){i(t.map((t,r)=>r===e?{...t,...n}:t))}function T(e){let t={...n.servers??{}};delete t[e],a({...n,servers:t})}let E=d.filter(e=>e.capability.kind===`skill`),ce=d.filter(e=>e.capability.kind===`plugin`),le=d.filter(e=>e.capability.kind===`mcp`);return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(Zf,{projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l}),(0,B.jsx)($f,{title:`Skills from registry`,kind:`skill`,refs:e,readOnly:u,adding:y===`skill`,caps:E,loading:h,fetchError:_,empty:`No skills assigned`,manualRef:S,manualSource:x,manualProvider:te,onAddClick:()=>void w(`skill`),onCancel:()=>b(null),onManualRef:C,onManualSource:ee,onManualProvider:ne,onAddManual:()=>re(`skill`),onAddRelay:e=>ie(`skill`,e),onUpdate:oe,onRemove:t=>r(e.filter((e,n)=>n!==t))}),(0,B.jsx)($f,{title:`Plugins from registry`,kind:`plugin`,refs:t,readOnly:u,adding:y===`plugin`,caps:ce,loading:h,fetchError:_,empty:`No plugins assigned`,manualRef:S,manualSource:x,manualProvider:te,onAddClick:()=>void w(`plugin`),onCancel:()=>b(null),onManualRef:C,onManualSource:ee,onManualProvider:ne,onAddManual:()=>re(`plugin`),onAddRelay:e=>ie(`plugin`,e),onUpdate:se,onRemove:e=>i(t.filter((t,n)=>n!==e))}),(0,B.jsx)(np,{mcpKeys:Object.keys(n.servers??{}),caps:le,adding:y===`mcp`,loading:h,fetchError:_,readOnly:u,onAddClick:()=>void w(`mcp`),onAddMcp:ae,onCancel:()=>b(null),onRemove:T})]})}function Zf(e){return(0,B.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-2`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[`Project and shared injection`,(0,B.jsxs)(Lf,{children:[`Read-only mirror of the Provisioning Policies above — what this profile injects from the project's `,(0,B.jsx)(`code`,{children:`.mcp.json`}),`/`,(0,B.jsx)(`code`,{children:`.claude`}),` and how its MCP is routed.`]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,B.jsxs)(F,{variant:e.projectMcp?`default`:`outline`,className:`text-[10px]`,children:[`project MCP: `,Gf(e.projectMcp)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSkills?`default`:`outline`,className:`text-[10px]`,children:[`project skills: `,Gf(e.projectSkills)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSettings?`default`:`outline`,className:`text-[10px]`,children:[`project settings: `,Gf(e.projectSettings)||`off`]}),(0,B.jsxs)(F,{variant:e.sharedMcp?`default`:`outline`,className:`text-[10px]`,children:[`shared MCP: `,Gf(e.sharedMcp)||`off`]})]})]})}function Qf(e){return[...new Set(e.variants.map(e=>e.sourceType||`relay`))].join(`, `)}function $f(e){return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.title}),!e.readOnly&&(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 gap-1 text-xs`,onClick:e.onAddClick,children:[(0,B.jsx)(ue,{className:`h-3 w-3`}),`Add `,e.kind]})]}),e.refs.length===0&&!e.adding&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.empty}),e.refs.map((t,n)=>(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded border border-border bg-card/60 px-2 py-1`,children:[(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] ${e.kind===`skill`?`bg-blue-500/10 text-blue-400 border-blue-500/30`:`bg-violet-500/10 text-violet-400 border-violet-500/30`}`,children:e.kind}),(0,B.jsx)(Yf,{source:t.source}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.ref}),t.provider&&t.provider!==`any`&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:t.provider}),(0,B.jsx)(fl,{checked:t.enabled,onCheckedChange:t=>e.onUpdate(n,{enabled:t}),disabled:e.readOnly,size:`sm`}),!e.readOnly&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-5 w-5`,onClick:()=>e.onRemove(n),children:(0,B.jsx)(Ae,{className:`h-3 w-3`})})]},Jf(t,n))),e.adding&&(0,B.jsxs)(`div`,{className:`mt-1.5 space-y-2 rounded border border-border bg-card/60 p-2`,children:[e.loading&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Loading...`}),e.fetchError&&(0,B.jsx)(`div`,{className:`text-xs text-destructive`,children:e.fetchError}),!e.loading&&e.caps.length===0&&!e.fetchError&&(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`No `,e.kind,` capabilities in registry`]}),e.caps.length>0&&(0,B.jsx)(`div`,{className:`max-h-44 space-y-0.5 overflow-y-auto rounded border border-border/60 bg-background/40 p-1`,children:e.caps.map(t=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.onAddRelay(t.capability.slug),className:`w-full rounded px-2 py-1 text-left font-mono text-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[t.capability.slug,t.capability.title?` - ${t.capability.title}`:``,t.variants.length>0&&(0,B.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,Qf(t),`)`]})]},t.capability.id))}),(0,B.jsx)(ep,{}),(0,B.jsx)(tp,{...e}),(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function ep(){return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 pt-0.5`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`or add manually`}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function tp(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_1fr] gap-1.5`,children:[(0,B.jsx)(qf,{value:e.manualSource,onChange:t=>e.onManualSource(t),options:[{value:`repo`,label:`Repo ref`},{value:`inline`,label:`Inline ref`},{value:`provider`,label:`Provider ref`},{value:`relay`,label:`Relay ref`}]}),(0,B.jsx)(qf,{value:e.manualProvider,onChange:t=>e.onManualProvider(t),options:Uf})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:e.manualRef,onChange:t=>e.onManualRef(t.target.value),placeholder:e.kind===`skill`?`.claude/skills/name or registry slug`:`.relay/plugins/name or registry slug`,className:`font-mono text-xs`}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,onClick:e.onAddManual,children:`Add ref`})]})]})}function np(e){return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`MCP from registry`}),!e.readOnly&&(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 gap-1 text-xs`,onClick:e.onAddClick,children:[(0,B.jsx)(ue,{className:`h-3 w-3`}),`Add MCP`]})]}),e.mcpKeys.length===0&&!e.adding&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No MCP servers from registry`}),e.mcpKeys.map(t=>(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded border border-border bg-card/60 px-2 py-1`,children:[(0,B.jsx)(F,{variant:`outline`,className:`border-emerald-500/30 bg-emerald-500/10 text-[10px] text-emerald-400`,children:`mcp`}),(0,B.jsx)(Yf,{source:`profile`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t}),!e.readOnly&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-5 w-5`,onClick:()=>e.onRemove(t),children:(0,B.jsx)(Ae,{className:`h-3 w-3`})})]},t)),e.adding&&(0,B.jsxs)(`div`,{className:`mt-1.5 space-y-2 rounded border border-border bg-card/60 p-2`,children:[e.loading&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Loading...`}),e.fetchError&&(0,B.jsx)(`div`,{className:`text-xs text-destructive`,children:e.fetchError}),!e.loading&&e.caps.length===0&&!e.fetchError&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No MCP capabilities in registry`}),e.caps.length>0&&(0,B.jsx)(`div`,{className:`max-h-44 space-y-0.5 overflow-y-auto rounded border border-border/60 bg-background/40 p-1`,children:e.caps.map(t=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.onAddMcp(t),className:`w-full rounded px-2 py-1 text-left font-mono text-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[t.capability.slug,t.capability.title?` - ${t.capability.title}`:``,t.variants.length>0&&(0,B.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,Qf(t),`)`]})]},t.capability.id))}),(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function rp(e){let t=kt();return e&&e!==`any`&&t.includes(e)?e:t[0]??``}function ip({profile:e}){let[t,n]=(0,z.useState)(()=>rp(e.provider)),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null);async function l(r=t){if(e.name.trim()){o(!0),c(null);try{let t=await Ee(`GET`,`/agent-profiles/${encodeURIComponent(e.name)}/resolved?provider=${encodeURIComponent(r)}`);n(t.provider),i(t.profile.provisioning??{skills:[],plugins:[],mcpServers:{}})}catch(e){c(jt(e)),i(null)}finally{o(!1)}}}let u=e.relay.tools?.groups??[],d=u.length?u.join(`, `):`all groups`,f=Object.keys(r?.mcpServers??{});return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsx)(qf,{value:t,onChange:e=>{n(e),l(e)},options:kt().map(e=>({value:e,label:Et(e)}))})]}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void l(),disabled:a||!e.name.trim(),children:a?`Resolving...`:`Resolve`})]}),s&&(0,B.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:s}),(0,B.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-2`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Relay tool surface`}),(0,B.jsx)(`div`,{className:`mt-1 font-mono text-xs`,children:d})]}),!r&&!s&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Resolve this profile to inspect materialized provisioning.`}),r&&(0,B.jsxs)(`div`,{className:`grid gap-2`,children:[(0,B.jsx)(ap,{title:`Skills`,values:r.skills.map(e=>e.name),empty:`No resolved skills`}),(0,B.jsx)(ap,{title:`Plugins`,values:r.plugins.map(e=>e.name),empty:`No resolved plugins`}),(0,B.jsx)(ap,{title:`MCP Servers`,values:f,empty:`No resolved MCP servers`}),(r.skipped?.length??0)>0&&(0,B.jsxs)(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 p-2`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-amber-300`,children:`Skipped`}),(0,B.jsx)(`div`,{className:`mt-1 space-y-1`,children:r.skipped.map(e=>(0,B.jsxs)(`div`,{className:`text-xs`,children:[(0,B.jsxs)(`span`,{className:`font-mono`,children:[e.kind,`:`,e.ref]}),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` - `,e.detail]})]},`${e.kind}:${e.ref}:${e.reason}`))})]})]})]})}function ap({title:e,values:t,empty:n}){return(0,B.jsxs)(`div`,{className:`rounded border border-border bg-card/60 p-2`,children:[(0,B.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:e}),t.length===0?(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n}):(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map((e,t)=>(0,B.jsx)(F,{variant:`outline`,className:`font-mono text-[10px]`,children:e},`${e}:${t}`))})]})}function op({title:e,children:t,defaultOpen:n=!0}){let[r,i]=(0,z.useState)(n);return(0,B.jsxs)(`div`,{className:`border border-border rounded-md`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium hover:bg-accent`,onClick:()=>i(!r),children:[r?(0,B.jsx)(l,{className:`h-3.5 w-3.5`}):(0,B.jsx)(ut,{className:`h-3.5 w-3.5`}),e]}),r&&(0,B.jsx)(`div`,{className:`space-y-3 border-t border-border px-3 py-3`,children:t})]})}function sp({value:e,onChange:t,options:n,disabled:r}){return(0,B.jsx)(`select`,{className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:e,onChange:e=>t(e.target.value),disabled:r,children:n.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function cp({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(``);function c(){i.trim()&&(t({...e,[i.trim()]:o}),a(``),s(``))}function l(n){let r={...e};delete r[n],t(r)}return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[r.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsxs)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 text-xs`,children:[e,`=`,t]}),!n&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>l(e),children:(0,B.jsx)(Ae,{className:`h-3 w-3`})})]},e)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:i,onChange:e=>a(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,B.jsx)(L,{value:o,onChange:e=>s(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&c()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:c,children:(0,B.jsx)(ue,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var lp=[{value:`host`,label:`Host — full access, relay-aware`},{value:`minimal`,label:`Minimal — relay disabled, repo-scoped`},{value:`isolated`,label:`Isolated — strict isolation`},{value:`vanilla`,label:`Vanilla — zero host bleed (plugins/skills/hooks/MCP/CLAUDE.md off)`}],up=[{value:`any`,label:`Any provider`},...kt().map(e=>({value:e,label:Et(e)}))],dp=[{value:`host`,label:`Host — use host config`},{value:`profile`,label:`Profile — use profile config`},{value:`repo`,label:`Repo — use repo config only`},{value:`none`,label:`None — disabled`}],fp=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],pp=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],mp=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}],hp={context:`Injects relay's context preamble each turn (memory + situational awareness).`,skills:`Makes the bundled Agent Relay skills available to the agent.`,plugins:`Loads the bundled Agent Relay Claude plugin (session registration, approval hooks).`,statusLine:`Enables the relay status-line probe (quota + context-window reporting).`,mcp:`Master switch for relay's own MCP tools (relay_* — messaging, memory, spawn, etc.). One of three independent MCP sources, alongside Project MCP (the project's .mcp.json) and MCP Mode (the host's ambient MCP).`},gp={context:`Context`,skills:`Skills`,plugins:`Plugins`,statusLine:`Status Line`,mcp:`MCP Tools`};function _p({values:e,onChange:t,disabled:n,placeholder:r}){let[i,a]=(0,z.useState)(``);function o(){let n=i.trim();n&&(t([...e,n]),a(``))}function s(n,r){t(e.map((e,t)=>t===n?r:e))}function c(n){t(e.filter((e,t)=>t!==n))}return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[e.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:e,onChange:e=>s(t,e.target.value),disabled:n,className:`flex-1 text-xs`}),!n&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>c(t),children:(0,B.jsx)(Ae,{className:`h-3 w-3`})})]},`${e}-${t}`)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:i,onChange:e=>a(e.target.value),placeholder:r,className:`flex-1 text-xs`,onKeyDown:e=>e.key===`Enter`&&o()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:o,children:(0,B.jsx)(ue,{className:`h-3 w-3`})})]}),e.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`None`})]})}function vp(){let{open:e,mode:t,profile:n}=A(e=>e.profileModal),r=A(e=>e.closeProfileModal),i=A(e=>e.updateProfileModal),a=A(e=>e.saveProfile),o=t===`view`,s=t===`create`||t===`duplicate`,c=t===`view`?`Profile: ${n.name}`:t===`edit`?`Edit: ${n.name}`:t===`duplicate`?`Duplicate Profile`:`Create Profile`;function l(e){i({instructions:{...n.instructions,...e}})}function u(e){i({relay:{...n.relay,...e}})}function d(e,t){let r=n.relay.tools?.groups??[],i=t?[...new Set([...r,e])]:r.filter(t=>t!==e);u({tools:i.length?{groups:i}:void 0})}function f(e){i({projectMcp:Kf(e)})}function p(e){i({projectSkills:Kf(e)})}function m(e){i({projectSettings:Kf(e)})}function h(e){i({sharedMcp:Kf(e)})}function g(e){i({permissions:{...n.permissions,...e}})}function _(e){let t=n.providerOptions||{},r={...t.codex&&typeof t.codex==`object`&&!Array.isArray(t.codex)?t.codex:{}};if(!e.trim())delete r.toolOutputTokenLimit;else{let t=Number(e);if(!Number.isSafeInteger(t))return;r.toolOutputTokenLimit=t}i({providerOptions:{...t,codex:r}})}function v(e){if(!e.trim()){i({maxSpawnedAgents:void 0});return}let t=Number(e);!Number.isInteger(t)||t<0||i({maxSpawnedAgents:Math.min(t,100)})}function y(e){let t=e===`host`;i({base:e,relay:{context:t,skills:t,plugins:t,statusLine:t,mcp:t},mcp:{...n.mcp,mode:t?`host`:`none`},hooks:{mode:t?`host`:`none`},permissions:{...n.permissions,filesystem:t?`host`:`repo`},instructions:{...n.instructions,globalInstructions:t?`allow`:`ignore`}})}let b=n.providerOptions?.codex&&typeof n.providerOptions.codex==`object`&&!Array.isArray(n.providerOptions.codex)?n.providerOptions.codex:{},x=Number.isSafeInteger(b.toolOutputTokenLimit)?String(b.toolOutputTokenLimit):``;return(0,B.jsx)(sf,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(uf,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(df,{children:(0,B.jsxs)(pf,{className:`flex items-center gap-2`,children:[c,n.builtIn&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:`Built-in`})]})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(op,{title:`General`,defaultOpen:!0,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Name`}),(0,B.jsx)(L,{value:n.name,onChange:e=>i({name:e.target.value}),placeholder:`my-profile`,disabled:o||t===`edit`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Description`}),(0,B.jsx)(L,{value:n.description||``,onChange:e=>i({description:e.target.value}),placeholder:`What this profile configures`,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Emoji shown across the dashboard wherever an agent on this profile appears (conversation rows, agent cards, chat header). A single emoji; leave blank for a neutral marker.`,children:`Icon`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(L,{value:n.icon||``,onChange:e=>i({icon:e.target.value}),placeholder:`🤖`,maxLength:8,disabled:o,className:`w-24 text-center text-base`}),(0,B.jsx)(`span`,{className:`text-2xl leading-none`,"aria-hidden":!0,children:n.icon?.trim()||`•`})]})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Base`}),(0,B.jsx)(sp,{value:n.base,onChange:e=>y(e),options:lp,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsx)(sp,{value:n.provider||`any`,onChange:e=>i({provider:e}),options:up,disabled:o})]})]})]}),(0,B.jsxs)(op,{title:`Instructions`,defaultOpen:!1,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`System Prompt`}),(0,B.jsx)(Wd,{value:n.instructions.system||``,onChange:e=>l({system:e.target.value}),placeholder:`Custom system prompt...`,rows:3,disabled:o,className:`font-mono text-xs`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Append Instructions`}),(0,B.jsx)(_p,{values:n.instructions.append??[],onChange:e=>l({append:e}),disabled:o,placeholder:`Append instruction fragment`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Repo Instructions`}),(0,B.jsx)(sp,{value:n.instructions.repoInstructions,onChange:e=>l({repoInstructions:e}),options:pp,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Global Instructions`}),(0,B.jsx)(sp,{value:n.instructions.globalInstructions,onChange:e=>l({globalInstructions:e}),options:pp,disabled:o})]})]})]}),(0,B.jsxs)(op,{title:`Relay Integration`,defaultOpen:!1,children:[(0,B.jsxs)(`p`,{className:`rounded border border-border bg-muted/20 px-2 py-1.5 text-xs text-muted-foreground`,children:[`MCP comes from three independent sources — relay (`,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`MCP Tools`}),` below), the project (`,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`Project MCP`}),` in Provisioning Policies), and the host (`,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`MCP Mode`}),` in MCP & Hooks). Toggle each separately and mix freely.`]}),(0,B.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[`context`,`skills`,`plugins`,`statusLine`,`mcp`].map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(Rf,{tip:hp[e],children:gp[e]}),(0,B.jsx)(fl,{checked:n.relay[e]??!0,onCheckedChange:t=>u({[e]:t}),disabled:o})]},e))}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Pick which subsets of relay's MCP tools the agent gets. No groups selected = the full relay tool surface.`,children:`Relay Tool Groups`}),(0,B.jsx)(`div`,{className:`mt-1 grid grid-cols-2 gap-1.5`,children:zf.map(e=>(0,B.jsxs)(`label`,{className:`flex items-center gap-2 rounded border border-border px-2 py-1 text-xs`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`rounded`,checked:(n.relay.tools?.groups??[]).includes(e),onChange:t=>d(e,t.target.checked),disabled:o}),(0,B.jsx)(`span`,{className:`font-mono`,children:e})]},e))}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`No groups selected means full relay MCP tool surface.`})]})]}),(0,B.jsx)(op,{title:`MCP & Hooks`,defaultOpen:!1,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`The host's ambient MCP servers (your rig's configured MCP). Host = inherit them; None = no host MCP (clean, no bleed). Separate from relay's own MCP and the project's MCP.`,children:`MCP Mode`}),(0,B.jsx)(sp,{value:n.mcp.mode,onChange:e=>i({mcp:{...n.mcp,mode:e}}),options:dp,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`The host's hook configuration. Host = inherit it; None = no host hooks.`,children:`Hooks Mode`}),(0,B.jsx)(sp,{value:n.hooks.mode,onChange:e=>i({hooks:{mode:e}}),options:dp,disabled:o})]})]})}),(0,B.jsx)(op,{title:`Provisioning Policies`,defaultOpen:!1,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Injects the MCP servers declared in the spawn directory's project .mcp.json, via relay's controlled config path (survives --strict-mcp-config, no trust modal). All = every declared server. This is the project's MCP source — distinct from relay's MCP Tools and the host's MCP Mode.`,children:`Project MCP`}),(0,B.jsx)(sp,{value:Gf(n.projectMcp),onChange:f,options:Bf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Injects skills committed under the project's .claude/skills.`,children:`Project Skills`}),(0,B.jsx)(sp,{value:Gf(n.projectSkills),onChange:p,options:Bf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Injects the project's .claude/settings.json (permission/security keys stripped).`,children:`Project Settings`}),(0,B.jsx)(sp,{value:Gf(n.projectSettings),onChange:m,options:Vf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(Rf,{tip:`Routes the agent's non-identity MCP through one shared orchestrator listener so the MCP session survives restarts and keeps correct worktree-cwd routing. A transport choice, not a source selector.`,children:`Shared MCP`}),(0,B.jsx)(sp,{value:Gf(n.sharedMcp),onChange:h,options:Bf,disabled:o})]}),(0,B.jsxs)(`div`,{className:`col-span-2`,children:[(0,B.jsx)(Rf,{tip:`How the agent's isolated branch lands: Direct (rebase/FF), Pull request, or the instance default.`,children:`Landing Strategy`}),(0,B.jsx)(sp,{value:n.landingStrategy??``,onChange:e=>i({landingStrategy:e||void 0}),options:Hf,disabled:o})]})]})}),(0,B.jsx)(op,{title:`Permissions`,defaultOpen:!1,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Approval Mode`}),(0,B.jsx)(sp,{value:n.permissions.mode||``,onChange:e=>g({mode:e||void 0}),options:mp,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Filesystem Scope`}),(0,B.jsx)(sp,{value:n.permissions.filesystem,onChange:e=>g({filesystem:e}),options:fp,disabled:o})]})]})}),(0,B.jsx)(op,{title:`Spawning`,defaultOpen:!1,children:(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Spawn Quota`}),(0,B.jsx)(L,{type:`number`,min:0,max:100,step:1,value:n.maxSpawnedAgents===void 0?``:String(n.maxSpawnedAgents),onChange:e=>v(e.target.value),placeholder:`0`,disabled:o}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Max concurrent live child agents this profile may spawn. Empty or 0 = cannot spawn (default). Children never inherit it (no grandchildren).`})]})}),(0,B.jsx)(op,{title:`Environment Variables`,defaultOpen:!1,children:(0,B.jsx)(cp,{env:n.env||{},onChange:e=>i({env:e}),disabled:o})}),(0,B.jsx)(op,{title:`Registry Capabilities`,defaultOpen:!1,children:(0,B.jsx)(Xf,{skills:n.skills??[],plugins:n.plugins??[],mcp:n.mcp,onChangeSkills:e=>i({skills:e}),onChangePlugins:e=>i({plugins:e}),onChangeMcp:e=>i({mcp:e}),projectMcp:n.projectMcp,projectSkills:n.projectSkills,projectSettings:n.projectSettings,sharedMcp:n.sharedMcp,readOnly:o})}),(0,B.jsx)(op,{title:`Resolved Provisioning`,defaultOpen:t===`view`,children:(0,B.jsx)(ip,{profile:n})}),(0,B.jsxs)(op,{title:`Provider Options`,defaultOpen:!1,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Codex Tool Output Limit`}),(0,B.jsx)(L,{type:`number`,min:1e3,max:2e5,value:x,onChange:e=>_(e.target.value),placeholder:`12000`,disabled:o})]}),(0,B.jsx)(Wd,{value:JSON.stringify(n.providerOptions||{},null,2),onChange:e=>{try{i({providerOptions:JSON.parse(e.target.value)})}catch{}},rows:3,disabled:o,className:`font-mono text-xs`,placeholder:`{}`})]})]}),!o&&(0,B.jsxs)(ff,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:a,children:s?`Create`:`Save`})]})]})})}function yp(){let e=A(e=>e.commandPaletteOpen),t=A(e=>e.commandQuery),n=A(e=>e.set),r=A(e=>e.closeCommandPalette),i=A(e=>e.runCommand),a=ul(),o=(0,z.useRef)(null);return(0,z.useEffect)(()=>{e&&setTimeout(()=>o.current?.focus(),50)},[e]),e?(0,B.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,onClick:e=>{e.target===e.currentTarget&&r()},children:[(0,B.jsx)(`div`,{className:`fixed inset-0 bg-black/60`}),(0,B.jsxs)(`div`,{className:`relative w-full max-w-lg bg-card border border-border rounded-xl shadow-2xl overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`p-3 border-b border-border`,children:(0,B.jsx)(L,{ref:o,value:t,onChange:e=>n({commandQuery:e.target.value}),placeholder:`Type a command...`,className:`border-0 bg-transparent focus-visible:ring-0 text-base`})}),(0,B.jsxs)(`div`,{className:`max-h-80 overflow-y-auto p-2`,children:[a.map(e=>(0,B.jsxs)(`button`,{onClick:()=>i(e),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-accent text-left transition-colors`,children:[(0,B.jsx)(rt[e.icon]||ut,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-sm`,children:e.title}),e.subtitle&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.subtitle})]})]},e.id)),a.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No matching commands.`})]})]})]}):null}function bp(){let e=A(e=>e.set),t=A(e=>e.connected);return(0,B.jsxs)(`div`,{className:`xl:hidden shrink-0 sticky top-0 z-30 bg-card border-b border-border px-4 h-[var(--header-h)] flex items-center gap-3`,children:[(0,B.jsx)(`button`,{onClick:()=>e({mobileMenuOpen:!0}),className:`p-1 -ml-1 text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Open menu`,children:(0,B.jsx)(Je,{className:`w-5 h-5`})}),(0,B.jsx)(oe,{className:`w-4 h-4 text-primary`}),(0,B.jsx)(`span`,{className:`font-bold text-sm`,children:`Agent Relay`}),(0,B.jsx)(`span`,{className:`ml-auto w-2 h-2 rounded-full ${t?`bg-emerald-500`:`bg-red-500 animate-pulse`}`})]})}function xp(e){return e===`five_hour`?`5h burst`:e===`seven_day`?`7-day`:e===`seven_day_sonnet`?`7-day Sonnet`:e===`seven_day_opus`?`7-day Opus`:e===`primary`?`Primary`:e===`secondary`?`Secondary`:e}function Sp(e,t){if(!t)return``;let n=Math.max(0,(t-e)/1e3);if(n<60)return`${Math.floor(n)}s`;if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400){let e=Math.floor(n/3600),t=Math.round(n%3600/60);return t===60?`${e+1}h`:t>0?`${e}h ${t}m`:`${e}h`}return`${Math.floor(n/86400)}d`}var Cp=`agent-relay:quota-widget`,wp=300*1e3,Tp=8;function Ep(e){return!e.quota&&e.lastError?.type===`unavailable`}function Dp(e,t){let n=t===`5h`?[`five_hour`,`primary`]:[`seven_day`,`secondary`];return e.quota?.windows.find(e=>n.includes(e.name))}function Op(e,t){if(!t)return``;let n=Math.max(0,(t-e)/1e3);return n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.round(n/3600)}h`:`${(n/86400).toFixed(1).replace(/\.0$/,``)}d`}function kp({record:e,now:t,advisory:n}){let r=(0,B.jsx)(Eu,{provider:e.provider,className:`w-3.5 h-3.5`});if(Ep(e))return(0,B.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[r,(0,B.jsx)(`span`,{className:`italic`,children:`unavailable`})]});if(!e.quota){let n=e.lastAttemptAt?j(t,e.lastAttemptAt):``,i=e.lastError?.retryAfterMs,a=i==null?null:Math.ceil(Math.max(0,(e.lastAttemptAt+i-t)/1e3));return(0,B.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[r,n&&(0,B.jsx)(`span`,{children:n}),a!=null&&a>0&&(0,B.jsxs)(`span`,{className:`text-amber-400/70`,children:[`~`,a,`s`]})]})}let i=Dp(e,`5h`),a=Dp(e,`7d`);function o(e){if(!e)return null;let n=Math.round(e.utilization*100),r=Op(t,e.resetsAt);return(0,B.jsxs)(`span`,{className:`tabular-nums`,children:[n,`%`,r?`/${r}`:``]})}let s=(e.stale||e.lastError)&&e.lastAttemptAt?j(t,e.lastAttemptAt):``;return(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 shrink-0 text-foreground/70`,children:[r,(0,B.jsx)(Fp,{advisory:n}),o(i),o(a),s&&(0,B.jsx)(`span`,{className:`text-muted-foreground/70`,children:s})]})}function Ap(){try{let e=localStorage.getItem(Cp);return{open:!0,pinned:!1,...e?JSON.parse(e):{}}}catch{return{open:!0,pinned:!1}}}function jp(e){try{localStorage.setItem(Cp,JSON.stringify(e))}catch{}}function Mp(){let[{open:e,pinned:t},n]=(0,z.useState)(Ap),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(`loading`),d=bt(),f=A(e=>e.connected);(0,z.useEffect)(()=>{if(!f)return;let e=!1;async function t(){try{let[t,n,r]=await Promise.all([Ee(`GET`,`/provider-quotas`),Ee(`GET`,`/providers/quota-config`).catch(()=>null),Ee(`GET`,`/provider-quotas/advisory`).catch(()=>null)]);e||(i(t),o(n),c(r),u(`ok`))}catch{e||u(`error`)}}t();let n=setInterval(()=>void t(),wp);return()=>{e=!0,clearInterval(n)}},[f,A(e=>e.quotaSeq)]);let p=e||t,m=(r?.quotas??[]).filter(e=>a?.[e.provider]?.showInWidget!==!1),h=m.some(e=>e.stale&&!Ep(e)),g=m.some(e=>e.lastError&&!Ep(e));function _(){if(t)return;let r={open:!e,pinned:t};n(r),jp(r)}function v(){let r=t?{open:e,pinned:!1}:{open:!0,pinned:!0};n(r),jp(r)}return(0,B.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,B.jsxs)(`div`,{className:`w-full flex items-center gap-2 px-4 py-2 text-xs hover:bg-muted/30 transition-colors`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:_,"aria-expanded":p,className:`min-w-0 flex flex-1 items-center gap-2 text-left`,children:[(0,B.jsx)(ut,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground transition-transform ${p?`rotate-90`:``}`}),(0,B.jsx)(`span`,{className:`font-semibold text-foreground/80 shrink-0 ${p?``:`hidden sm:inline`}`,children:`Provider Quotas`}),l===`loading`&&(0,B.jsx)(Xe,{className:`w-3 h-3 text-muted-foreground animate-spin`}),l===`error`&&(0,B.jsx)(`span`,{className:`text-amber-400 text-[10px]`,children:`● unavailable`}),!p&&l===`ok`&&m.length>0&&(0,B.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-0.5 text-[10px]`,children:m.map(e=>(0,B.jsx)(kp,{record:e,now:d,advisory:s?.advisories[e.provider]},`${e.provider}:${e.accountKey}`))}),p&&h&&(0,B.jsx)(`span`,{className:`text-amber-400 text-[10px]`,children:`● stale`}),p&&g&&(0,B.jsx)(`span`,{className:`text-red-400 text-[10px]`,children:`● error`})]}),(0,B.jsx)(`button`,{type:`button`,onClick:v,"aria-pressed":t,title:t?`Unpin`:`Pin always-on`,className:`p-0.5 rounded hover:bg-muted transition-colors ${t?`text-primary`:`text-muted-foreground/50 hover:text-muted-foreground`}`,children:(0,B.jsx)(fe,{className:`w-3 h-3`})})]}),p&&(0,B.jsxs)(`div`,{className:`px-4 py-3`,children:[l===`loading`&&(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[(0,B.jsx)(Xe,{className:`w-3 h-3 animate-spin`}),`Loading quota data…`]}),l===`error`&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Quota data unavailable — check that you are authenticated and the server is reachable.`}),l===`ok`&&r!==null&&m.length===0&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No quota data yet — waiting for runner to report.`}),l===`ok`&&r!==null&&m.length>0&&(0,B.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3`,children:m.map(e=>{let t=a?.[e.provider],n={enabled:t?.sparklineEnabled??!0,rangeHours:t?.sparklineRangeHours??Tp};return(0,B.jsx)(zp,{record:e,now:d,advisory:s?.advisories[e.provider],sparklineCfg:n},`${e.provider}:${e.accountKey}`)})})]})]})}var Np={prefer:{icon:lt,badge:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,dot:`bg-emerald-400`},caution:{icon:gt,badge:`text-amber-400 bg-amber-500/10 border-amber-500/20`,dot:`bg-amber-400`},"avoid-large":{icon:gt,badge:`text-orange-400 bg-orange-500/10 border-orange-500/20`,dot:`bg-orange-400`},"hard-avoid":{icon:Me,badge:`text-red-400 bg-red-500/10 border-red-500/20`,dot:`bg-red-400`}};function Pp({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded px-1 py-0.5 shrink-0`,children:[(0,B.jsx)(Me,{className:`w-2.5 h-2.5`}),`at capacity`]});let t=e.quotaPenaltyBand;if(t===`normal`)return null;let n=Np[t],r=n.icon;return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-medium ${n.badge} border rounded px-1 py-0.5 shrink-0`,children:[(0,B.jsx)(r,{className:`w-2.5 h-2.5`}),t]})}function Fp({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-500 shrink-0`,title:`at capacity`});let t=e.quotaPenaltyBand;return t===`normal`?null:(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${Np[t].dot} shrink-0`,title:t})}function Ip(e,t){if(!e||e.confidence===`low`||e.burnRatio===null)return null;let n=e.burnRatio.toFixed(1);return!e.earlyWallMs||e.earlyWallMs<=0?`${n}× rate`:`${n}× · ~${Sp(t,t+e.earlyWallMs)} before reset`}function Lp({burnWindow:e,now:t}){if(!e)return null;if(e.confidence===`low`||e.burnRatio===null)return(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground/50`,children:[(0,B.jsx)(tt,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{className:`italic`,children:`building burn history…`})]});let n=Ip(e,t);return n?(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground/70 tabular-nums`,children:[(0,B.jsx)(gt,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{children:n})]}):null}function Rp({provider:e,windowName:t,rangeHours:n}){let[r,i]=(0,z.useState)([]);bt(),(0,z.useEffect)(()=>{let r=!1,a=Date.now()-n*36e5;return Ee(`GET`,`/provider-quotas/history?provider=${encodeURIComponent(e)}&sinceMs=${a}&limit=500`).then(e=>{r||i(e.filter(e=>!!e.quota).map(e=>{let n=e.quota.windows.find(e=>e.name===t);return n?{t:e.capturedAt,v:n.utilization}:null}).filter(Boolean))}).catch(()=>{}),()=>{r=!0}},[e,t,n]);let a=(0,z.useMemo)(()=>{if(r.length<2)return null;let e=r[0].t,t=r[r.length-1].t-e||1;return r.map(n=>{let r=1+(n.t-e)/t*118,i=1+(1-n.v)*22;return`${r.toFixed(1)},${i.toFixed(1)}`}).join(` `)},[r]);if(!a)return null;let o=r.length>0?Math.round(r[r.length-1].v*100):0;return(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`svg`,{width:120,height:24,viewBox:`0 0 120 24`,className:`shrink-0`,children:(0,B.jsx)(`polyline`,{points:a,fill:`none`,stroke:o>=90?`#ef4444`:o>=70?`#f59e0b`:`#10b981`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,opacity:.8})}),(0,B.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[n,`h`]})]})}function zp({record:e,now:t,advisory:n,sparklineCfg:r}){let{provider:i,accountKey:a,quota:o,stale:s,lastError:c,lastUpdatedAt:l,lastAttemptAt:u}=e;if(Ep(e))return(0,B.jsxs)(`div`,{className:`rounded border border-border bg-muted/20 p-3 space-y-1.5 opacity-70`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,B.jsx)(Eu,{provider:i,className:`w-3.5 h-3.5 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground bg-muted border border-border rounded px-1 py-0.5 shrink-0`,children:`unavailable`})]}),(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Quota unavailable — `,c?.message??`no readable credentials`]})]});let d=c?.retryAfterMs,f=d==null?null:Math.max(0,u+d-t),p=f==null?null:Math.ceil(f/1e3),m=(s||!!c)&&u>0;return(0,B.jsxs)(`div`,{className:`rounded border ${c?`border-red-500/30`:s?`border-amber-500/30`:`border-border`} bg-card p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,B.jsx)(Eu,{provider:i,className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono truncate`,children:a})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,B.jsx)(Pp,{advisory:n}),s&&(0,B.jsx)(`span`,{className:`text-[9px] font-medium text-amber-400 bg-amber-500/10 border border-amber-500/20 rounded px-1 py-0.5`,children:`stale`}),c&&(0,B.jsx)(`span`,{className:`text-[9px] font-medium text-red-400 bg-red-500/10 border border-red-500/20 rounded px-1 py-0.5`,title:c.message,children:c.type===`rate_limited`?`429`:`err`})]})]}),o?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:o.windows.map(n=>{let i=Math.round(n.utilization*100),a=i>=90?`bg-red-500`:i>=70?`bg-amber-500`:`bg-emerald-500`,o=n.resetsAt?Sp(t,n.resetsAt):``,s=e.burn?.windows.find(e=>e.name===n.name);return(0,B.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:xp(n.name)}),(0,B.jsxs)(`span`,{children:[i,`%`,o?` · resets in ${o}`:``]})]}),(0,B.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,B.jsx)(`div`,{className:`h-full ${a} transition-all duration-500`,style:{width:`${Math.max(0,Math.min(100,i))}%`}})}),(0,B.jsx)(Lp,{burnWindow:s,now:t}),r?.enabled&&(0,B.jsx)(Rp,{provider:e.provider,windowName:n.name,rangeHours:r.rangeHours})]},n.name)})}):(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:c?c.message:`No quota data`}),(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2 text-[10px] text-muted-foreground/60`,children:[(0,B.jsxs)(`div`,{className:`space-y-0.5 min-w-0`,children:[m&&(0,B.jsxs)(`div`,{children:[`Attempted `,j(t,u)]}),(0,B.jsx)(`div`,{children:l?`Updated ${j(t,l)}`:`Never updated`})]}),p!=null&&(0,B.jsx)(`span`,{className:`text-amber-400/70 shrink-0 mt-0.5`,children:p>0?`retry in ~${p>60?`${Math.ceil(p/60)}m`:`${p}s`}`:`retrying…`})]})]})}function Bp(e){return(0,z.lazy)(()=>tr(e))}var Vp=Bp(()=>R(()=>import(`./overview-BmU7twic.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([16,1,6,8,9,10,17,12,18]),import.meta.url)),Hp=Bp(()=>R(()=>import(`./chat-C7XCmaZz.js`).then(e=>({default:e.ChatView})),__vite__mapDeps([19,1,6,20,8,9,10,21,22,23,24,25,11,12,17,26,13]),import.meta.url)),Up=Bp(()=>R(()=>import(`./agents-DgUjmk_D.js`).then(e=>({default:e.AgentsView})),__vite__mapDeps([27,1,28,29,6,12,30,20,31,32,33,34,35,8,9,10,24,25,11,17,18]),import.meta.url)),Wp=Bp(()=>R(()=>import(`./managed-agents-C7Czinaz.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([36,1,6,8,9,10,25,11,12,17]),import.meta.url)),Gp=Bp(()=>R(()=>import(`./teams-KNzmdolE.js`).then(e=>({default:e.TeamsView})),__vite__mapDeps([37,1,38,28,29,6,12,30,20,31,32,39,40,41,33,35,42,8,9,10,23,17,11,18,26]),import.meta.url)),Kp=Bp(()=>R(()=>import(`./agent-profiles-cnWPANzx.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([43,1,6,8,9,10,17,12,11]),import.meta.url)),qp=Bp(()=>R(()=>import(`./orchestrators-BjLl1Z0L.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([44,6,1,8,9,10,17,12,11,18]),import.meta.url)),Jp=Bp(()=>R(()=>import(`./workspaces-CSNdUg15.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([45,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),Yp=Bp(()=>R(()=>import(`./channels-DOYB1iiA.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([46,6,1,8,9,10,17,12,11,18]),import.meta.url)),Xp=Bp(()=>R(()=>import(`./connectors-C5CeK-2M.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([47,6,1,8,9,10,17,12,11,18]),import.meta.url)),Zp=Bp(()=>R(()=>import(`./integrations-CztQfrI7.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([48,6,1,8,9,10,17,12,11,18]),import.meta.url)),Qp=Bp(()=>R(()=>import(`./security-C9mBNQMZ.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([49,1,6,25,11,12,17,18,26]),import.meta.url)),$p=Bp(()=>R(()=>import(`./memory-Bys-M7GK.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([50,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),em=Bp(()=>R(()=>import(`./activity-DRAeL0Jq.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([51,1,6,8,9,10,21,22,17,12,11,18]),import.meta.url)),tm=Bp(()=>R(()=>import(`./pairs-xclXjw-c.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([52,6,1,8,9,10,17,12,11,18]),import.meta.url)),nm=Bp(()=>R(()=>import(`./messages-COSJ6trN.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([53,1,6,8,9,10,17,12,11,18]),import.meta.url)),rm=Bp(()=>R(()=>import(`./work-queue-DINvPVPn.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([54,6,1,8,9,10,17,12,11,18]),import.meta.url)),im=Bp(()=>R(()=>import(`./tasks-DNjZKSM2.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([55,6,1,8,9,10,17,12,11,18]),import.meta.url)),am=Bp(()=>R(()=>import(`./automation-CuTlgY1E.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([56,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),om=Bp(()=>R(()=>import(`./analytics-Q6Dl_CE9.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([57,1,6,8,9,10,18,58]),import.meta.url)),sm=Bp(()=>R(()=>import(`./insights-C0dDL4El.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([59,1,6,17,12,11,18,26,9,10]),import.meta.url)),cm=Bp(()=>R(()=>import(`./projects-cOeuiMjl.js`).then(e=>({default:e.ProjectsView})),__vite__mapDeps([60,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),lm=Bp(()=>R(()=>import(`./prompt-settings-CtQd0nz0.js`).then(e=>({default:e.PromptSettingsView})),__vite__mapDeps([61,1,6,17,12,11,18,9,10]),import.meta.url)),um=Bp(()=>R(()=>import(`./registry-CDe6vjKI.js`).then(e=>({default:e.RegistryView})),__vite__mapDeps([62,1,6,17,12,11,18,26,10]),import.meta.url)),dm=Bp(()=>R(()=>import(`./maintenance-DkOkcEkb.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([63,1,6,8,9,10,17,12,11]),import.meta.url)),fm=Bp(()=>R(()=>import(`./settings-BmZjWJkI.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([64,1,38,28,29,6,12,30,20,31,32,39,40,41,33,35,42,8,9,10,22,17,11,18,26,58]),import.meta.url)),pm=class extends z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
|
|
22
22
|
`,t.componentStack)}render(){return this.state.error?Qn(this.state.error)?(0,B.jsxs)(`div`,{className:`p-6 text-sm`,children:[(0,B.jsx)(`h2`,{className:`text-foreground text-lg mb-2`,children:`A new version was deployed`}),(0,B.jsx)(`p`,{className:`text-muted-foreground mb-4`,children:`Reload to pick up the latest dashboard.`}),(0,B.jsx)(`button`,{className:`px-3 py-1 bg-primary text-primary-foreground rounded text-sm`,onClick:()=>window.location.reload(),children:`Reload`})]}):(0,B.jsxs)(`div`,{className:`p-6 text-sm font-mono whitespace-pre-wrap`,children:[(0,B.jsx)(`h2`,{className:`text-red-400 text-lg mb-2`,children:`Dashboard Error`}),(0,B.jsx)(`p`,{className:`text-foreground mb-4`,children:this.state.error.message}),(0,B.jsx)(`pre`,{className:`text-muted-foreground text-xs overflow-auto`,children:this.state.error.stack}),(0,B.jsx)(`button`,{className:`mt-4 px-3 py-1 bg-zinc-700 rounded text-sm`,onClick:()=>this.setState({error:null}),children:`Retry`})]}):this.props.children}},mm={overview:Vp,chat:Hp,agents:Up,managed:Wp,teams:Gp,profiles:Kp,orchestrators:qp,workspaces:Jp,files:ou,channels:Yp,connectors:Xp,integrations:Zp,security:Qp,memory:$p,activity:em,pairs:tm,messages:nm,work:rm,tasks:im,automation:am,analytics:om,insights:sm,projects:cm,prompts:lm,registry:um,maintenance:dm,settings:fm},hm=`fixed z-50 top-[calc(var(--header-h,3rem)+0.5rem)] inset-x-3 xl:inset-x-auto xl:top-auto xl:bottom-4 xl:right-4 xl:max-w-sm animate-in fade-in slide-in-from-top-2 xl:slide-in-from-bottom-2 duration-200`;function gm(){return(0,B.jsxs)(`div`,{className:`flex items-center justify-center py-16 text-muted-foreground text-sm`,children:[(0,B.jsx)(`span`,{className:`inline-block w-3 h-3 mr-2 rounded-full bg-muted-foreground/60 animate-pulse`}),`Loading…`]})}function _m(){let e=A(e=>e.notification),t=A(e=>e.toastNotification),n=A(e=>e.openNotification),r=A(e=>e.dismissToast);if(t){let e=t;return(0,B.jsxs)(`div`,{className:`${hm} flex items-start gap-2 px-4 py-3 bg-zinc-800 text-zinc-100 text-sm rounded-md shadow-lg border border-zinc-700`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{n(e),r()},className:`flex-1 min-w-0 text-left cursor-pointer`,children:[(0,B.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),(0,B.jsx)(`div`,{className:`text-xs text-zinc-300 line-clamp-2 mt-0.5`,children:e.body}),(0,B.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-zinc-400 mt-1`,children:`Tap to open`})]}),(0,B.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Dismiss`,className:`shrink-0 -mr-1 -mt-1 px-1 text-lg leading-none text-zinc-400 hover:text-zinc-100`,children:`×`})]})}return e?(0,B.jsx)(`div`,{className:`${hm} px-4 py-2 bg-zinc-800 text-zinc-100 text-sm rounded-md shadow-lg border border-zinc-700`,children:e}):null}function vm(){let e=A(e=>e.init),t=A(e=>e.destroy),n=A(e=>e.theme),r=A(e=>e.view),i=A(e=>e.authNeeded),a=A(e=>e.connectionError),o=A(e=>e.authToken),s=A(e=>e.set),c=A(e=>e.saveTokenAndRefresh),l=A(e=>e.openCommandPalette),u=A(e=>e.commandPaletteOpen),d=A(e=>e.closeCommandPalette);(0,z.useEffect)(()=>{pn(n)},[n]),(0,z.useEffect)(()=>(e(),()=>t()),[]),(0,z.useEffect)(()=>{function e(e){(e.metaKey||e.ctrlKey)&&e.key?.toLowerCase()===`k`?(e.preventDefault(),l()):e.key===`Escape`&&u&&(e.preventDefault(),d())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u]);let f=mm[r]||Vp;return(0,B.jsx)(pm,{children:(0,B.jsx)(qc,{children:(0,B.jsxs)(`div`,{className:`flex min-h-[calc(100dvh-var(--sat))] mt-[var(--sat)]`,children:[(0,B.jsx)(El,{}),(0,B.jsx)(Dl,{}),(0,B.jsxs)(`main`,{className:`flex-1 min-w-0 h-[calc(100dvh-var(--sat))] flex flex-col overflow-y-auto`,children:[(0,B.jsx)(bp,{}),!i&&a&&(0,B.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 p-3 bg-amber-950/40 border-b border-amber-800/60 text-amber-200 text-sm`,children:[(0,B.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse`}),`Relay unreachable — showing last known data. Reconnecting…`]}),i&&(0,B.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 p-3 bg-card border-b border-border`,children:[(0,B.jsx)(Te,{className:`w-4 h-4 text-muted-foreground`}),(0,B.jsx)(L,{type:`password`,placeholder:`Relay token...`,value:o,onChange:e=>s({authToken:e.target.value}),onKeyDown:e=>e.key===`Enter`&&c(),className:`max-w-xs h-8`}),(0,B.jsx)(I,{size:`sm`,onClick:c,children:`Connect`})]}),(0,B.jsx)(Mp,{}),(0,B.jsx)(`div`,{className:r===`chat`?`flex min-h-0 flex-1 flex-col`:`p-4 md:p-6`,children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(gm,{}),children:(0,B.jsx)(f,{})})})]}),(0,B.jsx)(Od,{}),(0,B.jsx)(Ud,{}),(0,B.jsx)(Yd,{}),(0,B.jsx)(hf,{}),(0,B.jsx)(gf,{}),(0,B.jsx)(_f,{}),(0,B.jsx)(vf,{}),(0,B.jsx)(yf,{}),(0,B.jsx)(bf,{}),(0,B.jsx)(Cf,{}),(0,B.jsx)(wf,{}),(0,B.jsx)(Ef,{}),(0,B.jsx)(Mf,{}),(0,B.jsx)(Ff,{}),(0,B.jsx)(If,{}),(0,B.jsx)(vp,{}),(0,B.jsx)(su,{}),(0,B.jsx)(yp,{}),(0,B.jsx)(_m,{})]})})})}if((0,Yn.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(vm,{})})),`serviceWorker`in navigator){let e=new URL(`sw.js`,window.location.href),t=new URL(`.`,e),n=new URL(`/`,window.location.origin),r=new URL(`sw.js`,n);t.href!==n.href&&navigator.serviceWorker.getRegistration(n.pathname).then(e=>{e?.scope===n.href&&e.active?.scriptURL===r.href&&e.unregister()}).catch(()=>{}),navigator.serviceWorker.register(e.toString(),{scope:t.pathname}).catch(()=>{})}export{nr as $,xu as A,pl as B,ju as C,Ru as D,zu as E,ml as F,al as G,Qc as H,gl as I,Zc as J,ol as K,_l as L,iu as M,q as N,Iu as O,Rl as P,ll as Q,yl as R,Au as S,Vu as T,nl as U,fl as V,rl as W,sl as X,$c as Y,cl as Z,cd as _,ff as a,qu as b,$ as c,Ed as d,wd as f,xd as g,Sd as h,mf as i,ru as j,ku as k,Wd as l,bd as m,sf as n,df as o,Z as p,il as q,uf as r,pf as s,Sf as t,Vd as u,$u as v,Mu as w,Y as x,Ju as y,hl as z};
|
|
23
|
-
//# sourceMappingURL=index-
|
|
23
|
+
//# sourceMappingURL=index-DGyeTLPg.js.map
|