agent-relay-server 0.105.2 → 0.107.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 +29 -1
- package/package.json +5 -3
- package/public/assets/{MessageBubble-CPYQQLDI.js → MessageBubble-PEdvVh_m.js} +2 -2
- package/public/assets/{MessageBubble-CPYQQLDI.js.map → MessageBubble-PEdvVh_m.js.map} +1 -1
- package/public/assets/{PlanGraphPanel-B7xZt5DI.js → PlanGraphPanel-DSts7Rtq.js} +2 -2
- package/public/assets/{PlanGraphPanel-B7xZt5DI.js.map → PlanGraphPanel-DSts7Rtq.js.map} +1 -1
- package/public/assets/{activity-UKQrQ8_0.js → activity-BcYf8YNO.js} +2 -2
- package/public/assets/{activity-UKQrQ8_0.js.map → activity-BcYf8YNO.js.map} +1 -1
- package/public/assets/{agent-profiles-Zr_5nNEJ.js → agent-profiles-CuTQtmV6.js} +2 -2
- package/public/assets/{agent-profiles-Zr_5nNEJ.js.map → agent-profiles-CuTQtmV6.js.map} +1 -1
- package/public/assets/{agents-FdrfmJsj.js → agents-CgRFJyks.js} +2 -2
- package/public/assets/{agents-FdrfmJsj.js.map → agents-CgRFJyks.js.map} +1 -1
- package/public/assets/{analytics-VximqXQ9.js → analytics-C3OTFIXo.js} +18 -18
- package/public/assets/{analytics-VximqXQ9.js.map → analytics-C3OTFIXo.js.map} +1 -1
- package/public/assets/{automation-DlEcJvgu.js → automation-CH9YGYoE.js} +2 -2
- package/public/assets/{automation-DlEcJvgu.js.map → automation-CH9YGYoE.js.map} +1 -1
- package/public/assets/{chat-D1bunuI-.js → chat-BLcm2Aht.js} +2 -2
- package/public/assets/{chat-D1bunuI-.js.map → chat-BLcm2Aht.js.map} +1 -1
- package/public/assets/{formatted-body-impl-4v9SkUD1.js → formatted-body-impl-BJTthVHg.js} +2 -2
- package/public/assets/{formatted-body-impl-4v9SkUD1.js.map → formatted-body-impl-BJTthVHg.js.map} +1 -1
- package/public/assets/{index-Vmhw442d.js → index-3ydeNO0c.js} +6 -6
- package/public/assets/index-3ydeNO0c.js.map +1 -0
- package/public/assets/{insights-CntgHcTp.js → insights-DklrIhb6.js} +2 -2
- package/public/assets/{insights-CntgHcTp.js.map → insights-DklrIhb6.js.map} +1 -1
- package/public/assets/{maintenance-Dw7frQtu.js → maintenance-FAAMGpuZ.js} +2 -2
- package/public/assets/{maintenance-Dw7frQtu.js.map → maintenance-FAAMGpuZ.js.map} +1 -1
- package/public/assets/{managed-agents-Bj--bFmZ.js → managed-agents-CVca-s3t.js} +2 -2
- package/public/assets/{managed-agents-Bj--bFmZ.js.map → managed-agents-CVca-s3t.js.map} +1 -1
- package/public/assets/{markdown-preview-impl-DGLCocU8.js → markdown-preview-impl-BPW4OQo9.js} +2 -2
- package/public/assets/{markdown-preview-impl-DGLCocU8.js.map → markdown-preview-impl-BPW4OQo9.js.map} +1 -1
- package/public/assets/{memory-yj2MIxUA.js → memory-BzuDTHC5.js} +2 -2
- package/public/assets/{memory-yj2MIxUA.js.map → memory-BzuDTHC5.js.map} +1 -1
- package/public/assets/{messages-BT5mL7iz.js → messages-_W24PNvT.js} +2 -2
- package/public/assets/{messages-BT5mL7iz.js.map → messages-_W24PNvT.js.map} +1 -1
- package/public/assets/{orchestrators-BVDAhrPk.js → orchestrators-Du6I_n8i.js} +2 -2
- package/public/assets/{orchestrators-BVDAhrPk.js.map → orchestrators-Du6I_n8i.js.map} +1 -1
- package/public/assets/{overview-DlqJIqYK.js → overview-Dyvm1qpT.js} +2 -2
- package/public/assets/{overview-DlqJIqYK.js.map → overview-Dyvm1qpT.js.map} +1 -1
- package/public/assets/{pairs-DQ4tNCo3.js → pairs-B8x1RCNd.js} +2 -2
- package/public/assets/{pairs-DQ4tNCo3.js.map → pairs-B8x1RCNd.js.map} +1 -1
- package/public/assets/{prompt-settings-DlsqOP0C.js → prompt-settings-xVXmvxB5.js} +2 -2
- package/public/assets/{prompt-settings-DlsqOP0C.js.map → prompt-settings-xVXmvxB5.js.map} +1 -1
- package/public/assets/{registry-Cw2fdWrn.js → registry-ypiICauZ.js} +2 -2
- package/public/assets/{registry-Cw2fdWrn.js.map → registry-ypiICauZ.js.map} +1 -1
- package/public/assets/{security-ucr7IT1V.js → security-BfOQ6T5r.js} +2 -2
- package/public/assets/{security-ucr7IT1V.js.map → security-BfOQ6T5r.js.map} +1 -1
- package/public/assets/{select-D8UWCtYZ.js → select-Dx8Ro-A3.js} +2 -2
- package/public/assets/{select-D8UWCtYZ.js.map → select-Dx8Ro-A3.js.map} +1 -1
- package/public/assets/settings-87clTx4N.js +6 -0
- package/public/assets/settings-87clTx4N.js.map +1 -0
- package/public/assets/{tasks-jRUvxUd5.js → tasks-1Kvp53wh.js} +2 -2
- package/public/assets/{tasks-jRUvxUd5.js.map → tasks-1Kvp53wh.js.map} +1 -1
- package/public/assets/{teams-Dn0yggD-.js → teams-DJWp4AKi.js} +2 -2
- package/public/assets/{teams-Dn0yggD-.js.map → teams-DJWp4AKi.js.map} +1 -1
- package/public/assets/{terminal-viewer-impl-fLly20IP.js → terminal-viewer-impl-DgMuRAe_.js} +2 -2
- package/public/assets/{terminal-viewer-impl-fLly20IP.js.map → terminal-viewer-impl-DgMuRAe_.js.map} +1 -1
- package/public/assets/types-DorDDvEb.js.map +1 -1
- package/public/assets/{user-avatar-BWLUHt2e.js → user-avatar-CfAUS3PZ.js} +2 -2
- package/public/assets/{user-avatar-BWLUHt2e.js.map → user-avatar-CfAUS3PZ.js.map} +1 -1
- package/public/assets/{work-queue-BAnNY0xE.js → work-queue-D-Otxd9u.js} +2 -2
- package/public/assets/{work-queue-BAnNY0xE.js.map → work-queue-D-Otxd9u.js.map} +1 -1
- package/public/index.html +1 -1
- package/runner/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/runner/plugins/claude/monitors/relay-monitor.provisioned.mjs +15 -3
- package/runner/src/adapter.ts +14 -3
- package/src/branch-landed.ts +76 -1
- package/src/connectors.ts +116 -4
- package/src/db/provider-quotas.ts +6 -0
- package/src/mcp-egress-tools.ts +3 -2
- package/src/notification-router.ts +6 -1
- package/src/notification-types.ts +2 -0
- package/src/notify.ts +4 -4
- package/src/quota-band-transition.ts +6 -0
- package/src/routes/commands.ts +17 -1
- package/src/routes/index.ts +2 -1
- package/src/routes/provider-quotas.ts +13 -1
- package/src/security.ts +2 -0
- package/src/services/transient-agent-reaper.ts +16 -1
- package/src/token-db.ts +3 -3
- package/public/assets/index-Vmhw442d.js.map +0 -1
- package/public/assets/settings-Dvf_ps1B.js +0 -6
- package/public/assets/settings-Dvf_ps1B.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-BPW4OQo9.js","./lib-l-JkMVR9.js","./lucide-react-C4eXYCwx.js","./terminal-viewer-impl-DgMuRAe_.js","./store-DUfrGvOE.js","./display-BWi8DQCp.js","./types-DorDDvEb.js","./button-KASZcscA.js","./dist-BbUJ1Vht.js","./use-keyboard-viewport-RYMALvu1.js","./terminal-viewer-impl-BrP-ENHg.css","./formatted-body-impl-BJTthVHg.js","./overview-Dyvm1qpT.js","./badge-D8fABzMs.js","./card-Cds0MWME.js","./chat-BLcm2Aht.js","./react-dom-BMF4hNzG.js","./MessageBubble-PEdvVh_m.js","./user-avatar-CfAUS3PZ.js","./PlanGraphPanel-DSts7Rtq.js","./branch-state-badge-CcLZ_u86.js","./copy-button-d9DFNX9v.js","./input-CtHfLn1i.js","./agents-CgRFJyks.js","./dist-DOAjFOS4.js","./dist-UhEAFdvZ.js","./dist-DybScJmm.js","./dist-DreO5AcZ.js","./dist-BlZvUZZB.js","./es2015-DUjFyjDp.js","./dist-CgqfdHSt.js","./dist-BwwlmyBq.js","./managed-agents-CVca-s3t.js","./teams-DJWp4AKi.js","./select-Dx8Ro-A3.js","./dist-BiLuYU6G.js","./dist-DTXKbk2K.js","./dist-CBVZk9U8.js","./dist-DC-TqTz2.js","./agent-profiles-CuTQtmV6.js","./orchestrators-Du6I_n8i.js","./workspaces-CIsQqQby.js","./channels-CcSnLzCG.js","./connectors-DbPOlQhL.js","./integrations-hkSW8CzM.js","./security-BfOQ6T5r.js","./memory-BzuDTHC5.js","./activity-BcYf8YNO.js","./pairs-B8x1RCNd.js","./messages-_W24PNvT.js","./work-queue-D-Otxd9u.js","./tasks-1Kvp53wh.js","./automation-CH9YGYoE.js","./analytics-C3OTFIXo.js","./themes-DjSwmAZN.js","./insights-DklrIhb6.js","./projects-vt63bwHN.js","./prompt-settings-xVXmvxB5.js","./registry-ypiICauZ.js","./maintenance-FAAMGpuZ.js","./settings-87clTx4N.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e,t}from"./chunk-CilyBKbf.js";import{An as n,At as r,B as i,Bt as a,C as o,Cn as s,E as c,Ft as l,G as u,H as d,I as f,In as p,It as m,J as h,Jn as g,Jt as _,K as v,Kt as y,L as b,Ln as x,M as S,Nn as C,Nt as ee,O as te,On as ne,P as re,Pn as w,Pt as ie,Q as ae,Qn as oe,Qt as se,R as T,Rt as E,Sn as ce,St as le,T as ue,Tn as de,Tt as fe,U as D,V as pe,Vt as me,Wn as he,Xt as ge,Y as _e,Yn as O,Yt as ve,Zn as ye,_n as be,_t as xe,a as k,an as Se,at as Ce,b as we,cn as Te,dt as Ee,et as De,f as Oe,fn as ke,ft as Ae,g as je,h as Me,ht as Ne,i as Pe,in as Fe,jn as Ie,k as Le,kn as Re,l as ze,m as Be,mt as Ve,n as He,o as Ue,on as We,ot as Ge,pn as Ke,pt as qe,r as Je,rr as Ye,rt as Xe,t as Ze,tn as Qe,tt as $e,u as et,un as tt,ur as nt,ut as rt,v as it,vt as at,w as ot,wt as st,xn as ct,yn as lt,yt as ut,z as dt,zn as ft}from"./lucide-react-C4eXYCwx.js";import{t as pt}from"./react-dom-BMF4hNzG.js";import{c as mt,d as ht,f as gt,p as _t,s as vt,t as A}from"./store-DUfrGvOE.js";import{a as yt,c as bt,o as xt,s as St,u as Ct}from"./types-DorDDvEb.js";import{B as wt,C as Tt,D as Et,E as Dt,G as Ot,J as kt,K as j,O as At,Q as jt,S as Mt,T as Nt,W as Pt,X as Ft,Y as It,a as Lt,c as Rt,ct as zt,d as M,f as Bt,h as Vt,i as Ht,j as Ut,k as Wt,lt as Gt,m as Kt,n as qt,o as Jt,ot as Yt,p as Xt,q as Zt,r as Qt,t as $t,u as en,w as tn,x as nn,y as rn}from"./display-BWi8DQCp.js";import{n as an,t as on}from"./themes-DjSwmAZN.js";import{a as sn,i as cn,o as ln,r as un,t as dn}from"./dist-BbUJ1Vht.js";import{n as fn,t as N}from"./dist-DybScJmm.js";import{i as pn,n as P,r as mn,t as hn}from"./dist-UhEAFdvZ.js";import{t as gn}from"./dist-DTXKbk2K.js";import{t as _n}from"./dist-BwwlmyBq.js";import{t as vn}from"./dist-CgqfdHSt.js";import{a as yn,i as bn,n as xn,o as Sn,r as Cn,s as wn,t as Tn}from"./es2015-DUjFyjDp.js";import{t as En}from"./dist-CBVZk9U8.js";import{t as Dn}from"./dist-DreO5AcZ.js";import{t as On}from"./dist-DC-TqTz2.js";import{t as kn}from"./dist-BlZvUZZB.js";import{a as An,i as jn,n as Mn,r as Nn,t as Pn}from"./dist-DOAjFOS4.js";import{t as Fn}from"./dist-BiLuYU6G.js";import{t as F}from"./badge-D8fABzMs.js";import{t as I}from"./button-KASZcscA.js";import{t as L}from"./input-CtHfLn1i.js";import{t as In}from"./copy-button-d9DFNX9v.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 Ln=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,S||(S=!0,w());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}var S=!1,C=-1,ee=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-te<ee)}function re(){if(g=!1,S){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-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?w():S=!1}}}var w;if(typeof y==`function`)w=function(){y(re)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=re,w=function(){ae.postMessage(null)}}else w=function(){_(re,0)};function oe(t,n){C=_(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`):ee=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(C),C=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,w()))),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}}}})),Rn=t(((e,t)=>{t.exports=Ln()})),zn=t((e=>{var t=Rn(),n=nt(),r=pt();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`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),te=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),re=Symbol.for(`react.memo_cache_sentinel`),w=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=w&&e[w]||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 S:return`Suspense`;case C: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 ee: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 _e(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)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}fe(pe),D(pe,e)}function O(){fe(pe),fe(me),fe(he)}function ve(e){e.memoizedState!==null&&D(ge,e);var t=pe.current,n=Hd(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},Ar=`DialogDescriptionWarning`,jr=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Or(Ar).contentName}}.`;return z.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Mr=rr,Nr=lr,Pr=dr,Fr=hr,Ir=br,Lr=Sr,Rr=wr,zr=`rovingFocusGroup.onEntryFocus`,Br={bubbles:!1,cancelable:!0},Vr=`RovingFocusGroup`,[Hr,Ur,Wr]=gn(Vr),[Gr,Kr]=pn(Vr,[Wr]),[qr,Jr]=Gr(Vr),Yr=z.forwardRef((e,t)=>(0,B.jsx)(Hr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(Hr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(Xr,{...e,ref:t})})}));Yr.displayName=Vr;var Xr=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=ln(t,f),m=En(a),[h,g]=_n({prop:o,defaultProp:s??null,onChange:c,caller:Vr}),[_,v]=z.useState(!1),y=Dn(l),b=Ur(n),x=z.useRef(!1),[S,C]=z.useState(0);return z.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(zr,y),()=>e.removeEventListener(zr,y)},[y]),(0,B.jsx)(qr,{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(()=>C(e=>e+1),[]),onFocusableItemRemove:z.useCallback(()=>C(e=>e-1),[]),children:(0,B.jsx)(N.div,{tabIndex:_||S===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(zr,Br);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);ni([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))})})}),Zr=`RovingFocusGroupItem`,Qr=z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=wn(),l=a||c,u=Jr(Zr,n),d=u.currentTabStopId===l,f=Ur(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return z.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,B.jsx)(Hr.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=ti(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?ri(n,r+1):n.slice(r+1)}setTimeout(()=>ni(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Qr.displayName=Zr;var $r={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function ei(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function ti(e,t,n){let r=ei(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return $r[r]}function ni(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ri(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ii=Yr,ai=Qr,oi=[`Enter`,` `],si=[`ArrowDown`,`PageUp`,`Home`],ci=[`ArrowUp`,`PageDown`,`End`],li=[...si,...ci],ui={ltr:[...oi,`ArrowRight`],rtl:[...oi,`ArrowLeft`]},di={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},fi=`Menu`,[pi,mi,hi]=gn(fi),[gi,_i]=pn(fi,[hi,An,Kr]),vi=An(),yi=Kr(),[bi,xi]=gi(fi),[Si,Ci]=gi(fi),wi=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=vi(t),[c,l]=z.useState(null),u=z.useRef(!1),d=Dn(a),f=En(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)(jn,{...s,children:(0,B.jsx)(bi,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,B.jsx)(Si,{scope:t,onClose:z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};wi.displayName=fi;var Ti=`MenuAnchor`,Ei=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=vi(n);return(0,B.jsx)(Pn,{...i,...r,ref:t})});Ei.displayName=Ti;var Di=`MenuPortal`,[Oi,ki]=gi(Di,{forceMount:void 0}),Ai=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=xi(Di,t);return(0,B.jsx)(Oi,{scope:t,forceMount:n,children:(0,B.jsx)(vn,{present:n||a.open,children:(0,B.jsx)(bn,{asChild:!0,container:i,children:r})})})};Ai.displayName=Di;var ji=`MenuContent`,[Mi,V]=gi(ji),Ni=z.forwardRef((e,t)=>{let n=ki(ji,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=xi(ji,e.__scopeMenu),o=Ci(ji,e.__scopeMenu);return(0,B.jsx)(pi.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(vn,{present:r||a.open,children:(0,B.jsx)(pi.Slot,{scope:e.__scopeMenu,children:o.modal?(0,B.jsx)(Pi,{...i,ref:t}):(0,B.jsx)(Fi,{...i,ref:t})})})})}),Pi=z.forwardRef((e,t)=>{let n=xi(ji,e.__scopeMenu),r=z.useRef(null),i=ln(t,r);return z.useEffect(()=>{let e=r.current;if(e)return Tn(e)},[]),(0,B.jsx)(Li,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Fi=z.forwardRef((e,t)=>{let n=xi(ji,e.__scopeMenu);return(0,B.jsx)(Li,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ii=un(`MenuContent.ScrollLock`),Li=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=xi(ji,n),_=Ci(ji,n),v=vi(n),y=yi(n),b=mi(n),[x,S]=z.useState(null),C=z.useRef(null),ee=ln(t,C,g.onContentChange),te=z.useRef(0),ne=z.useRef(``),re=z.useRef(0),w=z.useRef(null),ie=z.useRef(`right`),ae=z.useRef(0),oe=m?xn:z.Fragment,se=m?{as:Ii,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=xa(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),[]),Cn();let E=z.useCallback(e=>ie.current===w.current?.side&&Ca(e,w.current?.area),[]);return(0,B.jsx)(Mi,{scope:n,searchRef:ne,onItemEnter:z.useCallback(e=>{E(e)&&e.preventDefault()},[E]),onItemLeave:z.useCallback(e=>{E(e)||(C.current?.focus(),S(null))},[E]),onTriggerLeave:z.useCallback(e=>{E(e)&&e.preventDefault()},[E]),pointerGraceTimerRef:re,onPointerGraceIntentChange:z.useCallback(e=>{w.current=e},[]),children:(0,B.jsx)(oe,{...se,children:(0,B.jsx)(yn,{asChild:!0,trapped:i,onMountAutoFocus:P(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,B.jsx)(Sn,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,B.jsx)(ii,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:P(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,B.jsx)(Nn,{role:`menu`,"aria-orientation":`vertical`,"data-state":ga(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:ee,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=C.current;if(e.target!==i||!li.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);ci.includes(e.key)&&a.reverse(),ya(a)}),onBlur:P(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(te.current),ne.current=``)}),onPointerMove:P(e.onPointerMove,wa(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)}))})})})})})})});Ni.displayName=ji;var Ri=`MenuGroup`,zi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`group`,...r,ref:t})});zi.displayName=Ri;var Bi=`MenuLabel`,Vi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{...r,ref:t})});Vi.displayName=Bi;var Hi=`MenuItem`,Ui=`menu.itemSelect`,Wi=z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=z.useRef(null),o=Ci(Hi,e.__scopeMenu),s=V(Hi,e.__scopeMenu),c=ln(t,a),l=z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Ui,{bubbles:!0,cancelable:!0});e.addEventListener(Ui,e=>r?.(e),{once:!0}),fn(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,B.jsx)(Gi,{...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===` `||oi.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Wi.displayName=Hi;var Gi=z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=V(Hi,n),s=yi(n),c=z.useRef(null),l=ln(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)(pi.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,B.jsx)(ai,{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,wa(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:P(e.onPointerLeave,wa(e=>o.onItemLeave(e))),onFocus:P(e.onFocus,()=>d(!0)),onBlur:P(e.onBlur,()=>d(!1))})})})}),Ki=`MenuCheckboxItem`,qi=z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,B.jsx)(ta,{scope:e.__scopeMenu,checked:n,children:(0,B.jsx)(Wi,{role:`menuitemcheckbox`,"aria-checked":_a(n)?`mixed`:n,...i,ref:t,"data-state":va(n),onSelect:P(i.onSelect,()=>r?.(_a(n)?!0:!n),{checkForDefaultPrevented:!1})})})});qi.displayName=Ki;var Ji=`MenuRadioGroup`,[Yi,Xi]=gi(Ji,{value:void 0,onValueChange:()=>{}}),Zi=z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Dn(r);return(0,B.jsx)(Yi,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,B.jsx)(zi,{...i,ref:t})})});Zi.displayName=Ji;var Qi=`MenuRadioItem`,$i=z.forwardRef((e,t)=>{let{value:n,...r}=e,i=Xi(Qi,e.__scopeMenu),a=n===i.value;return(0,B.jsx)(ta,{scope:e.__scopeMenu,checked:a,children:(0,B.jsx)(Wi,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":va(a),onSelect:P(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});$i.displayName=Qi;var ea=`MenuItemIndicator`,[ta,na]=gi(ea,{checked:!1}),ra=z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=na(ea,n);return(0,B.jsx)(vn,{present:r||_a(a.checked)||a.checked===!0,children:(0,B.jsx)(N.span,{...i,ref:t,"data-state":va(a.checked)})})});ra.displayName=ea;var ia=`MenuSeparator`,aa=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});aa.displayName=ia;var oa=`MenuArrow`,sa=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=vi(n);return(0,B.jsx)(Mn,{...i,...r,ref:t})});sa.displayName=oa;var ca=`MenuSub`,[la,ua]=gi(ca),da=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=xi(ca,t),o=vi(t),[s,c]=z.useState(null),[l,u]=z.useState(null),d=Dn(i);return z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,B.jsx)(jn,{...o,children:(0,B.jsx)(bi,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,B.jsx)(la,{scope:t,contentId:wn(),triggerId:wn(),trigger:s,onTriggerChange:c,children:n})})})};da.displayName=ca;var fa=`MenuSubTrigger`,pa=z.forwardRef((e,t)=>{let n=xi(fa,e.__scopeMenu),r=Ci(fa,e.__scopeMenu),i=ua(fa,e.__scopeMenu),a=V(fa,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)(Ei,{asChild:!0,...l,children:(0,B.jsx)(Gi,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":ga(n.open),...e,ref:sn(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:P(e.onPointerMove,wa(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,wa(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===` `||ui[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});pa.displayName=fa;var ma=`MenuSubContent`,ha=z.forwardRef((e,t)=>{let n=ki(ji,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=xi(ji,e.__scopeMenu),o=Ci(ji,e.__scopeMenu),s=ua(ma,e.__scopeMenu),c=z.useRef(null),l=ln(t,c);return(0,B.jsx)(pi.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(vn,{present:r||a.open,children:(0,B.jsx)(pi.Slot,{scope:e.__scopeMenu,children:(0,B.jsx)(Li,{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=di[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});ha.displayName=ma;function ga(e){return e?`open`:`closed`}function _a(e){return e===`indeterminate`}function va(e){return _a(e)?`indeterminate`:e?`checked`:`unchecked`}function ya(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ba(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function xa(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=ba(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 Sa(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 Ca(e,t){return t?Sa({x:e.clientX,y:e.clientY},t):!1}function wa(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Ta=wi,Ea=Ei,Da=Ai,Oa=Ni,ka=zi,Aa=Vi,ja=Wi,Ma=qi,Na=Zi,Pa=$i,Fa=ra,Ia=aa,La=sa,Ra=pa,za=ha,Ba=`DropdownMenu`,[Va,Ha]=pn(Ba,[_i]),Ua=_i(),[Wa,Ga]=Va(Ba),Ka=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Ua(t),l=z.useRef(null),[u,d]=_n({prop:i,defaultProp:a??!1,onChange:o,caller:Ba});return(0,B.jsx)(Wa,{scope:t,triggerId:wn(),triggerRef:l,contentId:wn(),open:u,onOpenChange:d,onOpenToggle:z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,B.jsx)(Ta,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Ka.displayName=Ba;var qa=`DropdownMenuTrigger`,Ja=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Ga(qa,n),o=Ua(n);return(0,B.jsx)(Ea,{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:sn(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())})})})});Ja.displayName=qa;var Ya=`DropdownMenuPortal`,Xa=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Ua(t);return(0,B.jsx)(Da,{...r,...n})};Xa.displayName=Ya;var Za=`DropdownMenuContent`,Qa=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ga(Za,n),a=Ua(n),o=z.useRef(!1);return(0,B.jsx)(Oa,{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)`}})});Qa.displayName=Za;var $a=`DropdownMenuGroup`,eo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(ka,{...i,...r,ref:t})});eo.displayName=$a;var to=`DropdownMenuLabel`,no=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Aa,{...i,...r,ref:t})});no.displayName=to;var ro=`DropdownMenuItem`,io=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(ja,{...i,...r,ref:t})});io.displayName=ro;var ao=`DropdownMenuCheckboxItem`,oo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Ma,{...i,...r,ref:t})});oo.displayName=ao;var so=`DropdownMenuRadioGroup`,co=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Na,{...i,...r,ref:t})});co.displayName=so;var lo=`DropdownMenuRadioItem`,uo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Pa,{...i,...r,ref:t})});uo.displayName=lo;var H=`DropdownMenuItemIndicator`,fo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Fa,{...i,...r,ref:t})});fo.displayName=H;var po=`DropdownMenuSeparator`,mo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Ia,{...i,...r,ref:t})});mo.displayName=po;var ho=`DropdownMenuArrow`,go=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(La,{...i,...r,ref:t})});go.displayName=ho;var _o=`DropdownMenuSubTrigger`,vo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Ra,{...i,...r,ref:t})});vo.displayName=_o;var yo=`DropdownMenuSubContent`,bo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(za,{...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)`}})});bo.displayName=yo;var xo=Ka,So=Ja,Co=Xa,wo=Qa,To=no,Eo=io,Do=mo,Oo=`Label`,ko=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())}}));ko.displayName=Oo;var Ao=ko;function jo(e,t){return z.useReducer((e,n)=>t[e][n]??e,e)}var Mo=`ScrollArea`,[No,Po]=pn(Mo),[Fo,Io]=No(Mo),Lo=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,S]=z.useState(!1),[C,ee]=z.useState(!1),te=ln(t,e=>c(e)),ne=En(i);return(0,B.jsx)(Fo,{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:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:C,onScrollbarYEnabledChange:ee,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}})})});Lo.displayName=Mo;var Ro=`ScrollAreaViewport`,zo=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=Io(Ro,n),s=ln(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})})]})});zo.displayName=Ro;var Bo=`ScrollAreaScrollbar`,Vo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Io(Bo,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)(Ho,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,B.jsx)(Uo,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,B.jsx)(Wo,{...r,ref:t,forceMount:n}):i.type===`always`?(0,B.jsx)(Go,{...r,ref:t}):null});Vo.displayName=Bo;var Ho=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Io(Bo,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)(vn,{present:n||a,children:(0,B.jsx)(Wo,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Uo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Io(Bo,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=ds(()=>c(`SCROLL_END`),100),[s,c]=jo(`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)(vn,{present:n||s!==`hidden`,children:(0,B.jsx)(Go,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:P(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:P(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),Wo=z.forwardRef((e,t)=>{let n=Io(Bo,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=z.useState(!1),s=e.orientation===`horizontal`,c=ds(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return fs(n.viewport,c),fs(n.content,c),(0,B.jsx)(vn,{present:r||a,children:(0,B.jsx)(Go,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),Go=z.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=Io(Bo,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=is(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 os(e,o.current,s,t)}return n===`horizontal`?(0,B.jsx)(Ko,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=ss(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)(qo,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=ss(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}),Ko=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Io(Bo,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=ln(t,c,a.onScrollbarXChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(Xo,{"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":as(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),ls(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:rs(o.paddingLeft),paddingEnd:rs(o.paddingRight)}})}})}),qo=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Io(Bo,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=ln(t,c,a.onScrollbarYChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(Xo,{"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":as(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),ls(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:rs(o.paddingTop),paddingEnd:rs(o.paddingBottom)}})}})}),[Jo,Yo]=No(Bo),Xo=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=Io(Bo,n),[m,h]=z.useState(null),g=ln(t,e=>h(e)),_=z.useRef(null),v=z.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Dn(u),S=Dn(c),C=ds(d,10);function ee(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(S,[r,S]),fs(m,C),fs(p.content,C),(0,B.jsx)(Jo,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Dn(a),onThumbPointerUp:Dn(o),onThumbPositionChange:S,onThumbPointerDown:Dn(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`),ee(e))}),onPointerMove:P(e.onPointerMove,ee),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})})})}),Zo=`ScrollAreaThumb`,Qo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Yo(Zo,e.__scopeScrollArea);return(0,B.jsx)(vn,{present:n||i.hasThumb,children:(0,B.jsx)($o,{ref:t,...r})})}),$o=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=Io(Zo,n),o=Yo(Zo,n),{onThumbPositionChange:s}=o,c=ln(t,e=>o.onThumbChange(e)),l=z.useRef(void 0),u=ds(()=>{l.current&&=(l.current(),void 0)},100);return z.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=us(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)})});Qo.displayName=Zo;var es=`ScrollAreaCorner`,ts=z.forwardRef((e,t)=>{let n=Io(es,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,B.jsx)(ns,{...e,ref:t}):null});ts.displayName=es;var ns=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=Io(es,n),[a,o]=z.useState(0),[s,c]=z.useState(0),l=!!(a&&s);return fs(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),fs(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 rs(e){return e?parseInt(e,10):0}function is(e,t){let n=e/t;return isNaN(n)?0:n}function as(e){let t=is(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function os(e,t,n,r=`ltr`){let i=as(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 cs([c,l],d)(e)}function ss(e,t,n=`ltr`){let r=as(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Fn(e,n===`ltr`?[0,o]:[o*-1,0]);return cs([0,o],[0,s])(c)}function cs(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 ls(e,t){return e>0&&e<t}var us=(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 ds(e,t){let n=Dn(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 fs(e,t){let n=Dn(t);hn(()=>{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 ps=Lo,ms=zo,hs=ts,gs=`Separator`,_s=`horizontal`,vs=[`horizontal`,`vertical`],ys=z.forwardRef((e,t)=>{let{decorative:n,orientation:r=_s,...i}=e,a=bs(r)?r:_s,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})});ys.displayName=gs;function bs(e){return vs.includes(e)}var xs=ys,Ss=`Switch`,[Cs,ws]=pn(Ss),[Ts,Es]=Cs(Ss),Ds=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=ln(t,e=>p(e)),h=z.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=_n({prop:i,defaultProp:a??!1,onChange:l,caller:Ss});return(0,B.jsxs)(Ts,{scope:n,checked:_,disabled:s,children:[(0,B.jsx)(N.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Ms(_),"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)(js,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Ds.displayName=Ss;var Os=`SwitchThumb`,ks=z.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Es(Os,n);return(0,B.jsx)(N.span,{"data-state":Ms(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});ks.displayName=Os;var As=`SwitchBubbleInput`,js=z.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=z.useRef(null),s=ln(o,a),c=On(n),l=kn(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}})});js.displayName=As;function Ms(e){return e?`checked`:`unchecked`}var Ns=Ds,Ps=ks,Fs=`Tabs`,[Is,Ls]=pn(Fs,[Kr]),Rs=Kr(),[zs,Bs]=Is(Fs),Vs=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=En(s),[d,f]=_n({prop:r,onChange:i,defaultProp:a??``,caller:Fs});return(0,B.jsx)(zs,{scope:n,baseId:wn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,B.jsx)(N.div,{dir:u,"data-orientation":o,...l,ref:t})})});Vs.displayName=Fs;var Hs=`TabsList`,Us=z.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Bs(Hs,n),o=Rs(n);return(0,B.jsx)(ii,{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})})});Us.displayName=Hs;var Ws=`TabsTrigger`,Gs=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Bs(Ws,n),s=Rs(n),c=Js(o.baseId,r),l=Ys(o.baseId,r),u=r===o.value;return(0,B.jsx)(ai,{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)})})})});Gs.displayName=Ws;var Ks=`TabsContent`,qs=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Bs(Ks,n),c=Js(s.baseId,r),l=Ys(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)(vn,{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})})});qs.displayName=Ks;function Js(e,t){return`${e}-trigger-${t}`}function Ys(e,t){return`${e}-content-${t}`}var Xs=Vs,Zs=Us,Qs=Gs,$s=qs,[ec,tc]=pn(`Tooltip`,[An]),nc=An(),rc=`TooltipProvider`,ic=700,ac=`tooltip.open`,[oc,sc]=ec(rc),cc=e=>{let{__scopeTooltip:t,delayDuration:n=ic,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)(oc,{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})};cc.displayName=rc;var lc=`Tooltip`,[uc,dc]=ec(lc),fc=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=sc(lc,e.__scopeTooltip),l=nc(t),[u,d]=z.useState(null),f=wn(),p=z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=z.useRef(!1),[_,v]=_n({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(ac))):c.onClose(),a?.(e)},caller:lc}),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]),S=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)(jn,{...l,children:(0,B.jsx)(uc,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:z.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};fc.displayName=lc;var pc=`TooltipTrigger`,mc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=dc(pc,n),a=sc(pc,n),o=nc(n),s=ln(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)(Pn,{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)})})});mc.displayName=pc;var hc=`TooltipPortal`,[gc,_c]=ec(hc,{forceMount:void 0}),vc=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=dc(hc,t);return(0,B.jsx)(gc,{scope:t,forceMount:n,children:(0,B.jsx)(vn,{present:n||a.open,children:(0,B.jsx)(bn,{asChild:!0,container:i,children:r})})})};vc.displayName=hc;var yc=`TooltipContent`,bc=z.forwardRef((e,t)=>{let n=_c(yc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=dc(yc,e.__scopeTooltip);return(0,B.jsx)(vn,{present:r||o.open,children:o.disableHoverableContent?(0,B.jsx)(Tc,{side:i,...a,ref:t}):(0,B.jsx)(xc,{side:i,...a,ref:t})})}),xc=z.forwardRef((e,t)=>{let n=dc(yc,e.__scopeTooltip),r=sc(yc,e.__scopeTooltip),i=z.useRef(null),a=ln(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=kc(r,Oc(r,n.getBoundingClientRect())),a=Ac(t.getBoundingClientRect());s(Mc([...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=!jc(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,B.jsx)(Tc,{...e,ref:a})}),[Sc,Cc]=ec(lc,{isInside:!1}),wc=cn(`TooltipContent`),Tc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=dc(yc,n),l=nc(n),{onClose:u}=c;return z.useEffect(()=>(document.addEventListener(ac,u),()=>document.removeEventListener(ac,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)(Sn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,B.jsxs)(Nn,{"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)(wc,{children:r}),(0,B.jsx)(Sc,{scope:n,isInside:!0,children:(0,B.jsx)(Zn,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});bc.displayName=yc;var Ec=`TooltipArrow`,Dc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=nc(n);return Cc(Ec,n).isInside?null:(0,B.jsx)(Mn,{...i,...r,ref:t})});Dc.displayName=Ec;function Oc(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 kc(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 Ac(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 jc(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 Mc(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)),Nc(t)}function Nc(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 Pc=cc,Fc=fc,Ic=mc,Lc=vc,Rc=bc,zc=Dc;function Bc({delayDuration:e=0,...t}){return(0,B.jsx)(Pc,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Vc({...e}){return(0,B.jsx)(Fc,{"data-slot":`tooltip`,...e})}function Hc({...e}){return(0,B.jsx)(Ic,{"data-slot":`tooltip-trigger`,...e})}function Uc({className:e,sideOffset:t=0,children:n,...r}){return(0,B.jsx)(Lc,{children:(0,B.jsxs)(Rc,{"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)(zc,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function U(e){return A(e)}function Wc(){let e=U(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 Gc(e){let t=U(e=>e.messages),n=U(e=>e.tasks),r=U(e=>e.pairs),i=U(e=>e.inboxReadCursors),a=U(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=>rn(t)===e.id&&!Dt(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>Nt(e)&&Mt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>At(i,e.id,t)).length,l=Qt(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=>tn(t)&&en(t.target,e)).length+t.filter(t=>Tt(t)&&en(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 Kc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.showOffline),r=U(e=>e.agentSort),i=U(e=>e.agentSortDir),a=U(e=>e.agentPresetFilter),o=U(e=>e.agentStatusFilter),s=U(e=>e.agentTagFilter),c=U(e=>e.agentHostFilter),l=U(e=>e.managedPolicies),u=U(e=>e.pairs);return(0,z.useMemo)(()=>{let d=Ft(e,t,l);if(a){let e=qc(u);d=Jc(d,a,ht.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)):((Gt[e.status]??9)-(Gt[t.status]??9))*f||M(e).localeCompare(M(t)))},[e,t,n,l,r,i,a,o,s,c,u,_t()])}function qc(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 Jc(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`||nn(n,e));case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return bt().includes(t)?e.filter(e=>Jt(e)===t):e}}function Yc(){let e=U(e=>e.messages),t=U(e=>e.inboxReadCursors),n=U(e=>e.inboxArchivedThreads),r=U(e=>e.inboxDrafts),i=U(e=>e.agentsById),a=U(e=>e.coordinatorMutes);return(0,z.useMemo)(()=>{let o=new Map;for(let t of e){if(Dt(t))continue;let e=rn(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&&!Et(n)){o=n;break}}e.previewMessage=o||e.lastMessage;let s=a.includes(e.peer),c=s?0:e.messages.filter(n=>At(t,e.peer,n)).length,l=s?!1:Qt(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 Xc(){let e=Yc(),t=U(e=>e.agents),n=U(e=>e.showBuiltIns),r=U(e=>e.showOffline),i=U(e=>e.managedPolicies),a=U(e=>e.pairs),o=U(e=>e.tasks),s=U(e=>e.messages),c=(0,z.useMemo)(()=>new Set(Ft(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=Ft(t,n,i).filter(e=>(r||e.status!==`offline`)&&Qt(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(tn).length+s.filter(Tt).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 Zc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>Ft(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function Qc(){let e=U(e=>e.agents);return(0,z.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function $c(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.showOffline),r=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let i=Ft(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function el(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(Ft(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function tl(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(Ft(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function nl(){let e=U(e=>e.tasks),t=U(e=>e.messages);return(0,z.useMemo)(()=>{let n=e.filter(e=>!jt.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:tn(e),task:e})),r=t.filter(Tt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:Wt(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:Tt(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?Zt(e.updatedAt)-Zt(t.updatedAt):i})},[e,t])}function rl(){let e=U(e=>e.commandQuery),t=U(e=>e.agents),n=U(e=>e.agentsById),r=U(e=>e.showBuiltIns),i=U(e=>e.showOffline),a=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let n=Ft(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=Ye(),c=[il(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),il(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),il(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),il(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),il(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),il(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),il(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>il(`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=>il(`pair-`+e.id,`Pair: `+M(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>il(`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 il(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 W({className:e,size:t=`default`,...n}){return(0,B.jsx)(Ns,{"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)(Ps,{"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 al({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,B.jsx)(xs,{"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 ol({...e}){return(0,B.jsx)(xo,{"data-slot":`dropdown-menu`,...e})}function sl({...e}){return(0,B.jsx)(So,{"data-slot":`dropdown-menu-trigger`,...e})}function cl({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,B.jsx)(Co,{children:(0,B.jsx)(wo,{"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 ll({className:e,inset:t,variant:n=`default`,...r}){return(0,B.jsx)(Eo,{"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 ul({className:e,inset:t,...n}){return(0,B.jsx)(To,{"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 dl({className:e,...t}){return(0,B.jsx)(Do,{"data-slot":`dropdown-menu-separator`,className:O(`-mx-1 my-1 h-px bg-border`,e),...t})}var fl={LayoutDashboard:at,MessageCircle:Xe,Bot:w,Server:c,MessagesSquare:De,Plug:dt,PlugZap:pe,Activity:g,Link:Ve,Mail:Ge,ListChecks:qe,ClipboardList:Te,CalendarClock:ne,AreaChart:de,Settings:ue,Workflow:Ue,BrainCircuit:Ie,FolderTree:ie,Shield:o,Wrench:k,UserCog:Oe,Lightbulb:xe,Users:ze,Boxes:C,PackagePlus:_e,FileText:me};function pl(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var ml=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function hl(){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),c=A(e=>e.clearNotifications),l=A(e=>e.requestBrowserNotifications),u=t>0?x:p;function d(e){i({notificationSettings:{...n,...e}})}return(0,B.jsxs)(ol,{onOpenChange:e=>{e&&o()},children:[(0,B.jsx)(sl,{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)(u,{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)(cl,{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)(ul,{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)(s,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(`button`,{type:`button`,title:`Clear`,onClick:c,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,B.jsx)(Me,{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)(W,{size:`sm`,checked:n.enabled,onCheckedChange:e=>d({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)(W,{size:`sm`,checked:n.browserEnabled&&r===`granted`,disabled:r===`unsupported`,onCheckedChange:e=>{e&&r!==`granted`?l():d({browserEnabled:e})}})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:ml.map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>d({[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)(dl,{}),(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)(ll,{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:pl(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 gl(){let e=A(e=>e.theme),t=A(e=>e.set);return(0,B.jsxs)(ol,{children:[(0,B.jsx)(sl,{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)(h,{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:on.find(t=>t.id===e)?.label})]})}),(0,B.jsx)(cl,{align:`start`,side:`right`,className:`w-40`,children:on.map(n=>(0,B.jsxs)(ll,{onSelect:()=>t({theme:n.id}),children:[(0,B.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,B.jsx)(ce,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function _l(){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=Xc(),f=Zc();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:Yt.map(n=>{let r=fl[n.icon]||w;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)(Fe,{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)(hl,{}),(0,B.jsx)(gl,{}),(0,B.jsx)(al,{}),(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)(W,{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)(W,{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)(W,{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 vl(){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)(b,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,B.jsx)(_l,{})]})}function yl(){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)(b,{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)(Pe,{className:`w-4 h-4`})})]}),(0,B.jsx)(_l,{})]})]})}var bl=500*1024,xl={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`},Sl={".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`},Cl=null;function wl(){return Cl??=R(()=>import(`./bundle-web-BLavPdXe.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),Cl}function Tl(e){return new TextEncoder().encode(e).length}function El(e){return e.split(`/`).filter(Boolean).pop()||e}function Dl(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 Ol(e,t,n,r){if(n)return n;let i=El(e).toLowerCase();if(Sl[i])return Sl[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=Dl(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&xl[o]?xl[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 kl(e,t,n,r){let i=Ol(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var Al=(0,z.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=A(e=>e.theme),o=on.find(e=>e.id===a)?.dark??!0,s=(0,z.useMemo)(()=>Ol(t,n,r,e)||`text`,[e,r,n,t]),c=Tl(e)>bl,[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(!1);function h(){return(0,B.jsx)(In,{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),wl().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)(Ae,{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}})]})}),jl=(0,z.lazy)(()=>R(()=>import(`./markdown-preview-impl-DGLCocU8.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function Ml(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)(jl,{...e})})}var Nl=e(pt(),1);function Pl({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)(He,{className:`h-4 w-4`}):(0,B.jsx)(Je,{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)(Pe,{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 Fl({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,Nl.createPortal)((0,B.jsx)(Pl,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var Il=`agent-relay:file-git-status`;function Ll(){try{return window.localStorage.getItem(Il)!==`off`}catch{return!0}}function Rl(e){try{window.localStorage.setItem(Il,e?`on`:`off`)}catch{}}function zl(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 G(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function Bl({status:e}){let t=zl(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 K(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function q(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function J(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function Vl(e,t,n){return J(e,t)?`markdown`:kl(e,t,void 0,n)?`code`:null}function Hl(e){return`agent-relay:file-view-mode:${e}`}function Ul(e){try{let t=window.localStorage.getItem(Hl(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function Wl(e,t){try{window.localStorage.setItem(Hl(e),t)}catch{}}function Gl(e,t){let n=q(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 Kl(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(yt(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function ql(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`,G(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(yt(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function Jl({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 Yl({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:o,error:s}=ql(e,t,r);return(0,z.useEffect)(()=>{n(s)},[s,n]),t?o?(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Ae,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):s?(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)(ee,{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`?ee:a,n=zl(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)(Ne,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(Bl,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:K(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 Xl({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:o,error:s}=Kl(e,t),c=(0,z.useRef)(null),[l,u]=(0,z.useState)(`raw`);(0,z.useEffect)(()=>{r(s)},[s,r]),(0,z.useEffect)(()=>{n>0&&c.current?.scrollIntoView({block:`center`})},[i,n]),(0,z.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){u(`raw`);return}let e=Vl(i.path,i.mediaType,i.content);u(e?Ul(e):`raw`)},[i?.path,i?.encoding,i?.mediaType,i?.content,n]);function d(e,t){u(e),t&&Wl(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(o)return(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Ae,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(s)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)(a,{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)(In,{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:K(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)(Fl,{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:K(i.size)})]})]});let f=i.content??``,p=J(i.path,i.mediaType),m=!p&&kl(i.path,i.mediaType,void 0,f),h=p||m,g=p?`markdown`:m?`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)(a,{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)(In,{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:K(i.size)}),h&&(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 ${l===`raw`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>d(`raw`,g),children:`Raw`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${l===`rendered`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>d(`rendered`,g),children:p?`Rendered`:`Highlighted`})]})]}),l===`rendered`&&p&&(0,B.jsx)(Ml,{content:f,path:i.path}),l===`rendered`&&m&&(0,B.jsx)(Al,{content:f,path:i.path,mediaType:i.mediaType}),l===`raw`&&(0,B.jsx)(Jl,{content:f,line:n,lineRef:c})]})}function Zl({overlay:e=!1}){let t=A(e=>e.apiCall),n=A(e=>e.orchestrators),o=A(e=>e.fileOrchestratorId),s=A(e=>e.filePath),c=A(e=>e.fileSelectedPath),l=A(e=>e.fileSelectedLine),u=A(e=>e.set),d=A(e=>e.closeFileOverlay),p=A(e=>e.openOrchestratorSpawnAt),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)(s),[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(``),[S,C]=(0,z.useState)(``),[te,ne]=(0,z.useState)(Ll),re=(0,z.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),w=n.find(e=>e.id===o)||re[0];(0,z.useEffect)(()=>{if(!w)return;let e={};o||(e.fileOrchestratorId=w.id),s||(e.filePath=w.baseDir),Object.keys(e).length&&u(e)},[o,s,w,u]),(0,z.useEffect)(()=>_(s),[s]);async function ae(e=s){if(!(!w||!e)){y(!0),x(``);try{let n=await t(`GET`,G(w.id,e,te));h(n),u({filePath:n.path}),_(n.path),C(``)}catch(e){x(yt(e))}finally{y(!1)}}}(0,z.useEffect)(()=>{ae(s)},[w?.id,s,te]);function oe(e){ne(e),Rl(e)}function se(e){u({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function T(e){C(``),e.type===`directory`?u({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):u({fileSelectedPath:e.path,fileSelectedLine:0})}function E(){if(!w)return;let t=g.trim()||s||w.baseDir;e&&d(),p({orchestratorId:w.id,cwd:t})}let ce=m?Gl(m.path,m.baseDir):[],le=b||S;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 ${c?`hidden md:flex`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,B.jsx)(ie,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,B.jsxs)(`select`,{value:w?.id||``,onChange:e=>se(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[re.length===0&&(0,B.jsx)(`option`,{value:``,children:`No online orchestrators`}),re.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:d,title:`Close`,children:(0,B.jsx)(Pe,{className:`h-4 w-4`})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${c?`hidden md:flex`:``}`,children:[(0,B.jsx)(L,{value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u({filePath:g,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:w?.baseDir||`Path`}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>ae(g),disabled:v||!w,children:[v?(0,B.jsx)(Ae,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(f,{className:`h-3.5 w-3.5`}),`Open`]}),(0,B.jsxs)(I,{size:`sm`,className:`gap-1`,onClick:E,disabled:!w,children:[(0,B.jsx)(i,{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)(r,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,B.jsx)(W,{checked:te,onCheckedChange:oe})]})]}),ce.length>0&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${c?`hidden md:flex`:``}`,children:ce.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:()=>u({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}),children:[e.label,t<ce.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),le&&(0,B.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:le}),(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)] ${c?``:`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 ${c?`hidden md:block`:``}`,children:[m?.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:()=>u({filePath:m.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(Qe,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{children:`Parent directory`})]}),m?.entries.map(e=>{let t=c===e.path||s===e.path,n=e.type===`directory`?ee:a,r=zl(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:()=>T(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)(Ne,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(Bl,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:K(e.size)})]},e.path)}),!v&&m&&m.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 ${c?``:`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:()=>u({fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(Qe,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(Xl,{orchestratorId:w?.id||``,selectedPath:c,line:l,onReadError:C})})]})]})]})}function Ql(){return(0,B.jsx)(Zl,{})}function $l(){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)(Zl,{overlay:!0})})}):null}function eu(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 tu({...e}){return eu(e.open,e.onOpenChange),(0,B.jsx)(Mr,{"data-slot":`sheet`,...e})}function nu({...e}){return(0,B.jsx)(Nr,{"data-slot":`sheet-portal`,...e})}function ru({className:e,...t}){return(0,B.jsx)(Pr,{"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 iu({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,B.jsxs)(nu,{children:[(0,B.jsx)(ru,{}),(0,B.jsxs)(Fr,{"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)(Rr,{"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)(Pe,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function au({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 ou({className:e,...t}){return(0,B.jsx)(Ir,{"data-slot":`sheet-title`,className:O(`font-heading text-base font-medium text-foreground`,e),...t})}function su({className:e,orientation:t=`horizontal`,...n}){return(0,B.jsx)(Xs,{"data-slot":`tabs`,"data-orientation":t,className:O(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var cu=dn(`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 lu({className:e,variant:t=`default`,...n}){return(0,B.jsx)(Zs,{"data-slot":`tabs-list`,"data-variant":t,className:O(cu({variant:t}),e),...n})}function uu({className:e,...t}){return(0,B.jsx)(Qs,{"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 du({className:e,...t}){return(0,B.jsx)($s,{"data-slot":`tabs-content`,className:O(`flex-1 text-sm outline-none`,e),...t})}function fu({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`,Ot(e,t),n)})}function pu({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 mu({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 hu={claude:pu,anthropic:pu,codex:mu,openai:mu},gu={claude:`text-orange-400`,anthropic:`text-orange-400`};function _u({provider:e,className:t}){let n=e.toLowerCase(),r=hu[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(gu[n],t)})}):(0,B.jsx)(`span`,{className:`capitalize`,children:e})}var vu={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`},yu={codex:je,claude:pu,user:et,system:c,channel:De,agent:w};function bu({agent:e,className:t}){let n=Jt(e),r=yu[n]||w;return(0,B.jsx)(`span`,{className:O(`inline-flex items-center justify-center w-5 h-5 rounded-md border text-sm`,vu[n]||vu.agent,t),children:(0,B.jsx)(r,{className:`w-3.5 h-3.5`})})}function xu({agent:e,compact:t=!1}){let n=ju(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 Su({agent:e,compact:t=!1,className:n=``}){let r=wu(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 Cu({agent:e}){let t=e.context;if(!t)return null;let n=Pu(t);if(n===null)return(0,B.jsxs)(`div`,{className:`space-y-1`,title:Fu(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:Fu(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 wu(e){let t=Tu(e),n=Eu(e),r=Du(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?re:Re,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 Tu(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Eu(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:Ee,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:y,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:rt,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Du(e){let t=Ou(e.meta?.workspace),n=St(t.requestedMode)||St(e.meta?.workspaceMode),i=St(t.mode),a=n&&n!==`inherit`?n:i&&n!==`inherit`?i:`default`;return a===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:r,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:a===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:ot,iconColor:`text-cyan-300`,className:`border-cyan-500/30 bg-cyan-500/10 text-cyan-300`}:{key:`workspace`,label:`Default`,title:i?`Workspace: default/inherit, resolved to ${i}`:`Workspace: default/inherit`,Icon:ut,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function Ou(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function ku(e){let t=Ou(e.meta?.workspace),n=St(t.repoRoot)||St(t.sourceCwd)||St(e.meta?.cwd);return n?Pt(n,2):``}function Au(e){return!!(e.context||e.providerCapabilities?.context)}function ju(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=$t(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=Pu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function Mu({context:e,expected:t=!!e,size:n=26,className:r}){let i=Pu(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:Fu(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 Nu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${Iu(t.tokensUsed)} / ${Iu(t.tokensMax)}`:t.tokensUsed?Iu(t.tokensUsed):t.tokensMax?Iu(t.tokensMax):null}function Pu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function Fu(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=Pu(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 Iu(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var Lu=(0,z.lazy)(()=>R(()=>import(`./terminal-viewer-impl-fLly20IP.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13,14]),import.meta.url));function Ru(e){return e.open?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(Lu,{...e})}):null}function zu({orchestratorId:e,session:t,lines:r=200}){let i=A(e=>e.apiCall),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[f,p]=(0,z.useState)(`provider`),[m,h]=(0,z.useState)(null);async function g(){if(!l)try{o((await i(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${r}${f===`mirror`?`&stream=mirror`:``}`)).lines||[]),h(null)}catch(e){h(yt(e))}}(0,z.useEffect)(()=>{g();let e=setInterval(()=>void g(),1500);return()=>clearInterval(e)},[e,t,l,f]);let _=s?a.filter(e=>e.toLowerCase().includes(s.toLowerCase())):a;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)(Le,{className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground`}),(0,B.jsx)(L,{className:`pl-8`,value:s,onChange:e=>c(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)(je,{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)(n,{className:`h-3.5 w-3.5`}),` Mirror`]})]}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>u(e=>!e),title:l?`Resume logs`:`Pause logs`,children:l?(0,B.jsx)(d,{className:`h-4 w-4`}):(0,B.jsx)(v,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>Xt(`${t}.log`,a.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},Ar=`DialogDescriptionWarning`,jr=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Or(Ar).contentName}}.`;return z.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Mr=rr,Nr=lr,Pr=dr,Fr=hr,Ir=br,Lr=Sr,Rr=wr,zr=`rovingFocusGroup.onEntryFocus`,Br={bubbles:!1,cancelable:!0},Vr=`RovingFocusGroup`,[Hr,Ur,Wr]=gn(Vr),[Gr,Kr]=pn(Vr,[Wr]),[qr,Jr]=Gr(Vr),Yr=z.forwardRef((e,t)=>(0,B.jsx)(Hr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(Hr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(Xr,{...e,ref:t})})}));Yr.displayName=Vr;var Xr=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=ln(t,f),m=En(a),[h,g]=_n({prop:o,defaultProp:s??null,onChange:c,caller:Vr}),[_,v]=z.useState(!1),y=Dn(l),b=Ur(n),x=z.useRef(!1),[S,C]=z.useState(0);return z.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(zr,y),()=>e.removeEventListener(zr,y)},[y]),(0,B.jsx)(qr,{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(()=>C(e=>e+1),[]),onFocusableItemRemove:z.useCallback(()=>C(e=>e-1),[]),children:(0,B.jsx)(N.div,{tabIndex:_||S===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(zr,Br);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);ni([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))})})}),Zr=`RovingFocusGroupItem`,Qr=z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=wn(),l=a||c,u=Jr(Zr,n),d=u.currentTabStopId===l,f=Ur(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return z.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,B.jsx)(Hr.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=ti(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?ri(n,r+1):n.slice(r+1)}setTimeout(()=>ni(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Qr.displayName=Zr;var $r={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function ei(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function ti(e,t,n){let r=ei(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return $r[r]}function ni(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ri(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ii=Yr,ai=Qr,oi=[`Enter`,` `],si=[`ArrowDown`,`PageUp`,`Home`],ci=[`ArrowUp`,`PageDown`,`End`],li=[...si,...ci],ui={ltr:[...oi,`ArrowRight`],rtl:[...oi,`ArrowLeft`]},di={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},fi=`Menu`,[pi,mi,hi]=gn(fi),[gi,_i]=pn(fi,[hi,An,Kr]),vi=An(),yi=Kr(),[bi,xi]=gi(fi),[Si,Ci]=gi(fi),wi=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=vi(t),[c,l]=z.useState(null),u=z.useRef(!1),d=Dn(a),f=En(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)(jn,{...s,children:(0,B.jsx)(bi,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,B.jsx)(Si,{scope:t,onClose:z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};wi.displayName=fi;var Ti=`MenuAnchor`,Ei=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=vi(n);return(0,B.jsx)(Pn,{...i,...r,ref:t})});Ei.displayName=Ti;var Di=`MenuPortal`,[Oi,ki]=gi(Di,{forceMount:void 0}),Ai=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=xi(Di,t);return(0,B.jsx)(Oi,{scope:t,forceMount:n,children:(0,B.jsx)(vn,{present:n||a.open,children:(0,B.jsx)(bn,{asChild:!0,container:i,children:r})})})};Ai.displayName=Di;var ji=`MenuContent`,[Mi,V]=gi(ji),Ni=z.forwardRef((e,t)=>{let n=ki(ji,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=xi(ji,e.__scopeMenu),o=Ci(ji,e.__scopeMenu);return(0,B.jsx)(pi.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(vn,{present:r||a.open,children:(0,B.jsx)(pi.Slot,{scope:e.__scopeMenu,children:o.modal?(0,B.jsx)(Pi,{...i,ref:t}):(0,B.jsx)(Fi,{...i,ref:t})})})})}),Pi=z.forwardRef((e,t)=>{let n=xi(ji,e.__scopeMenu),r=z.useRef(null),i=ln(t,r);return z.useEffect(()=>{let e=r.current;if(e)return Tn(e)},[]),(0,B.jsx)(Li,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Fi=z.forwardRef((e,t)=>{let n=xi(ji,e.__scopeMenu);return(0,B.jsx)(Li,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ii=un(`MenuContent.ScrollLock`),Li=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=xi(ji,n),_=Ci(ji,n),v=vi(n),y=yi(n),b=mi(n),[x,S]=z.useState(null),C=z.useRef(null),ee=ln(t,C,g.onContentChange),te=z.useRef(0),ne=z.useRef(``),re=z.useRef(0),w=z.useRef(null),ie=z.useRef(`right`),ae=z.useRef(0),oe=m?xn:z.Fragment,se=m?{as:Ii,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=xa(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),[]),Cn();let E=z.useCallback(e=>ie.current===w.current?.side&&Ca(e,w.current?.area),[]);return(0,B.jsx)(Mi,{scope:n,searchRef:ne,onItemEnter:z.useCallback(e=>{E(e)&&e.preventDefault()},[E]),onItemLeave:z.useCallback(e=>{E(e)||(C.current?.focus(),S(null))},[E]),onTriggerLeave:z.useCallback(e=>{E(e)&&e.preventDefault()},[E]),pointerGraceTimerRef:re,onPointerGraceIntentChange:z.useCallback(e=>{w.current=e},[]),children:(0,B.jsx)(oe,{...se,children:(0,B.jsx)(yn,{asChild:!0,trapped:i,onMountAutoFocus:P(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,B.jsx)(Sn,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,B.jsx)(ii,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:P(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,B.jsx)(Nn,{role:`menu`,"aria-orientation":`vertical`,"data-state":ga(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:ee,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=C.current;if(e.target!==i||!li.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);ci.includes(e.key)&&a.reverse(),ya(a)}),onBlur:P(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(te.current),ne.current=``)}),onPointerMove:P(e.onPointerMove,wa(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)}))})})})})})})});Ni.displayName=ji;var Ri=`MenuGroup`,zi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`group`,...r,ref:t})});zi.displayName=Ri;var Bi=`MenuLabel`,Vi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{...r,ref:t})});Vi.displayName=Bi;var Hi=`MenuItem`,Ui=`menu.itemSelect`,Wi=z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=z.useRef(null),o=Ci(Hi,e.__scopeMenu),s=V(Hi,e.__scopeMenu),c=ln(t,a),l=z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Ui,{bubbles:!0,cancelable:!0});e.addEventListener(Ui,e=>r?.(e),{once:!0}),fn(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,B.jsx)(Gi,{...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===` `||oi.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Wi.displayName=Hi;var Gi=z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=V(Hi,n),s=yi(n),c=z.useRef(null),l=ln(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)(pi.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,B.jsx)(ai,{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,wa(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:P(e.onPointerLeave,wa(e=>o.onItemLeave(e))),onFocus:P(e.onFocus,()=>d(!0)),onBlur:P(e.onBlur,()=>d(!1))})})})}),Ki=`MenuCheckboxItem`,qi=z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,B.jsx)(ta,{scope:e.__scopeMenu,checked:n,children:(0,B.jsx)(Wi,{role:`menuitemcheckbox`,"aria-checked":_a(n)?`mixed`:n,...i,ref:t,"data-state":va(n),onSelect:P(i.onSelect,()=>r?.(_a(n)?!0:!n),{checkForDefaultPrevented:!1})})})});qi.displayName=Ki;var Ji=`MenuRadioGroup`,[Yi,Xi]=gi(Ji,{value:void 0,onValueChange:()=>{}}),Zi=z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Dn(r);return(0,B.jsx)(Yi,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,B.jsx)(zi,{...i,ref:t})})});Zi.displayName=Ji;var Qi=`MenuRadioItem`,$i=z.forwardRef((e,t)=>{let{value:n,...r}=e,i=Xi(Qi,e.__scopeMenu),a=n===i.value;return(0,B.jsx)(ta,{scope:e.__scopeMenu,checked:a,children:(0,B.jsx)(Wi,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":va(a),onSelect:P(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});$i.displayName=Qi;var ea=`MenuItemIndicator`,[ta,na]=gi(ea,{checked:!1}),ra=z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=na(ea,n);return(0,B.jsx)(vn,{present:r||_a(a.checked)||a.checked===!0,children:(0,B.jsx)(N.span,{...i,ref:t,"data-state":va(a.checked)})})});ra.displayName=ea;var ia=`MenuSeparator`,aa=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});aa.displayName=ia;var oa=`MenuArrow`,sa=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=vi(n);return(0,B.jsx)(Mn,{...i,...r,ref:t})});sa.displayName=oa;var ca=`MenuSub`,[la,ua]=gi(ca),da=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=xi(ca,t),o=vi(t),[s,c]=z.useState(null),[l,u]=z.useState(null),d=Dn(i);return z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,B.jsx)(jn,{...o,children:(0,B.jsx)(bi,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,B.jsx)(la,{scope:t,contentId:wn(),triggerId:wn(),trigger:s,onTriggerChange:c,children:n})})})};da.displayName=ca;var fa=`MenuSubTrigger`,pa=z.forwardRef((e,t)=>{let n=xi(fa,e.__scopeMenu),r=Ci(fa,e.__scopeMenu),i=ua(fa,e.__scopeMenu),a=V(fa,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)(Ei,{asChild:!0,...l,children:(0,B.jsx)(Gi,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":ga(n.open),...e,ref:sn(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:P(e.onPointerMove,wa(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,wa(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===` `||ui[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});pa.displayName=fa;var ma=`MenuSubContent`,ha=z.forwardRef((e,t)=>{let n=ki(ji,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=xi(ji,e.__scopeMenu),o=Ci(ji,e.__scopeMenu),s=ua(ma,e.__scopeMenu),c=z.useRef(null),l=ln(t,c);return(0,B.jsx)(pi.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(vn,{present:r||a.open,children:(0,B.jsx)(pi.Slot,{scope:e.__scopeMenu,children:(0,B.jsx)(Li,{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=di[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});ha.displayName=ma;function ga(e){return e?`open`:`closed`}function _a(e){return e===`indeterminate`}function va(e){return _a(e)?`indeterminate`:e?`checked`:`unchecked`}function ya(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ba(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function xa(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=ba(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 Sa(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 Ca(e,t){return t?Sa({x:e.clientX,y:e.clientY},t):!1}function wa(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Ta=wi,Ea=Ei,Da=Ai,Oa=Ni,ka=zi,Aa=Vi,ja=Wi,Ma=qi,Na=Zi,Pa=$i,Fa=ra,Ia=aa,La=sa,Ra=pa,za=ha,Ba=`DropdownMenu`,[Va,Ha]=pn(Ba,[_i]),Ua=_i(),[Wa,Ga]=Va(Ba),Ka=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Ua(t),l=z.useRef(null),[u,d]=_n({prop:i,defaultProp:a??!1,onChange:o,caller:Ba});return(0,B.jsx)(Wa,{scope:t,triggerId:wn(),triggerRef:l,contentId:wn(),open:u,onOpenChange:d,onOpenToggle:z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,B.jsx)(Ta,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Ka.displayName=Ba;var qa=`DropdownMenuTrigger`,Ja=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Ga(qa,n),o=Ua(n);return(0,B.jsx)(Ea,{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:sn(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())})})})});Ja.displayName=qa;var Ya=`DropdownMenuPortal`,Xa=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Ua(t);return(0,B.jsx)(Da,{...r,...n})};Xa.displayName=Ya;var Za=`DropdownMenuContent`,Qa=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ga(Za,n),a=Ua(n),o=z.useRef(!1);return(0,B.jsx)(Oa,{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)`}})});Qa.displayName=Za;var $a=`DropdownMenuGroup`,eo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(ka,{...i,...r,ref:t})});eo.displayName=$a;var to=`DropdownMenuLabel`,no=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Aa,{...i,...r,ref:t})});no.displayName=to;var ro=`DropdownMenuItem`,io=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(ja,{...i,...r,ref:t})});io.displayName=ro;var ao=`DropdownMenuCheckboxItem`,oo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Ma,{...i,...r,ref:t})});oo.displayName=ao;var so=`DropdownMenuRadioGroup`,co=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Na,{...i,...r,ref:t})});co.displayName=so;var lo=`DropdownMenuRadioItem`,uo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Pa,{...i,...r,ref:t})});uo.displayName=lo;var H=`DropdownMenuItemIndicator`,fo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Fa,{...i,...r,ref:t})});fo.displayName=H;var po=`DropdownMenuSeparator`,mo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Ia,{...i,...r,ref:t})});mo.displayName=po;var ho=`DropdownMenuArrow`,go=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(La,{...i,...r,ref:t})});go.displayName=ho;var _o=`DropdownMenuSubTrigger`,vo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(Ra,{...i,...r,ref:t})});vo.displayName=_o;var yo=`DropdownMenuSubContent`,bo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ua(n);return(0,B.jsx)(za,{...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)`}})});bo.displayName=yo;var xo=Ka,So=Ja,Co=Xa,wo=Qa,To=no,Eo=io,Do=mo,Oo=`Label`,ko=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())}}));ko.displayName=Oo;var Ao=ko;function jo(e,t){return z.useReducer((e,n)=>t[e][n]??e,e)}var Mo=`ScrollArea`,[No,Po]=pn(Mo),[Fo,Io]=No(Mo),Lo=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,S]=z.useState(!1),[C,ee]=z.useState(!1),te=ln(t,e=>c(e)),ne=En(i);return(0,B.jsx)(Fo,{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:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:C,onScrollbarYEnabledChange:ee,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}})})});Lo.displayName=Mo;var Ro=`ScrollAreaViewport`,zo=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=Io(Ro,n),s=ln(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})})]})});zo.displayName=Ro;var Bo=`ScrollAreaScrollbar`,Vo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Io(Bo,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)(Ho,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,B.jsx)(Uo,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,B.jsx)(Wo,{...r,ref:t,forceMount:n}):i.type===`always`?(0,B.jsx)(Go,{...r,ref:t}):null});Vo.displayName=Bo;var Ho=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Io(Bo,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)(vn,{present:n||a,children:(0,B.jsx)(Wo,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Uo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Io(Bo,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=ds(()=>c(`SCROLL_END`),100),[s,c]=jo(`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)(vn,{present:n||s!==`hidden`,children:(0,B.jsx)(Go,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:P(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:P(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),Wo=z.forwardRef((e,t)=>{let n=Io(Bo,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=z.useState(!1),s=e.orientation===`horizontal`,c=ds(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return fs(n.viewport,c),fs(n.content,c),(0,B.jsx)(vn,{present:r||a,children:(0,B.jsx)(Go,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),Go=z.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=Io(Bo,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=is(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 os(e,o.current,s,t)}return n===`horizontal`?(0,B.jsx)(Ko,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=ss(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)(qo,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=ss(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}),Ko=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Io(Bo,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=ln(t,c,a.onScrollbarXChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(Xo,{"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":as(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),ls(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:rs(o.paddingLeft),paddingEnd:rs(o.paddingRight)}})}})}),qo=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Io(Bo,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=ln(t,c,a.onScrollbarYChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(Xo,{"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":as(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),ls(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:rs(o.paddingTop),paddingEnd:rs(o.paddingBottom)}})}})}),[Jo,Yo]=No(Bo),Xo=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=Io(Bo,n),[m,h]=z.useState(null),g=ln(t,e=>h(e)),_=z.useRef(null),v=z.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Dn(u),S=Dn(c),C=ds(d,10);function ee(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(S,[r,S]),fs(m,C),fs(p.content,C),(0,B.jsx)(Jo,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Dn(a),onThumbPointerUp:Dn(o),onThumbPositionChange:S,onThumbPointerDown:Dn(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`),ee(e))}),onPointerMove:P(e.onPointerMove,ee),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})})})}),Zo=`ScrollAreaThumb`,Qo=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Yo(Zo,e.__scopeScrollArea);return(0,B.jsx)(vn,{present:n||i.hasThumb,children:(0,B.jsx)($o,{ref:t,...r})})}),$o=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=Io(Zo,n),o=Yo(Zo,n),{onThumbPositionChange:s}=o,c=ln(t,e=>o.onThumbChange(e)),l=z.useRef(void 0),u=ds(()=>{l.current&&=(l.current(),void 0)},100);return z.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=us(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)})});Qo.displayName=Zo;var es=`ScrollAreaCorner`,ts=z.forwardRef((e,t)=>{let n=Io(es,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,B.jsx)(ns,{...e,ref:t}):null});ts.displayName=es;var ns=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=Io(es,n),[a,o]=z.useState(0),[s,c]=z.useState(0),l=!!(a&&s);return fs(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),fs(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 rs(e){return e?parseInt(e,10):0}function is(e,t){let n=e/t;return isNaN(n)?0:n}function as(e){let t=is(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function os(e,t,n,r=`ltr`){let i=as(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 cs([c,l],d)(e)}function ss(e,t,n=`ltr`){let r=as(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Fn(e,n===`ltr`?[0,o]:[o*-1,0]);return cs([0,o],[0,s])(c)}function cs(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 ls(e,t){return e>0&&e<t}var us=(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 ds(e,t){let n=Dn(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 fs(e,t){let n=Dn(t);hn(()=>{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 ps=Lo,ms=zo,hs=ts,gs=`Separator`,_s=`horizontal`,vs=[`horizontal`,`vertical`],ys=z.forwardRef((e,t)=>{let{decorative:n,orientation:r=_s,...i}=e,a=bs(r)?r:_s,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})});ys.displayName=gs;function bs(e){return vs.includes(e)}var xs=ys,Ss=`Switch`,[Cs,ws]=pn(Ss),[Ts,Es]=Cs(Ss),Ds=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=ln(t,e=>p(e)),h=z.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=_n({prop:i,defaultProp:a??!1,onChange:l,caller:Ss});return(0,B.jsxs)(Ts,{scope:n,checked:_,disabled:s,children:[(0,B.jsx)(N.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Ms(_),"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)(js,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Ds.displayName=Ss;var Os=`SwitchThumb`,ks=z.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Es(Os,n);return(0,B.jsx)(N.span,{"data-state":Ms(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});ks.displayName=Os;var As=`SwitchBubbleInput`,js=z.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=z.useRef(null),s=ln(o,a),c=On(n),l=kn(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}})});js.displayName=As;function Ms(e){return e?`checked`:`unchecked`}var Ns=Ds,Ps=ks,Fs=`Tabs`,[Is,Ls]=pn(Fs,[Kr]),Rs=Kr(),[zs,Bs]=Is(Fs),Vs=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=En(s),[d,f]=_n({prop:r,onChange:i,defaultProp:a??``,caller:Fs});return(0,B.jsx)(zs,{scope:n,baseId:wn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,B.jsx)(N.div,{dir:u,"data-orientation":o,...l,ref:t})})});Vs.displayName=Fs;var Hs=`TabsList`,Us=z.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Bs(Hs,n),o=Rs(n);return(0,B.jsx)(ii,{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})})});Us.displayName=Hs;var Ws=`TabsTrigger`,Gs=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Bs(Ws,n),s=Rs(n),c=Js(o.baseId,r),l=Ys(o.baseId,r),u=r===o.value;return(0,B.jsx)(ai,{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)})})})});Gs.displayName=Ws;var Ks=`TabsContent`,qs=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Bs(Ks,n),c=Js(s.baseId,r),l=Ys(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)(vn,{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})})});qs.displayName=Ks;function Js(e,t){return`${e}-trigger-${t}`}function Ys(e,t){return`${e}-content-${t}`}var Xs=Vs,Zs=Us,Qs=Gs,$s=qs,[ec,tc]=pn(`Tooltip`,[An]),nc=An(),rc=`TooltipProvider`,ic=700,ac=`tooltip.open`,[oc,sc]=ec(rc),cc=e=>{let{__scopeTooltip:t,delayDuration:n=ic,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)(oc,{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})};cc.displayName=rc;var lc=`Tooltip`,[uc,dc]=ec(lc),fc=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=sc(lc,e.__scopeTooltip),l=nc(t),[u,d]=z.useState(null),f=wn(),p=z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=z.useRef(!1),[_,v]=_n({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(ac))):c.onClose(),a?.(e)},caller:lc}),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]),S=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)(jn,{...l,children:(0,B.jsx)(uc,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:z.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};fc.displayName=lc;var pc=`TooltipTrigger`,mc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=dc(pc,n),a=sc(pc,n),o=nc(n),s=ln(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)(Pn,{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)})})});mc.displayName=pc;var hc=`TooltipPortal`,[gc,_c]=ec(hc,{forceMount:void 0}),vc=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=dc(hc,t);return(0,B.jsx)(gc,{scope:t,forceMount:n,children:(0,B.jsx)(vn,{present:n||a.open,children:(0,B.jsx)(bn,{asChild:!0,container:i,children:r})})})};vc.displayName=hc;var yc=`TooltipContent`,bc=z.forwardRef((e,t)=>{let n=_c(yc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=dc(yc,e.__scopeTooltip);return(0,B.jsx)(vn,{present:r||o.open,children:o.disableHoverableContent?(0,B.jsx)(Tc,{side:i,...a,ref:t}):(0,B.jsx)(xc,{side:i,...a,ref:t})})}),xc=z.forwardRef((e,t)=>{let n=dc(yc,e.__scopeTooltip),r=sc(yc,e.__scopeTooltip),i=z.useRef(null),a=ln(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=kc(r,Oc(r,n.getBoundingClientRect())),a=Ac(t.getBoundingClientRect());s(Mc([...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=!jc(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,B.jsx)(Tc,{...e,ref:a})}),[Sc,Cc]=ec(lc,{isInside:!1}),wc=cn(`TooltipContent`),Tc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=dc(yc,n),l=nc(n),{onClose:u}=c;return z.useEffect(()=>(document.addEventListener(ac,u),()=>document.removeEventListener(ac,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)(Sn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,B.jsxs)(Nn,{"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)(wc,{children:r}),(0,B.jsx)(Sc,{scope:n,isInside:!0,children:(0,B.jsx)(Zn,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});bc.displayName=yc;var Ec=`TooltipArrow`,Dc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=nc(n);return Cc(Ec,n).isInside?null:(0,B.jsx)(Mn,{...i,...r,ref:t})});Dc.displayName=Ec;function Oc(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 kc(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 Ac(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 jc(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 Mc(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)),Nc(t)}function Nc(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 Pc=cc,Fc=fc,Ic=mc,Lc=vc,Rc=bc,zc=Dc;function Bc({delayDuration:e=0,...t}){return(0,B.jsx)(Pc,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Vc({...e}){return(0,B.jsx)(Fc,{"data-slot":`tooltip`,...e})}function Hc({...e}){return(0,B.jsx)(Ic,{"data-slot":`tooltip-trigger`,...e})}function Uc({className:e,sideOffset:t=0,children:n,...r}){return(0,B.jsx)(Lc,{children:(0,B.jsxs)(Rc,{"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)(zc,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function U(e){return A(e)}function Wc(){let e=U(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 Gc(e){let t=U(e=>e.messages),n=U(e=>e.tasks),r=U(e=>e.pairs),i=U(e=>e.inboxReadCursors),a=U(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=>rn(t)===e.id&&!Dt(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>Nt(e)&&Mt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>At(i,e.id,t)).length,l=Qt(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=>tn(t)&&en(t.target,e)).length+t.filter(t=>Tt(t)&&en(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 Kc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.showOffline),r=U(e=>e.agentSort),i=U(e=>e.agentSortDir),a=U(e=>e.agentPresetFilter),o=U(e=>e.agentStatusFilter),s=U(e=>e.agentTagFilter),c=U(e=>e.agentHostFilter),l=U(e=>e.managedPolicies),u=U(e=>e.pairs);return(0,z.useMemo)(()=>{let d=Ft(e,t,l);if(a){let e=qc(u);d=Jc(d,a,ht.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)):((Gt[e.status]??9)-(Gt[t.status]??9))*f||M(e).localeCompare(M(t)))},[e,t,n,l,r,i,a,o,s,c,u,_t()])}function qc(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 Jc(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`||nn(n,e));case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return bt().includes(t)?e.filter(e=>Jt(e)===t):e}}function Yc(){let e=U(e=>e.messages),t=U(e=>e.inboxReadCursors),n=U(e=>e.inboxArchivedThreads),r=U(e=>e.inboxDrafts),i=U(e=>e.agentsById),a=U(e=>e.coordinatorMutes);return(0,z.useMemo)(()=>{let o=new Map;for(let t of e){if(Dt(t))continue;let e=rn(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&&!Et(n)){o=n;break}}e.previewMessage=o||e.lastMessage;let s=a.includes(e.peer),c=s?0:e.messages.filter(n=>At(t,e.peer,n)).length,l=s?!1:Qt(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 Xc(){let e=Yc(),t=U(e=>e.agents),n=U(e=>e.showBuiltIns),r=U(e=>e.showOffline),i=U(e=>e.managedPolicies),a=U(e=>e.pairs),o=U(e=>e.tasks),s=U(e=>e.messages),c=(0,z.useMemo)(()=>new Set(Ft(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=Ft(t,n,i).filter(e=>(r||e.status!==`offline`)&&Qt(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(tn).length+s.filter(Tt).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 Zc(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>Ft(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function Qc(){let e=U(e=>e.agents);return(0,z.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function $c(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.showOffline),r=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let i=Ft(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function el(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(Ft(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function tl(){let e=U(e=>e.agents),t=U(e=>e.showBuiltIns),n=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(Ft(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function nl(){let e=U(e=>e.tasks),t=U(e=>e.messages);return(0,z.useMemo)(()=>{let n=e.filter(e=>!jt.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:tn(e),task:e})),r=t.filter(Tt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:Wt(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:Tt(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?Zt(e.updatedAt)-Zt(t.updatedAt):i})},[e,t])}function rl(){let e=U(e=>e.commandQuery),t=U(e=>e.agents),n=U(e=>e.agentsById),r=U(e=>e.showBuiltIns),i=U(e=>e.showOffline),a=U(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let n=Ft(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=Ye(),c=[il(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),il(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),il(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),il(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),il(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),il(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),il(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>il(`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=>il(`pair-`+e.id,`Pair: `+M(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>il(`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 il(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 W({className:e,size:t=`default`,...n}){return(0,B.jsx)(Ns,{"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)(Ps,{"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 al({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,B.jsx)(xs,{"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 ol({...e}){return(0,B.jsx)(xo,{"data-slot":`dropdown-menu`,...e})}function sl({...e}){return(0,B.jsx)(So,{"data-slot":`dropdown-menu-trigger`,...e})}function cl({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,B.jsx)(Co,{children:(0,B.jsx)(wo,{"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 ll({className:e,inset:t,variant:n=`default`,...r}){return(0,B.jsx)(Eo,{"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 ul({className:e,inset:t,...n}){return(0,B.jsx)(To,{"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 dl({className:e,...t}){return(0,B.jsx)(Do,{"data-slot":`dropdown-menu-separator`,className:O(`-mx-1 my-1 h-px bg-border`,e),...t})}var fl={LayoutDashboard:at,MessageCircle:Xe,Bot:w,Server:c,MessagesSquare:De,Plug:dt,PlugZap:pe,Activity:g,Link:Ve,Mail:Ge,ListChecks:qe,ClipboardList:Te,CalendarClock:ne,AreaChart:de,Settings:ue,Workflow:Ue,BrainCircuit:Ie,FolderTree:ie,Shield:o,Wrench:k,UserCog:Oe,Lightbulb:xe,Users:ze,Boxes:C,PackagePlus:_e,FileText:me};function pl(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var ml=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function hl(){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),c=A(e=>e.clearNotifications),l=A(e=>e.requestBrowserNotifications),u=t>0?x:p;function d(e){i({notificationSettings:{...n,...e}})}return(0,B.jsxs)(ol,{onOpenChange:e=>{e&&o()},children:[(0,B.jsx)(sl,{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)(u,{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)(cl,{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)(ul,{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)(s,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(`button`,{type:`button`,title:`Clear`,onClick:c,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,B.jsx)(Me,{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)(W,{size:`sm`,checked:n.enabled,onCheckedChange:e=>d({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)(W,{size:`sm`,checked:n.browserEnabled&&r===`granted`,disabled:r===`unsupported`,onCheckedChange:e=>{e&&r!==`granted`?l():d({browserEnabled:e})}})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:ml.map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>d({[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)(dl,{}),(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)(ll,{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:pl(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 gl(){let e=A(e=>e.theme),t=A(e=>e.set);return(0,B.jsxs)(ol,{children:[(0,B.jsx)(sl,{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)(h,{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:on.find(t=>t.id===e)?.label})]})}),(0,B.jsx)(cl,{align:`start`,side:`right`,className:`w-40`,children:on.map(n=>(0,B.jsxs)(ll,{onSelect:()=>t({theme:n.id}),children:[(0,B.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,B.jsx)(ce,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function _l(){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=Xc(),f=Zc();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:Yt.map(n=>{let r=fl[n.icon]||w;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)(Fe,{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)(hl,{}),(0,B.jsx)(gl,{}),(0,B.jsx)(al,{}),(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)(W,{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)(W,{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)(W,{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 vl(){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)(b,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,B.jsx)(_l,{})]})}function yl(){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)(b,{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)(Pe,{className:`w-4 h-4`})})]}),(0,B.jsx)(_l,{})]})]})}var bl=500*1024,xl={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`},Sl={".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`},Cl=null;function wl(){return Cl??=R(()=>import(`./bundle-web-BLavPdXe.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),Cl}function Tl(e){return new TextEncoder().encode(e).length}function El(e){return e.split(`/`).filter(Boolean).pop()||e}function Dl(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 Ol(e,t,n,r){if(n)return n;let i=El(e).toLowerCase();if(Sl[i])return Sl[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=Dl(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&xl[o]?xl[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 kl(e,t,n,r){let i=Ol(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var Al=(0,z.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=A(e=>e.theme),o=on.find(e=>e.id===a)?.dark??!0,s=(0,z.useMemo)(()=>Ol(t,n,r,e)||`text`,[e,r,n,t]),c=Tl(e)>bl,[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(!1);function h(){return(0,B.jsx)(In,{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),wl().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)(Ae,{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}})]})}),jl=(0,z.lazy)(()=>R(()=>import(`./markdown-preview-impl-BPW4OQo9.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function Ml(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)(jl,{...e})})}var Nl=e(pt(),1);function Pl({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)(He,{className:`h-4 w-4`}):(0,B.jsx)(Je,{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)(Pe,{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 Fl({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,Nl.createPortal)((0,B.jsx)(Pl,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var Il=`agent-relay:file-git-status`;function Ll(){try{return window.localStorage.getItem(Il)!==`off`}catch{return!0}}function Rl(e){try{window.localStorage.setItem(Il,e?`on`:`off`)}catch{}}function zl(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 G(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function Bl({status:e}){let t=zl(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 K(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function q(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function J(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function Vl(e,t,n){return J(e,t)?`markdown`:kl(e,t,void 0,n)?`code`:null}function Hl(e){return`agent-relay:file-view-mode:${e}`}function Ul(e){try{let t=window.localStorage.getItem(Hl(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function Wl(e,t){try{window.localStorage.setItem(Hl(e),t)}catch{}}function Gl(e,t){let n=q(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 Kl(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(yt(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function ql(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`,G(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(yt(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function Jl({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 Yl({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:o,error:s}=ql(e,t,r);return(0,z.useEffect)(()=>{n(s)},[s,n]),t?o?(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Ae,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):s?(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)(ee,{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`?ee:a,n=zl(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)(Ne,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(Bl,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:K(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 Xl({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:o,error:s}=Kl(e,t),c=(0,z.useRef)(null),[l,u]=(0,z.useState)(`raw`);(0,z.useEffect)(()=>{r(s)},[s,r]),(0,z.useEffect)(()=>{n>0&&c.current?.scrollIntoView({block:`center`})},[i,n]),(0,z.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){u(`raw`);return}let e=Vl(i.path,i.mediaType,i.content);u(e?Ul(e):`raw`)},[i?.path,i?.encoding,i?.mediaType,i?.content,n]);function d(e,t){u(e),t&&Wl(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(o)return(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Ae,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(s)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)(a,{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)(In,{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:K(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)(Fl,{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:K(i.size)})]})]});let f=i.content??``,p=J(i.path,i.mediaType),m=!p&&kl(i.path,i.mediaType,void 0,f),h=p||m,g=p?`markdown`:m?`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)(a,{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)(In,{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:K(i.size)}),h&&(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 ${l===`raw`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>d(`raw`,g),children:`Raw`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${l===`rendered`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>d(`rendered`,g),children:p?`Rendered`:`Highlighted`})]})]}),l===`rendered`&&p&&(0,B.jsx)(Ml,{content:f,path:i.path}),l===`rendered`&&m&&(0,B.jsx)(Al,{content:f,path:i.path,mediaType:i.mediaType}),l===`raw`&&(0,B.jsx)(Jl,{content:f,line:n,lineRef:c})]})}function Zl({overlay:e=!1}){let t=A(e=>e.apiCall),n=A(e=>e.orchestrators),o=A(e=>e.fileOrchestratorId),s=A(e=>e.filePath),c=A(e=>e.fileSelectedPath),l=A(e=>e.fileSelectedLine),u=A(e=>e.set),d=A(e=>e.closeFileOverlay),p=A(e=>e.openOrchestratorSpawnAt),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)(s),[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(``),[S,C]=(0,z.useState)(``),[te,ne]=(0,z.useState)(Ll),re=(0,z.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),w=n.find(e=>e.id===o)||re[0];(0,z.useEffect)(()=>{if(!w)return;let e={};o||(e.fileOrchestratorId=w.id),s||(e.filePath=w.baseDir),Object.keys(e).length&&u(e)},[o,s,w,u]),(0,z.useEffect)(()=>_(s),[s]);async function ae(e=s){if(!(!w||!e)){y(!0),x(``);try{let n=await t(`GET`,G(w.id,e,te));h(n),u({filePath:n.path}),_(n.path),C(``)}catch(e){x(yt(e))}finally{y(!1)}}}(0,z.useEffect)(()=>{ae(s)},[w?.id,s,te]);function oe(e){ne(e),Rl(e)}function se(e){u({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function T(e){C(``),e.type===`directory`?u({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):u({fileSelectedPath:e.path,fileSelectedLine:0})}function E(){if(!w)return;let t=g.trim()||s||w.baseDir;e&&d(),p({orchestratorId:w.id,cwd:t})}let ce=m?Gl(m.path,m.baseDir):[],le=b||S;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 ${c?`hidden md:flex`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,B.jsx)(ie,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,B.jsxs)(`select`,{value:w?.id||``,onChange:e=>se(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[re.length===0&&(0,B.jsx)(`option`,{value:``,children:`No online orchestrators`}),re.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:d,title:`Close`,children:(0,B.jsx)(Pe,{className:`h-4 w-4`})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${c?`hidden md:flex`:``}`,children:[(0,B.jsx)(L,{value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u({filePath:g,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:w?.baseDir||`Path`}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>ae(g),disabled:v||!w,children:[v?(0,B.jsx)(Ae,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(f,{className:`h-3.5 w-3.5`}),`Open`]}),(0,B.jsxs)(I,{size:`sm`,className:`gap-1`,onClick:E,disabled:!w,children:[(0,B.jsx)(i,{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)(r,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,B.jsx)(W,{checked:te,onCheckedChange:oe})]})]}),ce.length>0&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${c?`hidden md:flex`:``}`,children:ce.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:()=>u({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}),children:[e.label,t<ce.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),le&&(0,B.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:le}),(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)] ${c?``:`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 ${c?`hidden md:block`:``}`,children:[m?.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:()=>u({filePath:m.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(Qe,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{children:`Parent directory`})]}),m?.entries.map(e=>{let t=c===e.path||s===e.path,n=e.type===`directory`?ee:a,r=zl(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:()=>T(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)(Ne,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(Bl,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:K(e.size)})]},e.path)}),!v&&m&&m.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 ${c?``:`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:()=>u({fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(Qe,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(Xl,{orchestratorId:w?.id||``,selectedPath:c,line:l,onReadError:C})})]})]})]})}function Ql(){return(0,B.jsx)(Zl,{})}function $l(){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)(Zl,{overlay:!0})})}):null}function eu(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 tu({...e}){return eu(e.open,e.onOpenChange),(0,B.jsx)(Mr,{"data-slot":`sheet`,...e})}function nu({...e}){return(0,B.jsx)(Nr,{"data-slot":`sheet-portal`,...e})}function ru({className:e,...t}){return(0,B.jsx)(Pr,{"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 iu({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,B.jsxs)(nu,{children:[(0,B.jsx)(ru,{}),(0,B.jsxs)(Fr,{"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)(Rr,{"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)(Pe,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function au({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 ou({className:e,...t}){return(0,B.jsx)(Ir,{"data-slot":`sheet-title`,className:O(`font-heading text-base font-medium text-foreground`,e),...t})}function su({className:e,orientation:t=`horizontal`,...n}){return(0,B.jsx)(Xs,{"data-slot":`tabs`,"data-orientation":t,className:O(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var cu=dn(`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 lu({className:e,variant:t=`default`,...n}){return(0,B.jsx)(Zs,{"data-slot":`tabs-list`,"data-variant":t,className:O(cu({variant:t}),e),...n})}function uu({className:e,...t}){return(0,B.jsx)(Qs,{"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 du({className:e,...t}){return(0,B.jsx)($s,{"data-slot":`tabs-content`,className:O(`flex-1 text-sm outline-none`,e),...t})}function fu({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`,Ot(e,t),n)})}function pu({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 mu({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 hu={claude:pu,anthropic:pu,codex:mu,openai:mu},gu={claude:`text-orange-400`,anthropic:`text-orange-400`};function _u({provider:e,className:t}){let n=e.toLowerCase(),r=hu[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(gu[n],t)})}):(0,B.jsx)(`span`,{className:`capitalize`,children:e})}var vu={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`},yu={codex:je,claude:pu,user:et,system:c,channel:De,agent:w};function bu({agent:e,className:t}){let n=Jt(e),r=yu[n]||w;return(0,B.jsx)(`span`,{className:O(`inline-flex items-center justify-center w-5 h-5 rounded-md border text-sm`,vu[n]||vu.agent,t),children:(0,B.jsx)(r,{className:`w-3.5 h-3.5`})})}function xu({agent:e,compact:t=!1}){let n=ju(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 Su({agent:e,compact:t=!1,className:n=``}){let r=wu(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 Cu({agent:e}){let t=e.context;if(!t)return null;let n=Pu(t);if(n===null)return(0,B.jsxs)(`div`,{className:`space-y-1`,title:Fu(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:Fu(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 wu(e){let t=Tu(e),n=Eu(e),r=Du(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?re:Re,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 Tu(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Eu(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:Ee,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:y,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:rt,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Du(e){let t=Ou(e.meta?.workspace),n=St(t.requestedMode)||St(e.meta?.workspaceMode),i=St(t.mode),a=n&&n!==`inherit`?n:i&&n!==`inherit`?i:`default`;return a===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:r,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:a===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:ot,iconColor:`text-cyan-300`,className:`border-cyan-500/30 bg-cyan-500/10 text-cyan-300`}:{key:`workspace`,label:`Default`,title:i?`Workspace: default/inherit, resolved to ${i}`:`Workspace: default/inherit`,Icon:ut,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function Ou(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function ku(e){let t=Ou(e.meta?.workspace),n=St(t.repoRoot)||St(t.sourceCwd)||St(e.meta?.cwd);return n?Pt(n,2):``}function Au(e){return!!(e.context||e.providerCapabilities?.context)}function ju(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=$t(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=Pu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function Mu({context:e,expected:t=!!e,size:n=26,className:r}){let i=Pu(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:Fu(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 Nu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${Iu(t.tokensUsed)} / ${Iu(t.tokensMax)}`:t.tokensUsed?Iu(t.tokensUsed):t.tokensMax?Iu(t.tokensMax):null}function Pu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function Fu(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=Pu(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 Iu(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var Lu=(0,z.lazy)(()=>R(()=>import(`./terminal-viewer-impl-DgMuRAe_.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13,14]),import.meta.url));function Ru(e){return e.open?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(Lu,{...e})}):null}function zu({orchestratorId:e,session:t,lines:r=200}){let i=A(e=>e.apiCall),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[f,p]=(0,z.useState)(`provider`),[m,h]=(0,z.useState)(null);async function g(){if(!l)try{o((await i(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${r}${f===`mirror`?`&stream=mirror`:``}`)).lines||[]),h(null)}catch(e){h(yt(e))}}(0,z.useEffect)(()=>{g();let e=setInterval(()=>void g(),1500);return()=>clearInterval(e)},[e,t,l,f]);let _=s?a.filter(e=>e.toLowerCase().includes(s.toLowerCase())):a;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)(Le,{className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground`}),(0,B.jsx)(L,{className:`pl-8`,value:s,onChange:e=>c(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)(je,{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)(n,{className:`h-3.5 w-3.5`}),` Mirror`]})]}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>u(e=>!e),title:l?`Resume logs`:`Pause logs`,children:l?(0,B.jsx)(d,{className:`h-4 w-4`}):(0,B.jsx)(v,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>Xt(`${t}.log`,a.join(`
|
|
16
16
|
`),`text/plain`),title:`Download logs`,children:(0,B.jsx)(se,{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 Bu(e,t){let n=t?.meta?.busyHealth;if(!t||t.status!==`busy`||!xt(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 Vu={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 Hu({agent:e,orchestrators:t}){let n=gt(),[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=xt(e.meta?.agentProfile)?e.meta.agentProfile:null,f=Wu(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 oe(`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 oe(`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)(it,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Diagnostics`]}),(0,B.jsx)(In,{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)(Uu,{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)(Y,{label:`Provider`,value:_.provider}),_.model&&(0,B.jsx)(Y,{label:`Model`,value:_.model}),_.effort&&(0,B.jsx)(Y,{label:`Effort`,value:_.effort}),(0,B.jsx)(Y,{label:`Permission`,value:_.permissionMode}),(0,B.jsx)(Y,{label:`Mode`,value:_.mode}),_.rig&&(0,B.jsx)(Y,{label:`Rig`,value:_.rig}),(0,B.jsx)(Y,{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)(Y,{label:`Provider Args`,value:_.providerArgs.join(` `),className:`col-span-2`,mono:!0}),_.binding&&(0,B.jsx)(Y,{label:`Channel`,value:`${_.binding.type}:${_.binding.channelId}`,className:`col-span-2`})]})}),(u||f)&&(0,B.jsx)(Uu,{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)(Y,{label:`Profile`,value:u}),f?.base&&(0,B.jsx)(Y,{label:`Base`,value:f.base}),f?.provider&&(0,B.jsx)(Y,{label:`Provider`,value:f.provider}),f&&(0,B.jsx)(Y,{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)(Uu,{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)(Y,{label:`Mode`,value:m.workspace.mode}),m.workspace.status&&(0,B.jsx)(Y,{label:`Status`,value:m.workspace.status}),m.workspace.worktreePath&&(0,B.jsx)(Y,{label:`Worktree`,value:m.workspace.worktreePath,className:`col-span-2`,mono:!0}),m.workspace.repoRoot&&(0,B.jsx)(Y,{label:`Repo`,value:m.workspace.repoRoot,className:`col-span-2`,mono:!0}),m.workspace.branch&&(0,B.jsx)(Y,{label:`Branch`,value:m.workspace.branch,className:`col-span-2`,mono:!0}),m.workspace.baseRef&&(0,B.jsx)(Y,{label:`Base`,value:m.workspace.baseRef}),m.workspace.baseSha&&(0,B.jsx)(Y,{label:`Base SHA`,value:m.workspace.baseSha.slice(0,12),mono:!0}),m.workspace.stewardAgentId&&(0,B.jsx)(Y,{label:`Steward`,value:m.workspace.stewardAgentId,className:`col-span-2`,mono:!0})]})}),m&&(0,B.jsx)(Uu,{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)(Y,{label:`PID`,value:String(m.pid),mono:!0}),m.sessionName&&(0,B.jsx)(Y,{label:`Session`,value:m.sessionName,mono:!0}),m.supervisor&&(0,B.jsx)(Y,{label:`Supervisor`,value:m.supervisor}),m.systemdUnit&&(0,B.jsx)(Y,{label:`Systemd`,value:m.systemdUnit,mono:!0}),m.terminalSession&&(0,B.jsx)(Y,{label:`Terminal`,value:`${m.terminalSession} (${m.terminalAvailable?`available`:`unavailable`})`,mono:!0}),m.tmuxSession&&m.tmuxSession!==m.sessionName&&(0,B.jsx)(Y,{label:`Legacy tmux`,value:m.tmuxSession,mono:!0}),m.spawnRequestId&&(0,B.jsx)(Y,{label:`Spawn ID`,value:m.spawnRequestId.slice(0,12),mono:!0}),m.startedAt&&(0,B.jsx)(Y,{label:`Started`,value:Vt(m.startedAt)}),p&&(0,B.jsx)(Y,{label:`Orchestrator`,value:`${p.hostname} (${p.id.slice(-8)})`}),p&&(0,B.jsx)(Y,{label:`Orch Status`,value:p.status})]})}),v&&(0,B.jsx)(Uu,{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:Vu[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)(Y,{label:`Restarts`,value:String(v.restartCount)}),(0,B.jsx)(Y,{label:`Failures`,value:String(v.consecutiveFailures)}),v.lastSpawnAt&&(0,B.jsx)(Y,{label:`Last spawn`,value:j(n,v.lastSpawnAt)}),v.lastStopAt&&(0,B.jsx)(Y,{label:`Last stop`,value:j(n,v.lastStopAt)}),v.healthySince&&(0,B.jsx)(Y,{label:`Healthy since`,value:j(n,v.healthySince)}),v.backoffUntil&&(0,B.jsx)(Y,{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)(Uu,{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 Uu({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)(ct,{className:`w-3 h-3`}):(0,B.jsx)(lt,{className:`w-3 h-3`}),e]}),t&&(0,B.jsx)(`div`,{className:`px-2.5 pb-2.5`,children:r})]})}function Wu(e){return xt(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 Y({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 Gu({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)(C,{className:`h-3 w-3 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:i.title||i.slug})]}):null}function X({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 Ku={github:X},qu=Ke;function Ju({provider:e,className:t}){return(0,B.jsx)(Ku[e]??qu,{className:O(`shrink-0`,t)})}var Yu={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`},Xu=1440*60*1e3;function Zu(e){return`${e.repo}#${e.externalKey}`}function Qu(e,t){return e.statusSyncedAt?`Status synced ${j(t,e.statusSyncedAt)} (${Vt(e.statusSyncedAt)})`:`Status not yet synced`}function $u({issueRef:e,now:t=Date.now(),compact:n=!1,showSync:r=!1,className:i}){let a=Zu(e),o=!e.statusSyncedAt||t-e.statusSyncedAt>Xu,s=[e.title?`${a}: ${e.title}`:a,`Status: ${e.status}`,Qu(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`,Yu[e.status],i),children:[(0,B.jsx)(Ju,{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)(_,{className:`ml-0.5 h-2.5 w-2.5 shrink-0 opacity-60`})]})}var ed={read:`read`,edit:`edited`,done:`completed`},td={done:`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`},nd=[];function rd(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 id({agentId:e,now:t}){let n=A(e=>e.fetchAgentIssueActivity),r=A(t=>t.issueActivityByAgent[e]??nd),i=A(e=>e.issueRefsById),a=A(t=>!!t.issueLoading[`agent:${e}`]),o=A(t=>t.issueErrors[`agent:${e}`]??null),s=(0,z.useMemo)(()=>rd(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)(al,{}),(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)($u,{issueRef:e.issueRef,now:t}),(0,B.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,title:Vt(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]`,td[e.action]),title:`${e.count} event${e.count===1?``:`s`} since ${Vt(e.firstAt)}`,children:[ed[e.action],e.count>1?` ${e.count}`:``]},e.action))})]},e.issueRef.id))})]})]})}function ad(e){let t=e?.meta?.tmuxSession;return typeof t==`string`&&t.trim()?t:null}function od(e,t,n){return e?n.find(n=>n.managedAgents.some(n=>n.agentId===e.id||n.tmuxSession===t))??null:null}function sd({agent:e,health:t,showLogs:n,setTab:r,openConfirm:i,doAgentAction:a}){let o=Lt(e,`interrupt`),s=Lt(e,`restart`),c=Lt(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)(Be,{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)(tt,{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)(S,{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)(T,{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)(me,{className:`w-3 h-3 mr-1`}),`Diagnostics`]})]})]})}function cd(e){return!e||e.status!==`offline`&&e.status!==`stale`?!1:!!(typeof e.meta?.provider==`string`?e.meta.provider:e.providerCapabilities?.model?.provider)}function ld(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 ud(e,t){return!!e.spawnedBy&&e.status!==`offline`&&!nn(t,e)}function dd(e,t){let n=new Map;for(let r of e){if(!r.spawnedBy||!ud(r,t))continue;let e=n.get(r.spawnedBy);e?e.push(r):n.set(r.spawnedBy,[r])}return n}function fd(e,t,n){let r=new Set(e.map(e=>e.id)),i=dd(e,n),a=[],o=new Set;for(let s of e){if(o.has(s.id)||s.spawnedBy&&!ud(s,n))continue;let e=!!(s.spawnedBy&&r.has(s.spawnedBy));if(ud(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 pd(e,t){let n=new Set(e.map(e=>e.id));return e.filter(e=>e.spawnedBy&&!ud(e,t)?!1:!ud(e,t)||!e.spawnedBy||!n.has(e.spawnedBy))}function md(e){return[...e].sort((e,t)=>M(e).localeCompare(M(t)))}function hd(){let e=A(e=>e.agentDetailOpen),t=A(e=>e.agentDetailId),n=A(e=>e.agentsById),r=A(e=>e.messages),i=A(e=>e.orchestrators),a=A(e=>e.fetchOrchestrators),o=gt(),s=A(e=>e.set),c=A(e=>e.closeAgentDetail),l=A(e=>e.openAgentDetail),d=A(e=>e.openComposeToAgent),p=A(e=>e.openInboxThread),m=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),b=A(e=>e.doAgentAction),x=A(e=>e.doDeleteAgent),C=A(e=>e.openFilesForAgent),[ee,ne]=(0,z.useState)([]),[re,w]=(0,z.useState)(null),[ie,se]=(0,z.useState)(null),[E,ce]=(0,z.useState)(`overview`),[le,ue]=(0,z.useState)(!1),[de,D]=(0,z.useState)(null),[pe,he]=(0,z.useState)(!1),[_e,O]=(0,z.useState)(null),ye=A(e=>e.livenessMismatches),xe=A(e=>e.commandStalls),k=n[t]||null,Se=Wc(),Ce=k?Se[k.id]??null:null,we=(0,z.useMemo)(()=>Object.values(n),[n]),Te=(0,z.useMemo)(()=>t?r.filter(e=>e.from===t||e.to===t).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,t]);(0,z.useEffect)(()=>{if(!e||!k?.context){ne([]);return}let t=!1;return oe(`GET`,`/agents/`+encodeURIComponent(k.id)+`/context-snapshots?limit=24`).then(e=>{t||ne(e)}).catch(()=>{t||ne([])}),()=>{t=!0}},[e,k?.id,k?.context?.lastUpdatedAt]),(0,z.useEffect)(()=>{if(O(null),!e||!k||!cd(k))return;let t=!1;return oe(`GET`,`/agents/`+encodeURIComponent(k.id)+`/timeline?limit=50`).then(e=>{t||O(ld(e))}).catch(()=>{t||O(null)}),()=>{t=!0}},[e,k?.id,k?.status,k?.meta?.provider]),(0,z.useEffect)(()=>{if(!e||!k){w(null);return}let t=!1;return oe(`GET`,`/agents/`+encodeURIComponent(k.id)+`/active-memories`).then(e=>{t||w(e)}).catch(()=>{t||w(null)}),()=>{t=!0}},[e,k?.id]),(0,z.useEffect)(()=>{if(!e||!k){se(null);return}let t=!1;return oe(`GET`,`/agents/`+encodeURIComponent(k.id)+`/crash-report`).then(e=>{t||se(e.report)}).catch(()=>{t||se(null)}),()=>{t=!0}},[e,k?.id]),(0,z.useEffect)(()=>{ce(`overview`),ue(!1),D(null)},[t]),(0,z.useEffect)(()=>{e&&k?.meta?.tmuxSession&&i.length===0&&a()},[e,k?.id,k?.meta?.tmuxSession,i.length]);async function Ee(){if(k)try{if(!(await oe(`DELETE`,`/agents/`+encodeURIComponent(k.id)+`/active-memories`)).supported){v(`Memory Clear Unavailable`,`The active memory broker does not support clearing active memories.`);return}w({agentId:k.id,supported:!0,memories:[],total:0}),y(`Active memories cleared`)}catch(e){v(`Memory Clear Failed`,e.message)}}async function De(){if(!(!k||pe)){he(!0);try{D(await oe(`POST`,`/agents/`+encodeURIComponent(k.id)+`/terminal-session`)),ue(!0)}catch(e){v(`Terminal Failed`,e.message)}finally{he(!1)}}}async function Oe(e){if(e){ue(!0);return}ue(!1);let t=de;if(D(null),k&&t?.mode===`guest`)try{await oe(`DELETE`,`/agents/`+encodeURIComponent(k.id)+`/terminal-session/`+encodeURIComponent(t.session))}catch{}}if(!k)return(0,B.jsx)(tu,{open:e,onOpenChange:e=>!e&&c(),children:(0,B.jsx)(iu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg`,children:(0,B.jsx)(au,{children:(0,B.jsx)(ou,{children:`Agent`})})})});let Ae=Ht(o,k,Kt(),Ce),Ne=Lt(k,`restart`),Pe=Lt(k,`shutdown`),Fe=Lt(k,`reconnect`),Le=Lt(k,`compact`),Re=Lt(k,`clearContext`),He=!!(_e&&cd(k)),Ue=qt(k),We=Cd(k.meta?.package),Ge=wd(k.meta?.contracts),Ke=k.providerCapabilities,qe=wt(k),Je=Nu(k),Ye=$t(k),Xe=ad(k),Ze=Xe?od(k,Xe,i):null,Qe=!!(Xe&&Ze?.status===`online`&&k.providerCapabilities?.terminal?.live?.read),et=!!(Qe&&k.providerCapabilities?.terminal?.live?.write),tt=k.providerCapabilities?.terminal?.attach?.create===!0,nt=Qe||tt,rt=Dd(k.meta?.lastExit),it=typeof k.meta?.lastError==`string`?k.meta.lastError:rt?.lastError,at=k.spawnedBy?n[k.spawnedBy]??null:null,ot=md(dd(we,o).get(k.id)??[]),st=ye[k.id]??null,ct=(Ae.tone===`offline`||Ae.tone===`stale`)&&Qe,lt=!!st||ct,ut=xe[k.id]??null,dt=Bu(o,k);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(tu,{open:e,onOpenChange:e=>!e&&c(),children:(0,B.jsxs)(iu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,B.jsxs)(au,{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)(fu,{agent:k,now:o}),(0,B.jsx)(bu,{agent:k}),(0,B.jsx)(ou,{className:`text-base truncate`,children:M(k)}),Au(k)&&(0,B.jsx)(Mu,{context:k.context,expected:!0})]}),(0,B.jsx)(Su,{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),c()},children:[(0,B.jsx)(te,{className:`w-3 h-3 mr-1`}),`Message`]}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,onClick:()=>{p(k.id),g(`chat`),c()},children:[(0,B.jsx)($e,{className:`w-3 h-3 mr-1`}),`Chat`]}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,onClick:()=>{h(k.id),c()},children:[(0,B.jsx)(Ve,{className:`w-3 h-3 mr-1`}),`Pair`]}),nt&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,disabled:pe,title:tt?`Open guest terminal`:`Open live terminal`,onClick:()=>void De(),children:(0,B.jsx)(je,{className:`w-3.5 h-3.5`})}),He&&(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 ${_e?.resumeId}? This can reload a large prior context and consume tokens.`,()=>b(k,`resume`,`agent-detail-drawer`)),children:(0,B.jsx)(ke,{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)}?`,()=>b(k,`compact`,`agent-detail-drawer`)),children:(0,B.jsx)(ae,{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)}?`,()=>b(k,`restart`,`agent-detail-drawer`)),children:(0,B.jsx)(S,{className:`w-3.5 h-3.5`})}),Pe&&(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`hidden sm:inline-flex px-2`,title:`Shutdown`,onClick:()=>_(`Shutdown Agent`,`Shutdown ${M(k)}?`,()=>b(k,`shutdown`,`agent-detail-drawer`)),children:(0,B.jsx)(T,{className:`w-3.5 h-3.5`})}),(0,B.jsxs)(ol,{children:[(0,B.jsx)(sl,{asChild:!0,children:(0,B.jsx)(I,{size:`sm`,variant:`outline`,className:`px-2`,children:(0,B.jsx)(ge,{className:`w-3.5 h-3.5`})})}),(0,B.jsxs)(cl,{align:`end`,children:[nt&&(0,B.jsxs)(ll,{className:`sm:hidden`,disabled:pe,onClick:()=>void De(),children:[(0,B.jsx)(je,{className:`w-3.5 h-3.5`}),`Terminal`]}),He&&(0,B.jsxs)(ll,{className:`sm:hidden`,onClick:()=>_(`Resume Session`,`Resume ${M(k)} from session ${_e?.resumeId}? This can reload a large prior context and consume tokens.`,()=>b(k,`resume`,`agent-detail-drawer`)),children:[(0,B.jsx)(ke,{className:`w-3.5 h-3.5`}),`Resume`]}),Le&&(0,B.jsxs)(ll,{className:`sm:hidden`,onClick:()=>_(`Compact Agent`,`Compact context for ${M(k)}?`,()=>b(k,`compact`,`agent-detail-drawer`)),children:[(0,B.jsx)(ae,{className:`w-3.5 h-3.5`}),`Compact`]}),Ne&&(0,B.jsxs)(ll,{className:`sm:hidden`,onClick:()=>_(`Restart Agent`,`Restart ${M(k)}?`,()=>b(k,`restart`,`agent-detail-drawer`)),children:[(0,B.jsx)(S,{className:`w-3.5 h-3.5`}),`Restart`]}),Pe&&(0,B.jsxs)(ll,{className:`sm:hidden`,onClick:()=>_(`Shutdown Agent`,`Shutdown ${M(k)}?`,()=>b(k,`shutdown`,`agent-detail-drawer`)),children:[(0,B.jsx)(T,{className:`w-3.5 h-3.5`}),`Shutdown`]}),(nt||He||Le||Ne||Pe)&&(0,B.jsx)(dl,{className:`sm:hidden`}),(0,B.jsxs)(ll,{onClick:()=>m(k),children:[(0,B.jsx)(u,{className:`w-3.5 h-3.5`}),`Rename`]}),Fe&&(0,B.jsxs)(ll,{onClick:()=>_(`Reconnect Agent`,`Reconnect ${M(k)}?`,()=>b(k,`reconnect`,`agent-detail-drawer`)),children:[(0,B.jsx)(f,{className:`w-3.5 h-3.5`}),`Reconnect`]}),Re&&(0,B.jsxs)(ll,{onClick:()=>_(`Clear Context`,`Clear context for ${M(k)}?`,()=>b(k,`clearContext`,`agent-detail-drawer`)),children:[(0,B.jsx)(ve,{className:`w-3.5 h-3.5`}),`Clear Context`]}),Ue&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(dl,{}),(0,B.jsxs)(ll,{variant:`destructive`,onClick:()=>_(`Forget Agent`,`Forget ${M(k)}?`,()=>x(k.id)),children:[(0,B.jsx)(Me,{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)(Be,{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.`}),nt&&(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`mt-2 h-7 text-xs`,disabled:pe,onClick:()=>void De(),children:[(0,B.jsx)(je,{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)(Be,{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}),nt&&(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`mt-2 h-7 text-xs`,disabled:pe,onClick:()=>void De(),children:[(0,B.jsx)(je,{className:`w-3 h-3 mr-1`}),`Open terminal`]})]}),dt&&(0,B.jsx)(sd,{agent:k,health:dt,showLogs:!!Xe,setTab:ce,openConfirm:_,doAgentAction:b}),(0,B.jsxs)(su,{value:E,onValueChange:e=>ce(e),className:`flex-1 min-h-0 gap-0`,children:[(0,B.jsxs)(lu,{variant:`line`,className:`w-full shrink-0 px-4 pt-2`,children:[(0,B.jsx)(uu,{value:`overview`,children:`Overview`}),(0,B.jsxs)(uu,{value:`timeline`,children:[(0,B.jsx)(fe,{className:`w-3.5 h-3.5`}),`Timeline`]}),(0,B.jsxs)(uu,{value:`logs`,children:[(0,B.jsx)(me,{className:`w-3.5 h-3.5`}),`Logs`]})]}),(0,B.jsx)(du,{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:kt(Ae.tone),children:Ae.label})]}),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)(be,{className:`w-3.5 h-3.5`}),`Recommended action`]}),(0,B.jsx)(`div`,{className:`mt-1 text-red-100/80`,children:qe.recommendedAction})]}),it&&(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)(be,{className:`w-3.5 h-3.5`}),`Last launch error`]}),(0,B.jsx)(`div`,{className:`mt-1 break-words text-amber-50/85`,children:it}),rt&&(0,B.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-amber-50/70`,children:[rt.detectedAt&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-amber-100/55`,children:`Detected`}),(0,B.jsx)(`div`,{children:j(o,rt.detectedAt)})]}),typeof rt.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(rt.runtimeMs/1e3)),`s`]})]}),rt.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:rt.systemd.unit})]}),rt.systemd&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-amber-100/55`,children:`Systemd`}),(0,B.jsx)(`div`,{children:[rt.systemd.activeState,rt.systemd.subState].filter(Boolean).join(`/`)||`unknown`})]}),rt.systemd?.result&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-amber-100/55`,children:`Result`}),(0,B.jsx)(`div`,{children:rt.systemd.result})]}),rt.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:[rt.logFile,` (`,rt.logBytes??`unknown`,` bytes`,rt.logEmpty?`, empty`:``,`)`]})]})]}),rt?.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:rt.logTail.slice(-5).join(`
|
|
20
20
|
`)}):null,rt?.unavailable?.length?(0,B.jsx)(`div`,{className:`mt-1 text-amber-50/55`,children:rt.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(o,k.lastSeen)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Created`}),(0,B.jsx)(`div`,{title:Vt(k.createdAt),children:j(o,k.createdAt)})]})]})]})]}),ie&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(al,{}),(0,B.jsx)(Ed,{report:ie,now:o})]}),k.context&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(al,{}),(0,B.jsx)(yd,{context:k.context,tokens:Je,history:ee,now:o})]}),(0,B.jsx)(id,{agentId:k.id,now:o}),(k.spawnedBy||ot.length>0||Ce)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(al,{}),(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:!at,onClick:()=>at&&l(at),children:at?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(fu,{agent:at,now:o}),(0,B.jsx)(bu,{agent:at}),(0,B.jsx)(`span`,{className:`truncate font-medium`,children:M(at)})]}):(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:()=>l(e),children:[(0,B.jsx)(fu,{agent:e,now:o}),(0,B.jsx)(bu,{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)(ze,{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)(al,{}),(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(o,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))})]})]})]})]}),re&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(al,{}),(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:[re.supported&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:re.memories.length}),re.supported&&re.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)}?`,Ee),children:[(0,B.jsx)(ve,{className:`w-3 h-3`}),`Clear`]})]})]}),re.supported?re.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:re.memories.map(e=>(0,B.jsx)(gd,{memory:e,now:o,onOpen:()=>{s({selectedMemoryId:e.id}),g(`memory`),c()}},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)(al,{}),(0,B.jsx)(Hu,{agent:k,orchestrators:i})]}),(0,B.jsx)(al,{}),(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)(vd,{label:`Agent ID`,value:k.id,copyLabel:`Copy agent ID`}),typeof k.meta?.cwd==`string`&&k.meta.cwd&&(0,B.jsx)(vd,{label:`Working dir`,value:k.meta.cwd,copyLabel:`Copy working dir`,title:`Open ${k.meta.cwd} in Files`,onClick:()=>{c(),C(k)}}),(0,B.jsx)(Gu,{agent:k,onNavigate:c}),(k.machine||k.rig||We)&&(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})]}),We&&(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:[We.name,` v`,We.version]})]})]}),Ge.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:Ge.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))})]}),It(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:It(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)(al,{}),(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:Bt(e.from,n)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,B.jsx)(`span`,{className:`truncate max-w-[40%]`,children:Bt(e.to,n)}),(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(o,e.createdAt)]})]}),(0,B.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:Wt(e)})]},e.id))})]})]})]})}),(0,B.jsx)(du,{value:`timeline`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:(0,B.jsx)(Z,{agentId:k.id,open:e&&E===`timeline`,now:o})}),(0,B.jsx)(du,{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)(zu,{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.`})})]})]})}),de&&(0,B.jsx)(Ru,{open:le,onOpenChange:e=>void Oe(e),orchestratorId:de.orchestratorId,session:de.session,interactive:de.interactive||et})]})}function gd({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:Vt(e.lastAccessedAt??e.updatedAt),children:j(t,e.lastAccessedAt??e.updatedAt)})]})})}function _d(e){return e>=.8?`text-red-400`:e>=.6?`text-yellow-400`:`text-emerald-400`}function vd({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)(In,{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 yd({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`:_d(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)(bd,{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 bd({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=_d(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 Z({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 oe(`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)(f,{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)(Sd,{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 xd(e){return e.metadata?.mismatch===!0||e.metadata?.stalled===!0?(0,B.jsx)(Be,{className:`w-3.5 h-3.5 text-amber-400`}):e.source===`command`?(0,B.jsx)(je,{className:`w-3.5 h-3.5 text-sky-400`}):e.source===`delivery`?(0,B.jsx)(te,{className:`w-3.5 h-3.5 text-violet-400`}):e.kind===`state`?(0,B.jsx)(he,{className:`w-3.5 h-3.5 text-emerald-400`}):(0,B.jsx)(g,{className:`w-3.5 h-3.5 text-muted-foreground`})}function Sd({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:xd(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:Vt(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 Cd(e){return xt(e)&&typeof e.name==`string`&&typeof e.version==`string`?{name:e.name,version:e.version}:null}function wd(e){return xt(e)?Object.entries(e).filter(e=>typeof e[1]==`number`):[]}var Td={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 Ed({report:e,now:t}){let n=e.diagnosis,r=Td[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)(be,{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:Vt(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 Dd(e){if(!xt(e)||typeof e.lastError!=`string`)return null;let t=xt(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 Od({className:e,children:t,...n}){return(0,B.jsxs)(ps,{"data-slot":`scroll-area`,className:O(`relative`,e),...n,children:[(0,B.jsx)(ms,{"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)(kd,{}),(0,B.jsx)(hs,{})]})}function kd({className:e,orientation:t=`vertical`,...n}){return(0,B.jsx)(Vo,{"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)(Qo,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Ad(){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=gt(),o=A(e=>e.closeChannelDetail),s=n.find(e=>e.id===t)||null,c=Rt(s),l=(0,z.useMemo)(()=>s?r.filter(e=>Ut(e,s)).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,s]);return(0,B.jsx)(tu,{open:e,onOpenChange:e=>!e&&o(),children:(0,B.jsxs)(iu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,B.jsx)(au,{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:kt(c.tone),children:c.label}),(0,B.jsx)(ou,{className:`text-base truncate`,children:s?.name||`Channel`})]})}),(0,B.jsx)(Od,{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)})]})]})]}),It(s.capabilities).length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(al,{}),(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:It(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)(al,{}),(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)(al,{}),(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:Bt(e.from,i)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,B.jsx)(`span`,{className:`truncate max-w-[40%]`,children:Bt(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:Wt(e)})]},e.id))})]})]})]})})]})})}var jd=!1;function Md(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;jd=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(jd){jd=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,jd=!0,window.history.back())}},[e])}function Nd({...e}){return Md(e.open,e.onOpenChange),(0,B.jsx)(Mr,{"data-slot":`dialog`,...e})}function Pd({...e}){return(0,B.jsx)(Nr,{"data-slot":`dialog-portal`,...e})}function Fd({className:e,blur:t=!0,...n}){return(0,B.jsx)(Pr,{"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 Q({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,B.jsxs)(Pd,{children:[(0,B.jsx)(Fd,{blur:r}),(0,B.jsxs)(Fr,{"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)(Rr,{"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)(Pe,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function Id({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-header`,className:O(`flex flex-col gap-2`,e),...t})}function Ld({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)(Rr,{asChild:!0,children:(0,B.jsx)(I,{variant:`outline`,children:`Close`})})]})}function Rd({className:e,...t}){return(0,B.jsx)(Ir,{"data-slot":`dialog-title`,className:O(`font-heading text-base leading-none font-medium`,e),...t})}function zd({className:e,...t}){return(0,B.jsx)(Lr,{"data-slot":`dialog-description`,className:O(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Bd({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)(Ao,{"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})}function Vd(){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=$c();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,B.jsx)(Nd,{open:e,onOpenChange:e=>!e&&s(),children:(0,B.jsxs)(Q,{className:`max-w-lg`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(Bd,{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)(W,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,B.jsxs)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:s,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}function Hd(){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)(Nd,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(Id,{children:[(0,B.jsx)(Rd,{children:e.title}),(0,B.jsx)(zd,{children:e.message})]}),(0,B.jsxs)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function Ud(){let e=A(e=>e.errorModal),t=A(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,B.jsx)(Nd,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(Id,{children:[(0,B.jsx)(Rd,{children:e.title}),(0,B.jsx)(zd,{children:e.message})]}),(0,B.jsx)(Ld,{children:(0,B.jsx)(I,{onClick:n,children:`OK`})})]})})}function Wd(){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)(Nd,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:n,children:`Save`})]})]})})}function Gd(){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=$c();function o(e){n({pairInvite:{...t,...e}})}return(0,B.jsx)(Nd,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Create Pair`})]})]})})}function Kd(){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)(Nd,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(Bd,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,B.jsxs)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}var qd=(0,z.lazy)(()=>R(()=>import(`./formatted-body-impl-4v9SkUD1.js`).then(e=>({default:e.FormattedBody})),__vite__mapDeps([15,1,5,3,6,8,9,10]),import.meta.url));function Jd(e){return(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`span`,{className:e.className,children:e.text}),children:(0,B.jsx)(qd,{...e})})}function Yd(){let e=A(e=>e.threadOpen),t=A(e=>e.threadMessages),n=A(e=>e.agentsById),r=gt(),i=A(e=>e.set);return(0,B.jsx)(Nd,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,B.jsxs)(Q,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{children:[`Thread (`,t.length,` messages)`]})}),(0,B.jsx)(Od,{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:Bt(e.from,n)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:Bt(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)(Jd,{text:Wt(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 `,Bt(e.claimedBy,n)]})]})]},e.id))})})]})})}function Xd(){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)(Nd,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,B.jsxs)(Q,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{children:[`Task Events (`,t.length,`)`]})}),(0,B.jsx)(Od,{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:zt[e.severity]||zt.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)(Zd,{event:e,onOpen:i}),(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[Vt(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 Zd({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 Qd({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),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(``),[y,b]=(0,z.useState)(null),x=u?.path||i||``,S=(0,z.useMemo)(()=>x.split(`/`).filter(Boolean),[x]),C=(0,z.useCallback)(async e=>{if(r){c(!0),p(null),g(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;d(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){p(yt(e))}finally{c(!1)}}},[r,o]);(0,z.useEffect)(()=>{e&&r&&(d(null),p(null),g(!1),C(i||void 0))},[e,r]);async function te(){if(!(!_.trim()||!u)){b(null);try{d(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:u.path,name:_.trim()})),g(!1),v(``)}catch(e){b(yt(e))}}}function ne(){x&&(n(x),t(!1))}function re(e){C(`/`+S.slice(0,e+1).join(`/`))}return(0,B.jsx)(Nd,{open:e,onOpenChange:t,children:(0,B.jsxs)(Q,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{className:`flex items-center gap-2`,children:[(0,B.jsx)(m,{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:()=>u?.baseDir&&C(u.baseDir),children:`/`}),S.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:()=>re(t),children:e}),t<S.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)(Ae,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&f&&(0,B.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:f}),!s&&u&&(0,B.jsxs)(`div`,{className:`p-1`,children:[u.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:()=>C(u.parent),children:[(0,B.jsx)(Qe,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),u.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:()=>C(e.path),children:[(0,B.jsx)(ee,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),u.entries.length===0&&!u.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),u.entries.length===0&&u.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),h?(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(L,{autoFocus:!0,value:_,onChange:e=>{v(e.target.value),b(null)},onKeyDown:e=>{e.key===`Enter`&&te(),e.key===`Escape`&&(g(!1),v(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`outline`,onClick:te,disabled:!_.trim(),children:(0,B.jsx)(ce,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{g(!1),v(``),b(null)},children:(0,B.jsx)(Pe,{className:`h-4 w-4`})})]}):(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>g(!0),disabled:!u||s,children:[(0,B.jsx)(l,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),y&&(0,B.jsx)(`p`,{className:`text-xs text-destructive`,children:y}),(0,B.jsxs)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(I,{onClick:ne,disabled:!x,children:`Select`})]})]})})}function $d({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)(m,{className:`h-4 w-4`})}),n&&(0,B.jsx)(Qd,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function ef({model:e}){if(!e)return null;let t=tf(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 tf(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:nf(n),Icon:y}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:st}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:st}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:Se}),t}function nf(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function rf(){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),S=t.find(e=>e.id===n),C=S?.providers||[],ee=vt(r,x),te=ee.find(e=>e.alias===i),ne=te?.efforts||[],re=!!(S&&C.length>0&&s.trim())&&!h,w=t.filter(e=>e.status===`online`),ie=w.length>1,ae=m.filter(e=>w.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?mt(r,x):``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function se(e){_({spawnProvider:e,spawnModel:mt(e,x),spawnEffort:``})}function T(e){_({spawnModel:e,spawnEffort:``})}return(0,B.jsx)(Nd,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,B.jsxs)(Q,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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:!C.length,children:[!C.length&&(0,B.jsx)(`option`,{value:r,children:`No providers available`}),C.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:!ee.length,children:ee.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)(ef,{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)($d,{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=w.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)(Bd,{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)(Bd,{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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,B.jsx)(I,{onClick:v,disabled:!re,children:h?`Spawning…`:C.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function af(){return`host-${Math.random().toString(36).slice(2,8)}`}function of(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function sf(){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(Ye()).origin,[]),[a,o]=(0,z.useState)(af),[s,l]=(0,z.useState)(`$HOME/projects`),[u,d]=(0,z.useState)(bt()),[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 S(){if(!a.trim()){n(`Validation`,`Orchestrator id is required`);return}if(!s.trim()){n(`Validation`,`Base directory is required`);return}if(!u.length){n(`Validation`,`Select at least one provider`);return}x(!0);try{let e=await oe(`POST`,`/orchestrators/bootstrap`,{id:a.trim(),relayUrl:i,baseDir:s.trim(),providers:u,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)(Nd,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,B.jsxs)(Q,{className:`max-w-2xl overflow-hidden`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{className:`flex items-center gap-2`,children:[(0,B.jsx)(c,{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=>l(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:bt().map(e=>(0,B.jsx)(I,{type:`button`,size:`sm`,variant:u.includes(e)?`default`:`outline`,onClick:()=>d(of(u,e)),children:Ct(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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,B.jsx)(In,{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:S,disabled:b,children:[(0,B.jsx)(je,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function cf(){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=vt(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:mt(r,a),effort:``})}function h(e){p({provider:e,rig:``,model:mt(e,a),effort:``})}return(0,B.jsx)(Nd,{open:e.open,onOpenChange:e=>!e&&p({open:!1}),children:(0,B.jsxs)(Q,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(ef,{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)($d,{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)(Bd,{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)(W,{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)(W,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>p({scheduledDailyRestart:e})})]})]}),(0,B.jsxs)(Ld,{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)(Vc,{children:[(0,B.jsx)(Hc,{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)(le,{className:`h-3 w-3`})})}),(0,B.jsx)(Uc,{className:`max-w-xs leading-relaxed`,children:e})]})}function uf({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 df=[`core`,`workspace`,`memory`,`artifacts`,`blackboard`,`subscriptions`,`spawn-lifecycle`,`plans`,`teams`,`project`,`issues`],ff=[{value:``,label:`Off`},{value:`all`,label:`All`}],pf=[{value:``,label:`Off`},{value:`all`,label:`All safe settings`}],mf=[{value:``,label:`Instance default`},{value:`direct`,label:`Direct`},{value:`pr`,label:`Pull request`}],hf=[{value:`any`,label:`Any provider`},...bt().map(e=>({value:e,label:Ct(e)}))],gf={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 _f(e){return e?e.policy??`all`:``}function vf(e){if(e)return e===`all`?{policy:`all`}:{}}function yf({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 bf(e,t){return`${e.source}:${e.provider??`any`}:${e.ref}:${t}`}function xf({source:e}){return(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] ${gf[e]}`,children:e})}function Sf({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,S]=(0,z.useState)(`repo`),[C,ee]=(0,z.useState)(``),[te,ne]=(0,z.useState)(`any`);async function re(e){if(b(e),!p){g(!0),v(null);try{f((await oe(`GET`,`/provisioning/capabilities`)).capabilities),m(!0)}catch(e){v(yt(e))}finally{g(!1)}}}function w(n){let a=C.trim();if(!a)return;let o={source:x,ref:a,enabled:!0,...te===`any`?{}:{provider:te}};n===`skill`?r([...e,o]):i([...t,o]),ee(``),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 se(t,n){r(e.map((e,r)=>r===t?{...e,...n}:e))}function T(e,n){i(t.map((t,r)=>r===e?{...t,...n}:t))}function E(e){let t={...n.servers??{}};delete t[e],a({...n,servers:t})}let ce=d.filter(e=>e.capability.kind===`skill`),le=d.filter(e=>e.capability.kind===`plugin`),ue=d.filter(e=>e.capability.kind===`mcp`);return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(Cf,{projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l}),(0,B.jsx)(Tf,{title:`Skills from registry`,kind:`skill`,refs:e,readOnly:u,adding:y===`skill`,caps:ce,loading:h,fetchError:_,empty:`No skills assigned`,manualRef:C,manualSource:x,manualProvider:te,onAddClick:()=>void re(`skill`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:ne,onAddManual:()=>w(`skill`),onAddRelay:e=>ie(`skill`,e),onUpdate:se,onRemove:t=>r(e.filter((e,n)=>n!==t))}),(0,B.jsx)(Tf,{title:`Plugins from registry`,kind:`plugin`,refs:t,readOnly:u,adding:y===`plugin`,caps:le,loading:h,fetchError:_,empty:`No plugins assigned`,manualRef:C,manualSource:x,manualProvider:te,onAddClick:()=>void re(`plugin`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:ne,onAddManual:()=>w(`plugin`),onAddRelay:e=>ie(`plugin`,e),onUpdate:T,onRemove:e=>i(t.filter((t,n)=>n!==e))}),(0,B.jsx)(Of,{mcpKeys:Object.keys(n.servers??{}),caps:ue,adding:y===`mcp`,loading:h,fetchError:_,readOnly:u,onAddClick:()=>void re(`mcp`),onAddMcp:ae,onCancel:()=>b(null),onRemove:E})]})}function Cf(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: `,_f(e.projectMcp)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSkills?`default`:`outline`,className:`text-[10px]`,children:[`project skills: `,_f(e.projectSkills)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSettings?`default`:`outline`,className:`text-[10px]`,children:[`project settings: `,_f(e.projectSettings)||`off`]}),(0,B.jsxs)(F,{variant:e.sharedMcp?`default`:`outline`,className:`text-[10px]`,children:[`shared MCP: `,_f(e.sharedMcp)||`off`]})]})]})}function wf(e){return[...new Set(e.variants.map(e=>e.sourceType||`relay`))].join(`, `)}function Tf(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)(i,{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)(xf,{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)(W,{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)(Me,{className:`h-3 w-3`})})]},bf(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:[`(`,wf(t),`)`]})]},t.capability.id))}),(0,B.jsx)(Ef,{}),(0,B.jsx)(Df,{...e}),(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function Ef(){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 Df(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)(yf,{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)(yf,{value:e.manualProvider,onChange:t=>e.onManualProvider(t),options:hf})]}),(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 Of(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)(i,{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)(xf,{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)(Me,{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:[`(`,wf(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 kf(e){let t=bt();return e&&e!==`any`&&t.includes(e)?e:t[0]??``}function Af({profile:e}){let[t,n]=(0,z.useState)(()=>kf(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 oe(`GET`,`/agent-profiles/${encodeURIComponent(e.name)}/resolved?provider=${encodeURIComponent(r)}`);n(t.provider),i(t.profile.provisioning??{skills:[],plugins:[],mcpServers:{}})}catch(e){c(yt(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)(yf,{value:t,onChange:e=>{n(e),l(e)},options:bt().map(e=>({value:e,label:Ct(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)(jf,{title:`Skills`,values:r.skills.map(e=>e.name),empty:`No resolved skills`}),(0,B.jsx)(jf,{title:`Plugins`,values:r.plugins.map(e=>e.name),empty:`No resolved plugins`}),(0,B.jsx)(jf,{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 jf({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 Mf({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)(ct,{className:`h-3.5 w-3.5`}):(0,B.jsx)(lt,{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 Nf({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 Pf({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(``);function l(){a.trim()&&(t({...e,[a.trim()]:s}),o(``),c(``))}function u(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:()=>u(e),children:(0,B.jsx)(Me,{className:`h-3 w-3`})})]},e)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:a,onChange:e=>o(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,B.jsx)(L,{value:s,onChange:e=>c(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&l()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:l,children:(0,B.jsx)(i,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var Ff=[{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)`}],If=[{value:`any`,label:`Any provider`},...bt().map(e=>({value:e,label:Ct(e)}))],Lf=[{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`}],Rf=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],zf=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],Bf=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}],Vf={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).`},Hf={context:`Context`,skills:`Skills`,plugins:`Plugins`,statusLine:`Status Line`,mcp:`MCP Tools`};function Uf({values:e,onChange:t,disabled:n,placeholder:r}){let[a,o]=(0,z.useState)(``);function s(){let n=a.trim();n&&(t([...e,n]),o(``))}function c(n,r){t(e.map((e,t)=>t===n?r:e))}function l(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=>c(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:()=>l(t),children:(0,B.jsx)(Me,{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:a,onChange:e=>o(e.target.value),placeholder:r,className:`flex-1 text-xs`,onKeyDown:e=>e.key===`Enter`&&s()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:s,children:(0,B.jsx)(i,{className:`h-3 w-3`})})]}),e.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`None`})]})}function Wf(){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:vf(e)})}function p(e){i({projectSkills:vf(e)})}function m(e){i({projectSettings:vf(e)})}function h(e){i({sharedMcp:vf(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)(Nd,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Q,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{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)(Mf,{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)(uf,{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)(Nf,{value:n.base,onChange:e=>y(e),options:Ff,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsx)(Nf,{value:n.provider||`any`,onChange:e=>i({provider:e}),options:If,disabled:o})]})]})]}),(0,B.jsxs)(Mf,{title:`Instructions`,defaultOpen:!1,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`System Prompt`}),(0,B.jsx)(Bd,{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)(Uf,{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)(Nf,{value:n.instructions.repoInstructions,onChange:e=>l({repoInstructions:e}),options:zf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Global Instructions`}),(0,B.jsx)(Nf,{value:n.instructions.globalInstructions,onChange:e=>l({globalInstructions:e}),options:zf,disabled:o})]})]})]}),(0,B.jsxs)(Mf,{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)(uf,{tip:Vf[e],children:Hf[e]}),(0,B.jsx)(W,{checked:n.relay[e]??!0,onCheckedChange:t=>u({[e]:t}),disabled:o})]},e))}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{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:df.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)(Mf,{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)(uf,{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)(Nf,{value:n.mcp.mode,onChange:e=>i({mcp:{...n.mcp,mode:e}}),options:Lf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{tip:`The host's hook configuration. Host = inherit it; None = no host hooks.`,children:`Hooks Mode`}),(0,B.jsx)(Nf,{value:n.hooks.mode,onChange:e=>i({hooks:{mode:e}}),options:Lf,disabled:o})]})]})}),(0,B.jsx)(Mf,{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)(uf,{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)(Nf,{value:_f(n.projectMcp),onChange:f,options:ff,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{tip:`Injects skills committed under the project's .claude/skills.`,children:`Project Skills`}),(0,B.jsx)(Nf,{value:_f(n.projectSkills),onChange:p,options:ff,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{tip:`Injects the project's .claude/settings.json (permission/security keys stripped).`,children:`Project Settings`}),(0,B.jsx)(Nf,{value:_f(n.projectSettings),onChange:m,options:pf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{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)(Nf,{value:_f(n.sharedMcp),onChange:h,options:ff,disabled:o})]}),(0,B.jsxs)(`div`,{className:`col-span-2`,children:[(0,B.jsx)(uf,{tip:`How the agent's isolated branch lands: Direct (rebase/FF), Pull request, or the instance default.`,children:`Landing Strategy`}),(0,B.jsx)(Nf,{value:n.landingStrategy??``,onChange:e=>i({landingStrategy:e||void 0}),options:mf,disabled:o})]})]})}),(0,B.jsx)(Mf,{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)(Nf,{value:n.permissions.mode||``,onChange:e=>g({mode:e||void 0}),options:Bf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Filesystem Scope`}),(0,B.jsx)(Nf,{value:n.permissions.filesystem,onChange:e=>g({filesystem:e}),options:Rf,disabled:o})]})]})}),(0,B.jsx)(Mf,{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)(Mf,{title:`Environment Variables`,defaultOpen:!1,children:(0,B.jsx)(Pf,{env:n.env||{},onChange:e=>i({env:e}),disabled:o})}),(0,B.jsx)(Mf,{title:`Registry Capabilities`,defaultOpen:!1,children:(0,B.jsx)(Sf,{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)(Mf,{title:`Resolved Provisioning`,defaultOpen:t===`view`,children:(0,B.jsx)(Af,{profile:n})}),(0,B.jsxs)(Mf,{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)(Bd,{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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:a,children:s?`Create`:`Save`})]})]})})}function Gf(){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=rl(),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)(Ze[e.icon]||lt,{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 Kf(){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)(Ce,{className:`w-5 h-5`})}),(0,B.jsx)(b,{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 qf(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 Jf(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 Yf=`agent-relay:quota-widget`,Xf=300*1e3;function Zf(e){return!e.quota&&e.lastError?.type===`unavailable`}function Qf(e,t){let n=t===`5h`?[`five_hour`,`primary`]:[`seven_day`,`secondary`];return e.quota?.windows.find(e=>n.includes(e.name))}function $f(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 ep({record:e,now:t,advisory:n}){let r=(0,B.jsx)(_u,{provider:e.provider,className:`w-3.5 h-3.5`});if(Zf(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=Qf(e,`5h`),a=Qf(e,`7d`);function o(e){if(!e)return null;let n=Math.round(e.utilization*100),r=$f(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)(op,{advisory:n}),o(i),o(a),s&&(0,B.jsx)(`span`,{className:`text-muted-foreground/70`,children:s})]})}function tp(){try{let e=localStorage.getItem(Yf);return{open:!0,pinned:!1,...e?JSON.parse(e):{}}}catch{return{open:!0,pinned:!1}}}function np(e){try{localStorage.setItem(Yf,JSON.stringify(e))}catch{}}function rp(){let[{open:e,pinned:t},n]=(0,z.useState)(tp),[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=gt(),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([oe(`GET`,`/provider-quotas`),oe(`GET`,`/providers/quota-config`).catch(()=>null),oe(`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(),Xf);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&&!Zf(e)),g=m.some(e=>e.lastError&&!Zf(e));function _(){if(t)return;let r={open:!e,pinned:t};n(r),np(r)}function v(){let r=t?{open:e,pinned:!1}:{open:!0,pinned:!0};n(r),np(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)(lt,{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)(Ae,{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)(ep,{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)(D,{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)(Ae,{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=>(0,B.jsx)(lp,{record:e,now:d,advisory:s?.advisories[e.provider]},`${e.provider}:${e.accountKey}`))})]})]})}var ip={prefer:{icon:we,badge:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,dot:`bg-emerald-400`},caution:{icon:E,badge:`text-amber-400 bg-amber-500/10 border-amber-500/20`,dot:`bg-amber-400`},"avoid-large":{icon:E,badge:`text-orange-400 bg-orange-500/10 border-orange-500/20`,dot:`bg-orange-400`},"hard-avoid":{icon:Be,badge:`text-red-400 bg-red-500/10 border-red-500/20`,dot:`bg-red-400`}};function ap({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)(ft,{className:`w-2.5 h-2.5`}),`blocked`]});let t=e.quotaPenaltyBand;if(t===`normal`)return null;let n=ip[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 op({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:`quota blocked`});let t=e.quotaPenaltyBand;return t===`normal`?null:(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${ip[t].dot} shrink-0`,title:t})}function sp(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}× · ~${Jf(t,t+e.earlyWallMs)} before reset`}function cp({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)(We,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{className:`italic`,children:`building burn history…`})]});let n=sp(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)(E,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{children:n})]}):null}function lp({record:e,now:t,advisory:n}){let{provider:r,accountKey:i,quota:a,stale:o,lastError:s,lastUpdatedAt:c,lastAttemptAt:l}=e;if(Zf(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)(_u,{provider:r,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 — `,s?.message??`no readable credentials`]})]});let u=s?.retryAfterMs,d=u==null?null:Math.max(0,l+u-t),f=d==null?null:Math.ceil(d/1e3),p=(o||!!s)&&l>0;return(0,B.jsxs)(`div`,{className:`rounded border ${s?`border-red-500/30`:o?`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)(_u,{provider:r,className:`w-3.5 h-3.5`}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono truncate`,children:i})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,B.jsx)(ap,{advisory:n}),o&&(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`}),s&&(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:s.message,children:s.type===`rate_limited`?`429`:`err`})]})]}),a?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:a.windows.map(n=>{let r=Math.round(n.utilization*100),i=r>=90?`bg-red-500`:r>=70?`bg-amber-500`:`bg-emerald-500`,a=n.resetsAt?Jf(t,n.resetsAt):``,o=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:qf(n.name)}),(0,B.jsxs)(`span`,{children:[r,`%`,a?` · resets in ${a}`:``]})]}),(0,B.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,B.jsx)(`div`,{className:`h-full ${i} transition-all duration-500`,style:{width:`${Math.max(0,Math.min(100,r))}%`}})}),(0,B.jsx)(cp,{burnWindow:o,now:t})]},n.name)})}):(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:s?s.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:[p&&(0,B.jsxs)(`div`,{children:[`Attempted `,j(t,l)]}),(0,B.jsx)(`div`,{children:c?`Updated ${j(t,c)}`:`Never updated`})]}),f!=null&&(0,B.jsx)(`span`,{className:`text-amber-400/70 shrink-0 mt-0.5`,children:f>0?`retry in ~${f>60?`${Math.ceil(f/60)}m`:`${f}s`}`:`retrying…`})]})]})}function up(e){return(0,z.lazy)(()=>qn(e))}var dp=up(()=>R(()=>import(`./overview-DlqJIqYK.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([16,1,6,8,9,10,17,12,18]),import.meta.url)),fp=up(()=>R(()=>import(`./chat-D1bunuI-.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)),pp=up(()=>R(()=>import(`./agents-FdrfmJsj.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)),mp=up(()=>R(()=>import(`./managed-agents-Bj--bFmZ.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([36,1,6,8,9,10,25,11,12,17]),import.meta.url)),hp=up(()=>R(()=>import(`./teams-Dn0yggD-.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)),gp=up(()=>R(()=>import(`./agent-profiles-Zr_5nNEJ.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([43,1,6,8,9,10,17,12,11]),import.meta.url)),_p=up(()=>R(()=>import(`./orchestrators-BVDAhrPk.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([44,6,1,8,9,10,17,12,11,18]),import.meta.url)),vp=up(()=>R(()=>import(`./workspaces-CIsQqQby.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([45,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),yp=up(()=>R(()=>import(`./channels-CcSnLzCG.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([46,6,1,8,9,10,17,12,11,18]),import.meta.url)),bp=up(()=>R(()=>import(`./connectors-DbPOlQhL.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([47,6,1,8,9,10,17,12,11,18]),import.meta.url)),xp=up(()=>R(()=>import(`./integrations-hkSW8CzM.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([48,6,1,8,9,10,17,12,11,18]),import.meta.url)),Sp=up(()=>R(()=>import(`./security-ucr7IT1V.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([49,1,6,25,11,12,17,18,26]),import.meta.url)),Cp=up(()=>R(()=>import(`./memory-yj2MIxUA.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([50,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),wp=up(()=>R(()=>import(`./activity-UKQrQ8_0.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([51,1,6,8,9,10,21,22,17,12,11,18]),import.meta.url)),Tp=up(()=>R(()=>import(`./pairs-DQ4tNCo3.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([52,6,1,8,9,10,17,12,11,18]),import.meta.url)),Ep=up(()=>R(()=>import(`./messages-BT5mL7iz.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([53,1,6,8,9,10,17,12,11,18]),import.meta.url)),Dp=up(()=>R(()=>import(`./work-queue-BAnNY0xE.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([54,6,1,8,9,10,17,12,11,18]),import.meta.url)),Op=up(()=>R(()=>import(`./tasks-jRUvxUd5.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([55,1,6,8,9,10,17,12,11,18]),import.meta.url)),kp=up(()=>R(()=>import(`./automation-DlEcJvgu.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([56,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),Ap=up(()=>R(()=>import(`./analytics-VximqXQ9.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([57,1,6,8,9,10,18,58]),import.meta.url)),jp=up(()=>R(()=>import(`./insights-CntgHcTp.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([59,1,6,17,12,11,18,26,9,10]),import.meta.url)),Mp=up(()=>R(()=>import(`./projects-vt63bwHN.js`).then(e=>({default:e.ProjectsView})),__vite__mapDeps([60,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),Np=up(()=>R(()=>import(`./prompt-settings-DlsqOP0C.js`).then(e=>({default:e.PromptSettingsView})),__vite__mapDeps([61,1,6,17,12,11,18,9,10]),import.meta.url)),Pp=up(()=>R(()=>import(`./registry-Cw2fdWrn.js`).then(e=>({default:e.RegistryView})),__vite__mapDeps([62,1,6,17,12,11,18,26,10]),import.meta.url)),Fp=up(()=>R(()=>import(`./maintenance-Dw7frQtu.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([63,1,6,8,9,10,17,12,11]),import.meta.url)),Ip=up(()=>R(()=>import(`./settings-Dvf_ps1B.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)),Lp=class extends z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
|
|
22
|
-
`,t.componentStack)}render(){return this.state.error?Wn(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}},
|
|
23
|
-
//# sourceMappingURL=index-
|
|
21
|
+
`)})]})]})}function Dd(e){if(!xt(e)||typeof e.lastError!=`string`)return null;let t=xt(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 Od({className:e,children:t,...n}){return(0,B.jsxs)(ps,{"data-slot":`scroll-area`,className:O(`relative`,e),...n,children:[(0,B.jsx)(ms,{"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)(kd,{}),(0,B.jsx)(hs,{})]})}function kd({className:e,orientation:t=`vertical`,...n}){return(0,B.jsx)(Vo,{"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)(Qo,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Ad(){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=gt(),o=A(e=>e.closeChannelDetail),s=n.find(e=>e.id===t)||null,c=Rt(s),l=(0,z.useMemo)(()=>s?r.filter(e=>Ut(e,s)).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,s]);return(0,B.jsx)(tu,{open:e,onOpenChange:e=>!e&&o(),children:(0,B.jsxs)(iu,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,B.jsx)(au,{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:kt(c.tone),children:c.label}),(0,B.jsx)(ou,{className:`text-base truncate`,children:s?.name||`Channel`})]})}),(0,B.jsx)(Od,{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)})]})]})]}),It(s.capabilities).length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(al,{}),(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:It(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)(al,{}),(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)(al,{}),(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:Bt(e.from,i)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,B.jsx)(`span`,{className:`truncate max-w-[40%]`,children:Bt(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:Wt(e)})]},e.id))})]})]})]})})]})})}var jd=!1;function Md(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;jd=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(jd){jd=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,jd=!0,window.history.back())}},[e])}function Nd({...e}){return Md(e.open,e.onOpenChange),(0,B.jsx)(Mr,{"data-slot":`dialog`,...e})}function Pd({...e}){return(0,B.jsx)(Nr,{"data-slot":`dialog-portal`,...e})}function Fd({className:e,blur:t=!0,...n}){return(0,B.jsx)(Pr,{"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 Q({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,B.jsxs)(Pd,{children:[(0,B.jsx)(Fd,{blur:r}),(0,B.jsxs)(Fr,{"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)(Rr,{"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)(Pe,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function Id({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-header`,className:O(`flex flex-col gap-2`,e),...t})}function Ld({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)(Rr,{asChild:!0,children:(0,B.jsx)(I,{variant:`outline`,children:`Close`})})]})}function Rd({className:e,...t}){return(0,B.jsx)(Ir,{"data-slot":`dialog-title`,className:O(`font-heading text-base leading-none font-medium`,e),...t})}function zd({className:e,...t}){return(0,B.jsx)(Lr,{"data-slot":`dialog-description`,className:O(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Bd({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)(Ao,{"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})}function Vd(){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=$c();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,B.jsx)(Nd,{open:e,onOpenChange:e=>!e&&s(),children:(0,B.jsxs)(Q,{className:`max-w-lg`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(Bd,{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)(W,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,B.jsxs)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:s,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}function Hd(){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)(Nd,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(Id,{children:[(0,B.jsx)(Rd,{children:e.title}),(0,B.jsx)(zd,{children:e.message})]}),(0,B.jsxs)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function Ud(){let e=A(e=>e.errorModal),t=A(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,B.jsx)(Nd,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(Id,{children:[(0,B.jsx)(Rd,{children:e.title}),(0,B.jsx)(zd,{children:e.message})]}),(0,B.jsx)(Ld,{children:(0,B.jsx)(I,{onClick:n,children:`OK`})})]})})}function Wd(){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)(Nd,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:n,children:`Save`})]})]})})}function Gd(){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=$c();function o(e){n({pairInvite:{...t,...e}})}return(0,B.jsx)(Nd,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Create Pair`})]})]})})}function Kd(){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)(Nd,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Q,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(Bd,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,B.jsxs)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}var qd=(0,z.lazy)(()=>R(()=>import(`./formatted-body-impl-BJTthVHg.js`).then(e=>({default:e.FormattedBody})),__vite__mapDeps([15,1,5,3,6,8,9,10]),import.meta.url));function Jd(e){return(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`span`,{className:e.className,children:e.text}),children:(0,B.jsx)(qd,{...e})})}function Yd(){let e=A(e=>e.threadOpen),t=A(e=>e.threadMessages),n=A(e=>e.agentsById),r=gt(),i=A(e=>e.set);return(0,B.jsx)(Nd,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,B.jsxs)(Q,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{children:[`Thread (`,t.length,` messages)`]})}),(0,B.jsx)(Od,{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:Bt(e.from,n)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:Bt(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)(Jd,{text:Wt(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 `,Bt(e.claimedBy,n)]})]})]},e.id))})})]})})}function Xd(){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)(Nd,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,B.jsxs)(Q,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{children:[`Task Events (`,t.length,`)`]})}),(0,B.jsx)(Od,{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:zt[e.severity]||zt.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)(Zd,{event:e,onOpen:i}),(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[Vt(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 Zd({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 Qd({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),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(``),[y,b]=(0,z.useState)(null),x=u?.path||i||``,S=(0,z.useMemo)(()=>x.split(`/`).filter(Boolean),[x]),C=(0,z.useCallback)(async e=>{if(r){c(!0),p(null),g(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;d(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){p(yt(e))}finally{c(!1)}}},[r,o]);(0,z.useEffect)(()=>{e&&r&&(d(null),p(null),g(!1),C(i||void 0))},[e,r]);async function te(){if(!(!_.trim()||!u)){b(null);try{d(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:u.path,name:_.trim()})),g(!1),v(``)}catch(e){b(yt(e))}}}function ne(){x&&(n(x),t(!1))}function re(e){C(`/`+S.slice(0,e+1).join(`/`))}return(0,B.jsx)(Nd,{open:e,onOpenChange:t,children:(0,B.jsxs)(Q,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{className:`flex items-center gap-2`,children:[(0,B.jsx)(m,{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:()=>u?.baseDir&&C(u.baseDir),children:`/`}),S.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:()=>re(t),children:e}),t<S.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)(Ae,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&f&&(0,B.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:f}),!s&&u&&(0,B.jsxs)(`div`,{className:`p-1`,children:[u.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:()=>C(u.parent),children:[(0,B.jsx)(Qe,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),u.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:()=>C(e.path),children:[(0,B.jsx)(ee,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),u.entries.length===0&&!u.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),u.entries.length===0&&u.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),h?(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(L,{autoFocus:!0,value:_,onChange:e=>{v(e.target.value),b(null)},onKeyDown:e=>{e.key===`Enter`&&te(),e.key===`Escape`&&(g(!1),v(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`outline`,onClick:te,disabled:!_.trim(),children:(0,B.jsx)(ce,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{g(!1),v(``),b(null)},children:(0,B.jsx)(Pe,{className:`h-4 w-4`})})]}):(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>g(!0),disabled:!u||s,children:[(0,B.jsx)(l,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),y&&(0,B.jsx)(`p`,{className:`text-xs text-destructive`,children:y}),(0,B.jsxs)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(I,{onClick:ne,disabled:!x,children:`Select`})]})]})})}function $d({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)(m,{className:`h-4 w-4`})}),n&&(0,B.jsx)(Qd,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function ef({model:e}){if(!e)return null;let t=tf(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 tf(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:nf(n),Icon:y}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:st}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:st}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:Se}),t}function nf(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function rf(){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),S=t.find(e=>e.id===n),C=S?.providers||[],ee=vt(r,x),te=ee.find(e=>e.alias===i),ne=te?.efforts||[],re=!!(S&&C.length>0&&s.trim())&&!h,w=t.filter(e=>e.status===`online`),ie=w.length>1,ae=m.filter(e=>w.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?mt(r,x):``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function se(e){_({spawnProvider:e,spawnModel:mt(e,x),spawnEffort:``})}function T(e){_({spawnModel:e,spawnEffort:``})}return(0,B.jsx)(Nd,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,B.jsxs)(Q,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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:!C.length,children:[!C.length&&(0,B.jsx)(`option`,{value:r,children:`No providers available`}),C.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:!ee.length,children:ee.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)(ef,{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)($d,{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=w.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)(Bd,{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)(Bd,{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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,B.jsx)(I,{onClick:v,disabled:!re,children:h?`Spawning…`:C.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function af(){return`host-${Math.random().toString(36).slice(2,8)}`}function of(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function sf(){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(Ye()).origin,[]),[a,o]=(0,z.useState)(af),[s,l]=(0,z.useState)(`$HOME/projects`),[u,d]=(0,z.useState)(bt()),[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 S(){if(!a.trim()){n(`Validation`,`Orchestrator id is required`);return}if(!s.trim()){n(`Validation`,`Base directory is required`);return}if(!u.length){n(`Validation`,`Select at least one provider`);return}x(!0);try{let e=await oe(`POST`,`/orchestrators/bootstrap`,{id:a.trim(),relayUrl:i,baseDir:s.trim(),providers:u,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)(Nd,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,B.jsxs)(Q,{className:`max-w-2xl overflow-hidden`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{className:`flex items-center gap-2`,children:[(0,B.jsx)(c,{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=>l(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:bt().map(e=>(0,B.jsx)(I,{type:`button`,size:`sm`,variant:u.includes(e)?`default`:`outline`,onClick:()=>d(of(u,e)),children:Ct(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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,B.jsx)(In,{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:S,disabled:b,children:[(0,B.jsx)(je,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function cf(){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=vt(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:mt(r,a),effort:``})}function h(e){p({provider:e,rig:``,model:mt(e,a),effort:``})}return(0,B.jsx)(Nd,{open:e.open,onOpenChange:e=>!e&&p({open:!1}),children:(0,B.jsxs)(Q,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(Id,{children:(0,B.jsx)(Rd,{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)(ef,{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)($d,{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)(Bd,{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)(W,{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)(W,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>p({scheduledDailyRestart:e})})]})]}),(0,B.jsxs)(Ld,{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)(Vc,{children:[(0,B.jsx)(Hc,{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)(le,{className:`h-3 w-3`})})}),(0,B.jsx)(Uc,{className:`max-w-xs leading-relaxed`,children:e})]})}function uf({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 df=[`core`,`workspace`,`memory`,`artifacts`,`blackboard`,`subscriptions`,`spawn-lifecycle`,`plans`,`teams`,`project`,`issues`],ff=[{value:``,label:`Off`},{value:`all`,label:`All`}],pf=[{value:``,label:`Off`},{value:`all`,label:`All safe settings`}],mf=[{value:``,label:`Instance default`},{value:`direct`,label:`Direct`},{value:`pr`,label:`Pull request`}],hf=[{value:`any`,label:`Any provider`},...bt().map(e=>({value:e,label:Ct(e)}))],gf={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 _f(e){return e?e.policy??`all`:``}function vf(e){if(e)return e===`all`?{policy:`all`}:{}}function yf({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 bf(e,t){return`${e.source}:${e.provider??`any`}:${e.ref}:${t}`}function xf({source:e}){return(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] ${gf[e]}`,children:e})}function Sf({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,S]=(0,z.useState)(`repo`),[C,ee]=(0,z.useState)(``),[te,ne]=(0,z.useState)(`any`);async function re(e){if(b(e),!p){g(!0),v(null);try{f((await oe(`GET`,`/provisioning/capabilities`)).capabilities),m(!0)}catch(e){v(yt(e))}finally{g(!1)}}}function w(n){let a=C.trim();if(!a)return;let o={source:x,ref:a,enabled:!0,...te===`any`?{}:{provider:te}};n===`skill`?r([...e,o]):i([...t,o]),ee(``),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 se(t,n){r(e.map((e,r)=>r===t?{...e,...n}:e))}function T(e,n){i(t.map((t,r)=>r===e?{...t,...n}:t))}function E(e){let t={...n.servers??{}};delete t[e],a({...n,servers:t})}let ce=d.filter(e=>e.capability.kind===`skill`),le=d.filter(e=>e.capability.kind===`plugin`),ue=d.filter(e=>e.capability.kind===`mcp`);return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(Cf,{projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l}),(0,B.jsx)(Tf,{title:`Skills from registry`,kind:`skill`,refs:e,readOnly:u,adding:y===`skill`,caps:ce,loading:h,fetchError:_,empty:`No skills assigned`,manualRef:C,manualSource:x,manualProvider:te,onAddClick:()=>void re(`skill`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:ne,onAddManual:()=>w(`skill`),onAddRelay:e=>ie(`skill`,e),onUpdate:se,onRemove:t=>r(e.filter((e,n)=>n!==t))}),(0,B.jsx)(Tf,{title:`Plugins from registry`,kind:`plugin`,refs:t,readOnly:u,adding:y===`plugin`,caps:le,loading:h,fetchError:_,empty:`No plugins assigned`,manualRef:C,manualSource:x,manualProvider:te,onAddClick:()=>void re(`plugin`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:ne,onAddManual:()=>w(`plugin`),onAddRelay:e=>ie(`plugin`,e),onUpdate:T,onRemove:e=>i(t.filter((t,n)=>n!==e))}),(0,B.jsx)(Of,{mcpKeys:Object.keys(n.servers??{}),caps:ue,adding:y===`mcp`,loading:h,fetchError:_,readOnly:u,onAddClick:()=>void re(`mcp`),onAddMcp:ae,onCancel:()=>b(null),onRemove:E})]})}function Cf(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: `,_f(e.projectMcp)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSkills?`default`:`outline`,className:`text-[10px]`,children:[`project skills: `,_f(e.projectSkills)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSettings?`default`:`outline`,className:`text-[10px]`,children:[`project settings: `,_f(e.projectSettings)||`off`]}),(0,B.jsxs)(F,{variant:e.sharedMcp?`default`:`outline`,className:`text-[10px]`,children:[`shared MCP: `,_f(e.sharedMcp)||`off`]})]})]})}function wf(e){return[...new Set(e.variants.map(e=>e.sourceType||`relay`))].join(`, `)}function Tf(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)(i,{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)(xf,{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)(W,{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)(Me,{className:`h-3 w-3`})})]},bf(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:[`(`,wf(t),`)`]})]},t.capability.id))}),(0,B.jsx)(Ef,{}),(0,B.jsx)(Df,{...e}),(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function Ef(){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 Df(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)(yf,{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)(yf,{value:e.manualProvider,onChange:t=>e.onManualProvider(t),options:hf})]}),(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 Of(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)(i,{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)(xf,{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)(Me,{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:[`(`,wf(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 kf(e){let t=bt();return e&&e!==`any`&&t.includes(e)?e:t[0]??``}function Af({profile:e}){let[t,n]=(0,z.useState)(()=>kf(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 oe(`GET`,`/agent-profiles/${encodeURIComponent(e.name)}/resolved?provider=${encodeURIComponent(r)}`);n(t.provider),i(t.profile.provisioning??{skills:[],plugins:[],mcpServers:{}})}catch(e){c(yt(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)(yf,{value:t,onChange:e=>{n(e),l(e)},options:bt().map(e=>({value:e,label:Ct(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)(jf,{title:`Skills`,values:r.skills.map(e=>e.name),empty:`No resolved skills`}),(0,B.jsx)(jf,{title:`Plugins`,values:r.plugins.map(e=>e.name),empty:`No resolved plugins`}),(0,B.jsx)(jf,{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 jf({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 Mf({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)(ct,{className:`h-3.5 w-3.5`}):(0,B.jsx)(lt,{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 Nf({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 Pf({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(``);function l(){a.trim()&&(t({...e,[a.trim()]:s}),o(``),c(``))}function u(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:()=>u(e),children:(0,B.jsx)(Me,{className:`h-3 w-3`})})]},e)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:a,onChange:e=>o(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,B.jsx)(L,{value:s,onChange:e=>c(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&l()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:l,children:(0,B.jsx)(i,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var Ff=[{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)`}],If=[{value:`any`,label:`Any provider`},...bt().map(e=>({value:e,label:Ct(e)}))],Lf=[{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`}],Rf=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],zf=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],Bf=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}],Vf={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).`},Hf={context:`Context`,skills:`Skills`,plugins:`Plugins`,statusLine:`Status Line`,mcp:`MCP Tools`};function Uf({values:e,onChange:t,disabled:n,placeholder:r}){let[a,o]=(0,z.useState)(``);function s(){let n=a.trim();n&&(t([...e,n]),o(``))}function c(n,r){t(e.map((e,t)=>t===n?r:e))}function l(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=>c(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:()=>l(t),children:(0,B.jsx)(Me,{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:a,onChange:e=>o(e.target.value),placeholder:r,className:`flex-1 text-xs`,onKeyDown:e=>e.key===`Enter`&&s()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:s,children:(0,B.jsx)(i,{className:`h-3 w-3`})})]}),e.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`None`})]})}function Wf(){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:vf(e)})}function p(e){i({projectSkills:vf(e)})}function m(e){i({projectSettings:vf(e)})}function h(e){i({sharedMcp:vf(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)(Nd,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Q,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(Id,{children:(0,B.jsxs)(Rd,{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)(Mf,{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)(uf,{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)(Nf,{value:n.base,onChange:e=>y(e),options:Ff,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsx)(Nf,{value:n.provider||`any`,onChange:e=>i({provider:e}),options:If,disabled:o})]})]})]}),(0,B.jsxs)(Mf,{title:`Instructions`,defaultOpen:!1,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`System Prompt`}),(0,B.jsx)(Bd,{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)(Uf,{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)(Nf,{value:n.instructions.repoInstructions,onChange:e=>l({repoInstructions:e}),options:zf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Global Instructions`}),(0,B.jsx)(Nf,{value:n.instructions.globalInstructions,onChange:e=>l({globalInstructions:e}),options:zf,disabled:o})]})]})]}),(0,B.jsxs)(Mf,{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)(uf,{tip:Vf[e],children:Hf[e]}),(0,B.jsx)(W,{checked:n.relay[e]??!0,onCheckedChange:t=>u({[e]:t}),disabled:o})]},e))}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{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:df.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)(Mf,{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)(uf,{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)(Nf,{value:n.mcp.mode,onChange:e=>i({mcp:{...n.mcp,mode:e}}),options:Lf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{tip:`The host's hook configuration. Host = inherit it; None = no host hooks.`,children:`Hooks Mode`}),(0,B.jsx)(Nf,{value:n.hooks.mode,onChange:e=>i({hooks:{mode:e}}),options:Lf,disabled:o})]})]})}),(0,B.jsx)(Mf,{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)(uf,{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)(Nf,{value:_f(n.projectMcp),onChange:f,options:ff,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{tip:`Injects skills committed under the project's .claude/skills.`,children:`Project Skills`}),(0,B.jsx)(Nf,{value:_f(n.projectSkills),onChange:p,options:ff,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{tip:`Injects the project's .claude/settings.json (permission/security keys stripped).`,children:`Project Settings`}),(0,B.jsx)(Nf,{value:_f(n.projectSettings),onChange:m,options:pf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(uf,{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)(Nf,{value:_f(n.sharedMcp),onChange:h,options:ff,disabled:o})]}),(0,B.jsxs)(`div`,{className:`col-span-2`,children:[(0,B.jsx)(uf,{tip:`How the agent's isolated branch lands: Direct (rebase/FF), Pull request, or the instance default.`,children:`Landing Strategy`}),(0,B.jsx)(Nf,{value:n.landingStrategy??``,onChange:e=>i({landingStrategy:e||void 0}),options:mf,disabled:o})]})]})}),(0,B.jsx)(Mf,{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)(Nf,{value:n.permissions.mode||``,onChange:e=>g({mode:e||void 0}),options:Bf,disabled:o})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Filesystem Scope`}),(0,B.jsx)(Nf,{value:n.permissions.filesystem,onChange:e=>g({filesystem:e}),options:Rf,disabled:o})]})]})}),(0,B.jsx)(Mf,{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)(Mf,{title:`Environment Variables`,defaultOpen:!1,children:(0,B.jsx)(Pf,{env:n.env||{},onChange:e=>i({env:e}),disabled:o})}),(0,B.jsx)(Mf,{title:`Registry Capabilities`,defaultOpen:!1,children:(0,B.jsx)(Sf,{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)(Mf,{title:`Resolved Provisioning`,defaultOpen:t===`view`,children:(0,B.jsx)(Af,{profile:n})}),(0,B.jsxs)(Mf,{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)(Bd,{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)(Ld,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:a,children:s?`Create`:`Save`})]})]})})}function Gf(){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=rl(),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)(Ze[e.icon]||lt,{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 Kf(){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)(Ce,{className:`w-5 h-5`})}),(0,B.jsx)(b,{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 qf(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 Jf(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 Yf=`agent-relay:quota-widget`,Xf=300*1e3,Zf=8;function Qf(e){return!e.quota&&e.lastError?.type===`unavailable`}function $f(e,t){let n=t===`5h`?[`five_hour`,`primary`]:[`seven_day`,`secondary`];return e.quota?.windows.find(e=>n.includes(e.name))}function ep(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 tp({record:e,now:t,advisory:n}){let r=(0,B.jsx)(_u,{provider:e.provider,className:`w-3.5 h-3.5`});if(Qf(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=$f(e,`5h`),a=$f(e,`7d`);function o(e){if(!e)return null;let n=Math.round(e.utilization*100),r=ep(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)(sp,{advisory:n}),o(i),o(a),s&&(0,B.jsx)(`span`,{className:`text-muted-foreground/70`,children:s})]})}function np(){try{let e=localStorage.getItem(Yf);return{open:!0,pinned:!1,...e?JSON.parse(e):{}}}catch{return{open:!0,pinned:!1}}}function rp(e){try{localStorage.setItem(Yf,JSON.stringify(e))}catch{}}function ip(){let[{open:e,pinned:t},n]=(0,z.useState)(np),[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=gt(),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([oe(`GET`,`/provider-quotas`),oe(`GET`,`/providers/quota-config`).catch(()=>null),oe(`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(),Xf);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&&!Qf(e)),g=m.some(e=>e.lastError&&!Qf(e));function _(){if(t)return;let r={open:!e,pinned:t};n(r),rp(r)}function v(){let r=t?{open:e,pinned:!1}:{open:!0,pinned:!0};n(r),rp(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)(lt,{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)(Ae,{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)(tp,{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)(D,{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)(Ae,{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??Zf};return(0,B.jsx)(dp,{record:e,now:d,advisory:s?.advisories[e.provider],sparklineCfg:n},`${e.provider}:${e.accountKey}`)})})]})]})}var ap={prefer:{icon:we,badge:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,dot:`bg-emerald-400`},caution:{icon:E,badge:`text-amber-400 bg-amber-500/10 border-amber-500/20`,dot:`bg-amber-400`},"avoid-large":{icon:E,badge:`text-orange-400 bg-orange-500/10 border-orange-500/20`,dot:`bg-orange-400`},"hard-avoid":{icon:Be,badge:`text-red-400 bg-red-500/10 border-red-500/20`,dot:`bg-red-400`}};function op({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)(ft,{className:`w-2.5 h-2.5`}),`blocked`]});let t=e.quotaPenaltyBand;if(t===`normal`)return null;let n=ap[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 sp({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:`quota blocked`});let t=e.quotaPenaltyBand;return t===`normal`?null:(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${ap[t].dot} shrink-0`,title:t})}function cp(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}× · ~${Jf(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)(We,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{className:`italic`,children:`building burn history…`})]});let n=cp(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)(E,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{children:n})]}):null}function up({provider:e,windowName:t,rangeHours:n}){let[r,i]=(0,z.useState)([]);gt(),(0,z.useEffect)(()=>{let r=!1,a=Date.now()-n*36e5;return oe(`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 dp({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(Qf(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)(_u,{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)(_u,{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)(op,{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?Jf(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:qf(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)(up,{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 fp(e){return(0,z.lazy)(()=>qn(e))}var pp=fp(()=>R(()=>import(`./overview-Dyvm1qpT.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([16,1,6,8,9,10,17,12,18]),import.meta.url)),mp=fp(()=>R(()=>import(`./chat-BLcm2Aht.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)),hp=fp(()=>R(()=>import(`./agents-CgRFJyks.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)),gp=fp(()=>R(()=>import(`./managed-agents-CVca-s3t.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([36,1,6,8,9,10,25,11,12,17]),import.meta.url)),_p=fp(()=>R(()=>import(`./teams-DJWp4AKi.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)),vp=fp(()=>R(()=>import(`./agent-profiles-CuTQtmV6.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([43,1,6,8,9,10,17,12,11]),import.meta.url)),yp=fp(()=>R(()=>import(`./orchestrators-Du6I_n8i.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([44,6,1,8,9,10,17,12,11,18]),import.meta.url)),bp=fp(()=>R(()=>import(`./workspaces-CIsQqQby.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([45,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),xp=fp(()=>R(()=>import(`./channels-CcSnLzCG.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([46,6,1,8,9,10,17,12,11,18]),import.meta.url)),Sp=fp(()=>R(()=>import(`./connectors-DbPOlQhL.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([47,6,1,8,9,10,17,12,11,18]),import.meta.url)),Cp=fp(()=>R(()=>import(`./integrations-hkSW8CzM.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([48,6,1,8,9,10,17,12,11,18]),import.meta.url)),wp=fp(()=>R(()=>import(`./security-BfOQ6T5r.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([49,1,6,25,11,12,17,18,26]),import.meta.url)),Tp=fp(()=>R(()=>import(`./memory-BzuDTHC5.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([50,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),Ep=fp(()=>R(()=>import(`./activity-BcYf8YNO.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([51,1,6,8,9,10,21,22,17,12,11,18]),import.meta.url)),Dp=fp(()=>R(()=>import(`./pairs-B8x1RCNd.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([52,6,1,8,9,10,17,12,11,18]),import.meta.url)),Op=fp(()=>R(()=>import(`./messages-_W24PNvT.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([53,1,6,8,9,10,17,12,11,18]),import.meta.url)),kp=fp(()=>R(()=>import(`./work-queue-D-Otxd9u.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([54,6,1,8,9,10,17,12,11,18]),import.meta.url)),Ap=fp(()=>R(()=>import(`./tasks-1Kvp53wh.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([55,1,6,8,9,10,17,12,11,18]),import.meta.url)),jp=fp(()=>R(()=>import(`./automation-CH9YGYoE.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([56,1,6,8,9,10,17,12,11,18,26]),import.meta.url)),Mp=fp(()=>R(()=>import(`./analytics-C3OTFIXo.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([57,1,6,8,9,10,18,58]),import.meta.url)),Np=fp(()=>R(()=>import(`./insights-DklrIhb6.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([59,1,6,17,12,11,18,26,9,10]),import.meta.url)),Pp=fp(()=>R(()=>import(`./projects-vt63bwHN.js`).then(e=>({default:e.ProjectsView})),__vite__mapDeps([60,1,6,8,9,10,25,11,12,17,18]),import.meta.url)),Fp=fp(()=>R(()=>import(`./prompt-settings-xVXmvxB5.js`).then(e=>({default:e.PromptSettingsView})),__vite__mapDeps([61,1,6,17,12,11,18,9,10]),import.meta.url)),Ip=fp(()=>R(()=>import(`./registry-ypiICauZ.js`).then(e=>({default:e.RegistryView})),__vite__mapDeps([62,1,6,17,12,11,18,26,10]),import.meta.url)),Lp=fp(()=>R(()=>import(`./maintenance-FAAMGpuZ.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([63,1,6,8,9,10,17,12,11]),import.meta.url)),Rp=fp(()=>R(()=>import(`./settings-87clTx4N.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)),zp=class extends z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
|
|
22
|
+
`,t.componentStack)}render(){return this.state.error?Wn(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}},Bp={overview:pp,chat:mp,agents:hp,managed:gp,teams:_p,profiles:vp,orchestrators:yp,workspaces:bp,files:Ql,channels:xp,connectors:Sp,integrations:Cp,security:wp,memory:Tp,activity:Ep,pairs:Dp,messages:Op,work:kp,tasks:Ap,automation:jp,analytics:Mp,insights:Np,projects:Pp,prompts:Fp,registry:Ip,maintenance:Lp,settings:Rp},Vp=`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 Hp(){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 Up(){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:`${Vp} 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:`${Vp} px-4 py-2 bg-zinc-800 text-zinc-100 text-sm rounded-md shadow-lg border border-zinc-700`,children:e}):null}function Wp(){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)(()=>{an(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=Bp[r]||pp;return(0,B.jsx)(zp,{children:(0,B.jsx)(Bc,{children:(0,B.jsxs)(`div`,{className:`flex min-h-[calc(100dvh-var(--sat))] mt-[var(--sat)]`,children:[(0,B.jsx)(vl,{}),(0,B.jsx)(yl,{}),(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)(Kf,{}),!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)(rt,{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)(ip,{}),(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)(Hp,{}),children:(0,B.jsx)(f,{})})})]}),(0,B.jsx)(hd,{}),(0,B.jsx)(Ad,{}),(0,B.jsx)(Vd,{}),(0,B.jsx)(Hd,{}),(0,B.jsx)(Ud,{}),(0,B.jsx)(Wd,{}),(0,B.jsx)(Gd,{}),(0,B.jsx)(Kd,{}),(0,B.jsx)(Yd,{}),(0,B.jsx)(Xd,{}),(0,B.jsx)(rf,{}),(0,B.jsx)(sf,{}),(0,B.jsx)(cf,{}),(0,B.jsx)(Wf,{}),(0,B.jsx)($l,{}),(0,B.jsx)(Gf,{}),(0,B.jsx)(Up,{})]})})})}if((0,Vn.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(Wp,{})})),`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{Xl as A,Gc as B,Mu as C,bu as D,Du as E,ll as F,Zc as G,Xc as H,dl as I,el as J,Wc as K,sl as L,Al as M,ol as N,fu as O,cl as P,al as R,Cu as S,ku as T,Qc as U,Yc as V,$c as W,nl as X,tl as Y,Jn as Z,Bu as _,Q as a,xu as b,Id as c,fd as d,dd as f,Gu as g,$u as h,Nd as i,Fl as j,Yl as k,Rd as l,pd as m,$ as n,zd as o,md as p,Kc as q,Bd as r,Ld as s,Jd as t,Od as u,zu as v,Au as w,Su as x,Ru as y,W as z};
|
|
23
|
+
//# sourceMappingURL=index-3ydeNO0c.js.map
|