agent-relay-server 0.120.6 → 0.121.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/openapi.json +1 -1
- package/package.json +5 -4
- package/public/assets/{MessageBubble-So86mU9-.js → MessageBubble-CLqxCG9b.js} +2 -2
- package/public/assets/{MessageBubble-So86mU9-.js.map → MessageBubble-CLqxCG9b.js.map} +1 -1
- package/public/assets/{PlanGraphPanel-DBZYAsww.js → PlanGraphPanel-BkkToFEb.js} +2 -2
- package/public/assets/{PlanGraphPanel-DBZYAsww.js.map → PlanGraphPanel-BkkToFEb.js.map} +1 -1
- package/public/assets/{activity-CZNwmXg1.js → activity-D-ocGQGs.js} +2 -2
- package/public/assets/{activity-CZNwmXg1.js.map → activity-D-ocGQGs.js.map} +1 -1
- package/public/assets/{agent-profiles-BhadoGwi.js → agent-profiles-CRPgYTyb.js} +2 -2
- package/public/assets/{agent-profiles-BhadoGwi.js.map → agent-profiles-CRPgYTyb.js.map} +1 -1
- package/public/assets/{agents-DWn1xx9x.js → agents-Chw5E_2q.js} +2 -2
- package/public/assets/{agents-DWn1xx9x.js.map → agents-Chw5E_2q.js.map} +1 -1
- package/public/assets/{analytics-DifGnk7q.js → analytics-BmNDG0hR.js} +2 -2
- package/public/assets/{analytics-DifGnk7q.js.map → analytics-BmNDG0hR.js.map} +1 -1
- package/public/assets/{automation-BExrtKkb.js → automation-D7g90kTv.js} +2 -2
- package/public/assets/{automation-BExrtKkb.js.map → automation-D7g90kTv.js.map} +1 -1
- package/public/assets/{branch-state-badge-CyC5Qrhc.js → branch-state-badge-Bv7DhLBZ.js} +2 -2
- package/public/assets/{branch-state-badge-CyC5Qrhc.js.map → branch-state-badge-Bv7DhLBZ.js.map} +1 -1
- package/public/assets/{channels-BLkdt2XR.js → channels-CLwPeEPi.js} +2 -2
- package/public/assets/{channels-BLkdt2XR.js.map → channels-CLwPeEPi.js.map} +1 -1
- package/public/assets/{chat-C7OhKtr6.js → chat-Cgj7VKzc.js} +2 -2
- package/public/assets/{chat-C7OhKtr6.js.map → chat-Cgj7VKzc.js.map} +1 -1
- package/public/assets/{connectors-C0n12Je8.js → connectors-Br6fiTny.js} +2 -2
- package/public/assets/{connectors-C0n12Je8.js.map → connectors-Br6fiTny.js.map} +1 -1
- package/public/assets/{formatted-body-BCQT2qSb.js → formatted-body-CmkuD23M.js} +3 -3
- package/public/assets/{formatted-body-BCQT2qSb.js.map → formatted-body-CmkuD23M.js.map} +1 -1
- package/public/assets/{formatted-body-impl-Bk7wnESl.js → formatted-body-impl-DbdFmbwW.js} +2 -2
- package/public/assets/{formatted-body-impl-Bk7wnESl.js.map → formatted-body-impl-DbdFmbwW.js.map} +1 -1
- package/public/assets/{index-CRraCeo_.js → index-D9OogaB5.js} +6 -6
- package/public/assets/{index-CRraCeo_.js.map → index-D9OogaB5.js.map} +1 -1
- package/public/assets/{insights-DEgES6jz.js → insights-qvaPqWCV.js} +2 -2
- package/public/assets/{insights-DEgES6jz.js.map → insights-qvaPqWCV.js.map} +1 -1
- package/public/assets/{integrations-v14ehskT.js → integrations-DYEGSqq_.js} +2 -2
- package/public/assets/{integrations-v14ehskT.js.map → integrations-DYEGSqq_.js.map} +1 -1
- package/public/assets/{maintenance-BgVB6_gO.js → maintenance-C0HIEB-J.js} +2 -2
- package/public/assets/{maintenance-BgVB6_gO.js.map → maintenance-C0HIEB-J.js.map} +1 -1
- package/public/assets/{managed-agents-8_NKSkhI.js → managed-agents-DdS7aI38.js} +2 -2
- package/public/assets/{managed-agents-8_NKSkhI.js.map → managed-agents-DdS7aI38.js.map} +1 -1
- package/public/assets/{markdown-preview-impl-yxQkrd2M.js → markdown-preview-impl-BnXMH1z1.js} +2 -2
- package/public/assets/{markdown-preview-impl-yxQkrd2M.js.map → markdown-preview-impl-BnXMH1z1.js.map} +1 -1
- package/public/assets/{memory-CJD8eekg.js → memory-CSwx7bz8.js} +2 -2
- package/public/assets/{memory-CJD8eekg.js.map → memory-CSwx7bz8.js.map} +1 -1
- package/public/assets/{messages-DLHMZbHZ.js → messages-Be9CmvDv.js} +2 -2
- package/public/assets/{messages-DLHMZbHZ.js.map → messages-Be9CmvDv.js.map} +1 -1
- package/public/assets/{orchestrators-DEOep7FX.js → orchestrators-BgtvvHvo.js} +2 -2
- package/public/assets/{orchestrators-DEOep7FX.js.map → orchestrators-BgtvvHvo.js.map} +1 -1
- package/public/assets/{overview-BgpfO6mt.js → overview-BvhbPWtF.js} +2 -2
- package/public/assets/{overview-BgpfO6mt.js.map → overview-BvhbPWtF.js.map} +1 -1
- package/public/assets/{pairs-8NVKHh96.js → pairs-CpXSOMx0.js} +2 -2
- package/public/assets/{pairs-8NVKHh96.js.map → pairs-CpXSOMx0.js.map} +1 -1
- package/public/assets/{projects-CZJW35C7.js → projects-DdPNPFJI.js} +2 -2
- package/public/assets/{projects-CZJW35C7.js.map → projects-DdPNPFJI.js.map} +1 -1
- package/public/assets/{prompt-settings-fqyLwUa-.js → prompt-settings-BpZse7-X.js} +2 -2
- package/public/assets/{prompt-settings-fqyLwUa-.js.map → prompt-settings-BpZse7-X.js.map} +1 -1
- package/public/assets/{registry-BKbLL4mO.js → registry-pb1gTZEg.js} +2 -2
- package/public/assets/{registry-BKbLL4mO.js.map → registry-pb1gTZEg.js.map} +1 -1
- package/public/assets/{security-BlTFTbq0.js → security-BgcX1n9D.js} +2 -2
- package/public/assets/{security-BlTFTbq0.js.map → security-BgcX1n9D.js.map} +1 -1
- package/public/assets/{select-Zd_qh0uU.js → select-DZPVpKPv.js} +2 -2
- package/public/assets/{select-Zd_qh0uU.js.map → select-DZPVpKPv.js.map} +1 -1
- package/public/assets/{settings-nHuSVRkL.js → settings-hd5kzdRB.js} +4 -4
- package/public/assets/settings-hd5kzdRB.js.map +1 -0
- package/public/assets/store-DKTLubBT.js +9 -0
- package/public/assets/store-DKTLubBT.js.map +1 -0
- package/public/assets/{tasks-C3JhQ8vB.js → tasks-C5d2LU5E.js} +2 -2
- package/public/assets/{tasks-C3JhQ8vB.js.map → tasks-C5d2LU5E.js.map} +1 -1
- package/public/assets/{teams-C9E9Yt39.js → teams-B8f2pGJe.js} +2 -2
- package/public/assets/{teams-C9E9Yt39.js.map → teams-B8f2pGJe.js.map} +1 -1
- package/public/assets/{terminal-viewer-impl-FP0JlsvS.js → terminal-viewer-impl-CxAscH0U.js} +2 -2
- package/public/assets/{terminal-viewer-impl-FP0JlsvS.js.map → terminal-viewer-impl-CxAscH0U.js.map} +1 -1
- package/public/assets/types-uVOXgvMT.js.map +1 -1
- package/public/assets/{work-queue-Ema7Hy3s.js → work-queue-9imc7aNK.js} +2 -2
- package/public/assets/{work-queue-Ema7Hy3s.js.map → work-queue-9imc7aNK.js.map} +1 -1
- package/public/assets/{workspaces-DI317fMk.js → workspaces-CLYc3yF3.js} +2 -2
- package/public/assets/{workspaces-DI317fMk.js.map → workspaces-CLYc3yF3.js.map} +1 -1
- package/public/index.html +3 -3
- package/runner/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/runner/plugins/claude/monitors/relay-monitor.provisioned.mjs +4 -0
- package/src/agent-card-projection.ts +39 -9
- package/src/agent-issue-repo.ts +10 -3
- package/src/agent-lifecycle-events.ts +23 -1
- package/src/agent-ref.ts +18 -3
- package/src/bus-outbox.ts +74 -1
- package/src/bus.ts +84 -5
- package/src/channel-target.ts +4 -0
- package/src/cli/steward.ts +15 -14
- package/src/commands-db.ts +63 -9
- package/src/config-store.ts +2 -0
- package/src/config.ts +54 -0
- package/src/db/claim-sql.ts +16 -0
- package/src/db/connection.ts +3 -1
- package/src/db/continuations.ts +44 -3
- package/src/db/index.ts +1 -0
- package/src/db/maintenance-worker.ts +91 -0
- package/src/db/message-reads.ts +34 -4
- package/src/db/messages.ts +147 -8
- package/src/db/migrations.ts +7 -0
- package/src/db/pairs.ts +1 -0
- package/src/db/retention.ts +130 -0
- package/src/db/schema.ts +11 -0
- package/src/db/stats.ts +22 -0
- package/src/event-loop-lag.ts +90 -0
- package/src/gate-resolver.ts +124 -0
- package/src/lifecycle-manager.ts +41 -10
- package/src/lifecycle-signal-registry.ts +87 -0
- package/src/maintenance/constants.ts +5 -1
- package/src/maintenance/jobs.ts +48 -8
- package/src/maintenance/workspaces.ts +75 -44
- package/src/managed-policy-escalation.ts +68 -3
- package/src/mcp/tools-spawn.ts +16 -6
- package/src/mcp-plan-tools.ts +2 -3
- package/src/notification-settings.ts +11 -0
- package/src/notification-types.ts +4 -0
- package/src/operator-alarm.ts +37 -0
- package/src/retention-config-store.ts +32 -0
- package/src/retention-config.ts +58 -0
- package/src/routes/agents.ts +4 -0
- package/src/routes/messages.ts +13 -1
- package/src/routes/orchestrator-proxy.ts +13 -1
- package/src/routes/orchestrator.ts +4 -0
- package/src/routing-policy-store.ts +11 -1
- package/src/security.ts +20 -0
- package/src/self-resume.ts +185 -21
- package/src/server.ts +4 -0
- package/src/services/plan-graph.ts +42 -12
- package/src/services/register-agent.ts +5 -1
- package/src/services/send-message.ts +99 -21
- package/src/services/spawn-agent.ts +21 -2
- package/src/services/spawn-registration-watchdog.ts +74 -9
- package/src/services/task-semantic-events.ts +17 -1
- package/src/settings/registry.ts +11 -0
- package/src/spawn-command.ts +3 -0
- package/src/spawn-targets.ts +26 -1
- package/src/sse.ts +67 -14
- package/src/workspace-auto-merge.ts +90 -34
- package/src/workspace-escalation.ts +52 -3
- package/src/workspace-human-escalation.ts +68 -0
- package/src/workspace-orphans.ts +11 -6
- package/src/workspace-phase.ts +22 -1
- package/public/assets/settings-nHuSVRkL.js.map +0 -1
- package/public/assets/store-nXGxgz2Q.js +0 -9
- package/public/assets/store-nXGxgz2Q.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./bundle-web-DhRGKIGF.js","./chunk-CilyBKbf.js","./preload-helper-C_JMBXql.js","./lib-Cc7Il-6i.js","./markdown-preview-impl-
|
|
2
|
-
import{r as e,t}from"./chunk-CilyBKbf.js";import{$ as n,$n as r,A as i,At as a,B as o,Bn as s,Bt as c,D as l,Dt as u,E as d,En as f,Et as p,F as m,Ft as h,G as g,H as _,Ht as v,In as y,It as b,Jt as x,K as S,Kn as C,L as ee,Ln as w,Lt as te,Mn as T,Mt as ne,N as re,Nn as ie,On as ae,Pn as oe,Qt as E,R as D,Rn as se,Rt as ce,Sn as le,T as ue,Tn as de,U as fe,Ut as pe,V as me,W as he,X as ge,Xt as _e,Y as ve,Zt as ye,_ as be,_t as xe,a as Se,bn as Ce,bt as we,cn as Te,cr as O,dn as Ee,dt as De,en as Oe,er as k,fn as ke,ft as Ae,g as je,gn as Me,gt as Ne,h as Pe,hn as Fe,hr as Ie,ht as Le,i as Re,it as ze,jn as Be,jt as Ve,k as He,kt as Ue,n as We,nr as Ge,nt as Ke,o as qe,on as Je,ot as Ye,p as Xe,pn as Ze,pt as Qe,q as $e,qn as et,r as tt,rn as nt,rr as rt,s as it,sn as at,st as ot,t as st,tn as ct,tt as lt,u as ut,un as dt,ut as ft,vn as pt,w as mt,wn as ht,wt as gt,x as _t,xn as vt,xt as yt,y as bt,yt as xt,z as St,zn as Ct}from"./lucide-react-DuhlF2Sj.js";import{t as wt}from"./react-dom-DWBmcawP.js";import{c as Tt,f as Et,l as Dt,m as Ot,p as kt,r as At,t as A}from"./store-nXGxgz2Q.js";import{a as jt,d as Mt,f as Nt,h as Pt,i as Ft,n as It,p as Lt,r as Rt,u as zt}from"./types-uVOXgvMT.js";import{B as Bt,C as Vt,D as Ht,E as Ut,G as Wt,H as Gt,J as Kt,K as j,N as qt,O as Jt,P as Yt,Q as Xt,R as Zt,S as Qt,T as $t,W as en,X as tn,Y as nn,a as rn,c as an,ct as on,d as M,f as sn,h as cn,i as ln,j as un,k as dn,lt as fn,m as pn,n as mn,o as hn,ot as gn,p as _n,q as vn,r as yn,rt as bn,t as xn,u as Sn,w as Cn,x as wn,y as Tn}from"./display-exQDWum3.js";import{n as En,t as Dn}from"./themes-DjSwmAZN.js";import{a as On,i as kn,o as An,r as jn,t as Mn}from"./dist-BIjlN-xB.js";import{n as Nn,t as N}from"./dist-B9G83DXv.js";import{i as Pn,n as P,r as Fn,t as In}from"./dist-B-T7lg0a.js";import{t as Ln}from"./dist-BInckSJC.js";import{t as Rn}from"./dist-OUPTEP6q.js";import{t as zn}from"./dist-BlzVGRhh.js";import{a as Bn,i as Vn,n as Hn,o as Un,r as Wn,s as Gn,t as Kn}from"./es2015-CnKXYKpf.js";import{t as qn}from"./dist-DGfp5dLz.js";import{t as Jn}from"./dist-DT-OV6sQ.js";import{t as Yn}from"./dist-B6woQ9Tb.js";import{t as Xn}from"./dist-C7aTlosb.js";import{a as Zn,i as Qn,n as $n,r as er,t as tr}from"./dist-B3e4B9pg.js";import{t as nr}from"./dist-BiLuYU6G.js";import{t as F}from"./badge-DCIT3Irj.js";import{t as I}from"./button-CzdTkRIf.js";import{t as L}from"./input-B6Q0NWCS.js";import{t as rr}from"./copy-button-B3o1jpLu.js";import{t as R}from"./preload-helper-C_JMBXql.js";import{n as ir,t as ar}from"./agent-type-icon-CeEoMouY.js";import{t as or}from"./task-chip-DXfvXBDx.js";import{t as sr}from"./formatted-body-BCQT2qSb.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 cr=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,ne());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}var S=!1,C=-1,ee=5,w=-1;function te(){return g?!0:!(e.unstable_now()-w<ee)}function T(){if(g=!1,S){var t=e.unstable_now();w=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&&te());){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&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ne():S=!1}}}var ne;if(typeof y==`function`)ne=function(){y(T)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=T,ne=function(){ie.postMessage(null)}}else ne=function(){_(T,0)};function ae(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,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ne()))),r},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),lr=t(((e,t)=>{t.exports=cr()})),ur=t((e=>{var t=lr(),n=Ie(),r=wt();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`),w=Symbol.for(`react.lazy`),te=Symbol.for(`react.activity`),T=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?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 te: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?ae(e.type)||`Memo`:t;case w:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,E=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function ue(e){return{current:e}}function de(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function fe(e,t){le++,ce[le]=e.current,e.current=t}var pe=ue(null),me=ue(null),he=ue(null),ge=ue(null);function _e(e,t){switch(fe(he,t),fe(me,e),fe(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}de(pe),fe(pe,e)}function ve(){de(pe),de(me),de(he)}function ye(e){e.memoizedState!==null&&fe(ge,e);var t=pe.current,n=Ud(t,e.type);t!==n&&(fe(me,e),fe(pe,n))}function be(e){me.current===e&&(de(pe),de(me)),ge.current===e&&(de(ge),Qf._currentValue=se)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1<e.stack.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./bundle-web-DhRGKIGF.js","./chunk-CilyBKbf.js","./preload-helper-C_JMBXql.js","./lib-Cc7Il-6i.js","./markdown-preview-impl-BnXMH1z1.js","./lib-BHsWPMKB.js","./lucide-react-DuhlF2Sj.js","./terminal-viewer-impl-CxAscH0U.js","./store-DKTLubBT.js","./display-exQDWum3.js","./types-uVOXgvMT.js","./button-CzdTkRIf.js","./dist-BIjlN-xB.js","./use-keyboard-viewport-CP109w9y.js","./terminal-viewer-impl-BrP-ENHg.css","./overview-BvhbPWtF.js","./agent-type-icon-CeEoMouY.js","./badge-DCIT3Irj.js","./card-C3BGuVC6.js","./chat-Cgj7VKzc.js","./react-dom-DWBmcawP.js","./MessageBubble-CLqxCG9b.js","./formatted-body-CmkuD23M.js","./user-avatar-Dw6mzWhv.js","./PlanGraphPanel-BkkToFEb.js","./task-chip-DXfvXBDx.js","./branch-state-badge-Bv7DhLBZ.js","./copy-button-B3o1jpLu.js","./input-B6Q0NWCS.js","./agents-Chw5E_2q.js","./dist-B3e4B9pg.js","./dist-B-T7lg0a.js","./dist-B9G83DXv.js","./dist-DT-OV6sQ.js","./dist-C7aTlosb.js","./es2015-CnKXYKpf.js","./dist-BlzVGRhh.js","./dist-OUPTEP6q.js","./managed-agents-DdS7aI38.js","./teams-B8f2pGJe.js","./select-DZPVpKPv.js","./dist-BiLuYU6G.js","./dist-BInckSJC.js","./dist-DGfp5dLz.js","./dist-B6woQ9Tb.js","./agent-profiles-CRPgYTyb.js","./orchestrators-BgtvvHvo.js","./workspaces-CLYc3yF3.js","./channels-CLwPeEPi.js","./connectors-Br6fiTny.js","./integrations-DYEGSqq_.js","./security-BgcX1n9D.js","./memory-CSwx7bz8.js","./activity-D-ocGQGs.js","./pairs-CpXSOMx0.js","./messages-Be9CmvDv.js","./work-queue-9imc7aNK.js","./tasks-C5d2LU5E.js","./automation-D7g90kTv.js","./analytics-BmNDG0hR.js","./themes-DjSwmAZN.js","./insights-qvaPqWCV.js","./projects-DdPNPFJI.js","./prompt-settings-BpZse7-X.js","./registry-pb1gTZEg.js","./maintenance-C0HIEB-J.js","./settings-hd5kzdRB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e,t}from"./chunk-CilyBKbf.js";import{$ as n,$n as r,A as i,At as a,B as o,Bn as s,Bt as c,D as l,Dt as u,E as d,En as f,Et as p,F as m,Ft as h,G as g,H as _,Ht as v,In as y,It as b,Jt as x,K as S,Kn as C,L as ee,Ln as w,Lt as te,Mn as T,Mt as ne,N as re,Nn as ie,On as ae,Pn as oe,Qt as E,R as D,Rn as se,Rt as ce,Sn as le,T as ue,Tn as de,U as fe,Ut as pe,V as me,W as he,X as ge,Xt as _e,Y as ve,Zt as ye,_ as be,_t as xe,a as Se,bn as Ce,bt as we,cn as Te,cr as O,dn as Ee,dt as De,en as Oe,er as k,fn as ke,ft as Ae,g as je,gn as Me,gt as Ne,h as Pe,hn as Fe,hr as Ie,ht as Le,i as Re,it as ze,jn as Be,jt as Ve,k as He,kt as Ue,n as We,nr as Ge,nt as Ke,o as qe,on as Je,ot as Ye,p as Xe,pn as Ze,pt as Qe,q as $e,qn as et,r as tt,rn as nt,rr as rt,s as it,sn as at,st as ot,t as st,tn as ct,tt as lt,u as ut,un as dt,ut as ft,vn as pt,w as mt,wn as ht,wt as gt,x as _t,xn as vt,xt as yt,y as bt,yt as xt,z as St,zn as Ct}from"./lucide-react-DuhlF2Sj.js";import{t as wt}from"./react-dom-DWBmcawP.js";import{c as Tt,f as Et,l as Dt,m as Ot,p as kt,r as At,t as A}from"./store-DKTLubBT.js";import{a as jt,d as Mt,f as Nt,h as Pt,i as Ft,n as It,p as Lt,r as Rt,u as zt}from"./types-uVOXgvMT.js";import{B as Bt,C as Vt,D as Ht,E as Ut,G as Wt,H as Gt,J as Kt,K as j,N as qt,O as Jt,P as Yt,Q as Xt,R as Zt,S as Qt,T as $t,W as en,X as tn,Y as nn,a as rn,c as an,ct as on,d as M,f as sn,h as cn,i as ln,j as un,k as dn,lt as fn,m as pn,n as mn,o as hn,ot as gn,p as _n,q as vn,r as yn,rt as bn,t as xn,u as Sn,w as Cn,x as wn,y as Tn}from"./display-exQDWum3.js";import{n as En,t as Dn}from"./themes-DjSwmAZN.js";import{a as On,i as kn,o as An,r as jn,t as Mn}from"./dist-BIjlN-xB.js";import{n as Nn,t as N}from"./dist-B9G83DXv.js";import{i as Pn,n as P,r as Fn,t as In}from"./dist-B-T7lg0a.js";import{t as Ln}from"./dist-BInckSJC.js";import{t as Rn}from"./dist-OUPTEP6q.js";import{t as zn}from"./dist-BlzVGRhh.js";import{a as Bn,i as Vn,n as Hn,o as Un,r as Wn,s as Gn,t as Kn}from"./es2015-CnKXYKpf.js";import{t as qn}from"./dist-DGfp5dLz.js";import{t as Jn}from"./dist-DT-OV6sQ.js";import{t as Yn}from"./dist-B6woQ9Tb.js";import{t as Xn}from"./dist-C7aTlosb.js";import{a as Zn,i as Qn,n as $n,r as er,t as tr}from"./dist-B3e4B9pg.js";import{t as nr}from"./dist-BiLuYU6G.js";import{t as F}from"./badge-DCIT3Irj.js";import{t as I}from"./button-CzdTkRIf.js";import{t as L}from"./input-B6Q0NWCS.js";import{t as rr}from"./copy-button-B3o1jpLu.js";import{t as R}from"./preload-helper-C_JMBXql.js";import{n as ir,t as ar}from"./agent-type-icon-CeEoMouY.js";import{t as or}from"./task-chip-DXfvXBDx.js";import{t as sr}from"./formatted-body-CmkuD23M.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 cr=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,ne());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}var S=!1,C=-1,ee=5,w=-1;function te(){return g?!0:!(e.unstable_now()-w<ee)}function T(){if(g=!1,S){var t=e.unstable_now();w=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&&te());){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&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ne():S=!1}}}var ne;if(typeof y==`function`)ne=function(){y(T)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=T,ne=function(){ie.postMessage(null)}}else ne=function(){_(T,0)};function ae(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,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ne()))),r},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),lr=t(((e,t)=>{t.exports=cr()})),ur=t((e=>{var t=lr(),n=Ie(),r=wt();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`),w=Symbol.for(`react.lazy`),te=Symbol.for(`react.activity`),T=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?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 te: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?ae(e.type)||`Memo`:t;case w:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,E=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function ue(e){return{current:e}}function de(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function fe(e,t){le++,ce[le]=e.current,e.current=t}var pe=ue(null),me=ue(null),he=ue(null),ge=ue(null);function _e(e,t){switch(fe(he,t),fe(me,e),fe(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}de(pe),fe(pe,e)}function ve(){de(pe),de(me),de(he)}function ye(e){e.memoizedState!==null&&fe(ge,e);var t=pe.current,n=Ud(t,e.type);t!==n&&(fe(me,e),fe(pe,n))}function be(e){me.current===e&&(de(pe),de(me)),ge.current===e&&(de(ge),Qf._currentValue=se)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+xe+e+Se}var we=!1;function Te(e,t){if(!e||we)return``;we=!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(`
|
|
5
5
|
`),l=s.split(`
|
|
@@ -11,8 +11,8 @@ 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},ti=`DialogDescriptionWarning`,ni=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${$r(ti).contentName}}.`;return z.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},ri=Or,ii=Pr,ai=Ir,oi=Br,si=Gr,ci=qr,li=Yr,ui=`rovingFocusGroup.onEntryFocus`,di={bubbles:!1,cancelable:!0},fi=`RovingFocusGroup`,[pi,mi,hi]=Ln(fi),[gi,_i]=Pn(fi,[hi]),[vi,yi]=gi(fi),bi=z.forwardRef((e,t)=>(0,B.jsx)(pi.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(pi.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(xi,{...e,ref:t})})}));bi.displayName=fi;var xi=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=An(t,f),m=qn(a),[h,g]=Rn({prop:o,defaultProp:s??null,onChange:c,caller:fi}),[_,v]=z.useState(!1),y=Jn(l),b=mi(n),x=z.useRef(!1),[S,C]=z.useState(0);return z.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(ui,y),()=>e.removeEventListener(ui,y)},[y]),(0,B.jsx)(vi,{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(ui,di);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Di([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))})})}),Si=`RovingFocusGroupItem`,Ci=z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Gn(),l=a||c,u=yi(Si,n),d=u.currentTabStopId===l,f=mi(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return z.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,B.jsx)(pi.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=Ei(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?Oi(n,r+1):n.slice(r+1)}setTimeout(()=>Di(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Ci.displayName=Si;var wi={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ti(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Ei(e,t,n){let r=Ti(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return wi[r]}function Di(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Oi(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ki=bi,Ai=Ci,ji=[`Enter`,` `],Mi=[`ArrowDown`,`PageUp`,`Home`],V=[`ArrowUp`,`PageDown`,`End`],Ni=[...Mi,...V],Pi={ltr:[...ji,`ArrowRight`],rtl:[...ji,`ArrowLeft`]},Fi={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Ii=`Menu`,[Li,Ri,zi]=Ln(Ii),[Bi,Vi]=Pn(Ii,[zi,Zn,_i]),Hi=Zn(),Ui=_i(),[Wi,Gi]=Bi(Ii),[Ki,qi]=Bi(Ii),Ji=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Hi(t),[c,l]=z.useState(null),u=z.useRef(!1),d=Jn(a),f=qn(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)(Qn,{...s,children:(0,B.jsx)(Wi,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,B.jsx)(Ki,{scope:t,onClose:z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Ji.displayName=Ii;var Yi=`MenuAnchor`,Xi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Hi(n);return(0,B.jsx)(tr,{...i,...r,ref:t})});Xi.displayName=Yi;var Zi=`MenuPortal`,[Qi,$i]=Bi(Zi,{forceMount:void 0}),ea=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Gi(Zi,t);return(0,B.jsx)(Qi,{scope:t,forceMount:n,children:(0,B.jsx)(zn,{present:n||a.open,children:(0,B.jsx)(Vn,{asChild:!0,container:i,children:r})})})};ea.displayName=Zi;var ta=`MenuContent`,[na,ra]=Bi(ta),ia=z.forwardRef((e,t)=>{let n=$i(ta,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Gi(ta,e.__scopeMenu),o=qi(ta,e.__scopeMenu);return(0,B.jsx)(Li.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(zn,{present:r||a.open,children:(0,B.jsx)(Li.Slot,{scope:e.__scopeMenu,children:o.modal?(0,B.jsx)(aa,{...i,ref:t}):(0,B.jsx)(oa,{...i,ref:t})})})})}),aa=z.forwardRef((e,t)=>{let n=Gi(ta,e.__scopeMenu),r=z.useRef(null),i=An(t,r);return z.useEffect(()=>{let e=r.current;if(e)return Kn(e)},[]),(0,B.jsx)(ca,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),oa=z.forwardRef((e,t)=>{let n=Gi(ta,e.__scopeMenu);return(0,B.jsx)(ca,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),sa=jn(`MenuContent.ScrollLock`),ca=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=Gi(ta,n),_=qi(ta,n),v=Hi(n),y=Ui(n),b=Ri(n),[x,S]=z.useState(null),C=z.useRef(null),ee=An(t,C,g.onContentChange),w=z.useRef(0),te=z.useRef(``),T=z.useRef(0),ne=z.useRef(null),re=z.useRef(`right`),ie=z.useRef(0),ae=m?Hn:z.Fragment,oe=m?{as:sa,allowPinchZoom:!0}:void 0,E=e=>{let t=te.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Ka(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){te.current=t,window.clearTimeout(w.current),t!==``&&(w.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};z.useEffect(()=>()=>window.clearTimeout(w.current),[]),Wn();let D=z.useCallback(e=>re.current===ne.current?.side&&Ja(e,ne.current?.area),[]);return(0,B.jsx)(na,{scope:n,searchRef:te,onItemEnter:z.useCallback(e=>{D(e)&&e.preventDefault()},[D]),onItemLeave:z.useCallback(e=>{D(e)||(C.current?.focus(),S(null))},[D]),onTriggerLeave:z.useCallback(e=>{D(e)&&e.preventDefault()},[D]),pointerGraceTimerRef:T,onPointerGraceIntentChange:z.useCallback(e=>{ne.current=e},[]),children:(0,B.jsx)(ae,{...oe,children:(0,B.jsx)(Bn,{asChild:!0,trapped:i,onMountAutoFocus:P(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,B.jsx)(Un,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,B.jsx)(ki,{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)(er,{role:`menu`,"aria-orientation":`vertical`,"data-state":Va(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&&E(e.key));let i=C.current;if(e.target!==i||!Ni.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);V.includes(e.key)&&a.reverse(),Wa(a)}),onBlur:P(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(w.current),te.current=``)}),onPointerMove:P(e.onPointerMove,Ya(e=>{let t=e.target,n=ie.current!==e.clientX;e.currentTarget.contains(t)&&n&&(re.current=e.clientX>ie.current?`right`:`left`,ie.current=e.clientX)}))})})})})})})});ia.displayName=ta;var la=`MenuGroup`,ua=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`group`,...r,ref:t})});ua.displayName=la;var da=`MenuLabel`,fa=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{...r,ref:t})});fa.displayName=da;var pa=`MenuItem`,ma=`menu.itemSelect`,ha=z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=z.useRef(null),o=qi(pa,e.__scopeMenu),s=ra(pa,e.__scopeMenu),c=An(t,a),l=z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(ma,{bubbles:!0,cancelable:!0});e.addEventListener(ma,e=>r?.(e),{once:!0}),Nn(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,B.jsx)(ga,{...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===` `||ji.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ha.displayName=pa;var ga=z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=ra(pa,n),s=Ui(n),c=z.useRef(null),l=An(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)(Li.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,Ya(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:P(e.onPointerLeave,Ya(e=>o.onItemLeave(e))),onFocus:P(e.onFocus,()=>d(!0)),onBlur:P(e.onBlur,()=>d(!1))})})})}),_a=`MenuCheckboxItem`,va=z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,B.jsx)(Ea,{scope:e.__scopeMenu,checked:n,children:(0,B.jsx)(ha,{role:`menuitemcheckbox`,"aria-checked":Ha(n)?`mixed`:n,...i,ref:t,"data-state":Ua(n),onSelect:P(i.onSelect,()=>r?.(Ha(n)?!0:!n),{checkForDefaultPrevented:!1})})})});va.displayName=_a;var ya=`MenuRadioGroup`,[ba,xa]=Bi(ya,{value:void 0,onValueChange:()=>{}}),Sa=z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Jn(r);return(0,B.jsx)(ba,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,B.jsx)(ua,{...i,ref:t})})});Sa.displayName=ya;var Ca=`MenuRadioItem`,wa=z.forwardRef((e,t)=>{let{value:n,...r}=e,i=xa(Ca,e.__scopeMenu),a=n===i.value;return(0,B.jsx)(Ea,{scope:e.__scopeMenu,checked:a,children:(0,B.jsx)(ha,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ua(a),onSelect:P(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});wa.displayName=Ca;var Ta=`MenuItemIndicator`,[Ea,Da]=Bi(Ta,{checked:!1}),Oa=z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Da(Ta,n);return(0,B.jsx)(zn,{present:r||Ha(a.checked)||a.checked===!0,children:(0,B.jsx)(N.span,{...i,ref:t,"data-state":Ua(a.checked)})})});Oa.displayName=Ta;var ka=`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=ka;var ja=`MenuArrow`,Ma=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Hi(n);return(0,B.jsx)($n,{...i,...r,ref:t})});Ma.displayName=ja;var Na=`MenuSub`,[Pa,Fa]=Bi(Na),Ia=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Gi(Na,t),o=Hi(t),[s,c]=z.useState(null),[l,u]=z.useState(null),d=Jn(i);return z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,B.jsx)(Qn,{...o,children:(0,B.jsx)(Wi,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,B.jsx)(Pa,{scope:t,contentId:Gn(),triggerId:Gn(),trigger:s,onTriggerChange:c,children:n})})})};Ia.displayName=Na;var La=`MenuSubTrigger`,Ra=z.forwardRef((e,t)=>{let n=Gi(La,e.__scopeMenu),r=qi(La,e.__scopeMenu),i=Fa(La,e.__scopeMenu),a=ra(La,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)(Xi,{asChild:!0,...l,children:(0,B.jsx)(ga,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Va(n.open),...e,ref:On(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:P(e.onPointerMove,Ya(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,Ya(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===` `||Pi[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Ra.displayName=La;var za=`MenuSubContent`,Ba=z.forwardRef((e,t)=>{let n=$i(ta,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Gi(ta,e.__scopeMenu),o=qi(ta,e.__scopeMenu),s=Fa(za,e.__scopeMenu),c=z.useRef(null),l=An(t,c);return(0,B.jsx)(Li.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(zn,{present:r||a.open,children:(0,B.jsx)(Li.Slot,{scope:e.__scopeMenu,children:(0,B.jsx)(ca,{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=Fi[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Ba.displayName=za;function Va(e){return e?`open`:`closed`}function Ha(e){return e===`indeterminate`}function Ua(e){return Ha(e)?`indeterminate`:e?`checked`:`unchecked`}function Wa(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ga(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Ka(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ga(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 qa(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Ja(e,t){return t?qa({x:e.clientX,y:e.clientY},t):!1}function Ya(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Xa=Ji,Za=Xi,Qa=ea,$a=ia,eo=ua,to=fa,no=ha,ro=va,io=Sa,ao=wa,oo=Oa,so=Aa,co=Ma,lo=Ra,uo=Ba,H=`DropdownMenu`,[U,fo]=Pn(H,[Vi]),po=Vi(),[mo,ho]=U(H),go=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=po(t),l=z.useRef(null),[u,d]=Rn({prop:i,defaultProp:a??!1,onChange:o,caller:H});return(0,B.jsx)(mo,{scope:t,triggerId:Gn(),triggerRef:l,contentId:Gn(),open:u,onOpenChange:d,onOpenToggle:z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,B.jsx)(Xa,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};go.displayName=H;var _o=`DropdownMenuTrigger`,vo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ho(_o,n),o=po(n);return(0,B.jsx)(Za,{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:On(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())})})})});vo.displayName=_o;var yo=`DropdownMenuPortal`,bo=e=>{let{__scopeDropdownMenu:t,...n}=e,r=po(t);return(0,B.jsx)(Qa,{...r,...n})};bo.displayName=yo;var xo=`DropdownMenuContent`,So=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ho(xo,n),a=po(n),o=z.useRef(!1);return(0,B.jsx)($a,{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)`}})});So.displayName=xo;var Co=`DropdownMenuGroup`,wo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(eo,{...i,...r,ref:t})});wo.displayName=Co;var To=`DropdownMenuLabel`,Eo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(to,{...i,...r,ref:t})});Eo.displayName=To;var Do=`DropdownMenuItem`,Oo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(no,{...i,...r,ref:t})});Oo.displayName=Do;var ko=`DropdownMenuCheckboxItem`,Ao=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(ro,{...i,...r,ref:t})});Ao.displayName=ko;var jo=`DropdownMenuRadioGroup`,Mo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(io,{...i,...r,ref:t})});Mo.displayName=jo;var No=`DropdownMenuRadioItem`,Po=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(ao,{...i,...r,ref:t})});Po.displayName=No;var Fo=`DropdownMenuItemIndicator`,Io=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(oo,{...i,...r,ref:t})});Io.displayName=Fo;var Lo=`DropdownMenuSeparator`,Ro=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(so,{...i,...r,ref:t})});Ro.displayName=Lo;var zo=`DropdownMenuArrow`,Bo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(co,{...i,...r,ref:t})});Bo.displayName=zo;var Vo=`DropdownMenuSubTrigger`,Ho=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(lo,{...i,...r,ref:t})});Ho.displayName=Vo;var Uo=`DropdownMenuSubContent`,Wo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(uo,{...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)`}})});Wo.displayName=Uo;var Go=go,Ko=vo,qo=bo,Jo=So,Yo=Eo,Xo=Oo,Zo=Ro,Qo=`Label`,$o=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())}}));$o.displayName=Qo;var es=$o;function ts(e,t){return z.useReducer((e,n)=>t[e][n]??e,e)}var ns=`ScrollArea`,[rs,is]=Pn(ns),[as,os]=rs(ns),ss=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),w=An(t,e=>c(e)),te=qn(i);return(0,B.jsx)(as,{scope:n,type:r,dir:te,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:te,...o,ref:w,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});ss.displayName=ns;var cs=`ScrollAreaViewport`,ls=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=os(cs,n),s=An(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})})]})});ls.displayName=cs;var us=`ScrollAreaScrollbar`,ds=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=os(us,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)(fs,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,B.jsx)(ps,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,B.jsx)(ms,{...r,ref:t,forceMount:n}):i.type===`always`?(0,B.jsx)(hs,{...r,ref:t}):null});ds.displayName=us;var fs=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=os(us,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)(zn,{present:n||a,children:(0,B.jsx)(ms,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),ps=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=os(us,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Fs(()=>c(`SCROLL_END`),100),[s,c]=ts(`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)(zn,{present:n||s!==`hidden`,children:(0,B.jsx)(hs,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:P(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:P(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),ms=z.forwardRef((e,t)=>{let n=os(us,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=z.useState(!1),s=e.orientation===`horizontal`,c=Fs(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return Is(n.viewport,c),Is(n.content,c),(0,B.jsx)(zn,{present:r||a,children:(0,B.jsx)(hs,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),hs=z.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=os(us,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=Os(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 As(e,o.current,s,t)}return n===`horizontal`?(0,B.jsx)(gs,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=js(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)(_s,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=js(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}),gs=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=os(us,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=An(t,c,a.onScrollbarXChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(bs,{"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":ks(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),Ns(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:Ds(o.paddingLeft),paddingEnd:Ds(o.paddingRight)}})}})}),_s=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=os(us,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=An(t,c,a.onScrollbarYChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(bs,{"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":ks(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),Ns(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:Ds(o.paddingTop),paddingEnd:Ds(o.paddingBottom)}})}})}),[vs,ys]=rs(us),bs=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=os(us,n),[m,h]=z.useState(null),g=An(t,e=>h(e)),_=z.useRef(null),v=z.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Jn(u),S=Jn(c),C=Fs(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]),Is(m,C),Is(p.content,C),(0,B.jsx)(vs,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Jn(a),onThumbPointerUp:Jn(o),onThumbPositionChange:S,onThumbPointerDown:Jn(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})})})}),xs=`ScrollAreaThumb`,Ss=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=ys(xs,e.__scopeScrollArea);return(0,B.jsx)(zn,{present:n||i.hasThumb,children:(0,B.jsx)(Cs,{ref:t,...r})})}),Cs=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=os(xs,n),o=ys(xs,n),{onThumbPositionChange:s}=o,c=An(t,e=>o.onThumbChange(e)),l=z.useRef(void 0),u=Fs(()=>{l.current&&=(l.current(),void 0)},100);return z.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=Ps(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)})});Ss.displayName=xs;var ws=`ScrollAreaCorner`,Ts=z.forwardRef((e,t)=>{let n=os(ws,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,B.jsx)(Es,{...e,ref:t}):null});Ts.displayName=ws;var Es=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=os(ws,n),[a,o]=z.useState(0),[s,c]=z.useState(0),l=!!(a&&s);return Is(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),Is(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 Ds(e){return e?parseInt(e,10):0}function Os(e,t){let n=e/t;return isNaN(n)?0:n}function ks(e){let t=Os(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function As(e,t,n,r=`ltr`){let i=ks(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 Ms([c,l],d)(e)}function js(e,t,n=`ltr`){let r=ks(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=nr(e,n===`ltr`?[0,o]:[o*-1,0]);return Ms([0,o],[0,s])(c)}function Ms(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 Ns(e,t){return e>0&&e<t}var Ps=(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 Fs(e,t){let n=Jn(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 Is(e,t){let n=Jn(t);In(()=>{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 Ls=ss,Rs=ls,zs=Ts,Bs=`Separator`,Vs=`horizontal`,Hs=[`horizontal`,`vertical`],Us=z.forwardRef((e,t)=>{let{decorative:n,orientation:r=Vs,...i}=e,a=Ws(r)?r:Vs,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})});Us.displayName=Bs;function Ws(e){return Hs.includes(e)}var Gs=Us,Ks=`Switch`,[qs,Js]=Pn(Ks),[Ys,Xs]=qs(Ks),Zs=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=An(t,e=>p(e)),h=z.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=Rn({prop:i,defaultProp:a??!1,onChange:l,caller:Ks});return(0,B.jsxs)(Ys,{scope:n,checked:_,disabled:s,children:[(0,B.jsx)(N.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":nc(_),"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)(tc,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Zs.displayName=Ks;var Qs=`SwitchThumb`,$s=z.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Xs(Qs,n);return(0,B.jsx)(N.span,{"data-state":nc(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});$s.displayName=Qs;var ec=`SwitchBubbleInput`,tc=z.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=z.useRef(null),s=An(o,a),c=Yn(n),l=Xn(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}})});tc.displayName=ec;function nc(e){return e?`checked`:`unchecked`}var rc=Zs,ic=$s,ac=`Tabs`,[oc,sc]=Pn(ac,[_i]),cc=_i(),[lc,uc]=oc(ac),dc=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=qn(s),[d,f]=Rn({prop:r,onChange:i,defaultProp:a??``,caller:ac});return(0,B.jsx)(lc,{scope:n,baseId:Gn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,B.jsx)(N.div,{dir:u,"data-orientation":o,...l,ref:t})})});dc.displayName=ac;var fc=`TabsList`,pc=z.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=uc(fc,n),o=cc(n);return(0,B.jsx)(ki,{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})})});pc.displayName=fc;var mc=`TabsTrigger`,hc=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=uc(mc,n),s=cc(n),c=vc(o.baseId,r),l=yc(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)})})})});hc.displayName=mc;var gc=`TabsContent`,_c=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=uc(gc,n),c=vc(s.baseId,r),l=yc(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)(zn,{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})})});_c.displayName=gc;function vc(e,t){return`${e}-trigger-${t}`}function yc(e,t){return`${e}-content-${t}`}var bc=dc,xc=pc,Sc=hc,Cc=_c,[wc,Tc]=Pn(`Tooltip`,[Zn]),Ec=Zn(),Dc=`TooltipProvider`,Oc=700,kc=`tooltip.open`,[Ac,jc]=wc(Dc),Mc=e=>{let{__scopeTooltip:t,delayDuration:n=Oc,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)(Ac,{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})};Mc.displayName=Dc;var Nc=`Tooltip`,[Pc,Fc]=wc(Nc),Ic=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=jc(Nc,e.__scopeTooltip),l=Ec(t),[u,d]=z.useState(null),f=Gn(),p=z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=z.useRef(!1),[_,v]=Rn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(kc))):c.onClose(),a?.(e)},caller:Nc}),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)(Qn,{...l,children:(0,B.jsx)(Pc,{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})})};Ic.displayName=Nc;var Lc=`TooltipTrigger`,Rc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Fc(Lc,n),a=jc(Lc,n),o=Ec(n),s=An(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)(tr,{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)})})});Rc.displayName=Lc;var zc=`TooltipPortal`,[Bc,Vc]=wc(zc,{forceMount:void 0}),Hc=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Fc(zc,t);return(0,B.jsx)(Bc,{scope:t,forceMount:n,children:(0,B.jsx)(zn,{present:n||a.open,children:(0,B.jsx)(Vn,{asChild:!0,container:i,children:r})})})};Hc.displayName=zc;var Uc=`TooltipContent`,Wc=z.forwardRef((e,t)=>{let n=Vc(Uc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Fc(Uc,e.__scopeTooltip);return(0,B.jsx)(zn,{present:r||o.open,children:o.disableHoverableContent?(0,B.jsx)(Yc,{side:i,...a,ref:t}):(0,B.jsx)(Gc,{side:i,...a,ref:t})})}),Gc=z.forwardRef((e,t)=>{let n=Fc(Uc,e.__scopeTooltip),r=jc(Uc,e.__scopeTooltip),i=z.useRef(null),a=An(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=$c(r,Qc(r,n.getBoundingClientRect())),a=el(t.getBoundingClientRect());s(nl([...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=!tl(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,B.jsx)(Yc,{...e,ref:a})}),[Kc,qc]=wc(Nc,{isInside:!1}),Jc=kn(`TooltipContent`),Yc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Fc(Uc,n),l=Ec(n),{onClose:u}=c;return z.useEffect(()=>(document.addEventListener(kc,u),()=>document.removeEventListener(kc,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)(Un,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,B.jsxs)(er,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,B.jsx)(Jc,{children:r}),(0,B.jsx)(Kc,{scope:n,isInside:!0,children:(0,B.jsx)(Sr,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Wc.displayName=Uc;var Xc=`TooltipArrow`,Zc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Ec(n);return qc(Xc,n).isInside?null:(0,B.jsx)($n,{...i,...r,ref:t})});Zc.displayName=Xc;function Qc(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 $c(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 el(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 tl(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 nl(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)),rl(t)}function rl(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 il=Mc,al=Ic,ol=Rc,sl=Hc,cl=Wc,ll=Zc;function ul({delayDuration:e=0,...t}){return(0,B.jsx)(il,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function dl({...e}){return(0,B.jsx)(al,{"data-slot":`tooltip`,...e})}function fl({...e}){return(0,B.jsx)(ol,{"data-slot":`tooltip-trigger`,...e})}function pl({className:e,sideOffset:t=0,children:n,...r}){return(0,B.jsx)(sl,{children:(0,B.jsxs)(cl,{"data-slot":`tooltip-content`,sideOffset:t,className:k(`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)(ll,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function W(e){return A(e)}function ml(){let e=W(e=>e.pairs);return(0,z.useMemo)(()=>{let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t},[e])}function hl(e){let t=W(e=>e.messages),n=W(e=>e.tasks),r=W(e=>e.pairs),i=W(e=>e.inboxReadCursors),a=W(e=>e.inboxArchivedThreads);return(0,z.useMemo)(()=>{if(!e)return{unread:0,needsHumanResponse:!1,pendingPairInvite:!1,claimableTasks:0,total:0,score:0};let o=t.filter(t=>Tn(t)===e.id&&!Ut(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>$t(e)&&Qt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>Jt(i,e.id,t)).length,l=yn(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=>Cn(t)&&Sn(t.target,e)).length+t.filter(t=>Vt(t)&&Sn(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 gl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.showOffline),r=W(e=>e.agentSort),i=W(e=>e.agentSortDir),a=W(e=>e.agentPresetFilter),o=W(e=>e.agentStatusFilter),s=W(e=>e.agentTagFilter),c=W(e=>e.agentHostFilter),l=W(e=>e.managedPolicies),u=W(e=>e.pairs);return(0,z.useMemo)(()=>{let d=tn(e,t,l);if(a){let e=_l(u);d=vl(d,a,Et.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)):((fn[e.status]??9)-(fn[t.status]??9))*f||M(e).localeCompare(M(t)))},[e,t,n,l,r,i,a,o,s,c,u,Ot()])}function _l(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 vl(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`||wn(n,e));case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return Lt().includes(t)?e.filter(e=>hn(e)===t):e}}function yl(){let e=W(e=>e.messages),t=W(e=>e.inboxReadCursors),n=W(e=>e.inboxArchivedThreads),r=W(e=>e.inboxDrafts),i=W(e=>e.agentsById),a=W(e=>e.coordinatorMutes);return(0,z.useMemo)(()=>{let o=new Map;for(let t of e){if(Ut(t))continue;let e=Tn(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&&!Ht(n)){o=n;break}}e.previewMessage=o||e.lastMessage;let s=a.includes(e.peer),c=s?0:e.messages.filter(n=>Jt(t,e.peer,n)).length,l=s?!1:yn(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 bl(){let e=yl(),t=W(e=>e.agents),n=W(e=>e.showBuiltIns),r=W(e=>e.showOffline),i=W(e=>e.managedPolicies),a=W(e=>e.pairs),o=W(e=>e.tasks),s=W(e=>e.messages),c=(0,z.useMemo)(()=>new Set(tn(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=tn(t,n,i).filter(e=>(r||e.status!==`offline`)&&yn(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(Cn).length+s.filter(Vt).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 xl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>tn(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function Sl(){let e=W(e=>e.agents);return(0,z.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function Cl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.showOffline),r=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let i=tn(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function wl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(tn(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function Tl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(tn(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function El(){let e=W(e=>e.tasks),t=W(e=>e.messages);return(0,z.useMemo)(()=>{let n=e.filter(e=>(e.kind??`claim`)===`claim`).filter(e=>!Xt.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:Cn(e),task:e})),r=t.filter(Vt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:dn(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:Vt(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?vn(e.updatedAt)-vn(t.updatedAt):i})},[e,t])}function Dl(){let e=W(e=>e.commandQuery),t=W(e=>e.agents),n=W(e=>e.agentsById),r=W(e=>e.showBuiltIns),i=W(e=>e.showOffline),a=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let n=tn(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=O(),c=[Ol(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),Ol(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),Ol(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),Ol(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),Ol(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),Ol(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),Ol(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>Ol(`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=>Ol(`pair-`+e.id,`Pair: `+M(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>Ol(`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 Ol(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 kl({className:e,size:t=`default`,...n}){return(0,B.jsx)(rc,{"data-slot":`switch`,"data-size":t,className:k(`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)(ic,{"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 G({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,B.jsx)(Gs,{"data-slot":`separator`,decorative:n,orientation:t,className:k(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}function Al({...e}){return(0,B.jsx)(Go,{"data-slot":`dropdown-menu`,...e})}function jl({...e}){return(0,B.jsx)(Ko,{"data-slot":`dropdown-menu-trigger`,...e})}function Ml({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,B.jsx)(qo,{children:(0,B.jsx)(Jo,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:k(`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 Nl({className:e,inset:t,variant:n=`default`,...r}){return(0,B.jsx)(Xo,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:k(`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 Pl({className:e,inset:t,...n}){return(0,B.jsx)(Yo,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:k(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function Fl({className:e,...t}){return(0,B.jsx)(Zo,{"data-slot":`dropdown-menu-separator`,className:k(`-mx-1 my-1 h-px bg-border`,e),...t})}var Il={LayoutDashboard:we,MessageCircle:ze,Bot:w,Server:l,MessagesSquare:lt,Plug:o,PlugZap:_,Activity:r,Link:Ne,Mail:ot,ListChecks:Le,ClipboardList:dt,CalendarClock:Be,AreaChart:ae,Settings:d,Workflow:it,BrainCircuit:oe,FolderTree:b,Shield:mt,Wrench:qe,UserCog:Xe,Lightbulb:xt,Users:ut,Boxes:y,PackagePlus:ge,FileText:pe};function Ll(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var Rl=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function K(){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?s:Ct;function d(e){i({notificationSettings:{...n,...e}})}return(0,B.jsxs)(Al,{onOpenChange:e=>{e&&o()},children:[(0,B.jsx)(jl,{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)(Ml,{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)(Pl,{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)(f,{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)(je,{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)(kl,{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)(kl,{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:Rl.map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>d({[e]:!n[e]}),className:k(`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)(Fl,{}),(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)(Nl,{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:k(`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:Ll(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 zl(){let e=A(e=>e.theme),t=A(e=>e.set);return(0,B.jsxs)(Al,{children:[(0,B.jsx)(jl,{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)(ve,{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:Dn.find(t=>t.id===e)?.label})]})}),(0,B.jsx)(Ml,{align:`start`,side:`right`,className:`w-40`,children:Dn.map(n=>(0,B.jsxs)(Nl,{onSelect:()=>t({theme:n.id}),children:[(0,B.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,B.jsx)(de,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function q(){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=bl(),f=xl();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:gn.map(n=>{let r=Il[n.icon]||w;return(0,B.jsxs)(`button`,{onClick:()=>t(n.key),className:k(`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:k(`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)(Je,{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)(K,{}),(0,B.jsx)(zl,{}),(0,B.jsx)(G,{}),(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)(kl,{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)(kl,{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)(kl,{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 J(){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)(D,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,B.jsx)(q,{})]})}function Y(){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:k(`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:k(`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)(D,{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)(Se,{className:`w-4 h-4`})})]}),(0,B.jsx)(q,{})]})]})}var Bl=500*1024,Vl={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`},Hl={".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`},Ul=null;function Wl(){return Ul??=R(()=>import(`./bundle-web-DhRGKIGF.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),Ul}function Gl(e){return new TextEncoder().encode(e).length}function Kl(e){return e.split(`/`).filter(Boolean).pop()||e}function ql(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 Jl(e,t,n,r){if(n)return n;let i=Kl(e).toLowerCase();if(Hl[i])return Hl[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=ql(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&Vl[o]?Vl[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 Yl(e,t,n,r){let i=Jl(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var Xl=(0,z.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=A(e=>e.theme),o=Dn.find(e=>e.id===a)?.dark??!0,s=(0,z.useMemo)(()=>Jl(t,n,r,e)||`text`,[e,r,n,t]),c=Gl(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)(rr,{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)(Qe,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):c||p||!l?(0,B.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,B.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,children:e||` `})]}):(0,B.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,B.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:l}})]})}),Zl=(0,z.lazy)(()=>R(()=>import(`./markdown-preview-impl-yxQkrd2M.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function Ql(e){return(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading preview…`}),children:(0,B.jsx)(Zl,{...e})})}var $l=e(wt(),1);function eu({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)(We,{className:`h-4 w-4`}):(0,B.jsx)(tt,{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)(Se,{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 tu({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,$l.createPortal)((0,B.jsx)(eu,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var nu=`agent-relay:file-git-status`;function ru(){try{return window.localStorage.getItem(nu)!==`off`}catch{return!0}}function iu(e){try{window.localStorage.setItem(nu,e?`on`:`off`)}catch{}}function au(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 ou(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function su({status:e}){let t=au(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 cu(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function lu(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function uu(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function du(e,t,n){return uu(e,t)?`markdown`:Yl(e,t,void 0,n)?`code`:null}function fu(e){return`agent-relay:file-view-mode:${e}`}function pu(e){try{let t=window.localStorage.getItem(fu(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function mu(e,t){try{window.localStorage.setItem(fu(e),t)}catch{}}function hu(e,t){let n=lu(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 gu(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(zt(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function _u(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`,ou(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(zt(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function vu({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 yu({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:a,error:o}=_u(e,t,r);return(0,z.useEffect)(()=>{n(o)},[o,n]),t?a?(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Qe,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):o?(0,B.jsx)(`div`,{className:`h-full bg-muted/20`}):i?(0,B.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(h,{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`?h:v,n=au(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)(xe,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(su,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:cu(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 bu({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:a,error:o}=gu(e,t),s=(0,z.useRef)(null),[c,l]=(0,z.useState)(`raw`);(0,z.useEffect)(()=>{r(o)},[o,r]),(0,z.useEffect)(()=>{n>0&&s.current?.scrollIntoView({block:`center`})},[i,n]),(0,z.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){l(`raw`);return}let e=du(i.path,i.mediaType,i.content);l(e?pu(e):`raw`)},[i?.path,i?.encoding,i?.mediaType,i?.content,n]);function u(e,t){l(e),t&&mu(t,e)}if(!t)return(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a file to preview`});if(a)return(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Qe,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(o)return(0,B.jsx)(`div`,{className:`h-full bg-muted/20`});if(!i)return null;if(i.encoding===`base64`)return(0,B.jsxs)(`div`,{className:`flex h-full flex-col bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(v,{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)(rr,{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:cu(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)(tu,{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:cu(i.size)})]})]});let d=i.content??``,f=uu(i.path,i.mediaType),p=!f&&Yl(i.path,i.mediaType,void 0,d),m=f||p,h=f?`markdown`:p?`code`:null;return(0,B.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(v,{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)(rr,{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:cu(i.size)}),m&&(0,B.jsxs)(`div`,{className:`flex shrink-0 rounded-md border border-border bg-muted/40 p-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`raw`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`raw`,h),children:`Raw`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`rendered`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`rendered`,h),children:f?`Rendered`:`Highlighted`})]})]}),c===`rendered`&&f&&(0,B.jsx)(Ql,{content:d,path:i.path}),c===`rendered`&&p&&(0,B.jsx)(Xl,{content:d,path:i.path,mediaType:i.mediaType}),c===`raw`&&(0,B.jsx)(vu,{content:d,line:n,lineRef:s})]})}function xu({overlay:e=!1}){let t=A(e=>e.apiCall),n=A(e=>e.orchestrators),r=A(e=>e.fileOrchestratorId),i=A(e=>e.filePath),a=A(e=>e.fileSelectedPath),o=A(e=>e.fileSelectedLine),s=A(e=>e.set),c=A(e=>e.closeFileOverlay),l=A(e=>e.openOrchestratorSpawnAt),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(i),[m,g]=(0,z.useState)(!1),[_,y]=(0,z.useState)(``),[x,S]=(0,z.useState)(``),[C,w]=(0,z.useState)(ru),te=(0,z.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),T=n.find(e=>e.id===r)||te[0];(0,z.useEffect)(()=>{if(!T)return;let e={};r||(e.fileOrchestratorId=T.id),i||(e.filePath=T.baseDir),Object.keys(e).length&&s(e)},[r,i,T,s]),(0,z.useEffect)(()=>p(i),[i]);async function re(e=i){if(!(!T||!e)){g(!0),y(``);try{let n=await t(`GET`,ou(T.id,e,C));d(n),s({filePath:n.path}),p(n.path),S(``)}catch(e){y(zt(e))}finally{g(!1)}}}(0,z.useEffect)(()=>{re(i)},[T?.id,i,C]);function ie(e){w(e),iu(e)}function ae(e){s({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function oe(e){S(``),e.type===`directory`?s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):s({fileSelectedPath:e.path,fileSelectedLine:0})}function E(){if(!T)return;let t=f.trim()||i||T.baseDir;e&&c(),l({orchestratorId:T.id,cwd:t})}let D=u?hu(u.path,u.baseDir):[],se=_||x;return(0,B.jsxs)(`div`,{className:e?`flex h-full flex-col`:`flex h-[calc(100dvh-5rem)] flex-col gap-3 md:gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,B.jsx)(b,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,B.jsxs)(`select`,{value:T?.id||``,onChange:e=>ae(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[te.length===0&&(0,B.jsx)(`option`,{value:``,children:`No online orchestrators`}),te.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.hostname||e.id},e.id))]}),e&&(0,B.jsx)(I,{size:`icon`,variant:`ghost`,className:`ml-auto h-8 w-8`,onClick:c,title:`Close`,children:(0,B.jsx)(Se,{className:`h-4 w-4`})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,B.jsx)(L,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s({filePath:f,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:T?.baseDir||`Path`}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>re(f),disabled:m||!T,children:[m?(0,B.jsx)(Qe,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(ee,{className:`h-3.5 w-3.5`}),`Open`]}),(0,B.jsxs)(I,{size:`sm`,className:`gap-1`,onClick:E,disabled:!T,children:[(0,B.jsx)(me,{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)(ne,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,B.jsx)(kl,{checked:C,onCheckedChange:ie})]})]}),D.length>0&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${a?`hidden md:flex`:``}`,children:D.map((e,t)=>(0,B.jsxs)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 font-mono hover:bg-accent hover:text-foreground`,onClick:()=>s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}),children:[e.label,t<D.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),se&&(0,B.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:se}),(0,B.jsxs)(`div`,{className:`grid min-h-0 flex-1 overflow-hidden md:rounded-md md:border md:border-border md:grid-cols-[22rem_minmax(0,1fr)] ${a?``:`rounded-md border border-border`}`,children:[(0,B.jsxs)(`div`,{className:`min-h-0 overflow-auto border-b border-border bg-card md:border-b-0 md:border-r ${a?`hidden md:block`:``}`,children:[u?.parent&&(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent`,onClick:()=>s({filePath:u.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(nt,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{children:`Parent directory`})]}),u?.entries.map(e=>{let t=a===e.path||i===e.path,n=e.type===`directory`?h:v,r=au(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:()=>oe(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)(xe,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(su,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:cu(e.size)})]},e.path)}),!m&&u&&u.entries.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden ${a?``:`hidden md:flex`}`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs text-muted-foreground hover:text-foreground md:hidden`,onClick:()=>s({fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(nt,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(bu,{orchestratorId:T?.id||``,selectedPath:a,line:o,onReadError:S})})]})]})]})}function Su(){return(0,B.jsx)(xu,{})}function Cu(){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)(xu,{overlay:!0})})}):null}var wu=!1;function Tu(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;wu=!1,window.history.pushState({sheetGuard:!0},``),n.current=!0;function t(){if(wu){wu=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,wu=!0,window.history.back())}},[e])}function Eu({...e}){return Tu(e.open,e.onOpenChange),(0,B.jsx)(ri,{"data-slot":`sheet`,...e})}function Du({...e}){return(0,B.jsx)(li,{"data-slot":`sheet-close`,...e})}function Ou({...e}){return(0,B.jsx)(ii,{"data-slot":`sheet-portal`,...e})}function ku({className:e,...t}){return(0,B.jsx)(ai,{"data-slot":`sheet-overlay`,className:k(`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 Au({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,B.jsxs)(Ou,{children:[(0,B.jsx)(ku,{}),(0,B.jsxs)(oi,{"data-slot":`sheet-content`,"data-side":n,className:k(`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)(li,{"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)(Se,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function ju({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`sheet-header`,className:k(`flex flex-col gap-0.5 p-4`,e),...t})}function Mu({className:e,...t}){return(0,B.jsx)(si,{"data-slot":`sheet-title`,className:k(`font-heading text-base font-medium text-foreground`,e),...t})}function Nu({className:e,orientation:t=`horizontal`,...n}){return(0,B.jsx)(bc,{"data-slot":`tabs`,"data-orientation":t,className:k(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Pu=Mn(`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 Fu({className:e,variant:t=`default`,...n}){return(0,B.jsx)(xc,{"data-slot":`tabs-list`,"data-variant":t,className:k(Pu({variant:t}),e),...n})}function Iu({className:e,...t}){return(0,B.jsx)(Sc,{"data-slot":`tabs-trigger`,className:k(`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 Lu({className:e,...t}){return(0,B.jsx)(Cc,{"data-slot":`tabs-content`,className:k(`flex-1 text-sm outline-none`,e),...t})}function Ru({agent:e,now:t,className:n}){return(0,B.jsx)(`span`,{className:k(`inline-block w-2.5 h-2.5 rounded-full shrink-0`,Wt(e,t),n)})}function zu({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 Bu({agent:e,compact:t=!1,className:n=``}){let r=Hu(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 Vu({agent:e}){let t=e.context;if(!t)return null;let n=Zu(t);if(n===null)return(0,B.jsxs)(`div`,{className:`space-y-1`,title:Qu(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:Qu(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 Hu(e){let t=Uu(e),n=Wu(e),r=Gu(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?m:T,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 Uu(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Wu(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:Ae,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:x,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:De,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Gu(e){let t=X(e.meta?.workspace),n=Nt(t.requestedMode)||Nt(e.meta?.workspaceMode),r=Nt(t.mode),i=n&&n!==`inherit`?n:r&&n!==`inherit`?r:`default`;return i===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:ne,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:i===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:ue,iconColor:`text-cyan-300`,className:`border-cyan-500/30 bg-cyan-500/10 text-cyan-300`}:{key:`workspace`,label:`Default`,title:r?`Workspace: default/inherit, resolved to ${r}`:`Workspace: default/inherit`,Icon:yt,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function X(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Ku(e){let t=X(e.meta?.workspace),n=Nt(t.repoRoot)||Nt(t.sourceCwd)||Nt(e.meta?.cwd);return n?en(n,2):``}function qu(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=xn(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=Zu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function Yu({context:e,expected:t=!!e,size:n=26,className:r}){let i=Zu(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:Qu(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 Xu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${$u(t.tokensUsed)} / ${$u(t.tokensMax)}`:t.tokensUsed?$u(t.tokensUsed):t.tokensMax?$u(t.tokensMax):null}function Zu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function Qu(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=Zu(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 $u(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var ed=(0,z.lazy)(()=>R(()=>import(`./terminal-viewer-impl-FP0JlsvS.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13,14]),import.meta.url));function td(e){return e.open?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(ed,{...e})}):null}function nd({orchestratorId:e,session:t,lines:n=200}){let r=A(e=>e.apiCall),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(`provider`),[p,m]=(0,z.useState)(null);async function h(){if(!l)try{o((await r(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${n}${d===`mirror`?`&stream=mirror`:``}`)).lines||[]),m(null)}catch(e){m(zt(e))}}(0,z.useEffect)(()=>{h();let e=setInterval(()=>void h(),1500);return()=>clearInterval(e)},[e,t,l,d]);let g=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)(i,{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:()=>f(`provider`),title:`Provider output`,className:k(`flex items-center gap-1 px-2 py-1.5 text-xs`,d===`provider`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,B.jsx)(be,{className:`h-3.5 w-3.5`}),` Output`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>f(`mirror`),title:`Session-mirror diagnostics (clean)`,className:k(`flex items-center gap-1 px-2 py-1.5 text-xs border-l border-border`,d===`mirror`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,B.jsx)(ie,{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)(fe,{className:`h-4 w-4`}):(0,B.jsx)($e,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>_n(`${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},ti=`DialogDescriptionWarning`,ni=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${$r(ti).contentName}}.`;return z.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},ri=Or,ii=Pr,ai=Ir,oi=Br,si=Gr,ci=qr,li=Yr,ui=`rovingFocusGroup.onEntryFocus`,di={bubbles:!1,cancelable:!0},fi=`RovingFocusGroup`,[pi,mi,hi]=Ln(fi),[gi,_i]=Pn(fi,[hi]),[vi,yi]=gi(fi),bi=z.forwardRef((e,t)=>(0,B.jsx)(pi.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(pi.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,B.jsx)(xi,{...e,ref:t})})}));bi.displayName=fi;var xi=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=An(t,f),m=qn(a),[h,g]=Rn({prop:o,defaultProp:s??null,onChange:c,caller:fi}),[_,v]=z.useState(!1),y=Jn(l),b=mi(n),x=z.useRef(!1),[S,C]=z.useState(0);return z.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(ui,y),()=>e.removeEventListener(ui,y)},[y]),(0,B.jsx)(vi,{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(ui,di);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Di([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))})})}),Si=`RovingFocusGroupItem`,Ci=z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Gn(),l=a||c,u=yi(Si,n),d=u.currentTabStopId===l,f=mi(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return z.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,B.jsx)(pi.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=Ei(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?Oi(n,r+1):n.slice(r+1)}setTimeout(()=>Di(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Ci.displayName=Si;var wi={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ti(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Ei(e,t,n){let r=Ti(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return wi[r]}function Di(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Oi(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ki=bi,Ai=Ci,ji=[`Enter`,` `],Mi=[`ArrowDown`,`PageUp`,`Home`],V=[`ArrowUp`,`PageDown`,`End`],Ni=[...Mi,...V],Pi={ltr:[...ji,`ArrowRight`],rtl:[...ji,`ArrowLeft`]},Fi={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Ii=`Menu`,[Li,Ri,zi]=Ln(Ii),[Bi,Vi]=Pn(Ii,[zi,Zn,_i]),Hi=Zn(),Ui=_i(),[Wi,Gi]=Bi(Ii),[Ki,qi]=Bi(Ii),Ji=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Hi(t),[c,l]=z.useState(null),u=z.useRef(!1),d=Jn(a),f=qn(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)(Qn,{...s,children:(0,B.jsx)(Wi,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,B.jsx)(Ki,{scope:t,onClose:z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Ji.displayName=Ii;var Yi=`MenuAnchor`,Xi=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Hi(n);return(0,B.jsx)(tr,{...i,...r,ref:t})});Xi.displayName=Yi;var Zi=`MenuPortal`,[Qi,$i]=Bi(Zi,{forceMount:void 0}),ea=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Gi(Zi,t);return(0,B.jsx)(Qi,{scope:t,forceMount:n,children:(0,B.jsx)(zn,{present:n||a.open,children:(0,B.jsx)(Vn,{asChild:!0,container:i,children:r})})})};ea.displayName=Zi;var ta=`MenuContent`,[na,ra]=Bi(ta),ia=z.forwardRef((e,t)=>{let n=$i(ta,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Gi(ta,e.__scopeMenu),o=qi(ta,e.__scopeMenu);return(0,B.jsx)(Li.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(zn,{present:r||a.open,children:(0,B.jsx)(Li.Slot,{scope:e.__scopeMenu,children:o.modal?(0,B.jsx)(aa,{...i,ref:t}):(0,B.jsx)(oa,{...i,ref:t})})})})}),aa=z.forwardRef((e,t)=>{let n=Gi(ta,e.__scopeMenu),r=z.useRef(null),i=An(t,r);return z.useEffect(()=>{let e=r.current;if(e)return Kn(e)},[]),(0,B.jsx)(ca,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),oa=z.forwardRef((e,t)=>{let n=Gi(ta,e.__scopeMenu);return(0,B.jsx)(ca,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),sa=jn(`MenuContent.ScrollLock`),ca=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=Gi(ta,n),_=qi(ta,n),v=Hi(n),y=Ui(n),b=Ri(n),[x,S]=z.useState(null),C=z.useRef(null),ee=An(t,C,g.onContentChange),w=z.useRef(0),te=z.useRef(``),T=z.useRef(0),ne=z.useRef(null),re=z.useRef(`right`),ie=z.useRef(0),ae=m?Hn:z.Fragment,oe=m?{as:sa,allowPinchZoom:!0}:void 0,E=e=>{let t=te.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Ka(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){te.current=t,window.clearTimeout(w.current),t!==``&&(w.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};z.useEffect(()=>()=>window.clearTimeout(w.current),[]),Wn();let D=z.useCallback(e=>re.current===ne.current?.side&&Ja(e,ne.current?.area),[]);return(0,B.jsx)(na,{scope:n,searchRef:te,onItemEnter:z.useCallback(e=>{D(e)&&e.preventDefault()},[D]),onItemLeave:z.useCallback(e=>{D(e)||(C.current?.focus(),S(null))},[D]),onTriggerLeave:z.useCallback(e=>{D(e)&&e.preventDefault()},[D]),pointerGraceTimerRef:T,onPointerGraceIntentChange:z.useCallback(e=>{ne.current=e},[]),children:(0,B.jsx)(ae,{...oe,children:(0,B.jsx)(Bn,{asChild:!0,trapped:i,onMountAutoFocus:P(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,B.jsx)(Un,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,B.jsx)(ki,{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)(er,{role:`menu`,"aria-orientation":`vertical`,"data-state":Va(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&&E(e.key));let i=C.current;if(e.target!==i||!Ni.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);V.includes(e.key)&&a.reverse(),Wa(a)}),onBlur:P(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(w.current),te.current=``)}),onPointerMove:P(e.onPointerMove,Ya(e=>{let t=e.target,n=ie.current!==e.clientX;e.currentTarget.contains(t)&&n&&(re.current=e.clientX>ie.current?`right`:`left`,ie.current=e.clientX)}))})})})})})})});ia.displayName=ta;var la=`MenuGroup`,ua=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{role:`group`,...r,ref:t})});ua.displayName=la;var da=`MenuLabel`,fa=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(N.div,{...r,ref:t})});fa.displayName=da;var pa=`MenuItem`,ma=`menu.itemSelect`,ha=z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=z.useRef(null),o=qi(pa,e.__scopeMenu),s=ra(pa,e.__scopeMenu),c=An(t,a),l=z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(ma,{bubbles:!0,cancelable:!0});e.addEventListener(ma,e=>r?.(e),{once:!0}),Nn(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,B.jsx)(ga,{...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===` `||ji.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ha.displayName=pa;var ga=z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=ra(pa,n),s=Ui(n),c=z.useRef(null),l=An(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)(Li.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,Ya(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:P(e.onPointerLeave,Ya(e=>o.onItemLeave(e))),onFocus:P(e.onFocus,()=>d(!0)),onBlur:P(e.onBlur,()=>d(!1))})})})}),_a=`MenuCheckboxItem`,va=z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,B.jsx)(Ea,{scope:e.__scopeMenu,checked:n,children:(0,B.jsx)(ha,{role:`menuitemcheckbox`,"aria-checked":Ha(n)?`mixed`:n,...i,ref:t,"data-state":Ua(n),onSelect:P(i.onSelect,()=>r?.(Ha(n)?!0:!n),{checkForDefaultPrevented:!1})})})});va.displayName=_a;var ya=`MenuRadioGroup`,[ba,xa]=Bi(ya,{value:void 0,onValueChange:()=>{}}),Sa=z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Jn(r);return(0,B.jsx)(ba,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,B.jsx)(ua,{...i,ref:t})})});Sa.displayName=ya;var Ca=`MenuRadioItem`,wa=z.forwardRef((e,t)=>{let{value:n,...r}=e,i=xa(Ca,e.__scopeMenu),a=n===i.value;return(0,B.jsx)(Ea,{scope:e.__scopeMenu,checked:a,children:(0,B.jsx)(ha,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ua(a),onSelect:P(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});wa.displayName=Ca;var Ta=`MenuItemIndicator`,[Ea,Da]=Bi(Ta,{checked:!1}),Oa=z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Da(Ta,n);return(0,B.jsx)(zn,{present:r||Ha(a.checked)||a.checked===!0,children:(0,B.jsx)(N.span,{...i,ref:t,"data-state":Ua(a.checked)})})});Oa.displayName=Ta;var ka=`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=ka;var ja=`MenuArrow`,Ma=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Hi(n);return(0,B.jsx)($n,{...i,...r,ref:t})});Ma.displayName=ja;var Na=`MenuSub`,[Pa,Fa]=Bi(Na),Ia=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Gi(Na,t),o=Hi(t),[s,c]=z.useState(null),[l,u]=z.useState(null),d=Jn(i);return z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,B.jsx)(Qn,{...o,children:(0,B.jsx)(Wi,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,B.jsx)(Pa,{scope:t,contentId:Gn(),triggerId:Gn(),trigger:s,onTriggerChange:c,children:n})})})};Ia.displayName=Na;var La=`MenuSubTrigger`,Ra=z.forwardRef((e,t)=>{let n=Gi(La,e.__scopeMenu),r=qi(La,e.__scopeMenu),i=Fa(La,e.__scopeMenu),a=ra(La,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)(Xi,{asChild:!0,...l,children:(0,B.jsx)(ga,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Va(n.open),...e,ref:On(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:P(e.onPointerMove,Ya(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,Ya(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===` `||Pi[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Ra.displayName=La;var za=`MenuSubContent`,Ba=z.forwardRef((e,t)=>{let n=$i(ta,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Gi(ta,e.__scopeMenu),o=qi(ta,e.__scopeMenu),s=Fa(za,e.__scopeMenu),c=z.useRef(null),l=An(t,c);return(0,B.jsx)(Li.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(zn,{present:r||a.open,children:(0,B.jsx)(Li.Slot,{scope:e.__scopeMenu,children:(0,B.jsx)(ca,{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=Fi[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Ba.displayName=za;function Va(e){return e?`open`:`closed`}function Ha(e){return e===`indeterminate`}function Ua(e){return Ha(e)?`indeterminate`:e?`checked`:`unchecked`}function Wa(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ga(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Ka(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ga(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 qa(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Ja(e,t){return t?qa({x:e.clientX,y:e.clientY},t):!1}function Ya(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Xa=Ji,Za=Xi,Qa=ea,$a=ia,eo=ua,to=fa,no=ha,ro=va,io=Sa,ao=wa,oo=Oa,so=Aa,co=Ma,lo=Ra,uo=Ba,H=`DropdownMenu`,[U,fo]=Pn(H,[Vi]),po=Vi(),[mo,ho]=U(H),go=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=po(t),l=z.useRef(null),[u,d]=Rn({prop:i,defaultProp:a??!1,onChange:o,caller:H});return(0,B.jsx)(mo,{scope:t,triggerId:Gn(),triggerRef:l,contentId:Gn(),open:u,onOpenChange:d,onOpenToggle:z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,B.jsx)(Xa,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};go.displayName=H;var _o=`DropdownMenuTrigger`,vo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ho(_o,n),o=po(n);return(0,B.jsx)(Za,{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:On(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())})})})});vo.displayName=_o;var yo=`DropdownMenuPortal`,bo=e=>{let{__scopeDropdownMenu:t,...n}=e,r=po(t);return(0,B.jsx)(Qa,{...r,...n})};bo.displayName=yo;var xo=`DropdownMenuContent`,So=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ho(xo,n),a=po(n),o=z.useRef(!1);return(0,B.jsx)($a,{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)`}})});So.displayName=xo;var Co=`DropdownMenuGroup`,wo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(eo,{...i,...r,ref:t})});wo.displayName=Co;var To=`DropdownMenuLabel`,Eo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(to,{...i,...r,ref:t})});Eo.displayName=To;var Do=`DropdownMenuItem`,Oo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(no,{...i,...r,ref:t})});Oo.displayName=Do;var ko=`DropdownMenuCheckboxItem`,Ao=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(ro,{...i,...r,ref:t})});Ao.displayName=ko;var jo=`DropdownMenuRadioGroup`,Mo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(io,{...i,...r,ref:t})});Mo.displayName=jo;var No=`DropdownMenuRadioItem`,Po=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(ao,{...i,...r,ref:t})});Po.displayName=No;var Fo=`DropdownMenuItemIndicator`,Io=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(oo,{...i,...r,ref:t})});Io.displayName=Fo;var Lo=`DropdownMenuSeparator`,Ro=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(so,{...i,...r,ref:t})});Ro.displayName=Lo;var zo=`DropdownMenuArrow`,Bo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(co,{...i,...r,ref:t})});Bo.displayName=zo;var Vo=`DropdownMenuSubTrigger`,Ho=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(lo,{...i,...r,ref:t})});Ho.displayName=Vo;var Uo=`DropdownMenuSubContent`,Wo=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=po(n);return(0,B.jsx)(uo,{...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)`}})});Wo.displayName=Uo;var Go=go,Ko=vo,qo=bo,Jo=So,Yo=Eo,Xo=Oo,Zo=Ro,Qo=`Label`,$o=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())}}));$o.displayName=Qo;var es=$o;function ts(e,t){return z.useReducer((e,n)=>t[e][n]??e,e)}var ns=`ScrollArea`,[rs,is]=Pn(ns),[as,os]=rs(ns),ss=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),w=An(t,e=>c(e)),te=qn(i);return(0,B.jsx)(as,{scope:n,type:r,dir:te,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:te,...o,ref:w,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});ss.displayName=ns;var cs=`ScrollAreaViewport`,ls=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=os(cs,n),s=An(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})})]})});ls.displayName=cs;var us=`ScrollAreaScrollbar`,ds=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=os(us,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)(fs,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,B.jsx)(ps,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,B.jsx)(ms,{...r,ref:t,forceMount:n}):i.type===`always`?(0,B.jsx)(hs,{...r,ref:t}):null});ds.displayName=us;var fs=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=os(us,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)(zn,{present:n||a,children:(0,B.jsx)(ms,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),ps=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=os(us,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Fs(()=>c(`SCROLL_END`),100),[s,c]=ts(`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)(zn,{present:n||s!==`hidden`,children:(0,B.jsx)(hs,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:P(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:P(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),ms=z.forwardRef((e,t)=>{let n=os(us,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=z.useState(!1),s=e.orientation===`horizontal`,c=Fs(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return Is(n.viewport,c),Is(n.content,c),(0,B.jsx)(zn,{present:r||a,children:(0,B.jsx)(hs,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),hs=z.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=os(us,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=Os(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 As(e,o.current,s,t)}return n===`horizontal`?(0,B.jsx)(gs,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=js(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)(_s,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=js(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}),gs=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=os(us,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=An(t,c,a.onScrollbarXChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(bs,{"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":ks(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),Ns(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:Ds(o.paddingLeft),paddingEnd:Ds(o.paddingRight)}})}})}),_s=z.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=os(us,e.__scopeScrollArea),[o,s]=z.useState(),c=z.useRef(null),l=An(t,c,a.onScrollbarYChange);return z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,B.jsx)(bs,{"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":ks(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),Ns(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:Ds(o.paddingTop),paddingEnd:Ds(o.paddingBottom)}})}})}),[vs,ys]=rs(us),bs=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=os(us,n),[m,h]=z.useState(null),g=An(t,e=>h(e)),_=z.useRef(null),v=z.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Jn(u),S=Jn(c),C=Fs(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]),Is(m,C),Is(p.content,C),(0,B.jsx)(vs,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Jn(a),onThumbPointerUp:Jn(o),onThumbPositionChange:S,onThumbPointerDown:Jn(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})})})}),xs=`ScrollAreaThumb`,Ss=z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=ys(xs,e.__scopeScrollArea);return(0,B.jsx)(zn,{present:n||i.hasThumb,children:(0,B.jsx)(Cs,{ref:t,...r})})}),Cs=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=os(xs,n),o=ys(xs,n),{onThumbPositionChange:s}=o,c=An(t,e=>o.onThumbChange(e)),l=z.useRef(void 0),u=Fs(()=>{l.current&&=(l.current(),void 0)},100);return z.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=Ps(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)})});Ss.displayName=xs;var ws=`ScrollAreaCorner`,Ts=z.forwardRef((e,t)=>{let n=os(ws,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,B.jsx)(Es,{...e,ref:t}):null});Ts.displayName=ws;var Es=z.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=os(ws,n),[a,o]=z.useState(0),[s,c]=z.useState(0),l=!!(a&&s);return Is(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),Is(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 Ds(e){return e?parseInt(e,10):0}function Os(e,t){let n=e/t;return isNaN(n)?0:n}function ks(e){let t=Os(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function As(e,t,n,r=`ltr`){let i=ks(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 Ms([c,l],d)(e)}function js(e,t,n=`ltr`){let r=ks(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=nr(e,n===`ltr`?[0,o]:[o*-1,0]);return Ms([0,o],[0,s])(c)}function Ms(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 Ns(e,t){return e>0&&e<t}var Ps=(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 Fs(e,t){let n=Jn(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 Is(e,t){let n=Jn(t);In(()=>{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 Ls=ss,Rs=ls,zs=Ts,Bs=`Separator`,Vs=`horizontal`,Hs=[`horizontal`,`vertical`],Us=z.forwardRef((e,t)=>{let{decorative:n,orientation:r=Vs,...i}=e,a=Ws(r)?r:Vs,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})});Us.displayName=Bs;function Ws(e){return Hs.includes(e)}var Gs=Us,Ks=`Switch`,[qs,Js]=Pn(Ks),[Ys,Xs]=qs(Ks),Zs=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=An(t,e=>p(e)),h=z.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=Rn({prop:i,defaultProp:a??!1,onChange:l,caller:Ks});return(0,B.jsxs)(Ys,{scope:n,checked:_,disabled:s,children:[(0,B.jsx)(N.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":nc(_),"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)(tc,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Zs.displayName=Ks;var Qs=`SwitchThumb`,$s=z.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Xs(Qs,n);return(0,B.jsx)(N.span,{"data-state":nc(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});$s.displayName=Qs;var ec=`SwitchBubbleInput`,tc=z.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=z.useRef(null),s=An(o,a),c=Yn(n),l=Xn(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}})});tc.displayName=ec;function nc(e){return e?`checked`:`unchecked`}var rc=Zs,ic=$s,ac=`Tabs`,[oc,sc]=Pn(ac,[_i]),cc=_i(),[lc,uc]=oc(ac),dc=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=qn(s),[d,f]=Rn({prop:r,onChange:i,defaultProp:a??``,caller:ac});return(0,B.jsx)(lc,{scope:n,baseId:Gn(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,B.jsx)(N.div,{dir:u,"data-orientation":o,...l,ref:t})})});dc.displayName=ac;var fc=`TabsList`,pc=z.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=uc(fc,n),o=cc(n);return(0,B.jsx)(ki,{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})})});pc.displayName=fc;var mc=`TabsTrigger`,hc=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=uc(mc,n),s=cc(n),c=vc(o.baseId,r),l=yc(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)})})})});hc.displayName=mc;var gc=`TabsContent`,_c=z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=uc(gc,n),c=vc(s.baseId,r),l=yc(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)(zn,{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})})});_c.displayName=gc;function vc(e,t){return`${e}-trigger-${t}`}function yc(e,t){return`${e}-content-${t}`}var bc=dc,xc=pc,Sc=hc,Cc=_c,[wc,Tc]=Pn(`Tooltip`,[Zn]),Ec=Zn(),Dc=`TooltipProvider`,Oc=700,kc=`tooltip.open`,[Ac,jc]=wc(Dc),Mc=e=>{let{__scopeTooltip:t,delayDuration:n=Oc,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)(Ac,{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})};Mc.displayName=Dc;var Nc=`Tooltip`,[Pc,Fc]=wc(Nc),Ic=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=jc(Nc,e.__scopeTooltip),l=Ec(t),[u,d]=z.useState(null),f=Gn(),p=z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=z.useRef(!1),[_,v]=Rn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(kc))):c.onClose(),a?.(e)},caller:Nc}),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)(Qn,{...l,children:(0,B.jsx)(Pc,{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})})};Ic.displayName=Nc;var Lc=`TooltipTrigger`,Rc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Fc(Lc,n),a=jc(Lc,n),o=Ec(n),s=An(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)(tr,{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)})})});Rc.displayName=Lc;var zc=`TooltipPortal`,[Bc,Vc]=wc(zc,{forceMount:void 0}),Hc=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Fc(zc,t);return(0,B.jsx)(Bc,{scope:t,forceMount:n,children:(0,B.jsx)(zn,{present:n||a.open,children:(0,B.jsx)(Vn,{asChild:!0,container:i,children:r})})})};Hc.displayName=zc;var Uc=`TooltipContent`,Wc=z.forwardRef((e,t)=>{let n=Vc(Uc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Fc(Uc,e.__scopeTooltip);return(0,B.jsx)(zn,{present:r||o.open,children:o.disableHoverableContent?(0,B.jsx)(Yc,{side:i,...a,ref:t}):(0,B.jsx)(Gc,{side:i,...a,ref:t})})}),Gc=z.forwardRef((e,t)=>{let n=Fc(Uc,e.__scopeTooltip),r=jc(Uc,e.__scopeTooltip),i=z.useRef(null),a=An(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=$c(r,Qc(r,n.getBoundingClientRect())),a=el(t.getBoundingClientRect());s(nl([...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=!tl(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,B.jsx)(Yc,{...e,ref:a})}),[Kc,qc]=wc(Nc,{isInside:!1}),Jc=kn(`TooltipContent`),Yc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Fc(Uc,n),l=Ec(n),{onClose:u}=c;return z.useEffect(()=>(document.addEventListener(kc,u),()=>document.removeEventListener(kc,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)(Un,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,B.jsxs)(er,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,B.jsx)(Jc,{children:r}),(0,B.jsx)(Kc,{scope:n,isInside:!0,children:(0,B.jsx)(Sr,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Wc.displayName=Uc;var Xc=`TooltipArrow`,Zc=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Ec(n);return qc(Xc,n).isInside?null:(0,B.jsx)($n,{...i,...r,ref:t})});Zc.displayName=Xc;function Qc(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 $c(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 el(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 tl(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 nl(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)),rl(t)}function rl(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 il=Mc,al=Ic,ol=Rc,sl=Hc,cl=Wc,ll=Zc;function ul({delayDuration:e=0,...t}){return(0,B.jsx)(il,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function dl({...e}){return(0,B.jsx)(al,{"data-slot":`tooltip`,...e})}function fl({...e}){return(0,B.jsx)(ol,{"data-slot":`tooltip-trigger`,...e})}function pl({className:e,sideOffset:t=0,children:n,...r}){return(0,B.jsx)(sl,{children:(0,B.jsxs)(cl,{"data-slot":`tooltip-content`,sideOffset:t,className:k(`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)(ll,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function W(e){return A(e)}function ml(){let e=W(e=>e.pairs);return(0,z.useMemo)(()=>{let t={};for(let n of e)(n.status===`active`||n.status===`pending`)&&(n.requesterId&&(t[n.requesterId]=n),n.targetId&&(t[n.targetId]=n));return t},[e])}function hl(e){let t=W(e=>e.messages),n=W(e=>e.tasks),r=W(e=>e.pairs),i=W(e=>e.inboxReadCursors),a=W(e=>e.inboxArchivedThreads);return(0,z.useMemo)(()=>{if(!e)return{unread:0,needsHumanResponse:!1,pendingPairInvite:!1,claimableTasks:0,total:0,score:0};let o=t.filter(t=>Tn(t)===e.id&&!Ut(t)),s=Number(a[e.id]||0),c=s>=o.filter(e=>$t(e)&&Qt(e)).reduce((e,t)=>Math.max(e,t.id),0)&&s>0?0:o.filter(t=>Jt(i,e.id,t)).length,l=yn(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=>Cn(t)&&Sn(t.target,e)).length+t.filter(t=>Vt(t)&&Sn(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 gl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.showOffline),r=W(e=>e.agentSort),i=W(e=>e.agentSortDir),a=W(e=>e.agentPresetFilter),o=W(e=>e.agentStatusFilter),s=W(e=>e.agentTagFilter),c=W(e=>e.agentHostFilter),l=W(e=>e.managedPolicies),u=W(e=>e.pairs);return(0,z.useMemo)(()=>{let d=tn(e,t,l);if(a){let e=_l(u);d=vl(d,a,Et.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)):((fn[e.status]??9)-(fn[t.status]??9))*f||M(e).localeCompare(M(t)))},[e,t,n,l,r,i,a,o,s,c,u,Ot()])}function _l(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 vl(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`||wn(n,e));case`paired`:return e.filter(e=>!!r[e.id]);case`unpaired`:return e.filter(e=>!r[e.id]);default:return Lt().includes(t)?e.filter(e=>hn(e)===t):e}}function yl(){let e=W(e=>e.messages),t=W(e=>e.inboxReadCursors),n=W(e=>e.inboxArchivedThreads),r=W(e=>e.inboxDrafts),i=W(e=>e.agentsById),a=W(e=>e.coordinatorMutes);return(0,z.useMemo)(()=>{let o=new Map;for(let t of e){if(Ut(t))continue;let e=Tn(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&&!Ht(n)){o=n;break}}e.previewMessage=o||e.lastMessage;let s=a.includes(e.peer),c=s?0:e.messages.filter(n=>Jt(t,e.peer,n)).length,l=s?!1:yn(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 bl(){let e=yl(),t=W(e=>e.agents),n=W(e=>e.showBuiltIns),r=W(e=>e.showOffline),i=W(e=>e.managedPolicies),a=W(e=>e.pairs),o=W(e=>e.tasks),s=W(e=>e.messages),c=(0,z.useMemo)(()=>new Set(tn(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=tn(t,n,i).filter(e=>(r||e.status!==`offline`)&&yn(e)).length,d=a.filter(e=>e.status===`pending`).length,f=o.filter(Cn).length+s.filter(Vt).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 xl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>tn(e,t,n).filter(e=>e.status!==`offline`).length,[e,t,n])}function Sl(){let e=W(e=>e.agents);return(0,z.useMemo)(()=>e.filter(e=>e.status===`busy`).length,[e])}function Cl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.showOffline),r=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let i=tn(e,t,r);return n?i:i.filter(e=>e.status!==`offline`)},[e,t,n,r])}function wl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(tn(e,t,n).map(e=>e.machine).filter(Boolean))].sort(),[e,t,n])}function Tl(){let e=W(e=>e.agents),t=W(e=>e.showBuiltIns),n=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>[...new Set(tn(e,t,n).flatMap(e=>e.tags||[]))],[e,t,n])}function El(){let e=W(e=>e.tasks),t=W(e=>e.messages);return(0,z.useMemo)(()=>{let n=e.filter(e=>(e.kind??`claim`)===`claim`).filter(e=>!Xt.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:Cn(e),task:e})),r=t.filter(Vt).map(e=>({id:`message-`+e.id,sourceType:`message`,title:e.subject||`Claimable message #`+e.id,body:dn(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:Vt(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?vn(e.updatedAt)-vn(t.updatedAt):i})},[e,t])}function Dl(){let e=W(e=>e.commandQuery),t=W(e=>e.agents),n=W(e=>e.agentsById),r=W(e=>e.showBuiltIns),i=W(e=>e.showOffline),a=W(e=>e.managedPolicies);return(0,z.useMemo)(()=>{let n=tn(t,r,a).filter(e=>i||e.status!==`offline`),o=[...new Set(n.flatMap(e=>e.tags||[]))],s=O(),c=[Ol(`open-chat`,`Open chat`,`Human console`,`MessageCircle`,`openView`,{view:`chat`}),Ol(`open-work`,`Open work queue`,`Claimable messages and tasks`,`ListChecks`,`openView`,{view:`work`}),Ol(`open-workspaces`,`Open workspaces`,`Agent worktrees and merge state`,`GitBranch`,`openView`,{view:`workspaces`}),Ol(`show-stale`,`Show stale agents`,`Filter agents to offline or stale`,`Filter`,`agentPreset`,{preset:`offline_stale`}),Ol(`copy-url`,`Copy relay URL`,s,`Copy`,`copy`,{value:s}),Ol(`export-md`,`Export timeline as Markdown`,`Activity audit trace`,`FileDown`,`exportActivity`,{format:`markdown`}),Ol(`export-json`,`Export timeline as JSON`,`Activity audit trace`,`Braces`,`exportActivity`,{format:`json`}),...n.slice(0,12).map(e=>Ol(`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=>Ol(`pair-`+e.id,`Pair: `+M(e),e.id,`Link`,`pairAgent`,{agentId:e.id})),...o.map(e=>Ol(`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 Ol(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 kl({className:e,size:t=`default`,...n}){return(0,B.jsx)(rc,{"data-slot":`switch`,"data-size":t,className:k(`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)(ic,{"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 G({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,B.jsx)(Gs,{"data-slot":`separator`,decorative:n,orientation:t,className:k(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}function Al({...e}){return(0,B.jsx)(Go,{"data-slot":`dropdown-menu`,...e})}function jl({...e}){return(0,B.jsx)(Ko,{"data-slot":`dropdown-menu-trigger`,...e})}function Ml({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,B.jsx)(qo,{children:(0,B.jsx)(Jo,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:k(`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 Nl({className:e,inset:t,variant:n=`default`,...r}){return(0,B.jsx)(Xo,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:k(`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 Pl({className:e,inset:t,...n}){return(0,B.jsx)(Yo,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:k(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function Fl({className:e,...t}){return(0,B.jsx)(Zo,{"data-slot":`dropdown-menu-separator`,className:k(`-mx-1 my-1 h-px bg-border`,e),...t})}var Il={LayoutDashboard:we,MessageCircle:ze,Bot:w,Server:l,MessagesSquare:lt,Plug:o,PlugZap:_,Activity:r,Link:Ne,Mail:ot,ListChecks:Le,ClipboardList:dt,CalendarClock:Be,AreaChart:ae,Settings:d,Workflow:it,BrainCircuit:oe,FolderTree:b,Shield:mt,Wrench:qe,UserCog:Xe,Lightbulb:xt,Users:ut,Boxes:y,PackagePlus:ge,FileText:pe};function Ll(e){return new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}var Rl=[[`messages`,`Messages`],[`replies`,`Replies`],[`errors`,`Errors`]];function K(){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?s:Ct;function d(e){i({notificationSettings:{...n,...e}})}return(0,B.jsxs)(Al,{onOpenChange:e=>{e&&o()},children:[(0,B.jsx)(jl,{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)(Ml,{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)(Pl,{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)(f,{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)(je,{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)(kl,{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)(kl,{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:Rl.map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>d({[e]:!n[e]}),className:k(`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)(Fl,{}),(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)(Nl,{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:k(`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:Ll(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 zl(){let e=A(e=>e.theme),t=A(e=>e.set);return(0,B.jsxs)(Al,{children:[(0,B.jsx)(jl,{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)(ve,{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:Dn.find(t=>t.id===e)?.label})]})}),(0,B.jsx)(Ml,{align:`start`,side:`right`,className:`w-40`,children:Dn.map(n=>(0,B.jsxs)(Nl,{onSelect:()=>t({theme:n.id}),children:[(0,B.jsx)(`span`,{className:`flex-1`,children:n.label}),e===n.id&&(0,B.jsx)(de,{className:`w-3.5 h-3.5 text-primary`})]},n.id))})]})}function q(){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=bl(),f=xl();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:gn.map(n=>{let r=Il[n.icon]||w;return(0,B.jsxs)(`button`,{onClick:()=>t(n.key),className:k(`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:k(`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)(Je,{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)(K,{}),(0,B.jsx)(zl,{}),(0,B.jsx)(G,{}),(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)(kl,{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)(kl,{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)(kl,{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 J(){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)(D,{className:`w-4 h-4 text-primary`}),`Agent Relay`]}),(0,B.jsx)(q,{})]})}function Y(){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:k(`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:k(`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)(D,{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)(Se,{className:`w-4 h-4`})})]}),(0,B.jsx)(q,{})]})]})}var Bl=500*1024,Vl={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`},Hl={".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`},Ul=null;function Wl(){return Ul??=R(()=>import(`./bundle-web-DhRGKIGF.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),Ul}function Gl(e){return new TextEncoder().encode(e).length}function Kl(e){return e.split(`/`).filter(Boolean).pop()||e}function ql(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 Jl(e,t,n,r){if(n)return n;let i=Kl(e).toLowerCase();if(Hl[i])return Hl[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=ql(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&Vl[o]?Vl[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 Yl(e,t,n,r){let i=Jl(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var Xl=(0,z.memo)(function({content:e,path:t,mediaType:n,languageHint:r,compact:i=!1}){let a=A(e=>e.theme),o=Dn.find(e=>e.id===a)?.dark??!0,s=(0,z.useMemo)(()=>Jl(t,n,r,e)||`text`,[e,r,n,t]),c=Gl(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)(rr,{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)(Qe,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):c||p||!l?(0,B.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,B.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,children:e||` `})]}):(0,B.jsxs)(`div`,{className:`group/code relative`,children:[h(),(0,B.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${i?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:l}})]})}),Zl=(0,z.lazy)(()=>R(()=>import(`./markdown-preview-impl-BnXMH1z1.js`).then(e=>({default:e.MarkdownPreview})),__vite__mapDeps([4,5,1,3,6]),import.meta.url));function Ql(e){return(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading preview…`}),children:(0,B.jsx)(Zl,{...e})})}var $l=e(wt(),1);function eu({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)(We,{className:`h-4 w-4`}):(0,B.jsx)(tt,{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)(Se,{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 tu({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,$l.createPortal)((0,B.jsx)(eu,{src:e,alt:t,onClose:()=>a(!1)}),document.body)]})}var nu=`agent-relay:file-git-status`;function ru(){try{return window.localStorage.getItem(nu)!==`off`}catch{return!0}}function iu(e){try{window.localStorage.setItem(nu,e?`on`:`off`)}catch{}}function au(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 ou(e,t,n){let r=`/orchestrators/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`;return n?`${r}&git=1`:r}function su({status:e}){let t=au(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 cu(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function lu(e,t){let n=t.replace(/\/+$/,``);return e===n?`/`:e.startsWith(n+`/`)?e.slice(n.length+1):e}function uu(e,t){let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.mdx`)||n.endsWith(`.markdown`)||t===`text/markdown`}function du(e,t,n){return uu(e,t)?`markdown`:Yl(e,t,void 0,n)?`code`:null}function fu(e){return`agent-relay:file-view-mode:${e}`}function pu(e){try{let t=window.localStorage.getItem(fu(e));return t===`raw`||t===`rendered`?t:`rendered`}catch{return`rendered`}}function mu(e,t){try{window.localStorage.setItem(fu(e),t)}catch{}}function hu(e,t){let n=lu(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 gu(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(zt(e)))}).finally(()=>{r||o(!1)}),()=>{r=!0}},[n,e,t]),{file:r,loading:a,error:s}}function _u(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`,ou(e,t,n)).then(e=>{i||a(e)}).catch(e=>{i||(a(null),l(zt(e)))}).finally(()=>{i||s(!1)}),()=>{i=!0}},[r,e,t,n]),{listing:i,loading:o,error:c}}function vu({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 yu({orchestratorId:e,selectedPath:t,onReadError:n,git:r=!1}){let{listing:i,loading:a,error:o}=_u(e,t,r);return(0,z.useEffect)(()=>{n(o)},[o,n]),t?a?(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Qe,{className:`h-4 w-4 animate-spin`}),`Loading directory`]}):o?(0,B.jsx)(`div`,{className:`h-full bg-muted/20`}):i?(0,B.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(h,{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`?h:v,n=au(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)(xe,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(su,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:cu(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 bu({orchestratorId:e,selectedPath:t,line:n,onReadError:r}){let{file:i,loading:a,error:o}=gu(e,t),s=(0,z.useRef)(null),[c,l]=(0,z.useState)(`raw`);(0,z.useEffect)(()=>{r(o)},[o,r]),(0,z.useEffect)(()=>{n>0&&s.current?.scrollIntoView({block:`center`})},[i,n]),(0,z.useEffect)(()=>{if(!i||i.encoding===`binary`)return;if(n>0){l(`raw`);return}let e=du(i.path,i.mediaType,i.content);l(e?pu(e):`raw`)},[i?.path,i?.encoding,i?.mediaType,i?.content,n]);function u(e,t){l(e),t&&mu(t,e)}if(!t)return(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a file to preview`});if(a)return(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(Qe,{className:`h-4 w-4 animate-spin`}),`Loading file`]});if(o)return(0,B.jsx)(`div`,{className:`h-full bg-muted/20`});if(!i)return null;if(i.encoding===`base64`)return(0,B.jsxs)(`div`,{className:`flex h-full flex-col bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(v,{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)(rr,{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:cu(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)(tu,{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:cu(i.size)})]})]});let d=i.content??``,f=uu(i.path,i.mediaType),p=!f&&Yl(i.path,i.mediaType,void 0,d),m=f||p,h=f?`markdown`:p?`code`:null;return(0,B.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background px-3 py-2 text-xs`,children:[(0,B.jsx)(v,{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)(rr,{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:cu(i.size)}),m&&(0,B.jsxs)(`div`,{className:`flex shrink-0 rounded-md border border-border bg-muted/40 p-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`raw`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`raw`,h),children:`Raw`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[10px] font-medium ${c===`rendered`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>u(`rendered`,h),children:f?`Rendered`:`Highlighted`})]})]}),c===`rendered`&&f&&(0,B.jsx)(Ql,{content:d,path:i.path}),c===`rendered`&&p&&(0,B.jsx)(Xl,{content:d,path:i.path,mediaType:i.mediaType}),c===`raw`&&(0,B.jsx)(vu,{content:d,line:n,lineRef:s})]})}function xu({overlay:e=!1}){let t=A(e=>e.apiCall),n=A(e=>e.orchestrators),r=A(e=>e.fileOrchestratorId),i=A(e=>e.filePath),a=A(e=>e.fileSelectedPath),o=A(e=>e.fileSelectedLine),s=A(e=>e.set),c=A(e=>e.closeFileOverlay),l=A(e=>e.openOrchestratorSpawnAt),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(i),[m,g]=(0,z.useState)(!1),[_,y]=(0,z.useState)(``),[x,S]=(0,z.useState)(``),[C,w]=(0,z.useState)(ru),te=(0,z.useMemo)(()=>n.filter(e=>e.status===`online`),[n]),T=n.find(e=>e.id===r)||te[0];(0,z.useEffect)(()=>{if(!T)return;let e={};r||(e.fileOrchestratorId=T.id),i||(e.filePath=T.baseDir),Object.keys(e).length&&s(e)},[r,i,T,s]),(0,z.useEffect)(()=>p(i),[i]);async function re(e=i){if(!(!T||!e)){g(!0),y(``);try{let n=await t(`GET`,ou(T.id,e,C));d(n),s({filePath:n.path}),p(n.path),S(``)}catch(e){y(zt(e))}finally{g(!1)}}}(0,z.useEffect)(()=>{re(i)},[T?.id,i,C]);function ie(e){w(e),iu(e)}function ae(e){s({fileOrchestratorId:e,filePath:n.find(t=>t.id===e)?.baseDir||``,fileSelectedPath:``,fileSelectedLine:0})}function oe(e){S(``),e.type===`directory`?s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}):s({fileSelectedPath:e.path,fileSelectedLine:0})}function E(){if(!T)return;let t=f.trim()||i||T.baseDir;e&&c(),l({orchestratorId:T.id,cwd:t})}let D=u?hu(u.path,u.baseDir):[],se=_||x;return(0,B.jsxs)(`div`,{className:e?`flex h-full flex-col`:`flex h-[calc(100dvh-5rem)] flex-col gap-3 md:gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,B.jsx)(b,{className:`h-5 w-5 text-primary`}),`Files`]}),(0,B.jsxs)(`select`,{value:T?.id||``,onChange:e=>ae(e.target.value),className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[te.length===0&&(0,B.jsx)(`option`,{value:``,children:`No online orchestrators`}),te.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.hostname||e.id},e.id))]}),e&&(0,B.jsx)(I,{size:`icon`,variant:`ghost`,className:`ml-auto h-8 w-8`,onClick:c,title:`Close`,children:(0,B.jsx)(Se,{className:`h-4 w-4`})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a?`hidden md:flex`:``}`,children:[(0,B.jsx)(L,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s({filePath:f,fileSelectedPath:``,fileSelectedLine:0})},className:`min-w-0 flex-1 basis-full font-mono text-xs sm:basis-auto`,placeholder:T?.baseDir||`Path`}),(0,B.jsxs)(I,{size:`sm`,variant:`outline`,className:`gap-1`,onClick:()=>re(f),disabled:m||!T,children:[m?(0,B.jsx)(Qe,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(ee,{className:`h-3.5 w-3.5`}),`Open`]}),(0,B.jsxs)(I,{size:`sm`,className:`gap-1`,onClick:E,disabled:!T,children:[(0,B.jsx)(me,{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)(ne,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:`Git`}),(0,B.jsx)(kl,{checked:C,onCheckedChange:ie})]})]}),D.length>0&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-muted-foreground ${a?`hidden md:flex`:``}`,children:D.map((e,t)=>(0,B.jsxs)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 font-mono hover:bg-accent hover:text-foreground`,onClick:()=>s({filePath:e.path,fileSelectedPath:``,fileSelectedLine:0}),children:[e.label,t<D.length-1&&e.label!==`/`?` /`:``]},`${e.path}-${t}`))}),se&&(0,B.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:se}),(0,B.jsxs)(`div`,{className:`grid min-h-0 flex-1 overflow-hidden md:rounded-md md:border md:border-border md:grid-cols-[22rem_minmax(0,1fr)] ${a?``:`rounded-md border border-border`}`,children:[(0,B.jsxs)(`div`,{className:`min-h-0 overflow-auto border-b border-border bg-card md:border-b-0 md:border-r ${a?`hidden md:block`:``}`,children:[u?.parent&&(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent`,onClick:()=>s({filePath:u.parent,fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(nt,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{children:`Parent directory`})]}),u?.entries.map(e=>{let t=a===e.path||i===e.path,n=e.type===`directory`?h:v,r=au(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:()=>oe(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)(xe,{className:`h-3 w-3 shrink-0 text-muted-foreground/60`}),(0,B.jsx)(su,{status:e.gitStatus}),e.type!==`directory`&&(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:cu(e.size)})]},e.path)}),!m&&u&&u.entries.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`No files`})]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden ${a?``:`hidden md:flex`}`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs text-muted-foreground hover:text-foreground md:hidden`,onClick:()=>s({fileSelectedPath:``,fileSelectedLine:0}),children:[(0,B.jsx)(nt,{className:`h-3.5 w-3.5`}),`Back to files`]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(bu,{orchestratorId:T?.id||``,selectedPath:a,line:o,onReadError:S})})]})]})]})}function Su(){return(0,B.jsx)(xu,{})}function Cu(){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)(xu,{overlay:!0})})}):null}var wu=!1;function Tu(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;wu=!1,window.history.pushState({sheetGuard:!0},``),n.current=!0;function t(){if(wu){wu=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,wu=!0,window.history.back())}},[e])}function Eu({...e}){return Tu(e.open,e.onOpenChange),(0,B.jsx)(ri,{"data-slot":`sheet`,...e})}function Du({...e}){return(0,B.jsx)(li,{"data-slot":`sheet-close`,...e})}function Ou({...e}){return(0,B.jsx)(ii,{"data-slot":`sheet-portal`,...e})}function ku({className:e,...t}){return(0,B.jsx)(ai,{"data-slot":`sheet-overlay`,className:k(`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 Au({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,B.jsxs)(Ou,{children:[(0,B.jsx)(ku,{}),(0,B.jsxs)(oi,{"data-slot":`sheet-content`,"data-side":n,className:k(`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)(li,{"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)(Se,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function ju({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`sheet-header`,className:k(`flex flex-col gap-0.5 p-4`,e),...t})}function Mu({className:e,...t}){return(0,B.jsx)(si,{"data-slot":`sheet-title`,className:k(`font-heading text-base font-medium text-foreground`,e),...t})}function Nu({className:e,orientation:t=`horizontal`,...n}){return(0,B.jsx)(bc,{"data-slot":`tabs`,"data-orientation":t,className:k(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Pu=Mn(`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 Fu({className:e,variant:t=`default`,...n}){return(0,B.jsx)(xc,{"data-slot":`tabs-list`,"data-variant":t,className:k(Pu({variant:t}),e),...n})}function Iu({className:e,...t}){return(0,B.jsx)(Sc,{"data-slot":`tabs-trigger`,className:k(`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 Lu({className:e,...t}){return(0,B.jsx)(Cc,{"data-slot":`tabs-content`,className:k(`flex-1 text-sm outline-none`,e),...t})}function Ru({agent:e,now:t,className:n}){return(0,B.jsx)(`span`,{className:k(`inline-block w-2.5 h-2.5 rounded-full shrink-0`,Wt(e,t),n)})}function zu({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 Bu({agent:e,compact:t=!1,className:n=``}){let r=Hu(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 Vu({agent:e}){let t=e.context;if(!t)return null;let n=Zu(t);if(n===null)return(0,B.jsxs)(`div`,{className:`space-y-1`,title:Qu(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:Qu(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 Hu(e){let t=Uu(e),n=Wu(e),r=Gu(e);return[{key:`origin`,label:t?`Relay`:`External`,title:t?`Agent Relay spawned this agent`:`Externally started agent registered with Agent Relay`,Icon:t?m:T,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 Uu(e){return typeof e.meta?.spawnRequestId==`string`||typeof e.meta?.policyName==`string`||typeof e.meta?.automationRunId==`string`}function Wu(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:Ae,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:x,className:`border-blue-500/30 bg-blue-500/10 text-blue-300`}:{key:`approval`,label:`Guarded`,title:`Approval mode: guarded`,Icon:De,className:`border-amber-500/30 bg-amber-500/10 text-amber-300`}}function Gu(e){let t=X(e.meta?.workspace),n=Nt(t.requestedMode)||Nt(e.meta?.workspaceMode),r=Nt(t.mode),i=n&&n!==`inherit`?n:r&&n!==`inherit`?r:`default`;return i===`isolated`?{key:`workspace`,label:`Isolated`,title:`Workspace: isolated worktree`,Icon:ne,iconColor:`text-violet-300`,className:`border-violet-500/30 bg-violet-500/10 text-violet-300`}:i===`shared`?{key:`workspace`,label:`Shared`,title:`Workspace: shared repo checkout`,Icon:ue,iconColor:`text-cyan-300`,className:`border-cyan-500/30 bg-cyan-500/10 text-cyan-300`}:{key:`workspace`,label:`Default`,title:r?`Workspace: default/inherit, resolved to ${r}`:`Workspace: default/inherit`,Icon:yt,iconColor:`text-zinc-400`,className:`border-zinc-500/30 bg-zinc-500/10 text-zinc-300`}}function X(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Ku(e){let t=X(e.meta?.workspace),n=Nt(t.repoRoot)||Nt(t.sourceCwd)||Nt(e.meta?.cwd);return n?en(n,2):``}function qu(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=xn(e).length;if(i&&r.push(i===1?`1 subagent`:`${i} subagents`),n){let e=Zu(n);r.push(e===null?`ctx collecting`:`${Math.round(e*100)}% ctx`)}return r}function Yu({context:e,expected:t=!!e,size:n=26,className:r}){let i=Zu(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:Qu(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 Xu(e){let t=e.context;return!t?.tokensUsed&&!t?.tokensMax?null:t.tokensUsed&&t.tokensMax?`${$u(t.tokensUsed)} / ${$u(t.tokensMax)}`:t.tokensUsed?$u(t.tokensUsed):t.tokensMax?$u(t.tokensMax):null}function Zu(e){return!e||typeof e.utilization!=`number`||!Number.isFinite(e.utilization)?null:Math.min(1,Math.max(0,e.utilization))}function Qu(e){if(!e)return`Context: collecting; provider has not reported usage yet`;let t=Zu(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 $u(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var ed=(0,z.lazy)(()=>R(()=>import(`./terminal-viewer-impl-CxAscH0U.js`).then(e=>({default:e.TerminalDialog})),__vite__mapDeps([7,1,6,8,9,10,11,12,13,14]),import.meta.url));function td(e){return e.open?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(ed,{...e})}):null}function nd({orchestratorId:e,session:t,lines:n=200}){let r=A(e=>e.apiCall),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(`provider`),[p,m]=(0,z.useState)(null);async function h(){if(!l)try{o((await r(`GET`,`/orchestrators/${encodeURIComponent(e)}/logs/${encodeURIComponent(t)}?lines=${n}${d===`mirror`?`&stream=mirror`:``}`)).lines||[]),m(null)}catch(e){m(zt(e))}}(0,z.useEffect)(()=>{h();let e=setInterval(()=>void h(),1500);return()=>clearInterval(e)},[e,t,l,d]);let g=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)(i,{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:()=>f(`provider`),title:`Provider output`,className:k(`flex items-center gap-1 px-2 py-1.5 text-xs`,d===`provider`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,B.jsx)(be,{className:`h-3.5 w-3.5`}),` Output`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>f(`mirror`),title:`Session-mirror diagnostics (clean)`,className:k(`flex items-center gap-1 px-2 py-1.5 text-xs border-l border-border`,d===`mirror`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),children:[(0,B.jsx)(ie,{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)(fe,{className:`h-4 w-4`}):(0,B.jsx)($e,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>_n(`${t}.log`,a.join(`
|
|
16
16
|
`),`text/plain`),title:`Download logs`,children:(0,B.jsx)(Oe,{className:`h-4 w-4`})})]}),p&&(0,B.jsx)(`div`,{className:`text-sm text-destructive`,children:p}),(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:g.join(`
|
|
17
17
|
`)||`No log output`})]})}function rd(e,t){let n=t?.meta?.busyHealth;if(!t||t.status!==`busy`||!Mt(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 id={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 ad({agent:e,orchestrators:t}){let n=kt(),[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=Mt(e.meta?.agentProfile)?e.meta.agentProfile:null,f=sd(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 rt(`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 rt(`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)(bt,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Diagnostics`]}),(0,B.jsx)(rr,{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)(od,{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)(Z,{label:`Provider`,value:_.provider}),_.model&&(0,B.jsx)(Z,{label:`Model`,value:_.model}),_.effort&&(0,B.jsx)(Z,{label:`Effort`,value:_.effort}),(0,B.jsx)(Z,{label:`Permission`,value:_.permissionMode}),(0,B.jsx)(Z,{label:`Mode`,value:_.mode}),_.rig&&(0,B.jsx)(Z,{label:`Rig`,value:_.rig}),(0,B.jsx)(Z,{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)(Z,{label:`Provider Args`,value:_.providerArgs.join(` `),className:`col-span-2`,mono:!0}),_.binding&&(0,B.jsx)(Z,{label:`Channel`,value:`${_.binding.type}:${_.binding.channelId}`,className:`col-span-2`})]})}),(u||f)&&(0,B.jsx)(od,{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)(Z,{label:`Profile`,value:u}),f?.base&&(0,B.jsx)(Z,{label:`Base`,value:f.base}),f?.provider&&(0,B.jsx)(Z,{label:`Provider`,value:f.provider}),f&&(0,B.jsx)(Z,{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)(od,{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)(Z,{label:`Mode`,value:m.workspace.mode}),m.workspace.status&&(0,B.jsx)(Z,{label:`Status`,value:m.workspace.status}),m.workspace.worktreePath&&(0,B.jsx)(Z,{label:`Worktree`,value:m.workspace.worktreePath,className:`col-span-2`,mono:!0}),m.workspace.repoRoot&&(0,B.jsx)(Z,{label:`Repo`,value:m.workspace.repoRoot,className:`col-span-2`,mono:!0}),m.workspace.branch&&(0,B.jsx)(Z,{label:`Branch`,value:m.workspace.branch,className:`col-span-2`,mono:!0}),m.workspace.baseRef&&(0,B.jsx)(Z,{label:`Base`,value:m.workspace.baseRef}),m.workspace.baseSha&&(0,B.jsx)(Z,{label:`Base SHA`,value:m.workspace.baseSha.slice(0,12),mono:!0}),m.workspace.stewardAgentId&&(0,B.jsx)(Z,{label:`Steward`,value:m.workspace.stewardAgentId,className:`col-span-2`,mono:!0})]})}),m&&(0,B.jsx)(od,{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)(Z,{label:`PID`,value:String(m.pid),mono:!0}),m.sessionName&&(0,B.jsx)(Z,{label:`Session`,value:m.sessionName,mono:!0}),m.supervisor&&(0,B.jsx)(Z,{label:`Supervisor`,value:m.supervisor}),m.systemdUnit&&(0,B.jsx)(Z,{label:`Systemd`,value:m.systemdUnit,mono:!0}),m.terminalSession&&(0,B.jsx)(Z,{label:`Terminal`,value:`${m.terminalSession} (${m.terminalAvailable?`available`:`unavailable`})`,mono:!0}),m.tmuxSession&&m.tmuxSession!==m.sessionName&&(0,B.jsx)(Z,{label:`Legacy tmux`,value:m.tmuxSession,mono:!0}),m.spawnRequestId&&(0,B.jsx)(Z,{label:`Spawn ID`,value:m.spawnRequestId.slice(0,12),mono:!0}),m.startedAt&&(0,B.jsx)(Z,{label:`Started`,value:cn(m.startedAt)}),p&&(0,B.jsx)(Z,{label:`Orchestrator`,value:`${p.hostname} (${p.id.slice(-8)})`}),p&&(0,B.jsx)(Z,{label:`Orch Status`,value:p.status})]})}),v&&(0,B.jsx)(od,{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:id[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)(Z,{label:`Restarts`,value:String(v.restartCount)}),(0,B.jsx)(Z,{label:`Failures`,value:String(v.consecutiveFailures)}),v.lastSpawnAt&&(0,B.jsx)(Z,{label:`Last spawn`,value:j(n,v.lastSpawnAt)}),v.lastStopAt&&(0,B.jsx)(Z,{label:`Last stop`,value:j(n,v.lastStopAt)}),v.healthySince&&(0,B.jsx)(Z,{label:`Healthy since`,value:j(n,v.healthySince)}),v.backoffUntil&&(0,B.jsx)(Z,{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)(od,{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 od({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)(ht,{className:`w-3 h-3`}):(0,B.jsx)(le,{className:`w-3 h-3`}),e]}),t&&(0,B.jsx)(`div`,{className:`px-2.5 pb-2.5`,children:r})]})}function sd(e){return Mt(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 Z({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 cd({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)(y,{className:`h-3 w-3 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:i.title||i.slug})]}):null}function ld({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 ud={github:ld},dd=Me;function fd({provider:e,className:t}){return(0,B.jsx)(ud[e]??dd,{className:k(`shrink-0`,t)})}var pd={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`},md=1440*60*1e3;function hd(e){return`${e.repo}#${e.externalKey}`}function gd(e,t){return e.statusSyncedAt?`Status synced ${j(t,e.statusSyncedAt)} (${cn(e.statusSyncedAt)})`:`Status not yet synced`}function _d({issueRef:e,now:t=Date.now(),compact:n=!1,showSync:r=!1,className:i}){let a=hd(e),o=!e.statusSyncedAt||t-e.statusSyncedAt>md,s=[e.title?`${a}: ${e.title}`:a,`Status: ${e.status}`,gd(e,t)].join(`
|
|
@@ -20,6 +20,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
20
20
|
`)}):null,at?.unavailable?.length?(0,B.jsx)(`div`,{className:`mt-1 text-amber-50/55`,children:at.unavailable.join(`; `)}):null]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 pt-0.5 text-xs`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Last seen`}),(0,B.jsx)(`div`,{children:j(s,O.lastSeen)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Created`}),(0,B.jsx)(`div`,{title:cn(O.createdAt),children:j(s,O.createdAt)})]})]})]})]}),_t.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Tasks`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:_t.map(e=>(0,B.jsx)(or,{id:e.id,title:e.title,status:e.status,compact:!0,onClick:()=>te(e.id)},e.id))})]})]}),D&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Wd,{report:D,now:s})]}),O.context&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Id,{context:O.context,tokens:Xe,history:T,now:s})]}),(0,B.jsx)(xd,{agentId:O.id,now:s}),(O.spawnedBy||ct.length>0||De)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(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:[O.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:!st,onClick:()=>st&&d(st),children:st?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ru,{agent:st,now:s}),(0,B.jsx)(ar,{agent:st}),(0,B.jsx)(`span`,{className:`truncate font-medium`,children:M(st)})]}):(0,B.jsx)(`span`,{className:`truncate font-mono`,children:O.spawnedBy})})]}),ct.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:ct.length})]}),(0,B.jsx)(`div`,{className:`space-y-1`,children:ct.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:()=>d(e),children:[(0,B.jsx)(Ru,{agent:e,now:s}),(0,B.jsx)(ar,{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))})]}),O.spawnedBy&&ct.length===0&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(ut,{className:`h-3.5 w-3.5`}),`No live child agents`]}),De&&(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:De.status===`active`?`bg-emerald-500/20 text-emerald-400`:`bg-yellow-500/20 text-yellow-400`,children:De.status})]}),De.objective&&(0,B.jsx)(`p`,{className:`text-muted-foreground`,children:De.objective})]})]})]})]}),(Je||Ze.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(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:[Ye&&(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:Ye.state})]}),Ye.reason&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Reason`}),(0,B.jsx)(`div`,{children:Ye.reason})]}),Ye.source&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Source`}),(0,B.jsx)(`div`,{children:Ye.source})]}),Ye.updatedAt&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Updated`}),(0,B.jsx)(`div`,{children:j(s,Ye.updatedAt)})]})]}),Je?.model&&(0,B.jsxs)(`div`,{className:`space-y-1`,children:[Je.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:Je.model.provider})]}),(Je.model.alias||Je.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:Je.model.alias||Je.model.id})]}),Je.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:Je.model.effort})]})]}),Je?.session&&(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:[Je.session.approvalMode&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Mode`}),(0,B.jsx)(`div`,{children:Je.session.approvalMode})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Files`}),(0,B.jsx)(`div`,{children:Je.session.fileWrite?`read/write`:Je.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:Je.session.shell?`yes`:`no`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Confidence`}),(0,B.jsx)(`div`,{children:Je.confidence})]})]}),Je?.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:Je.lifecycle.managed?`secondary`:`outline`,className:`text-[10px]`,children:Je.lifecycle.managed?`managed`:`bridge`}),Je.lifecycle.shutdownHard&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:`shutdown`}),Je.lifecycle.restartHard&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:`restart`}),Je.lifecycle.reconnect&&(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:`reconnect`})]})]}),Ze.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:Ze.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))})]})]})]})]}),ie&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(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)(oe,{className:`w-3.5 h-3.5 text-muted-foreground`}),`Memory`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ie.supported&&(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:ie.memories.length}),ie.supported&&ie.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(O)}?`,ke),children:[(0,B.jsx)(ye,{className:`w-3 h-3`}),`Clear`]})]})]}),ie.supported?ie.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:ie.memories.map(e=>(0,B.jsx)(Nd,{memory:e,now:s,onOpen:()=>{c({selectedMemoryId:e.id}),g(`memory`),l()}},e.id))}):(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Active memory list unavailable`})]})]}),O.meta?.runnerManaged===!0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(ad,{agent:O,orchestrators:a})]}),(0,B.jsx)(G,{}),(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)(Fd,{label:`Agent ID`,value:O.id,copyLabel:`Copy agent ID`}),typeof O.meta?.cwd==`string`&&O.meta.cwd&&(0,B.jsx)(Fd,{label:`Working dir`,value:O.meta.cwd,copyLabel:`Copy working dir`,title:`Open ${O.meta.cwd} in Files`,onClick:()=>{l(),C(O)}}),(0,B.jsx)(cd,{agent:O,onNavigate:l}),(O.machine||O.rig||Ge)&&(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1.5 text-xs`,children:[O.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:O.machine,children:O.machine})]}),O.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:O.rig,children:O.rig})]}),Ge&&(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:[Ge.name,` v`,Ge.version]})]})]}),qe.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:qe.map(([e,t])=>(0,B.jsxs)(F,{variant:`secondary`,className:`text-[10px]`,children:[e,`=`,t]},e))})]}),O.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:O.tags.map(e=>(0,B.jsx)(F,{variant:`outline`,className:`text-[10px]`,children:e},e))})]}),nn(O.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:nn(O.capabilities).map(e=>(0,B.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:e},e))})]})]})]}),k.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(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:[k.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:k.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:sn(e.from,r)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,B.jsx)(`span`,{className:`truncate max-w-[40%]`,children:sn(e.to,r)}),(0,B.jsxs)(`span`,{className:`ml-auto shrink-0 text-[10px]`,children:[(0,B.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),j(s,e.createdAt)]})]}),(0,B.jsx)(`div`,{className:`text-foreground whitespace-pre-wrap break-words line-clamp-3`,children:dn(e)})]},e.id))})]})]})]})}),(0,B.jsx)(Lu,{value:`timeline`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:(0,B.jsx)(Rd,{agentId:O.id,open:e&&ue===`timeline`,now:s})}),(0,B.jsx)(Lu,{value:`logs`,className:`min-h-0 overflow-y-auto overflow-x-hidden`,children:Qe&&$e?(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsx)(nd,{orchestratorId:$e.id,session:Qe})}):(0,B.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No session logs available for this agent.`})})]})]})}),he&&(0,B.jsx)(td,{open:fe,onOpenChange:e=>void Me(e),orchestratorId:he.orchestratorId,session:he.session,interactive:he.interactive||tt,canWrite:tt})]})}function Nd({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:cn(e.lastAccessedAt??e.updatedAt),children:j(t,e.lastAccessedAt??e.updatedAt)})]})})}function Pd(e){return e>=.8?`text-red-400`:e>=.6?`text-yellow-400`:`text-emerald-400`}function Fd({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)(rr,{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 Id({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`:Pd(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)(Ld,{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 Ld({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=Pd(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 Rd({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 rt(`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)(ee,{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)(Bd,{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 zd(e){return e.metadata?.mismatch===!0||e.metadata?.stalled===!0?(0,B.jsx)(Pe,{className:`w-3.5 h-3.5 text-amber-400`}):e.source===`command`?(0,B.jsx)(be,{className:`w-3.5 h-3.5 text-sky-400`}):e.source===`delivery`?(0,B.jsx)(He,{className:`w-3.5 h-3.5 text-violet-400`}):e.kind===`state`?(0,B.jsx)(et,{className:`w-3.5 h-3.5 text-emerald-400`}):(0,B.jsx)(r,{className:`w-3.5 h-3.5 text-muted-foreground`})}function Bd({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:zd(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:cn(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 Vd(e){return Mt(e)&&typeof e.name==`string`&&typeof e.version==`string`?{name:e.name,version:e.version}:null}function Hd(e){return Mt(e)?Object.entries(e).filter(e=>typeof e[1]==`number`):[]}var Ud={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 Wd({report:e,now:t}){let n=e.diagnosis,r=Ud[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)(Ce,{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:cn(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
21
|
`)})]})]})}function Gd(e){if(!Mt(e)||typeof e.lastError!=`string`)return null;let t=Mt(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 Kd({className:e,children:t,...n}){return(0,B.jsxs)(Ls,{"data-slot":`scroll-area`,className:k(`relative`,e),...n,children:[(0,B.jsx)(Rs,{"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)(qd,{}),(0,B.jsx)(zs,{})]})}function qd({className:e,orientation:t=`vertical`,...n}){return(0,B.jsx)(ds,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:k(`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)(Ss,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Jd(){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=kt(),o=A(e=>e.closeChannelDetail),s=n.find(e=>e.id===t)||null,c=an(s),l=(0,z.useMemo)(()=>s?r.filter(e=>un(e,s)).sort((e,t)=>t.id-e.id).slice(0,8):[],[r,s]);return(0,B.jsx)(Eu,{open:e,onOpenChange:e=>!e&&o(),children:(0,B.jsxs)(Au,{className:`w-full max-w-[100dvw] sm:max-w-md lg:max-w-lg p-0`,children:[(0,B.jsx)(ju,{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)(Mu,{className:`text-base truncate`,children:s?.name||`Channel`})]})}),(0,B.jsx)(Kd,{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)})]})]})]}),nn(s.capabilities).length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(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:nn(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)(G,{}),(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)(G,{}),(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:sn(e.from,i)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`→`}),(0,B.jsx)(`span`,{className:`truncate max-w-[40%]`,children:sn(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:dn(e)})]},e.id))})]})]})]})})]})})}function Yd({className:e,...t}){return(0,B.jsx)(`textarea`,{"data-slot":`textarea`,className:k(`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)(es,{"data-slot":`label`,className:k(`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 Xd(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Zd(e,t){if(t.startsWith(`/`))return t;let n=`${e.replace(/\/+$/,``)}/${t}`.split(`/`),r=[];for(let e of n)!e||e===`.`||(e===`..`?r.pop():r.push(e));return`/`+r.join(`/`)}function Qd(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>0?t.slice(0,n):`/`}function $d(e,t){return e.filter(e=>e.status===`online`&&Zt(t,e.baseDir)).sort((e,t)=>qt(t.baseDir).length-qt(e.baseDir).length)[0]||e.find(e=>e.status===`online`)}function ef(){return typeof window<`u`&&window.matchMedia(`(min-width: 1280px)`).matches}function tf(){return typeof window<`u`&&!!window.getSelection()?.toString()}function nf(e){let t=e.payload?.attachments;return Array.isArray(t)?t.filter(e=>!!(e&&typeof e==`object`&&typeof e.artifactId==`string`)):[]}var rf=[`👍`,`❤️`,`✅`,`👀`];function af(e){let t=new Map;for(let n of e.reactions||[]){let e=Yt(n.emoji),r=t.get(e)??{emoji:e,count:0,mine:!1,actors:[]};r.count+=1,r.mine=r.mine||n.actorId===`user`,r.actors.push(n.actorId),t.set(e,r)}return[...t.values()].sort((e,t)=>t.count-e.count||e.emoji.localeCompare(t.emoji))}function of(e){return Ut(e)}function sf(e,t){let n=e.readBy||[],r=e.resolvedToAgent||t||e.to,i=r?n.includes(r):!1,a=n.some(e=>e!==bn);if(i||a){let e=i?r:n.find(e=>e!==bn);return{label:`read`,title:e?`Read by ${e}`:`Read by agent`,tone:`ok`,icon:f}}if(e.deliveryStatus===`delivered`)return{label:`delivered`,title:`Delivered to agent inbox`,tone:`ok`,icon:f};if(e.deliveryStatus===`queued`)return{label:`queued`,title:`Queued until the target agent is available`,tone:`warn`,icon:Te};if(e.deliveryStatus===`failed`||e.deliveryStatus===`dead`){let t=e.deliveryPoisonReason||e.deliveryLastError||e.deliveryStatus;return{label:e.deliveryStatus,title:t,tone:`danger`,icon:Ce}}return{label:`sent`,title:`Accepted by Relay`,tone:`muted`,icon:de}}function cf(e){let t=vn(e.createdAt);return(e.reactions||[]).reduce((e,t)=>Math.max(e,vn(t.updatedAt||t.createdAt)),t)}function lf(e){return e?e.messages.reduce((e,t)=>Math.max(e,cf(t)),0):0}function uf(e,t,n){return(e-t)*n}function df(e){if(!e)return 0;let t=0;for(let n of e.messages)Qt(n)&&(t=Math.max(t,vn(n.createdAt)));return t}function ff(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function pf(e){for(let t of e)t.previewUrl&&URL.revokeObjectURL(t.previewUrl)}function mf(e,t,n,r){if(e?.teamId)return{teamId:e.teamId};let i=[...t];n&&!i.some(e=>e.id===n.id)&&i.push(n);let a=i.filter(e=>e.threadId).reverse(),o=a.find(e=>!!r[At(e.threadId,e.channel)])??a[0];return o?.threadId?{threadId:o.threadId,...o.channel?{channel:o.channel}:{}}:null}var hf={online:`came online`,offline:`went offline`,shutdown:`shut down`,restarted:`restarted`,"compaction-requested":`compaction requested`,compacting:`compaction started`,compacted:`context compacted`,"compaction-stalled":`compaction stalled — may need manual intervention`,"clear-requested":`clear requested`,"clearing-context":`clear started`,"context-cleared":`context cleared`,"clear-stalled":`context clear stalled — may need manual intervention`,"shutting-down":`shutting down`},gf=new Set(Object.keys(hf)),_f=3e3;function vf(e){return new Date(e.occurredAt??e.createdAt).getTime()}function yf(e){if(e.kind!==`session`)return null;let t=e.payload?.session;return!t||t.type!==`narration`&&t.type!==`reasoning`&&t.type!==`tool`?null:{id:e.id,kind:t.type,label:typeof t.label==`string`?t.label:void 0,text:e.body,ts:vf(e),turnId:typeof t.turnId==`string`?t.turnId:void 0}}function bf(e){if(e.kind!==`session`)return null;let t=e.payload?.session;if(t?.type!==`notice`)return null;let n=typeof t.label==`string`&&t.label?t.label:`compacted`;return{id:`notice-${e.id}`,status:n,timestamp:vf(e)}}function xf(e){if(e.kind!==`session`)return null;let t=e.payload?.session;if(t?.type!==`relay-injection`)return null;let n=t.relayInjection&&typeof t.relayInjection==`object`&&!Array.isArray(t.relayInjection)?t.relayInjection:{},r=typeof n.category==`string`&&[`memory`,`instructions`,`tools`,`comms`,`knowledge`,`context`].includes(n.category)?n.category:`context`,i=typeof n.timestamp==`number`&&Number.isFinite(n.timestamp)?n.timestamp:vf(e),a=n.detail&&typeof n.detail==`object`&&!Array.isArray(n.detail)?n.detail:{};return{id:e.id,category:r,summary:typeof n.summary==`string`&&n.summary.trim()?n.summary:e.body,detail:a,agentId:typeof n.agentId==`string`&&n.agentId?n.agentId:e.from,timestamp:i}}function Sf(e){if(e.kind!==`session`)return null;let t=e.payload?.session;if(t?.type!==`prompt-resolution`)return null;let n=t.promptResolution&&typeof t.promptResolution==`object`&&!Array.isArray(t.promptResolution)?t.promptResolution:{},r=n.kind===`questions`||n.kind===`plan`||n.kind===`command`||n.kind===`tool`?n.kind:`tool`,i=typeof n.title==`string`&&n.title.trim()?n.title:`Prompt resolved`,a=typeof n.decisionLabel==`string`&&n.decisionLabel.trim()?n.decisionLabel:typeof t.label==`string`&&t.label.trim()?t.label:`Resolved`,o=n.answers&&typeof n.answers==`object`&&!Array.isArray(n.answers)?n.answers:{};return{id:e.id,title:i,kind:r,body:typeof n.promptBody==`string`?n.promptBody:typeof n.body==`string`?n.body:e.body,toolName:typeof n.toolName==`string`&&n.toolName.trim()?n.toolName:i,decisionLabel:a,questions:Cf(n.questions,o,a),timestamp:vf(e)}}function Cf(e,t,n){let r=(Array.isArray(e)?e:[]).map((e,r)=>{let i=e&&typeof e==`object`&&!Array.isArray(e)?e:{},a=typeof i.question==`string`&&i.question.trim()?i.question.trim():typeof i.header==`string`&&i.header.trim()?i.header.trim():`Question ${r+1}`,o=t[a]??t[String(i.question??``)]??t[String(i.header??``)];return{question:a,answer:typeof o==`string`&&o.trim()?o.trim():n}});return r.length?r:Object.entries(t).map(([e,t])=>({question:e,answer:t}))}function wf(e,t){let n=e.trim();for(let e of t){let t=e.trim();if(t){if(n===t)break;n.startsWith(`${t}\n\n`)&&(n=n.slice(t.length+2).trimStart())}}return n.trim()||e.trim()}function Tf(e){return e.kind===`system`&&e.from===`system`}var Ef=new Set([`agent.ready`,`agent.exited`,`agent.spawn_failed`]);function Df(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Of(e){let t=e.filter(e=>gf.has(e.status)).slice().sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let e of t)n.some(t=>t.id===e.id)||n.some(t=>t.status===e.status&&Math.abs(t.timestamp-e.timestamp)<=_f)||n.push(e);return n}function kf(e,t,n,r=[],i){let a=[];for(let e of r){let t=e.entries.reduce((e,t)=>Math.min(e,vn(t.originalCreatedAt)),1/0),n=Number.isFinite(t)?t-1:e.importedAt;a.push({ts:n,entry:{type:`import-boundary`,history:e,timestamp:n}});for(let t of e.entries)a.push({ts:vn(t.originalCreatedAt),entry:{type:`imported-message`,history:e,entry:t}})}if(n){let e=new Date(n).getTime();Number.isFinite(e)&&a.push({ts:e,entry:{type:`created`,timestamp:e}})}if(i?.spawnedBy){let e=n?new Date(n).getTime():0,t=Number.isFinite(e)?e:0;a.push({ts:t,entry:{type:`agent-action`,direction:`spawned-by`,agentId:i.spawnedBy.agentId,provider:i.spawnedBy.provider,status:`ready`,timestamp:t}})}let o=i?.spawnedBy?.agentId,s=null,c=1/0;if(i?.initialPromptComplete!==!1)for(let t of e){if(t.id<0||t.kind===`session`||Tf(t)||Ut(t)||!(t.from===`user`||o!==void 0&&t.from===o)||!dn(t).trim())continue;let e=vf(t);e<c&&(c=e,s=t.id)}let l=new Map,u=new Map,d=new Map;for(let t of e){if(t.kind!==`session`)continue;let e=t.payload?.session;if(e?.type===`narration`&&typeof e.turnId==`string`){let n=u.get(e.turnId)??[];n.push({id:t.id,body:t.body.trim()}),u.set(e.turnId,n)}else if(e?.type===`response`&&typeof e.turnId==`string`){let n=l.get(e.turnId)??[];n.push(t.body.trim()),l.set(e.turnId,n)}}let f=new Map;for(let[e,t]of l){let n=(u.get(e)??[]).map(e=>e.body);f.set(e,t.map(e=>wf(e,n)))}for(let t of e){if(t.kind!==`session`)continue;let e=t.payload?.session;if(e?.type!==`response`||typeof e.turnId!=`string`)continue;let n=wf(t.body,(u.get(e.turnId)??[]).map(e=>e.body));n&&n!==t.body&&d.set(t.id,n)}let p=new Set;for(let[e,t]of f){let n=u.get(e)??[];for(let e of t)for(let t=n.length-1;t>=0;t--){let r=n[t];if(!p.has(r.id)&&Gt(e,r.body)){p.add(r.id);break}}}let m=new Map,h=[];for(let t of e){if(Tf(t)){let e=typeof t.payload?.kind==`string`?t.payload.kind:``;if(Ef.has(e)){let n=t.payload,r=typeof n.agentId==`string`?n.agentId:``,i=vf(t);if(!r){a.push({ts:i,entry:{type:`notice`,msg:t}});continue}let o=e===`agent.ready`?`ready`:e===`agent.exited`?`exited`:`failed`,s=m.get(r);if(s)s.entry.status=o,typeof n.reason==`string`&&(s.entry.reason=n.reason),s.entry.timestamp=i,s.ts=i;else{let e={ts:i,entry:{type:`agent-action`,direction:`spawned-child`,agentId:r,provider:typeof n.provider==`string`?n.provider:void 0,status:o,reason:typeof n.reason==`string`?n.reason:void 0,timestamp:i}};m.set(r,e),a.push(e)}continue}a.push({ts:vf(t),entry:{type:`notice`,msg:t}});continue}let e=bf(t);if(e){h.push(e);continue}let n=yf(t);if(n){if(n.kind===`narration`&&p.has(n.id))continue;a.push({ts:n.ts,entry:{type:`activity`,steps:[n],timestamp:n.ts}});continue}let r=xf(t);if(r){a.push({ts:r.timestamp,entry:{type:`relay-injection`,event:r}});continue}let i=Sf(t);if(i){a.push({ts:i.timestamp,entry:{type:`prompt-resolution`,event:i}});continue}if(t.kind===`session`){let e=t.payload?.session;if(e?.type===`response`&&typeof e.turnId==`string`){let e=d.get(t.id);if(e&&e!==t.body){a.push({ts:vf(t),entry:{type:`message`,msg:{...t,body:e}}});continue}}}let o=t.id===s?`initial-prompt`:`message`;a.push({ts:vf(t),entry:{type:o,msg:t}})}for(let e of Of([...t,...h]))a.push({ts:e.timestamp,entry:{type:`status`,event:e}});let g={created:0,date:1,"import-boundary":2,"imported-message":3,"initial-prompt":4,message:4,activity:4,notice:4,"agent-action":4,"relay-injection":4,"prompt-resolution":4,status:5};a.sort((e,t)=>{let n=e.ts-t.ts;return Math.abs(n)<3e3&&g[e.entry.type]-g[t.entry.type]||n});let _=[],v=``;for(let{ts:e,entry:t}of a){if(t.type===`created`){_.push(t);continue}let n=Df(e);if(n!==v&&(_.push({type:`date`,date:n,timestamp:e}),v=n),t.type===`activity`){let e=_[_.length-1];if(e&&e.type===`activity`&&Lf(e,t)){e.steps.push(...t.steps);continue}}_.push(t)}return _}function Af(e){return e.type===`message`||e.type===`initial-prompt`?`msg-${e.msg.id}`:e.type===`notice`?`notice-${e.msg.id}`:e.type===`relay-injection`?`relay-injection-${e.event.id}`:e.type===`prompt-resolution`?`prompt-resolution-${e.event.id}`:e.type===`agent-action`?`agent-action-${e.direction}-${e.agentId}`:e.type===`activity`?`act-${e.steps[0]?.id??e.timestamp}`:e.type===`import-boundary`?`import-${e.history.id}`:e.type===`imported-message`?`import-msg-${e.history.id}-${e.entry.originalMessageId}-${e.entry.position}`:e.type===`status`?`status-${e.event.id}`:e.type===`date`?`date-${e.date}`:`created-${e.timestamp}`}function jf(e){return e.type===`initial-prompt`?[`initprompt-${e.msg.id}`]:[]}function Mf(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Nf(e){if(e.type===`message`||e.type===`initial-prompt`||e.type===`notice`){let t=Mf(e.msg.id);return t===null?[]:[t]}if(e.type===`relay-injection`||e.type===`prompt-resolution`)return[e.event.id];if(e.type===`activity`)return e.steps.map(e=>e.id).filter(Number.isFinite);if(e.type===`imported-message`){let t=Mf(e.entry.message?.id);return t===null?[]:[t]}return[]}function Pf(e){let t=Nf(e);return t.length?{messageId:Math.min(...t),endMessageId:Math.max(...t)}:null}function Ff(e,t){let n=Mf(t.messageId);if(n!==null){let r=Mf(t.endMessageId),i=r!==null&&r>=n?r:n,a=-1,o=-1/0;for(let t=0;t<e.length;t+=1){let r=Nf(e[t]);if(r.some(e=>e>=n&&e<=i))return t;let s=r.filter(e=>e<=n).sort((e,t)=>t-e)[0];s!==void 0&&s>o&&(o=s,a=t)}if(a>=0)return a}if(t.topKey){let n=e.findIndex(e=>Af(e)===t.topKey||jf(e).includes(t.topKey));if(n>=0)return n}return-1}function If(e){return e.type===`message`||e.type===`initial-prompt`||e.type===`notice`?(e.msg.subject?`${e.msg.subject} `:``)+dn(e.msg):e.type===`imported-message`?dn(e.entry.message):e.type===`activity`?e.steps.map(e=>[e.label,e.text].filter(Boolean).join(` `)).join(`
|
|
22
22
|
`):e.type===`relay-injection`?`${e.event.category} ${e.event.summary}\n${JSON.stringify(e.event.detail)}`:e.type===`prompt-resolution`?[e.event.title,e.event.decisionLabel,e.event.body,...e.event.questions.map(e=>`${e.question} ${e.answer}`)].filter(Boolean).join(`
|
|
23
|
-
`):``}function Lf(e,t){let n=e.steps[e.steps.length-1]?.turnId,r=t.steps[0]?.turnId;return n&&r?n===r:!n&&!r}var Rf={online:`text-emerald-400`,offline:`text-zinc-400`,shutdown:`text-zinc-400`,restarted:`text-blue-400`,"compaction-requested":`text-zinc-400`,compacting:`text-amber-400`,compacted:`text-amber-400`,"compaction-stalled":`text-red-400`,"clear-requested":`text-zinc-400`,"clearing-context":`text-amber-400`,"context-cleared":`text-amber-400`,"clear-stalled":`text-red-400`,"shutting-down":`text-zinc-400`};function zf(e){let t=new Date,[n,r,i]=e.split(`-`).map(Number),a=new Date(n,r-1,i);if(e===Df(t.getTime()))return`Today`;let o=new Date(t);return o.setDate(o.getDate()-1),e===Df(o.getTime())?`Yesterday`:a.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:a.getFullYear()===t.getFullYear()?void 0:`numeric`})}function Bf({event:e}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,B.jsx)(Ee,{className:k(`w-2 h-2 fill-current`,Rf[e.status]||`text-zinc-400`)}),(0,B.jsx)(`span`,{children:hf[e.status]||e.status}),(0,B.jsx)(`span`,{className:`text-muted-foreground/60`,children:ff(e.timestamp)})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}var Vf={"branch.landed":Ue,"context.warning":Pe,"agent.context_threshold":Pe,"agent.resume_budget_exhausted":Pe,"agent.rate_limit_resume":_},Hf={"branch.landed":`branch landed`,"context.warning":`context warning`,"agent.context_threshold":`context threshold reached`};function Uf(e){return e&&(e.includes(`.`)?e.slice(e.indexOf(`.`)+1):e).replace(/[._-]+/g,` `).trim()||`system signal`}function Wf({agentId:e,fallbackLabel:t,className:n,noIcon:r}){let i=A(t=>t.agentsById[e])||null,a=A(e=>e.openInboxThread),o=A(e=>e.switchView),s=i?M(i):t||e;return(0,B.jsxs)(`button`,{type:`button`,className:k(`inline-flex max-w-full items-center gap-1 rounded px-1 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,n),onClick:t=>{t.stopPropagation(),a(e),o(`chat`)},title:`Open chat for ${s}`,children:[!r&&(0,B.jsx)(ar,{agent:i,className:`w-4 h-4 text-[10px]`}),(0,B.jsx)(`span`,{className:`max-w-[160px] truncate`,children:s})]})}function Gf({msg:e}){let t=e.payload??{},n=qf(e),r=typeof t.sha==`string`?t.sha:``,i=r?r.slice(0,7):``,a=typeof t.author==`string`?t.author:``,o=typeof t.branch==`string`?t.branch:``,s=typeof t.base==`string`?t.base:``,c=t.pushed,l=typeof t.taskId==`number`&&Number.isSafeInteger(t.taskId)?t.taskId:void 0,u=typeof t.taskLabel==`string`?t.taskLabel:void 0,d=A(e=>e.openTaskDetailById);return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center justify-center gap-x-1.5 gap-y-0.5 rounded-full border border-emerald-600/35 bg-emerald-500/10 px-2.5 py-1 text-xs text-emerald-700 dark:border-emerald-500/25 dark:text-emerald-300/90`,children:[(0,B.jsx)(Ue,{className:`h-3 w-3 shrink-0 text-emerald-600 dark:text-emerald-400`}),(0,B.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-300`,children:`branch landed`}),o&&s&&(0,B.jsxs)(`span`,{className:`font-mono text-emerald-700/80 dark:text-emerald-200/70`,title:`${o} → ${s}`,children:[o,(0,B.jsx)(`span`,{className:`opacity-50`,children:` → `}),s]}),i&&(0,B.jsx)(`span`,{className:`rounded bg-emerald-500/15 px-1 font-mono text-emerald-800 dark:text-emerald-200`,title:r,children:i}),a&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-emerald-700/80 dark:text-emerald-300/80`,children:[(0,B.jsx)(`span`,{className:`opacity-70`,children:`by`}),(0,B.jsx)(Wf,{agentId:a,className:`text-emerald-700 hover:text-emerald-900 dark:text-emerald-300/90 dark:hover:text-emerald-100`})]}),l!=null&&(0,B.jsx)(or,{id:l,title:u,compact:!0,onClick:()=>d(l)}),c===!1&&(0,B.jsx)(`span`,{className:`text-amber-600 dark:text-amber-300/80`,title:`Local-only land — not pushed to origin`,children:`· local only`}),n&&(0,B.jsxs)(`span`,{className:`max-w-[220px] truncate text-emerald-700/70 dark:text-emerald-300/70`,title:n,children:[`· because `,n]}),(0,B.jsx)(`span`,{className:`text-emerald-700/60 dark:text-emerald-300/50`,children:ff(e.occurredAt??e.createdAt)})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Kf({msg:e}){let t=typeof e.payload?.kind==`string`?e.payload.kind:``;if(t===`branch.landed`)return(0,B.jsx)(Gf,{msg:e});let n=Vf[t]??D,r=Hf[t]??Uf(t),i=qf(e);return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-full border border-border bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground`,children:[(0,B.jsx)(n,{className:`h-3 w-3`}),(0,B.jsx)(`span`,{children:r}),i&&(0,B.jsxs)(`span`,{className:`max-w-[220px] truncate text-muted-foreground/80`,title:i,children:[`· because `,i]}),(0,B.jsx)(`span`,{className:`text-muted-foreground/60`,children:ff(e.occurredAt??e.createdAt)})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function qf(e){let t=e.payload?.routing;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.reason;return typeof n==`string`?n:``}var Jf={"spawned-child":{ready:`spawned`,exited:`spawned · exited`,failed:`spawn failed`},"spawned-by":{ready:`spawned by`,exited:`spawned by`,failed:`spawned by`}},Yf={"spawned-child-ready":me,"spawned-child-exited":ft,"spawned-child-failed":Ce,"spawned-by-ready":C,"spawned-by-exited":C,"spawned-by-failed":C},Xf={"spawned-child-ready":`text-emerald-400`,"spawned-child-exited":`text-zinc-400`,"spawned-child-failed":`text-red-400`,"spawned-by-ready":`text-blue-400`,"spawned-by-exited":`text-blue-400`,"spawned-by-failed":`text-blue-400`};function Zf({entry:e}){let t=`${e.direction}-${e.status}`,n=Jf[e.direction]?.[e.status]??e.direction,r=Yf[t]??D,i=Xf[t]??`text-muted-foreground`,a=e.status===`failed`;return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:k(`flex items-center gap-1.5 rounded-full border bg-muted/30 px-2.5 py-1 text-xs`,a?`border-red-500/30`:`border-border`),children:[(0,B.jsx)(r,{className:k(`h-3 w-3 shrink-0`,i)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:n}),(0,B.jsx)(Wf,{agentId:e.agentId}),e.reason&&a&&(0,B.jsxs)(`span`,{className:`text-red-400/80 max-w-[120px] truncate`,title:e.reason,children:[`— `,e.reason]}),(0,B.jsx)(`span`,{className:`text-muted-foreground/60 shrink-0`,children:ff(e.timestamp)})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}var Qf={memory:ie,instructions:pe,tools:qe,comms:D,knowledge:se,context:ct},$f={memory:`border-emerald-500/25 bg-emerald-500/10 text-emerald-300`,instructions:`border-sky-500/25 bg-sky-500/10 text-sky-300`,tools:`border-amber-500/25 bg-amber-500/10 text-amber-300`,comms:`border-violet-500/25 bg-violet-500/10 text-violet-300`,knowledge:`border-cyan-500/25 bg-cyan-500/10 text-cyan-300`,context:`border-zinc-500/25 bg-zinc-500/10 text-zinc-300`};function ep(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function tp({entry:e}){let[t,n]=(0,z.useState)(!1),r=e.event,i=Qf[r.category]??_t;return(0,B.jsx)(`div`,{className:`flex justify-center py-2 my-1`,children:(0,B.jsxs)(`div`,{className:k(`w-full max-w-[85%] md:max-w-[75%] rounded-lg border px-2.5 py-1.5 text-xs shadow-sm`,$f[r.category]??$f.context),children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-center gap-1.5 text-left`,onClick:()=>n(e=>!e),children:[(0,B.jsx)(i,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`shrink-0 font-medium`,children:r.category}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/80`,children:r.summary}),(0,B.jsx)(`span`,{className:`shrink-0 text-muted-foreground/60`,children:ff(r.timestamp)}),(0,B.jsx)(le,{className:k(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-90`)})]}),t&&(0,B.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto rounded-md border border-border/60 bg-background/75 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap break-words`,children:ep(r.detail)})]})})}function np({blockedLabel:e,onInterrupt:t}){return e?(0,B.jsx)(`div`,{className:`flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150`,children:(0,B.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-red-500/30 px-4`,children:[(0,B.jsx)(Ce,{className:`w-3.5 h-3.5 text-red-400`}),(0,B.jsxs)(`span`,{className:`text-xs text-red-300`,children:[`blocked: `,e]})]})}):(0,B.jsx)(`div`,{className:`flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150`,children:(0,B.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-foreground/10 px-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_infinite]`}),(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.2s_infinite]`}),(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.4s_infinite]`})]}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`working`}),t&&(0,B.jsxs)(`button`,{onClick:t,title:`Interrupt`,className:`ml-1 flex items-center gap-1 rounded-full px-1.5 py-0.5 text-xs text-muted-foreground hover:text-red-300 hover:bg-red-500/10 transition-colors`,children:[(0,B.jsx)(Ze,{className:`w-3.5 h-3.5`}),`Stop`]})]})})}var rp=`agent-relay:chat-hide-tools`,ip=(()=>{let e=new Set,t=(()=>{try{return window.localStorage.getItem(rp)===`on`}catch{return!1}})(),n=()=>e.forEach(e=>e());return typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===rp&&(t=e.newValue===`on`,n())}),{subscribe(t){return e.add(t),()=>e.delete(t)},get:()=>t,toggle(){t=!t;try{window.localStorage.setItem(rp,t?`on`:`off`)}catch{}n()}}})();function ap(){return[(0,z.useSyncExternalStore)(ip.subscribe,ip.get,()=>!1),ip.toggle]}function op({steps:e,showReasoning:t,issueRepo:n}){let[r,i]=ap(),a=t?e:e.filter(e=>e.kind!==`reasoning`);if(!a.length)return null;let o=a.filter(e=>e.kind===`tool`).length;return(0,B.jsx)(`div`,{className:`flex justify-start mb-2`,children:(0,B.jsxs)(`div`,{className:`max-w-[85%] md:max-w-[75%] min-w-0 space-y-1.5`,children:[a.map(e=>e.kind===`narration`?(0,B.jsx)(sr,{text:e.text,issueRepo:n,className:`text-sm leading-relaxed break-words text-foreground/90 min-w-0`},e.id):e.kind===`reasoning`?(0,B.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground/80`,children:[(0,B.jsx)(ie,{className:`w-3.5 h-3.5 mt-0.5 shrink-0 opacity-70`}),(0,B.jsx)(sr,{text:e.text,issueRepo:n,className:`italic break-words min-w-0`})]},e.id):r?null:(0,B.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground`,children:[(0,B.jsx)(be,{className:`w-3 h-3 mt-0.5 shrink-0 opacity-70`}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.label||`tool`}),e.text&&e.text.trim()&&e.text.trim()!==(e.label??``).trim()?(0,B.jsxs)(`span`,{className:`opacity-70`,children:[` — `,e.text]}):null]})]},e.id)),o>0&&(0,B.jsxs)(`button`,{onClick:i,className:`flex items-center gap-1 text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors text-left`,children:[(0,B.jsx)(le,{className:k(`w-3 h-3 shrink-0 transition-transform`,!r&&`rotate-90`)}),(0,B.jsx)(`span`,{children:r?`show ${o} tool step${o===1?``:`s`}`:`hide tool steps`})]})]})})}function sp({entry:e}){let{event:t}=e,n=t.kind===`questions`,r=n?t.title:t.kind===`plan`?`Plan prompt`:`${t.toolName} permission`;return(0,B.jsx)(`div`,{className:`flex justify-center py-1.5`,children:(0,B.jsxs)(`div`,{className:`w-full max-w-2xl rounded-md border border-border bg-muted/20 px-3 py-2 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,B.jsx)(pt,{className:`h-3.5 w-3.5 text-emerald-500`}),(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),(0,B.jsx)(`span`,{children:t.decisionLabel}),(0,B.jsx)(`span`,{className:`ml-auto shrink-0 text-muted-foreground/60`,children:ff(t.timestamp)})]}),n&&t.questions.length>0?(0,B.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:t.questions.map((e,t)=>(0,B.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.question}),(0,B.jsx)(`div`,{className:`text-sm text-foreground`,children:e.answer})]},`${e.question}-${t}`))}):t.body.trim()?(0,B.jsx)(`div`,{className:`mt-2 max-h-48 overflow-auto rounded border border-border/70 bg-background/40 px-2 py-1.5 text-sm`,children:(0,B.jsx)(sr,{text:t.body})}):null]})})}function cp({date:e}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-3 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:zf(e)}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function lp({timestamp:e}){let t=new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`});return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`created `,t]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function up({history:e}){let t=e.sourceAgentLabel||e.sourcePeerId,n=e.entries.length;return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-full border border-dashed border-border bg-muted/30 px-2 py-1 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(a,{className:`h-3 w-3`}),(0,B.jsxs)(`span`,{children:[`forked history from `,t]}),(0,B.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[n,` `,n===1?`entry`:`entries`]})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function dp({entry:e,sourceLabel:t,issueRepo:n}){let r=e.message,i=dn(r),a=e.originalFrom===bn;return(0,B.jsx)(`div`,{className:k(`flex mb-3 opacity-80`,a?`justify-end`:`justify-start`),children:(0,B.jsx)(`div`,{className:`max-w-[85%] md:max-w-[75%]`,children:(0,B.jsxs)(`div`,{className:k(`rounded-2xl border border-dashed px-3.5 py-2 text-sm select-text`,a?`border-primary/25 bg-primary/10 text-foreground rounded-br-sm`:`border-border bg-card/70 rounded-bl-sm`),children:[(0,B.jsxs)(`div`,{className:k(`mb-1 text-[10px] uppercase tracking-normal`,a?`text-primary/70`:`text-muted-foreground`),children:[`forked history · `,a?`you`:t||e.originalFrom]}),(0,B.jsx)(sr,{text:i,rawBody:r.body,issueRepo:n,className:`leading-relaxed`}),(0,B.jsxs)(`p`,{className:k(`mt-1 flex items-center justify-end gap-1.5 text-xs`,a?`text-primary/60`:`text-muted-foreground`),children:[(0,B.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.originalMessageId]}),(0,B.jsx)(`span`,{children:ff(e.originalCreatedAt)})]})]})})})}function fp({msg:e,issueRepo:t}){let n=dn(e),r=ff(e.occurredAt??e.createdAt);return(0,B.jsx)(`div`,{"data-msg-id":e.id,className:`mb-3`,children:(0,B.jsxs)(`div`,{className:`rounded-xl border border-primary/30 bg-primary/[0.06] px-3.5 py-2.5 shadow-sm`,children:[(0,B.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-primary/80`,children:[(0,B.jsx)(_t,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{children:`Initial prompt`}),(0,B.jsx)(`span`,{className:`ml-auto text-[10px] font-normal normal-case text-muted-foreground/60`,children:r})]}),(0,B.jsx)(sr,{text:n,rawBody:e.body,issueRepo:t,className:`text-sm leading-relaxed text-foreground`})]})})}function pp({scrollEl:e,timeline:t}){let[n,r]=(0,z.useState)(!0),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1),u=(0,z.useMemo)(()=>{for(let e=t.length-1;e>=0;e--){let n=t[e];if(!(!n||n.type!==`message`&&n.type!==`initial-prompt`)&&n.msg.from===`user`)return{id:n.msg.id,body:dn(n.msg)}}return null},[t]);if((0,z.useEffect)(()=>{if(!u||!e){r(!0);return}let t=null,n=null,i=()=>{let i=e.querySelector(`[data-msg-id="${u.id}"]`);if(!i){t?.disconnect(),t=null,n=null,r(!1);return}let a=i.getBoundingClientRect(),o=e.getBoundingClientRect();l(a.top<o.top),i!==n&&(t?.disconnect(),n=i,t=new IntersectionObserver(([e])=>{e&&r(e.isIntersecting)},{root:e,threshold:0}),t.observe(i))};return i(),e.addEventListener(`scroll`,i,{passive:!0}),()=>{t?.disconnect(),e.removeEventListener(`scroll`,i)}},[u?.id,e]),n||!u||!u.body.trim())return null;let d=i?.id===u.id?i.value:!1,f=o?.id===u.id?o.value:!1;function p(){!e||!u||e.querySelector(`[data-msg-id="${u.id}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`})}let m=c?`↑`:`↓`;return f?(0,B.jsx)(`div`,{className:`flex shrink-0 bg-card/45 border-b border-border`,children:(0,B.jsxs)(`button`,{type:`button`,className:`w-full flex items-center justify-center gap-1.5 py-1 text-[11px] text-primary/60 hover:text-primary transition-colors`,onClick:()=>s({id:u.id,value:!1}),children:[(0,B.jsx)(`span`,{children:`Your prompt`}),(0,B.jsx)(ht,{className:`w-3 h-3`})]})}):(0,B.jsxs)(`section`,{className:`flex shrink-0 flex-col border-b border-border bg-card/45 px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground mb-0.5`,children:[(0,B.jsx)(`span`,{className:`font-medium text-primary/70`,children:`Your prompt`}),(0,B.jsxs)(`button`,{type:`button`,className:`ml-auto hover:text-foreground transition-colors`,onClick:p,children:[m,` scroll to original`]}),(0,B.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors`,onClick:()=>s({id:u.id,value:!0}),title:`Minimize`,children:(0,B.jsx)(vt,{className:`w-3 h-3`})})]}),(0,B.jsx)(`p`,{className:k(`text-sm text-foreground leading-snug cursor-pointer`,!d&&`line-clamp-2`),onClick:()=>a({id:u.id,value:!d}),children:u.body})]})}var mp={none:`None`,uncommitted:`Uncommitted`,"committed-on-branch":`On Branch`,"landed-on-main":`Landed`,deploying:`Deploying`,deployed:`Deployed`},hp={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,claimed:`bg-purple-500/10 text-purple-300 border-purple-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,orphaned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,done:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,failed:`bg-red-500/10 text-red-400 border-red-500/20`,canceled:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`},gp={none:`bg-zinc-500/10 text-zinc-400`,uncommitted:`bg-yellow-500/10 text-yellow-400`,"committed-on-branch":`bg-blue-500/10 text-blue-400`,"landed-on-main":`bg-emerald-500/10 text-emerald-400`,deploying:`bg-purple-500/10 text-purple-400`,deployed:`bg-teal-500/10 text-teal-400`};function _p(e){let t=e.dispatch;return{title:e.title??``,intent:e.intent??``,latestSteer:e.latestSteer??``,doneWhen:e.doneWhen??``,teamId:e.teamId??``,dispatchComplexity:t?.complexity??``,dispatchType:t?.type??``,dispatchFootprint:t?.contextFootprint??``,dispatchCriticality:t?.criticality??``}}function vp(){let e=kt(),t=A(e=>e.taskDetailOpen),n=A(e=>e.taskDetailId),r=A(e=>e.taskDetailById),i=A(e=>e.taskMemoryById),a=A(e=>e.taskHistoryById),o=A(e=>e.taskDispatchResultById),s=A(e=>e.taskDispatchLoadingId),c=A(e=>e.providerCatalog),l=A(e=>e.closeTaskDetail),u=A(e=>e.doEditTask),d=A(e=>e.doDispatchTask),f=A(e=>e.doSpawnWithTask),p=c.map(e=>e.provider),[m,h]=(0,z.useState)(!1),[_,v]=(0,z.useState)(null),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)(``),[C,ee]=(0,z.useState)(``),w=n==null?null:r[n]??null,te=n==null?null:i[n]??null,T=n==null?[]:a[n]??[],re=n==null?null:o[n]??null,ie=n!=null&&s===n,ae=w?hp[w.status]??`bg-zinc-500/10 text-zinc-400`:``,oe=w?.deliverableStage?gp[w.deliverableStage]??`bg-zinc-500/10 text-zinc-400`:``;function E(e){e||(l(),h(!1),v(null))}function D(){w&&(v(_p(w)),h(!0))}function se(){h(!1),v(null)}async function ce(){if(!w||!_)return;let e={};_.dispatchComplexity&&(e.complexity=_.dispatchComplexity),_.dispatchType&&(e.type=_.dispatchType),_.dispatchFootprint&&(e.contextFootprint=_.dispatchFootprint),_.dispatchCriticality&&(e.criticality=_.dispatchCriticality);let t={..._.title===w.title?{}:{title:_.title},..._.intent===(w.intent??``)?{}:{intent:_.intent},..._.latestSteer===(w.latestSteer??``)?{}:{latestSteer:_.latestSteer},..._.doneWhen===(w.doneWhen??``)?{}:{doneWhen:_.doneWhen},..._.teamId===(w.teamId??``)?{}:{teamId:_.teamId},...Object.keys(e).length||w.dispatch?{dispatch:Object.keys(e).length?e:null}:{}};if(!Object.keys(t).length){se();return}await u(w.id,t),h(!1),v(null)}function le(){if(!w)return;let e={};y&&(e.provider=y),x&&(e.model=x),C&&(e.effort=C),d(w.id,Object.keys(e).length?e:void 0)}return(0,B.jsx)(Eu,{open:t,onOpenChange:E,children:(0,B.jsxs)(Au,{className:`w-full max-w-[100dvw] sm:max-w-lg lg:max-w-xl p-0 flex flex-col`,showCloseButton:!1,children:[(0,B.jsx)(ju,{className:`shrink-0 p-4 border-b border-border`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:w&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(F,{variant:`outline`,className:`text-xs border ${ae}`,children:w.status}),w.deliverableStage&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs ${oe}`,children:mp[w.deliverableStage]??w.deliverableStage}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`T`,w.id]})]})}),(0,B.jsx)(Mu,{className:`text-base leading-snug`,children:w?.title??`Task`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&!m&&(0,B.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:D,title:`Edit task`,children:(0,B.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(Du,{asChild:!0,children:(0,B.jsxs)(I,{size:`icon-sm`,variant:`ghost`,title:`Close`,children:[(0,B.jsx)(Se,{className:`w-4 h-4`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}),(0,B.jsx)(Kd,{className:`flex-1 min-h-0 overflow-x-hidden`,children:(0,B.jsxs)(`div`,{className:`p-4 space-y-5 min-w-0`,children:[!w&&(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:`Loading…`}),w&&m&&_&&(0,B.jsx)(yp,{form:_,onChange:e=>v(t=>t&&{...t,...e}),onSave:()=>void ce(),onCancel:se}),w&&!m&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Status`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Execution`}),(0,B.jsx)(F,{variant:`outline`,className:`text-xs border ${ae}`,children:w.status})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Deliverable stage`}),(0,B.jsx)(F,{variant:`secondary`,className:`text-xs ${oe}`,children:mp[w.deliverableStage??`none`]??w.deliverableStage??`none`})]})]}),w.blockedBy&&w.blockedBy.length>0&&(0,B.jsx)(`div`,{className:`mt-2 space-y-1`,children:w.blockedBy.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-yellow-400 min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium capitalize shrink-0`,children:e.type}),e.ref&&(0,B.jsxs)(`span`,{className:`text-muted-foreground truncate min-w-0`,children:[`→ `,e.ref]}),e.note&&(0,B.jsx)(`span`,{className:`text-muted-foreground truncate min-w-0`,children:e.note})]},t))})]}),(0,B.jsx)(G,{}),(w.intent||w.doneWhen)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{className:`space-y-2`,children:[w.intent&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Intent`}),(0,B.jsx)(sr,{text:w.intent,className:`text-sm min-w-0 break-words [overflow-wrap:anywhere]`})]}),w.doneWhen&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Done when`}),(0,B.jsx)(sr,{text:w.doneWhen,className:`text-sm min-w-0 break-words [overflow-wrap:anywhere]`})]})]}),(0,B.jsx)(G,{})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Ownership`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[w.ownerAgentId&&(0,B.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Owner`}),(0,B.jsx)(Wf,{agentId:w.ownerAgentId,fallbackLabel:w.ownerAgentLabel,className:`min-w-0 text-sm`})]}),w.createdBy&&(0,B.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created by`}),(0,B.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,title:w.createdBy,children:w.createdBy})]}),w.teamId&&(0,B.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Team`}),(0,B.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere] font-mono text-xs`,title:w.teamId,children:w.teamId})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created`}),(0,B.jsx)(`span`,{title:cn(w.createdAt),children:j(e,w.createdAt)})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Updated`}),(0,B.jsx)(`span`,{title:cn(w.updatedAt),children:j(e,w.updatedAt)})]})]})]}),(w.dispatchWorkShape?.specified||w.dispatchDecision||w.boundWorkerModel)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(bp,{detail:w})]}),(w.branch||w.commits&&w.commits.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsxs)(`section`,{className:`min-w-0 overflow-hidden`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Code`}),w.branch&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm mb-1 min-w-0`,children:[(0,B.jsx)(ne,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,B.jsx)(`span`,{className:`font-mono text-xs min-w-0 break-words [overflow-wrap:anywhere]`,title:w.branch,children:w.branch})]}),w.commits?.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm ml-1 min-w-0`,children:[(0,B.jsx)(Ve,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,B.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:e.sha.slice(0,8)}),e.subject&&(0,B.jsx)(`span`,{className:`text-xs min-w-0 break-words [overflow-wrap:anywhere]`,children:e.subject})]},e.sha))]})]}),w.issues&&w.issues.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Cp,{issues:w.issues})]}),(w.dependsOn&&w.dependsOn.length>0||w.dependents&&w.dependents.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(wp,{dependsOn:w.dependsOn??[],dependents:w.dependents??[]})]}),w.gates&&w.gates.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Tp,{gates:w.gates,now:e})]}),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Sp,{taskId:w.id,taskStatus:w.status,pinProvider:y,pinModel:x,pinEffort:C,onPinProvider:b,onPinModel:S,onPinEffort:ee,onDispatch:le,onSpawn:e=>void f(w.id,e),loading:ie,result:re,providers:p})]}),te&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Ep,{memory:te,now:e})]}),T.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Dp,{history:T,now:e})]})]})]})})]})})}function yp({form:e,onChange:t,onSave:n,onCancel:r}){return(0,B.jsxs)(`section`,{className:`space-y-4`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Edit Task fields`}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-title`,children:`Title`}),(0,B.jsx)(L,{id:`edit-title`,value:e.title,onChange:e=>t({title:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-intent`,children:`Intent`}),(0,B.jsx)(Yd,{id:`edit-intent`,value:e.intent,onChange:e=>t({intent:e.target.value}),rows:3})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-steer`,children:`Latest steer`}),(0,B.jsx)(Yd,{id:`edit-steer`,value:e.latestSteer,onChange:e=>t({latestSteer:e.target.value}),rows:2,placeholder:`Redirect or re-scope in-flight work`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-done-when`,children:`Done when`}),(0,B.jsx)(Yd,{id:`edit-done-when`,value:e.doneWhen,onChange:e=>t({doneWhen:e.target.value}),rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-team`,children:`Team ID`}),(0,B.jsx)(L,{id:`edit-team`,value:e.teamId,onChange:e=>t({teamId:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-complexity`,className:`text-xs`,children:`Complexity`}),(0,B.jsxs)(`select`,{id:`edit-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchComplexity,onChange:e=>t({dispatchComplexity:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),It.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-type`,className:`text-xs`,children:`Type`}),(0,B.jsxs)(`select`,{id:`edit-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchType,onChange:e=>t({dispatchType:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),jt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-footprint`,className:`text-xs`,children:`Context footprint`}),(0,B.jsxs)(`select`,{id:`edit-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchFootprint,onChange:e=>t({dispatchFootprint:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ft.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-criticality`,className:`text-xs`,children:`Criticality`}),(0,B.jsxs)(`select`,{id:`edit-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchCriticality,onChange:e=>t({dispatchCriticality:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Rt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,B.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,B.jsx)(I,{size:`sm`,onClick:n,children:`Save`}),(0,B.jsx)(I,{size:`sm`,variant:`outline`,onClick:r,children:`Cancel`})]})]})}function bp({detail:e}){let t=e.dispatchWorkShape,n=e.dispatchDecision,r=e.boundWorkerModel;return(0,B.jsxs)(`section`,{className:`space-y-3`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch`}),t&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Work shape`}),t.specified?(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.complexity&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.complexity}),t.type&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.type}),t.contextFootprint&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.contextFootprint}),t.criticality&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.criticality})]}):(0,B.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:`Not specified`})]}),n&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Decision`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[n.target.provider&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:n.target.provider}),n.target.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:n.target.model}),n.target.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:n.target.effort}),n.pinned&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),n.rationale&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.rationale}),n.warnings?.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400 mt-0.5`,children:[(0,B.jsx)(Pe,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,B.jsx)(`span`,{children:e})]},t))]}),r&&(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Bound worker`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[r.provider&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:r.provider}),r.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:r.model}),r.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:r.effort})]}),(0,B.jsx)(Wf,{agentId:r.agentId,fallbackLabel:e.ownerAgentLabel,className:`text-xs text-muted-foreground`})]})]})}var xp=new Set([`done`,`canceled`,`failed`]);function Sp({taskId:e,taskStatus:t,pinProvider:n,pinModel:r,pinEffort:i,onPinProvider:a,onPinModel:o,onPinEffort:s,onDispatch:c,onSpawn:l,loading:u,result:d,providers:f}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3`,children:`Spawn with task`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mb-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-provider-${e}`,className:`text-xs`,children:`Provider pin`}),(0,B.jsxs)(`select`,{id:`spawn-provider-${e}`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs`,value:n,onChange:e=>a(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`auto`}),f.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-model-${e}`,className:`text-xs`,children:`Model pin`}),(0,B.jsx)(L,{id:`spawn-model-${e}`,className:`mt-1 h-8 text-xs`,value:r,onChange:e=>o(e.target.value),placeholder:`auto`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-effort-${e}`,className:`text-xs`,children:`Effort pin`}),(0,B.jsx)(L,{id:`spawn-effort-${e}`,className:`mt-1 h-8 text-xs`,value:i,onChange:e=>s(e.target.value),placeholder:`auto`})]})]}),(0,B.jsxs)(I,{size:`sm`,onClick:c,disabled:u||xp.has(t),className:`gap-1.5`,children:[(0,B.jsx)(Re,{className:`w-3.5 h-3.5`}),u?`Planning…`:`Plan dispatch`]}),d&&(0,B.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/20 p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(Re,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:d.decision.target.provider}),d.decision.target.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:d.decision.target.model}),d.decision.target.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:d.decision.target.effort}),d.decision.pinned&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d.decision.rationale}),d.decision.factors.band&&(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Band: `,d.decision.factors.band,d.decision.factors.contextWindowTokens?` · ${(d.decision.factors.contextWindowTokens/1e3).toFixed(0)}k ctx`:``]}),d.decision.warnings.length>0&&(0,B.jsx)(`div`,{className:`space-y-0.5`,children:d.decision.warnings.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400`,children:[(0,B.jsx)(Pe,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,B.jsx)(`span`,{children:e})]},t))}),d.decision.review&&(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Auto-review: `,d.decision.review.reason,` → `,d.decision.review.target.provider,`/`,d.decision.review.target.model??`default`,d.reviewTaskId&&(0,B.jsxs)(`span`,{className:`ml-1`,children:[`(task T`,d.reviewTaskId,`)`]})]})]})]}),(0,B.jsx)(`div`,{className:`pt-1 border-t border-border/50`,children:(0,B.jsxs)(I,{size:`sm`,className:`gap-1.5 w-full`,onClick:()=>l(d.decision.target),children:[(0,B.jsx)(Re,{className:`w-3.5 h-3.5`}),`Spawn worker with task T`,e]})})]})]})}function Cp({issues:e}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Linked Issues`}),(0,B.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:[e.provider,`/`,e.externalKey]}),e.title&&(0,B.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.title}),(0,B.jsx)(F,{variant:`secondary`,className:`text-xs shrink-0`,children:e.status}),e.url&&(0,B.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,B.jsx)(_e,{className:`w-3.5 h-3.5`})})]},e.issueRefId))})]})}function wp({dependsOn:e,dependents:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Dependencies`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[e.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Depends on: `}),e.map((t,n)=>(0,B.jsxs)(`span`,{className:`font-mono text-xs`,children:[`T`,t,n<e.length-1?`, `:``]},t))]}),t.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Blocks: `}),t.map((e,n)=>(0,B.jsxs)(`span`,{className:`font-mono text-xs`,children:[`T`,e,n<t.length-1?`, `:``]},e))]})]})]})}function Tp({gates:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Gate Ledger`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:[...e].sort((e,t)=>t.ranAt-e.ranAt).map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`pass`?(0,B.jsx)(pt,{className:`w-4 h-4 text-emerald-400 shrink-0 mt-0.5`}):(0,B.jsx)(ke,{className:`w-4 h-4 text-red-400 shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-mono text-xs font-medium truncate min-w-0`,children:e.gate}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto shrink-0`,title:cn(e.ranAt),children:j(t,e.ranAt)})]}),e.detail&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.detail}),e.commitSha&&(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.commitSha.slice(0,8)})]})]},e.gate+e.ranAt))})]})}function Ep({memory:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Task Memory`}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[e.workingState&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Working state`}),(0,B.jsx)(`p`,{className:`text-xs whitespace-pre-wrap [overflow-wrap:anywhere] bg-muted/30 rounded p-2`,children:e.workingState})]}),e.ledger.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Ruled out (`,e.ledger.length,`)`]}),(0,B.jsx)(`div`,{className:`space-y-1`,children:e.ledger.map((e,t)=>(0,B.jsxs)(`div`,{className:`text-xs bg-muted/20 rounded p-1.5`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.ruledOut}),e.why&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` — `,e.why]})]},t))})]}),e.decisions.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Decisions (`,e.decisions.length,`)`]}),(0,B.jsx)(`div`,{className:`space-y-1.5`,children:e.decisions.map((e,n)=>(0,B.jsxs)(`div`,{className:`text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium truncate min-w-0`,children:e.decision}),(0,B.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0`,title:cn(e.at),children:j(t,e.at)})]}),e.rationale&&(0,B.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.rationale}),e.by&&(0,B.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`by `,e.by]})]},n))})]})]})]})}function Dp({history:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`History`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:[...e].reverse().slice(0,30).map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,B.jsx)(Te,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-muted-foreground shrink-0`,children:e.type}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground shrink-0`,title:cn(e.createdAt),children:j(t,e.createdAt)})]}),e.title&&e.title!==e.type&&(0,B.jsx)(`p`,{className:`text-foreground mt-0.5 truncate`,children:e.title})]})]},e.id))})]})}var Op=!1;function kp(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;Op=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(Op){Op=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,Op=!0,window.history.back())}},[e])}function Ap({...e}){return kp(e.open,e.onOpenChange),(0,B.jsx)(ri,{"data-slot":`dialog`,...e})}function jp({...e}){return(0,B.jsx)(ii,{"data-slot":`dialog-portal`,...e})}function Mp({className:e,blur:t=!0,...n}){return(0,B.jsx)(ai,{"data-slot":`dialog-overlay`,className:k(`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 Np({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,B.jsxs)(jp,{children:[(0,B.jsx)(Mp,{blur:r}),(0,B.jsxs)(oi,{"data-slot":`dialog-content`,className:k(`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)(li,{"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)(Se,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function Pp({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-header`,className:k(`flex flex-col gap-2`,e),...t})}function Fp({className:e,showCloseButton:t=!1,children:n,...r}){return(0,B.jsxs)(`div`,{"data-slot":`dialog-footer`,className:k(`-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)(li,{asChild:!0,children:(0,B.jsx)(I,{variant:`outline`,children:`Close`})})]})}function Ip({className:e,...t}){return(0,B.jsx)(si,{"data-slot":`dialog-title`,className:k(`font-heading text-base leading-none font-medium`,e),...t})}function Lp({className:e,...t}){return(0,B.jsx)(ci,{"data-slot":`dialog-description`,className:k(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Rp(){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=Cl();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&s(),children:(0,B.jsxs)(Np,{className:`max-w-lg`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Yd,{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)(kl,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:s,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}function zp(){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)(Ap,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(Pp,{children:[(0,B.jsx)(Ip,{children:e.title}),(0,B.jsx)(Lp,{children:e.message})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function Bp(){let e=A(e=>e.errorModal),t=A(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,B.jsx)(Ap,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(Pp,{children:[(0,B.jsx)(Ip,{children:e.title}),(0,B.jsx)(Lp,{children:e.message})]}),(0,B.jsx)(Fp,{children:(0,B.jsx)(I,{onClick:n,children:`OK`})})]})})}function Vp(){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)(Ap,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:n,children:`Save`})]})]})})}function Hp(){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=Cl();function o(e){n({pairInvite:{...t,...e}})}return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Create Pair`})]})]})})}function Up(){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)(Ap,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Yd,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}function Wp(){let e=A(e=>e.threadOpen),t=A(e=>e.threadMessages),n=A(e=>e.agentsById),r=kt(),i=A(e=>e.set);return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,B.jsxs)(Np,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{children:[`Thread (`,t.length,` messages)`]})}),(0,B.jsx)(Kd,{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:sn(e.from,n)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:sn(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)(sr,{text:dn(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 `,sn(e.claimedBy,n)]})]})]},e.id))})})]})})}function Gp(){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)(Ap,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,B.jsxs)(Np,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{children:[`Task Events (`,t.length,`)`]})}),(0,B.jsx)(Kd,{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:on[e.severity]||on.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)(Kp,{event:e,onOpen:i}),(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[cn(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 Kp({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)(oe,{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 qp(){let e=A(e=>e.taskCreateOpen),t=A(e=>e.taskCreateForm),n=A(e=>e.closeTaskCreate),r=A(e=>e.setTaskCreateForm),i=A(e=>e.doCreateTask);return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Np,{className:`max-w-lg`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{children:`New Task`})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-title`,children:[`Title `,(0,B.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,B.jsx)(L,{id:`task-title`,value:t.title,onChange:e=>r({title:e.target.value}),placeholder:`Short description of the work`,autoFocus:!0})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`task-intent`,children:`Intent`}),(0,B.jsx)(Yd,{id:`task-intent`,value:t.intent,onChange:e=>r({intent:e.target.value}),placeholder:`What is this task trying to accomplish?`,rows:3})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`task-done-when`,children:`Done when`}),(0,B.jsx)(Yd,{id:`task-done-when`,value:t.doneWhen,onChange:e=>r({doneWhen:e.target.value}),placeholder:`Acceptance criteria`,rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-issue-refs`,children:[`Issue refs `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated, e.g. owner/repo#123)`})]}),(0,B.jsx)(L,{id:`task-issue-refs`,value:t.issueRefs,onChange:e=>r({issueRefs:e.target.value}),placeholder:`owner/repo#123, owner/repo#456`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-depends-on`,children:[`Depends on `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated task IDs)`})]}),(0,B.jsx)(L,{id:`task-depends-on`,value:t.dependsOn,onChange:e=>r({dependsOn:e.target.value}),placeholder:`42, 43`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape (optional)`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-complexity`,className:`text-xs`,children:`Complexity`}),(0,B.jsxs)(`select`,{id:`dispatch-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchComplexity,onChange:e=>r({dispatchComplexity:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),It.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-type`,className:`text-xs`,children:`Type`}),(0,B.jsxs)(`select`,{id:`dispatch-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchType,onChange:e=>r({dispatchType:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),jt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-footprint`,className:`text-xs`,children:`Context footprint`}),(0,B.jsxs)(`select`,{id:`dispatch-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchFootprint,onChange:e=>r({dispatchFootprint:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ft.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-criticality`,className:`text-xs`,children:`Criticality`}),(0,B.jsxs)(`select`,{id:`dispatch-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchCriticality,onChange:e=>r({dispatchCriticality:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Rt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]})]})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{onClick:()=>void i(),disabled:!t.title.trim(),children:`Create`})]})]})})}function Jp({open:e,onOpenChange:t,onSelect:n,orchestratorId:r,initialPath:i,title:a=`Select Directory`}){let o=A(e=>e.apiCall),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(!1),[g,_]=(0,z.useState)(``),[v,y]=(0,z.useState)(null),b=l?.path||i||``,x=(0,z.useMemo)(()=>b.split(`/`).filter(Boolean),[b]),S=(0,z.useCallback)(async e=>{if(r){c(!0),f(null),m(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;u(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){f(zt(e))}finally{c(!1)}}},[r,o]);(0,z.useEffect)(()=>{e&&r&&(u(null),f(null),m(!1),S(i||void 0))},[e,r]);async function C(){if(!(!g.trim()||!l)){y(null);try{u(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:l.path,name:g.trim()})),m(!1),_(``)}catch(e){y(zt(e))}}}function ee(){b&&(n(b),t(!1))}function w(e){S(`/`+x.slice(0,e+1).join(`/`))}return(0,B.jsx)(Ap,{open:e,onOpenChange:t,children:(0,B.jsxs)(Np,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ce,{className:`h-4 w-4`}),a]})}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-muted/50 px-2 py-1.5 text-xs overflow-x-auto`,children:[(0,B.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground shrink-0`,onClick:()=>l?.baseDir&&S(l.baseDir),children:`/`}),x.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:()=>w(t),children:e}),t<x.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)(Qe,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&d&&(0,B.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:d}),!s&&l&&(0,B.jsxs)(`div`,{className:`p-1`,children:[l.parent&&(0,B.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>S(l.parent),children:[(0,B.jsx)(nt,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),l.entries.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>S(e.path),children:[(0,B.jsx)(h,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),l.entries.length===0&&!l.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),l.entries.length===0&&l.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),p?(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(L,{autoFocus:!0,value:g,onChange:e=>{_(e.target.value),y(null)},onKeyDown:e=>{e.key===`Enter`&&C(),e.key===`Escape`&&(m(!1),_(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`outline`,onClick:C,disabled:!g.trim(),children:(0,B.jsx)(de,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{m(!1),_(``),y(null)},children:(0,B.jsx)(Se,{className:`h-4 w-4`})})]}):(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(!0),disabled:!l||s,children:[(0,B.jsx)(te,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),v&&(0,B.jsx)(`p`,{className:`text-xs text-destructive`,children:v}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(I,{onClick:ee,disabled:!b,children:`Select`})]})]})})}function Yp({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)(ce,{className:`h-4 w-4`})}),n&&(0,B.jsx)(Jp,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function Xp({model:e}){if(!e)return null;let t=Zp(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 Zp(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:Qp(n),Icon:x}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:p}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:p}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:at}),t}function Qp(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function $p(){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=Tt(r,x),w=ee.find(e=>e.alias===i),te=w?.efforts||[],T=!!(S&&C.length>0&&s.trim())&&!h,ne=t.filter(e=>e.status===`online`),re=ne.length>1,ie=m.filter(e=>ne.some(t=>t.id===e.orchId)).slice(0,5);function ae(e){let n=t.find(t=>t.id===e),r=n?.providers[0]||``;_({spawnOrchId:e,spawnProvider:r,spawnModel:r?Dt(r,x):``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function oe(e){_({spawnProvider:e,spawnModel:Dt(e,x),spawnEffort:``})}function E(e){_({spawnModel:e,spawnEffort:``})}return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,B.jsxs)(Np,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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=>ae(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=>oe(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=>E(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:!te.length,children:[(0,B.jsx)(`option`,{value:``,children:`Default`}),te.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,B.jsx)(Xp,{model:w}),(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)(Yp,{value:s,onChange:e=>_({spawnCwd:e}),orchestratorId:n,placeholder:`Select a project directory`})}),ie.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:ie.map(e=>{let t=e.cwd.replace(/\/+$/,``).split(`/`).pop()||e.cwd,r=ne.find(t=>t.id===e.orchId)?.hostname,i=e.orchId===n&&e.cwd===s;return(0,B.jsx)(`button`,{type:`button`,title:re&&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:re&&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)(Yd,{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)(Yd,{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)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,B.jsx)(I,{onClick:v,disabled:!T,children:h?`Spawning…`:C.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function em(){return`host-${Math.random().toString(36).slice(2,8)}`}function tm(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function nm(){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(O()).origin,[]),[a,o]=(0,z.useState)(em),[s,c]=(0,z.useState)(`$HOME/projects`),[u,d]=(0,z.useState)(Lt()),[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 rt(`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)(Ap,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,B.jsxs)(Np,{className:`max-w-2xl overflow-hidden`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{className:`flex items-center gap-2`,children:[(0,B.jsx)(l,{className:`w-4 h-4`}),`Add Orchestrator`]})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Orchestrator ID`}),(0,B.jsx)(L,{value:a,onChange:e=>o(e.target.value)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Relay URL`}),(0,B.jsx)(L,{value:i,readOnly:!0})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Base Directory`}),(0,B.jsx)(L,{value:s,onChange:e=>c(e.target.value)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`API Port`}),(0,B.jsx)(L,{value:f,onChange:e=>p(e.target.value),inputMode:`numeric`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Providers`}),(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:Lt().map(e=>(0,B.jsx)(I,{type:`button`,size:`sm`,variant:u.includes(e)?`default`:`outline`,onClick:()=>d(tm(u,e)),children:Pt(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)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,B.jsx)(rr,{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)(be,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function rm(){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=Tt(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:Dt(r,a),effort:``})}function h(e){p({provider:e,rig:``,model:Dt(e,a),effort:``})}return(0,B.jsx)(Ap,{open:e.open,onOpenChange:e=>!e&&p({open:!1}),children:(0,B.jsxs)(Np,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Xp,{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)(Yp,{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)(Yd,{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)(kl,{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)(kl,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>p({scheduledDailyRestart:e})})]})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>p({open:!1}),children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:d?`Save`:`Create`})]})]})})}function im({children:e}){return(0,B.jsxs)(dl,{children:[(0,B.jsx)(fl,{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)(gt,{className:`h-3 w-3`})})}),(0,B.jsx)(pl,{className:`max-w-xs leading-relaxed`,children:e})]})}function am({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)(im,{children:t})]})}var om=[{value:``,label:`Off`},{value:`all`,label:`All`}],sm=[{value:``,label:`Off`},{value:`all`,label:`All safe settings`}],cm=[{value:``,label:`Instance default`},{value:`direct`,label:`Direct`},{value:`pr`,label:`Pull request`}],lm=[{value:`any`,label:`Any provider`},...Lt().map(e=>({value:e,label:Pt(e)}))],um={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 dm(e){return e?e.policy??`all`:``}function fm(e){if(e)return e===`all`?{policy:`all`}:{}}function pm({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 mm(e,t){return`${e.source}:${e.provider??`any`}:${e.ref}:${t}`}function hm({source:e}){return(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] ${um[e]}`,children:e})}function gm({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)(``),[w,te]=(0,z.useState)(`any`);async function T(e){if(b(e),!p){g(!0),v(null);try{f((await rt(`GET`,`/provisioning/capabilities`)).capabilities),m(!0)}catch(e){v(zt(e))}finally{g(!1)}}}function ne(n){let a=C.trim();if(!a)return;let o={source:x,ref:a,enabled:!0,...w===`any`?{}:{provider:w}};n===`skill`?r([...e,o]):i([...t,o]),ee(``),b(null)}function re(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 ie(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 ae(t,n){r(e.map((e,r)=>r===t?{...e,...n}:e))}function oe(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 D=d.filter(e=>e.capability.kind===`skill`),se=d.filter(e=>e.capability.kind===`plugin`),ce=d.filter(e=>e.capability.kind===`mcp`);return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(_m,{projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l}),(0,B.jsx)(ym,{title:`Skills from registry`,kind:`skill`,refs:e,readOnly:u,adding:y===`skill`,caps:D,loading:h,fetchError:_,empty:`No skills assigned`,manualRef:C,manualSource:x,manualProvider:w,onAddClick:()=>void T(`skill`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:te,onAddManual:()=>ne(`skill`),onAddRelay:e=>re(`skill`,e),onUpdate:ae,onRemove:t=>r(e.filter((e,n)=>n!==t))}),(0,B.jsx)(ym,{title:`Plugins from registry`,kind:`plugin`,refs:t,readOnly:u,adding:y===`plugin`,caps:se,loading:h,fetchError:_,empty:`No plugins assigned`,manualRef:C,manualSource:x,manualProvider:w,onAddClick:()=>void T(`plugin`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:te,onAddManual:()=>ne(`plugin`),onAddRelay:e=>re(`plugin`,e),onUpdate:oe,onRemove:e=>i(t.filter((t,n)=>n!==e))}),(0,B.jsx)(Sm,{mcpKeys:Object.keys(n.servers??{}),caps:ce,adding:y===`mcp`,loading:h,fetchError:_,readOnly:u,onAddClick:()=>void T(`mcp`),onAddMcp:ie,onCancel:()=>b(null),onRemove:E})]})}function _m(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)(im,{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: `,dm(e.projectMcp)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSkills?`default`:`outline`,className:`text-[10px]`,children:[`project skills: `,dm(e.projectSkills)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSettings?`default`:`outline`,className:`text-[10px]`,children:[`project settings: `,dm(e.projectSettings)||`off`]}),(0,B.jsxs)(F,{variant:e.sharedMcp?`default`:`outline`,className:`text-[10px]`,children:[`shared MCP: `,dm(e.sharedMcp)||`off`]})]})]})}function vm(e){return[...new Set(e.variants.map(e=>e.sourceType||`relay`))].join(`, `)}function ym(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)(me,{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)(hm,{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)(kl,{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)(je,{className:`h-3 w-3`})})]},mm(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:[`(`,vm(t),`)`]})]},t.capability.id))}),(0,B.jsx)(bm,{}),(0,B.jsx)(xm,{...e}),(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function bm(){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 xm(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)(pm,{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)(pm,{value:e.manualProvider,onChange:t=>e.onManualProvider(t),options:lm})]}),(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 Sm(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)(me,{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)(hm,{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)(je,{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:[`(`,vm(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 Cm(e){let t=Lt();return e&&e!==`any`&&t.includes(e)?e:t[0]??``}function wm({profile:e}){let[t,n]=(0,z.useState)(()=>Cm(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 rt(`GET`,`/agent-profiles/${encodeURIComponent(e.name)}/resolved?provider=${encodeURIComponent(r)}`);n(t.provider),i(t.profile.provisioning??{skills:[],plugins:[],mcpServers:{}})}catch(e){c(zt(e)),i(null)}finally{o(!1)}}}let u=e.relay.tools?.groups??[],d=u.length?`custom: ${u.join(`, `)}`:`full access (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)(pm,{value:t,onChange:e=>{n(e),l(e)},options:Lt().map(e=>({value:e,label:Pt(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)(Tm,{title:`Skills`,values:r.skills.map(e=>e.name),empty:`No resolved skills`}),(0,B.jsx)(Tm,{title:`Plugins`,values:r.plugins.map(e=>e.name),empty:`No resolved plugins`}),(0,B.jsx)(Tm,{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 Tm({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 Em({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)(ht,{className:`h-3.5 w-3.5`}):(0,B.jsx)(le,{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 Dm({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 Om({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(``);function c(){i.trim()&&(t({...e,[i.trim()]:o}),a(``),s(``))}function l(n){let r={...e};delete r[n],t(r)}return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[r.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsxs)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 text-xs`,children:[e,`=`,t]}),!n&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>l(e),children:(0,B.jsx)(je,{className:`h-3 w-3`})})]},e)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:i,onChange:e=>a(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,B.jsx)(L,{value:o,onChange:e=>s(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&c()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:c,children:(0,B.jsx)(me,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var km=[{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)`}],Am=[{value:`any`,label:`Any provider`},...Lt().map(e=>({value:e,label:Pt(e)}))],jm=[{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`}],Mm=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],Nm=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],Pm=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}],Fm={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).`},Im={context:`Context`,skills:`Skills`,plugins:`Plugins`,statusLine:`Status Line`,mcp:`MCP Tools`};function Lm({values:e,onChange:t,disabled:n,placeholder:r}){let[i,a]=(0,z.useState)(``);function o(){let n=i.trim();n&&(t([...e,n]),a(``))}function s(n,r){t(e.map((e,t)=>t===n?r:e))}function c(n){t(e.filter((e,t)=>t!==n))}return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[e.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:e,onChange:e=>s(t,e.target.value),disabled:n,className:`flex-1 text-xs`}),!n&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>c(t),children:(0,B.jsx)(je,{className:`h-3 w-3`})})]},`${e}-${t}`)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:i,onChange:e=>a(e.target.value),placeholder:r,className:`flex-1 text-xs`,onKeyDown:e=>e.key===`Enter`&&o()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:o,children:(0,B.jsx)(me,{className:`h-3 w-3`})})]}),e.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`None`})]})}function Rm(){let{open:e,mode:t,profile:n,relayToolsMode:r}=A(e=>e.profileModal),i=A(e=>e.closeProfileModal),a=A(e=>e.updateProfileModal),o=A(e=>e.setRelayToolsMode),s=A(e=>e.toolGroupCatalog),c=A(e=>e.toolGroupCatalogStatus),l=A(e=>e.fetchToolGroupCatalog),u=A(e=>e.saveProfile),d=t===`view`,f=t===`create`||t===`duplicate`,p=t===`view`?`Profile: ${n.name}`:t===`edit`?`Edit: ${n.name}`:t===`duplicate`?`Duplicate Profile`:`Create Profile`;function m(e){a({instructions:{...n.instructions,...e}})}function h(e){a({relay:{...n.relay,...e}})}function g(e,t){let r=n.relay.tools?.groups??[],i=t?[...new Set([...r,e])]:r.filter(t=>t!==e);h({tools:i.length?{groups:i}:void 0})}let _=n.relay.tools?.groups??[],v=s.reduce((e,t)=>e+t.tools.length,0),y=c.loading||!c.loaded&&s.length===0,b=!y&&(!!c.error||s.length===0);function x(e){a({projectMcp:fm(e)})}function S(e){a({projectSkills:fm(e)})}function C(e){a({projectSettings:fm(e)})}function w(e){a({sharedMcp:fm(e)})}function te(e){a({permissions:{...n.permissions,...e}})}function T(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}a({providerOptions:{...t,codex:r}})}function ne(e){if(!e.trim()){a({maxSpawnedAgents:void 0});return}let t=Number(e);!Number.isInteger(t)||t<0||a({maxSpawnedAgents:Math.min(t,100)})}function re(e){let t=e===`host`;a({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 ie=n.providerOptions?.codex&&typeof n.providerOptions.codex==`object`&&!Array.isArray(n.providerOptions.codex)?n.providerOptions.codex:{},ae=Number.isSafeInteger(ie.toolOutputTokenLimit)?String(ie.toolOutputTokenLimit):``;return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&i(),children:(0,B.jsxs)(Np,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{className:`flex items-center gap-2`,children:[p,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)(Em,{title:`General`,defaultOpen:!0,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Name`}),(0,B.jsx)(L,{value:n.name,onChange:e=>a({name:e.target.value}),placeholder:`my-profile`,disabled:d||t===`edit`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Description`}),(0,B.jsx)(L,{value:n.description||``,onChange:e=>a({description:e.target.value}),placeholder:`What this profile configures`,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{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=>a({icon:e.target.value}),placeholder:`🤖`,maxLength:8,disabled:d,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)(Dm,{value:n.base,onChange:e=>re(e),options:km,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsx)(Dm,{value:n.provider||`any`,onChange:e=>a({provider:e}),options:Am,disabled:d})]})]})]}),(0,B.jsxs)(Em,{title:`Instructions`,defaultOpen:!1,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`System Prompt`}),(0,B.jsx)(Yd,{value:n.instructions.system||``,onChange:e=>m({system:e.target.value}),placeholder:`Custom system prompt...`,rows:3,disabled:d,className:`font-mono text-xs`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Append Instructions`}),(0,B.jsx)(Lm,{values:n.instructions.append??[],onChange:e=>m({append:e}),disabled:d,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)(Dm,{value:n.instructions.repoInstructions,onChange:e=>m({repoInstructions:e}),options:Nm,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Global Instructions`}),(0,B.jsx)(Dm,{value:n.instructions.globalInstructions,onChange:e=>m({globalInstructions:e}),options:Nm,disabled:d})]})]})]}),(0,B.jsxs)(Em,{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)(am,{tip:Fm[e],children:Im[e]}),(0,B.jsx)(kl,{checked:n.relay[e]??!0,onCheckedChange:t=>h({[e]:t}),disabled:d})]},e))}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{tip:`Which relay MCP tools this agent can call. Full access grants every tool relay exposes; Custom restricts the agent to only the selected groups. Sourced live from the server's tool-group registry, so it can't drift out of date.`,children:`Relay Tool Groups`}),(0,B.jsxs)(`div`,{className:`mt-1 flex overflow-hidden rounded-md border border-input text-xs`,children:[(0,B.jsx)(`button`,{type:`button`,className:`flex-1 px-2 py-1.5 font-medium transition-colors ${r===`full`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`}`,onClick:()=>o(`full`),disabled:d,children:`Full access — all tools`}),(0,B.jsx)(`button`,{type:`button`,className:`flex-1 border-l border-input px-2 py-1.5 font-medium transition-colors ${r===`custom`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`}`,onClick:()=>o(`custom`),disabled:d,children:`Custom — selected groups`})]}),r===`full`&&(0,B.jsxs)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[`Every relay MCP tool is available — `,v,` tools across `,s.length,` groups.`]}),r===`custom`&&(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`div`,{className:`mt-1.5 rounded border border-border bg-muted/20 px-2 py-2 text-xs text-muted-foreground`,children:`Loading tool groups…`}):b?(0,B.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-2 rounded border border-destructive/40 bg-destructive/10 px-2 py-2 text-xs text-destructive`,children:[(0,B.jsx)(`span`,{children:`Couldn't load tool groups (is the server up to date?)`}),(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:()=>void l(),disabled:c.loading,children:[(0,B.jsx)(ee,{className:`h-3 w-3 ${c.loading?`animate-spin`:``}`}),`Retry`]})]}):(0,B.jsx)(`div`,{className:`mt-1.5 grid grid-cols-2 gap-1.5`,children:s.map(e=>(0,B.jsxs)(`label`,{className:`flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`rounded`,checked:_.includes(e.name),onChange:t=>g(e.name,t.target.checked),disabled:d}),(0,B.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:e.name}),(0,B.jsx)(im,{children:(0,B.jsx)(`div`,{className:`font-mono text-[11px] leading-relaxed`,children:e.tools.join(`, `)})})]},e.name))}),!y&&!b&&(_.length===0?(0,B.jsx)(`p`,{className:`mt-1.5 text-xs text-amber-400`,children:`No groups selected yet — until you pick at least one, this profile keeps full tool access.`}):(0,B.jsxs)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[_.length,` of `,s.length,` groups selected.`]}))]})]})]}),(0,B.jsx)(Em,{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)(am,{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)(Dm,{value:n.mcp.mode,onChange:e=>a({mcp:{...n.mcp,mode:e}}),options:jm,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{tip:`The host's hook configuration. Host = inherit it; None = no host hooks.`,children:`Hooks Mode`}),(0,B.jsx)(Dm,{value:n.hooks.mode,onChange:e=>a({hooks:{mode:e}}),options:jm,disabled:d})]})]})}),(0,B.jsx)(Em,{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)(am,{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)(Dm,{value:dm(n.projectMcp),onChange:x,options:om,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{tip:`Injects skills committed under the project's .claude/skills.`,children:`Project Skills`}),(0,B.jsx)(Dm,{value:dm(n.projectSkills),onChange:S,options:om,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{tip:`Injects the project's .claude/settings.json (permission/security keys stripped).`,children:`Project Settings`}),(0,B.jsx)(Dm,{value:dm(n.projectSettings),onChange:C,options:sm,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{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)(Dm,{value:dm(n.sharedMcp),onChange:w,options:om,disabled:d})]}),(0,B.jsxs)(`div`,{className:`col-span-2`,children:[(0,B.jsx)(am,{tip:`How the agent's isolated branch lands: Direct (rebase/FF), Pull request, or the instance default.`,children:`Landing Strategy`}),(0,B.jsx)(Dm,{value:n.landingStrategy??``,onChange:e=>a({landingStrategy:e||void 0}),options:cm,disabled:d})]})]})}),(0,B.jsx)(Em,{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)(Dm,{value:n.permissions.mode||``,onChange:e=>te({mode:e||void 0}),options:Pm,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Filesystem Scope`}),(0,B.jsx)(Dm,{value:n.permissions.filesystem,onChange:e=>te({filesystem:e}),options:Mm,disabled:d})]})]})}),(0,B.jsx)(Em,{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=>ne(e.target.value),placeholder:`0`,disabled:d}),(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)(Em,{title:`Environment Variables`,defaultOpen:!1,children:(0,B.jsx)(Om,{env:n.env||{},onChange:e=>a({env:e}),disabled:d})}),(0,B.jsx)(Em,{title:`Registry Capabilities`,defaultOpen:!1,children:(0,B.jsx)(gm,{skills:n.skills??[],plugins:n.plugins??[],mcp:n.mcp,onChangeSkills:e=>a({skills:e}),onChangePlugins:e=>a({plugins:e}),onChangeMcp:e=>a({mcp:e}),projectMcp:n.projectMcp,projectSkills:n.projectSkills,projectSettings:n.projectSettings,sharedMcp:n.sharedMcp,readOnly:d})}),(0,B.jsx)(Em,{title:`Resolved Provisioning`,defaultOpen:t===`view`,children:(0,B.jsx)(wm,{profile:n})}),(0,B.jsxs)(Em,{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:ae,onChange:e=>T(e.target.value),placeholder:`12000`,disabled:d})]}),(0,B.jsx)(Yd,{value:JSON.stringify(n.providerOptions||{},null,2),onChange:e=>{try{a({providerOptions:JSON.parse(e.target.value)})}catch{}},rows:3,disabled:d,className:`font-mono text-xs`,placeholder:`{}`})]})]}),!d&&(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:i,children:`Cancel`}),(0,B.jsx)(I,{onClick:u,children:f?`Create`:`Save`})]})]})})}function zm(){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=Dl(),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)(st[e.icon]||le,{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 Bm(){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)(Ye,{className:`w-5 h-5`})}),(0,B.jsx)(D,{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 Vm(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 Hm(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`}let r=Math.floor(n/86400),i=Math.round(n%86400/3600);return i===24?`${r+1}d`:i>0?`${r}d ${i}h`:`${r}d`}var Um=`agent-relay:quota-widget`,Wm=300*1e3,Gm=8;function Km(e){return!e.quota&&e.lastError?.type===`unavailable`}function qm(e,t){let n=t===`5h`?[`five_hour`,`primary`]:[`seven_day`,`secondary`];return e.quota?.windows.find(e=>n.includes(e.name))}function Jm(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 Ym({record:e,now:t,advisory:n}){let r=(0,B.jsx)(ir,{provider:e.provider,className:`w-3.5 h-3.5`});if(Km(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=qm(e,`5h`),a=qm(e,`7d`);function o(e){if(!e)return null;let n=Math.round(e.utilization*100),r=Jm(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)(th,{advisory:n}),o(i),o(a),s&&(0,B.jsx)(`span`,{className:`text-muted-foreground/70`,children:s})]})}function Xm(){try{let e=localStorage.getItem(Um);return{open:!0,pinned:!1,...e?JSON.parse(e):{}}}catch{return{open:!0,pinned:!1}}}function Zm(e){try{localStorage.setItem(Um,JSON.stringify(e))}catch{}}function Qm(){let[{open:e,pinned:t},n]=(0,z.useState)(Xm),[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=kt(),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([rt(`GET`,`/provider-quotas`),rt(`GET`,`/providers/quota-config`).catch(()=>null),rt(`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(),Wm);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&&!Km(e)),g=m.some(e=>e.lastError&&!Km(e));function _(){if(t)return;let r={open:!e,pinned:t};n(r),Zm(r)}function v(){let r=t?{open:e,pinned:!1}:{open:!0,pinned:!0};n(r),Zm(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)(le,{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)(Qe,{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)(Ym,{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)(he,{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)(Qe,{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??Gm};return(0,B.jsx)(ah,{record:e,now:d,advisory:s?.advisories[e.provider],sparklineCfg:n},`${e.provider}:${e.accountKey}`)})})]})]})}var $m={prefer:{icon:_t,badge:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,dot:`bg-emerald-400`},caution:{icon:c,badge:`text-amber-400 bg-amber-500/10 border-amber-500/20`,dot:`bg-amber-400`},"avoid-large":{icon:c,badge:`text-orange-400 bg-orange-500/10 border-orange-500/20`,dot:`bg-orange-400`},"hard-avoid":{icon:Pe,badge:`text-red-400 bg-red-500/10 border-red-500/20`,dot:`bg-red-400`}};function eh({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)(Pe,{className:`w-2.5 h-2.5`}),`at capacity`]});let t=e.quotaPenaltyBand;if(t===`normal`)return null;let n=$m[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 th({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-500 shrink-0`,title:`at capacity`});let t=e.quotaPenaltyBand;return t===`normal`?null:(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${$m[t].dot} shrink-0`,title:t})}function nh(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}× · ~${Hm(t,t+e.earlyWallMs)} before reset`}function rh({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)(Te,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{className:`italic`,children:`building burn history…`})]});let n=nh(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)(c,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{children:n})]}):null}function ih({provider:e,windowName:t,rangeHours:n}){let[r,i]=(0,z.useState)([]);kt(),(0,z.useEffect)(()=>{let r=!1,a=Date.now()-n*36e5;return rt(`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 ah({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(Km(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)(ir,{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)(ir,{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)(eh,{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?Hm(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:Vm(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)(rh,{burnWindow:s,now:t}),r?.enabled&&(0,B.jsx)(ih,{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 oh(e){return(0,z.lazy)(()=>vr(e))}var sh=oh(()=>R(()=>import(`./overview-BgpfO6mt.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([15,1,6,8,9,10,16,17,12,18]),import.meta.url)),ch=oh(()=>R(()=>import(`./chat-C7OhKtr6.js`).then(e=>({default:e.ChatView})),__vite__mapDeps([19,1,6,20,8,9,10,21,16,22,2,23,24,25,26,27,11,12,17,28,13]),import.meta.url)),lh=oh(()=>R(()=>import(`./agents-DWn1xx9x.js`).then(e=>({default:e.AgentsView})),__vite__mapDeps([29,1,30,31,6,12,32,20,33,34,35,36,37,8,9,10,16,26,27,11,17,18]),import.meta.url)),uh=oh(()=>R(()=>import(`./managed-agents-8_NKSkhI.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([38,1,6,8,9,10,27,11,12,17]),import.meta.url)),dh=oh(()=>R(()=>import(`./teams-C9E9Yt39.js`).then(e=>({default:e.TeamsView})),__vite__mapDeps([39,1,40,30,31,6,12,32,20,33,34,41,42,43,35,37,44,8,9,10,24,25,17,11,18,28]),import.meta.url)),fh=oh(()=>R(()=>import(`./agent-profiles-BhadoGwi.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([45,1,6,8,9,10,17,12,11]),import.meta.url)),ph=oh(()=>R(()=>import(`./orchestrators-DEOep7FX.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([46,6,1,8,9,10,17,12,11,18]),import.meta.url)),mh=oh(()=>R(()=>import(`./workspaces-DI317fMk.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([47,1,6,8,9,10,27,11,12,25,17,18]),import.meta.url)),hh=oh(()=>R(()=>import(`./channels-BLkdt2XR.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([48,6,1,8,9,10,17,12,11,18]),import.meta.url)),gh=oh(()=>R(()=>import(`./connectors-C0n12Je8.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([49,6,1,8,9,10,17,12,11,18]),import.meta.url)),_h=oh(()=>R(()=>import(`./integrations-v14ehskT.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([50,6,1,8,9,10,17,12,11,18]),import.meta.url)),vh=oh(()=>R(()=>import(`./security-BlTFTbq0.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([51,1,6,27,11,12,17,18,28]),import.meta.url)),yh=oh(()=>R(()=>import(`./memory-CJD8eekg.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([52,1,6,8,9,10,17,12,11,18,28]),import.meta.url)),bh=oh(()=>R(()=>import(`./activity-CZNwmXg1.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([53,1,6,8,9,10,21,16,22,2,23,25,17,12,11,18]),import.meta.url)),xh=oh(()=>R(()=>import(`./pairs-8NVKHh96.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([54,6,1,8,9,10,17,12,11,18]),import.meta.url)),Sh=oh(()=>R(()=>import(`./messages-DLHMZbHZ.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([55,1,6,8,9,10,22,2,17,12,11,18]),import.meta.url)),Ch=oh(()=>R(()=>import(`./work-queue-Ema7Hy3s.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([56,6,1,8,9,10,17,12,11,18]),import.meta.url)),wh=oh(()=>R(()=>import(`./tasks-C3JhQ8vB.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([57,1,6,8,9,10,17,12,11,18]),import.meta.url)),Th=oh(()=>R(()=>import(`./automation-BExrtKkb.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([58,1,6,8,9,10,17,12,11,18,28]),import.meta.url)),Eh=oh(()=>R(()=>import(`./analytics-DifGnk7q.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([59,1,6,8,9,10,18,60]),import.meta.url)),Dh=oh(()=>R(()=>import(`./insights-DEgES6jz.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([61,1,6,17,12,11,18,28,9,10]),import.meta.url)),Oh=oh(()=>R(()=>import(`./projects-CZJW35C7.js`).then(e=>({default:e.ProjectsView})),__vite__mapDeps([62,1,6,8,9,10,27,11,12,17,18]),import.meta.url)),kh=oh(()=>R(()=>import(`./prompt-settings-fqyLwUa-.js`).then(e=>({default:e.PromptSettingsView})),__vite__mapDeps([63,1,6,17,12,11,18,9,10]),import.meta.url)),Ah=oh(()=>R(()=>import(`./registry-BKbLL4mO.js`).then(e=>({default:e.RegistryView})),__vite__mapDeps([64,1,6,17,12,11,18,28,10]),import.meta.url)),jh=oh(()=>R(()=>import(`./maintenance-BgVB6_gO.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([65,1,6,8,9,10,17,12,11]),import.meta.url)),Mh=oh(()=>R(()=>import(`./settings-nHuSVRkL.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([66,1,40,30,31,6,12,32,20,33,34,41,42,43,35,37,44,8,9,10,23,16,17,11,18,28,60]),import.meta.url)),Nh=class extends z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
|
|
23
|
+
`):``}function Lf(e,t){let n=e.steps[e.steps.length-1]?.turnId,r=t.steps[0]?.turnId;return n&&r?n===r:!n&&!r}var Rf={online:`text-emerald-400`,offline:`text-zinc-400`,shutdown:`text-zinc-400`,restarted:`text-blue-400`,"compaction-requested":`text-zinc-400`,compacting:`text-amber-400`,compacted:`text-amber-400`,"compaction-stalled":`text-red-400`,"clear-requested":`text-zinc-400`,"clearing-context":`text-amber-400`,"context-cleared":`text-amber-400`,"clear-stalled":`text-red-400`,"shutting-down":`text-zinc-400`};function zf(e){let t=new Date,[n,r,i]=e.split(`-`).map(Number),a=new Date(n,r-1,i);if(e===Df(t.getTime()))return`Today`;let o=new Date(t);return o.setDate(o.getDate()-1),e===Df(o.getTime())?`Yesterday`:a.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:a.getFullYear()===t.getFullYear()?void 0:`numeric`})}function Bf({event:e}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,B.jsx)(Ee,{className:k(`w-2 h-2 fill-current`,Rf[e.status]||`text-zinc-400`)}),(0,B.jsx)(`span`,{children:hf[e.status]||e.status}),(0,B.jsx)(`span`,{className:`text-muted-foreground/60`,children:ff(e.timestamp)})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}var Vf={"branch.landed":Ue,"context.warning":Pe,"agent.context_threshold":Pe,"agent.resume_budget_exhausted":Pe,"agent.rate_limit_resume":_},Hf={"branch.landed":`branch landed`,"context.warning":`context warning`,"agent.context_threshold":`context threshold reached`};function Uf(e){return e&&(e.includes(`.`)?e.slice(e.indexOf(`.`)+1):e).replace(/[._-]+/g,` `).trim()||`system signal`}function Wf({agentId:e,fallbackLabel:t,className:n,noIcon:r}){let i=A(t=>t.agentsById[e])||null,a=A(e=>e.openInboxThread),o=A(e=>e.switchView),s=i?M(i):t||e;return(0,B.jsxs)(`button`,{type:`button`,className:k(`inline-flex max-w-full items-center gap-1 rounded px-1 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,n),onClick:t=>{t.stopPropagation(),a(e),o(`chat`)},title:`Open chat for ${s}`,children:[!r&&(0,B.jsx)(ar,{agent:i,className:`w-4 h-4 text-[10px]`}),(0,B.jsx)(`span`,{className:`max-w-[160px] truncate`,children:s})]})}function Gf({msg:e}){let t=e.payload??{},n=qf(e),r=typeof t.sha==`string`?t.sha:``,i=r?r.slice(0,7):``,a=typeof t.author==`string`?t.author:``,o=typeof t.branch==`string`?t.branch:``,s=typeof t.base==`string`?t.base:``,c=t.pushed,l=typeof t.taskId==`number`&&Number.isSafeInteger(t.taskId)?t.taskId:void 0,u=typeof t.taskLabel==`string`?t.taskLabel:void 0,d=A(e=>e.openTaskDetailById);return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center justify-center gap-x-1.5 gap-y-0.5 rounded-full border border-emerald-600/35 bg-emerald-500/10 px-2.5 py-1 text-xs text-emerald-700 dark:border-emerald-500/25 dark:text-emerald-300/90`,children:[(0,B.jsx)(Ue,{className:`h-3 w-3 shrink-0 text-emerald-600 dark:text-emerald-400`}),(0,B.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-300`,children:`branch landed`}),o&&s&&(0,B.jsxs)(`span`,{className:`font-mono text-emerald-700/80 dark:text-emerald-200/70`,title:`${o} → ${s}`,children:[o,(0,B.jsx)(`span`,{className:`opacity-50`,children:` → `}),s]}),i&&(0,B.jsx)(`span`,{className:`rounded bg-emerald-500/15 px-1 font-mono text-emerald-800 dark:text-emerald-200`,title:r,children:i}),a&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-emerald-700/80 dark:text-emerald-300/80`,children:[(0,B.jsx)(`span`,{className:`opacity-70`,children:`by`}),(0,B.jsx)(Wf,{agentId:a,className:`text-emerald-700 hover:text-emerald-900 dark:text-emerald-300/90 dark:hover:text-emerald-100`})]}),l!=null&&(0,B.jsx)(or,{id:l,title:u,compact:!0,onClick:()=>d(l)}),c===!1&&(0,B.jsx)(`span`,{className:`text-amber-600 dark:text-amber-300/80`,title:`Local-only land — not pushed to origin`,children:`· local only`}),n&&(0,B.jsxs)(`span`,{className:`max-w-[220px] truncate text-emerald-700/70 dark:text-emerald-300/70`,title:n,children:[`· because `,n]}),(0,B.jsx)(`span`,{className:`text-emerald-700/60 dark:text-emerald-300/50`,children:ff(e.occurredAt??e.createdAt)})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Kf({msg:e}){let t=typeof e.payload?.kind==`string`?e.payload.kind:``;if(t===`branch.landed`)return(0,B.jsx)(Gf,{msg:e});let n=Vf[t]??D,r=Hf[t]??Uf(t),i=qf(e);return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-full border border-border bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground`,children:[(0,B.jsx)(n,{className:`h-3 w-3`}),(0,B.jsx)(`span`,{children:r}),i&&(0,B.jsxs)(`span`,{className:`max-w-[220px] truncate text-muted-foreground/80`,title:i,children:[`· because `,i]}),(0,B.jsx)(`span`,{className:`text-muted-foreground/60`,children:ff(e.occurredAt??e.createdAt)})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function qf(e){let t=e.payload?.routing;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.reason;return typeof n==`string`?n:``}var Jf={"spawned-child":{ready:`spawned`,exited:`spawned · exited`,failed:`spawn failed`},"spawned-by":{ready:`spawned by`,exited:`spawned by`,failed:`spawned by`}},Yf={"spawned-child-ready":me,"spawned-child-exited":ft,"spawned-child-failed":Ce,"spawned-by-ready":C,"spawned-by-exited":C,"spawned-by-failed":C},Xf={"spawned-child-ready":`text-emerald-400`,"spawned-child-exited":`text-zinc-400`,"spawned-child-failed":`text-red-400`,"spawned-by-ready":`text-blue-400`,"spawned-by-exited":`text-blue-400`,"spawned-by-failed":`text-blue-400`};function Zf({entry:e}){let t=`${e.direction}-${e.status}`,n=Jf[e.direction]?.[e.status]??e.direction,r=Yf[t]??D,i=Xf[t]??`text-muted-foreground`,a=e.status===`failed`;return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:k(`flex items-center gap-1.5 rounded-full border bg-muted/30 px-2.5 py-1 text-xs`,a?`border-red-500/30`:`border-border`),children:[(0,B.jsx)(r,{className:k(`h-3 w-3 shrink-0`,i)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:n}),(0,B.jsx)(Wf,{agentId:e.agentId}),e.reason&&a&&(0,B.jsxs)(`span`,{className:`text-red-400/80 max-w-[120px] truncate`,title:e.reason,children:[`— `,e.reason]}),(0,B.jsx)(`span`,{className:`text-muted-foreground/60 shrink-0`,children:ff(e.timestamp)})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}var Qf={memory:ie,instructions:pe,tools:qe,comms:D,knowledge:se,context:ct},$f={memory:`border-emerald-500/25 bg-emerald-500/10 text-emerald-300`,instructions:`border-sky-500/25 bg-sky-500/10 text-sky-300`,tools:`border-amber-500/25 bg-amber-500/10 text-amber-300`,comms:`border-violet-500/25 bg-violet-500/10 text-violet-300`,knowledge:`border-cyan-500/25 bg-cyan-500/10 text-cyan-300`,context:`border-zinc-500/25 bg-zinc-500/10 text-zinc-300`};function ep(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function tp({entry:e}){let[t,n]=(0,z.useState)(!1),r=e.event,i=Qf[r.category]??_t;return(0,B.jsx)(`div`,{className:`flex justify-center py-2 my-1`,children:(0,B.jsxs)(`div`,{className:k(`w-full max-w-[85%] md:max-w-[75%] rounded-lg border px-2.5 py-1.5 text-xs shadow-sm`,$f[r.category]??$f.context),children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-center gap-1.5 text-left`,onClick:()=>n(e=>!e),children:[(0,B.jsx)(i,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`shrink-0 font-medium`,children:r.category}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/80`,children:r.summary}),(0,B.jsx)(`span`,{className:`shrink-0 text-muted-foreground/60`,children:ff(r.timestamp)}),(0,B.jsx)(le,{className:k(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-90`)})]}),t&&(0,B.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto rounded-md border border-border/60 bg-background/75 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap break-words`,children:ep(r.detail)})]})})}function np({blockedLabel:e,onInterrupt:t}){return e?(0,B.jsx)(`div`,{className:`flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150`,children:(0,B.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-red-500/30 px-4`,children:[(0,B.jsx)(Ce,{className:`w-3.5 h-3.5 text-red-400`}),(0,B.jsxs)(`span`,{className:`text-xs text-red-300`,children:[`blocked: `,e]})]})}):(0,B.jsx)(`div`,{className:`flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150`,children:(0,B.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-foreground/10 px-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_infinite]`}),(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.2s_infinite]`}),(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.4s_infinite]`})]}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`working`}),t&&(0,B.jsxs)(`button`,{onClick:t,title:`Interrupt`,className:`ml-1 flex items-center gap-1 rounded-full px-1.5 py-0.5 text-xs text-muted-foreground hover:text-red-300 hover:bg-red-500/10 transition-colors`,children:[(0,B.jsx)(Ze,{className:`w-3.5 h-3.5`}),`Stop`]})]})})}var rp=`agent-relay:chat-hide-tools`,ip=(()=>{let e=new Set,t=(()=>{try{return window.localStorage.getItem(rp)===`on`}catch{return!1}})(),n=()=>e.forEach(e=>e());return typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===rp&&(t=e.newValue===`on`,n())}),{subscribe(t){return e.add(t),()=>e.delete(t)},get:()=>t,toggle(){t=!t;try{window.localStorage.setItem(rp,t?`on`:`off`)}catch{}n()}}})();function ap(){return[(0,z.useSyncExternalStore)(ip.subscribe,ip.get,()=>!1),ip.toggle]}function op({steps:e,showReasoning:t,issueRepo:n}){let[r,i]=ap(),a=t?e:e.filter(e=>e.kind!==`reasoning`);if(!a.length)return null;let o=a.filter(e=>e.kind===`tool`).length;return(0,B.jsx)(`div`,{className:`flex justify-start mb-2`,children:(0,B.jsxs)(`div`,{className:`max-w-[85%] md:max-w-[75%] min-w-0 space-y-1.5`,children:[a.map(e=>e.kind===`narration`?(0,B.jsx)(sr,{text:e.text,issueRepo:n,className:`text-sm leading-relaxed break-words text-foreground/90 min-w-0`},e.id):e.kind===`reasoning`?(0,B.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground/80`,children:[(0,B.jsx)(ie,{className:`w-3.5 h-3.5 mt-0.5 shrink-0 opacity-70`}),(0,B.jsx)(sr,{text:e.text,issueRepo:n,className:`italic break-words min-w-0`})]},e.id):r?null:(0,B.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground`,children:[(0,B.jsx)(be,{className:`w-3 h-3 mt-0.5 shrink-0 opacity-70`}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.label||`tool`}),e.text&&e.text.trim()&&e.text.trim()!==(e.label??``).trim()?(0,B.jsxs)(`span`,{className:`opacity-70`,children:[` — `,e.text]}):null]})]},e.id)),o>0&&(0,B.jsxs)(`button`,{onClick:i,className:`flex items-center gap-1 text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors text-left`,children:[(0,B.jsx)(le,{className:k(`w-3 h-3 shrink-0 transition-transform`,!r&&`rotate-90`)}),(0,B.jsx)(`span`,{children:r?`show ${o} tool step${o===1?``:`s`}`:`hide tool steps`})]})]})})}function sp({entry:e}){let{event:t}=e,n=t.kind===`questions`,r=n?t.title:t.kind===`plan`?`Plan prompt`:`${t.toolName} permission`;return(0,B.jsx)(`div`,{className:`flex justify-center py-1.5`,children:(0,B.jsxs)(`div`,{className:`w-full max-w-2xl rounded-md border border-border bg-muted/20 px-3 py-2 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,B.jsx)(pt,{className:`h-3.5 w-3.5 text-emerald-500`}),(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),(0,B.jsx)(`span`,{children:t.decisionLabel}),(0,B.jsx)(`span`,{className:`ml-auto shrink-0 text-muted-foreground/60`,children:ff(t.timestamp)})]}),n&&t.questions.length>0?(0,B.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:t.questions.map((e,t)=>(0,B.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.question}),(0,B.jsx)(`div`,{className:`text-sm text-foreground`,children:e.answer})]},`${e.question}-${t}`))}):t.body.trim()?(0,B.jsx)(`div`,{className:`mt-2 max-h-48 overflow-auto rounded border border-border/70 bg-background/40 px-2 py-1.5 text-sm`,children:(0,B.jsx)(sr,{text:t.body})}):null]})})}function cp({date:e}){return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-3 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:zf(e)}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function lp({timestamp:e}){let t=new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`});return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`created `,t]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function up({history:e}){let t=e.sourceAgentLabel||e.sourcePeerId,n=e.entries.length;return(0,B.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-full border border-dashed border-border bg-muted/30 px-2 py-1 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(a,{className:`h-3 w-3`}),(0,B.jsxs)(`span`,{children:[`forked history from `,t]}),(0,B.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[n,` `,n===1?`entry`:`entries`]})]}),(0,B.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function dp({entry:e,sourceLabel:t,issueRepo:n}){let r=e.message,i=dn(r),a=e.originalFrom===bn;return(0,B.jsx)(`div`,{className:k(`flex mb-3 opacity-80`,a?`justify-end`:`justify-start`),children:(0,B.jsx)(`div`,{className:`max-w-[85%] md:max-w-[75%]`,children:(0,B.jsxs)(`div`,{className:k(`rounded-2xl border border-dashed px-3.5 py-2 text-sm select-text`,a?`border-primary/25 bg-primary/10 text-foreground rounded-br-sm`:`border-border bg-card/70 rounded-bl-sm`),children:[(0,B.jsxs)(`div`,{className:k(`mb-1 text-[10px] uppercase tracking-normal`,a?`text-primary/70`:`text-muted-foreground`),children:[`forked history · `,a?`you`:t||e.originalFrom]}),(0,B.jsx)(sr,{text:i,rawBody:r.body,issueRepo:n,className:`leading-relaxed`}),(0,B.jsxs)(`p`,{className:k(`mt-1 flex items-center justify-end gap-1.5 text-xs`,a?`text-primary/60`:`text-muted-foreground`),children:[(0,B.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.originalMessageId]}),(0,B.jsx)(`span`,{children:ff(e.originalCreatedAt)})]})]})})})}function fp({msg:e,issueRepo:t}){let n=dn(e),r=ff(e.occurredAt??e.createdAt);return(0,B.jsx)(`div`,{"data-msg-id":e.id,className:`mb-3`,children:(0,B.jsxs)(`div`,{className:`rounded-xl border border-primary/30 bg-primary/[0.06] px-3.5 py-2.5 shadow-sm`,children:[(0,B.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-primary/80`,children:[(0,B.jsx)(_t,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{children:`Initial prompt`}),(0,B.jsx)(`span`,{className:`ml-auto text-[10px] font-normal normal-case text-muted-foreground/60`,children:r})]}),(0,B.jsx)(sr,{text:n,rawBody:e.body,issueRepo:t,className:`text-sm leading-relaxed text-foreground`})]})})}function pp({scrollEl:e,timeline:t}){let[n,r]=(0,z.useState)(!0),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1),u=(0,z.useMemo)(()=>{for(let e=t.length-1;e>=0;e--){let n=t[e];if(!(!n||n.type!==`message`&&n.type!==`initial-prompt`)&&n.msg.from===`user`)return{id:n.msg.id,body:dn(n.msg)}}return null},[t]);if((0,z.useEffect)(()=>{if(!u||!e){r(!0);return}let t=null,n=null,i=()=>{let i=e.querySelector(`[data-msg-id="${u.id}"]`);if(!i){t?.disconnect(),t=null,n=null,r(!1);return}let a=i.getBoundingClientRect(),o=e.getBoundingClientRect();l(a.top<o.top),i!==n&&(t?.disconnect(),n=i,t=new IntersectionObserver(([e])=>{e&&r(e.isIntersecting)},{root:e,threshold:0}),t.observe(i))};return i(),e.addEventListener(`scroll`,i,{passive:!0}),()=>{t?.disconnect(),e.removeEventListener(`scroll`,i)}},[u?.id,e]),n||!u||!u.body.trim())return null;let d=i?.id===u.id?i.value:!1,f=o?.id===u.id?o.value:!1;function p(){!e||!u||e.querySelector(`[data-msg-id="${u.id}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`})}let m=c?`↑`:`↓`;return f?(0,B.jsx)(`div`,{className:`flex shrink-0 bg-card/45 border-b border-border`,children:(0,B.jsxs)(`button`,{type:`button`,className:`w-full flex items-center justify-center gap-1.5 py-1 text-[11px] text-primary/60 hover:text-primary transition-colors`,onClick:()=>s({id:u.id,value:!1}),children:[(0,B.jsx)(`span`,{children:`Your prompt`}),(0,B.jsx)(ht,{className:`w-3 h-3`})]})}):(0,B.jsxs)(`section`,{className:`flex shrink-0 flex-col border-b border-border bg-card/45 px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground mb-0.5`,children:[(0,B.jsx)(`span`,{className:`font-medium text-primary/70`,children:`Your prompt`}),(0,B.jsxs)(`button`,{type:`button`,className:`ml-auto hover:text-foreground transition-colors`,onClick:p,children:[m,` scroll to original`]}),(0,B.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors`,onClick:()=>s({id:u.id,value:!0}),title:`Minimize`,children:(0,B.jsx)(vt,{className:`w-3 h-3`})})]}),(0,B.jsx)(`p`,{className:k(`text-sm text-foreground leading-snug cursor-pointer`,!d&&`line-clamp-2`),onClick:()=>a({id:u.id,value:!d}),children:u.body})]})}var mp={none:`None`,uncommitted:`Uncommitted`,"committed-on-branch":`On Branch`,"landed-on-main":`Landed`,deploying:`Deploying`,deployed:`Deployed`},hp={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,claimed:`bg-purple-500/10 text-purple-300 border-purple-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,orphaned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,done:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,failed:`bg-red-500/10 text-red-400 border-red-500/20`,canceled:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`},gp={none:`bg-zinc-500/10 text-zinc-400`,uncommitted:`bg-yellow-500/10 text-yellow-400`,"committed-on-branch":`bg-blue-500/10 text-blue-400`,"landed-on-main":`bg-emerald-500/10 text-emerald-400`,deploying:`bg-purple-500/10 text-purple-400`,deployed:`bg-teal-500/10 text-teal-400`};function _p(e){let t=e.dispatch;return{title:e.title??``,intent:e.intent??``,latestSteer:e.latestSteer??``,doneWhen:e.doneWhen??``,teamId:e.teamId??``,dispatchComplexity:t?.complexity??``,dispatchType:t?.type??``,dispatchFootprint:t?.contextFootprint??``,dispatchCriticality:t?.criticality??``}}function vp(){let e=kt(),t=A(e=>e.taskDetailOpen),n=A(e=>e.taskDetailId),r=A(e=>e.taskDetailById),i=A(e=>e.taskMemoryById),a=A(e=>e.taskHistoryById),o=A(e=>e.taskDispatchResultById),s=A(e=>e.taskDispatchLoadingId),c=A(e=>e.providerCatalog),l=A(e=>e.closeTaskDetail),u=A(e=>e.doEditTask),d=A(e=>e.doDispatchTask),f=A(e=>e.doSpawnWithTask),p=c.map(e=>e.provider),[m,h]=(0,z.useState)(!1),[_,v]=(0,z.useState)(null),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)(``),[C,ee]=(0,z.useState)(``),w=n==null?null:r[n]??null,te=n==null?null:i[n]??null,T=n==null?[]:a[n]??[],re=n==null?null:o[n]??null,ie=n!=null&&s===n,ae=w?hp[w.status]??`bg-zinc-500/10 text-zinc-400`:``,oe=w?.deliverableStage?gp[w.deliverableStage]??`bg-zinc-500/10 text-zinc-400`:``;function E(e){e||(l(),h(!1),v(null))}function D(){w&&(v(_p(w)),h(!0))}function se(){h(!1),v(null)}async function ce(){if(!w||!_)return;let e={};_.dispatchComplexity&&(e.complexity=_.dispatchComplexity),_.dispatchType&&(e.type=_.dispatchType),_.dispatchFootprint&&(e.contextFootprint=_.dispatchFootprint),_.dispatchCriticality&&(e.criticality=_.dispatchCriticality);let t={..._.title===w.title?{}:{title:_.title},..._.intent===(w.intent??``)?{}:{intent:_.intent},..._.latestSteer===(w.latestSteer??``)?{}:{latestSteer:_.latestSteer},..._.doneWhen===(w.doneWhen??``)?{}:{doneWhen:_.doneWhen},..._.teamId===(w.teamId??``)?{}:{teamId:_.teamId},...Object.keys(e).length||w.dispatch?{dispatch:Object.keys(e).length?e:null}:{}};if(!Object.keys(t).length){se();return}await u(w.id,t),h(!1),v(null)}function le(){if(!w)return;let e={};y&&(e.provider=y),x&&(e.model=x),C&&(e.effort=C),d(w.id,Object.keys(e).length?e:void 0)}return(0,B.jsx)(Eu,{open:t,onOpenChange:E,children:(0,B.jsxs)(Au,{className:`w-full max-w-[100dvw] sm:max-w-lg lg:max-w-xl p-0 flex flex-col`,showCloseButton:!1,children:[(0,B.jsx)(ju,{className:`shrink-0 p-4 border-b border-border`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:w&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(F,{variant:`outline`,className:`text-xs border ${ae}`,children:w.status}),w.deliverableStage&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs ${oe}`,children:mp[w.deliverableStage]??w.deliverableStage}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`T`,w.id]})]})}),(0,B.jsx)(Mu,{className:`text-base leading-snug`,children:w?.title??`Task`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&!m&&(0,B.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:D,title:`Edit task`,children:(0,B.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(Du,{asChild:!0,children:(0,B.jsxs)(I,{size:`icon-sm`,variant:`ghost`,title:`Close`,children:[(0,B.jsx)(Se,{className:`w-4 h-4`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}),(0,B.jsx)(Kd,{className:`flex-1 min-h-0 overflow-x-hidden`,children:(0,B.jsxs)(`div`,{className:`p-4 space-y-5 min-w-0`,children:[!w&&(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:`Loading…`}),w&&m&&_&&(0,B.jsx)(yp,{form:_,onChange:e=>v(t=>t&&{...t,...e}),onSave:()=>void ce(),onCancel:se}),w&&!m&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Status`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Execution`}),(0,B.jsx)(F,{variant:`outline`,className:`text-xs border ${ae}`,children:w.status})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-0.5`,children:`Deliverable stage`}),(0,B.jsx)(F,{variant:`secondary`,className:`text-xs ${oe}`,children:mp[w.deliverableStage??`none`]??w.deliverableStage??`none`})]})]}),w.blockedBy&&w.blockedBy.length>0&&(0,B.jsx)(`div`,{className:`mt-2 space-y-1`,children:w.blockedBy.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-yellow-400 min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium capitalize shrink-0`,children:e.type}),e.ref&&(0,B.jsxs)(`span`,{className:`text-muted-foreground truncate min-w-0`,children:[`→ `,e.ref]}),e.note&&(0,B.jsx)(`span`,{className:`text-muted-foreground truncate min-w-0`,children:e.note})]},t))})]}),(0,B.jsx)(G,{}),(w.intent||w.doneWhen)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{className:`space-y-2`,children:[w.intent&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Intent`}),(0,B.jsx)(sr,{text:w.intent,className:`text-sm min-w-0 break-words [overflow-wrap:anywhere]`})]}),w.doneWhen&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:`Done when`}),(0,B.jsx)(sr,{text:w.doneWhen,className:`text-sm min-w-0 break-words [overflow-wrap:anywhere]`})]})]}),(0,B.jsx)(G,{})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Ownership`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[w.ownerAgentId&&(0,B.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Owner`}),(0,B.jsx)(Wf,{agentId:w.ownerAgentId,fallbackLabel:w.ownerAgentLabel,className:`min-w-0 text-sm`})]}),w.createdBy&&(0,B.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created by`}),(0,B.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,title:w.createdBy,children:w.createdBy})]}),w.teamId&&(0,B.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Team`}),(0,B.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere] font-mono text-xs`,title:w.teamId,children:w.teamId})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Created`}),(0,B.jsx)(`span`,{title:cn(w.createdAt),children:j(e,w.createdAt)})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-20`,children:`Updated`}),(0,B.jsx)(`span`,{title:cn(w.updatedAt),children:j(e,w.updatedAt)})]})]})]}),(w.dispatchWorkShape?.specified||w.dispatchDecision||w.boundWorkerModel)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(bp,{detail:w})]}),(w.branch||w.commits&&w.commits.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsxs)(`section`,{className:`min-w-0 overflow-hidden`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Code`}),w.branch&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm mb-1 min-w-0`,children:[(0,B.jsx)(ne,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,B.jsx)(`span`,{className:`font-mono text-xs min-w-0 break-words [overflow-wrap:anywhere]`,title:w.branch,children:w.branch})]}),w.commits?.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm ml-1 min-w-0`,children:[(0,B.jsx)(Ve,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,B.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:e.sha.slice(0,8)}),e.subject&&(0,B.jsx)(`span`,{className:`text-xs min-w-0 break-words [overflow-wrap:anywhere]`,children:e.subject})]},e.sha))]})]}),w.issues&&w.issues.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Cp,{issues:w.issues})]}),(w.dependsOn&&w.dependsOn.length>0||w.dependents&&w.dependents.length>0)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(wp,{dependsOn:w.dependsOn??[],dependents:w.dependents??[]})]}),w.gates&&w.gates.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Tp,{gates:w.gates,now:e})]}),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Sp,{taskId:w.id,taskStatus:w.status,pinProvider:y,pinModel:x,pinEffort:C,onPinProvider:b,onPinModel:S,onPinEffort:ee,onDispatch:le,onSpawn:e=>void f(w.id,e),loading:ie,result:re,providers:p})]}),te&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Ep,{memory:te,now:e})]}),T.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),(0,B.jsx)(Dp,{history:T,now:e})]})]})]})})]})})}function yp({form:e,onChange:t,onSave:n,onCancel:r}){return(0,B.jsxs)(`section`,{className:`space-y-4`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Edit Task fields`}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-title`,children:`Title`}),(0,B.jsx)(L,{id:`edit-title`,value:e.title,onChange:e=>t({title:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-intent`,children:`Intent`}),(0,B.jsx)(Yd,{id:`edit-intent`,value:e.intent,onChange:e=>t({intent:e.target.value}),rows:3})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-steer`,children:`Latest steer`}),(0,B.jsx)(Yd,{id:`edit-steer`,value:e.latestSteer,onChange:e=>t({latestSteer:e.target.value}),rows:2,placeholder:`Redirect or re-scope in-flight work`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-done-when`,children:`Done when`}),(0,B.jsx)(Yd,{id:`edit-done-when`,value:e.doneWhen,onChange:e=>t({doneWhen:e.target.value}),rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`edit-team`,children:`Team ID`}),(0,B.jsx)(L,{id:`edit-team`,value:e.teamId,onChange:e=>t({teamId:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-complexity`,className:`text-xs`,children:`Complexity`}),(0,B.jsxs)(`select`,{id:`edit-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchComplexity,onChange:e=>t({dispatchComplexity:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),It.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-type`,className:`text-xs`,children:`Type`}),(0,B.jsxs)(`select`,{id:`edit-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchType,onChange:e=>t({dispatchType:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),jt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-footprint`,className:`text-xs`,children:`Context footprint`}),(0,B.jsxs)(`select`,{id:`edit-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchFootprint,onChange:e=>t({dispatchFootprint:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ft.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`edit-criticality`,className:`text-xs`,children:`Criticality`}),(0,B.jsxs)(`select`,{id:`edit-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:e.dispatchCriticality,onChange:e=>t({dispatchCriticality:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Rt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,B.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,B.jsx)(I,{size:`sm`,onClick:n,children:`Save`}),(0,B.jsx)(I,{size:`sm`,variant:`outline`,onClick:r,children:`Cancel`})]})]})}function bp({detail:e}){let t=e.dispatchWorkShape,n=e.dispatchDecision,r=e.boundWorkerModel;return(0,B.jsxs)(`section`,{className:`space-y-3`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch`}),t&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Work shape`}),t.specified?(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.complexity&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.complexity}),t.type&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.type}),t.contextFootprint&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.contextFootprint}),t.criticality&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs`,children:t.criticality})]}):(0,B.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:`Not specified`})]}),n&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Decision`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[n.target.provider&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:n.target.provider}),n.target.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:n.target.model}),n.target.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:n.target.effort}),n.pinned&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),n.rationale&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.rationale}),n.warnings?.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400 mt-0.5`,children:[(0,B.jsx)(Pe,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,B.jsx)(`span`,{children:e})]},t))]}),r&&(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Bound worker`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:[r.provider&&(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:r.provider}),r.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:r.model}),r.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:r.effort})]}),(0,B.jsx)(Wf,{agentId:r.agentId,fallbackLabel:e.ownerAgentLabel,className:`text-xs text-muted-foreground`})]})]})}var xp=new Set([`done`,`canceled`,`failed`]);function Sp({taskId:e,taskStatus:t,pinProvider:n,pinModel:r,pinEffort:i,onPinProvider:a,onPinModel:o,onPinEffort:s,onDispatch:c,onSpawn:l,loading:u,result:d,providers:f}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3`,children:`Spawn with task`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mb-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-provider-${e}`,className:`text-xs`,children:`Provider pin`}),(0,B.jsxs)(`select`,{id:`spawn-provider-${e}`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs`,value:n,onChange:e=>a(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`auto`}),f.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-model-${e}`,className:`text-xs`,children:`Model pin`}),(0,B.jsx)(L,{id:`spawn-model-${e}`,className:`mt-1 h-8 text-xs`,value:r,onChange:e=>o(e.target.value),placeholder:`auto`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`spawn-effort-${e}`,className:`text-xs`,children:`Effort pin`}),(0,B.jsx)(L,{id:`spawn-effort-${e}`,className:`mt-1 h-8 text-xs`,value:i,onChange:e=>s(e.target.value),placeholder:`auto`})]})]}),(0,B.jsxs)(I,{size:`sm`,onClick:c,disabled:u||xp.has(t),className:`gap-1.5`,children:[(0,B.jsx)(Re,{className:`w-3.5 h-3.5`}),u?`Planning…`:`Plan dispatch`]}),d&&(0,B.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/20 p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(Re,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,B.jsx)(F,{variant:`secondary`,className:`text-xs font-mono`,children:d.decision.target.provider}),d.decision.target.model&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs font-mono`,children:d.decision.target.model}),d.decision.target.effort&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs`,children:d.decision.target.effort}),d.decision.pinned&&(0,B.jsx)(F,{variant:`outline`,className:`text-xs text-yellow-400 border-yellow-500/30`,children:`pinned`})]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d.decision.rationale}),d.decision.factors.band&&(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Band: `,d.decision.factors.band,d.decision.factors.contextWindowTokens?` · ${(d.decision.factors.contextWindowTokens/1e3).toFixed(0)}k ctx`:``]}),d.decision.warnings.length>0&&(0,B.jsx)(`div`,{className:`space-y-0.5`,children:d.decision.warnings.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-start gap-1 text-xs text-yellow-400`,children:[(0,B.jsx)(Pe,{className:`w-3 h-3 shrink-0 mt-0.5`}),(0,B.jsx)(`span`,{children:e})]},t))}),d.decision.review&&(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Auto-review: `,d.decision.review.reason,` → `,d.decision.review.target.provider,`/`,d.decision.review.target.model??`default`,d.reviewTaskId&&(0,B.jsxs)(`span`,{className:`ml-1`,children:[`(task T`,d.reviewTaskId,`)`]})]})]})]}),(0,B.jsx)(`div`,{className:`pt-1 border-t border-border/50`,children:(0,B.jsxs)(I,{size:`sm`,className:`gap-1.5 w-full`,onClick:()=>l(d.decision.target),children:[(0,B.jsx)(Re,{className:`w-3.5 h-3.5`}),`Spawn worker with task T`,e]})})]})]})}function Cp({issues:e}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Linked Issues`}),(0,B.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:[e.provider,`/`,e.externalKey]}),e.title&&(0,B.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.title}),(0,B.jsx)(F,{variant:`secondary`,className:`text-xs shrink-0`,children:e.status}),e.url&&(0,B.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,B.jsx)(_e,{className:`w-3.5 h-3.5`})})]},e.issueRefId))})]})}function wp({dependsOn:e,dependents:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Dependencies`}),(0,B.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[e.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Depends on: `}),e.map((t,n)=>(0,B.jsxs)(`span`,{className:`font-mono text-xs`,children:[`T`,t,n<e.length-1?`, `:``]},t))]}),t.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Blocks: `}),t.map((e,n)=>(0,B.jsxs)(`span`,{className:`font-mono text-xs`,children:[`T`,e,n<t.length-1?`, `:``]},e))]})]})]})}function Tp({gates:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Gate Ledger`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:[...e].sort((e,t)=>t.ranAt-e.ranAt).map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`pass`?(0,B.jsx)(pt,{className:`w-4 h-4 text-emerald-400 shrink-0 mt-0.5`}):(0,B.jsx)(ke,{className:`w-4 h-4 text-red-400 shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-mono text-xs font-medium truncate min-w-0`,children:e.gate}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto shrink-0`,title:cn(e.ranAt),children:j(t,e.ranAt)})]}),e.detail&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.detail}),e.commitSha&&(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.commitSha.slice(0,8)})]})]},e.gate+e.ranAt))})]})}function Ep({memory:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Task Memory`}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[e.workingState&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Working state`}),(0,B.jsx)(`p`,{className:`text-xs whitespace-pre-wrap [overflow-wrap:anywhere] bg-muted/30 rounded p-2`,children:e.workingState})]}),e.ledger.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Ruled out (`,e.ledger.length,`)`]}),(0,B.jsx)(`div`,{className:`space-y-1`,children:e.ledger.map((e,t)=>(0,B.jsxs)(`div`,{className:`text-xs bg-muted/20 rounded p-1.5`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.ruledOut}),e.why&&(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[` — `,e.why]})]},t))})]}),e.decisions.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:[`Decisions (`,e.decisions.length,`)`]}),(0,B.jsx)(`div`,{className:`space-y-1.5`,children:e.decisions.map((e,n)=>(0,B.jsxs)(`div`,{className:`text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium truncate min-w-0`,children:e.decision}),(0,B.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0`,title:cn(e.at),children:j(t,e.at)})]}),e.rationale&&(0,B.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.rationale}),e.by&&(0,B.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`by `,e.by]})]},n))})]})]})]})}function Dp({history:e,now:t}){return(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`History`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:[...e].reverse().slice(0,30).map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,B.jsx)(Te,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-muted-foreground shrink-0`,children:e.type}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground shrink-0`,title:cn(e.createdAt),children:j(t,e.createdAt)})]}),e.title&&e.title!==e.type&&(0,B.jsx)(`p`,{className:`text-foreground mt-0.5 truncate`,children:e.title})]})]},e.id))})]})}var Op=!1;function kp(e,t){let n=z.useRef(!1),r=z.useRef(t);r.current=t,z.useEffect(()=>{if(!e||!r.current)return;Op=!1,window.history.pushState({dialogGuard:!0},``),n.current=!0;function t(){if(Op){Op=!1;return}n.current&&(n.current=!1,r.current?.(!1))}return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),n.current&&(n.current=!1,Op=!0,window.history.back())}},[e])}function Ap({...e}){return kp(e.open,e.onOpenChange),(0,B.jsx)(ri,{"data-slot":`dialog`,...e})}function jp({...e}){return(0,B.jsx)(ii,{"data-slot":`dialog-portal`,...e})}function Mp({className:e,blur:t=!0,...n}){return(0,B.jsx)(ai,{"data-slot":`dialog-overlay`,className:k(`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 Np({className:e,children:t,showCloseButton:n=!0,blurOverlay:r=!0,...i}){return(0,B.jsxs)(jp,{children:[(0,B.jsx)(Mp,{blur:r}),(0,B.jsxs)(oi,{"data-slot":`dialog-content`,className:k(`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)(li,{"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)(Se,{}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function Pp({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`dialog-header`,className:k(`flex flex-col gap-2`,e),...t})}function Fp({className:e,showCloseButton:t=!1,children:n,...r}){return(0,B.jsxs)(`div`,{"data-slot":`dialog-footer`,className:k(`-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)(li,{asChild:!0,children:(0,B.jsx)(I,{variant:`outline`,children:`Close`})})]})}function Ip({className:e,...t}){return(0,B.jsx)(si,{"data-slot":`dialog-title`,className:k(`font-heading text-base leading-none font-medium`,e),...t})}function Lp({className:e,...t}){return(0,B.jsx)(ci,{"data-slot":`dialog-description`,className:k(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Rp(){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=Cl();function s(){r({composeOpen:!1}),a()}function c(e){r({compose:{...t,...e}})}return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&s(),children:(0,B.jsxs)(Np,{className:`max-w-lg`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Yd,{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)(kl,{checked:t.claimable,onCheckedChange:e=>c({claimable:e})}),(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Claimable task`})]})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:s,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}function zp(){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)(Ap,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(Pp,{children:[(0,B.jsx)(Ip,{children:e.title}),(0,B.jsx)(Lp,{children:e.message})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{variant:`destructive`,onClick:()=>{e.action?.(),n()},children:`Confirm`})]})]})})}function Bp(){let e=A(e=>e.errorModal),t=A(e=>e.set);function n(){t({errorModal:{show:!1,title:``,message:``}})}return(0,B.jsx)(Ap,{open:e.show,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(Pp,{children:[(0,B.jsx)(Ip,{children:e.title}),(0,B.jsx)(Lp,{children:e.message})]}),(0,B.jsx)(Fp,{children:(0,B.jsx)(I,{onClick:n,children:`OK`})})]})})}function Vp(){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)(Ap,{open:e.show,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:n,children:`Save`})]})]})})}function Hp(){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=Cl();function o(e){n({pairInvite:{...t,...e}})}return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Create Pair`})]})]})})}function Up(){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)(Ap,{open:e,onOpenChange:e=>!e&&r(),children:(0,B.jsxs)(Np,{className:`sm:max-w-sm`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Yd,{value:t.body,onChange:e=>a({body:e.target.value}),rows:4,placeholder:`Message body...`,autoFocus:!0})]})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:r,children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:`Send`})]})]})})}function Wp(){let e=A(e=>e.threadOpen),t=A(e=>e.threadMessages),n=A(e=>e.agentsById),r=kt(),i=A(e=>e.set);return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&i({threadOpen:!1}),children:(0,B.jsxs)(Np,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{children:[`Thread (`,t.length,` messages)`]})}),(0,B.jsx)(Kd,{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:sn(e.from,n)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:sn(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)(sr,{text:dn(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 `,sn(e.claimedBy,n)]})]})]},e.id))})})]})})}function Gp(){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)(Ap,{open:e,onOpenChange:e=>!e&&n({taskEventsOpen:!1}),children:(0,B.jsxs)(Np,{className:`max-w-2xl max-h-[80vh]`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{children:[`Task Events (`,t.length,`)`]})}),(0,B.jsx)(Kd,{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:on[e.severity]||on.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)(Kp,{event:e,onOpen:i}),(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[cn(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 Kp({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)(oe,{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 qp(){let e=A(e=>e.taskCreateOpen),t=A(e=>e.taskCreateForm),n=A(e=>e.closeTaskCreate),r=A(e=>e.setTaskCreateForm),i=A(e=>e.doCreateTask);return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(Np,{className:`max-w-lg`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{children:`New Task`})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-title`,children:[`Title `,(0,B.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,B.jsx)(L,{id:`task-title`,value:t.title,onChange:e=>r({title:e.target.value}),placeholder:`Short description of the work`,autoFocus:!0})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`task-intent`,children:`Intent`}),(0,B.jsx)(Yd,{id:`task-intent`,value:t.intent,onChange:e=>r({intent:e.target.value}),placeholder:`What is this task trying to accomplish?`,rows:3})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{htmlFor:`task-done-when`,children:`Done when`}),(0,B.jsx)(Yd,{id:`task-done-when`,value:t.doneWhen,onChange:e=>r({doneWhen:e.target.value}),placeholder:`Acceptance criteria`,rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-issue-refs`,children:[`Issue refs `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated, e.g. owner/repo#123)`})]}),(0,B.jsx)(L,{id:`task-issue-refs`,value:t.issueRefs,onChange:e=>r({issueRefs:e.target.value}),placeholder:`owner/repo#123, owner/repo#456`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)($,{htmlFor:`task-depends-on`,children:[`Depends on `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(comma-separated task IDs)`})]}),(0,B.jsx)(L,{id:`task-depends-on`,value:t.dependsOn,onChange:e=>r({dependsOn:e.target.value}),placeholder:`42, 43`})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)($,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Dispatch work-shape (optional)`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-complexity`,className:`text-xs`,children:`Complexity`}),(0,B.jsxs)(`select`,{id:`dispatch-complexity`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchComplexity,onChange:e=>r({dispatchComplexity:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),It.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-type`,className:`text-xs`,children:`Type`}),(0,B.jsxs)(`select`,{id:`dispatch-type`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchType,onChange:e=>r({dispatchType:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),jt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-footprint`,className:`text-xs`,children:`Context footprint`}),(0,B.jsxs)(`select`,{id:`dispatch-footprint`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchFootprint,onChange:e=>r({dispatchFootprint:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Ft.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{htmlFor:`dispatch-criticality`,className:`text-xs`,children:`Criticality`}),(0,B.jsxs)(`select`,{id:`dispatch-criticality`,className:`w-full mt-1 rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:t.dispatchCriticality,onChange:e=>r({dispatchCriticality:e.target.value}),children:[(0,B.jsx)(`option`,{value:``,children:`—`}),Rt.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]})]})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:n,children:`Cancel`}),(0,B.jsx)(I,{onClick:()=>void i(),disabled:!t.title.trim(),children:`Create`})]})]})})}function Jp({open:e,onOpenChange:t,onSelect:n,orchestratorId:r,initialPath:i,title:a=`Select Directory`}){let o=A(e=>e.apiCall),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(!1),[g,_]=(0,z.useState)(``),[v,y]=(0,z.useState)(null),b=l?.path||i||``,x=(0,z.useMemo)(()=>b.split(`/`).filter(Boolean),[b]),S=(0,z.useCallback)(async e=>{if(r){c(!0),f(null),m(!1);try{let t=e?`?path=${encodeURIComponent(e)}`:``;u(await o(`GET`,`/orchestrators/${encodeURIComponent(r)}/directories${t}`))}catch(e){f(zt(e))}finally{c(!1)}}},[r,o]);(0,z.useEffect)(()=>{e&&r&&(u(null),f(null),m(!1),S(i||void 0))},[e,r]);async function C(){if(!(!g.trim()||!l)){y(null);try{u(await o(`POST`,`/orchestrators/${encodeURIComponent(r)}/directories`,{path:l.path,name:g.trim()})),m(!1),_(``)}catch(e){y(zt(e))}}}function ee(){b&&(n(b),t(!1))}function w(e){S(`/`+x.slice(0,e+1).join(`/`))}return(0,B.jsx)(Ap,{open:e,onOpenChange:t,children:(0,B.jsxs)(Np,{className:`max-w-lg max-h-[85dvh] flex flex-col`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ce,{className:`h-4 w-4`}),a]})}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-muted/50 px-2 py-1.5 text-xs overflow-x-auto`,children:[(0,B.jsx)(`button`,{type:`button`,className:`font-mono text-muted-foreground hover:text-foreground shrink-0`,onClick:()=>l?.baseDir&&S(l.baseDir),children:`/`}),x.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:()=>w(t),children:e}),t<x.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)(Qe,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!s&&d&&(0,B.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:d}),!s&&l&&(0,B.jsxs)(`div`,{className:`p-1`,children:[l.parent&&(0,B.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>S(l.parent),children:[(0,B.jsx)(nt,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`..`})]}),l.entries.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>S(e.path),children:[(0,B.jsx)(h,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),l.entries.length===0&&!l.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`Empty directory`}),l.entries.length===0&&l.parent&&(0,B.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground text-center`,children:`No subdirectories`})]})]}),p?(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(L,{autoFocus:!0,value:g,onChange:e=>{_(e.target.value),y(null)},onKeyDown:e=>{e.key===`Enter`&&C(),e.key===`Escape`&&(m(!1),_(``))},placeholder:`New directory name...`,className:`flex-1 font-mono text-sm`}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`outline`,onClick:C,disabled:!g.trim(),children:(0,B.jsx)(de,{className:`h-4 w-4`})}),(0,B.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>{m(!1),_(``),y(null)},children:(0,B.jsx)(Se,{className:`h-4 w-4`})})]}):(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(!0),disabled:!l||s,children:[(0,B.jsx)(te,{className:`h-4 w-4 mr-1.5`}),`New Directory`]}),v&&(0,B.jsx)(`p`,{className:`text-xs text-destructive`,children:v}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,B.jsx)(I,{onClick:ee,disabled:!b,children:`Select`})]})]})})}function Yp({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)(ce,{className:`h-4 w-4`})}),n&&(0,B.jsx)(Jp,{open:a,onOpenChange:o,onSelect:t,orchestratorId:n,initialPath:e||void 0})]})}function Xp({model:e}){if(!e)return null;let t=Zp(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 Zp(e){let t=[],n=e.limits?.contextWindowTokens?.value;return n&&t.push({label:Qp(n),Icon:x}),e.capabilities?.modalities.input.image&&t.push({label:`Image input`,Icon:p}),(e.capabilities?.modalities.output.image||e.capabilities?.tools?.imageGeneration)&&t.push({label:`Image output`,Icon:p}),e.capabilities?.tools?.code&&t.push({label:`Code`,Icon:at}),t}function Qp(e){return e>=1e6?`${e/1e6}M ctx`:e>=1e3?`${Math.round(e/1e3)}K ctx`:`${e} ctx`}function $p(){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=Tt(r,x),w=ee.find(e=>e.alias===i),te=w?.efforts||[],T=!!(S&&C.length>0&&s.trim())&&!h,ne=t.filter(e=>e.status===`online`),re=ne.length>1,ie=m.filter(e=>ne.some(t=>t.id===e.orchId)).slice(0,5);function ae(e){let n=t.find(t=>t.id===e),r=n?.providers[0]||``;_({spawnOrchId:e,spawnProvider:r,spawnModel:r?Dt(r,x):``,spawnEffort:``,spawnCwd:n?.baseDir||``})}function oe(e){_({spawnProvider:e,spawnModel:Dt(e,x),spawnEffort:``})}function E(e){_({spawnModel:e,spawnEffort:``})}return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&_({orchestratorSpawnOpen:!1}),children:(0,B.jsxs)(Np,{className:`max-w-lg max-h-[90dvh] flex flex-col`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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=>ae(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=>oe(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=>E(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:!te.length,children:[(0,B.jsx)(`option`,{value:``,children:`Default`}),te.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,B.jsx)(Xp,{model:w}),(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)(Yp,{value:s,onChange:e=>_({spawnCwd:e}),orchestratorId:n,placeholder:`Select a project directory`})}),ie.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:ie.map(e=>{let t=e.cwd.replace(/\/+$/,``).split(`/`).pop()||e.cwd,r=ne.find(t=>t.id===e.orchId)?.hostname,i=e.orchId===n&&e.cwd===s;return(0,B.jsx)(`button`,{type:`button`,title:re&&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:re&&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)(Yd,{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)(Yd,{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)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>_({orchestratorSpawnOpen:!1}),disabled:h,children:`Cancel`}),(0,B.jsx)(I,{onClick:v,disabled:!T,children:h?`Spawning…`:C.length?p>1?`Spawn ${p}`:`Spawn`:`No providers`})]})]})})}function em(){return`host-${Math.random().toString(36).slice(2,8)}`}function tm(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function nm(){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(O()).origin,[]),[a,o]=(0,z.useState)(em),[s,c]=(0,z.useState)(`$HOME/projects`),[u,d]=(0,z.useState)(Lt()),[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 rt(`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)(Ap,{open:e,onOpenChange:e=>!e&&t({orchestratorInstallOpen:!1}),children:(0,B.jsxs)(Np,{className:`max-w-2xl overflow-hidden`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{className:`flex items-center gap-2`,children:[(0,B.jsx)(l,{className:`w-4 h-4`}),`Add Orchestrator`]})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Orchestrator ID`}),(0,B.jsx)(L,{value:a,onChange:e=>o(e.target.value)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Relay URL`}),(0,B.jsx)(L,{value:i,readOnly:!0})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Base Directory`}),(0,B.jsx)(L,{value:s,onChange:e=>c(e.target.value)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`API Port`}),(0,B.jsx)(L,{value:f,onChange:e=>p(e.target.value),inputMode:`numeric`})]})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Providers`}),(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:Lt().map(e=>(0,B.jsx)(I,{type:`button`,size:`sm`,variant:u.includes(e)?`default`:`outline`,onClick:()=>d(tm(u,e)),children:Pt(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)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>t({orchestratorInstallOpen:!1}),children:`Close`}),g&&(0,B.jsx)(rr,{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)(be,{className:`w-3.5 h-3.5`}),b?`Generating...`:`Generate Command`]})]})]})})}function rm(){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=Tt(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:Dt(r,a),effort:``})}function h(e){p({provider:e,rig:``,model:Dt(e,a),effort:``})}return(0,B.jsx)(Ap,{open:e.open,onOpenChange:e=>!e&&p({open:!1}),children:(0,B.jsxs)(Np,{className:`max-w-lg max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(Pp,{children:(0,B.jsx)(Ip,{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)(Xp,{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)(Yp,{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)(Yd,{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)(kl,{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)(kl,{id:`dailyRestart`,checked:e.scheduledDailyRestart,onCheckedChange:e=>p({scheduledDailyRestart:e})})]})]}),(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:()=>p({open:!1}),children:`Cancel`}),(0,B.jsx)(I,{onClick:i,children:d?`Save`:`Create`})]})]})})}function im({children:e}){return(0,B.jsxs)(dl,{children:[(0,B.jsx)(fl,{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)(gt,{className:`h-3 w-3`})})}),(0,B.jsx)(pl,{className:`max-w-xs leading-relaxed`,children:e})]})}function am({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)(im,{children:t})]})}var om=[{value:``,label:`Off`},{value:`all`,label:`All`}],sm=[{value:``,label:`Off`},{value:`all`,label:`All safe settings`}],cm=[{value:``,label:`Instance default`},{value:`direct`,label:`Direct`},{value:`pr`,label:`Pull request`}],lm=[{value:`any`,label:`Any provider`},...Lt().map(e=>({value:e,label:Pt(e)}))],um={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 dm(e){return e?e.policy??`all`:``}function fm(e){if(e)return e===`all`?{policy:`all`}:{}}function pm({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 mm(e,t){return`${e.source}:${e.provider??`any`}:${e.ref}:${t}`}function hm({source:e}){return(0,B.jsx)(F,{variant:`outline`,className:`text-[10px] ${um[e]}`,children:e})}function gm({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)(``),[w,te]=(0,z.useState)(`any`);async function T(e){if(b(e),!p){g(!0),v(null);try{f((await rt(`GET`,`/provisioning/capabilities`)).capabilities),m(!0)}catch(e){v(zt(e))}finally{g(!1)}}}function ne(n){let a=C.trim();if(!a)return;let o={source:x,ref:a,enabled:!0,...w===`any`?{}:{provider:w}};n===`skill`?r([...e,o]):i([...t,o]),ee(``),b(null)}function re(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 ie(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 ae(t,n){r(e.map((e,r)=>r===t?{...e,...n}:e))}function oe(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 D=d.filter(e=>e.capability.kind===`skill`),se=d.filter(e=>e.capability.kind===`plugin`),ce=d.filter(e=>e.capability.kind===`mcp`);return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(_m,{projectMcp:o,projectSkills:s,projectSettings:c,sharedMcp:l}),(0,B.jsx)(ym,{title:`Skills from registry`,kind:`skill`,refs:e,readOnly:u,adding:y===`skill`,caps:D,loading:h,fetchError:_,empty:`No skills assigned`,manualRef:C,manualSource:x,manualProvider:w,onAddClick:()=>void T(`skill`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:te,onAddManual:()=>ne(`skill`),onAddRelay:e=>re(`skill`,e),onUpdate:ae,onRemove:t=>r(e.filter((e,n)=>n!==t))}),(0,B.jsx)(ym,{title:`Plugins from registry`,kind:`plugin`,refs:t,readOnly:u,adding:y===`plugin`,caps:se,loading:h,fetchError:_,empty:`No plugins assigned`,manualRef:C,manualSource:x,manualProvider:w,onAddClick:()=>void T(`plugin`),onCancel:()=>b(null),onManualRef:ee,onManualSource:S,onManualProvider:te,onAddManual:()=>ne(`plugin`),onAddRelay:e=>re(`plugin`,e),onUpdate:oe,onRemove:e=>i(t.filter((t,n)=>n!==e))}),(0,B.jsx)(Sm,{mcpKeys:Object.keys(n.servers??{}),caps:ce,adding:y===`mcp`,loading:h,fetchError:_,readOnly:u,onAddClick:()=>void T(`mcp`),onAddMcp:ie,onCancel:()=>b(null),onRemove:E})]})}function _m(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)(im,{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: `,dm(e.projectMcp)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSkills?`default`:`outline`,className:`text-[10px]`,children:[`project skills: `,dm(e.projectSkills)||`off`]}),(0,B.jsxs)(F,{variant:e.projectSettings?`default`:`outline`,className:`text-[10px]`,children:[`project settings: `,dm(e.projectSettings)||`off`]}),(0,B.jsxs)(F,{variant:e.sharedMcp?`default`:`outline`,className:`text-[10px]`,children:[`shared MCP: `,dm(e.sharedMcp)||`off`]})]})]})}function vm(e){return[...new Set(e.variants.map(e=>e.sourceType||`relay`))].join(`, `)}function ym(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)(me,{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)(hm,{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)(kl,{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)(je,{className:`h-3 w-3`})})]},mm(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:[`(`,vm(t),`)`]})]},t.capability.id))}),(0,B.jsx)(bm,{}),(0,B.jsx)(xm,{...e}),(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`mt-1 h-6 text-xs`,onClick:e.onCancel,children:`Cancel`})]})]})}function bm(){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 xm(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)(pm,{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)(pm,{value:e.manualProvider,onChange:t=>e.onManualProvider(t),options:lm})]}),(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 Sm(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)(me,{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)(hm,{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)(je,{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:[`(`,vm(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 Cm(e){let t=Lt();return e&&e!==`any`&&t.includes(e)?e:t[0]??``}function wm({profile:e}){let[t,n]=(0,z.useState)(()=>Cm(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 rt(`GET`,`/agent-profiles/${encodeURIComponent(e.name)}/resolved?provider=${encodeURIComponent(r)}`);n(t.provider),i(t.profile.provisioning??{skills:[],plugins:[],mcpServers:{}})}catch(e){c(zt(e)),i(null)}finally{o(!1)}}}let u=e.relay.tools?.groups??[],d=u.length?`custom: ${u.join(`, `)}`:`full access (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)(pm,{value:t,onChange:e=>{n(e),l(e)},options:Lt().map(e=>({value:e,label:Pt(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)(Tm,{title:`Skills`,values:r.skills.map(e=>e.name),empty:`No resolved skills`}),(0,B.jsx)(Tm,{title:`Plugins`,values:r.plugins.map(e=>e.name),empty:`No resolved plugins`}),(0,B.jsx)(Tm,{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 Tm({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 Em({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)(ht,{className:`h-3.5 w-3.5`}):(0,B.jsx)(le,{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 Dm({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 Om({env:e,onChange:t,disabled:n}){let r=Object.entries(e),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(``);function c(){i.trim()&&(t({...e,[i.trim()]:o}),a(``),s(``))}function l(n){let r={...e};delete r[n],t(r)}return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[r.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsxs)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 text-xs`,children:[e,`=`,t]}),!n&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>l(e),children:(0,B.jsx)(je,{className:`h-3 w-3`})})]},e)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:i,onChange:e=>a(e.target.value),placeholder:`KEY`,className:`flex-1 text-xs font-mono`}),(0,B.jsx)(L,{value:o,onChange:e=>s(e.target.value),placeholder:`value`,className:`flex-1 text-xs font-mono`,onKeyDown:e=>e.key===`Enter`&&c()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:c,children:(0,B.jsx)(me,{className:`h-3 w-3`})})]}),r.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})}var km=[{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)`}],Am=[{value:`any`,label:`Any provider`},...Lt().map(e=>({value:e,label:Pt(e)}))],jm=[{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`}],Mm=[{value:`host`,label:`Host — full filesystem`},{value:`workspace`,label:`Workspace — working directory tree`},{value:`repo`,label:`Repo — repository root only`}],Nm=[{value:`allow`,label:`Allow`},{value:`ignore`,label:`Ignore`}],Pm=[{value:``,label:`Default`},{value:`open`,label:`Open — allow all`},{value:`guarded`,label:`Guarded — prompt for risky`},{value:`read-only`,label:`Read-only`}],Fm={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).`},Im={context:`Context`,skills:`Skills`,plugins:`Plugins`,statusLine:`Status Line`,mcp:`MCP Tools`};function Lm({values:e,onChange:t,disabled:n,placeholder:r}){let[i,a]=(0,z.useState)(``);function o(){let n=i.trim();n&&(t([...e,n]),a(``))}function s(n,r){t(e.map((e,t)=>t===n?r:e))}function c(n){t(e.filter((e,t)=>t!==n))}return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[e.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:e,onChange:e=>s(t,e.target.value),disabled:n,className:`flex-1 text-xs`}),!n&&(0,B.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 shrink-0`,onClick:()=>c(t),children:(0,B.jsx)(je,{className:`h-3 w-3`})})]},`${e}-${t}`)),!n&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(L,{value:i,onChange:e=>a(e.target.value),placeholder:r,className:`flex-1 text-xs`,onKeyDown:e=>e.key===`Enter`&&o()}),(0,B.jsx)(I,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-8 w-8 shrink-0`,onClick:o,children:(0,B.jsx)(me,{className:`h-3 w-3`})})]}),e.length===0&&n&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`None`})]})}function Rm(){let{open:e,mode:t,profile:n,relayToolsMode:r}=A(e=>e.profileModal),i=A(e=>e.closeProfileModal),a=A(e=>e.updateProfileModal),o=A(e=>e.setRelayToolsMode),s=A(e=>e.toolGroupCatalog),c=A(e=>e.toolGroupCatalogStatus),l=A(e=>e.fetchToolGroupCatalog),u=A(e=>e.saveProfile),d=t===`view`,f=t===`create`||t===`duplicate`,p=t===`view`?`Profile: ${n.name}`:t===`edit`?`Edit: ${n.name}`:t===`duplicate`?`Duplicate Profile`:`Create Profile`;function m(e){a({instructions:{...n.instructions,...e}})}function h(e){a({relay:{...n.relay,...e}})}function g(e,t){let r=n.relay.tools?.groups??[],i=t?[...new Set([...r,e])]:r.filter(t=>t!==e);h({tools:i.length?{groups:i}:void 0})}let _=n.relay.tools?.groups??[],v=s.reduce((e,t)=>e+t.tools.length,0),y=c.loading||!c.loaded&&s.length===0,b=!y&&(!!c.error||s.length===0);function x(e){a({projectMcp:fm(e)})}function S(e){a({projectSkills:fm(e)})}function C(e){a({projectSettings:fm(e)})}function w(e){a({sharedMcp:fm(e)})}function te(e){a({permissions:{...n.permissions,...e}})}function T(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}a({providerOptions:{...t,codex:r}})}function ne(e){if(!e.trim()){a({maxSpawnedAgents:void 0});return}let t=Number(e);!Number.isInteger(t)||t<0||a({maxSpawnedAgents:Math.min(t,100)})}function re(e){let t=e===`host`;a({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 ie=n.providerOptions?.codex&&typeof n.providerOptions.codex==`object`&&!Array.isArray(n.providerOptions.codex)?n.providerOptions.codex:{},ae=Number.isSafeInteger(ie.toolOutputTokenLimit)?String(ie.toolOutputTokenLimit):``;return(0,B.jsx)(Ap,{open:e,onOpenChange:e=>!e&&i(),children:(0,B.jsxs)(Np,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,B.jsx)(Pp,{children:(0,B.jsxs)(Ip,{className:`flex items-center gap-2`,children:[p,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)(Em,{title:`General`,defaultOpen:!0,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Name`}),(0,B.jsx)(L,{value:n.name,onChange:e=>a({name:e.target.value}),placeholder:`my-profile`,disabled:d||t===`edit`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Description`}),(0,B.jsx)(L,{value:n.description||``,onChange:e=>a({description:e.target.value}),placeholder:`What this profile configures`,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{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=>a({icon:e.target.value}),placeholder:`🤖`,maxLength:8,disabled:d,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)(Dm,{value:n.base,onChange:e=>re(e),options:km,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Provider`}),(0,B.jsx)(Dm,{value:n.provider||`any`,onChange:e=>a({provider:e}),options:Am,disabled:d})]})]})]}),(0,B.jsxs)(Em,{title:`Instructions`,defaultOpen:!1,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`System Prompt`}),(0,B.jsx)(Yd,{value:n.instructions.system||``,onChange:e=>m({system:e.target.value}),placeholder:`Custom system prompt...`,rows:3,disabled:d,className:`font-mono text-xs`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Append Instructions`}),(0,B.jsx)(Lm,{values:n.instructions.append??[],onChange:e=>m({append:e}),disabled:d,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)(Dm,{value:n.instructions.repoInstructions,onChange:e=>m({repoInstructions:e}),options:Nm,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Global Instructions`}),(0,B.jsx)(Dm,{value:n.instructions.globalInstructions,onChange:e=>m({globalInstructions:e}),options:Nm,disabled:d})]})]})]}),(0,B.jsxs)(Em,{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)(am,{tip:Fm[e],children:Im[e]}),(0,B.jsx)(kl,{checked:n.relay[e]??!0,onCheckedChange:t=>h({[e]:t}),disabled:d})]},e))}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{tip:`Which relay MCP tools this agent can call. Full access grants every tool relay exposes; Custom restricts the agent to only the selected groups. Sourced live from the server's tool-group registry, so it can't drift out of date.`,children:`Relay Tool Groups`}),(0,B.jsxs)(`div`,{className:`mt-1 flex overflow-hidden rounded-md border border-input text-xs`,children:[(0,B.jsx)(`button`,{type:`button`,className:`flex-1 px-2 py-1.5 font-medium transition-colors ${r===`full`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`}`,onClick:()=>o(`full`),disabled:d,children:`Full access — all tools`}),(0,B.jsx)(`button`,{type:`button`,className:`flex-1 border-l border-input px-2 py-1.5 font-medium transition-colors ${r===`custom`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`}`,onClick:()=>o(`custom`),disabled:d,children:`Custom — selected groups`})]}),r===`full`&&(0,B.jsxs)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[`Every relay MCP tool is available — `,v,` tools across `,s.length,` groups.`]}),r===`custom`&&(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`div`,{className:`mt-1.5 rounded border border-border bg-muted/20 px-2 py-2 text-xs text-muted-foreground`,children:`Loading tool groups…`}):b?(0,B.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-2 rounded border border-destructive/40 bg-destructive/10 px-2 py-2 text-xs text-destructive`,children:[(0,B.jsx)(`span`,{children:`Couldn't load tool groups (is the server up to date?)`}),(0,B.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:()=>void l(),disabled:c.loading,children:[(0,B.jsx)(ee,{className:`h-3 w-3 ${c.loading?`animate-spin`:``}`}),`Retry`]})]}):(0,B.jsx)(`div`,{className:`mt-1.5 grid grid-cols-2 gap-1.5`,children:s.map(e=>(0,B.jsxs)(`label`,{className:`flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`rounded`,checked:_.includes(e.name),onChange:t=>g(e.name,t.target.checked),disabled:d}),(0,B.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:e.name}),(0,B.jsx)(im,{children:(0,B.jsx)(`div`,{className:`font-mono text-[11px] leading-relaxed`,children:e.tools.join(`, `)})})]},e.name))}),!y&&!b&&(_.length===0?(0,B.jsx)(`p`,{className:`mt-1.5 text-xs text-amber-400`,children:`No groups selected yet — until you pick at least one, this profile keeps full tool access.`}):(0,B.jsxs)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[_.length,` of `,s.length,` groups selected.`]}))]})]})]}),(0,B.jsx)(Em,{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)(am,{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)(Dm,{value:n.mcp.mode,onChange:e=>a({mcp:{...n.mcp,mode:e}}),options:jm,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{tip:`The host's hook configuration. Host = inherit it; None = no host hooks.`,children:`Hooks Mode`}),(0,B.jsx)(Dm,{value:n.hooks.mode,onChange:e=>a({hooks:{mode:e}}),options:jm,disabled:d})]})]})}),(0,B.jsx)(Em,{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)(am,{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)(Dm,{value:dm(n.projectMcp),onChange:x,options:om,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{tip:`Injects skills committed under the project's .claude/skills.`,children:`Project Skills`}),(0,B.jsx)(Dm,{value:dm(n.projectSkills),onChange:S,options:om,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{tip:`Injects the project's .claude/settings.json (permission/security keys stripped).`,children:`Project Settings`}),(0,B.jsx)(Dm,{value:dm(n.projectSettings),onChange:C,options:sm,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(am,{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)(Dm,{value:dm(n.sharedMcp),onChange:w,options:om,disabled:d})]}),(0,B.jsxs)(`div`,{className:`col-span-2`,children:[(0,B.jsx)(am,{tip:`How the agent's isolated branch lands: Direct (rebase/FF), Pull request, or the instance default.`,children:`Landing Strategy`}),(0,B.jsx)(Dm,{value:n.landingStrategy??``,onChange:e=>a({landingStrategy:e||void 0}),options:cm,disabled:d})]})]})}),(0,B.jsx)(Em,{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)(Dm,{value:n.permissions.mode||``,onChange:e=>te({mode:e||void 0}),options:Pm,disabled:d})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)($,{children:`Filesystem Scope`}),(0,B.jsx)(Dm,{value:n.permissions.filesystem,onChange:e=>te({filesystem:e}),options:Mm,disabled:d})]})]})}),(0,B.jsx)(Em,{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=>ne(e.target.value),placeholder:`0`,disabled:d}),(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)(Em,{title:`Environment Variables`,defaultOpen:!1,children:(0,B.jsx)(Om,{env:n.env||{},onChange:e=>a({env:e}),disabled:d})}),(0,B.jsx)(Em,{title:`Registry Capabilities`,defaultOpen:!1,children:(0,B.jsx)(gm,{skills:n.skills??[],plugins:n.plugins??[],mcp:n.mcp,onChangeSkills:e=>a({skills:e}),onChangePlugins:e=>a({plugins:e}),onChangeMcp:e=>a({mcp:e}),projectMcp:n.projectMcp,projectSkills:n.projectSkills,projectSettings:n.projectSettings,sharedMcp:n.sharedMcp,readOnly:d})}),(0,B.jsx)(Em,{title:`Resolved Provisioning`,defaultOpen:t===`view`,children:(0,B.jsx)(wm,{profile:n})}),(0,B.jsxs)(Em,{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:ae,onChange:e=>T(e.target.value),placeholder:`12000`,disabled:d})]}),(0,B.jsx)(Yd,{value:JSON.stringify(n.providerOptions||{},null,2),onChange:e=>{try{a({providerOptions:JSON.parse(e.target.value)})}catch{}},rows:3,disabled:d,className:`font-mono text-xs`,placeholder:`{}`})]})]}),!d&&(0,B.jsxs)(Fp,{children:[(0,B.jsx)(I,{variant:`outline`,onClick:i,children:`Cancel`}),(0,B.jsx)(I,{onClick:u,children:f?`Create`:`Save`})]})]})})}function zm(){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=Dl(),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)(st[e.icon]||le,{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 Bm(){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)(Ye,{className:`w-5 h-5`})}),(0,B.jsx)(D,{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 Vm(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 Hm(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`}let r=Math.floor(n/86400),i=Math.round(n%86400/3600);return i===24?`${r+1}d`:i>0?`${r}d ${i}h`:`${r}d`}function Um(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`}var Wm=`agent-relay:quota-widget`,Gm=300*1e3,Km=8;function qm(e){return!e.quota&&e.lastError?.type===`unavailable`}function Jm(e,t){let n=t===`5h`?[`five_hour`,`primary`]:[`seven_day`,`secondary`];return e.quota?.windows.find(e=>n.includes(e.name))}function Ym({record:e,now:t,advisory:n}){let r=(0,B.jsx)(ir,{provider:e.provider,className:`w-3.5 h-3.5`});if(qm(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=Jm(e,`5h`),a=Jm(e,`7d`);function o(e){if(!e)return null;let n=Math.round(e.utilization*100),r=Um(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)(th,{advisory:n}),o(i),o(a),s&&(0,B.jsx)(`span`,{className:`text-muted-foreground/70`,children:s})]})}function Xm(){try{let e=localStorage.getItem(Wm);return{open:!0,pinned:!1,...e?JSON.parse(e):{}}}catch{return{open:!0,pinned:!1}}}function Zm(e){try{localStorage.setItem(Wm,JSON.stringify(e))}catch{}}function Qm(){let[{open:e,pinned:t},n]=(0,z.useState)(Xm),[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=kt(),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([rt(`GET`,`/provider-quotas`),rt(`GET`,`/providers/quota-config`).catch(()=>null),rt(`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(),Gm);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&&!qm(e)),g=m.some(e=>e.lastError&&!qm(e));function _(){if(t)return;let r={open:!e,pinned:t};n(r),Zm(r)}function v(){let r=t?{open:e,pinned:!1}:{open:!0,pinned:!0};n(r),Zm(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)(le,{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)(Qe,{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)(Ym,{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)(he,{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)(Qe,{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??Km};return(0,B.jsx)(ah,{record:e,now:d,advisory:s?.advisories[e.provider],sparklineCfg:n},`${e.provider}:${e.accountKey}`)})})]})]})}var $m={prefer:{icon:_t,badge:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,dot:`bg-emerald-400`},caution:{icon:c,badge:`text-amber-400 bg-amber-500/10 border-amber-500/20`,dot:`bg-amber-400`},"avoid-large":{icon:c,badge:`text-orange-400 bg-orange-500/10 border-orange-500/20`,dot:`bg-orange-400`},"hard-avoid":{icon:Pe,badge:`text-red-400 bg-red-500/10 border-red-500/20`,dot:`bg-red-400`}};function eh({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)(Pe,{className:`w-2.5 h-2.5`}),`at capacity`]});let t=e.quotaPenaltyBand;if(t===`normal`)return null;let n=$m[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 th({advisory:e}){if(!e)return null;if(e.blockedNow)return(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-500 shrink-0`,title:`at capacity`});let t=e.quotaPenaltyBand;return t===`normal`?null:(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${$m[t].dot} shrink-0`,title:t})}function nh(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}× · ~${Hm(t,t+e.earlyWallMs)} before reset`}function rh({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)(Te,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{className:`italic`,children:`building burn history…`})]});let n=nh(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)(c,{className:`w-2.5 h-2.5 shrink-0`}),(0,B.jsx)(`span`,{children:n})]}):null}function ih({provider:e,windowName:t,rangeHours:n}){let[r,i]=(0,z.useState)([]);kt(),(0,z.useEffect)(()=>{let r=!1,a=Date.now()-n*36e5;return rt(`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 ah({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(qm(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)(ir,{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)(ir,{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)(eh,{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?Hm(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:Vm(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)(rh,{burnWindow:s,now:t}),r?.enabled&&(0,B.jsx)(ih,{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 oh(e){return(0,z.lazy)(()=>vr(e))}var sh=oh(()=>R(()=>import(`./overview-BvhbPWtF.js`).then(e=>({default:e.OverviewView})),__vite__mapDeps([15,1,6,8,9,10,16,17,12,18]),import.meta.url)),ch=oh(()=>R(()=>import(`./chat-Cgj7VKzc.js`).then(e=>({default:e.ChatView})),__vite__mapDeps([19,1,6,20,8,9,10,21,16,22,2,23,24,25,26,27,11,12,17,28,13]),import.meta.url)),lh=oh(()=>R(()=>import(`./agents-Chw5E_2q.js`).then(e=>({default:e.AgentsView})),__vite__mapDeps([29,1,30,31,6,12,32,20,33,34,35,36,37,8,9,10,16,26,27,11,17,18]),import.meta.url)),uh=oh(()=>R(()=>import(`./managed-agents-DdS7aI38.js`).then(e=>({default:e.ManagedAgentsView})),__vite__mapDeps([38,1,6,8,9,10,27,11,12,17]),import.meta.url)),dh=oh(()=>R(()=>import(`./teams-B8f2pGJe.js`).then(e=>({default:e.TeamsView})),__vite__mapDeps([39,1,40,30,31,6,12,32,20,33,34,41,42,43,35,37,44,8,9,10,24,25,17,11,18,28]),import.meta.url)),fh=oh(()=>R(()=>import(`./agent-profiles-CRPgYTyb.js`).then(e=>({default:e.AgentProfilesView})),__vite__mapDeps([45,1,6,8,9,10,17,12,11]),import.meta.url)),ph=oh(()=>R(()=>import(`./orchestrators-BgtvvHvo.js`).then(e=>({default:e.OrchestratorsView})),__vite__mapDeps([46,6,1,8,9,10,17,12,11,18]),import.meta.url)),mh=oh(()=>R(()=>import(`./workspaces-CLYc3yF3.js`).then(e=>({default:e.WorkspacesView})),__vite__mapDeps([47,1,6,8,9,10,27,11,12,25,17,18]),import.meta.url)),hh=oh(()=>R(()=>import(`./channels-CLwPeEPi.js`).then(e=>({default:e.ChannelsView})),__vite__mapDeps([48,6,1,8,9,10,17,12,11,18]),import.meta.url)),gh=oh(()=>R(()=>import(`./connectors-Br6fiTny.js`).then(e=>({default:e.ConnectorsView})),__vite__mapDeps([49,6,1,8,9,10,17,12,11,18]),import.meta.url)),_h=oh(()=>R(()=>import(`./integrations-DYEGSqq_.js`).then(e=>({default:e.IntegrationsView})),__vite__mapDeps([50,6,1,8,9,10,17,12,11,18]),import.meta.url)),vh=oh(()=>R(()=>import(`./security-BgcX1n9D.js`).then(e=>({default:e.SecurityView})),__vite__mapDeps([51,1,6,27,11,12,17,18,28]),import.meta.url)),yh=oh(()=>R(()=>import(`./memory-CSwx7bz8.js`).then(e=>({default:e.MemoryView})),__vite__mapDeps([52,1,6,8,9,10,17,12,11,18,28]),import.meta.url)),bh=oh(()=>R(()=>import(`./activity-D-ocGQGs.js`).then(e=>({default:e.ActivityView})),__vite__mapDeps([53,1,6,8,9,10,21,16,22,2,23,25,17,12,11,18]),import.meta.url)),xh=oh(()=>R(()=>import(`./pairs-CpXSOMx0.js`).then(e=>({default:e.PairsView})),__vite__mapDeps([54,6,1,8,9,10,17,12,11,18]),import.meta.url)),Sh=oh(()=>R(()=>import(`./messages-Be9CmvDv.js`).then(e=>({default:e.MessagesView})),__vite__mapDeps([55,1,6,8,9,10,22,2,17,12,11,18]),import.meta.url)),Ch=oh(()=>R(()=>import(`./work-queue-9imc7aNK.js`).then(e=>({default:e.WorkQueueView})),__vite__mapDeps([56,6,1,8,9,10,17,12,11,18]),import.meta.url)),wh=oh(()=>R(()=>import(`./tasks-C5d2LU5E.js`).then(e=>({default:e.TasksView})),__vite__mapDeps([57,1,6,8,9,10,17,12,11,18]),import.meta.url)),Th=oh(()=>R(()=>import(`./automation-D7g90kTv.js`).then(e=>({default:e.AutomationView})),__vite__mapDeps([58,1,6,8,9,10,17,12,11,18,28]),import.meta.url)),Eh=oh(()=>R(()=>import(`./analytics-BmNDG0hR.js`).then(e=>({default:e.AnalyticsView})),__vite__mapDeps([59,1,6,8,9,10,18,60]),import.meta.url)),Dh=oh(()=>R(()=>import(`./insights-qvaPqWCV.js`).then(e=>({default:e.InsightsView})),__vite__mapDeps([61,1,6,17,12,11,18,28,9,10]),import.meta.url)),Oh=oh(()=>R(()=>import(`./projects-DdPNPFJI.js`).then(e=>({default:e.ProjectsView})),__vite__mapDeps([62,1,6,8,9,10,27,11,12,17,18]),import.meta.url)),kh=oh(()=>R(()=>import(`./prompt-settings-BpZse7-X.js`).then(e=>({default:e.PromptSettingsView})),__vite__mapDeps([63,1,6,17,12,11,18,9,10]),import.meta.url)),Ah=oh(()=>R(()=>import(`./registry-pb1gTZEg.js`).then(e=>({default:e.RegistryView})),__vite__mapDeps([64,1,6,17,12,11,18,28,10]),import.meta.url)),jh=oh(()=>R(()=>import(`./maintenance-C0HIEB-J.js`).then(e=>({default:e.MaintenanceView})),__vite__mapDeps([65,1,6,8,9,10,17,12,11]),import.meta.url)),Mh=oh(()=>R(()=>import(`./settings-hd5kzdRB.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([66,1,40,30,31,6,12,32,20,33,34,41,42,43,35,37,44,8,9,10,23,16,17,11,18,28,60]),import.meta.url)),Nh=class extends z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e.message,`
|
|
24
24
|
`,t.componentStack)}render(){return this.state.error?hr(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}},Ph={overview:sh,chat:ch,agents:lh,managed:uh,teams:dh,profiles:fh,orchestrators:ph,workspaces:mh,files:Su,channels:hh,connectors:gh,integrations:_h,security:vh,memory:yh,activity:bh,pairs:xh,messages:Sh,work:Ch,tasks:wh,automation:Th,analytics:Eh,insights:Dh,projects:Oh,prompts:kh,registry:Ah,maintenance:jh,settings:Mh},Fh=`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 Ih(){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 Lh(){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:`${Fh} 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:`${Fh} px-4 py-2 bg-zinc-800 text-zinc-100 text-sm rounded-md shadow-lg border border-zinc-700`,children:e}):null}function Rh(){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)(()=>{En(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=Ph[r]||sh;return(0,B.jsx)(Nh,{children:(0,B.jsx)(ul,{children:(0,B.jsxs)(`div`,{className:`flex min-h-[calc(100dvh-var(--sat))] mt-[var(--sat)]`,children:[(0,B.jsx)(J,{}),(0,B.jsx)(Y,{}),(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)(Bm,{}),!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)(De,{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)(Qm,{}),(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)(Ih,{}),children:(0,B.jsx)(f,{})})})]}),(0,B.jsx)(Md,{}),(0,B.jsx)(Jd,{}),(0,B.jsx)(vp,{}),(0,B.jsx)(Rp,{}),(0,B.jsx)(zp,{}),(0,B.jsx)(Bp,{}),(0,B.jsx)(Vp,{}),(0,B.jsx)(Hp,{}),(0,B.jsx)(Up,{}),(0,B.jsx)(Wp,{}),(0,B.jsx)(Gp,{}),(0,B.jsx)(qp,{}),(0,B.jsx)($p,{}),(0,B.jsx)(nm,{}),(0,B.jsx)(rm,{}),(0,B.jsx)(Rm,{}),(0,B.jsx)(Cu,{}),(0,B.jsx)(zm,{}),(0,B.jsx)(Lh,{})]})})})}if((0,fr.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(Rh,{})})),`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{nd as $,af as A,El as At,pf as B,Pf as C,Sl as Ct,ff as D,gl as Dt,rf as E,ml as Et,$d as F,Kd as G,lf as H,sf as I,jd as J,kd as K,Qd as L,of as M,df as N,uf as O,wl as Ot,nf as P,rd as Q,mf as R,Ff as S,bl as St,If as T,xl as Tt,$ as U,ef as V,Yd as W,_d as X,Ad as Y,cd as Z,sp as _,jl as _t,Pp as a,qu as at,pp as b,hl as bt,Zf as c,Ru as ct,lp as d,tu as dt,td as et,cp as f,Xl as ft,Kf as g,Fl as gt,fp as h,Nl as ht,Fp as i,Yu as it,tf as j,yr as jt,Xd as k,Tl as kt,Wf as l,yu as lt,dp as m,Ml as mt,Np as n,Bu as nt,Ip as o,Ku as ot,up as p,Al as pt,Od as q,Lp as r,Vu as rt,op as s,Gu as st,Ap as t,zu as tt,np as u,bu as ut,tp as v,G as vt,Af as w,Cl as wt,kf as x,yl as xt,Bf as y,kl as yt,Zd as z};
|
|
25
|
-
//# sourceMappingURL=index-
|
|
25
|
+
//# sourceMappingURL=index-D9OogaB5.js.map
|