@nathanstephenson/flow 0.1.1 → 0.1.2

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workflows-pane-DJ3UwHjd.js","assets/rolldown-runtime-B0Z9INg1.js","assets/switch-ftZleVB8.js","assets/select-6i3wxovH.js","assets/workflows-Bmsrl5kE.js","assets/workflows-9aO6cptD.css","assets/settings-workflows-BPjeFoaT.js","assets/settings-mcp-COi1p_1o.js","assets/settings-secrets-C599riFl.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workflows-pane-DPXGg0na.js","assets/rolldown-runtime-B0Z9INg1.js","assets/switch-ftZleVB8.js","assets/select-6i3wxovH.js","assets/workflows-CBuB_bva.js","assets/workflows-9aO6cptD.css","assets/settings-workflows-1DMYfZtn.js","assets/settings-mcp-ZMIfuuZU.js","assets/settings-secrets-CgTrBpi2.js"])))=>i.map(i=>d[i]);
2
2
  import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-B0Z9INg1.js";import{$ as a,An as o,At as s,B as c,Bn as l,C as u,Cr as d,Ct as f,D as p,E as m,Et as h,F as g,Fn as _,Ft as v,G as y,H as b,I as x,It as S,J as C,Jn as w,K as T,Kn as E,L as D,Ln as O,M as k,Mn as A,N as j,Nn as M,Nt as N,O as P,On as F,Ot as I,P as ee,Pn as te,Pt as ne,Q as L,Qn as R,R as re,Rn as ie,Rt as ae,S as oe,Sr as se,St as ce,T as le,U as ue,V as de,W as fe,Xn as pe,Y as me,Z as he,Zn as ge,_ as _e,_n as ve,_r as ye,_t as be,a as xe,ar as Se,at as Ce,b as we,bn as Te,br as Ee,bt as De,c as Oe,cr as ke,d as Ae,dr as je,dt as Me,et as Ne,f as Pe,fr as Fe,ft as Ie,g as z,gr as Le,gt as Re,h as B,hn as ze,hr as Be,ht as Ve,i as He,ir as Ue,it as We,j as Ge,jn as Ke,k as qe,kn as Je,kt as Ye,l as Xe,lr as Ze,m as Qe,mr as $e,n as et,o as tt,on as nt,or as rt,ot as it,p as at,pn as ot,pr as st,pt as ct,q as lt,qn as ut,r as dt,rt as ft,s as pt,sr as V,st as mt,t as ht,tt as gt,u as _t,un as vt,ut as yt,v as bt,vn as xt,vr as St,vt as Ct,w as wt,wr as Tt,wt as Et,x as Dt,xn as Ot,xr as kt,xt as At,y as jt,yn as Mt,yr as Nt,yt as Pt,z as Ft,zn as It,zt as Lt}from"./switch-ftZleVB8.js";import{$ as Rt,A as zt,B as Bt,C as Vt,Ct as Ht,D as Ut,Dt as Wt,E as Gt,Et as Kt,F as qt,G as Jt,H as Yt,J as Xt,K as Zt,L as Qt,M as $t,N as en,O as tn,P as nn,Q as rn,R as an,S as on,St as sn,T as cn,Tt as ln,U as un,V as dn,W as fn,X as pn,Y as mn,Z as hn,_ as gn,_t as _n,a as vn,at as yn,b as bn,bt as xn,c as Sn,ct as Cn,d as wn,dt as Tn,et as En,f as Dn,ft as On,g as kn,gt as An,h as jn,ht as Mn,i as Nn,it as Pn,j as Fn,k as In,l as Ln,lt as Rn,m as zn,mt as Bn,n as Vn,nt as Hn,o as Un,ot as Wn,p as Gn,pt as Kn,q as qn,r as Jn,rt as Yn,s as Xn,st as Zn,t as Qn,tt as $n,u as er,ut as tr,v as nr,vt as rr,w as ir,wt as ar,x as or,xt as sr,y as cr,yt as lr,z as ur}from"./select-6i3wxovH.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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var dr=i((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,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=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&&E());){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&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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`):w=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,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),fr=i(((e,t)=>{t.exports=dr()})),pr=i((e=>{var t=fr(),n=Tt(),r=d();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 f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},ee=[],te=-1;function ne(e){return{current:e}}function L(e){0>te||(e.current=ee[te],ee[te]=null,te--)}function R(e,t){te++,ee[te]=e.current,e.current=t}var re=ne(null),ie=ne(null),ae=ne(null),oe=ne(null);function se(e,t){switch(R(ae,t),R(ie,e),R(re,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Yd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Yd(t),e=Xd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}L(re),R(re,e)}function ce(){L(re),L(ie),L(ae)}function le(e){e.memoizedState!==null&&R(oe,e);var t=re.current,n=Xd(t,e.type);t!==n&&(R(ie,e),R(re,n))}function ue(e){ie.current===e&&(L(re),L(ie)),oe.current===e&&(L(oe),ap._currentValue=I)}var de,fe;function pe(e){if(de===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);de=t&&t[1]||``,fe=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+de+e+fe}var me=!1;function he(e,t){if(!e||me)return``;me=!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(`
@@ -104,7 +104,7 @@ Example:
104
104
  For tests, pass a Ghostty instance directly:
105
105
  import { Ghostty, Terminal } from "ghostty-web";
106
106
  const ghostty = await Ghostty.load();
107
- const term = new Terminal({ ghostty });`)}var Fj=`/assets/ghostty-vt-DOMeXDrv.wasm`,Ij;function Lj(){return Ij??=lj.load(Fj),Ij}function Rj({sessionId:e,shellId:t,onOpened:n,onStatus:r}){let i=(0,H.useRef)(null),[a,o]=(0,H.useState)({state:`connecting`}),{config:s}=Dt(),c=s.fonts?.monospace??oe.monospace,l=(0,H.useRef)({shellId:t,onOpened:n,onStatus:r});return l.current={shellId:t,onOpened:n,onStatus:r},(0,H.useEffect)(()=>{let t=i.current;if(!t)return;let n=e=>{o(e),l.current.onStatus(e)},r=!1,a,s;return(async()=>{let[i]=await Promise.all([Lj(),u(c)]);if(r)return;a=new Oj({ghostty:i,fontSize:13,fontFamily:c,theme:zj(t),cursorBlink:!0}),a.open(t);let o=new Nj;a.loadAddon(o),o.fit(),o.observeResize();let d=l.current.shellId;if(d===void 0){try{d=(await Ia(e,a.cols,a.rows)).id}catch(e){r||n({state:`gone`,why:e instanceof Error?e.message:String(e)});return}if(r){Ra(d);return}l.current.onOpened(d)}s=za(d,{output:e=>a?.write(e),ready:()=>n({state:`live`}),exit:e=>n({state:`gone`,why:e===0?`exited`:`exited (${e??`signal`})`}),closed:()=>n({state:`gone`,why:`disconnected`})}),a.onData(e=>s?.send(e)),a.onResize(({cols:e,rows:t})=>s?.resize(e,t)),s.resize(a.cols,a.rows),a.focus()})(),()=>{r=!0,s?.close(),a?.dispose()}},[e,c]),(0,U.jsxs)(`div`,{"data-shell-pane":``,className:`relative min-h-0 overflow-hidden bg-background`,"aria-label":`Shell`,children:[(0,U.jsx)(`div`,{ref:i,className:`size-full`}),a.state===`live`?null:(0,U.jsx)(`span`,{className:`pointer-events-none absolute top-1 right-2 text-xs text-muted-foreground`,children:a.state===`connecting`?`connecting…`:a.why})]})}function zj(e){let t=getComputedStyle(e),n=(e,n)=>{let r=t.getPropertyValue(e).trim();return r?Bj(r)??n:n};return{background:n(`--background`,`#0a0a0a`),foreground:n(`--foreground`,`#fafafa`),cursor:n(`--foreground`,`#fafafa`)}}function Bj(e){let t=document.createElement(`canvas`);t.width=1,t.height=1;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n||(n.fillStyle=e,n.fillStyle===`#000000`&&!/^(#000000|black|rgb\(0, ?0, ?0\))$/i.test(e)))return;n.fillRect(0,0,1,1);let[r,i,a]=n.getImageData(0,0,1,1).data;return`#${[r,i,a].map(e=>(e??0).toString(16).padStart(2,`0`)).join(``)}`}var Vj=(0,H.lazy)(()=>nj(()=>import(`./workflows-pane-DJ3UwHjd.js`),__vite__mapDeps([0,1,2,3,4,5])));function Hj({side:e,dock:t,sessionId:n,shells:r,dispatch:i,visible:a=!0,mobile:o=!1,mobileNavigation:s}){let c=(0,H.useRef)(null),[l,u]=(0,H.useState)({}),d=(0,H.useCallback)((e,t)=>{u(n=>({...n,[e]:t}))},[]),f=s?.tabId??t.activeId,p=t.tabs.find(e=>e.id===f),m=e===`bottom`?`bottom Dock`:`right Dock`,h=(t,n)=>i({type:`resize`,side:e,px:t,...n===void 0?{}:{available:n}});return(0,U.jsxs)(`section`,{ref:c,"data-dock":e,"aria-label":m,className:z(`relative min-h-0 min-w-0 bg-background`,a?`grid`:`hidden`,o?`col-start-1 row-start-1 grid-rows-[minmax(0,1fr)]`:e===`bottom`?`col-start-1 row-start-2 grid-rows-[auto_minmax(0,1fr)] border-t`:`col-start-2 row-span-2 row-start-1 grid-rows-[auto_minmax(0,1fr)] border-l`),children:[o?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yD,{side:e,size:t.size,onResize:h,onNudge:(n,r)=>{let i=c.current?.closest(`[data-dock-frame]`),a=i==null?void 0:e===`bottom`?i.clientHeight:i.clientWidth;h(t.size+n*sa(r),a)}}),(0,U.jsxs)(`div`,{className:`flex h-9 min-w-0 items-center gap-1 border-b px-1.5`,children:[(0,U.jsx)(`div`,{role:`tablist`,"aria-label":`${m} tabs`,"aria-orientation":`horizontal`,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto`,children:t.tabs.map(n=>{let r=l[n.id];return(0,U.jsxs)(`div`,{className:z(`flex shrink-0 items-center gap-0.5 rounded-2xl pr-0.5 pl-2.5 text-xs`,n.id===t.activeId?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50`),children:[(0,U.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.id===t.activeId,onClick:()=>i({type:`activate`,side:e,tabId:n.id}),className:`max-w-40 truncate py-1 outline-none`,children:[ka(t,n.id),r?.state===`gone`?(0,U.jsx)(`span`,{className:`ml-1.5 text-muted-foreground`,children:r.why}):null]}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`rounded-xl`,onClick:()=>i({type:`close-tab`,side:e,tabId:n.id}),title:n.content?.kind===`shell`?`Close this tab — ends its Shell`:`Close this tab`,"aria-label":`Close ${ka(t,n.id)}${n.content?.kind===`shell`?` — ends its Shell`:``}`,children:(0,U.jsx)(ts,{"aria-hidden":!0})})]},n.id)})}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 rounded-xl`,onClick:()=>i({type:`add-tab`,side:e}),title:`New tab`,"aria-label":`New tab in the ${m}`,children:(0,U.jsx)(Ko,{"aria-hidden":!0})}),(0,U.jsxs)(ul,{children:[(0,U.jsx)(dl,{render:(0,U.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 rounded-xl`,onClick:()=>i({type:`toggle`,side:e}),"aria-label":`Minimise the ${m}`}),children:e===`bottom`?(0,U.jsx)(Vo,{"aria-hidden":!0}):(0,U.jsx)(Wo,{"aria-hidden":!0})}),(0,U.jsx)(fl,{children:`Minimise — Shells keep running`})]})]})]}),(0,U.jsx)(`div`,{className:`relative min-h-0 min-w-0 overflow-hidden`,children:t.tabs.length===0?(0,U.jsx)(Wj,{onChooseWorkflows:()=>i({type:`open-workflows`,side:e}),onChooseGit:()=>i({type:`open-git`,side:e}),onChooseSubagents:()=>i({type:`open-subagents`,side:e}),...r?{onChooseShell:()=>i({type:`open-shell`,side:e})}:{}}):t.tabs.map(t=>(0,U.jsx)(Uj,{side:e,tab:t,active:t.id===p?.id,visible:a&&t.id===p?.id,sessionId:n,shells:r,dispatch:i,onStatus:e=>d(t.id,e),mobileNavigation:s?.tabId===t.id?s:void 0},t.id))})]})}function Uj({side:e,tab:t,active:n,visible:r,sessionId:i,shells:a,dispatch:o,onStatus:s,mobileNavigation:c}){let l=t.content;return(0,U.jsx)(H.Activity,{mode:r?`visible`:`hidden`,children:(0,U.jsx)(`div`,{role:`tabpanel`,"aria-hidden":!r,className:`absolute inset-0 flex min-h-0 min-w-0 flex-col overflow-hidden`,children:l?.kind===`workflows`?(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading workflows…`}),children:(0,U.jsx)(Vj,{sessionId:i,placement:e,mobileNavigation:c?{stepId:c.detail?.kind===`workflow-step`?c.detail.id:``,onSelect:e=>c.onDetail({kind:`workflow-step`,id:e}),onBack:c.onBackDetail}:void 0},i)}):l?.kind===`git`?(0,U.jsx)(rA,{sessionId:i},`${i}-${t.id}`):l?.kind===`subagents`?(0,U.jsx)(qA,{sessionId:i,subagentId:c?c.detail?.kind===`subagent`?c.detail.id:void 0:l.subagentId,onSelect:n=>{o({type:`select-subagent`,side:e,tabId:t.id,...n?{subagentId:n}:{}}),c&&(n?c.onDetail({kind:`subagent`,id:n}):c.onBackDetail())}},t.id):l?.kind===`shell`?n&&r?(0,U.jsx)(Rj,{sessionId:i,shellId:l.shellId,onOpened:n=>o({type:`remember-shell`,side:e,tabId:t.id,shellId:n}),onStatus:s},t.id):null:(0,U.jsx)(Wj,{onChooseWorkflows:()=>o({type:`open-workflows`,side:e,tabId:t.id}),onChooseGit:()=>o({type:`open-git`,side:e,tabId:t.id}),onChooseSubagents:()=>o({type:`open-subagents`,side:e,tabId:t.id}),...a?{onChooseShell:()=>o({type:`open-shell`,side:e,tabId:t.id})}:{}})})})}function Wj({onChooseWorkflows:e,onChooseShell:t,onChooseSubagents:n,onChooseGit:r}){return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-wrap items-center justify-center gap-2 overflow-auto p-4`,children:[t===void 0?null:(0,U.jsxs)(B,{variant:`outline`,size:`sm`,className:`max-lg:min-h-10`,onClick:t,children:[(0,U.jsx)(Qo,{"aria-hidden":!0,"data-icon":`inline-start`}),`Shell`]}),(0,U.jsx)(B,{variant:`outline`,size:`sm`,className:`max-lg:min-h-10`,onClick:r,children:`Git`}),(0,U.jsx)(B,{variant:`outline`,size:`sm`,className:`max-lg:min-h-10`,onClick:e,children:`Workflows`}),(0,U.jsxs)(B,{variant:`outline`,size:`sm`,className:`max-lg:min-h-10`,onClick:n,children:[(0,U.jsx)(To,{"aria-hidden":!0,"data-icon":`inline-start`}),`Agents`]})]})}var Gj=120;function Kj({query:e,onQueryChange:t,onClose:n}){let[r,i]=(0,H.useState)(e),a=(0,H.useRef)(e),o=(0,H.useRef)(null);return(0,H.useEffect)(()=>{o.current?.select()},[]),(0,H.useEffect)(()=>{let e=r.trim().toLowerCase();if(e===a.current)return;let n=setTimeout(()=>{a.current=e,t(e)},Gj);return()=>clearTimeout(n)},[r,t]),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-card px-3 py-1`,children:[(0,U.jsx)(Jo,{className:`size-4 shrink-0 opacity-50`,"aria-hidden":!0}),(0,U.jsx)(et,{ref:o,"data-transcript-search":``,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&n()},placeholder:`Find in this Presentation Transcript`,"aria-label":`Find in this Presentation Transcript`,className:`h-8 border-0 bg-transparent px-0 shadow-none dark:bg-transparent focus-visible:border-0 focus-visible:ring-0`}),(0,U.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close search`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(ts,{className:`size-4`,"aria-hidden":!0})})]})}var qj=`tool:`,Jj=`thinking:`,Yj=3,Xj=e=>e.startsWith(qj),Zj=e=>Xj(e)||e.startsWith(Jj);function Qj(e,t=Yj){let n=[],r=[],i=()=>{if(r.length>=t&&r.some(Xj))n.push({kind:`chain`,keys:r});else for(let e of r)n.push({kind:`entry`,key:e});r=[]};for(let t of e){if(Zj(t)){r.push(t);continue}i(),n.push({kind:`entry`,key:t})}return i(),n}function $j(e,t=40){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function eM({view:e,keys:t,children:n}){let r=(0,H.useMemo)(()=>t.filter(Xj),[t]),i=ni(e,r[r.length-1]??``),a=tM(e,t),o=i?.kind===`tool`?as(i.input):void 0;return(0,U.jsx)(`div`,{className:`py-0.5`,children:(0,U.jsxs)(`details`,{className:`rounded-lg border text-foreground`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-default items-center gap-2 px-3 py-2 select-none`,children:[(0,U.jsx)(Lo,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,U.jsxs)(`span`,{className:`shrink-0 text-sm text-muted-foreground`,children:[r.length,` tools`]}),i?.kind===`tool`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,U.jsx)(kA,{status:i.status}),(0,U.jsx)(`span`,{className:`shrink-0 font-mono text-sm text-foreground`,children:i.name}),o===void 0?null:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:o})]}):null,a===0?null:(0,U.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs text-destructive`,children:[a,` failed`]})]}),(0,U.jsx)(`div`,{className:`border-t px-3 py-1`,children:n})]})})}function tM(e,t){let n=(0,H.useCallback)(t=>e.subscribeTranscript(t),[e]),r=(0,H.useCallback)(()=>{let n=0;for(let r of t){let t=e.getEntry(r);t?.kind===`tool`&&t.status===`error`&&(n+=1)}return n},[e,t]);return(0,H.useSyncExternalStore)(n,r)}var nM=400;function rM({view:e,query:t,visible:n=!0,onObserved:r}){let i=ti(e),a=sM(e,i,t),o=(0,H.useCallback)(t=>e.getEntry(t),[e]),s=(0,H.useMemo)(()=>GA(a,o),[a,o]),[c,l]=(0,H.useState)(!1),u=(0,H.useMemo)(()=>c||s.length<=nM?s:s.slice(-400),[c,s]),d=s.length-u.length,f=(0,H.useMemo)(()=>Qj(u),[u]),p=(0,H.useRef)(null),m=(0,H.useRef)(!0),[h,g]=(0,H.useState)(!0),_=(0,H.useCallback)(e=>{!n||!m.current||document.hidden||!document.hasFocus()||r?.(e)},[r,n]),v=(0,H.useRef)(_);v.current=_;let y=(0,H.useRef)([0,0]),b=(0,H.useCallback)((t=e.getLastSeq())=>{cancelAnimationFrame(y.current[0]),cancelAnimationFrame(y.current[1]),y.current[0]=requestAnimationFrame(()=>{y.current[1]=requestAnimationFrame(()=>v.current(t))})},[e]);(0,H.useEffect)(()=>b()),(0,H.useEffect)(()=>()=>{cancelAnimationFrame(y.current[0]),cancelAnimationFrame(y.current[1])},[]),(0,H.useEffect)(()=>{let e=()=>b();return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[b]),(0,H.useEffect)(()=>{let e=p.current;if(!e)return;let t,n=()=>{m.current=$j(e),!t&&(t=setTimeout(()=>{t=void 0,g(m.current),m.current&&b()},150))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{e.removeEventListener(`scroll`,n),t&&clearTimeout(t)}},[b]),(0,H.useEffect)(()=>{let e=p.current;if(!e)return;let t=new ResizeObserver(()=>{m.current&&(e.scrollTop=e.scrollHeight)});return t.observe(e),()=>t.disconnect()},[]),(0,H.useLayoutEffect)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight,m.current=!0,g(!0))},[t,e]);let x=(0,H.useCallback)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight,m.current=!0,g(!0),b())},[b]);return(0,U.jsxs)(`div`,{className:`relative min-h-0 min-w-0`,children:[(0,U.jsx)(`div`,{ref:p,className:`transcript-scroller h-full px-3 pt-2 pb-[calc(var(--composer-inset,0px)+1.5rem)]`,children:(0,U.jsxs)(`div`,{className:`pane-measure`,children:[d>0?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`mb-2 flex w-full items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,U.jsx)(`span`,{className:`h-px flex-1 bg-border`,"aria-hidden":!0}),d.toLocaleString(),` earlier entries · show all`,(0,U.jsx)(`span`,{className:`h-px flex-1 bg-border`,"aria-hidden":!0})]}):null,f.map(n=>n.kind===`entry`?(0,U.jsx)(iM,{view:e,entryKey:n.key,query:t},n.key):(0,U.jsx)(eM,{view:e,keys:n.keys,children:n.keys.map(n=>(0,U.jsx)(iM,{view:e,entryKey:n,query:t},n))},n.keys[0])),s.length===0?(0,U.jsx)(`p`,{className:`px-1 py-4 text-sm text-muted-foreground`,children:i.length===0?`Nothing here yet.`:`No Entry matches.`}):null,(0,U.jsx)(aM,{view:e,scroller:p,pinned:m,scheduleObserved:b})]})}),h?null:(0,U.jsx)(oM,{onClick:x})]})}function iM({view:e,entryKey:t,query:n}){let r=ni(e,t);return r?(0,U.jsx)(gA,{entry:r,query:n,sessionId:e.sessionId}):null}function aM({view:e,scroller:t,pinned:n,scheduleObserved:r}){let[,i]=(0,H.useState)(0);return(0,H.useEffect)(()=>e.subscribeTranscript(()=>i(e=>e+1)),[e]),(0,H.useLayoutEffect)(()=>{let i=t.current;i&&n.current&&(i.scrollTop=i.scrollHeight),r(e.getLastSeq())}),null}function oM({onClick:e}){return(0,U.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Jump to latest`,className:`-translate-x-1/2 absolute bottom-[calc(var(--composer-inset,0px)+1.5rem)] left-1/2 rounded-full border bg-popover p-2 text-popover-foreground shadow-md transition-colors hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(xo,{className:`size-4`})})}function sM(e,t,n){let r=(0,H.useMemo)(()=>Ok(),[]),[i,a]=(0,H.useState)(t);return(0,H.useEffect)(()=>{if(n===``)return;let t=()=>{let t=e.getKeys().filter(t=>{let i=e.getEntry(t);return i!==void 0&&r.matches(i,n)});a(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)};return t(),e.subscribeTranscript(t)},[e,n,r]),n===``?t:i}function cM({className:e,orientation:t=`horizontal`,...n}){return(0,U.jsx)(Pc,{"data-slot":`separator`,orientation:t,className:z(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}function lM({...e}){return(0,U.jsx)(yE,{"data-slot":`sheet`,...e})}function uM({...e}){return(0,U.jsx)(Us,{"data-slot":`sheet-portal`,...e})}function dM({className:e,...t}){return(0,U.jsx)(Is,{"data-slot":`sheet-overlay`,className:z(`fixed inset-0 z-50 bg-black/30 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-sm`,e),...t})}function fM({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,U.jsxs)(uM,{children:[(0,U.jsx)(dM,{}),(0,U.jsxs)(Hs,{"data-slot":`sheet-content`,"data-side":n,className:z(`fixed z-50 flex flex-col bg-popover bg-clip-padding text-sm text-popover-foreground shadow-xl transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm`,e),...i,children:[t,r&&(0,U.jsxs)(Ls,{"data-slot":`sheet-close`,render:(0,U.jsx)(B,{variant:`ghost`,className:`absolute top-4 right-4 bg-secondary`,size:`icon-sm`}),children:[(0,U.jsx)(ts,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function pM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sheet-header`,className:z(`flex flex-col gap-1.5 p-6`,e),...t})}function mM({className:e,...t}){return(0,U.jsx)(Ws,{"data-slot":`sheet-title`,className:z(`font-heading text-base font-medium text-foreground`,e),...t})}function hM({className:e,...t}){return(0,U.jsx)(Rs,{"data-slot":`sheet-description`,className:z(`text-sm text-muted-foreground`,e),...t})}var gM=`sidebar_state`,_M=604800,vM=`16rem`,yM=`18rem`,bM=`3rem`,xM=H.createContext(null);function SM(){let e=H.useContext(xM);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function CM({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=ds(),[c,l]=H.useState(!1),[u,d]=H.useState(e),f=t??u,p=H.useCallback(e=>{let t=typeof e==`function`?e(f):e;n?n(t):d(t),document.cookie=`${gM}=${t}; path=/; max-age=${_M}`},[n,f]),m=H.useCallback(()=>s?l(e=>!e):p(e=>!e),[s,p,l]),h=f?`expanded`:`collapsed`,g=H.useMemo(()=>({state:h,open:f,setOpen:p,isMobile:s,openMobile:c,setOpenMobile:l,toggleSidebar:m}),[h,f,p,s,c,l,m]);return(0,U.jsx)(xM.Provider,{value:g,children:(0,U.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":vM,"--sidebar-width-icon":bM,...i},className:z(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})}function wM({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,dir:a,...o}){let{isMobile:s,state:c,openMobile:l,setOpenMobile:u}=SM();return n===`none`?(0,U.jsx)(`div`,{"data-slot":`sidebar`,className:z(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),...o,children:i}):s?(0,U.jsx)(lM,{open:l,onOpenChange:u,...o,children:(0,U.jsxs)(fM,{dir:a,"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:{"--sidebar-width":yM},side:e,children:[(0,U.jsxs)(pM,{className:`sr-only`,children:[(0,U.jsx)(mM,{children:`Sidebar`}),(0,U.jsx)(hM,{children:`Displays the mobile sidebar.`})]}),(0,U.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})]})}):(0,U.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground lg:block`,"data-state":c,"data-collapsible":c===`collapsed`?n:``,"data-variant":t,"data-side":e,"data-slot":`sidebar`,children:[(0,U.jsx)(`div`,{"data-slot":`sidebar-gap`,className:z(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),(0,U.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":e,className:z(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] lg:flex`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,r),...o,children:(0,U.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-2xl group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:i})})]})}function TM({className:e,onClick:t,...n}){let{toggleSidebar:r}=SM();return(0,U.jsxs)(B,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,className:z(e),onClick:e=>{t?.(e),r()},...n,children:[(0,U.jsx)(Uo,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})}function EM({className:e,...t}){return(0,U.jsx)(`main`,{"data-slot":`sidebar-inset`,className:z(`relative flex w-full flex-1 flex-col bg-background lg:peer-data-[variant=inset]:m-2 lg:peer-data-[variant=inset]:ml-0 lg:peer-data-[variant=inset]:rounded-2xl lg:peer-data-[variant=inset]:shadow-sm lg:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,e),...t})}function DM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:z(`flex flex-col gap-2 p-2 [--radius:var(--radius-xl)]`,e),...t})}function OM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:z(`flex flex-col gap-2 p-2`,e),...t})}function kM({className:e,...t}){return(0,U.jsx)(cM,{"data-slot":`sidebar-separator`,"data-sidebar":`separator`,className:z(`mx-2 w-auto bg-sidebar-border`,e),...t})}function AM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:z(`no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto [--radius:var(--radius-xl)] group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function jM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:z(`relative flex w-full min-w-0 flex-col p-2`,e),...t})}function MM({className:e,render:t,...n}){return LE({defaultTagName:`div`,props:Pt({className:z(`flex h-8 shrink-0 items-center rounded-xl px-3 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-3 [&>svg]:size-4 [&>svg]:shrink-0`,e)},n),render:t,state:{slot:`sidebar-group-label`,sidebar:`group-label`}})}function NM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:z(`w-full text-sm`,e),...t})}function PM({className:e,...t}){return(0,U.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:z(`flex w-full min-w-0 flex-col gap-0.5`,e),...t})}function FM({className:e,...t}){return(0,U.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:z(`group/menu-item relative`,e),...t})}var IM=_e(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-xl px-3 py-2 text-left text-sm whitespace-nowrap ring-sidebar-ring outline-hidden transition-[width,height,padding] duration-200 group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-3 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 has-[>svg:first-child]:pl-2.5 has-[>svg:last-child]:pr-2.5 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 px-3 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function LM({render:e,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o}){let{isMobile:s,state:c}=SM(),l=LE({defaultTagName:`button`,props:Pt({className:z(IM({variant:n,size:r}),a)},o),render:i?(0,U.jsx)(dl,{render:e}):e,state:{slot:`sidebar-menu-button`,sidebar:`menu-button`,size:r,active:t}});return i?(typeof i==`string`&&(i={children:i}),(0,U.jsxs)(ul,{children:[l,(0,U.jsx)(fl,{side:`right`,align:`center`,hidden:c!==`collapsed`||s,...i})]})):l}function RM({className:e,render:t,showOnHover:n=!1,...r}){return LE({defaultTagName:`button`,props:Pt({className:z(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-xl p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-3 lg:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,n&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 lg:opacity-0`,e)},r),render:t,state:{slot:`sidebar-menu-action`,sidebar:`menu-action`}})}function zM({sessionId:e,docks:t,shells:n,searchOpen:r,onCloseSearch:i,drafts:a}){let o=$r(e);return o?(0,U.jsx)(VM,{view:o,sessionId:e,searchOpen:r,onCloseSearch:i,docks:t,shells:n,drafts:a},e):(0,U.jsx)(`div`,{className:`min-h-0`})}function BM(e,t){let n=t.authorising?.callId;if(n===void 0)return;let r=e.getEntry(`tool:${n}`);return r?.kind===`tool`?as(r.input):void 0}function VM({view:e,sessionId:t,docks:n,shells:r,searchOpen:i,onCloseSearch:a,drafts:o}){let s=ei(e),{sessions:c}=ta(),l=ra(),u=ls(t),[d,f]=(0,H.useState)(``),p=ds(),{openMobile:m}=SM(),[h,g]=(0,H.useState)(()=>gs(ms(window.history.state,t),n.layout)),_=(0,H.useRef)(h);_.current=h;let v=(0,H.useRef)({}),y=(0,H.useRef)(0);(0,H.useEffect)(()=>{if(!p||window.visualViewport===null)return;let e=window.visualViewport,t=()=>{document.documentElement.style.setProperty(`--mobile-viewport-height`,`${e.height}px`)};return t(),e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t),document.documentElement.style.removeProperty(`--mobile-viewport-height`)}},[p]);let b=(0,H.useCallback)((e,n=!1)=>{if(_s(_.current,e)&&!n||(_.current=e,g(e),!p))return;let r=hs(window.history.state,t,e);window.history[n?`replaceState`:`pushState`](r,``,window.location.href)},[p,t]);(0,H.useEffect)(()=>{let e=e=>{g(gs(ms(e.state,t),n.layout))};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[n.layout,t]);let x=gs(h,n.layout);(0,H.useEffect)(()=>{_s(x,h)||g(x)},[h,x]),(0,H.useEffect)(()=>{if(x.kind!==`dock`)return;let e=`${x.side}:${x.tabId}`;v.current[e]=x.detail;let t=n.layout[x.side];t.activeId!==x.tabId&&n.dispatch({type:`activate`,side:x.side,tabId:x.tabId});let r=t.tabs.find(e=>e.id===x.tabId);if(r?.content?.kind!==`subagents`)return;let i=x.detail?.kind===`subagent`?x.detail.id:void 0;i!==void 0&&r.content.subagentId!==i&&n.dispatch({type:`select-subagent`,side:x.side,tabId:x.tabId,subagentId:i})},[n,x]),(0,H.useEffect)(()=>{let e=n.reveal;if(!(!e||e.sessionId!==t||e.nonce===y.current)&&(y.current=e.nonce,n.acknowledgeReveal(e.nonce),p))for(let t of[`right`,`bottom`]){let r=n.layout[t].tabs.find(t=>t.content?.kind===e.kind);if(!r)continue;let i={kind:`dock`,side:t,tabId:r.id};r.content?.kind===`subagents`&&r.content.subagentId?(b(i),b({...i,detail:{kind:`subagent`,id:r.content.subagentId}})):b(i);break}},[n.layout,n.reveal,p,t,b]);let S=(0,H.useCallback)((e,t)=>{n.dispatch({type:`activate`,side:e,tabId:t});let r=`${e}:${t}`,i=n.layout[e].tabs.find(e=>e.id===t),a=i?.content?.kind===`subagents`&&i.content.subagentId?{kind:`subagent`,id:i.content.subagentId}:void 0,o=v.current[r]??a,s={kind:`dock`,side:e,tabId:t};o?(b(s),b({...s,detail:o})):b(s)},[n,b]),C=(0,H.useCallback)(e=>{x.kind===`dock`&&(v.current[`${x.side}:${x.tabId}`]=e,b({...x,detail:e}))},[x,b]),w=(0,H.useCallback)(()=>{x.kind===`dock`&&(v.current[`${x.side}:${x.tabId}`]=void 0,x.detail?window.history.back():b({kind:`dock`,side:x.side,tabId:x.tabId},!0))},[x,b]),T=c.find(e=>e.id===t),E=T?ns(T):t,D=(0,H.useRef)(0),O=(0,H.useCallback)(e=>{let n=T?.attention;!n||n.version<=D.current||e<n.observedSeq||(D.current=n.version,l({type:`acknowledge`,sessionId:t,throughVersion:n.version}).then(e=>{e!==!0&&D.current===n.version&&(D.current=Math.max(0,n.version-1))}))},[l,t,T?.attention]),k=(0,U.jsxs)(`section`,{"data-pane":``,className:z(`relative grid min-h-0 min-w-0 bg-background`,i?`grid-rows-[auto_minmax(0,1fr)]`:`grid-rows-[minmax(0,1fr)]`),"aria-label":`Agent Session ${E}`,children:[i?(0,U.jsx)(Kj,{query:d,onQueryChange:f,onClose:()=>{f(``),a()}}):null,(0,U.jsx)(oA,{value:e=>n.dispatch({type:`open-subagents`,subagentId:e}),children:(0,U.jsx)(rM,{view:e,query:d,visible:d===``&&(!p||x.kind===`transcript`&&!m),onObserved:O})}),(0,U.jsx)(pD,{id:t,chrome:s,actions:u,drafts:o,unavailable:s.capabilities?s.capabilities.models.length===0?`No confirmed model capabilities are available. Revive or restart the Backend Session to retry.`:void 0:`Loading model capabilities before agent work can start…`,authorisingSummary:BM(e,s),onShowSubagents:()=>n.dispatch({type:`open-subagents`})})]}),A=n.layout.bottom,j=n.layout.right,M=!A.minimised,N=!j.minimised,P=x.kind===`dock`?x:void 0;return(0,U.jsxs)(`div`,{className:z(`grid min-h-0 min-w-0`,p?`mobile-view-height grid-cols-[minmax(0,1fr)] grid-rows-[auto_auto_minmax(0,1fr)]`:`grid-rows-[auto_minmax(0,1fr)]`),children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(pl,{sessionId:t,title:E,chrome:s,docks:p?void 0:n}),(0,U.jsx)(bo,{sessionId:t})]}),p?(0,U.jsx)(HM,{layout:n.layout,selected:x,shells:r,onTranscript:()=>b(fs),onSelect:S,onNew:()=>{let e=crypto.randomUUID();n.dispatch({type:`add-tab`,side:`right`,tabId:e}),b({kind:`dock`,side:`right`,tabId:e})},onClose:(e,t)=>{x.kind===`dock`&&x.side===e&&x.tabId===t&&b(fs,!0),delete v.current[`${e}:${t}`],n.dispatch({type:`close-tab`,side:e,tabId:t})}}):null,(0,U.jsxs)(`div`,{"data-dock-frame":``,className:`grid min-h-0 min-w-0 overflow-hidden`,style:{"--dock-bottom":`${A.size}px`,"--dock-right":`${j.size}px`,gridTemplateColumns:p||!N?`minmax(0,1fr)`:`minmax(0,1fr) var(--dock-right)`,gridTemplateRows:p?`minmax(0,1fr)`:M?`minmax(0,1fr) var(--dock-bottom)`:`minmax(0,1fr) 0px`},children:[(0,U.jsx)(`div`,{className:z(`col-start-1 row-start-1 grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] overflow-hidden`,p&&x.kind!==`transcript`&&`hidden`),children:k}),(0,U.jsx)(Hj,{side:`bottom`,dock:A,sessionId:t,shells:r,dispatch:n.dispatch,mobile:p,visible:p?P?.side===`bottom`:M,mobileNavigation:p&&P?.side===`bottom`?{tabId:P.tabId,detail:P.detail,onDetail:C,onBackDetail:w}:void 0}),(0,U.jsx)(Hj,{side:`right`,dock:j,sessionId:t,shells:r,dispatch:n.dispatch,mobile:p,visible:p?P?.side===`right`:N,mobileNavigation:p&&P?.side===`right`?{tabId:P.tabId,detail:P.detail,onDetail:C,onBackDetail:w}:void 0})]})]})}function HM({layout:e,selected:t,shells:n,onTranscript:r,onSelect:i,onNew:a,onClose:o}){return(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 border-b bg-card px-1.5 py-1`,"aria-label":`Agent Session views`,children:[(0,U.jsxs)(`div`,{role:`tablist`,"aria-label":`Agent Session content`,className:`flex min-w-0 flex-1 gap-1 overflow-x-auto`,children:[(0,U.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t.kind===`transcript`,onClick:r,className:z(`flex min-h-10 shrink-0 items-center gap-1.5 rounded-xl px-3 text-xs font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,t.kind===`transcript`?`bg-muted text-foreground`:`text-muted-foreground`),children:[(0,U.jsx)(Bo,{className:`size-4`,"aria-hidden":!0}),`Transcript`]}),[`bottom`,`right`].flatMap(n=>e[n].tabs.map(r=>{let a=t.kind===`dock`&&t.side===n&&t.tabId===r.id,s=ka(e[n],r.id);return(0,U.jsxs)(`div`,{className:z(`flex min-h-10 shrink-0 items-center rounded-xl pr-0.5 pl-3 text-xs`,a?`bg-muted text-foreground`:`text-muted-foreground`),children:[(0,U.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a,className:`max-w-36 truncate py-2 font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>i(n,r.id),title:`${s} · ${n} Dock`,children:s}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-sm`,className:`rounded-xl`,onClick:()=>o(n,r.id),title:r.content?.kind===`shell`?`Close this tab — ends its Shell`:`Close this tab`,"aria-label":`Close ${s}${r.content?.kind===`shell`?` — ends its Shell`:``}`,children:(0,U.jsx)(ts,{"aria-hidden":!0})})]},`${n}:${r.id}`)}))]}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-lg`,className:`shrink-0 rounded-xl`,onClick:a,"aria-label":`New tab in the right Dock`,title:n?`New tab`:`New Git, Workflows, or Agents tab`,children:(0,U.jsx)(Ko,{"aria-hidden":!0})})]})}function UM({backend:e,className:t}){let n=z(`size-3! shrink-0`,t);return e===`claude`?(0,U.jsx)(GM,{className:n}):e===`pi`?(0,U.jsx)(WM,{className:n,children:`π`}):e===`fake`?(0,U.jsx)(wo,{"aria-hidden":!0,className:n}):(0,U.jsx)(WM,{className:n,children:e.slice(0,1).toUpperCase()})}function WM({className:e,children:t}){return(0,U.jsx)(`span`,{"aria-hidden":!0,className:z(`inline-flex items-center justify-center leading-none`,e),children:t})}function GM({className:e}){return(0,U.jsx)(`svg`,{"aria-hidden":!0,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,U.jsx)(`path`,{d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`})})}function KM(e){let t=cA(),{isMobile:n,setOpenMobile:r}=SM(),i=()=>{n&&r(!1)},a={...e,onFocus:t=>{e.onFocus(t),i()},onNew:()=>{e.onNew(),i()},onOpenSettings:()=>{e.onOpenSettings(),i()}},o=new Map(Sr.map(e=>[e,[]]));for(let t of e.sessions)o.get(Cr(t))?.push(t);let s=Sr.map(e=>({group:e,sessions:o.get(e)})).filter(({sessions:e})=>e.length>0),c=s.find(({group:e})=>e===`filed-away`),l=e.sessions.find(t=>t.id===e.cursorId),u=l?Cr(l):void 0,d=u===`filed-away`,[f,p]=(0,H.useState)(!1),m=(0,H.useRef)(null),h=(0,H.useRef)(!1);return(0,H.useLayoutEffect)(()=>{let e=m.current;if(!e)return;let t=document.activeElement,n=e.querySelector(`[data-cursor="true"]`),r=n?.closest(`[data-sidebar="menu-item"]`);h.current&&n&&!r?.contains(t)&&n.focus()},[e.cursorId,u]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(JM,{onNew:a.onNew}),(0,U.jsxs)(AM,{ref:m,className:`transcript-scroller gap-0`,onKeyDown:qM,onFocusCapture:e=>{h.current=e.target.closest(`[data-sidebar="menu-item"]`)!==null},onBlurCapture:e=>{e.target.isConnected&&(h.current=!1)},children:[s.filter(({group:e})=>e!==`filed-away`).map(({group:e,sessions:n})=>(0,U.jsxs)(jM,{className:`p-0`,children:[(0,U.jsxs)(MM,{className:`select-none text-muted-foreground`,children:[wr(e),` · `,n.length]}),(0,U.jsx)(NM,{children:(0,U.jsx)(YM,{...a,label:`${wr(e)} Agent Sessions`,sessions:n,now:t})})]},e)),c?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(kM,{className:`mx-0`}),(0,U.jsx)(QM,{count:c.sessions.length,open:f||d,onOpenChange:p,children:(0,U.jsx)(YM,{...a,label:`Filed away Agent Sessions`,sessions:c.sessions,now:t})})]}):null,e.sessions.length===0?(0,U.jsx)(`p`,{className:`px-3 py-4 text-sm text-muted-foreground`,children:`No Agent Sessions yet.`}):null]}),(0,U.jsx)($M,{link:e.link,onOpenSettings:a.onOpenSettings})]})}function qM(e){let t=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0;if(t===0)return;let n=e.target;if(!(n instanceof HTMLElement))return;let r=n.closest(`[data-sidebar="menu-item"]`);if(!r)return;let i=[...r.querySelectorAll(`[data-sidebar="menu-button"], [data-sidebar="menu-action"]`)],a=i.indexOf(n),o=a<0?void 0:i[a+t];o&&(e.preventDefault(),o.focus())}function JM({onNew:e}){return(0,U.jsx)(DM,{className:`border-b border-sidebar-border`,children:(0,U.jsxs)(B,{variant:`outline`,size:`sm`,className:`w-full justify-start gap-2`,onClick:e,children:[(0,U.jsx)(Ko,{"aria-hidden":!0,className:`size-4 shrink-0`}),`New Agent Session`]})})}function YM({sessions:e,now:t,label:n,...r}){return(0,U.jsx)(PM,{className:`gap-0`,"aria-label":n,children:e.map(e=>(0,U.jsx)(XM,{summary:e,now:t,status:(e.id===r.focusedId?r.focusedStatus:void 0)??e.status,selected:e.id===r.focusedId,cursored:e.id===r.cursorId,onFocus:r.onFocus,onSettle:r.onSettle},e.id))})}function XM({summary:e,now:t,status:n,selected:r,cursored:i,onFocus:a,onSettle:o}){let s=i?0:-1;return(0,U.jsxs)(FM,{children:[(0,U.jsxs)(LM,{size:`lg`,isActive:r,"aria-current":r?`true`:void 0,"data-cursor":i?`true`:void 0,tabIndex:s,onClick:()=>a(e.id),className:z(`h-auto rounded-none py-1.5 pr-8`,`border-l-2 border-l-transparent`,r&&`border-l-primary`,i&&`outline -outline-offset-1 outline-sidebar-ring`),children:[(0,U.jsx)(Ts,{status:n,working:Tr({...e,status:n})}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,U.jsx)(`span`,{className:z(`min-w-0 flex-1 truncate text-sm`,e.attention&&`font-semibold`),children:ns(e)})}),e.outputPreview?(0,U.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.outputPreview}):null,(0,U.jsx)(ZM,{summary:e}),e.attention?(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,children:e.attention.group===`needs-input`?`!`:`●`}),(0,U.jsx)(`span`,{children:e.attention.reason}),(0,U.jsx)(`span`,{className:`ml-auto shrink-0 text-muted-foreground`,children:jl(e.attention.at,t)})]}):null,(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`sr-only`,children:Pl({...e,status:n})}),(0,U.jsx)(UM,{backend:e.backend}),(0,U.jsx)(`span`,{className:`sr-only`,children:e.backend}),(0,U.jsx)(`span`,{className:`truncate`,children:Ss(e.scope,e.worktree)}),e.attention?null:(0,U.jsx)(`span`,{className:`ml-auto shrink-0`,children:jl(e.restingAt,t)})]})]})]}),Er(n)?(0,U.jsxs)(ul,{children:[(0,U.jsxs)(dl,{render:(0,U.jsx)(RM,{showOnHover:!0,tabIndex:s,onClick:()=>o(e.id)}),children:[(0,U.jsx)(ko,{"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Settle`})]}),(0,U.jsx)(fl,{children:`Settle`})]}):null]})}function ZM({summary:e}){if(!e.branch)return null;let t=e.worktree?Po:Fo;return(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(t,{"aria-hidden":!0,className:`size-3! shrink-0`}),(0,U.jsxs)(`span`,{className:`sr-only`,children:[ww(e),e.branch.detached?`, detached at`:``]}),(0,U.jsx)(`span`,{className:`truncate font-mono`,children:e.branch.name})]})}function QM({count:e,open:t,onOpenChange:n,children:r}){return(0,U.jsx)(jM,{className:`p-0`,children:(0,U.jsxs)(`details`,{open:t,onToggle:e=>n(e.currentTarget.open),children:[(0,U.jsxs)(MM,{render:(0,U.jsx)(`summary`,{className:`cursor-default gap-1 text-muted-foreground select-none`}),children:[(0,U.jsx)(dn,{"aria-hidden":!0,className:z(`transition-transform`,!t&&`-rotate-90`)}),`Filed away · `,e]}),(0,U.jsx)(NM,{className:`opacity-60`,children:r})]})})}function $M({link:e,onOpenSettings:t}){return(0,U.jsxs)(OM,{className:`flex-row items-center gap-2 border-t border-sidebar-border py-1.5`,children:[(0,U.jsxs)(ul,{children:[(0,U.jsxs)(dl,{render:(0,U.jsx)(B,{size:`icon`,variant:`ghost`,className:`-ml-1 size-6 shrink-0`,onClick:()=>t()}),children:[(0,U.jsx)(Yo,{"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Settings`})]}),(0,U.jsx)(fl,{children:`Settings`})]}),(0,U.jsx)(tN,{link:e})]})}function eN({children:e}){return(0,U.jsx)(`kbd`,{className:`rounded-sm border bg-muted px-1 font-mono text-xs text-muted-foreground`,children:e})}function tN({link:e}){return e===void 0?null:(0,U.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:z(`inline-block size-1.5 rounded-full`,e===`gone`?`bg-destructive`:e===`live`?`bg-current`:`border border-current`)}),e]})}var nN=new Set([`new-agent-session`,`command-palette`,`toggle-rail`,`keyboard-settings`]);function rN(e,t){let n=iN(e,t);return n===void 0||t.view!==`settings`?n:n===`blur-or-abort`?`leave-settings`:nN.has(n)?n:void 0}function iN(e,t){if(e.ctrlKey||e.metaKey)return e.repeat?void 0:e.key===`k`||e.key===`K`?`command-palette`:e.key===`b`||e.key===`B`?`toggle-rail`:e.key===`f`||e.key===`F`?`search`:void 0;if(e.key===`Escape`)return`blur-or-abort`;if(!t.typing){switch(e.key){case`j`:case`ArrowDown`:return`sidebar-next`;case`k`:case`ArrowUp`:return`sidebar-previous`}if(!e.repeat)switch(e.key){case`Home`:return`sidebar-first`;case`End`:return`sidebar-last`;case`n`:return`new-agent-session`;case`Enter`:return`focus-pane`;case`m`:return`model-picker`;case`e`:return`effort-picker`;case`s`:return`settle`;case"`":return`toggle-bottom-dock`;case`~`:return`toggle-right-dock`;case`?`:return`keyboard-settings`;default:return}}}var aN=new Set([`input`,`textarea`,`select`]);function oN(e,t,n,r){return aN.has(e.toLowerCase())||t||n===`textbox`||r}function sN({handlers:e,view:t,children:n}){return(0,H.useEffect)(()=>{let n=n=>{let r=n.target,i=r!==null&&oN(r.tagName,r.isContentEditable,r.getAttribute(`role`)??void 0,r.closest(`[data-shell-pane]`)!==null);if(n.defaultPrevented)return;let a=rN({key:n.key,ctrlKey:n.ctrlKey,metaKey:n.metaKey,shiftKey:n.shiftKey,repeat:n.repeat},{typing:i,view:t});if(a===void 0)return;if(i&&(a===`blur-or-abort`||a===`leave-settings`)){r?.blur(),n.preventDefault();return}let o=e[a];o&&(n.preventDefault(),o())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),(0,U.jsx)(U.Fragment,{children:n})}function cN(e,t){return t??(e.includes(`claude`)?`claude`:e[0])}var lN={s:1e3,m:6e4,h:36e5,d:864e5};function uN(e){let t=/^\s*(\d+(?:\.\d+)?)\s*(s|m|h|d)\s*$/.exec(e),n=t?.[1],r=t?.[2];if(!n||!r)return;let i=lN[r];if(i!==void 0)return Number(n)*i}function dN(){let[e,t]=(0,H.useState)(void 0),[n,r]=(0,H.useState)(!0),[i,a]=(0,H.useState)(void 0),o=async e=>{r(!0),a(void 0);try{let n=await kt(`/api/models${e?`?refresh=1`:``}`);if(!n.ok){a(`Model capability discovery failed (${n.status}).`);return}t(await n.json())}catch{a(`Could not reach the Session Host to confirm model Effort support.`)}finally{r(!1)}};return(0,H.useEffect)(()=>{o(!1)},[]),{catalogue:e,loading:n,problem:i,refresh:()=>o(!0)}}function fN(e,t){let n=(0,H.useRef)(Promise.resolve([]));return(0,H.useEffect)(()=>{n.current=e===void 0||e===``||t===``?Promise.resolve([]):pN(e,t)},[e,t]),(0,H.useCallback)(()=>n.current,[])}async function pN(e,t){try{let n=await kt(`/api/skills?scope=${encodeURIComponent(e)}&backend=${encodeURIComponent(t)}`);if(!n.ok)return[];let r=await n.json();return r.scope===e?r.skills:[]}catch{return[]}}function mN(e,t,n){let r=e?.find(e=>e.backend===n)?.models??[];if(r.length===0)return;let i=t?.[n];return r.find(e=>e.id===i)??r[0]}var hN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),gN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=hN(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),_N=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=hN(),n=gN(),r=hN();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=gN();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
107
+ const term = new Terminal({ ghostty });`)}var Fj=`/assets/ghostty-vt-DOMeXDrv.wasm`,Ij;function Lj(){return Ij??=lj.load(Fj),Ij}function Rj({sessionId:e,shellId:t,onOpened:n,onStatus:r}){let i=(0,H.useRef)(null),[a,o]=(0,H.useState)({state:`connecting`}),{config:s}=Dt(),c=s.fonts?.monospace??oe.monospace,l=(0,H.useRef)({shellId:t,onOpened:n,onStatus:r});return l.current={shellId:t,onOpened:n,onStatus:r},(0,H.useEffect)(()=>{let t=i.current;if(!t)return;let n=e=>{o(e),l.current.onStatus(e)},r=!1,a,s;return(async()=>{let[i]=await Promise.all([Lj(),u(c)]);if(r)return;a=new Oj({ghostty:i,fontSize:13,fontFamily:c,theme:zj(t),cursorBlink:!0}),a.open(t);let o=new Nj;a.loadAddon(o),o.fit(),o.observeResize();let d=l.current.shellId;if(d===void 0){try{d=(await Ia(e,a.cols,a.rows)).id}catch(e){r||n({state:`gone`,why:e instanceof Error?e.message:String(e)});return}if(r){Ra(d);return}l.current.onOpened(d)}s=za(d,{output:e=>a?.write(e),ready:()=>n({state:`live`}),exit:e=>n({state:`gone`,why:e===0?`exited`:`exited (${e??`signal`})`}),closed:()=>n({state:`gone`,why:`disconnected`})}),a.onData(e=>s?.send(e)),a.onResize(({cols:e,rows:t})=>s?.resize(e,t)),s.resize(a.cols,a.rows),a.focus()})(),()=>{r=!0,s?.close(),a?.dispose()}},[e,c]),(0,U.jsxs)(`div`,{"data-shell-pane":``,className:`relative min-h-0 overflow-hidden bg-background`,"aria-label":`Shell`,children:[(0,U.jsx)(`div`,{ref:i,className:`size-full`}),a.state===`live`?null:(0,U.jsx)(`span`,{className:`pointer-events-none absolute top-1 right-2 text-xs text-muted-foreground`,children:a.state===`connecting`?`connecting…`:a.why})]})}function zj(e){let t=getComputedStyle(e),n=(e,n)=>{let r=t.getPropertyValue(e).trim();return r?Bj(r)??n:n};return{background:n(`--background`,`#0a0a0a`),foreground:n(`--foreground`,`#fafafa`),cursor:n(`--foreground`,`#fafafa`)}}function Bj(e){let t=document.createElement(`canvas`);t.width=1,t.height=1;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n||(n.fillStyle=e,n.fillStyle===`#000000`&&!/^(#000000|black|rgb\(0, ?0, ?0\))$/i.test(e)))return;n.fillRect(0,0,1,1);let[r,i,a]=n.getImageData(0,0,1,1).data;return`#${[r,i,a].map(e=>(e??0).toString(16).padStart(2,`0`)).join(``)}`}var Vj=(0,H.lazy)(()=>nj(()=>import(`./workflows-pane-DPXGg0na.js`),__vite__mapDeps([0,1,2,3,4,5])));function Hj({side:e,dock:t,sessionId:n,shells:r,dispatch:i,visible:a=!0,mobile:o=!1,mobileNavigation:s}){let c=(0,H.useRef)(null),[l,u]=(0,H.useState)({}),d=(0,H.useCallback)((e,t)=>{u(n=>({...n,[e]:t}))},[]),f=s?.tabId??t.activeId,p=t.tabs.find(e=>e.id===f),m=e===`bottom`?`bottom Dock`:`right Dock`,h=(t,n)=>i({type:`resize`,side:e,px:t,...n===void 0?{}:{available:n}});return(0,U.jsxs)(`section`,{ref:c,"data-dock":e,"aria-label":m,className:z(`relative min-h-0 min-w-0 bg-background`,a?`grid`:`hidden`,o?`col-start-1 row-start-1 grid-rows-[minmax(0,1fr)]`:e===`bottom`?`col-start-1 row-start-2 grid-rows-[auto_minmax(0,1fr)] border-t`:`col-start-2 row-span-2 row-start-1 grid-rows-[auto_minmax(0,1fr)] border-l`),children:[o?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yD,{side:e,size:t.size,onResize:h,onNudge:(n,r)=>{let i=c.current?.closest(`[data-dock-frame]`),a=i==null?void 0:e===`bottom`?i.clientHeight:i.clientWidth;h(t.size+n*sa(r),a)}}),(0,U.jsxs)(`div`,{className:`flex h-9 min-w-0 items-center gap-1 border-b px-1.5`,children:[(0,U.jsx)(`div`,{role:`tablist`,"aria-label":`${m} tabs`,"aria-orientation":`horizontal`,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto`,children:t.tabs.map(n=>{let r=l[n.id];return(0,U.jsxs)(`div`,{className:z(`flex shrink-0 items-center gap-0.5 rounded-2xl pr-0.5 pl-2.5 text-xs`,n.id===t.activeId?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50`),children:[(0,U.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.id===t.activeId,onClick:()=>i({type:`activate`,side:e,tabId:n.id}),className:`max-w-40 truncate py-1 outline-none`,children:[ka(t,n.id),r?.state===`gone`?(0,U.jsx)(`span`,{className:`ml-1.5 text-muted-foreground`,children:r.why}):null]}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`rounded-xl`,onClick:()=>i({type:`close-tab`,side:e,tabId:n.id}),title:n.content?.kind===`shell`?`Close this tab — ends its Shell`:`Close this tab`,"aria-label":`Close ${ka(t,n.id)}${n.content?.kind===`shell`?` — ends its Shell`:``}`,children:(0,U.jsx)(ts,{"aria-hidden":!0})})]},n.id)})}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 rounded-xl`,onClick:()=>i({type:`add-tab`,side:e}),title:`New tab`,"aria-label":`New tab in the ${m}`,children:(0,U.jsx)(Ko,{"aria-hidden":!0})}),(0,U.jsxs)(ul,{children:[(0,U.jsx)(dl,{render:(0,U.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 rounded-xl`,onClick:()=>i({type:`toggle`,side:e}),"aria-label":`Minimise the ${m}`}),children:e===`bottom`?(0,U.jsx)(Vo,{"aria-hidden":!0}):(0,U.jsx)(Wo,{"aria-hidden":!0})}),(0,U.jsx)(fl,{children:`Minimise — Shells keep running`})]})]})]}),(0,U.jsx)(`div`,{className:`relative min-h-0 min-w-0 overflow-hidden`,children:t.tabs.length===0?(0,U.jsx)(Wj,{onChooseWorkflows:()=>i({type:`open-workflows`,side:e}),onChooseGit:()=>i({type:`open-git`,side:e}),onChooseSubagents:()=>i({type:`open-subagents`,side:e}),...r?{onChooseShell:()=>i({type:`open-shell`,side:e})}:{}}):t.tabs.map(t=>(0,U.jsx)(Uj,{side:e,tab:t,active:t.id===p?.id,visible:a&&t.id===p?.id,sessionId:n,shells:r,dispatch:i,onStatus:e=>d(t.id,e),mobileNavigation:s?.tabId===t.id?s:void 0},t.id))})]})}function Uj({side:e,tab:t,active:n,visible:r,sessionId:i,shells:a,dispatch:o,onStatus:s,mobileNavigation:c}){let l=t.content;return(0,U.jsx)(H.Activity,{mode:r?`visible`:`hidden`,children:(0,U.jsx)(`div`,{role:`tabpanel`,"aria-hidden":!r,className:`absolute inset-0 flex min-h-0 min-w-0 flex-col overflow-hidden`,children:l?.kind===`workflows`?(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading workflows…`}),children:(0,U.jsx)(Vj,{sessionId:i,placement:e,mobileNavigation:c?{stepId:c.detail?.kind===`workflow-step`?c.detail.id:``,onSelect:e=>c.onDetail({kind:`workflow-step`,id:e}),onBack:c.onBackDetail}:void 0},i)}):l?.kind===`git`?(0,U.jsx)(rA,{sessionId:i},`${i}-${t.id}`):l?.kind===`subagents`?(0,U.jsx)(qA,{sessionId:i,subagentId:c?c.detail?.kind===`subagent`?c.detail.id:void 0:l.subagentId,onSelect:n=>{o({type:`select-subagent`,side:e,tabId:t.id,...n?{subagentId:n}:{}}),c&&(n?c.onDetail({kind:`subagent`,id:n}):c.onBackDetail())}},t.id):l?.kind===`shell`?n&&r?(0,U.jsx)(Rj,{sessionId:i,shellId:l.shellId,onOpened:n=>o({type:`remember-shell`,side:e,tabId:t.id,shellId:n}),onStatus:s},t.id):null:(0,U.jsx)(Wj,{onChooseWorkflows:()=>o({type:`open-workflows`,side:e,tabId:t.id}),onChooseGit:()=>o({type:`open-git`,side:e,tabId:t.id}),onChooseSubagents:()=>o({type:`open-subagents`,side:e,tabId:t.id}),...a?{onChooseShell:()=>o({type:`open-shell`,side:e,tabId:t.id})}:{}})})})}function Wj({onChooseWorkflows:e,onChooseShell:t,onChooseSubagents:n,onChooseGit:r}){return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-wrap items-center justify-center gap-2 overflow-auto p-4`,children:[t===void 0?null:(0,U.jsxs)(B,{variant:`outline`,size:`sm`,className:`max-lg:min-h-10`,onClick:t,children:[(0,U.jsx)(Qo,{"aria-hidden":!0,"data-icon":`inline-start`}),`Shell`]}),(0,U.jsx)(B,{variant:`outline`,size:`sm`,className:`max-lg:min-h-10`,onClick:r,children:`Git`}),(0,U.jsx)(B,{variant:`outline`,size:`sm`,className:`max-lg:min-h-10`,onClick:e,children:`Workflows`}),(0,U.jsxs)(B,{variant:`outline`,size:`sm`,className:`max-lg:min-h-10`,onClick:n,children:[(0,U.jsx)(To,{"aria-hidden":!0,"data-icon":`inline-start`}),`Agents`]})]})}var Gj=120;function Kj({query:e,onQueryChange:t,onClose:n}){let[r,i]=(0,H.useState)(e),a=(0,H.useRef)(e),o=(0,H.useRef)(null);return(0,H.useEffect)(()=>{o.current?.select()},[]),(0,H.useEffect)(()=>{let e=r.trim().toLowerCase();if(e===a.current)return;let n=setTimeout(()=>{a.current=e,t(e)},Gj);return()=>clearTimeout(n)},[r,t]),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-card px-3 py-1`,children:[(0,U.jsx)(Jo,{className:`size-4 shrink-0 opacity-50`,"aria-hidden":!0}),(0,U.jsx)(et,{ref:o,"data-transcript-search":``,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&n()},placeholder:`Find in this Presentation Transcript`,"aria-label":`Find in this Presentation Transcript`,className:`h-8 border-0 bg-transparent px-0 shadow-none dark:bg-transparent focus-visible:border-0 focus-visible:ring-0`}),(0,U.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close search`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(ts,{className:`size-4`,"aria-hidden":!0})})]})}var qj=`tool:`,Jj=`thinking:`,Yj=3,Xj=e=>e.startsWith(qj),Zj=e=>Xj(e)||e.startsWith(Jj);function Qj(e,t=Yj){let n=[],r=[],i=()=>{if(r.length>=t&&r.some(Xj))n.push({kind:`chain`,keys:r});else for(let e of r)n.push({kind:`entry`,key:e});r=[]};for(let t of e){if(Zj(t)){r.push(t);continue}i(),n.push({kind:`entry`,key:t})}return i(),n}function $j(e,t=40){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function eM({view:e,keys:t,children:n}){let r=(0,H.useMemo)(()=>t.filter(Xj),[t]),i=ni(e,r[r.length-1]??``),a=tM(e,t),o=i?.kind===`tool`?as(i.input):void 0;return(0,U.jsx)(`div`,{className:`py-0.5`,children:(0,U.jsxs)(`details`,{className:`rounded-lg border text-foreground`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-default items-center gap-2 px-3 py-2 select-none`,children:[(0,U.jsx)(Lo,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,U.jsxs)(`span`,{className:`shrink-0 text-sm text-muted-foreground`,children:[r.length,` tools`]}),i?.kind===`tool`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,U.jsx)(kA,{status:i.status}),(0,U.jsx)(`span`,{className:`shrink-0 font-mono text-sm text-foreground`,children:i.name}),o===void 0?null:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:o})]}):null,a===0?null:(0,U.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs text-destructive`,children:[a,` failed`]})]}),(0,U.jsx)(`div`,{className:`border-t px-3 py-1`,children:n})]})})}function tM(e,t){let n=(0,H.useCallback)(t=>e.subscribeTranscript(t),[e]),r=(0,H.useCallback)(()=>{let n=0;for(let r of t){let t=e.getEntry(r);t?.kind===`tool`&&t.status===`error`&&(n+=1)}return n},[e,t]);return(0,H.useSyncExternalStore)(n,r)}var nM=400;function rM({view:e,query:t,visible:n=!0,onObserved:r}){let i=ti(e),a=sM(e,i,t),o=(0,H.useCallback)(t=>e.getEntry(t),[e]),s=(0,H.useMemo)(()=>GA(a,o),[a,o]),[c,l]=(0,H.useState)(!1),u=(0,H.useMemo)(()=>c||s.length<=nM?s:s.slice(-400),[c,s]),d=s.length-u.length,f=(0,H.useMemo)(()=>Qj(u),[u]),p=(0,H.useRef)(null),m=(0,H.useRef)(!0),[h,g]=(0,H.useState)(!0),_=(0,H.useCallback)(e=>{!n||!m.current||document.hidden||!document.hasFocus()||r?.(e)},[r,n]),v=(0,H.useRef)(_);v.current=_;let y=(0,H.useRef)([0,0]),b=(0,H.useCallback)((t=e.getLastSeq())=>{cancelAnimationFrame(y.current[0]),cancelAnimationFrame(y.current[1]),y.current[0]=requestAnimationFrame(()=>{y.current[1]=requestAnimationFrame(()=>v.current(t))})},[e]);(0,H.useEffect)(()=>b()),(0,H.useEffect)(()=>()=>{cancelAnimationFrame(y.current[0]),cancelAnimationFrame(y.current[1])},[]),(0,H.useEffect)(()=>{let e=()=>b();return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[b]),(0,H.useEffect)(()=>{let e=p.current;if(!e)return;let t,n=()=>{m.current=$j(e),!t&&(t=setTimeout(()=>{t=void 0,g(m.current),m.current&&b()},150))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{e.removeEventListener(`scroll`,n),t&&clearTimeout(t)}},[b]),(0,H.useEffect)(()=>{let e=p.current;if(!e)return;let t=new ResizeObserver(()=>{m.current&&(e.scrollTop=e.scrollHeight)});return t.observe(e),()=>t.disconnect()},[]),(0,H.useLayoutEffect)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight,m.current=!0,g(!0))},[t,e]);let x=(0,H.useCallback)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight,m.current=!0,g(!0),b())},[b]);return(0,U.jsxs)(`div`,{className:`relative min-h-0 min-w-0`,children:[(0,U.jsx)(`div`,{ref:p,className:`transcript-scroller h-full px-3 pt-2 pb-[calc(var(--composer-inset,0px)+1.5rem)]`,children:(0,U.jsxs)(`div`,{className:`pane-measure`,children:[d>0?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`mb-2 flex w-full items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,U.jsx)(`span`,{className:`h-px flex-1 bg-border`,"aria-hidden":!0}),d.toLocaleString(),` earlier entries · show all`,(0,U.jsx)(`span`,{className:`h-px flex-1 bg-border`,"aria-hidden":!0})]}):null,f.map(n=>n.kind===`entry`?(0,U.jsx)(iM,{view:e,entryKey:n.key,query:t},n.key):(0,U.jsx)(eM,{view:e,keys:n.keys,children:n.keys.map(n=>(0,U.jsx)(iM,{view:e,entryKey:n,query:t},n))},n.keys[0])),s.length===0?(0,U.jsx)(`p`,{className:`px-1 py-4 text-sm text-muted-foreground`,children:i.length===0?`Nothing here yet.`:`No Entry matches.`}):null,(0,U.jsx)(aM,{view:e,scroller:p,pinned:m,scheduleObserved:b})]})}),h?null:(0,U.jsx)(oM,{onClick:x})]})}function iM({view:e,entryKey:t,query:n}){let r=ni(e,t);return r?(0,U.jsx)(gA,{entry:r,query:n,sessionId:e.sessionId}):null}function aM({view:e,scroller:t,pinned:n,scheduleObserved:r}){let[,i]=(0,H.useState)(0);return(0,H.useEffect)(()=>e.subscribeTranscript(()=>i(e=>e+1)),[e]),(0,H.useLayoutEffect)(()=>{let i=t.current;i&&n.current&&(i.scrollTop=i.scrollHeight),r(e.getLastSeq())}),null}function oM({onClick:e}){return(0,U.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Jump to latest`,className:`-translate-x-1/2 absolute bottom-[calc(var(--composer-inset,0px)+1.5rem)] left-1/2 rounded-full border bg-popover p-2 text-popover-foreground shadow-md transition-colors hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(xo,{className:`size-4`})})}function sM(e,t,n){let r=(0,H.useMemo)(()=>Ok(),[]),[i,a]=(0,H.useState)(t);return(0,H.useEffect)(()=>{if(n===``)return;let t=()=>{let t=e.getKeys().filter(t=>{let i=e.getEntry(t);return i!==void 0&&r.matches(i,n)});a(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)};return t(),e.subscribeTranscript(t)},[e,n,r]),n===``?t:i}function cM({className:e,orientation:t=`horizontal`,...n}){return(0,U.jsx)(Pc,{"data-slot":`separator`,orientation:t,className:z(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}function lM({...e}){return(0,U.jsx)(yE,{"data-slot":`sheet`,...e})}function uM({...e}){return(0,U.jsx)(Us,{"data-slot":`sheet-portal`,...e})}function dM({className:e,...t}){return(0,U.jsx)(Is,{"data-slot":`sheet-overlay`,className:z(`fixed inset-0 z-50 bg-black/30 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-sm`,e),...t})}function fM({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,U.jsxs)(uM,{children:[(0,U.jsx)(dM,{}),(0,U.jsxs)(Hs,{"data-slot":`sheet-content`,"data-side":n,className:z(`fixed z-50 flex flex-col bg-popover bg-clip-padding text-sm text-popover-foreground shadow-xl transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm`,e),...i,children:[t,r&&(0,U.jsxs)(Ls,{"data-slot":`sheet-close`,render:(0,U.jsx)(B,{variant:`ghost`,className:`absolute top-4 right-4 bg-secondary`,size:`icon-sm`}),children:[(0,U.jsx)(ts,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function pM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sheet-header`,className:z(`flex flex-col gap-1.5 p-6`,e),...t})}function mM({className:e,...t}){return(0,U.jsx)(Ws,{"data-slot":`sheet-title`,className:z(`font-heading text-base font-medium text-foreground`,e),...t})}function hM({className:e,...t}){return(0,U.jsx)(Rs,{"data-slot":`sheet-description`,className:z(`text-sm text-muted-foreground`,e),...t})}var gM=`sidebar_state`,_M=604800,vM=`16rem`,yM=`18rem`,bM=`3rem`,xM=H.createContext(null);function SM(){let e=H.useContext(xM);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function CM({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=ds(),[c,l]=H.useState(!1),[u,d]=H.useState(e),f=t??u,p=H.useCallback(e=>{let t=typeof e==`function`?e(f):e;n?n(t):d(t),document.cookie=`${gM}=${t}; path=/; max-age=${_M}`},[n,f]),m=H.useCallback(()=>s?l(e=>!e):p(e=>!e),[s,p,l]),h=f?`expanded`:`collapsed`,g=H.useMemo(()=>({state:h,open:f,setOpen:p,isMobile:s,openMobile:c,setOpenMobile:l,toggleSidebar:m}),[h,f,p,s,c,l,m]);return(0,U.jsx)(xM.Provider,{value:g,children:(0,U.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":vM,"--sidebar-width-icon":bM,...i},className:z(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})}function wM({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,dir:a,...o}){let{isMobile:s,state:c,openMobile:l,setOpenMobile:u}=SM();return n===`none`?(0,U.jsx)(`div`,{"data-slot":`sidebar`,className:z(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),...o,children:i}):s?(0,U.jsx)(lM,{open:l,onOpenChange:u,...o,children:(0,U.jsxs)(fM,{dir:a,"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:{"--sidebar-width":yM},side:e,children:[(0,U.jsxs)(pM,{className:`sr-only`,children:[(0,U.jsx)(mM,{children:`Sidebar`}),(0,U.jsx)(hM,{children:`Displays the mobile sidebar.`})]}),(0,U.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})]})}):(0,U.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground lg:block`,"data-state":c,"data-collapsible":c===`collapsed`?n:``,"data-variant":t,"data-side":e,"data-slot":`sidebar`,children:[(0,U.jsx)(`div`,{"data-slot":`sidebar-gap`,className:z(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),(0,U.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":e,className:z(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] lg:flex`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,r),...o,children:(0,U.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-2xl group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:i})})]})}function TM({className:e,onClick:t,...n}){let{toggleSidebar:r}=SM();return(0,U.jsxs)(B,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,className:z(e),onClick:e=>{t?.(e),r()},...n,children:[(0,U.jsx)(Uo,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})}function EM({className:e,...t}){return(0,U.jsx)(`main`,{"data-slot":`sidebar-inset`,className:z(`relative flex w-full flex-1 flex-col bg-background lg:peer-data-[variant=inset]:m-2 lg:peer-data-[variant=inset]:ml-0 lg:peer-data-[variant=inset]:rounded-2xl lg:peer-data-[variant=inset]:shadow-sm lg:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,e),...t})}function DM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:z(`flex flex-col gap-2 p-2 [--radius:var(--radius-xl)]`,e),...t})}function OM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:z(`flex flex-col gap-2 p-2`,e),...t})}function kM({className:e,...t}){return(0,U.jsx)(cM,{"data-slot":`sidebar-separator`,"data-sidebar":`separator`,className:z(`mx-2 w-auto bg-sidebar-border`,e),...t})}function AM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:z(`no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto [--radius:var(--radius-xl)] group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function jM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:z(`relative flex w-full min-w-0 flex-col p-2`,e),...t})}function MM({className:e,render:t,...n}){return LE({defaultTagName:`div`,props:Pt({className:z(`flex h-8 shrink-0 items-center rounded-xl px-3 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-3 [&>svg]:size-4 [&>svg]:shrink-0`,e)},n),render:t,state:{slot:`sidebar-group-label`,sidebar:`group-label`}})}function NM({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:z(`w-full text-sm`,e),...t})}function PM({className:e,...t}){return(0,U.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:z(`flex w-full min-w-0 flex-col gap-0.5`,e),...t})}function FM({className:e,...t}){return(0,U.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:z(`group/menu-item relative`,e),...t})}var IM=_e(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-xl px-3 py-2 text-left text-sm whitespace-nowrap ring-sidebar-ring outline-hidden transition-[width,height,padding] duration-200 group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-3 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 has-[>svg:first-child]:pl-2.5 has-[>svg:last-child]:pr-2.5 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 px-3 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function LM({render:e,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o}){let{isMobile:s,state:c}=SM(),l=LE({defaultTagName:`button`,props:Pt({className:z(IM({variant:n,size:r}),a)},o),render:i?(0,U.jsx)(dl,{render:e}):e,state:{slot:`sidebar-menu-button`,sidebar:`menu-button`,size:r,active:t}});return i?(typeof i==`string`&&(i={children:i}),(0,U.jsxs)(ul,{children:[l,(0,U.jsx)(fl,{side:`right`,align:`center`,hidden:c!==`collapsed`||s,...i})]})):l}function RM({className:e,render:t,showOnHover:n=!1,...r}){return LE({defaultTagName:`button`,props:Pt({className:z(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-xl p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-3 lg:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,n&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 lg:opacity-0`,e)},r),render:t,state:{slot:`sidebar-menu-action`,sidebar:`menu-action`}})}function zM({sessionId:e,docks:t,shells:n,searchOpen:r,onCloseSearch:i,drafts:a}){let o=$r(e);return o?(0,U.jsx)(VM,{view:o,sessionId:e,searchOpen:r,onCloseSearch:i,docks:t,shells:n,drafts:a},e):(0,U.jsx)(`div`,{className:`min-h-0`})}function BM(e,t){let n=t.authorising?.callId;if(n===void 0)return;let r=e.getEntry(`tool:${n}`);return r?.kind===`tool`?as(r.input):void 0}function VM({view:e,sessionId:t,docks:n,shells:r,searchOpen:i,onCloseSearch:a,drafts:o}){let s=ei(e),{sessions:c}=ta(),l=ra(),u=ls(t),[d,f]=(0,H.useState)(``),p=ds(),{openMobile:m}=SM(),[h,g]=(0,H.useState)(()=>gs(ms(window.history.state,t),n.layout)),_=(0,H.useRef)(h);_.current=h;let v=(0,H.useRef)({}),y=(0,H.useRef)(0);(0,H.useEffect)(()=>{if(!p||window.visualViewport===null)return;let e=window.visualViewport,t=()=>{document.documentElement.style.setProperty(`--mobile-viewport-height`,`${e.height}px`)};return t(),e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t),document.documentElement.style.removeProperty(`--mobile-viewport-height`)}},[p]);let b=(0,H.useCallback)((e,n=!1)=>{if(_s(_.current,e)&&!n||(_.current=e,g(e),!p))return;let r=hs(window.history.state,t,e);window.history[n?`replaceState`:`pushState`](r,``,window.location.href)},[p,t]);(0,H.useEffect)(()=>{let e=e=>{g(gs(ms(e.state,t),n.layout))};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[n.layout,t]);let x=gs(h,n.layout);(0,H.useEffect)(()=>{_s(x,h)||g(x)},[h,x]),(0,H.useEffect)(()=>{if(x.kind!==`dock`)return;let e=`${x.side}:${x.tabId}`;v.current[e]=x.detail;let t=n.layout[x.side];t.activeId!==x.tabId&&n.dispatch({type:`activate`,side:x.side,tabId:x.tabId});let r=t.tabs.find(e=>e.id===x.tabId);if(r?.content?.kind!==`subagents`)return;let i=x.detail?.kind===`subagent`?x.detail.id:void 0;i!==void 0&&r.content.subagentId!==i&&n.dispatch({type:`select-subagent`,side:x.side,tabId:x.tabId,subagentId:i})},[n,x]),(0,H.useEffect)(()=>{let e=n.reveal;if(!(!e||e.sessionId!==t||e.nonce===y.current)&&(y.current=e.nonce,n.acknowledgeReveal(e.nonce),p))for(let t of[`right`,`bottom`]){let r=n.layout[t].tabs.find(t=>t.content?.kind===e.kind);if(!r)continue;let i={kind:`dock`,side:t,tabId:r.id};r.content?.kind===`subagents`&&r.content.subagentId?(b(i),b({...i,detail:{kind:`subagent`,id:r.content.subagentId}})):b(i);break}},[n.layout,n.reveal,p,t,b]);let S=(0,H.useCallback)((e,t)=>{n.dispatch({type:`activate`,side:e,tabId:t});let r=`${e}:${t}`,i=n.layout[e].tabs.find(e=>e.id===t),a=i?.content?.kind===`subagents`&&i.content.subagentId?{kind:`subagent`,id:i.content.subagentId}:void 0,o=v.current[r]??a,s={kind:`dock`,side:e,tabId:t};o?(b(s),b({...s,detail:o})):b(s)},[n,b]),C=(0,H.useCallback)(e=>{x.kind===`dock`&&(v.current[`${x.side}:${x.tabId}`]=e,b({...x,detail:e}))},[x,b]),w=(0,H.useCallback)(()=>{x.kind===`dock`&&(v.current[`${x.side}:${x.tabId}`]=void 0,x.detail?window.history.back():b({kind:`dock`,side:x.side,tabId:x.tabId},!0))},[x,b]),T=c.find(e=>e.id===t),E=T?ns(T):t,D=(0,H.useRef)(0),O=(0,H.useCallback)(e=>{let n=T?.attention;!n||n.version<=D.current||e<n.observedSeq||(D.current=n.version,l({type:`acknowledge`,sessionId:t,throughVersion:n.version}).then(e=>{e!==!0&&D.current===n.version&&(D.current=Math.max(0,n.version-1))}))},[l,t,T?.attention]),k=(0,U.jsxs)(`section`,{"data-pane":``,className:z(`relative grid min-h-0 min-w-0 bg-background`,i?`grid-rows-[auto_minmax(0,1fr)]`:`grid-rows-[minmax(0,1fr)]`),"aria-label":`Agent Session ${E}`,children:[i?(0,U.jsx)(Kj,{query:d,onQueryChange:f,onClose:()=>{f(``),a()}}):null,(0,U.jsx)(oA,{value:e=>n.dispatch({type:`open-subagents`,subagentId:e}),children:(0,U.jsx)(rM,{view:e,query:d,visible:d===``&&(!p||x.kind===`transcript`&&!m),onObserved:O})}),(0,U.jsx)(pD,{id:t,chrome:s,actions:u,drafts:o,unavailable:s.capabilities?s.capabilities.models.length===0?`No confirmed model capabilities are available. Revive or restart the Backend Session to retry.`:void 0:`Loading model capabilities before agent work can start…`,authorisingSummary:BM(e,s),onShowSubagents:()=>n.dispatch({type:`open-subagents`})})]}),A=n.layout.bottom,j=n.layout.right,M=!A.minimised,N=!j.minimised,P=x.kind===`dock`?x:void 0;return(0,U.jsxs)(`div`,{className:z(`grid min-h-0 min-w-0`,p?`mobile-view-height grid-cols-[minmax(0,1fr)] grid-rows-[auto_auto_minmax(0,1fr)]`:`grid-rows-[auto_minmax(0,1fr)]`),children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(pl,{sessionId:t,title:E,chrome:s,docks:p?void 0:n}),(0,U.jsx)(bo,{sessionId:t})]}),p?(0,U.jsx)(HM,{layout:n.layout,selected:x,shells:r,onTranscript:()=>b(fs),onSelect:S,onNew:()=>{let e=crypto.randomUUID();n.dispatch({type:`add-tab`,side:`right`,tabId:e}),b({kind:`dock`,side:`right`,tabId:e})},onClose:(e,t)=>{x.kind===`dock`&&x.side===e&&x.tabId===t&&b(fs,!0),delete v.current[`${e}:${t}`],n.dispatch({type:`close-tab`,side:e,tabId:t})}}):null,(0,U.jsxs)(`div`,{"data-dock-frame":``,className:`grid min-h-0 min-w-0 overflow-hidden`,style:{"--dock-bottom":`${A.size}px`,"--dock-right":`${j.size}px`,gridTemplateColumns:p||!N?`minmax(0,1fr)`:`minmax(0,1fr) var(--dock-right)`,gridTemplateRows:p?`minmax(0,1fr)`:M?`minmax(0,1fr) var(--dock-bottom)`:`minmax(0,1fr) 0px`},children:[(0,U.jsx)(`div`,{className:z(`col-start-1 row-start-1 grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] overflow-hidden`,p&&x.kind!==`transcript`&&`hidden`),children:k}),(0,U.jsx)(Hj,{side:`bottom`,dock:A,sessionId:t,shells:r,dispatch:n.dispatch,mobile:p,visible:p?P?.side===`bottom`:M,mobileNavigation:p&&P?.side===`bottom`?{tabId:P.tabId,detail:P.detail,onDetail:C,onBackDetail:w}:void 0}),(0,U.jsx)(Hj,{side:`right`,dock:j,sessionId:t,shells:r,dispatch:n.dispatch,mobile:p,visible:p?P?.side===`right`:N,mobileNavigation:p&&P?.side===`right`?{tabId:P.tabId,detail:P.detail,onDetail:C,onBackDetail:w}:void 0})]})]})}function HM({layout:e,selected:t,shells:n,onTranscript:r,onSelect:i,onNew:a,onClose:o}){return(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 border-b bg-card px-1.5 py-1`,"aria-label":`Agent Session views`,children:[(0,U.jsxs)(`div`,{role:`tablist`,"aria-label":`Agent Session content`,className:`flex min-w-0 flex-1 gap-1 overflow-x-auto`,children:[(0,U.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t.kind===`transcript`,onClick:r,className:z(`flex min-h-10 shrink-0 items-center gap-1.5 rounded-xl px-3 text-xs font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,t.kind===`transcript`?`bg-muted text-foreground`:`text-muted-foreground`),children:[(0,U.jsx)(Bo,{className:`size-4`,"aria-hidden":!0}),`Transcript`]}),[`bottom`,`right`].flatMap(n=>e[n].tabs.map(r=>{let a=t.kind===`dock`&&t.side===n&&t.tabId===r.id,s=ka(e[n],r.id);return(0,U.jsxs)(`div`,{className:z(`flex min-h-10 shrink-0 items-center rounded-xl pr-0.5 pl-3 text-xs`,a?`bg-muted text-foreground`:`text-muted-foreground`),children:[(0,U.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a,className:`max-w-36 truncate py-2 font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>i(n,r.id),title:`${s} · ${n} Dock`,children:s}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-sm`,className:`rounded-xl`,onClick:()=>o(n,r.id),title:r.content?.kind===`shell`?`Close this tab — ends its Shell`:`Close this tab`,"aria-label":`Close ${s}${r.content?.kind===`shell`?` — ends its Shell`:``}`,children:(0,U.jsx)(ts,{"aria-hidden":!0})})]},`${n}:${r.id}`)}))]}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-lg`,className:`shrink-0 rounded-xl`,onClick:a,"aria-label":`New tab in the right Dock`,title:n?`New tab`:`New Git, Workflows, or Agents tab`,children:(0,U.jsx)(Ko,{"aria-hidden":!0})})]})}function UM({backend:e,className:t}){let n=z(`size-3! shrink-0`,t);return e===`claude`?(0,U.jsx)(GM,{className:n}):e===`pi`?(0,U.jsx)(WM,{className:n,children:`π`}):e===`fake`?(0,U.jsx)(wo,{"aria-hidden":!0,className:n}):(0,U.jsx)(WM,{className:n,children:e.slice(0,1).toUpperCase()})}function WM({className:e,children:t}){return(0,U.jsx)(`span`,{"aria-hidden":!0,className:z(`inline-flex items-center justify-center leading-none`,e),children:t})}function GM({className:e}){return(0,U.jsx)(`svg`,{"aria-hidden":!0,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,U.jsx)(`path`,{d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`})})}function KM(e){let t=cA(),{isMobile:n,setOpenMobile:r}=SM(),i=()=>{n&&r(!1)},a={...e,onFocus:t=>{e.onFocus(t),i()},onNew:()=>{e.onNew(),i()},onOpenSettings:()=>{e.onOpenSettings(),i()}},o=new Map(Sr.map(e=>[e,[]]));for(let t of e.sessions)o.get(Cr(t))?.push(t);let s=Sr.map(e=>({group:e,sessions:o.get(e)})).filter(({sessions:e})=>e.length>0),c=s.find(({group:e})=>e===`filed-away`),l=e.sessions.find(t=>t.id===e.cursorId),u=l?Cr(l):void 0,d=u===`filed-away`,[f,p]=(0,H.useState)(!1),m=(0,H.useRef)(null),h=(0,H.useRef)(!1);return(0,H.useLayoutEffect)(()=>{let e=m.current;if(!e)return;let t=document.activeElement,n=e.querySelector(`[data-cursor="true"]`),r=n?.closest(`[data-sidebar="menu-item"]`);h.current&&n&&!r?.contains(t)&&n.focus()},[e.cursorId,u]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(JM,{onNew:a.onNew}),(0,U.jsxs)(AM,{ref:m,className:`transcript-scroller gap-0`,onKeyDown:qM,onFocusCapture:e=>{h.current=e.target.closest(`[data-sidebar="menu-item"]`)!==null},onBlurCapture:e=>{e.target.isConnected&&(h.current=!1)},children:[s.filter(({group:e})=>e!==`filed-away`).map(({group:e,sessions:n})=>(0,U.jsxs)(jM,{className:`p-0`,children:[(0,U.jsxs)(MM,{className:`select-none text-muted-foreground`,children:[wr(e),` · `,n.length]}),(0,U.jsx)(NM,{children:(0,U.jsx)(YM,{...a,label:`${wr(e)} Agent Sessions`,sessions:n,now:t})})]},e)),c?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(kM,{className:`mx-0`}),(0,U.jsx)(QM,{count:c.sessions.length,open:f||d,onOpenChange:p,children:(0,U.jsx)(YM,{...a,label:`Filed away Agent Sessions`,sessions:c.sessions,now:t})})]}):null,e.sessions.length===0?(0,U.jsx)(`p`,{className:`px-3 py-4 text-sm text-muted-foreground`,children:`No Agent Sessions yet.`}):null]}),(0,U.jsx)($M,{link:e.link,onOpenSettings:a.onOpenSettings})]})}function qM(e){let t=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0;if(t===0)return;let n=e.target;if(!(n instanceof HTMLElement))return;let r=n.closest(`[data-sidebar="menu-item"]`);if(!r)return;let i=[...r.querySelectorAll(`[data-sidebar="menu-button"], [data-sidebar="menu-action"]`)],a=i.indexOf(n),o=a<0?void 0:i[a+t];o&&(e.preventDefault(),o.focus())}function JM({onNew:e}){return(0,U.jsx)(DM,{className:`border-b border-sidebar-border`,children:(0,U.jsxs)(B,{variant:`outline`,size:`sm`,className:`w-full justify-start gap-2`,onClick:e,children:[(0,U.jsx)(Ko,{"aria-hidden":!0,className:`size-4 shrink-0`}),`New Agent Session`]})})}function YM({sessions:e,now:t,label:n,...r}){return(0,U.jsx)(PM,{className:`gap-0`,"aria-label":n,children:e.map(e=>(0,U.jsx)(XM,{summary:e,now:t,status:(e.id===r.focusedId?r.focusedStatus:void 0)??e.status,selected:e.id===r.focusedId,cursored:e.id===r.cursorId,onFocus:r.onFocus,onSettle:r.onSettle},e.id))})}function XM({summary:e,now:t,status:n,selected:r,cursored:i,onFocus:a,onSettle:o}){let s=i?0:-1;return(0,U.jsxs)(FM,{children:[(0,U.jsxs)(LM,{size:`lg`,isActive:r,"aria-current":r?`true`:void 0,"data-cursor":i?`true`:void 0,tabIndex:s,onClick:()=>a(e.id),className:z(`h-auto rounded-none py-1.5 pr-8`,`border-l-2 border-l-transparent`,r&&`border-l-primary`,i&&`outline -outline-offset-1 outline-sidebar-ring`),children:[(0,U.jsx)(Ts,{status:n,working:Tr({...e,status:n})}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,U.jsx)(`span`,{className:z(`min-w-0 flex-1 truncate text-sm`,e.attention&&`font-semibold`),children:ns(e)})}),e.outputPreview?(0,U.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.outputPreview}):null,(0,U.jsx)(ZM,{summary:e}),e.attention?(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,children:e.attention.group===`needs-input`?`!`:`●`}),(0,U.jsx)(`span`,{children:e.attention.reason}),(0,U.jsx)(`span`,{className:`ml-auto shrink-0 text-muted-foreground`,children:jl(e.attention.at,t)})]}):null,(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`sr-only`,children:Pl({...e,status:n})}),(0,U.jsx)(UM,{backend:e.backend}),(0,U.jsx)(`span`,{className:`sr-only`,children:e.backend}),(0,U.jsx)(`span`,{className:`truncate`,children:Ss(e.scope,e.worktree)}),e.attention?null:(0,U.jsx)(`span`,{className:`ml-auto shrink-0`,children:jl(e.restingAt,t)})]})]})]}),Er(n)?(0,U.jsxs)(ul,{children:[(0,U.jsxs)(dl,{render:(0,U.jsx)(RM,{showOnHover:!0,tabIndex:s,onClick:()=>o(e.id)}),children:[(0,U.jsx)(ko,{"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Settle`})]}),(0,U.jsx)(fl,{children:`Settle`})]}):null]})}function ZM({summary:e}){if(!e.branch)return null;let t=e.worktree?Po:Fo;return(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(t,{"aria-hidden":!0,className:`size-3! shrink-0`}),(0,U.jsxs)(`span`,{className:`sr-only`,children:[ww(e),e.branch.detached?`, detached at`:``]}),(0,U.jsx)(`span`,{className:`truncate font-mono`,children:e.branch.name})]})}function QM({count:e,open:t,onOpenChange:n,children:r}){return(0,U.jsx)(jM,{className:`p-0`,children:(0,U.jsxs)(`details`,{open:t,onToggle:e=>n(e.currentTarget.open),children:[(0,U.jsxs)(MM,{render:(0,U.jsx)(`summary`,{className:`cursor-default gap-1 text-muted-foreground select-none`}),children:[(0,U.jsx)(dn,{"aria-hidden":!0,className:z(`transition-transform`,!t&&`-rotate-90`)}),`Filed away · `,e]}),(0,U.jsx)(NM,{className:`opacity-60`,children:r})]})})}function $M({link:e,onOpenSettings:t}){return(0,U.jsxs)(OM,{className:`flex-row items-center gap-2 border-t border-sidebar-border py-1.5`,children:[(0,U.jsxs)(ul,{children:[(0,U.jsxs)(dl,{render:(0,U.jsx)(B,{size:`icon`,variant:`ghost`,className:`-ml-1 size-6 shrink-0`,onClick:()=>t()}),children:[(0,U.jsx)(Yo,{"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Settings`})]}),(0,U.jsx)(fl,{children:`Settings`})]}),(0,U.jsx)(tN,{link:e})]})}function eN({children:e}){return(0,U.jsx)(`kbd`,{className:`rounded-sm border bg-muted px-1 font-mono text-xs text-muted-foreground`,children:e})}function tN({link:e}){return e===void 0?null:(0,U.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:z(`inline-block size-1.5 rounded-full`,e===`gone`?`bg-destructive`:e===`live`?`bg-current`:`border border-current`)}),e]})}var nN=new Set([`new-agent-session`,`command-palette`,`toggle-rail`,`keyboard-settings`]);function rN(e,t){let n=iN(e,t);return n===void 0||t.view!==`settings`?n:n===`blur-or-abort`?`leave-settings`:nN.has(n)?n:void 0}function iN(e,t){if(e.ctrlKey||e.metaKey)return e.repeat?void 0:e.key===`k`||e.key===`K`?`command-palette`:e.key===`b`||e.key===`B`?`toggle-rail`:e.key===`f`||e.key===`F`?`search`:void 0;if(e.key===`Escape`)return`blur-or-abort`;if(!t.typing){switch(e.key){case`j`:case`ArrowDown`:return`sidebar-next`;case`k`:case`ArrowUp`:return`sidebar-previous`}if(!e.repeat)switch(e.key){case`Home`:return`sidebar-first`;case`End`:return`sidebar-last`;case`n`:return`new-agent-session`;case`Enter`:return`focus-pane`;case`m`:return`model-picker`;case`e`:return`effort-picker`;case`s`:return`settle`;case"`":return`toggle-bottom-dock`;case`~`:return`toggle-right-dock`;case`?`:return`keyboard-settings`;default:return}}}var aN=new Set([`input`,`textarea`,`select`]);function oN(e,t,n,r){return aN.has(e.toLowerCase())||t||n===`textbox`||r}function sN({handlers:e,view:t,children:n}){return(0,H.useEffect)(()=>{let n=n=>{let r=n.target,i=r!==null&&oN(r.tagName,r.isContentEditable,r.getAttribute(`role`)??void 0,r.closest(`[data-shell-pane]`)!==null);if(n.defaultPrevented)return;let a=rN({key:n.key,ctrlKey:n.ctrlKey,metaKey:n.metaKey,shiftKey:n.shiftKey,repeat:n.repeat},{typing:i,view:t});if(a===void 0)return;if(i&&(a===`blur-or-abort`||a===`leave-settings`)){r?.blur(),n.preventDefault();return}let o=e[a];o&&(n.preventDefault(),o())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),(0,U.jsx)(U.Fragment,{children:n})}function cN(e,t){return t??(e.includes(`claude`)?`claude`:e[0])}var lN={s:1e3,m:6e4,h:36e5,d:864e5};function uN(e){let t=/^\s*(\d+(?:\.\d+)?)\s*(s|m|h|d)\s*$/.exec(e),n=t?.[1],r=t?.[2];if(!n||!r)return;let i=lN[r];if(i!==void 0)return Number(n)*i}function dN(){let[e,t]=(0,H.useState)(void 0),[n,r]=(0,H.useState)(!0),[i,a]=(0,H.useState)(void 0),o=async e=>{r(!0),a(void 0);try{let n=await kt(`/api/models${e?`?refresh=1`:``}`);if(!n.ok){a(`Model capability discovery failed (${n.status}).`);return}t(await n.json())}catch{a(`Could not reach the Session Host to confirm model Effort support.`)}finally{r(!1)}};return(0,H.useEffect)(()=>{o(!1)},[]),{catalogue:e,loading:n,problem:i,refresh:()=>o(!0)}}function fN(e,t){let n=(0,H.useRef)(Promise.resolve([]));return(0,H.useEffect)(()=>{n.current=e===void 0||e===``||t===``?Promise.resolve([]):pN(e,t)},[e,t]),(0,H.useCallback)(()=>n.current,[])}async function pN(e,t){try{let n=await kt(`/api/skills?scope=${encodeURIComponent(e)}&backend=${encodeURIComponent(t)}`);if(!n.ok)return[];let r=await n.json();return r.scope===e?r.skills:[]}catch{return[]}}function mN(e,t,n){let r=e?.find(e=>e.backend===n)?.models??[];if(r.length===0)return;let i=t?.[n];return r.find(e=>e.id===i)??r[0]}var hN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),gN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=hN(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),_N=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=hN(),n=gN(),r=hN();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=gN();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
108
108
  `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-->0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${ee(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${ee(n)} ${e} ${ee(r)}`}function ee(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),vN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=_N(),n=hN();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0||(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0||{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0||(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0||Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),yN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=_N();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),bN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=_N(),n=vN(),r=yN();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),xN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=bN(),n=_N(),r=yN(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),SN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),CN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),wN=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=SN(),n=CN(),r=bN(),i=_N(),a=vN(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
109
109
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
110
110
  || (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
@@ -167,4 +167,4 @@ For tests, pass a Ghostty instance directly:
167
167
 
168
168
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function mW(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;mW(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var hW=new Set([`type`,`properties`,`required`,`additionalProperties`]),gW=[`oneOf`,`anyOf`];function _W(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function vW(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!hW.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??_W(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}vR(n,r,e.length===1?e[0]:vW(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=_W(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function yW(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of hW)if(t in e)return;let n=t.filter(e=>gW.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=vW(t);else{let e=n[0],i=gW.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>vW([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,cW(e,r))}function bW(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):cW(i,s),cW(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())mW(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])yW(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}cW(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,vR(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:CW(t,`input`,e.processors),output:CW(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function xW(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return xW(r.element,n);if(r.type===`set`)return xW(r.valueType,n);if(r.type===`lazy`)return xW(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return xW(r.innerType,n);if(r.type===`intersection`)return xW(r.left,n)||xW(r.right,n);if(r.type===`record`||r.type===`map`)return xW(r.keyType,n)||xW(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:xW(r.in,n)||xW(r.out,n);if(r.type===`object`){for(let e in r.shape)if(xW(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(xW(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(xW(e,n))return!0;return!!(r.rest&&xW(r.rest,n))}return!1}var SW=(e,t={})=>n=>{let r=lW({...n,processors:t});return dW(e,r),pW(r,e),bW(r,e)},CW=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=lW({...i??{},target:a,io:t,processors:n});return dW(e,o),pW(o,e),bW(o,e)},wW=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},TW=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},EW=(e,t)=>{wW(e,`minimum`,t),TW(e,`maximum`,t)},DW=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},OW=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},kW=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},AW=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},jW=(e,t)=>wW(e,`minimum`,t.minimum),MW=(e,t)=>TW(e,`maximum`,t.maximum),NW=e=>(t,n)=>{AW(t,n.format);let[r,i]=e[n.format];wW(t,`minimum`,r),TW(t,`maximum`,i)},PW={greater_than:(e,t)=>wW(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>TW(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>DW(e,t.value),number_format:NW(RR),bigint_format:NW(zR),min_length:jW,max_length:MW,length_equals:(e,t)=>EW(e,t.length),min_size:jW,max_size:MW,size_equals:(e,t)=>EW(e,t.size),string_format:(e,t)=>{AW(e,t.format),t.pattern&&OW(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>kW(e,t.mime)};function FW(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)PW[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&wW(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&wW(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&TW(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&TW(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&DW(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&kW(t,i.mime);for(let e of i.patterns??[])OW(t,e);return t}var IW={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},LW=new Map([[RV,yB],[BV,bB]]),RW=e=>LW.get(e)??e,zW=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=FW(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=IW[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(RW);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},BW=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=FW(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):uW(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},VW=(e,t,n,r)=>{n.type=`boolean`},HW=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},UW=(e,t,n,r)=>{n.not={}},WW=(e,t,n,r)=>{let i=e._zod.def,a=cR(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},GW=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(uW(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(uW(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},KW=(e,t,n,r)=>{uW(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},qW=(e,t,n,r)=>{uW(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},JW=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=FW(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=dW(a.element,t,{...r,path:[...r.path,`items`]})};function YW(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?YW(t.out):t.type===`catch`?YW(t.innerType):e._zod.optin}var XW=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&uW(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)vR(i.properties,e,dW(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?YW(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=dW(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ZW=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>dW(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},QW=(e,t,n,r)=>{let i=e._zod.def,a=dW(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=dW(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function $W(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=$W(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>$W(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?jB:AB).source),p):p}var eG=new WeakMap;function tG(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of eG.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=$W(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var nG=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=FW(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=dW(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)vR(i.patternProperties,RW(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=dW(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=eG.get(t);n||(n=[],eG.set(t,n),t.deferred.push(()=>tG(t))),n.push(e)}i.additionalProperties=dW(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&YW(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},rG=(e,t,n,r)=>{let i=e._zod.def,a=dW(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},iG=(e,t,n,r)=>{let i=e._zod.def;dW(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},aG=Symbol();function oG(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(uW(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),aG):JSON.parse(o)}var sG=(e,t,n,r)=>{let i=e._zod.def;dW(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=oG(i.defaultValue,e,t,n,r);o!==aG&&(n.default=o)},cG=(e,t,n,r)=>{let i=e._zod.def;dW(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=oG(i.defaultValue,e,t,n,r);o!==aG&&(n._prefault=o)},lG=(e,t,n,r)=>{let i=e._zod.def;dW(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{uW(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},uG=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;dW(o,t,r);let s=t.seen.get(e);s.ref=o},dG=(e,t,n,r)=>{let i=e._zod.def;dW(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},fG=(e,t,n,r)=>{let i=e._zod.def;dW(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pG=(e,t,n,r)=>{let i=e._zod.innerType;dW(i,t,r);let a=t.seen.get(e);a.ref=i},mG=new WeakSet([Object.prototype,Error.prototype]);function hG(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var gG=$(`ZodError`,(e,t)=>{Nz.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);mG.has(n)||(mG.add(n),hG(n,`format`,e=>t=>Iz(e,t)),hG(n,`flatten`,e=>t=>Fz(e,t)),hG(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,uR,2)}),hG(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,uR,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),_G=Rz(gG),vG=zz(gG),yG=Bz(gG),bG=Hz(gG),xG=Jz(gG),SG=Yz(gG),CG=Xz(gG),wG=Zz(gG),TG=Qz(gG),EG=$z(gG),DG=eB(gG),OG=tB(gG);function kG(){Tz.localeError||Ez($H())}function AG(){Tz.memoizer||Ez({memoizer:XH()})}var jG=$(`ZodType`,(e,t)=>(kG(),nV.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(TR(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return FR(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(nq(e,t))},superRefine(e,t){return this.check(rq(e,t))},overwrite(e){return this.check(QU(e))},optional(){return IK(this)},exactOptional(){return RK(this)},nullable(){return BK(this)},nullish(){return IK(BK(this))},nonoptional(e){return KK(this,e)},array(){return vK(this)},or(e){return SK([this,e])},and(e){return EK(this,e)},transform(e){return XK(this,PK(e))},default(e){return HK(this,e)},prefault(e){return WK(this,e)},catch(e){return JK(this,e)},pipe(e){return XK(this,e)},readonly(){return QK(this)},describe(e){let t=this.clone();return rU.add(t,{description:e}),t},meta(...e){if(e.length===0)return rU.get(this);let t=this.clone();return rU.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return cz(this,`~standard`,{...aV(this),jsonSchema:{input:CW(this,`input`),output:CW(this,`output`)}})},set"~standard"(e){sz(this,`~standard`,e)},parse:function e(t,n){return _G(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await vG(this,t,n,{callee:e})},safeParse(e,t){return yG(this,e,t)},async safeParseAsync(e,t){return bG(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){sz(this,`spa`,e)},validate(e,t){return Gz(this,e,t)},validateAsync(e,t){return qz(this,e,t)},encode:function e(t,n){return xG(this,t,n,{callee:e})},decode:function e(t,n){return SG(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await CG(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await wG(this,t,n,{callee:e})},safeEncode(e,t){return TG(this,e,t)},safeDecode(e,t){return EG(this,e,t)},async safeEncodeAsync(e,t){return DG(this,e,t)},async safeDecodeAsync(e,t){return OG(this,e,t)},toJSONSchema(e){return SW(this,{})(e)},get description(){return rU.get(this)?.description},get _def(){return this._zod.def}}),MG=$(`_ZodString`,(e,t)=>{oV.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zW(e,t,n,r)},lz({format:e=>FW(e).format??null,minLength:e=>FW(e).minimum??null,maxLength:e=>FW(e).maximum??null},{regex(...e){return this.check(KU(...e))},includes(...e){return this.check(YU(...e))},startsWith(...e){return this.check(XU(...e))},endsWith(...e){return this.check(ZU(...e))},min(...e){return this.check(WU(...e))},max(...e){return this.check(UU(...e))},length(...e){return this.check(GU(...e))},nonempty(...e){return this.check(WU(1,...e))},lowercase(e){return this.check(qU(e))},uppercase(e){return this.check(JU(e))},trim(){return this.check(eW())},normalize(...e){return this.check($U(...e))},toLowerCase(){return this.check(tW())},toUpperCase(){return this.check(nW())},slugify(){return this.check(rW())}})),NG=$(`ZodString`,(e,t)=>{oV.init(e,t),MG.init(e,t)},{email(e){return this.check(oU(BG,e))},url(e){return this.check(fU(UG,e))},jwt(e){return this.check(DU(iK,e))},emoji(e){return this.check(pU(WG,e))},guid(e){return this.check(sU(VG,e))},uuid(e){return this.check(cU(HG,e))},uuidv4(e){return this.check(lU(HG,e))},uuidv6(e){return this.check(uU(HG,e))},uuidv7(e){return this.check(dU(HG,e))},nanoid(e){return this.check(mU(GG,e))},cuid(e){return this.check(hU(KG,e))},cuid2(e){return this.check(gU(qG,e))},ulid(e){return this.check(_U(JG,e))},base64(e){return this.check(wU(tK,e))},base64url(e){return this.check(TU(nK,e))},xid(e){return this.check(vU(YG,e))},ksuid(e){return this.check(yU(XG,e))},ipv4(e){return this.check(bU(ZG,e))},ipv6(e){return this.check(xU(QG,e))},cidrv4(e){return this.check(SU($G,e))},cidrv6(e){return this.check(CU(eK,e))},e164(e){return this.check(EU(rK,e))},datetime(e){return this.check(OU(IG,e))},date(e){return this.check(kU(LG,e))},time(e){return this.check(AU(RG,e))},duration(e){return this.check(jU(zG,e))}});function PG(e){return aU(NG,e)}var FG=$(`ZodStringFormat`,(e,t)=>{sV.init(e,t),MG.init(e,t)}),IG=$(`ZodISODateTime`,(e,t)=>{EV.init(e,t),FG.init(e,t)}),LG=$(`ZodISODate`,(e,t)=>{DV.init(e,t),FG.init(e,t)}),RG=$(`ZodISOTime`,(e,t)=>{OV.init(e,t),FG.init(e,t)}),zG=$(`ZodISODuration`,(e,t)=>{kV.init(e,t),FG.init(e,t)}),BG=$(`ZodEmail`,(e,t)=>{uV.init(e,t),FG.init(e,t)}),VG=$(`ZodGUID`,(e,t)=>{cV.init(e,t),FG.init(e,t)}),HG=$(`ZodUUID`,(e,t)=>{lV.init(e,t),FG.init(e,t)}),UG=$(`ZodURL`,(e,t)=>{vV.init(e,t),FG.init(e,t)}),WG=$(`ZodEmoji`,(e,t)=>{yV.init(e,t),FG.init(e,t)}),GG=$(`ZodNanoID`,(e,t)=>{bV.init(e,t),FG.init(e,t)}),KG=$(`ZodCUID`,(e,t)=>{xV.init(e,t),FG.init(e,t)}),qG=$(`ZodCUID2`,(e,t)=>{SV.init(e,t),FG.init(e,t)}),JG=$(`ZodULID`,(e,t)=>{CV.init(e,t),FG.init(e,t)}),YG=$(`ZodXID`,(e,t)=>{wV.init(e,t),FG.init(e,t)}),XG=$(`ZodKSUID`,(e,t)=>{TV.init(e,t),FG.init(e,t)}),ZG=$(`ZodIPv4`,(e,t)=>{AV.init(e,t),FG.init(e,t)}),QG=$(`ZodIPv6`,(e,t)=>{NV.init(e,t),FG.init(e,t)}),$G=$(`ZodCIDRv4`,(e,t)=>{PV.init(e,t),FG.init(e,t)}),eK=$(`ZodCIDRv6`,(e,t)=>{IV.init(e,t),FG.init(e,t)}),tK=$(`ZodBase64`,(e,t)=>{zV.init(e,t),FG.init(e,t)}),nK=$(`ZodBase64URL`,(e,t)=>{HV.init(e,t),FG.init(e,t)}),rK=$(`ZodE164`,(e,t)=>{UV.init(e,t),FG.init(e,t)}),iK=$(`ZodJWT`,(e,t)=>{GV.init(e,t),FG.init(e,t)}),aK=$(`ZodNumber`,(e,t)=>{KV.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>BW(e,t,n,r),e.isFinite=!0},lz({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=FW(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=FW(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=FW(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>FW(e).format??null},{gt(e,t){return this.check(BU(e,t))},gte(e,t){return this.check(VU(e,t))},min(e,t){return this.check(VU(e,t))},lt(e,t){return this.check(RU(e,t))},lte(e,t){return this.check(zU(e,t))},max(e,t){return this.check(zU(e,t))},int(e){return this.check(cK(e))},safe(e){return this.check(cK(e))},positive(e){return this.check(BU(0,e))},nonnegative(e){return this.check(VU(0,e))},negative(e){return this.check(RU(0,e))},nonpositive(e){return this.check(zU(0,e))},multipleOf(e,t){return this.check(HU(e,t))},step(e,t){return this.check(HU(e,t))},finite(){return this}}));function oK(e){return MU(aK,e)}var sK=$(`ZodNumberFormat`,(e,t)=>{qV.init(e,t),aK.init(e,t)});function cK(e){return NU(sK,e)}var lK=$(`ZodBoolean`,(e,t)=>{JV.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>VW(e,t,n,r)});function uK(e){return PU(lK,e)}var dK=$(`ZodNull`,(e,t)=>{YV.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>HW(e,t,n,r)});function fK(e){return FU(dK,e)}var pK=$(`ZodUnknown`,(e,t)=>{XV.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function mK(){return IU(pK)}var hK=$(`ZodNever`,(e,t)=>{ZV.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>UW(e,t,n,r)});function gK(e){return LU(hK,e)}var _K=$(`ZodArray`,(e,t)=>{AG(),$V.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JW(e,t,n,r),e.element=t.element},{min(e,t){return this.check(WU(e,t))},nonempty(e){return this.check(WU(1,e))},max(e,t){return this.check(UU(e,t))},length(e,t){return this.check(GU(e,t))},unwrap(){return this.element}});function vK(e,t){return iW(_K,e,t)}var yK=$(`ZodObject`,(e,t)=>{AG(),aH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XW(e,t,n,r),gz(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return AK(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(TR(this._zod.def,{catchall:e}))},passthrough(){return this.clone(TR(this._zod.def,{catchall:mK()}))},loose(){return this.clone(TR(this._zod.def,{catchall:mK()}))},strict(){return this.clone(TR(this._zod.def,{catchall:gK()}))},strip(){return this.clone(TR(this._zod.def,{catchall:void 0}))},extend(e){return UR(this,e)},safeExtend(e){return GR(this,e)},merge(e){return KR(this,e)},pick(e){return BR(this,e)},omit(e){return HR(this,e)},partial(...e){return qR(FK,this,e[0])},exactPartial(...e){return qR(LK,this,e[0],`exactPartial`)},required(...e){return JR(GK,this,e[0])}});function bK(e,t){return new yK({type:`object`,shape:e??{},...Q(t)})}var xK=$(`ZodUnion`,(e,t)=>{sH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ZW(e,t,n,r),e.options=t.options});function SK(e,t){return new xK({type:`union`,options:e,...Q(t)})}var CK=$(`ZodDiscriminatedUnion`,(e,t)=>{xK.init(e,t),lH.init(e,t)});function wK(e,t,n){return new CK({type:`union`,options:t,discriminator:e,...Q(n)})}var TK=$(`ZodIntersection`,(e,t)=>{uH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QW(e,t,n,r)});function EK(e,t){return new TK({type:`intersection`,left:e,right:t})}var DK=$(`ZodRecord`,(e,t)=>{AG(),pH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nG(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function OK(e,t,n){return!t||!t._zod?new DK({type:`record`,keyType:PG(),valueType:e,...Q(t)}):new DK({type:`record`,keyType:e,valueType:t,...Q(n)})}var kK=$(`ZodEnum`,(e,t)=>{mH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>WW(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new kK({...t,checks:[],...Q(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new kK({...t,checks:[],...Q(r),entries:i})}});function AK(e,t){return new kK({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Q(t)})}var jK=$(`ZodLiteral`,(e,t)=>{hH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>GW(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function MK(e,t){return new jK({type:`literal`,values:Array.isArray(e)?e:[e],...Q(t)})}var NK=$(`ZodTransform`,(e,t)=>{AG(),gH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qW(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new wz(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(az(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(az(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function PK(e){return new NK({type:`transform`,transform:e})}var FK=$(`ZodOptional`,(e,t)=>{vH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fG(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function IK(e){return new FK({type:`optional`,innerType:e})}var LK=$(`ZodExactOptional`,(e,t)=>{yH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fG(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function RK(e){return new LK({type:`optional`,innerType:e})}var zK=$(`ZodNullable`,(e,t)=>{bH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rG(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function BK(e){return new zK({type:`nullable`,innerType:e})}var VK=$(`ZodDefault`,(e,t)=>{xH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sG(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function HK(e,t){return new VK({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():MR(t)}})}var UK=$(`ZodPrefault`,(e,t)=>{CH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cG(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function WK(e,t){return new UK({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():MR(t)}})}var GK=$(`ZodNonOptional`,(e,t)=>{wH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iG(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function KK(e,t){return new GK({type:`nonoptional`,innerType:e,...Q(t)})}var qK=$(`ZodCatch`,(e,t)=>{DH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lG(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function JK(e,t){return new qK({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:vz(t)})}var YK=$(`ZodPipe`,(e,t)=>{OH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uG(e,t,n,r),e.in=t.in,e.out=t.out});function XK(e,t){return new YK({type:`pipe`,in:e,out:t})}var ZK=$(`ZodReadonly`,(e,t)=>{AH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dG(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function QK(e){return new ZK({type:`readonly`,innerType:e})}var $K=$(`ZodLazy`,(e,t)=>{MH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pG(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function eq(e){return new $K({type:`lazy`,getter:e})}var tq=$(`ZodCustom`,(e,t)=>{NH.init(e,t),jG.init(e,t),e._zod.processJSONSchema=(t,n,r)=>KW(e,t,n,r)});function nq(e,t={}){return aW(tq,e,t)}function rq(e,t){return oW(e,t)}function iq(e){let t=eq(()=>SK([PG(e),oK(),uK(),fK(),vK(t),OK(PG(),t)]));return t}function aq(e){return typeof e==`string`&&/^[A-Za-z_][A-Za-z0-9_-]{0,127}$/.test(e)&&![`__proto__`,`constructor`,`prototype`].includes(e)}var oq=class{nodes=[{variable:1/0,choices:[]},{variable:1/0,choices:[]}];unique=new Map;cache=new Map;outcome(e,t){return this.node(e,Array.from({length:5},(e,n)=>Number(n===t)))}and(e,t){return this.apply(`and`,e,t)}or(e,t){return this.apply(`or`,e,t)}not(e){if(e<2)return 1-e;let t=`not:${e}`,n=this.cache.get(t);if(n!==void 0)return n;let r=this.nodes[e],i=this.node(r.variable,r.choices.map(e=>this.not(e)));return this.cache.set(t,i),i}implies(e,t){return this.and(e,this.not(t))===0}node(e,t){if(t.every(e=>e===t[0]))return t[0];let n=`${e}:${t.join(`,`)}`,r=this.unique.get(n);if(r!==void 0)return r;let i=this.nodes.length;return this.nodes.push({variable:e,choices:t}),this.unique.set(n,i),i}apply(e,t,n){if(t===n)return t;if(e===`and`){if(t===0||n===0)return 0;if(t===1)return n;if(n===1)return t}else{if(t===1||n===1)return 1;if(t===0)return n;if(n===0)return t}let r=`${e}:${Math.min(t,n)}:${Math.max(t,n)}`,i=this.cache.get(r);if(i!==void 0)return i;let a=this.nodes[t],o=this.nodes[n],s=Math.min(a.variable,o.variable),c=this.node(s,Array.from({length:5},(r,i)=>this.apply(e,a.variable===s?a.choices[i]:t,o.variable===s?o.choices[i]:n)));return this.cache.set(r,c),c}};function sq(e){let t=e.steps.map(e=>e.id),n=new Set(t);if(n.size!==t.length)throw Error(`Step IDs must be unique`);if(new Set(e.edges.map(e=>e.id)).size!==e.edges.length)throw Error(`Edge IDs must be unique`);let r=new Map(t.map(e=>[e,[]])),i=new Map(t.map(e=>[e,[]]));for(let t of e.edges){if(!n.has(t.from)||!n.has(t.to))throw Error(`Unknown edge endpoint`);r.get(t.to).push(t),i.get(t.from).push(t)}let a=t.filter(e=>!r.get(e).length),o=new Set(a),s=[...a];for(let e=0;e<s.length;e++)for(let t of i.get(s[e]))o.has(t.to)||(o.add(t.to),s.push(t.to));if(o.size!==n.size)throw Error(`Workflow cycle has no entry from a root`);let c=new Map(t.map(e=>[e,new Set(a.includes(e)?[e]:t)])),l=!0;for(;l;){l=!1;for(let e of s){let t=r.get(e);if(!t.length)continue;let n=new Set([...c.get(t[0].from)].filter(e=>t.every(t=>c.get(t.from).has(e))));n.add(e);let i=c.get(e);(n.size!==i.size||[...n].some(e=>!i.has(e)))&&(c.set(e,n),l=!0)}}let u=e.edges.filter(e=>c.get(e.from).has(e.to)),d=new Set(u.map(e=>e.id)),f=new Map;for(let e of u){let t=f.get(e.to)??new Set([e.to]),n=[e.from];for(;n.length;){let e=n.pop();t.has(e)||(t.add(e),n.push(...r.get(e).map(e=>e.from)))}f.set(e.to,t)}let p=[...f].map(([n,r])=>({headerId:n,memberIds:t.filter(e=>r.has(e)),backEdgeIds:u.filter(e=>e.to===n).map(e=>e.id),entryEdgeIds:e.edges.filter(e=>!r.has(e.from)&&r.has(e.to)).map(e=>e.id),exitEdgeIds:e.edges.filter(e=>r.has(e.from)&&!r.has(e.to)).map(e=>e.id)}));for(let t of p){let n=f.get(t.headerId);if(e.edges.some(e=>!n.has(e.from)&&n.has(e.to)&&e.to!==t.headerId))throw Error(`Workflow loop has multiple entry steps`);let r=[];for(let e of p){if(e===t)continue;let i=f.get(e.headerId),a=t.memberIds.filter(e=>i.has(e)).length;if(a){if(a===n.size&&n.size<i.size)r.push(e);else if(a!==i.size||n.size===i.size)throw Error(`Workflow loops overlap without strict nesting`)}}r.sort((e,t)=>e.memberIds.length-t.memberIds.length),r[0]&&(t.parentHeaderId=r[0].headerId)}let m=[],h=new Set(t);for(;h.size;){let e=[...h].filter(e=>r.get(e).every(e=>d.has(e.id)||!h.has(e.from)));if(!e.length)throw Error(`Workflow contains an irreducible or multiple-entry cycle`);for(let t of e)m.push(t),h.delete(t)}return p.sort((e,n)=>n.memberIds.length-e.memberIds.length||t.indexOf(e.headerId)-t.indexOf(n.headerId)),{loops:p,order:m}}var cq=PG().refine(e=>![`__proto__`,`constructor`,`prototype`].includes(e),`Reserved dictionary key`);function lq(e){return mK().superRefine((e,t)=>{if(e&&typeof e==`object`)for(let n of Object.keys(e))cq.safeParse(n).success||t.addIssue({code:`custom`,message:`Reserved dictionary key`,path:[n]})}).pipe(OK(cq,e))}var uq=eq(()=>SK([fK(),uK(),oK(),PG(),vK(uq),OK(PG(),uq)])),dq=eq(()=>wK(`type`,[bK({type:MK(`null`)}).strict(),bK({type:MK(`json`),schema:SK([uK(),OK(PG(),uq)]).optional()}).strict(),bK({type:MK(`string`)}).strict(),bK({type:MK(`number`),integer:uK().optional()}).strict(),bK({type:MK(`boolean`)}).strict(),bK({type:MK(`enum`),values:vK(PG()).min(1).refine(e=>new Set(e).size===e.length)}).strict(),bK({type:MK(`array`),items:dq}).strict(),bK({type:MK(`union`),variants:vK(dq).min(2)}).strict(),bK({type:MK(`object`),fields:lq(bK({schema:dq,required:uK().optional(),default:uq.optional()}).strict())}).strict()]));function fq(e){switch(e.type){case`null`:return fK();case`json`:return e.schema!==void 0&&aR(e.schema),uq.superRefine((t,n)=>{try{e.schema!==void 0&&oR(e.schema,t)}catch(e){n.addIssue({code:`custom`,message:e.message})}});case`string`:return PG();case`number`:return e.integer?oK().int():oK();case`boolean`:return uK();case`enum`:return AK(e.values);case`array`:return vK(fq(e.items));case`union`:return SK(e.variants.map(fq));case`object`:return bK(Object.fromEntries(Object.entries(e.fields).map(([e,t])=>{let n=fq(t.schema);return t.default===void 0?t.required||(n=n.optional()):n=n.default(pq(t.schema,t.default)),[e,n]}))).strict()}}function pq(e,t){return uq.parse(fq(e).parse(t))}function mq(e){dq.parse(e),fq(e)}function hq(e){switch(e.type){case`json`:return`unknown`;case`enum`:return e.values.map(e=>JSON.stringify(e)).join(` | `);case`array`:return`Array<${hq(e.items)}>`;case`union`:return e.variants.map(hq).join(` | `);case`object`:return`{ ${Object.entries(e.fields).map(([e,t])=>`${JSON.stringify(e)}${t.required||t.default!==void 0?``:`?`}: ${hq(t.schema)}`).join(`; `)} }`;default:return e.type}}var gq={type:`object`,fields:{exitCode:{schema:{type:`number`,integer:!0},required:!0},stdout:{schema:{type:`string`},required:!0},stderr:{schema:{type:`string`},required:!0}}};function _q(e){if(e.kind===`mcp`)return{type:`object`,fields:{structuredContent:{required:!0,schema:{type:`json`,...e.tool.outputSchema===void 0?{}:{schema:e.tool.outputSchema}}},content:{required:!0,schema:{type:`array`,items:{type:`json`}}}}};if(e.kind===`shell`)return gq;if(e.kind===`branch`)return{type:`boolean`};if(e.kind!==`join`)return e.outputSchema}function vq(e,t){if(!t.length)return{schema:e,optional:!1};if(e.type===`json`)return{schema:{type:`json`,schema:sR(e.schema??!0,t)},optional:!1};if(e.type===`null`)return{schema:{type:`json`},optional:!1};if(e.type===`union`){let n=e.variants.map(e=>vq(e,t));return{schema:xq(n.map(e=>e.schema)),optional:n.some(e=>e.optional)}}let[n,...r]=t;if(e.type===`object`){let t=Object.hasOwn(e.fields,n)?e.fields[n]:void 0;if(!t)throw Error(`Unknown field: ${n}`);let i=vq(t.schema,r);return{schema:i.schema,optional:i.optional||!t.required&&t.default===void 0}}if(e.type===`array`&&/^(0|[1-9]\d*)$/.test(n))return{schema:vq(e.items,r).schema,optional:!0};throw Error(`Invalid field path: ${n}`)}function yq(e,t){return t.type===`json`||e.type===`json`?!0:e.type===`union`?e.variants.every(e=>yq(e,t)):t.type===`union`?t.variants.some(t=>yq(e,t)):e.type===`enum`?t.type===`string`||t.type===`enum`&&e.values.every(e=>t.values.includes(e)):e.type===t.type?e.type===`number`&&t.type===`number`?!t.integer||!!e.integer:e.type===`array`&&t.type===`array`?yq(e.items,t.items):e.type===`object`&&t.type===`object`?Object.keys(e.fields).every(e=>Object.hasOwn(t.fields,e))&&Object.entries(t.fields).every(([t,n])=>{let r=Object.hasOwn(e.fields,t)?e.fields[t]:void 0,i=n.required&&n.default===void 0;return r?(!i||r.required||r.default!==void 0)&&yq(r.schema,n.schema):!i}):!0:!1}function bq(e){return e.type===`object`?{type:`object`,fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,{schema:bq(t.schema)}]))}:e.type===`array`?{type:`array`,items:bq(e.items)}:e.type===`union`?xq(e.variants.map(bq)):e}function xq(e){let t=[...new Map(e.map(e=>[JSON.stringify(e),e])).values()];return t.length===1?t[0]:{type:`union`,variants:t}}var Sq=wK(`source`,[bK({source:MK(`input`),path:vK(PG())}).strict(),bK({source:MK(`step`),stepId:PG(),path:vK(PG())}).strict()]),Cq=eq(()=>wK(`kind`,[bK({kind:MK(`literal`),value:iq()}).strict(),bK({kind:MK(`reference`),reference:Sq}).strict(),bK({kind:MK(`object`),fields:lq(Cq)}).strict(),bK({kind:MK(`array`),items:vK(Cq)}).strict()])),wq=SK([uK(),OK(PG(),iq())]),Tq=wK(`kind`,[bK({kind:MK(`template`),template:Cq}).strict(),bK({kind:MK(`reference`),reference:Sq}).strict(),bK({kind:MK(`object`),fields:lq(Sq)}).strict()]),Eq={id:cq.min(1),name:cq.min(1),inputSchema:dq.optional(),mapping:Tq.optional(),repeatMapping:Tq.optional(),permission:AK([`ask`,`auto-accept`]).optional(),timeoutMs:oK().int().positive().max(2147483647).optional(),secrets:lq(PG().refine(aq,`Invalid secret reference`)).optional(),position:bK({x:oK(),y:oK()}).strict().optional()},Dq=wK(`operator`,[bK({operator:MK(`truthy`),path:vK(PG())}).strict(),bK({operator:AK([`equals`,`not-equals`]),path:vK(PG()),value:iq()}).strict(),bK({operator:AK([`greater-than`,`less-than`]),path:vK(PG()),value:oK()}).strict()]),Oq=bK({version:MK(1),id:PG().regex(/^[a-zA-Z0-9_-]{1,128}$/),name:PG().min(1),backend:PG().min(1),projectId:PG().optional(),permission:AK([`ask`,`auto-accept`]).optional(),inputSchema:dq.refine(e=>e.type===`object`),steps:vK(wK(`kind`,[bK({...Eq,kind:MK(`agent`),instructions:PG(),model:PG().min(1),effort:AK([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),outputSchema:dq}).strict(),bK({...Eq,kind:MK(`shell`),command:PG(),acceptedExitCodes:vK(oK().int()).min(1).optional()}).strict(),bK({...Eq,kind:MK(`typescript`),code:PG(),outputSchema:dq}).strict(),bK({...Eq,kind:MK(`branch`),condition:Dq}).strict(),bK({...Eq,kind:MK(`join`)}).strict(),bK({...Eq,kind:MK(`mcp`),tool:bK({connectionId:PG().min(1),connectionName:PG(),identity:PG().regex(/^[a-f0-9]{64}$/),serverIdentity:PG().regex(/^[a-f0-9]{64}$/),toolName:PG().min(1),inputSchema:wq,outputSchema:wq.optional()}).strict()}).strict()])).min(1),loopSettings:lq(bK({maxTries:oK().int().min(1).max(100)}).strict()).optional(),edges:vK(bK({id:PG().min(1),from:PG(),to:PG(),outcome:AK([`success`,`failure`,`timeout`,`true`,`false`])}).strict())}).strict();function kq(e){let t=Oq.parse(e),n=t.steps.find(e=>e.kind===`agent`&&MC(e.instructions));if(n&&!t.projectId)throw Error(`Workflow Step ${JSON.stringify(n.name)} invokes a Skill and requires a Project binding`);mq(t.inputSchema);let r=new Map(t.steps.map(e=>[e.id,e]));if(r.size!==t.steps.length||new Set(t.steps.map(e=>e.name)).size!==r.size)throw Error(`Step IDs and names must be unique`);if(new Set(t.edges.map(e=>e.id)).size!==t.edges.length)throw Error(`Edge IDs must be unique`);let i=new Map(t.steps.map(e=>[e.id,[]])),a=new Map(t.steps.map(e=>[e.id,[]])),o=new Set;for(let e of t.edges){let t=r.get(e.from);if(!t||!r.has(e.to))throw Error(`Unknown edge endpoint`);let n=JSON.stringify([e.from,e.to,e.outcome]);if(o.has(n))throw Error(`Duplicate connection`);if(o.add(n),t.kind===`branch`?![`true`,`false`,`failure`,`timeout`].includes(e.outcome):[`true`,`false`].includes(e.outcome))throw Error(`Invalid edge outcome`);i.get(e.to).push(e),a.get(e.from).push(e)}let s=sq(t),c=s.loops.map(e=>({...e,maxTries:t.loopSettings?.[e.headerId]?.maxTries??3})),l=new Map(c.map(e=>[e.headerId,e]));for(let e of Object.keys(t.loopSettings??{}))if(!l.has(e))throw Error(`Loop settings require a loop header`);for(let e of r.values())if(e.repeatMapping&&!l.has(e.id))throw Error(`Repeat mapping requires a loop header`);let u=new Set(c.flatMap(e=>e.backEdgeIds)),d=new Map([...i].map(([e,t])=>[e,t.filter(e=>!u.has(e.id))])),f=s.order.map(e=>r.get(e)),p=new oq,m=new Map,h=new Map,g=new Map,_=new Map,v=e=>e.reduce((e,t)=>p.or(e,t),0),y=new Map,b=new Map,x=new Map,S=new Map,C=new Map,w=new Map,T={definition:t,order:f,incoming:i,outgoing:a,forwardIncoming:d,loops:c,outputSchemas:b,inputSchemas:x,firstInputSchemas:S,repeatInputSchemas:C};for(let e of f){let t=d.get(e.id),n=v(t.map(e=>_.get(e.id))),r=p.and(t.length?v(t.map(e=>g.get(e.id))):1,p.not(n)),i=p.or(v(t.map(e=>p.and(g.get(e.id),e.outcome===`failure`||e.outcome===`timeout`?1:h.get(e.from)))),l.has(e.id)?p.and(r,p.outcome(f.length+f.indexOf(e),1)):0);w.set(e.id,r),h.set(e.id,i);let o=f.indexOf(e),s=p.outcome(o,1),c=p.outcome(o,2),u=p.not(p.or(s,c));m.set(e.id,p.and(r,u));let b={success:u,failure:s,timeout:c,true:v([p.outcome(o,0),p.outcome(o,3)]),false:p.outcome(o,4)},x=a.get(e.id),S=p.or(p.and(s,x.some(e=>e.outcome===`failure`)?i:1),p.and(c,x.some(e=>e.outcome===`timeout`)?i:1));for(let e of x){let t=e.outcome===`failure`||e.outcome===`timeout`;g.set(e.id,p.and(r,p.and(b[e.outcome],t?p.not(i):1))),_.set(e.id,p.or(n,t?0:p.and(r,S)))}y.set(e.id,new Set(t.flatMap(e=>[e.from,...y.get(e.from)])))}for(let e of c){let t=v(e.backEdgeIds.map(e=>g.get(e))),n=e.memberIds.map(e=>{let t=v(a.get(e).map(e=>g.get(e.id)));return p.and(m.get(e),p.not(t))}),r=v([...e.exitEdgeIds.map(e=>g.get(e)),...n]);if(p.and(t,r)!==0)throw Error(`Loop ${e.headerId} can select exit and repeat together`)}let E=new Set,D=e=>{let t=b.get(e);if(t)return t;let n=r.get(e),i=_q(n)??n.inputSchema??k(e);return mq(i),b.set(e,i),i},O=(e,n)=>{let a=l.get(e.id),o=n?i.get(e.id).filter(e=>a.backEdgeIds.includes(e.id)):d.get(e.id),s=n?v(o.map(e=>g.get(e.id))):w.get(e.id),c=n?new Set(o.flatMap(e=>[e.from,...y.get(e.from)])):y.get(e.id),u=n?e.repeatMapping:e.mapping,f=e=>{if(e.source===`input`)return vq(t.inputSchema,e.path);let n=r.get(e.stepId);if(!n||!c.has(e.stepId))throw Error(`Mapping must reference an earlier step`);if(!p.implies(s,m.get(n.id)))throw Error(`Output is not guaranteed: ${n.name}`);return vq(D(n.id),e.path)};if(e.kind===`join`&&u)throw Error(`Joins collect selected incoming outputs without mappings`);let h;if(u?.kind===`template`){let e=t=>{t.kind===`reference`&&f(t.reference),t.kind===`object`&&Object.values(t.fields).forEach(e),t.kind===`array`&&t.items.forEach(e)};e(u.template),h={type:`json`}}else if(u?.kind===`reference`){let e=f(u.reference);if(e.optional)throw Error(`A direct input reference must be required or have a default`);h=e.schema}else if(u?.kind===`object`)h={type:`object`,fields:Object.fromEntries(Object.entries(u.fields).map(([e,t])=>{let n=f(t);return[e,{schema:n.schema,required:!n.optional}]}))};else if(!o.length)h=t.inputSchema;else{let t=[...new Set(o.map(e=>e.from))],n=Object.fromEntries(t.map(e=>{let t=r.get(e),n=o.filter(t=>t.from===e),i=xq(n.map(t=>t.outcome===`failure`||t.outcome===`timeout`?Aq(r.get(e).inputSchema??k(e),D(e)):D(e)));return[t.name,{schema:i,required:p.implies(s,v(n.map(e=>g.get(e.id))))}]})),i={type:`object`,fields:n},a=Object.values(n).filter(e=>e.required).length;h=e.kind===`join`||a>1?i:xq([...Object.values(n).map(e=>e.schema),...t.length>1?[i]:[]])}if(e.inputSchema&&(mq(e.inputSchema),!yq(h,e.inputSchema)))throw Error(`Input does not match the declared input schema`);return e.inputSchema??h},k=e=>{let t=x.get(e);if(t)return t;if(E.has(e))throw Error(`Cyclic input schema at ${e}; declare a loop header inputSchema`);E.add(e);let n=r.get(e),i=O(n,!1);S.set(e,i);let a=i;if(l.has(e)){let t=O(n,!0);C.set(e,t),a=xq([i,t])}return x.set(e,a),E.delete(e),a};for(let e of f){e.kind===`mcp`&&(aR(e.tool.inputSchema),e.tool.outputSchema!==void 0&&aR(e.tool.outputSchema));let t=k(e.id);if(e.kind===`branch`){let n=vq(e.inputSchema??t,e.condition.path),r=e.condition.operator===`truthy`?`boolean`:[`greater-than`,`less-than`].includes(e.condition.operator)?`number`:void 0;if(r&&(n.optional||!yq(n.schema,{type:r})))throw Error(`Branch condition requires a required ${r}`)}D(e.id)}return T}function Aq(e,t){return{type:`object`,fields:{input:{schema:e,required:!0},error:{required:!0,schema:{type:`object`,fields:{message:{schema:{type:`string`},required:!0},kind:{schema:{type:`enum`,values:[`failure`,`timeout`,`interrupted`]},required:!0}}}},partialOutput:{schema:bq(t)}}}}function jq(e,t,n){return e.filter(e=>e.backend===t&&(e.projectId===void 0||e.projectId===n))}function Mq(e){return kq(e).definition.inputSchema}function Nq(e,t){return pq(e,t)}function Pq(e){let t=e.scope.trim();if(t!==``&&e.backend!==``)return{type:`create`,scope:t,backend:e.backend,...e.modelId===void 0?{}:{modelId:e.modelId},...e.effort===void 0?{}:{effort:e.effort},...e.inWorktree&&e.repository&&e.base!==``?{worktree:{from:e.base}}:{}}}function Fq(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.group===n.group){e.items.push(n);continue}t.push({group:n.group,items:[n]})}return t}function Iq(e,t){if(t===void 0||t===``)return e;let n=t.endsWith(`/`)?t:`${t}/`;if(!e.startsWith(n))return e;let r=e.slice(n.length);return r===``?e:r}function Lq(e,t){let n=1;for(;e.steps.some(e=>e.name===`${t}_${n}`);)n++;return`${t}_${n}`}function Rq(e){return e&&typeof e==`object`&&`issues`in e&&Array.isArray(e.issues)?e.issues.map(e=>`${e.path?.map(String).join(`.`)||`Workflow`}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function zq(e,t=[]){return[t,...e.type===`json`&&typeof e.schema==`object`&&e.schema.properties&&typeof e.schema.properties==`object`&&!Array.isArray(e.schema.properties)?Object.entries(e.schema.properties).flatMap(([e,n])=>zq({type:`json`,schema:n},[...t,e])):[],...e.type===`object`?Object.entries(e.fields).flatMap(([e,n])=>zq(n.schema,[...t,e])):[]]}function Bq(e,t,n=`reference`,r=`mapping`){if(!e.steps.find(e=>e.id===t))return[];let i={...e,steps:e.steps.map(e=>{if(e.id!==t)return e;let n={...e};return delete n[r],delete n.inputSchema,n})},a;try{a=kq(i)}catch{let t=new Set(sq(e).loops.map(e=>e.headerId));i={...e,loopSettings:{},steps:e.steps.map(e=>{let n={...e};return delete n.inputSchema,n.mapping={kind:`reference`,reference:{source:`input`,path:[]}},t.has(e.id)?n.repeatMapping=n.mapping:delete n.repeatMapping,n.kind===`branch`&&(n.condition={operator:`equals`,path:[],value:null}),n.kind===`agent`&&!n.model&&(n.model=`unselected`),n.kind===`join`&&(delete n.mapping,delete n.repeatMapping),n})},a=kq(i)}let o=zq(e.inputSchema).map(e=>({label:`Workflow input${e.length?`.`+e.join(`.`):``}`,reference:{source:`input`,path:e}})),s=o.splice(0);for(let n of e.steps){if(n.id===t&&r===`mapping`)continue;let e=a.outputSchemas.get(n.id);if(e)for(let t of zq(e)){let e={source:`step`,stepId:n.id,path:t};s.push({label:`${n.name}${t.length?`.`+t.join(`.`):``}`,reference:e})}}for(let e of s){let{reference:a}=e;try{kq({...i,steps:i.steps.map(e=>e.id===t?{...e,[r]:n===`object`?{kind:`object`,fields:{value:a}}:{kind:`reference`,reference:a}}:e)}),o.push(e)}catch{}}return o}function Vq(e,t,n){let r=e.steps.find(e=>e.id===t),i=kq(e),a=r?.kind===`mcp`?{type:`json`,schema:r.tool.inputSchema}:i.inputSchemas.get(t);if(!a)throw Error(`Select a step`);return pq(a,n)}function Hq(e,t,n){if(n)return`The workflow slot is occupied`;if(e.backend!==t)return`Requires Backend Adapter ${e.backend}`;try{kq(e)}catch(e){return Rq(e)}}function Uq(e,t,n){if(!t||[`__proto__`,`constructor`,`prototype`].includes(t))throw Error(`Invalid field name`);return{...e,mapping:{kind:`object`,fields:{...e.mapping?.kind===`object`?e.mapping.fields:{},[t]:n}}}}var Wq=e=>typeof e==`boolean`||typeof e==`object`&&e&&!Array.isArray(e)?e:!0;function Gq(e,t,n=new Set){if(typeof e==`boolean`)return{};let r={...e};if(typeof e.$ref==`string`&&e.$ref.startsWith(`#/`)&&!n.has(e.$ref)){n.add(e.$ref);let i=t;for(let t of e.$ref.slice(2).split(`/`).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)))i=i&&typeof i==`object`&&!Array.isArray(i)?i[t]??!0:!0;r={...Gq(Wq(i),t,n),...r}}for(let i of Array.isArray(e.allOf)?e.allOf:[]){let e=Gq(Wq(i),t,new Set(n));r={...e,...r,properties:{...Kq(e),...Kq(r)},required:[...new Set([...Array.isArray(e.required)?e.required:[],...Array.isArray(r.required)?r.required:[]])]}}return r}function Kq(e){return e.properties&&typeof e.properties==`object`&&!Array.isArray(e.properties)?e.properties:{}}function qq(e){if(e.kind===`reference`)return;if(e.kind===`literal`)return e.value;if(e.kind===`array`){let t=e.items.map(qq);return t.some(e=>e===void 0)?void 0:t}let t=Object.entries(e.fields).map(([e,t])=>[e,qq(t)]);return t.some(([,e])=>e===void 0)?void 0:Object.fromEntries(t)}function Jq(e){return Array.isArray(e)?{kind:`array`,items:e.map(Jq)}:e&&typeof e==`object`?{kind:`object`,fields:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Jq(t)]))}:{kind:`literal`,value:e}}function Yq(e,t=e){let n=Gq(e,t);return n.default!==void 0||n.const!==void 0?Jq(n.default??n.const??null):Array.isArray(n.enum)&&n.enum.length?Jq(n.enum[0]):n.type===`object`||n.properties?{kind:`object`,fields:{}}:n.type===`array`?{kind:`array`,items:[]}:{kind:`literal`,value:n.type===`null`?null:n.type===`boolean`?!1:n.type===`number`||n.type===`integer`?0:``}}function Xq(e,t,n){let r=[],i=n&&typeof n==`object`&&!Array.isArray(n)?n:{};if(e.if!==void 0&&n!==void 0){let i=!1;try{let r=Wq(e.if);oR(typeof r==`boolean`?r:{...typeof t==`object`&&t.$defs?{$defs:t.$defs}:{},...typeof t==`object`&&t.definitions?{definitions:t.definitions}:{},...r},n),i=!0}catch{}r.push(Wq(i?e.then:e.else))}for(let t of[`dependentSchemas`,`dependencies`]){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))for(let[e,t]of Object.entries(n))Object.hasOwn(i,e)&&!Array.isArray(t)&&r.push(Wq(t))}return r.reduce((e,n)=>{let r=Gq(n,t);return{...e,...r,properties:{...Kq(e),...Kq(r)},required:[...new Set([...Array.isArray(e.required)?e.required:[],...Array.isArray(r.required)?r.required:[]])]}},e)}function Zq(e,t){return Wq(Array.isArray(e.prefixItems)?e.prefixItems[t]??e.items:Array.isArray(e.items)?e.items[t]??e.additionalItems:e.items)}function Qq({schema:e,root:t=e,template:n,onChange:r,choices:i=[],label:a=`Arguments`,depth:o=0}){let[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(0),d=Xq(Gq(e,t),t,qq(n)),f=Array.isArray(d.oneOf)?d.oneOf:Array.isArray(d.anyOf)?d.anyOf:Array.isArray(d.type)?d.type.map(e=>({type:e})):[],p=f.length?Gq(Wq(f[l]),t):{},m={...d,...p,properties:{...Kq(d),...Kq(p)}},h=Kq(m),g=qq(n),_=n.kind===`object`?`object`:n.kind===`array`?`array`:g===null?`null`:typeof g,v=(e,n,r,a)=>(0,U.jsx)(Qq,{schema:e,root:t,template:n,onChange:r,choices:i,label:a,depth:o+1});return(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:a}),typeof m.description==`string`&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m.description}),i.length>0&&(0,U.jsxs)(Qn,{value:n.kind===`reference`?JSON.stringify(n.reference):`literal`,onValueChange:n=>{if(n===`literal`)r(Yq(e,t));else{let e=i.find(e=>JSON.stringify(e.reference)===n);e&&r({kind:`reference`,reference:e.reference})}},children:[(0,U.jsx)(Un,{"aria-label":`${a} source`,children:(0,U.jsx)(Xn,{children:n.kind===`reference`?i.find(e=>JSON.stringify(e.reference)===JSON.stringify(n.reference))?.label??`Unavailable reference`:`Literal value`})}),(0,U.jsxs)(Vn,{children:[(0,U.jsx)(Nn,{value:`literal`,children:`Literal value`}),i.map(e=>(0,U.jsx)(Nn,{value:JSON.stringify(e.reference),children:e.label},e.label))]})]}),n.kind!==`reference`&&(0,U.jsxs)(U.Fragment,{children:[f.length>0&&(0,U.jsxs)(Qn,{value:l,onValueChange:e=>{e!==null&&(u(e),r(Yq(Wq(f[e]),t)))},children:[(0,U.jsx)(Un,{"aria-label":`${a} variant`,children:(0,U.jsxs)(Xn,{children:[`Variant `,l+1]})}),(0,U.jsx)(Vn,{children:f.map((e,t)=>(0,U.jsxs)(Nn,{value:t,children:[`Variant `,t+1]},t))})]}),(0,U.jsxs)(Qn,{value:_,onValueChange:e=>{e&&r(Yq({type:e}))},children:[(0,U.jsx)(Un,{"aria-label":`${a} JSON type`,children:(0,U.jsx)(Xn,{children:_})}),(0,U.jsx)(Vn,{children:[`object`,`array`,`string`,`number`,`boolean`,`null`].map(e=>(0,U.jsx)(Nn,{value:e,children:e},e))})]}),Array.isArray(m.enum)&&(0,U.jsxs)(Qn,{value:JSON.stringify(g),onValueChange:e=>{e&&r(Jq(JSON.parse(e)))},children:[(0,U.jsx)(Un,{"aria-label":`${a} enum`,children:(0,U.jsx)(Xn,{children:JSON.stringify(g)})}),(0,U.jsx)(Vn,{children:m.enum.map((e,t)=>(0,U.jsx)(Nn,{value:JSON.stringify(e),children:JSON.stringify(e)},t))})]}),n.kind===`object`&&(0,U.jsxs)(U.Fragment,{children:[[...new Set([...Object.keys(h),...Object.keys(n.fields)])].map(e=>{let i=Object.hasOwn(n.fields,e)?n.fields[e]:void 0,o=m.patternProperties&&typeof m.patternProperties==`object`&&!Array.isArray(m.patternProperties)?Object.entries(m.patternProperties).filter(([t])=>{try{return new RegExp(t).test(e)}catch{return!1}}).map(([,e])=>e):[],s=Wq(Object.hasOwn(h,e)?h[e]:o.length?{allOf:o}:m.additionalProperties);return(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(ht,{"aria-label":`Include ${a}.${e}`,checked:!!i,onCheckedChange:i=>{let a={...n.fields};i?a[e]=Yq(s,t):delete a[e],r({kind:`object`,fields:a})}}),e,Array.isArray(m.required)&&m.required.includes(e)?` *`:``]}),i&&v(s,i,t=>r({kind:`object`,fields:{...n.fields,[e]:t}}),`${a}.${e}`)]},e)}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(et,{"aria-label":`${a} new property`,placeholder:`Additional property name`,value:s,onChange:e=>c(e.target.value)}),(0,U.jsx)(B,{variant:`outline`,size:`sm`,disabled:!s||[`__proto__`,`constructor`,`prototype`].includes(s),onClick:()=>{r({kind:`object`,fields:{...n.fields,[s]:Yq(Wq(m.additionalProperties),t)}}),c(``)},children:`Add property`})]})]}),n.kind===`array`&&(0,U.jsxs)(U.Fragment,{children:[n.items.map((e,t)=>(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[v(Zq(m,t),e,e=>r({kind:`array`,items:n.items.map((n,r)=>r===t?e:n)}),`${a}[${t}]`),(0,U.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>r({kind:`array`,items:n.items.filter((e,n)=>n!==t)}),children:`Remove item`})]},t)),(0,U.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{let e=n.items.length;r({kind:`array`,items:[...n.items,Yq(Zq(m,e),t)]})},children:`Add item`})]}),n.kind===`literal`&&_===`boolean`&&(0,U.jsx)(ht,{"aria-label":a,checked:g===!0,onCheckedChange:e=>r({kind:`literal`,value:e})}),n.kind===`literal`&&(_===`string`||_===`number`)&&(0,U.jsx)(et,{"aria-label":a,type:_===`number`?`number`:`text`,value:g,onChange:e=>r({kind:`literal`,value:_===`number`?Number(e.target.value):e.target.value})})]}),(0,U.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,U.jsx)(`summary`,{children:`Original schema and constraints`}),(0,U.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap`,children:JSON.stringify(e,null,2)})]})]})}function $q({schema:e,value:t,onChange:n,label:r}){return(0,U.jsx)(Qq,{schema:e,template:Jq(t),label:r,onChange:e=>{let t=qq(e);t!==void 0&&n(t)}})}function eJ(e){return e===`object`?{type:e,fields:{}}:e===`array`?{type:e,items:{type:`string`}}:e===`enum`?{type:e,values:[`value`]}:e===`union`?{type:e,variants:[{type:`string`}]}:{type:e}}function tJ(e){switch(e.type){case`json`:return{};case`null`:return null;case`object`:return Object.fromEntries(Object.entries(e.fields).filter(([,e])=>e.required||e.default!==void 0).map(([e,t])=>[e,t.default??tJ(t.schema)]));case`array`:return[];case`number`:return 0;case`boolean`:return!1;case`enum`:return e.values[0]??``;case`union`:return tJ(e.variants[0]);default:return``}}function nJ({schema:e,value:t,onChange:n,onClear:r,label:i=`Value`}){let[a,o]=(0,H.useState)(0);if(e.type===`json`)return(0,U.jsx)($q,{schema:e.schema??!0,value:t??null,label:i,onChange:n});if(e.type===`null`)return(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`null`});if(e.type===`object`){let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{};return(0,U.jsx)(`div`,{className:`grid gap-3`,children:Object.entries(e.fields).map(([e,t])=>(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`span`,{className:`text-sm font-medium`,children:[e,t.required?` *`:``]}),!t.required&&(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(ht,{"aria-label":`Include ${e}`,checked:Object.hasOwn(r,e),onCheckedChange:i=>{let a={...r};i?a[e]=t.default??tJ(t.schema):delete a[e],n(a)}}),`Include`]}),(0,U.jsx)(nJ,{schema:t.schema,label:i===`Value`?e:`${i}.${e}`,value:r[e]??t.default,onClear:()=>{let t={...r};delete t[e],n(t)},onChange:t=>n({...r,[e]:t})})]},e))})}return e.type===`array`?(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(Array.isArray(t)?t:[]).map((r,a)=>(0,U.jsxs)(`div`,{className:`grid gap-2 rounded-lg border p-3`,children:[(0,U.jsx)(nJ,{schema:e.items,label:`${i} item ${a+1}`,value:r,onChange:e=>n(t.map((t,n)=>n===a?e:t))}),(0,U.jsx)(B,{size:`sm`,variant:`destructive`,className:`justify-self-start`,onClick:()=>n(t.filter((e,t)=>t!==a)),children:`Remove item`})]},a)),(0,U.jsx)(B,{size:`sm`,variant:`outline`,className:`justify-self-start`,onClick:()=>n([...Array.isArray(t)?t:[],tJ(e.items)]),children:`Add item`})]}):e.type===`union`?(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(Qn,{value:a,onValueChange:t=>{t!==null&&(o(t),n(tJ(e.variants[t])))},children:[(0,U.jsx)(Un,{className:`w-full`,"aria-label":i===`Value`?`Input variant`:`${i} variant`,children:(0,U.jsx)(Xn,{children:`Variant ${a+1}: ${e.variants[a]?.type??``}`})}),(0,U.jsx)(Vn,{children:e.variants.map((e,t)=>(0,U.jsxs)(Nn,{value:t,children:[`Variant `,t+1,`: `,e.type]},t))})]}),(0,U.jsx)(nJ,{schema:e.variants[a]??e.variants[0],label:i,value:t,onChange:n})]}):e.type===`boolean`?(0,U.jsx)(ht,{"aria-label":i,checked:t===!0,onCheckedChange:n}):e.type===`enum`?(0,U.jsxs)(Qn,{value:typeof t==`string`?t:``,onValueChange:e=>{e!==null&&n(e)},children:[(0,U.jsx)(Un,{className:`w-full`,"aria-label":i,children:(0,U.jsx)(Xn,{children:typeof t==`string`&&t?t:`Select`})}),(0,U.jsxs)(Vn,{children:[!e.values.includes(``)&&(0,U.jsx)(Nn,{value:``,children:`Select`}),e.values.map(e=>(0,U.jsx)(Nn,{value:e,children:e||`Empty string`},e))]})]}):(0,U.jsx)(et,{"aria-label":i,type:e.type===`number`?`number`:`text`,value:typeof t==`string`||typeof t==`number`?t:``,onChange:t=>e.type===`number`&&t.target.value===``&&r?r():n(e.type===`number`?t.target.value===``?null:Number(t.target.value):t.target.value)})}function rJ({schema:e,onChange:t,root:n=!1}){return(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:`Schema`}),!n&&(0,U.jsxs)(Qn,{value:e.type,onValueChange:e=>{e!==null&&t(eJ(e))},children:[(0,U.jsx)(Un,{className:`w-full`,"aria-label":`Schema type`,children:(0,U.jsx)(Xn,{children:e.type})}),(0,U.jsx)(Vn,{children:[`object`,`array`,`string`,`number`,`boolean`,`enum`,`json`,`null`].map(e=>(0,U.jsx)(Nn,{value:e,children:e},e))})]}),e.type===`enum`&&(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`Values (one per line)`}),(0,U.jsx)(RE,{value:e.values.join(`
169
169
  `),onChange:n=>t({...e,values:n.target.value.split(`
170
- `)})})]}),e.type===`array`&&(0,U.jsx)(rJ,{schema:e.items,onChange:n=>t({...e,items:n})}),e.type===`object`&&(0,U.jsxs)(U.Fragment,{children:[Object.entries(e.fields).map(([n,r])=>(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:n}),(0,U.jsx)(B,{size:`sm`,variant:`destructive`,className:`justify-self-start`,onClick:()=>t({...e,fields:Object.fromEntries(Object.entries(e.fields).filter(([e])=>e!==n))}),children:`Remove field`}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(ht,{checked:!!r.required,onCheckedChange:i=>t({...e,fields:{...e.fields,[n]:{...r,required:i}}})}),`Required`]}),(0,U.jsx)(rJ,{schema:r.schema,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,schema:i}}})}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(ht,{checked:r.default!==void 0,onCheckedChange:i=>{let a={...r};i?a.default=tJ(r.schema):delete a.default,t({...e,fields:{...e.fields,[n]:a}})}}),`Default`]}),r.default!==void 0&&(0,U.jsx)(nJ,{schema:r.schema,value:r.default,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,default:i}}})})]},n)),(0,U.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault();let r=n.currentTarget,i=String(new FormData(r).get(`field`));i&&![`__proto__`,`constructor`,`prototype`].includes(i)&&!e.fields[i]&&(t({...e,fields:{...e.fields,[i]:{schema:{type:`string`}}}}),r.reset())},children:[(0,U.jsx)(et,{className:`min-w-0 flex-1`,name:`field`,"aria-label":`New field name`,placeholder:`Field name`,required:!0}),(0,U.jsx)(B,{type:`submit`,size:`sm`,variant:`outline`,children:`Add field`})]})]})]})}var iJ=Iw,aJ=Xw;function oJ({className:e,children:t,...n}){return(0,U.jsx)(Zw,{children:(0,U.jsxs)(Qw,{onKeyDown:e=>{e.key===`Enter`&&e.stopPropagation()},className:z(`group flex w-full items-center gap-2 rounded-lg py-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,e),...n,children:[t,(0,U.jsx)(dn,{className:`ml-auto size-4 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-180`})]})})}function sJ({className:e,...t}){return(0,U.jsx)(sT,{className:z(`pb-3`,e),...t})}var cJ=_e(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-2xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function lJ({className:e,variant:t=`default`,render:n,...r}){return LE({defaultTagName:`span`,props:Pt({className:z(cJ({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}function uJ({initialBackend:e,drafts:t,onCreated:n}){let{config:r,refresh:i}=Dt(),a=ra(),[o,s]=(0,H.useState)(`chat`),[c,l]=(0,H.useState)({}),u=(r.mcp??[]).filter(e=>c[e.id]??e.enabledByDefault).map(e=>e.id),d=r.projectList??[],f=(r.projectCandidates??[]).length,[p,m]=(0,H.useState)(()=>t.scope()),h=d.find(e=>e.path===p),g=h?.path,[_,v]=(0,H.useState)(e),y=_??cN(r.backends,r.providers?.defaultBackend)??``,[b,x]=(0,H.useState)(),[S,C]=(0,H.useState)(),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(),[O,k]=(0,H.useState)(),A=(0,H.useRef)(null);(0,H.useEffect)(()=>{i()},[i]);let j=Ew(g);(0,H.useEffect)(()=>{r.git!==!1&&j.load()},[g,r.git]);let M=fN(g,y),N=j.list?.repository===!0,P=j.list?.head,F=P?.detached?void 0:P?.name,I=E??F??``,{catalogue:ee,loading:te,problem:ne,refresh:L}=dN(),R=ee?.find(e=>e.backend===y),re=R?.models.find(e=>e.id===b)??mN(ee,r.providers?.defaults,y),ie=te?`Checking model capabilities before starting agent work…`:ne??R?.problem??(R?re?void 0:`No confirmed model is available for ${y}.`:`Model capabilities for ${y||`this backend`} are unavailable.`),ae=r.providers?.efforts?.[y],oe=re?.effortLevels??[],se=S===void 0&&ae!==void 0&&re&&(oe.length>0?!oe.includes(ae):ae!==`off`)?oe.length>0?`Saved Default Effort “${ae}” is unsupported for ${re?.label??re?.id}. Select a supported Effort here or correct Provider Settings.`:`Saved Default Effort “${ae}” is invalid because ${re?.label??re?.id} has no Effort control. Clear it in Provider Settings.`:void 0,ce=ie??se,le=Pq({scope:g??``,backend:y,modelId:re?.id,effort:S,inWorktree:w,repository:N,base:I}),ue=w?I===``?void 0:{name:I}:P,de=(0,H.useMemo)(()=>({status:`idle`,backend:y,scope:g,capabilities:R&&!ie?{providers:[],models:R.models,compaction:!1,fork:!1,subagents:!1,enquiries:!1,permissions:!1}:void 0,model:re,effort:S,branch:ue,worktree:void 0,contextUsage:void 0,endedReason:void 0,queueDepth:0,activeSubagents:0,activeBackgroundCalls:0,asking:void 0,authorising:void 0,compacting:!1,spoken:!1,link:`live`}),[y,R,ie,S,re,g,ue]),fe=(0,H.useCallback)(async()=>{if(!le)return;k(void 0);let e=await a({...le,mcpConnectionIds:u});return e||k(`The Session Host refused this. Check the Project and branch to cut from.`),e},[le,u,a]),pe=(0,H.useCallback)(async(e,r)=>{let i=await fe();if(!i)return;let o=e===``&&r.length===0||await a({type:`send`,sessionId:i,text:e,...r.length?{attachments:r}:{},when:`after_turn`});return t.write(Xa,{text:``,attachments:[]}),n(i),o},[fe,t,n,a]),me=(0,H.useMemo)(()=>({send:pe,setModel:e=>{x(e);let t=R?.models.find(t=>t.id===e)?.effortLevels??[];C(e=>e&&t.includes(e)?e:void 0)},setEffort:C,switchBranch:async e=>{if(w)return D(e),!0;if(!g)return!1;let t=await a({type:`switch_scope_branch`,scope:g,branch:e});return t!==void 0&&j.load(),t!==void 0},listSkills:M}),[R,j,w,M,a,g,pe]),he=bt(o===`workflow`?`/api/workflows`:void 0,1e4),ge=(0,H.useMemo)(()=>jq(he.data?.workflows??[],y,p),[y,he.data,p]),[_e,ve]=(0,H.useState)(``),[ye,be]=(0,H.useState)({}),xe=ge.find(e=>e.id===_e),Se=(0,H.useMemo)(()=>{if(!xe)return{};try{return{schema:Mq(xe)}}catch(e){return{issue:Rq(e)}}},[xe]);(0,H.useEffect)(()=>{_e&&!ge.some(e=>e.id===_e)&&(ve(``),be({}))},[ge,_e]);let Ce,we=``;if(Se.issue)we=Se.issue;else if(Se.schema)try{Ce=Nq(Se.schema,ye)}catch(e){we=Rq(e)}let Te=xe?.steps.some(e=>e.kind===`shell`||e.kind===`typescript`)===!0,Ee=bt(o===`workflow`&&Te?`/api/workflow-runtime`:void 0,5e3),De=Te?Ee.error||(Ee.data===void 0?`Checking workflow runtime…`:Ee.data.available?``:Ee.data.error??`Workflow runtime is unavailable`):``,[Oe,ke]=(0,H.useState)(!1),Ae=(0,H.useRef)(!1),je=(0,H.useCallback)(async()=>{if(Ae.current||!xe||Ce===void 0||we||De)return;Ae.current=!0,ke(!0),k(void 0);let e=Ce,t=crypto.randomUUID();try{let r=await fe();if(!r)return;try{await jt(`/api/sessions/${encodeURIComponent(r)}/workflows`,`POST`,{workflowId:xe.id,input:e,launchId:t,nameSession:!0})}catch(n){Ji(r,{launchId:t,workflowId:xe.id,input:e,error:Rq(n)})}n(r,!0)}finally{Ae.current=!1,ke(!1)}},[fe,we,n,De,Ce,xe]);(0,H.useEffect)(()=>{g===void 0?A.current?.querySelector(`button`)?.focus():document.querySelector(`[data-new-session] [data-composer-input]`)?.focus()},[]),(0,H.useEffect)(()=>()=>{p!==void 0&&t.setScope(p)},[t,p]);let Me=Fq(d);return(0,U.jsx)(`div`,{"data-new-session":``,className:`transcript-scroller min-h-0 overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-5 px-4 py-12 sm:px-6`,children:[(0,U.jsx)(`h1`,{className:`text-center text-lg font-medium`,children:`New Agent Session`}),(0,U.jsxs)($k,{value:o,onValueChange:e=>{(e===`chat`||e===`workflow`)&&s(e)},className:`contents`,children:[(0,U.jsx)(eA,{"aria-label":`New Agent Session mode`,className:`mx-auto`,children:[`chat`,`workflow`].map(e=>(0,U.jsx)(tA,{value:e,className:`min-w-24 capitalize`,children:e},e))}),d.length===0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(nA,{value:`chat`,children:(0,U.jsx)(fJ,{uncurated:f})}),(0,U.jsx)(nA,{value:`workflow`,children:(0,U.jsx)(fJ,{uncurated:f})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,U.jsxs)(Qn,{value:y,onValueChange:e=>{typeof e==`string`&&(v(e),x(void 0),C(void 0))},children:[(0,U.jsx)(Un,{"aria-label":`Backend`,size:`sm`,className:z(Mw,`w-auto`),children:(0,U.jsx)(Xn,{children:()=>y})}),(0,U.jsx)(Vn,{children:r.backends.map(e=>(0,U.jsx)(Nn,{value:e,children:e},e))})]}),(0,U.jsx)(dJ,{fieldRef:A,groups:Me,projects:d,project:h,onPick:e=>{m(e.path),D(void 0),T(!1)}})]}),ce?(0,U.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground`,role:`status`,children:[(0,U.jsx)(`span`,{children:ce}),!te&&ie?(0,U.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>void L(),children:`Check again`}):null]}):null,(0,U.jsx)(nA,{value:`chat`,keepMounted:!0,className:`grid gap-3`,children:(0,U.jsx)(pD,{id:Xa,chrome:de,actions:me,floating:!1,unavailable:y===``?`This Session Host advertises no backend`:ce,placeholder:`What should it work on? Enter starts the Agent Session.`,drafts:t,authorisingSummary:void 0,onShowSubagents:()=>{}})}),(0,U.jsxs)(nA,{value:`workflow`,keepMounted:!0,className:`grid gap-4 rounded-xl border bg-card/30 p-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`font-medium`,children:`Start with a workflow`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The workflow runs independently, so the parent chat stays available for questions and follow-up work.`})]}),he.error?(0,U.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not load workflows: `,he.error]}):he.data===void 0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading compatible workflows…`}):ge.length===0?(0,U.jsxs)(`p`,{className:`rounded-lg border border-dashed p-4 text-sm text-muted-foreground`,children:[`No global or `,h?.name,` workflows use Backend Adapter `,y,`.`]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Workflow`}),(0,U.jsxs)(Qn,{value:_e,onValueChange:e=>{if(e===null)return;let t=ge.find(t=>t.id===e);ve(e),be(t?tJ(t.inputSchema):{})},children:[(0,U.jsx)(Un,{className:`w-full`,"aria-label":`Workflow`,children:(0,U.jsx)(Xn,{children:xe?.name??`Select a workflow`})}),(0,U.jsxs)(Vn,{children:[(0,U.jsx)(Nn,{value:``,children:`Select a workflow`}),ge.map(e=>(0,U.jsxs)(Nn,{value:e.id,children:[e.name,e.projectId===void 0?` · Global`:``]},e.id))]})]})]}),xe?(0,U.jsxs)(`div`,{className:`grid gap-4`,children:[(0,U.jsxs)(`fieldset`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:`Inputs`}),(0,U.jsx)(nJ,{schema:xe.inputSchema,value:ye,onChange:be})]}),(we||De)&&(0,U.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:we||De}),(0,U.jsx)(B,{className:`justify-self-start`,disabled:Oe||!le||Ce===void 0||!!we||!!De||!!ce,onClick:()=>void je(),children:Oe?`Starting workflow…`:`Create Agent Session and start`})]}):null]}),(0,U.jsx)(`div`,{className:`overflow-hidden rounded-xl border bg-background`,children:(0,U.jsx)(dD,{chrome:de,actions:me})})]}),(r.mcp??[]).length>0&&(0,U.jsx)(iJ,{children:(0,U.jsxs)(aJ,{value:`mcp`,children:[(0,U.jsxs)(oJ,{children:[`MCP connections`,(0,U.jsx)(lJ,{variant:`secondary`,"aria-label":`${u.length} enabled`,children:u.length})]}),(0,U.jsx)(sJ,{className:`flex flex-col gap-3`,children:r.mcp.map(e=>(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[e.name,(0,U.jsx)(ht,{checked:c[e.id]??e.enabledByDefault,onCheckedChange:t=>l(n=>({...n,[e.id]:t}))})]},e.id))})]})}),N&&r.git!==!1?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:w,onChange:e=>T(e.target.checked)}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Start in a new worktree`})]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w?(0,U.jsx)(U.Fragment,{children:`The branch above is what it will be cut from; a name is chosen for you. The worktree is kept by the Session Host and removed when this Agent Session is reaped, but only if nothing is uncommitted.`}):(0,U.jsxs)(U.Fragment,{children:[`This Agent Session shares `,h?.name??`the Project`,`’s checkout, so choosing a branch above moves it — for anything else already working there too. A worktree gives this one its own.`]})})]}):null,O?(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:O}):null]})]})]})})}function dJ({fieldRef:e,groups:t,projects:n,project:r,onPick:i}){return(0,U.jsx)(`label`,{ref:e,className:`flex`,children:(0,U.jsxs)(GE,{items:t,value:r??null,isItemEqualToValue:(e,t)=>e.path===t.path,itemToStringLabel:pJ,itemToStringValue:e=>e.path,onValueChange:e=>{let t=e;t&&i(t)},children:[(0,U.jsx)(qE,{"aria-label":`Project`,render:(0,U.jsx)(B,{variant:`ghost`,size:`sm`,className:z(Mw,`w-auto`)}),children:(0,U.jsx)(KE,{children:e=>e===null?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`Choose a Project`}):(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:pJ(e)})})}),(0,U.jsxs)(XE,{children:[(0,U.jsx)(YE,{showTrigger:!1,placeholder:`Filter ${n.length} ${n.length===1?`Project`:`Projects`}`}),(0,U.jsx)(ZE,{children:e=>(0,U.jsxs)($E,{items:e.items,children:[e.group===void 0?null:(0,U.jsx)(eD,{children:e.group}),(0,U.jsx)(tD,{children:e=>(0,U.jsx)(QE,{value:e,children:(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.name})},e.path)})]},e.group??``)}),(0,U.jsx)(nD,{children:`No Project matches.`})]})]})})}function fJ({uncurated:e}){return(0,U.jsxs)(`p`,{className:`rounded-xl border border-dashed px-4 py-6 text-center text-sm text-muted-foreground`,children:[`No Projects yet. `,e>0?(0,U.jsxs)(U.Fragment,{children:[e,` `,e===1?`repository was`:`repositories were`,` found beneath the Project Root — opt in under Settings → Projects to start an Agent Session in one.`]}):(0,U.jsx)(U.Fragment,{children:`Add one under Settings → Projects to start an Agent Session in it.`})]})}function pJ(e){return e.group===void 0?e.name:`${e.group}/${e.name}`}function mJ({width:e,onResize:t,onNudge:n}){let{toggleSidebar:r,state:i}=SM(),{dragging:a,onPointerDown:o}=vD({grow:1,axis:`col`,variable:`--sidebar-width`,container:e=>e.closest(`[data-slot="sidebar-wrapper"]`),size:e,clamp:e=>Qa(e),onCommit:t,onClick:r});return(0,U.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the rail`,"aria-valuenow":e,"aria-valuemin":180,"aria-valuemax":520,tabIndex:0,onPointerDown:o,onKeyDown:e=>{if(e.key===`ArrowLeft`)n(-1,e.shiftKey);else if(e.key===`ArrowRight`)n(1,e.shiftKey);else if(e.key===`Enter`||e.key===` `)r();else return;e.preventDefault(),e.stopPropagation()},title:`Drag to resize, click to collapse`,className:z(`absolute inset-y-0 -right-2 z-20 hidden w-4 shrink-0 cursor-col-resize sm:block`,`after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] after:-translate-x-1/2`,`hover:after:bg-sidebar-border focus-visible:after:bg-sidebar-ring focus-visible:outline-hidden`,a&&`after:bg-sidebar-ring`,i===`collapsed`&&`cursor-e-resize hover:bg-sidebar`)})}var hJ=36e5,gJ=1e4,_J=2e3,vJ=1e4;function yJ(e,t){return t-e>=3e4?`recovery-needed`:`reconnecting`}function bJ(e,t,n){return t===`starting`?`updating`:t===`reconnecting`?`reconnecting`:t===`recovery-needed`?`recovery-needed`:e?.operation?.state===`updating`?`updating`:e?.operation?.state===`unverified`?`recovery-needed`:t===`checking`?`checking`:n?`error`:e?.updateAvailable&&e.eligibility.state===`unsupported`?`unsupported`:e?.updateAvailable&&e.eligibility.state===`blocked`?`blocked`:e?.operation?.state===`failed`?`failure`:e?.eligibility.state===`eligible`&&e.updateAvailable?`available`:e?.operation?.state===`succeeded`?`success`:e?.checkError?`error`:e?.eligibility.state===`unsupported`?`unsupported`:e?.eligibility.state===`blocked`?`blocked`:e?.updateAvailable?`available`:`up-to-date`}function xJ(e,t,n={}){let r=CJ(t);switch(e){case`checking`:return`Checking the npm registry for the latest stable release…`;case`up-to-date`:return`Flow ${t?.installedVersion??``} is up to date.`;case`available`:return`Flow ${t?.latestVersion} is available and this installation can update safely.`;case`unsupported`:return wJ(t?.eligibility.state===`unsupported`?t.eligibility.reason:`This installation cannot update itself.`,r);case`blocked`:return wJ(t?.eligibility.state===`blocked`?t.eligibility.reason:`Active work must finish before Flow can update.`,r);case`updating`:return`The guarded npm update is running independently of this browser. The Session Host will restart shortly.`;case`reconnecting`:return`The Session Host is restarting. Flow will reconnect and verify the running version automatically.`;case`success`:return TJ(`${t?.operation?.message??`The update was verified.`} Updated web assets are loaded; Agent Sessions remain Dormant until you Revive them.`,t);case`failure`:return TJ(`${t?.operation?.message??`The update failed.`} The Session Host recovered, but this remains a failed update.`,t);case`recovery-needed`:return`Flow could not verify recovery. Reconnect below; if the host remains unavailable, repair the private global npm installation manually and restart it.${t?.operation?.message?` Last known update status: ${t.operation.message}`:``}`;case`error`:return n.actionError??t?.checkError??n.transportError??`Could not check for updates. Normal Flow use is unaffected.`}}function SJ(e,t){return e?.eligibility.state===`eligible`&&e.updateAvailable&&e.latestVersion!==void 0&&[`available`,`failure`].includes(t)}function CJ(e){let t=e?.operation;if(t?.state===`succeeded`){let e=t.installedVersion??t.targetVersion;return`The previous update${e?` to Flow ${e}`:``} was verified successfully.`}if(t?.state===`failed`)return`The previous update failed${t.message?`: ${t.message}`:`.`}`}function wJ(e,t){return t?`${e} ${t}`:e}function TJ(e,t){return t?.checkError?`${e} The latest release check also failed: ${t.checkError} Use Check for updates to retry; normal Flow use is unaffected.`:e}var EJ=class{current={view:`checking`};listeners=new Set;reconnectingSince;pollTimer;pollDelay;hourlyTimer;started=!1;lifecycleRevision=0;statusRequestSequence=0;options;constructor(e){this.options=e}get snapshot(){return this.current}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}start(){this.started||(this.started=!0,this.check(!1),this.hourlyTimer=this.options.setInterval(()=>{this.check(!1)},hJ),this.syncPolling())}stop(){this.started=!1,this.hourlyTimer!==void 0&&this.options.clearInterval(this.hourlyTimer),this.hourlyTimer=void 0,this.clearPoll()}async check(e=!1){if(this.current.view===`starting`)return;let t=this.lifecycleRevision,n=++this.statusRequestSequence;e&&!this.operationMayBeRunning()&&this.publish({...this.current,view:`checking`});try{let r=await this.options.getStatus(e),i=await r.json();if(!r.ok)throw Error(i.error??`Could not check for updates (${r.status})`);if(!this.acceptStatusResponse(t,n))return;this.reconnectingSince=void 0,this.publish({status:i,view:`ready`}),i.operation?.state===`succeeded`&&this.options.onSucceeded?.(i.operation.id)}catch(e){if(!this.acceptStatusResponse(t,n))return;let r=OJ(e,`Could not reach the Session Host`);if(!this.operationMayBeRunning()){this.publish({...this.current,view:`ready`,transportError:r});return}this.reconnectingSince??=this.options.now(),this.publish({...this.current,view:yJ(this.reconnectingSince,this.options.now()),transportError:r})}}async begin(e){this.lifecycleRevision++,this.publish(DJ({...this.current,view:`starting`}));let t=new AbortController,n,r=new Promise((e,r)=>{n=this.options.setTimeout(()=>{r(Error(`The update request timed out and may have started; reconnecting to verify it`)),t.abort()},gJ)}),i,a;try{({response:i,body:a}=await Promise.race([this.readMutationResponse(e,t.signal),r]))}catch(e){this.reconnectingSince=this.options.now(),this.publish({...this.current,view:`reconnecting`,transportError:OJ(e,`The update request may have started; reconnecting to verify it`)});return}finally{n!==void 0&&this.options.clearTimeout(n)}if(!i.ok)throw this.reconnectingSince=void 0,this.publish(DJ({...this.current,view:`ready`})),Error(a.error??`Could not start the update (${i.status})`);this.reconnectingSince=this.options.now(),this.publish(DJ({status:a,view:`reconnecting`}))}async readMutationResponse(e,t){let n=await this.options.beginUpdate(e,t);return{response:n,body:await n.json()}}acceptStatusResponse(e,t){return e===this.lifecycleRevision&&t===this.statusRequestSequence}publish(e){this.current=e;for(let t of this.listeners)t(e);this.syncPolling()}operationMayBeRunning(){return this.reconnectingSince!==void 0||[`updating`,`unverified`].includes(this.current.status?.operation?.state??``)||[`starting`,`reconnecting`,`recovery-needed`].includes(this.current.view)}shouldPoll(){return[`updating`,`unverified`].includes(this.current.status?.operation?.state??``)||this.current.view===`reconnecting`||this.current.view===`recovery-needed`}syncPolling(){if(!this.started||!this.shouldPoll()){this.clearPoll();return}let e=this.current.view===`recovery-needed`||this.current.status?.operation?.state===`unverified`?vJ:_J;(this.pollTimer===void 0||this.pollDelay!==e)&&(this.clearPoll(),this.pollDelay=e,this.pollTimer=this.options.setTimeout(()=>{this.pollTimer=void 0,this.pollDelay=void 0,!(!this.started||!this.shouldPoll())&&this.check(!1).finally(()=>this.syncPolling())},e))}clearPoll(){this.pollTimer!==void 0&&this.options.clearTimeout(this.pollTimer),this.pollTimer=void 0,this.pollDelay=void 0}};function DJ(e){let{transportError:t,...n}=e;return n}function OJ(e,t){return e instanceof Error&&e.message?e.message:t}var kJ=(0,H.createContext)(void 0);function AJ(){let e=(0,H.useContext)(kJ);if(!e)throw Error(`useUpdates outside UpdatesProvider`);return e}function jJ({children:e}){let[t]=(0,H.useState)(()=>new EJ({getStatus:e=>kt(`/api/update${e?`?refresh=1`:``}`,{cache:`no-store`,signal:AbortSignal.timeout(1e4)}),beginUpdate:(e,t)=>kt(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({confirmed:!0,version:e}),signal:t}),now:()=>Date.now(),setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e),setInterval:(e,t)=>window.setInterval(e,t),clearInterval:e=>window.clearInterval(e),onSucceeded:e=>{let t=`flow-update-reloaded:${e}`;sessionStorage.getItem(t)!==`yes`&&(sessionStorage.setItem(t,`yes`),location.reload())}})),[n,r]=(0,H.useState)(t.snapshot);(0,H.useEffect)(()=>{let e=t.subscribe(r);return t.start(),()=>{e(),t.stop()}},[t]);let i=(0,H.useCallback)((e=!1)=>t.check(e),[t]),a=(0,H.useCallback)(e=>t.begin(e),[t]);return(0,U.jsx)(kJ.Provider,{value:{...n,check:i,begin:a},children:e})}var MJ={workflows:{label:`Workflows`,hint:`Visual workflow definitions`,icon:Zo},mcp:{label:`MCP`,hint:`Local and remote tools`,icon:Zo},secrets:{label:`Secrets`,hint:`Named secrets and code runtime`,icon:Xo},general:{label:`General`,hint:`Updates, retention, and this host`,icon:Zo},projects:{label:`Projects`,hint:`Where your repositories live`,icon:Po},permissions:{label:`Permissions`,hint:`Tools allowed without asking`,icon:Xo},providers:{label:`Providers`,hint:`Which models to use`,icon:jo},appearance:{label:`Appearance`,hint:`The two typefaces`,icon:es},keyboard:{label:`Keyboard`,hint:`Every shortcut`,icon:Io}};function NJ({section:e,onSelect:t,onLeave:n}){let{config:r}=Dt(),{status:i}=AJ(),{isMobile:a,setOpenMobile:o}=SM(),s=e=>{t(e),a&&o(!1)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(DM,{className:`flex-row items-center gap-1 border-b border-sidebar-border`,children:(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Settings`})}),(0,U.jsx)(AM,{className:`transcript-scroller gap-0`,children:(0,U.jsx)(jM,{className:`p-0`,children:(0,U.jsx)(NM,{children:(0,U.jsx)(PM,{className:`gap-0`,"aria-label":`Settings sections`,children:co.map(t=>{let{label:n,hint:r,icon:a}=MJ[t],o=t===e;return(0,U.jsx)(FM,{children:(0,U.jsxs)(LM,{size:`lg`,isActive:o,"aria-current":o?`page`:void 0,onClick:()=>s(t),className:z(`rounded-none py-1.5 border-l-2 border-l-transparent`,o&&`border-l-primary`),children:[(0,U.jsx)(a,{"aria-hidden":!0}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-sm`,children:n}),(0,U.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})]}),t===`general`&&i?.updateAvailable?(0,U.jsx)(lJ,{variant:`secondary`,className:`px-1.5`,children:`Update`}):null]})},t)})})})})}),(0,U.jsxs)(OM,{className:`border-t border-sidebar-border py-1.5`,children:[r.authentication===`oidc`?(0,U.jsx)(`form`,{action:`/oauth/logout`,method:`post`,children:(0,U.jsxs)(B,{type:`submit`,variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,children:[(0,U.jsx)(zo,{"aria-hidden":!0}),`Sign out of Flow`]})}):null,(0,U.jsxs)(B,{variant:`ghost`,size:`sm`,className:`justify-start gap-2`,onClick:()=>{n(),a&&o(!1)},children:[(0,U.jsx)(So,{"aria-hidden":!0}),`Back to Agent Sessions`]})]})]})}function PJ(e,t,n){if(t===`never`)return[];let r=uN(t);return r===void 0||r<=0?[]:e.filter(e=>{if(e.status!==`settled`||e.settledAt===void 0)return!1;let t=Date.parse(e.settledAt);return!Number.isNaN(t)&&n-t>=r})}function FJ({title:e,description:t,children:n}){return(0,U.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold`,children:e}),t===void 0?null:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),n]})}function IJ({label:e,children:t}){return(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b py-1.5 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-right font-mono text-xs`,children:t})]})}function LJ(){let{saveSettings:e}=Dt(),[t,n]=(0,H.useState)(!1);return{save:(0,H.useCallback)(async(t,r)=>{n(!0);try{return await e(t),p.info(r),!0}catch(e){return p.error(e instanceof Error?e.message:`Could not save the Settings`),!1}finally{n(!1)}},[e]),saving:t}}function RJ({dirty:e,saving:t,saveDisabled:n=!1,onSave:r,onReset:i}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(B,{size:`sm`,disabled:!e||t||n,onClick:r,children:t?`Saving…`:`Save`}),(0,U.jsx)(B,{size:`sm`,variant:`ghost`,disabled:!e||t,onClick:i,children:`Discard`})]})}function zJ(){let{status:e,view:t,transportError:n,check:r,begin:i}=AJ(),[a,o]=(0,H.useState)(),[s,c]=(0,H.useState)(),l=bJ(e,t,n??s),u=xJ(l,e,{actionError:s,transportError:n});(0,H.useEffect)(()=>{r(!1)},[]);let d=[`checking`,`updating`,`reconnecting`].includes(l),f=SJ(e,l)?e?.latestVersion:void 0,p=async e=>{o(void 0),c(void 0);try{await i(e)}catch(e){c(e instanceof Error?e.message:`Could not start the update`)}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(FJ,{title:`Flow update`,description:`Discover and install the latest stable npm release. Updates are never automatic.`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(IJ,{label:`Installed`,children:e?.installedVersion??`checking…`}),(0,U.jsx)(IJ,{label:`Latest`,children:e?.latestVersion??(e?.checkError?`check failed`:`checking…`)})]}),(0,U.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border bg-muted/35 px-3 py-2.5 text-sm`,role:`status`,"aria-live":`polite`,"data-update-state":l,children:[d?(0,U.jsx)(Ro,{className:`mt-0.5 size-4 shrink-0 animate-spin`,"aria-hidden":!0}):l===`success`?(0,U.jsx)(ko,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":!0}):[`error`,`failure`,`recovery-needed`,`blocked`,`unsupported`].includes(l)?(0,U.jsx)(Oo,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,U.jsx)(Mo,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:BJ(l)}),e?.updateAvailable?(0,U.jsxs)(lJ,{variant:`secondary`,children:[e.latestVersion,` available`]}):null]}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-muted-foreground`,children:u})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsxs)(B,{size:`sm`,variant:`outline`,disabled:d,onClick:()=>{c(void 0),r(!0)},children:[(0,U.jsx)(qo,{"aria-hidden":!0}),`Check for updates`]}),f?(0,U.jsxs)(B,{size:`sm`,onClick:()=>o(f),children:[(0,U.jsx)(Mo,{"aria-hidden":!0}),`Update to `,f]}):null,l===`recovery-needed`?(0,U.jsx)(B,{size:`sm`,onClick:()=>{c(void 0),r(!1)},children:`Reconnect`}):null]}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Only the fixed `,(0,U.jsx)(`code`,{className:`font-mono`,children:`@nathanstephenson/flow@latest`}),` update is allowed. Prereleases, downgrades, custom paths, and force updates are not offered.`]})]}),(0,U.jsx)(Gs,{open:a!==void 0,onOpenChange:e=>{e||o(void 0)},children:(0,U.jsxs)(Js,{children:[(0,U.jsxs)(Ys,{children:[(0,U.jsxs)(Zs,{children:[`Update Flow to `,a,`?`]}),(0,U.jsx)(Qs,{children:`Flow will temporarily disconnect this browser and restart the background Session Host. Durable Agent Sessions and Presentation Transcripts stay on disk, but Agent Sessions return Dormant and are not Revived automatically. Ephemeral Shells are lost.`})]}),(0,U.jsxs)(Xs,{children:[(0,U.jsx)(ec,{children:`Cancel`}),(0,U.jsx)($s,{onClick:()=>{a&&p(a)},children:`Update and restart`})]})]})})]})}function BJ(e){return{checking:`Checking`,"up-to-date":`Up to date`,available:`Update available`,unsupported:`Manual update required`,blocked:`Update blocked`,updating:`Updating`,reconnecting:`Reconnecting`,success:`Update complete`,failure:`Update failed`,"recovery-needed":`Recovery needs attention`,error:`Check failed`}[e]}function VJ(){let{config:e}=Dt(),{sessions:t}=ta(),{save:n,saving:r}=LJ(),i=e.retention?.settled,[a,o]=(0,H.useState)(i??``),[s,c]=(0,H.useState)(!1);if((0,H.useEffect)(()=>o(i??``),[i]),i===void 0)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(zJ,{}),(0,U.jsx)(FJ,{title:`Retention`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This Session Host serves no Settings.`})})]});let l=a.trim()!==i,u=Date.now(),d=PJ(t,a.trim(),u).length-PJ(t,i,u).length,f=()=>{c(!1),n({retention:{settled:a.trim()}},`Retention saved — it applies at the next sweep.`)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(zJ,{}),(0,U.jsxs)(FJ,{title:`Retention`,description:(0,U.jsxs)(U.Fragment,{children:[`How long a Settled Agent Session survives before it is reaped. A duration —`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`90m`}),`,`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`36h`}),`,`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`1d`}),` — or`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`never`}),` to keep them all. Only Settled Agent Sessions are ever reaped; an Ended one stays on disk.`]}),children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Settled Agent Sessions`}),(0,U.jsx)(et,{className:`font-mono`,value:a,onChange:e=>o(e.target.value),placeholder:`1d`,spellCheck:!1})]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The Session Host sweeps once an hour, so a change applies within the hour rather than now.`}),(0,U.jsx)(RJ,{dirty:l,saving:r,onSave:()=>d>0?c(!0):f(),onReset:()=>o(i)})]}),(0,U.jsx)(FJ,{title:`This Session Host`,children:(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(IJ,{label:`Default Scope`,children:e.scope}),(0,U.jsx)(IJ,{label:`Backends`,children:e.backends.join(`, `)||`none`}),(0,U.jsx)(IJ,{label:`Shells`,children:e.shell?`available`:`unavailable`}),(0,U.jsx)(IJ,{label:`Settings file`,children:`<state root>/config.json`})]})}),(0,U.jsx)(Gs,{open:s,onOpenChange:c,children:(0,U.jsxs)(Js,{children:[(0,U.jsxs)(Ys,{children:[(0,U.jsxs)(Zs,{children:[`This reaps `,d,` Agent Session`,d===1?``:`s`]}),(0,U.jsxs)(Qs,{children:[d===1?`One Settled Agent Session is`:`${d} Settled Agent Sessions are`,` `,`older than `,a.trim(),`, so the next sweep will delete`,` `,d===1?`its Presentation Transcript`:`their Presentation Transcripts`,` from disk. That happens within the hour, not now, and it cannot be undone.`]})]}),(0,U.jsxs)(Xs,{children:[(0,U.jsx)(ec,{children:`Keep the old window`}),(0,U.jsx)($s,{variant:`destructive`,onClick:f,children:`Save anyway`})]})]})})]})}function HJ(e){let t=e.trim();return t.startsWith(`/`)||t.startsWith(`~`)?`completion`:`search`}function UJ(e){return e.trim()!==``}function WJ(){let{config:e,refresh:t}=Dt(),{save:n,saving:r}=LJ(),i=e.projectList??[],a=e.projectCandidates??[],o=e.projects?.root??``,s=e.projects?.include??[],c=(0,H.useCallback)((e,r)=>{(async()=>{await n({projects:{include:e}},r)&&await t()})()},[n,t]),l=t=>{let n=Iq(t,e.projects?.root===void 0?void 0:e.scope);s.includes(n)||c([...s,n],`Project added.`)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(GJ,{included:i,onRemove:e=>c(s.filter((t,n)=>n!==e),`Project removed.`)}),(0,U.jsx)(KJ,{candidates:a,hasRoot:e.projects?.root!==void 0,onAdd:l}),(0,U.jsx)(qJ,{onAdd:l}),(0,U.jsx)(JJ,{current:o,saving:r,onSave:n,onSaved:t})]})}function GJ({included:e,onRemove:t}){return(0,U.jsx)(FJ,{title:`Projects · ${e.length}`,description:e.length===0?`Nothing yet. A Project is one you have opted into — add one below, and it becomes an option in the New Agent Session view.`:`What the New Agent Session view offers, in this order.`,children:e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,n)=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.group===void 0?e.name:`${e.group}/${e.name}`}),e.missing?(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`directory is gone`}):null]}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.path}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.name}`,onClick:()=>t(n),children:(0,U.jsx)(ts,{"aria-hidden":!0})})]})]},e.path))})})}function KJ({candidates:e,hasRoot:t,onAdd:n}){return t?(0,U.jsx)(FJ,{title:`Found beneath the Project Root · ${e.length}`,description:`Repositories Flow can see but is not offering. Add the ones you work in.`,children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing left to add. Either everything found is already a Project, or the Project Root holds no git repositories within three levels.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:Fq(e).map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.group===void 0?null:(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.group}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.items.map(e=>(0,U.jsxs)(B,{variant:`outline`,size:`sm`,className:`font-mono text-xs font-normal`,onClick:()=>n(e.path),children:[(0,U.jsx)(Ko,{"aria-hidden":!0}),e.name]},e.path))})]},e.group??``))})}):null}function qJ({onAdd:e}){let[t,n]=(0,H.useState)(``),[r,i]=(0,H.useState)(void 0),a=(0,H.useRef)(``);(0,H.useEffect)(()=>{if(a.current=t,!UJ(t)){i(void 0);return}let e=new AbortController,n=setTimeout(()=>{(async()=>{try{let n=await kt(`/api/directories?q=${encodeURIComponent(t)}`,{signal:e.signal});if(!n.ok)return;let r=await n.json();r.query===a.current&&i(r)}catch{}})()},150);return()=>{e.abort(),clearTimeout(n)}},[t]);let o=HJ(t);return(0,U.jsxs)(FJ,{title:`Add any directory`,description:(0,U.jsxs)(U.Fragment,{children:[`Type a name to search beneath the Project Root — repositories included, so`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`packages/api`}),` inside a monorepo is reachable. Start with `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`/`}),` or`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),` to complete a path anywhere on this machine instead.`]}),children:[(0,U.jsx)(et,{className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`api, or /home/you/elsewhere`,spellCheck:!1}),r===void 0?null:r.paths.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o===`completion`?`No directory there.`:`Nothing beneath the Project Root matches.`}):(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsxs)(`span`,{className:`pb-1 text-xs text-muted-foreground`,children:[o===`completion`?`Directories here`:`Found beneath the Project Root`,r.truncated?` — showing the first few, keep typing`:null]}),r.paths.map(t=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b py-1 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t}),(0,U.jsxs)(B,{variant:`ghost`,size:`sm`,onClick:()=>{e(t),n(``)},children:[(0,U.jsx)(Ko,{"aria-hidden":!0}),`Add`]})]},t))]})]})}function JJ({current:e,saving:t,onSave:n,onSaved:r}){let[i,a]=(0,H.useState)(e);return(0,H.useEffect)(()=>a(e),[e]),(0,U.jsxs)(FJ,{title:`Project Root`,description:(0,U.jsxs)(U.Fragment,{children:[`The directory Flow looks beneath for candidates, and the one it reports as its default Scope. Absolute, or starting with`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),`. A Project outside it can still be added by path.`]}),children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Where your repositories live`}),(0,U.jsx)(et,{className:`font-mono`,value:i,onChange:e=>a(e.target.value),placeholder:`~/workspace`,spellCheck:!1})]}),(0,U.jsx)(RJ,{dirty:i.trim()!==e,saving:t,onSave:()=>{(async()=>{let e=i.trim()===``?`Project Root cleared.`:`Project Root saved.`;await n({projects:{root:i.trim()}},e)&&await r()})()},onReset:()=>a(e)})]})}function YJ(){let{config:e}=Dt(),{save:t}=LJ(),n=e.permissions?.allow??[],r=(0,H.useCallback)(e=>{t({permissions:{allow:n.filter(t=>t!==e)}},`${e} will be asked about again.`)},[n,t]);return(0,U.jsx)(FJ,{title:`Always allowed · ${n.length}`,description:n.length===0?`Nothing yet. Answering a Permission Prompt with “Always allow on this machine” adds a tool here, and it is never asked about again until you take it back.`:`These run in every Agent Session without asking. Revoking one means the next call is asked about again — it does not undo anything already done.`,children:n.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-col`,children:n.map(e=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-sm`,"aria-label":`Revoke ${e}`,onClick:()=>r(e),children:(0,U.jsx)(ts,{"aria-hidden":!0})})]},e))})})}var XJ=`__unset_effort__`;function ZJ({value:e,levels:t,ariaLabel:n,allowUnset:r=!1,disabled:i=!1,onChange:a}){let o=e!==``&&!t.includes(e);return(0,U.jsxs)(Qn,{value:e||(r?XJ:null),disabled:i,onValueChange:e=>{typeof e==`string`&&a(e===XJ?``:e)},children:[(0,U.jsx)(Un,{className:`w-full`,size:`sm`,"aria-label":n,"aria-invalid":o||void 0,children:(0,U.jsx)(Xn,{children:e||`Use backend default`})}),(0,U.jsxs)(Vn,{children:[r?(0,U.jsx)(Nn,{value:XJ,children:`Use backend default`}):null,o?(0,U.jsxs)(Nn,{value:e,disabled:!0,children:[e,` (saved — unsupported)`]}):null,t.map(e=>(0,U.jsx)(Nn,{value:e,children:e},e))]})]})}var QJ=`__unset__`;function $J(){let{config:e}=Dt(),{catalogue:t,loading:n,problem:r,refresh:i}=dN();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(tY,{backends:e.backends,current:e.providers?.defaultBackend??``}),(0,U.jsx)(`div`,{className:`flex flex-col gap-3`,children:(e.backends??[]).map(i=>(0,U.jsx)(nY,{backend:i,providers:e.providers,isDefault:i===cN(e.backends,e.providers?.defaultBackend),listing:t?.find(e=>e.backend===i),loading:n,discoveryProblem:r},i))}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(B,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>void i(),children:n?`Checking models…`:`Check again`}),(0,U.jsx)(`span`,{role:r?`alert`:void 0,children:r??`Refresh after connecting a Provider. Pi lists only models with authentication configured.`})]})]})}function eY(e){return e===`pi`?`Pi`:e===`claude`?`Claude`:e}function tY({backends:e,current:t}){let{save:n,saving:r}=LJ(),[i,a]=(0,H.useState)(t);(0,H.useEffect)(()=>a(t),[t]);let o=cN(e);return(0,U.jsxs)(FJ,{title:`Default Backend`,description:`Used by web and terminal for new Agent Sessions. An explicit backend choice takes precedence.`,children:[(0,U.jsxs)(Qn,{value:i||QJ,onValueChange:e=>{typeof e==`string`&&a(e===QJ?``:e)},children:[(0,U.jsx)(Un,{className:`w-full sm:max-w-sm`,"aria-label":`Default Backend`,children:(0,U.jsx)(Xn,{children:i?eY(i):`Automatic${o?` — ${eY(o)}`:``}`})}),(0,U.jsxs)(Vn,{children:[(0,U.jsxs)(Nn,{value:QJ,children:[`Automatic`,o?` — ${eY(o)}`:``]}),t&&!e.includes(t)?(0,U.jsxs)(Nn,{value:t,disabled:!0,children:[t,` (unavailable)`]}):null,e.map(e=>(0,U.jsx)(Nn,{value:e,children:eY(e)},e))]})]}),(0,U.jsx)(RJ,{dirty:i!==t,saving:r,onReset:()=>a(t),onSave:()=>void n({providers:{defaultBackend:i}},`Default Backend saved.`)})]})}function nY({backend:e,providers:t,listing:n,loading:r,isDefault:i,discoveryProblem:a}){let{save:o,saving:s}=LJ(),c=t?.summary,l=t?.summaries?.[e]??(c?.backend===e?c:void 0),u=t?.defaults?.[e]??``,d=t?.efforts?.[e]??``,f=l?.modelId??``,p=l?.automatic??!0,[m,h]=(0,H.useState)(u),[g,_]=(0,H.useState)(d),[v,y]=(0,H.useState)(f),[b,x]=(0,H.useState)(p);function S(){h(u),_(d),y(f),x(p)}(0,H.useEffect)(S,[u,d,f,p]);let C=n?.models.find(e=>e.id===m),w=C?.effortLevels??[],T=r?`Checking model Effort support…`:a??n?.problem??(m?C?void 0:`This model is unavailable; Effort support cannot be confirmed.`:`Choose a model to confirm its Effort levels.`),E=!!C&&w.length===0,D=!!g&&(!C||!w.includes(g)),O=m!==u||g!==d||v!==f||b!==p;return(0,U.jsxs)(`details`,{name:`provider-backends`,className:`group rounded-lg border bg-card`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-3 rounded-lg p-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold`,children:eY(e)}),i?(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground`,children:`Default`}):null,O?(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Unsaved`}):null]}),(0,U.jsxs)(`p`,{className:`mt-1 truncate text-xs text-muted-foreground`,children:[C?.label??(m||`Backend model default`),g?` · ${g} effort`:``,v?` · Summary enabled`:` · No summary model`]})]}),(0,U.jsx)(dn,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 border-t p-4`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Model and effort defaults apply to new Agent Sessions only.`}),(0,U.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,U.jsx)(iY,{label:`Default Model`,backend:e,listing:n,loading:r,value:m,placeholder:`Use backend default`,onChange:h}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Default Effort`}),E?D?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`text-sm`,"aria-invalid":`true`,children:[g,` (saved — unsupported)`]}),(0,U.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>_(``),children:`Use backend default`})]}):null:(0,U.jsx)(ZJ,{value:g,levels:w,ariaLabel:`${e} Default Effort`,allowUnset:!0,disabled:!!T,onChange:_}),(0,U.jsx)(`span`,{className:D?`text-xs text-destructive`:`text-xs text-muted-foreground`,role:D||T?`status`:void 0,children:D?E?`Saved Effort “${g}” is invalid because this model has no Effort control. Use the backend default.`:`Saved Effort “${g}” is not confirmed for this model. Choose a supported level or use the backend default.`:T||(E?`This model has no Effort control.`:`For the main model only. Explicit session effort takes precedence.`)})]})]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,U.jsx)(iY,{label:`Summary Model`,backend:e,listing:n,loading:r,value:v,placeholder:`None — keep the first line`,onChange:y}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Names this backend’s Agent Sessions. Does not inherit Default Effort.`}),v?(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Name new Agent Sessions automatically`}),(0,U.jsx)(ht,{checked:b,onCheckedChange:x})]}):null]})]}),(0,U.jsx)(RJ,{dirty:O,saving:s,saveDisabled:D,onReset:S,onSave:()=>void o({providers:{defaults:{[e]:m},efforts:{[e]:g},summaries:{[e]:v?{modelId:v,automatic:b}:null}}},`${e} models saved.`)}),n?.autoCompaction?(0,U.jsx)(rY,{backend:e,listing:n,current:t?.autoCompaction?.[e]}):null]})]})}function rY({backend:e,listing:t,current:n}){let{save:r,saving:i}=LJ(),[a,o]=(0,H.useState)(``),s=n?.[a],[c,l]=(0,H.useState)(`default`),[u,d]=(0,H.useState)(`80`),f=s?.mode??`default`,p=s?.mode===`enabled`?String(s.targetPercent):`80`;function m(){l(f),d(p)}(0,H.useEffect)(m,[a,f,p]);let h=[...t.models,...Object.keys(n??{}).filter(e=>!t.models.some(t=>t.id===e)).map(e=>({id:e}))],g=t.models.find(e=>e.id===a),_=t.autoCompaction===`model-change`&&!g?.contextWindow,v=Number(u),y=c!==`enabled`||!_&&Number.isInteger(v)&&v>=1&&v<=99,b=c!==f||c===`enabled`&&u!==p;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 border-t pt-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Auto-compaction`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Applies when a Backend Session opens or is Revived. Saving does not change running Backend Sessions. Manual compaction stays available.`}),(0,U.jsx)(iY,{label:`Auto-compaction model`,backend:e,listing:{...t,models:h},loading:!1,value:a,placeholder:`Choose a model`,onChange:o}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Auto-compaction mode`}),(0,U.jsxs)(Qn,{value:c,disabled:!a,onValueChange:e=>{(e==="default"||e===`disabled`||e===`enabled`)&&l(e)},children:[(0,U.jsx)(Un,{"aria-label":`${e} Auto-compaction mode`,children:(0,U.jsx)(Xn,{children:c==="default"?`Use backend default`:c===`disabled`?`Disabled`:`Enabled with target`})}),(0,U.jsxs)(Vn,{children:[(0,U.jsx)(Nn,{value:`default`,children:`Use backend default`}),(0,U.jsx)(Nn,{value:`disabled`,children:`Disabled`}),(0,U.jsx)(Nn,{value:`enabled`,disabled:_,children:`Enabled with target`})]})]})]}),c===`enabled`?(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Target percentage`}),(0,U.jsx)(et,{"aria-label":`${e} Auto-compaction target percentage`,type:`number`,min:1,max:99,step:1,disabled:_,value:u,onChange:e=>d(e.target.value)}),!y&&!_?(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`Enter an integer from 1 to 99.`}):null]}):null,_&&a?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The model context window is unknown. Percentage control is unavailable.`}):null,(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The percentage is a target, not a guarantee. `,t.autoCompaction===`startup`?`Claude may compact earlier. Backend restrictions still apply. Model changes in a running Backend Session do not change its startup threshold. If no model is selected at startup, Claude uses its own defaults.`:`Pi uses the model context window to set reserved tokens. This also changes the summary token budget. Model changes use the Settings snapshot from when the Backend Session opened.`]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(B,{size:`sm`,disabled:!a||!b||!y||i,onClick:()=>{if(!a||!y)return;let t=c==="default"?null:c===`disabled`?{mode:c}:{mode:c,targetPercent:v};r({providers:{autoCompaction:{[e]:{[a]:t}}}},`Auto-compaction saved.`)},children:i?`Saving…`:`Save`}),(0,U.jsx)(B,{size:`sm`,variant:`ghost`,disabled:!b||i,onClick:m,children:`Discard`})]})]})}function iY({label:e,backend:t,listing:n,loading:r,value:i,placeholder:a,onChange:o}){let[s,c]=(0,H.useState)(``),l=n?.models??[],u=l.filter(e=>`${e.provider??``} ${e.label??``} ${e.id}`.toLowerCase().includes(s.toLowerCase())),d=l.find(e=>e.id===i),f=i!==``&&d===void 0,p=d?`${d.provider?`${d.provider} / `:``}${d.label??d.id}`:i?`${i} (unavailable)`:a;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e}),t!==`pi`&&!r&&l.length===0?(0,U.jsx)(et,{"aria-label":`${t} ${e}`,value:i,placeholder:a,onChange:e=>o(e.target.value),spellCheck:!1,autoComplete:`off`}):(0,U.jsxs)(U.Fragment,{children:[l.length>10?(0,U.jsx)(et,{"aria-label":`Search ${t} ${e}`,placeholder:`Filter models…`,value:s,onChange:e=>c(e.target.value)}):null,(0,U.jsxs)(Qn,{value:i||QJ,onValueChange:e=>{typeof e==`string`&&o(e===QJ?``:e)},children:[(0,U.jsx)(Un,{className:`w-full`,size:`sm`,"aria-label":`${t} ${e}`,children:(0,U.jsx)(Xn,{children:p})}),(0,U.jsxs)(Vn,{children:[(0,U.jsx)(Nn,{value:QJ,children:a}),f?(0,U.jsxs)(Nn,{value:i,disabled:!0,children:[i,` (unavailable)`]}):null,u.map(e=>(0,U.jsxs)(Nn,{value:e.id,children:[e.provider?`${e.provider} / `:``,e.label??e.id]},e.id))]})]})]}),r?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Checking models…`}):null,n?.problem?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.problem}):null,t===`pi`&&!r&&l.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No authenticated models available. Connect a Provider in pi, then check again.`}):null]})}function aY(){let{config:e}=Dt(),{save:t,saving:n}=LJ(),r=e.fonts??oe,[i,a]=(0,H.useState)(r.chrome),[o,s]=(0,H.useState)(r.monospace);(0,H.useEffect)(()=>{a(r.chrome),s(r.monospace)},[r.chrome,r.monospace]);let c=i.trim()!==r.chrome||o.trim()!==r.monospace;return(0,U.jsxs)(FJ,{title:`Typefaces`,description:`A CSS font-family list. The browser uses the first family it can resolve, so name the one you want and leave a generic at the end.`,children:[(0,U.jsx)(oY,{label:`Interface`,hint:`Labels, transcript prose, buttons.`,value:i,onChange:a,preview:`The quick brown fox`,onDefault:()=>a(le().chrome)}),(0,U.jsx)(oY,{label:`Monospace`,hint:`The Shell's terminal, and everything that aligns character by character — Scopes, ids, counts.`,value:o,onChange:s,preview:`~/code   main  ✔ 1234567890`,onDefault:()=>s(le().monospace)}),(0,U.jsx)(RJ,{dirty:c,saving:n,onSave:()=>void t({fonts:{chrome:i.trim(),monospace:o.trim()}},`Typefaces saved.`),onReset:()=>{a(r.chrome),s(r.monospace)}})]})}function oY({label:e,hint:t,value:n,onChange:r,preview:i,onDefault:a}){let o=wt(n);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e}),(0,U.jsx)(B,{variant:`link`,size:`sm`,className:`h-auto p-0 text-xs`,onClick:e=>{e.preventDefault(),a()},children:`Use the default`})]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}),(0,U.jsx)(et,{className:`font-mono text-xs`,value:n,onChange:e=>r(e.target.value),spellCheck:!1,autoComplete:`off`})]}),(0,U.jsx)(`p`,{"aria-hidden":!0,className:`truncate rounded-md border bg-muted/40 px-2 py-1.5 text-sm`,style:{fontFamily:n},children:i}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.length,` famil`,o.length===1?`y`:`ies`,`: `,o.join(` → `)||`none`]})]})}var sY=[{title:`Moving around`,description:`The rail's cursor is not the Agent Session on screen. Move it, then press Enter to open what it is on.`,shortcuts:[{binding:`sidebar-next`,keys:[`j`,`ArrowDown`],description:`Next Agent Session in the rail`},{binding:`sidebar-previous`,keys:[`k`,`ArrowUp`],description:`Previous Agent Session in the rail`},{binding:`sidebar-first`,keys:[`Home`],description:`First Agent Session`},{binding:`sidebar-last`,keys:[`End`],description:`Last Agent Session`},{binding:`focus-pane`,keys:[`Enter`],description:`Open the cursored one and type in it`}]},{title:`Doing things`,description:`Nothing here spends money or sends text on a single unmodified key: n opens the New Agent Session view rather than starting one, and no shortcut sends a message or Revives one.`,shortcuts:[{binding:`new-agent-session`,keys:[`n`],description:`New Agent Session — opens the view`},{binding:`settle`,keys:[`s`],description:`Settle the Agent Session on screen`},{binding:`toggle-bottom-dock`,keys:["`"],description:`Show or minimise the bottom Dock — minimising does not end its Shells`},{binding:`toggle-right-dock`,keys:[`~`],description:`Show or minimise the right Dock`},{binding:`search`,keys:[`f`],chord:!0,description:`Find in the Presentation Transcript — opens the field, Escape closes it`},{binding:`model-picker`,keys:[`m`],description:`Model picker`},{binding:`effort-picker`,keys:[`e`],description:`Effort picker`},{binding:`blur-or-abort`,keys:[`Escape`],description:`Leave the Composer, or abort the turn — aborting discards the Steering Queue`}]},{title:`Everywhere`,shortcuts:[{binding:`command-palette`,keys:[`k`],chord:!0,description:`Command palette`},{binding:`toggle-rail`,keys:[`b`],chord:!0,description:`Show or hide the rail — drag its right edge to resize instead`},{binding:`keyboard-settings`,keys:[`?`],description:`This list`},{binding:`leave-settings`,keys:[`Escape`],description:`Leave the Settings`}]}],cY={ArrowDown:`↓`,ArrowUp:`↑`,ArrowLeft:`←`,ArrowRight:`→`};function lY(e){return cY[e]??e}function uY(){return(0,U.jsx)(U.Fragment,{children:sY.map(e=>(0,U.jsx)(FJ,{title:e.title,description:e.description,children:(0,U.jsx)(`dl`,{className:`flex flex-col`,children:e.shortcuts.map(e=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b py-1.5 last:border-b-0`,children:[(0,U.jsx)(`dt`,{className:`text-sm`,children:e.description}),(0,U.jsxs)(`dd`,{className:`flex shrink-0 items-center gap-1`,children:[e.chord===!0?(0,U.jsx)(eN,{children:`⌘/Ctrl`}):null,e.keys.map(e=>(0,U.jsx)(eN,{children:lY(e)},e))]})]},e.binding))})},e.title))})}var dY=(0,H.lazy)(()=>nj(()=>import(`./settings-workflows-BPjeFoaT.js`),__vite__mapDeps([6,1,2,3,4,5]))),fY=(0,H.lazy)(()=>nj(()=>import(`./settings-mcp-COi1p_1o.js`),__vite__mapDeps([7,1,2,3]))),pY=(0,H.lazy)(()=>nj(()=>import(`./settings-secrets-C599riFl.js`),__vite__mapDeps([8,1,2])));function mY({section:e}){return(0,U.jsx)(`div`,{className:`transcript-scroller min-h-0 overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex ${e===`workflows`?`w-full`:`max-w-2xl`} flex-col gap-6 px-4 py-8 max-lg:pt-14 sm:px-6`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These apply to every Agent Session on this machine, not to one Scope.`}),(0,U.jsxs)(H.Suspense,{fallback:(0,U.jsx)(`p`,{children:`Loading settings…`}),children:[e===`workflows`&&(0,U.jsx)(dY,{}),e===`secrets`&&(0,U.jsx)(pY,{}),e===`mcp`&&(0,U.jsx)(fY,{})]}),e===`general`?(0,U.jsx)(VJ,{}):null,e===`projects`?(0,U.jsx)(WJ,{}):null,e===`permissions`?(0,U.jsx)(YJ,{}):null,e===`providers`?(0,U.jsx)($J,{}):null,e===`appearance`?(0,U.jsx)(aY,{}):null,e===`keyboard`?(0,U.jsx)(uY,{}):null]})})}function hY(){let{config:e}=Dt(),{sessions:t,loaded:n}=ta(),{route:r,sessionId:i,focus:a,openNewAgentSession:o,openSettings:s,leaveSettings:c}=_o(),l=ra(),[u,d]=(0,H.useState)(void 0),[f,m]=(0,H.useState)(!0),[h,g]=(0,H.useState)(!1),_=ro(),v=(0,H.useMemo)(()=>t.map(e=>e.id),[t]),y=Va(i,n?v:void 0),b=(0,H.useRef)(void 0),x=(0,H.useCallback)((e,t=!1)=>{t&&(b.current=e),a(e)},[a]);(0,H.useEffect)(()=>{b.current===i&&(b.current=void 0,y.dispatch({type:`open-workflows`}))},[y,i]);let S=Za(v),C=ri(i),[w,T]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(w||r.view!==`session`)return;if(i!==void 0){T(!0);return}if(!n)return;T(!0);let e=t[0];!e||Cr(e)===`filed-away`||a(e.id)},[w,n,t,i,a,r.view]),(0,H.useEffect)(()=>{d(e=>oo(t,e))},[t]);let E=(0,H.useCallback)(e=>{d(n=>so(t,n,e))},[t]);(0,H.useEffect)(()=>{g(!1)},[i]);let D=(0,H.useCallback)(e=>{l({type:`settle`,sessionId:e}).then(()=>{p.info(`Settled — the next message Revives it.`)})},[l]),O=(0,H.useCallback)(e=>{document.querySelector(`[data-pane] ${e}`)?.focus()},[]),k=(0,H.useMemo)(()=>({"new-agent-session":o,"sidebar-next":()=>E(1),"sidebar-previous":()=>E(-1),"sidebar-first":()=>d(t[0]?.id),"sidebar-last":()=>d(t.at(-1)?.id),"focus-pane":()=>{u&&a(u),O(`[data-composer-input]`)},...i===void 0?{}:{search:()=>{g(!0),O(`[data-transcript-search]`)}},settle:()=>{i!==void 0&&C!==void 0&&Er(C.status)&&D(i)},"toggle-bottom-dock":()=>{i!==void 0&&y.dispatch({type:`toggle`,side:`bottom`})},"toggle-right-dock":()=>{i!==void 0&&y.dispatch({type:`toggle`,side:`right`})},"toggle-rail":()=>m(e=>!e),"keyboard-settings":()=>s(`keyboard`),"leave-settings":c,"blur-or-abort":()=>{if(i===void 0||C===void 0||!xr(C.status))return;let e=C.queueDepth;l({type:`abort`,sessionId:i}).then(()=>{p.info(e>0?`aborted · ${e} queued message${e===1?``:`s`} discarded`:`aborted`)})}}),[C,e.shell,u,y,a,O,i,c,o,s,E,l,t,D]),A=r.view===`settings`;return(0,U.jsx)(sN,{handlers:k,view:r.view,children:(0,U.jsxs)(CM,{className:`h-full min-h-0`,open:f,onOpenChange:m,style:{"--sidebar-width":eo(_.width)},children:[(0,U.jsxs)(wM,{collapsible:`offcanvas`,role:`complementary`,"aria-label":A?`Settings`:`Agent Sessions`,className:`border-r border-sidebar-border`,children:[(0,U.jsx)(mJ,{width:_.width,onResize:_.set,onNudge:_.nudge}),A?(0,U.jsx)(NJ,{section:r.section,onSelect:s,onLeave:c}):(0,U.jsx)(KM,{sessions:t,focusedId:i,focusedStatus:C?.status,cursorId:u,link:C?.link,onFocus:a,onSettle:D,onNew:o,onOpenSettings:s})]}),(0,U.jsxs)(EM,{className:`mobile-safe-frame grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] overflow-hidden`,children:[(0,U.jsx)(TM,{className:`mobile-rail-trigger absolute z-30 lg:hidden`}),A?(0,U.jsx)(mY,{section:r.section}):i===void 0?w?(0,U.jsx)(uJ,{drafts:S,onCreated:x,initialBackend:r.view===`session`?r.backend:void 0}):(0,U.jsx)(`div`,{className:`min-h-0`}):(0,U.jsx)(zM,{sessionId:i,searchOpen:h,onCloseSearch:()=>g(!1),docks:y,drafts:S,shells:e.shell===!0})]})]})})}function gY(){return(0,U.jsx)(we,{children:(0,U.jsx)(jJ,{children:(0,U.jsx)(na,{children:(0,U.jsx)(Qr,{children:(0,U.jsxs)(ll,{children:[(0,U.jsx)(hY,{}),(0,U.jsx)(m,{}),(0,U.jsx)(yo,{})]})})})})})}var _Y=document.getElementById(`root`);if(!_Y)throw Error(`index.html is missing #root`);(0,hr.createRoot)(_Y).render((0,U.jsx)(H.StrictMode,{children:(0,U.jsx)(gY,{})}));export{xy as $,tA as A,Zu as At,LC as B,Xi as Bt,dN as C,Ju as Ct,$k as D,fu as Dt,gA as E,G as Et,ow as F,Ro as Ft,db as G,MC as H,Vr as Ht,BC as I,Eo as It,Dy as J,Ab as K,VC as L,xo as Lt,RE as M,Yl as Mt,jw as N,Qu as Nt,nA as O,Nu as Ot,pw as P,ds as Pt,Wv as Q,zC as R,vo as Rt,oR as S,M_ as St,$j as T,fd as Tt,OC as U,jr as Ut,PC as V,Yi as Vt,vS as W,ay as X,Jv as Y,wy as Z,kq as _,G_ as _t,nJ as a,Gv as at,hq as b,pf as bt,Yq as c,xv as ct,Lq as d,W_ as dt,Cy as et,zq as f,L_ as ft,Rq as g,pv as gt,Uq as h,dv as ht,rJ as i,sy as it,aD as j,Au as jt,eA as k,md as kt,qq as l,J as lt,Vq as m,B_ as mt,FJ as n,Ty as nt,tJ as o,jy as ot,Hq as p,V_ as pt,yS as q,LJ as r,fy as rt,Qq as s,Yv as st,ZJ as t,Ey as tt,Bq as u,P_ as ut,pq as v,hf as vt,cN as w,W as wt,sq as x,r_ as xt,vq as y,Jg as yt,RC as z,ta as zt};
170
+ `)})})]}),e.type===`array`&&(0,U.jsx)(rJ,{schema:e.items,onChange:n=>t({...e,items:n})}),e.type===`object`&&(0,U.jsxs)(U.Fragment,{children:[Object.entries(e.fields).map(([n,r])=>(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:n}),(0,U.jsx)(B,{size:`sm`,variant:`destructive`,className:`justify-self-start`,onClick:()=>t({...e,fields:Object.fromEntries(Object.entries(e.fields).filter(([e])=>e!==n))}),children:`Remove field`}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(ht,{checked:!!r.required,onCheckedChange:i=>t({...e,fields:{...e.fields,[n]:{...r,required:i}}})}),`Required`]}),(0,U.jsx)(rJ,{schema:r.schema,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,schema:i}}})}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(ht,{checked:r.default!==void 0,onCheckedChange:i=>{let a={...r};i?a.default=tJ(r.schema):delete a.default,t({...e,fields:{...e.fields,[n]:a}})}}),`Default`]}),r.default!==void 0&&(0,U.jsx)(nJ,{schema:r.schema,value:r.default,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,default:i}}})})]},n)),(0,U.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault();let r=n.currentTarget,i=String(new FormData(r).get(`field`));i&&![`__proto__`,`constructor`,`prototype`].includes(i)&&!e.fields[i]&&(t({...e,fields:{...e.fields,[i]:{schema:{type:`string`}}}}),r.reset())},children:[(0,U.jsx)(et,{className:`min-w-0 flex-1`,name:`field`,"aria-label":`New field name`,placeholder:`Field name`,required:!0}),(0,U.jsx)(B,{type:`submit`,size:`sm`,variant:`outline`,children:`Add field`})]})]})]})}var iJ=Iw,aJ=Xw;function oJ({className:e,children:t,...n}){return(0,U.jsx)(Zw,{children:(0,U.jsxs)(Qw,{onKeyDown:e=>{e.key===`Enter`&&e.stopPropagation()},className:z(`group flex w-full items-center gap-2 rounded-lg py-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,e),...n,children:[t,(0,U.jsx)(dn,{className:`ml-auto size-4 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-180`})]})})}function sJ({className:e,...t}){return(0,U.jsx)(sT,{className:z(`pb-3`,e),...t})}var cJ=_e(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-2xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function lJ({className:e,variant:t=`default`,render:n,...r}){return LE({defaultTagName:`span`,props:Pt({className:z(cJ({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}function uJ({initialBackend:e,drafts:t,onCreated:n}){let{config:r,refresh:i}=Dt(),a=ra(),[o,s]=(0,H.useState)(`chat`),[c,l]=(0,H.useState)({}),u=(r.mcp??[]).filter(e=>c[e.id]??e.enabledByDefault).map(e=>e.id),d=r.projectList??[],f=(r.projectCandidates??[]).length,[p,m]=(0,H.useState)(()=>t.scope()),h=d.find(e=>e.path===p),g=h?.path,[_,v]=(0,H.useState)(e),y=_??cN(r.backends,r.providers?.defaultBackend)??``,[b,x]=(0,H.useState)(),[S,C]=(0,H.useState)(),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(),[O,k]=(0,H.useState)(),A=(0,H.useRef)(null);(0,H.useEffect)(()=>{i()},[i]);let j=Ew(g);(0,H.useEffect)(()=>{r.git!==!1&&j.load()},[g,r.git]);let M=fN(g,y),N=j.list?.repository===!0,P=j.list?.head,F=P?.detached?void 0:P?.name,I=E??F??``,{catalogue:ee,loading:te,problem:ne,refresh:L}=dN(),R=ee?.find(e=>e.backend===y),re=R?.models.find(e=>e.id===b)??mN(ee,r.providers?.defaults,y),ie=te?`Checking model capabilities before starting agent work…`:ne??R?.problem??(R?re?void 0:`No confirmed model is available for ${y}.`:`Model capabilities for ${y||`this backend`} are unavailable.`),ae=r.providers?.efforts?.[y],oe=re?.effortLevels??[],se=S===void 0&&ae!==void 0&&re&&(oe.length>0?!oe.includes(ae):ae!==`off`)?oe.length>0?`Saved Default Effort “${ae}” is unsupported for ${re?.label??re?.id}. Select a supported Effort here or correct Provider Settings.`:`Saved Default Effort “${ae}” is invalid because ${re?.label??re?.id} has no Effort control. Clear it in Provider Settings.`:void 0,ce=ie??se,le=Pq({scope:g??``,backend:y,modelId:re?.id,effort:S,inWorktree:w,repository:N,base:I}),ue=w?I===``?void 0:{name:I}:P,de=(0,H.useMemo)(()=>({status:`idle`,backend:y,scope:g,capabilities:R&&!ie?{providers:[],models:R.models,compaction:!1,fork:!1,subagents:!1,enquiries:!1,permissions:!1}:void 0,model:re,effort:S,branch:ue,worktree:void 0,contextUsage:void 0,endedReason:void 0,queueDepth:0,activeSubagents:0,activeBackgroundCalls:0,asking:void 0,authorising:void 0,compacting:!1,spoken:!1,link:`live`}),[y,R,ie,S,re,g,ue]),fe=(0,H.useCallback)(async()=>{if(!le)return;k(void 0);let e=await a({...le,mcpConnectionIds:u});return e||k(`The Session Host refused this. Check the Project and branch to cut from.`),e},[le,u,a]),pe=(0,H.useCallback)(async(e,r)=>{let i=await fe();if(!i)return;let o=e===``&&r.length===0||await a({type:`send`,sessionId:i,text:e,...r.length?{attachments:r}:{},when:`after_turn`});return t.write(Xa,{text:``,attachments:[]}),n(i),o},[fe,t,n,a]),me=(0,H.useMemo)(()=>({send:pe,setModel:e=>{x(e);let t=R?.models.find(t=>t.id===e)?.effortLevels??[];C(e=>e&&t.includes(e)?e:void 0)},setEffort:C,switchBranch:async e=>{if(w)return D(e),!0;if(!g)return!1;let t=await a({type:`switch_scope_branch`,scope:g,branch:e});return t!==void 0&&j.load(),t!==void 0},listSkills:M}),[R,j,w,M,a,g,pe]),he=bt(o===`workflow`?`/api/workflows`:void 0,1e4),ge=(0,H.useMemo)(()=>jq(he.data?.workflows??[],y,p),[y,he.data,p]),[_e,ve]=(0,H.useState)(``),[ye,be]=(0,H.useState)({}),xe=ge.find(e=>e.id===_e),Se=(0,H.useMemo)(()=>{if(!xe)return{};try{return{schema:Mq(xe)}}catch(e){return{issue:Rq(e)}}},[xe]);(0,H.useEffect)(()=>{_e&&!ge.some(e=>e.id===_e)&&(ve(``),be({}))},[ge,_e]);let Ce,we=``;if(Se.issue)we=Se.issue;else if(Se.schema)try{Ce=Nq(Se.schema,ye)}catch(e){we=Rq(e)}let Te=xe?.steps.some(e=>e.kind===`shell`||e.kind===`typescript`)===!0,Ee=bt(o===`workflow`&&Te?`/api/workflow-runtime`:void 0,5e3),De=Te?Ee.error||(Ee.data===void 0?`Checking workflow runtime…`:Ee.data.available?``:Ee.data.error??`Workflow runtime is unavailable`):``,[Oe,ke]=(0,H.useState)(!1),Ae=(0,H.useRef)(!1),je=(0,H.useCallback)(async()=>{if(Ae.current||!xe||Ce===void 0||we||De)return;Ae.current=!0,ke(!0),k(void 0);let e=Ce,t=crypto.randomUUID();try{let r=await fe();if(!r)return;try{await jt(`/api/sessions/${encodeURIComponent(r)}/workflows`,`POST`,{workflowId:xe.id,input:e,launchId:t,nameSession:!0})}catch(n){Ji(r,{launchId:t,workflowId:xe.id,input:e,error:Rq(n)})}n(r,!0)}finally{Ae.current=!1,ke(!1)}},[fe,we,n,De,Ce,xe]);(0,H.useEffect)(()=>{g===void 0?A.current?.querySelector(`button`)?.focus():document.querySelector(`[data-new-session] [data-composer-input]`)?.focus()},[]),(0,H.useEffect)(()=>()=>{p!==void 0&&t.setScope(p)},[t,p]);let Me=Fq(d);return(0,U.jsx)(`div`,{"data-new-session":``,className:`transcript-scroller min-h-0 overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-5 px-4 py-12 sm:px-6`,children:[(0,U.jsx)(`h1`,{className:`text-center text-lg font-medium`,children:`New Agent Session`}),(0,U.jsxs)($k,{value:o,onValueChange:e=>{(e===`chat`||e===`workflow`)&&s(e)},className:`contents`,children:[(0,U.jsx)(eA,{"aria-label":`New Agent Session mode`,className:`mx-auto`,children:[`chat`,`workflow`].map(e=>(0,U.jsx)(tA,{value:e,className:`min-w-24 capitalize`,children:e},e))}),d.length===0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(nA,{value:`chat`,children:(0,U.jsx)(fJ,{uncurated:f})}),(0,U.jsx)(nA,{value:`workflow`,children:(0,U.jsx)(fJ,{uncurated:f})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,U.jsxs)(Qn,{value:y,onValueChange:e=>{typeof e==`string`&&(v(e),x(void 0),C(void 0))},children:[(0,U.jsx)(Un,{"aria-label":`Backend`,size:`sm`,className:z(Mw,`w-auto`),children:(0,U.jsx)(Xn,{children:()=>y})}),(0,U.jsx)(Vn,{children:r.backends.map(e=>(0,U.jsx)(Nn,{value:e,children:e},e))})]}),(0,U.jsx)(dJ,{fieldRef:A,groups:Me,projects:d,project:h,onPick:e=>{m(e.path),D(void 0),T(!1)}})]}),ce?(0,U.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground`,role:`status`,children:[(0,U.jsx)(`span`,{children:ce}),!te&&ie?(0,U.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>void L(),children:`Check again`}):null]}):null,(0,U.jsx)(nA,{value:`chat`,keepMounted:!0,className:`grid gap-3`,children:(0,U.jsx)(pD,{id:Xa,chrome:de,actions:me,floating:!1,unavailable:y===``?`This Session Host advertises no backend`:ce,placeholder:`What should it work on? Enter starts the Agent Session.`,drafts:t,authorisingSummary:void 0,onShowSubagents:()=>{}})}),(0,U.jsxs)(nA,{value:`workflow`,keepMounted:!0,className:`grid gap-4 rounded-xl border bg-card/30 p-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`font-medium`,children:`Start with a workflow`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The workflow runs independently, so the parent chat stays available for questions and follow-up work.`})]}),he.error?(0,U.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not load workflows: `,he.error]}):he.data===void 0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading compatible workflows…`}):ge.length===0?(0,U.jsxs)(`p`,{className:`rounded-lg border border-dashed p-4 text-sm text-muted-foreground`,children:[`No global or `,h?.name,` workflows use Backend Adapter `,y,`.`]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Workflow`}),(0,U.jsxs)(Qn,{value:_e,onValueChange:e=>{if(e===null)return;let t=ge.find(t=>t.id===e);ve(e),be(t?tJ(t.inputSchema):{})},children:[(0,U.jsx)(Un,{className:`w-full`,"aria-label":`Workflow`,children:(0,U.jsx)(Xn,{children:xe?.name??`Select a workflow`})}),(0,U.jsxs)(Vn,{children:[(0,U.jsx)(Nn,{value:``,children:`Select a workflow`}),ge.map(e=>(0,U.jsxs)(Nn,{value:e.id,children:[e.name,e.projectId===void 0?` · Global`:``]},e.id))]})]})]}),xe?(0,U.jsxs)(`div`,{className:`grid gap-4`,children:[(0,U.jsxs)(`fieldset`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:`Inputs`}),(0,U.jsx)(nJ,{schema:xe.inputSchema,value:ye,onChange:be})]}),(we||De)&&(0,U.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:we||De}),(0,U.jsx)(B,{className:`justify-self-start`,disabled:Oe||!le||Ce===void 0||!!we||!!De||!!ce,onClick:()=>void je(),children:Oe?`Starting workflow…`:`Create Agent Session and start`})]}):null]}),(0,U.jsx)(`div`,{className:`overflow-hidden rounded-xl border bg-background`,children:(0,U.jsx)(dD,{chrome:de,actions:me})})]}),(r.mcp??[]).length>0&&(0,U.jsx)(iJ,{children:(0,U.jsxs)(aJ,{value:`mcp`,children:[(0,U.jsxs)(oJ,{children:[`MCP connections`,(0,U.jsx)(lJ,{variant:`secondary`,"aria-label":`${u.length} enabled`,children:u.length})]}),(0,U.jsx)(sJ,{className:`flex flex-col gap-3`,children:r.mcp.map(e=>(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[e.name,(0,U.jsx)(ht,{checked:c[e.id]??e.enabledByDefault,onCheckedChange:t=>l(n=>({...n,[e.id]:t}))})]},e.id))})]})}),N&&r.git!==!1?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,checked:w,onChange:e=>T(e.target.checked)}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Start in a new worktree`})]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w?(0,U.jsx)(U.Fragment,{children:`The branch above is what it will be cut from; a name is chosen for you. The worktree is kept by the Session Host and removed when this Agent Session is reaped, but only if nothing is uncommitted.`}):(0,U.jsxs)(U.Fragment,{children:[`This Agent Session shares `,h?.name??`the Project`,`’s checkout, so choosing a branch above moves it — for anything else already working there too. A worktree gives this one its own.`]})})]}):null,O?(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:O}):null]})]})]})})}function dJ({fieldRef:e,groups:t,projects:n,project:r,onPick:i}){return(0,U.jsx)(`label`,{ref:e,className:`flex`,children:(0,U.jsxs)(GE,{items:t,value:r??null,isItemEqualToValue:(e,t)=>e.path===t.path,itemToStringLabel:pJ,itemToStringValue:e=>e.path,onValueChange:e=>{let t=e;t&&i(t)},children:[(0,U.jsx)(qE,{"aria-label":`Project`,render:(0,U.jsx)(B,{variant:`ghost`,size:`sm`,className:z(Mw,`w-auto`)}),children:(0,U.jsx)(KE,{children:e=>e===null?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`Choose a Project`}):(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:pJ(e)})})}),(0,U.jsxs)(XE,{children:[(0,U.jsx)(YE,{showTrigger:!1,placeholder:`Filter ${n.length} ${n.length===1?`Project`:`Projects`}`}),(0,U.jsx)(ZE,{children:e=>(0,U.jsxs)($E,{items:e.items,children:[e.group===void 0?null:(0,U.jsx)(eD,{children:e.group}),(0,U.jsx)(tD,{children:e=>(0,U.jsx)(QE,{value:e,children:(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.name})},e.path)})]},e.group??``)}),(0,U.jsx)(nD,{children:`No Project matches.`})]})]})})}function fJ({uncurated:e}){return(0,U.jsxs)(`p`,{className:`rounded-xl border border-dashed px-4 py-6 text-center text-sm text-muted-foreground`,children:[`No Projects yet. `,e>0?(0,U.jsxs)(U.Fragment,{children:[e,` `,e===1?`repository was`:`repositories were`,` found beneath the Project Root — opt in under Settings → Projects to start an Agent Session in one.`]}):(0,U.jsx)(U.Fragment,{children:`Add one under Settings → Projects to start an Agent Session in it.`})]})}function pJ(e){return e.group===void 0?e.name:`${e.group}/${e.name}`}function mJ({width:e,onResize:t,onNudge:n}){let{toggleSidebar:r,state:i}=SM(),{dragging:a,onPointerDown:o}=vD({grow:1,axis:`col`,variable:`--sidebar-width`,container:e=>e.closest(`[data-slot="sidebar-wrapper"]`),size:e,clamp:e=>Qa(e),onCommit:t,onClick:r});return(0,U.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the rail`,"aria-valuenow":e,"aria-valuemin":180,"aria-valuemax":520,tabIndex:0,onPointerDown:o,onKeyDown:e=>{if(e.key===`ArrowLeft`)n(-1,e.shiftKey);else if(e.key===`ArrowRight`)n(1,e.shiftKey);else if(e.key===`Enter`||e.key===` `)r();else return;e.preventDefault(),e.stopPropagation()},title:`Drag to resize, click to collapse`,className:z(`absolute inset-y-0 -right-2 z-20 hidden w-4 shrink-0 cursor-col-resize sm:block`,`after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] after:-translate-x-1/2`,`hover:after:bg-sidebar-border focus-visible:after:bg-sidebar-ring focus-visible:outline-hidden`,a&&`after:bg-sidebar-ring`,i===`collapsed`&&`cursor-e-resize hover:bg-sidebar`)})}var hJ=36e5,gJ=1e4,_J=2e3,vJ=1e4;function yJ(e,t){return t-e>=3e4?`recovery-needed`:`reconnecting`}function bJ(e,t,n){return t===`starting`?`updating`:t===`reconnecting`?`reconnecting`:t===`recovery-needed`?`recovery-needed`:e?.operation?.state===`updating`?`updating`:e?.operation?.state===`unverified`?`recovery-needed`:t===`checking`?`checking`:n?`error`:e?.updateAvailable&&e.eligibility.state===`unsupported`?`unsupported`:e?.updateAvailable&&e.eligibility.state===`blocked`?`blocked`:e?.operation?.state===`failed`?`failure`:e?.eligibility.state===`eligible`&&e.updateAvailable?`available`:e?.operation?.state===`succeeded`?`success`:e?.checkError?`error`:e?.eligibility.state===`unsupported`?`unsupported`:e?.eligibility.state===`blocked`?`blocked`:e?.updateAvailable?`available`:`up-to-date`}function xJ(e,t,n={}){let r=CJ(t);switch(e){case`checking`:return`Checking the npm registry for the latest stable release…`;case`up-to-date`:return`Flow ${t?.installedVersion??``} is up to date.`;case`available`:return`Flow ${t?.latestVersion} is available and this installation can update safely.`;case`unsupported`:return wJ(t?.eligibility.state===`unsupported`?t.eligibility.reason:`This installation cannot update itself.`,r);case`blocked`:return wJ(t?.eligibility.state===`blocked`?t.eligibility.reason:`Active work must finish before Flow can update.`,r);case`updating`:return`The guarded npm update is running independently of this browser. The Session Host will restart shortly.`;case`reconnecting`:return`The Session Host is restarting. Flow will reconnect and verify the running version automatically.`;case`success`:return TJ(`${t?.operation?.message??`The update was verified.`} Updated web assets are loaded; Agent Sessions remain Dormant until you Revive them.`,t);case`failure`:return TJ(`${t?.operation?.message??`The update failed.`} The Session Host recovered, but this remains a failed update.`,t);case`recovery-needed`:return`Flow could not verify recovery. Reconnect below; if the host remains unavailable, repair the private global npm installation manually and restart it.${t?.operation?.message?` Last known update status: ${t.operation.message}`:``}`;case`error`:return n.actionError??t?.checkError??n.transportError??`Could not check for updates. Normal Flow use is unaffected.`}}function SJ(e,t){return e?.eligibility.state===`eligible`&&e.updateAvailable&&e.latestVersion!==void 0&&[`available`,`failure`].includes(t)}function CJ(e){let t=e?.operation;if(t?.state===`succeeded`){let e=t.installedVersion??t.targetVersion;return`The previous update${e?` to Flow ${e}`:``} was verified successfully.`}if(t?.state===`failed`)return`The previous update failed${t.message?`: ${t.message}`:`.`}`}function wJ(e,t){return t?`${e} ${t}`:e}function TJ(e,t){return t?.checkError?`${e} The latest release check also failed: ${t.checkError} Use Check for updates to retry; normal Flow use is unaffected.`:e}var EJ=class{current={view:`checking`};listeners=new Set;reconnectingSince;pollTimer;pollDelay;hourlyTimer;started=!1;lifecycleRevision=0;statusRequestSequence=0;options;constructor(e){this.options=e}get snapshot(){return this.current}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}start(){this.started||(this.started=!0,this.check(!1),this.hourlyTimer=this.options.setInterval(()=>{this.check(!1)},hJ),this.syncPolling())}stop(){this.started=!1,this.hourlyTimer!==void 0&&this.options.clearInterval(this.hourlyTimer),this.hourlyTimer=void 0,this.clearPoll()}async check(e=!1){if(this.current.view===`starting`)return;let t=this.lifecycleRevision,n=++this.statusRequestSequence;e&&!this.operationMayBeRunning()&&this.publish({...this.current,view:`checking`});try{let r=await this.options.getStatus(e),i=await r.json();if(!r.ok)throw Error(i.error??`Could not check for updates (${r.status})`);if(!this.acceptStatusResponse(t,n))return;this.reconnectingSince=void 0,this.publish({status:i,view:`ready`}),i.operation?.state===`succeeded`&&this.options.onSucceeded?.(i.operation.id)}catch(e){if(!this.acceptStatusResponse(t,n))return;let r=OJ(e,`Could not reach the Session Host`);if(!this.operationMayBeRunning()){this.publish({...this.current,view:`ready`,transportError:r});return}this.reconnectingSince??=this.options.now(),this.publish({...this.current,view:yJ(this.reconnectingSince,this.options.now()),transportError:r})}}async begin(e){this.lifecycleRevision++,this.publish(DJ({...this.current,view:`starting`}));let t=new AbortController,n,r=new Promise((e,r)=>{n=this.options.setTimeout(()=>{r(Error(`The update request timed out and may have started; reconnecting to verify it`)),t.abort()},gJ)}),i,a;try{({response:i,body:a}=await Promise.race([this.readMutationResponse(e,t.signal),r]))}catch(e){this.reconnectingSince=this.options.now(),this.publish({...this.current,view:`reconnecting`,transportError:OJ(e,`The update request may have started; reconnecting to verify it`)});return}finally{n!==void 0&&this.options.clearTimeout(n)}if(!i.ok)throw this.reconnectingSince=void 0,this.publish(DJ({...this.current,view:`ready`})),Error(a.error??`Could not start the update (${i.status})`);this.reconnectingSince=this.options.now(),this.publish(DJ({status:a,view:`reconnecting`}))}async readMutationResponse(e,t){let n=await this.options.beginUpdate(e,t);return{response:n,body:await n.json()}}acceptStatusResponse(e,t){return e===this.lifecycleRevision&&t===this.statusRequestSequence}publish(e){this.current=e;for(let t of this.listeners)t(e);this.syncPolling()}operationMayBeRunning(){return this.reconnectingSince!==void 0||[`updating`,`unverified`].includes(this.current.status?.operation?.state??``)||[`starting`,`reconnecting`,`recovery-needed`].includes(this.current.view)}shouldPoll(){return[`updating`,`unverified`].includes(this.current.status?.operation?.state??``)||this.current.view===`reconnecting`||this.current.view===`recovery-needed`}syncPolling(){if(!this.started||!this.shouldPoll()){this.clearPoll();return}let e=this.current.view===`recovery-needed`||this.current.status?.operation?.state===`unverified`?vJ:_J;(this.pollTimer===void 0||this.pollDelay!==e)&&(this.clearPoll(),this.pollDelay=e,this.pollTimer=this.options.setTimeout(()=>{this.pollTimer=void 0,this.pollDelay=void 0,!(!this.started||!this.shouldPoll())&&this.check(!1).finally(()=>this.syncPolling())},e))}clearPoll(){this.pollTimer!==void 0&&this.options.clearTimeout(this.pollTimer),this.pollTimer=void 0,this.pollDelay=void 0}};function DJ(e){let{transportError:t,...n}=e;return n}function OJ(e,t){return e instanceof Error&&e.message?e.message:t}var kJ=(0,H.createContext)(void 0);function AJ(){let e=(0,H.useContext)(kJ);if(!e)throw Error(`useUpdates outside UpdatesProvider`);return e}function jJ({children:e}){let[t]=(0,H.useState)(()=>new EJ({getStatus:e=>kt(`/api/update${e?`?refresh=1`:``}`,{cache:`no-store`,signal:AbortSignal.timeout(1e4)}),beginUpdate:(e,t)=>kt(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({confirmed:!0,version:e}),signal:t}),now:()=>Date.now(),setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e),setInterval:(e,t)=>window.setInterval(e,t),clearInterval:e=>window.clearInterval(e),onSucceeded:e=>{let t=`flow-update-reloaded:${e}`;sessionStorage.getItem(t)!==`yes`&&(sessionStorage.setItem(t,`yes`),location.reload())}})),[n,r]=(0,H.useState)(t.snapshot);(0,H.useEffect)(()=>{let e=t.subscribe(r);return t.start(),()=>{e(),t.stop()}},[t]);let i=(0,H.useCallback)((e=!1)=>t.check(e),[t]),a=(0,H.useCallback)(e=>t.begin(e),[t]);return(0,U.jsx)(kJ.Provider,{value:{...n,check:i,begin:a},children:e})}var MJ={workflows:{label:`Workflows`,hint:`Visual workflow definitions`,icon:Zo},mcp:{label:`MCP`,hint:`Local and remote tools`,icon:Zo},secrets:{label:`Secrets`,hint:`Named secrets and code runtime`,icon:Xo},general:{label:`General`,hint:`Updates, retention, and this host`,icon:Zo},projects:{label:`Projects`,hint:`Where your repositories live`,icon:Po},permissions:{label:`Permissions`,hint:`Tools allowed without asking`,icon:Xo},providers:{label:`Providers`,hint:`Which models to use`,icon:jo},appearance:{label:`Appearance`,hint:`The two typefaces`,icon:es},keyboard:{label:`Keyboard`,hint:`Every shortcut`,icon:Io}};function NJ({section:e,onSelect:t,onLeave:n}){let{config:r}=Dt(),{status:i}=AJ(),{isMobile:a,setOpenMobile:o}=SM(),s=e=>{t(e),a&&o(!1)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(DM,{className:`flex-row items-center gap-1 border-b border-sidebar-border`,children:(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Settings`})}),(0,U.jsx)(AM,{className:`transcript-scroller gap-0`,children:(0,U.jsx)(jM,{className:`p-0`,children:(0,U.jsx)(NM,{children:(0,U.jsx)(PM,{className:`gap-0`,"aria-label":`Settings sections`,children:co.map(t=>{let{label:n,hint:r,icon:a}=MJ[t],o=t===e;return(0,U.jsx)(FM,{children:(0,U.jsxs)(LM,{size:`lg`,isActive:o,"aria-current":o?`page`:void 0,onClick:()=>s(t),className:z(`rounded-none py-1.5 border-l-2 border-l-transparent`,o&&`border-l-primary`),children:[(0,U.jsx)(a,{"aria-hidden":!0}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-sm`,children:n}),(0,U.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})]}),t===`general`&&i?.updateAvailable?(0,U.jsx)(lJ,{variant:`secondary`,className:`px-1.5`,children:`Update`}):null]})},t)})})})})}),(0,U.jsxs)(OM,{className:`border-t border-sidebar-border py-1.5`,children:[r.authentication===`oidc`?(0,U.jsx)(`form`,{action:`/oauth/logout`,method:`post`,children:(0,U.jsxs)(B,{type:`submit`,variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,children:[(0,U.jsx)(zo,{"aria-hidden":!0}),`Sign out of Flow`]})}):null,(0,U.jsxs)(B,{variant:`ghost`,size:`sm`,className:`justify-start gap-2`,onClick:()=>{n(),a&&o(!1)},children:[(0,U.jsx)(So,{"aria-hidden":!0}),`Back to Agent Sessions`]})]})]})}function PJ(e,t,n){if(t===`never`)return[];let r=uN(t);return r===void 0||r<=0?[]:e.filter(e=>{if(e.status!==`settled`||e.settledAt===void 0)return!1;let t=Date.parse(e.settledAt);return!Number.isNaN(t)&&n-t>=r})}function FJ({title:e,description:t,children:n}){return(0,U.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold`,children:e}),t===void 0?null:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),n]})}function IJ({label:e,children:t}){return(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b py-1.5 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-right font-mono text-xs`,children:t})]})}function LJ(){let{saveSettings:e}=Dt(),[t,n]=(0,H.useState)(!1);return{save:(0,H.useCallback)(async(t,r)=>{n(!0);try{return await e(t),p.info(r),!0}catch(e){return p.error(e instanceof Error?e.message:`Could not save the Settings`),!1}finally{n(!1)}},[e]),saving:t}}function RJ({dirty:e,saving:t,saveDisabled:n=!1,onSave:r,onReset:i}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(B,{size:`sm`,disabled:!e||t||n,onClick:r,children:t?`Saving…`:`Save`}),(0,U.jsx)(B,{size:`sm`,variant:`ghost`,disabled:!e||t,onClick:i,children:`Discard`})]})}function zJ(){let{status:e,view:t,transportError:n,check:r,begin:i}=AJ(),[a,o]=(0,H.useState)(),[s,c]=(0,H.useState)(),l=bJ(e,t,n??s),u=xJ(l,e,{actionError:s,transportError:n});(0,H.useEffect)(()=>{r(!1)},[]);let d=[`checking`,`updating`,`reconnecting`].includes(l),f=SJ(e,l)?e?.latestVersion:void 0,p=async e=>{o(void 0),c(void 0);try{await i(e)}catch(e){c(e instanceof Error?e.message:`Could not start the update`)}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(FJ,{title:`Flow update`,description:`Discover and install the latest stable npm release. Updates are never automatic.`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(IJ,{label:`Installed`,children:e?.installedVersion??`checking…`}),(0,U.jsx)(IJ,{label:`Latest`,children:e?.latestVersion??(e?.checkError?`check failed`:`checking…`)})]}),(0,U.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border bg-muted/35 px-3 py-2.5 text-sm`,role:`status`,"aria-live":`polite`,"data-update-state":l,children:[d?(0,U.jsx)(Ro,{className:`mt-0.5 size-4 shrink-0 animate-spin`,"aria-hidden":!0}):l===`success`?(0,U.jsx)(ko,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":!0}):[`error`,`failure`,`recovery-needed`,`blocked`,`unsupported`].includes(l)?(0,U.jsx)(Oo,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,U.jsx)(Mo,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:BJ(l)}),e?.updateAvailable?(0,U.jsxs)(lJ,{variant:`secondary`,children:[e.latestVersion,` available`]}):null]}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-muted-foreground`,children:u})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsxs)(B,{size:`sm`,variant:`outline`,disabled:d,onClick:()=>{c(void 0),r(!0)},children:[(0,U.jsx)(qo,{"aria-hidden":!0}),`Check for updates`]}),f?(0,U.jsxs)(B,{size:`sm`,onClick:()=>o(f),children:[(0,U.jsx)(Mo,{"aria-hidden":!0}),`Update to `,f]}):null,l===`recovery-needed`?(0,U.jsx)(B,{size:`sm`,onClick:()=>{c(void 0),r(!1)},children:`Reconnect`}):null]}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Only the fixed `,(0,U.jsx)(`code`,{className:`font-mono`,children:`@nathanstephenson/flow@latest`}),` update is allowed. Prereleases, downgrades, custom paths, and force updates are not offered.`]})]}),(0,U.jsx)(Gs,{open:a!==void 0,onOpenChange:e=>{e||o(void 0)},children:(0,U.jsxs)(Js,{children:[(0,U.jsxs)(Ys,{children:[(0,U.jsxs)(Zs,{children:[`Update Flow to `,a,`?`]}),(0,U.jsx)(Qs,{children:`Flow will temporarily disconnect this browser and restart the Session Host. Durable Agent Sessions and Presentation Transcripts stay on disk, but Agent Sessions return Dormant and are not Revived automatically. Ephemeral Shells are lost.`})]}),(0,U.jsxs)(Xs,{children:[(0,U.jsx)(ec,{children:`Cancel`}),(0,U.jsx)($s,{onClick:()=>{a&&p(a)},children:`Update and restart`})]})]})})]})}function BJ(e){return{checking:`Checking`,"up-to-date":`Up to date`,available:`Update available`,unsupported:`Manual update required`,blocked:`Update blocked`,updating:`Updating`,reconnecting:`Reconnecting`,success:`Update complete`,failure:`Update failed`,"recovery-needed":`Recovery needs attention`,error:`Check failed`}[e]}function VJ(){let{config:e}=Dt(),{sessions:t}=ta(),{save:n,saving:r}=LJ(),i=e.retention?.settled,[a,o]=(0,H.useState)(i??``),[s,c]=(0,H.useState)(!1);if((0,H.useEffect)(()=>o(i??``),[i]),i===void 0)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(zJ,{}),(0,U.jsx)(FJ,{title:`Retention`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This Session Host serves no Settings.`})})]});let l=a.trim()!==i,u=Date.now(),d=PJ(t,a.trim(),u).length-PJ(t,i,u).length,f=()=>{c(!1),n({retention:{settled:a.trim()}},`Retention saved — it applies at the next sweep.`)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(zJ,{}),(0,U.jsxs)(FJ,{title:`Retention`,description:(0,U.jsxs)(U.Fragment,{children:[`How long a Settled Agent Session survives before it is reaped. A duration —`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`90m`}),`,`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`36h`}),`,`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`1d`}),` — or`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`never`}),` to keep them all. Only Settled Agent Sessions are ever reaped; an Ended one stays on disk.`]}),children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Settled Agent Sessions`}),(0,U.jsx)(et,{className:`font-mono`,value:a,onChange:e=>o(e.target.value),placeholder:`1d`,spellCheck:!1})]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The Session Host sweeps once an hour, so a change applies within the hour rather than now.`}),(0,U.jsx)(RJ,{dirty:l,saving:r,onSave:()=>d>0?c(!0):f(),onReset:()=>o(i)})]}),(0,U.jsx)(FJ,{title:`This Session Host`,children:(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(IJ,{label:`Default Scope`,children:e.scope}),(0,U.jsx)(IJ,{label:`Backends`,children:e.backends.join(`, `)||`none`}),(0,U.jsx)(IJ,{label:`Shells`,children:e.shell?`available`:`unavailable`}),(0,U.jsx)(IJ,{label:`Settings file`,children:`<state root>/config.json`})]})}),(0,U.jsx)(Gs,{open:s,onOpenChange:c,children:(0,U.jsxs)(Js,{children:[(0,U.jsxs)(Ys,{children:[(0,U.jsxs)(Zs,{children:[`This reaps `,d,` Agent Session`,d===1?``:`s`]}),(0,U.jsxs)(Qs,{children:[d===1?`One Settled Agent Session is`:`${d} Settled Agent Sessions are`,` `,`older than `,a.trim(),`, so the next sweep will delete`,` `,d===1?`its Presentation Transcript`:`their Presentation Transcripts`,` from disk. That happens within the hour, not now, and it cannot be undone.`]})]}),(0,U.jsxs)(Xs,{children:[(0,U.jsx)(ec,{children:`Keep the old window`}),(0,U.jsx)($s,{variant:`destructive`,onClick:f,children:`Save anyway`})]})]})})]})}function HJ(e){let t=e.trim();return t.startsWith(`/`)||t.startsWith(`~`)?`completion`:`search`}function UJ(e){return e.trim()!==``}function WJ(){let{config:e,refresh:t}=Dt(),{save:n,saving:r}=LJ(),i=e.projectList??[],a=e.projectCandidates??[],o=e.projects?.root??``,s=e.projects?.include??[],c=(0,H.useCallback)((e,r)=>{(async()=>{await n({projects:{include:e}},r)&&await t()})()},[n,t]),l=t=>{let n=Iq(t,e.projects?.root===void 0?void 0:e.scope);s.includes(n)||c([...s,n],`Project added.`)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(GJ,{included:i,onRemove:e=>c(s.filter((t,n)=>n!==e),`Project removed.`)}),(0,U.jsx)(KJ,{candidates:a,hasRoot:e.projects?.root!==void 0,onAdd:l}),(0,U.jsx)(qJ,{onAdd:l}),(0,U.jsx)(JJ,{current:o,saving:r,onSave:n,onSaved:t})]})}function GJ({included:e,onRemove:t}){return(0,U.jsx)(FJ,{title:`Projects · ${e.length}`,description:e.length===0?`Nothing yet. A Project is one you have opted into — add one below, and it becomes an option in the New Agent Session view.`:`What the New Agent Session view offers, in this order.`,children:e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,n)=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.group===void 0?e.name:`${e.group}/${e.name}`}),e.missing?(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`directory is gone`}):null]}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.path}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.name}`,onClick:()=>t(n),children:(0,U.jsx)(ts,{"aria-hidden":!0})})]})]},e.path))})})}function KJ({candidates:e,hasRoot:t,onAdd:n}){return t?(0,U.jsx)(FJ,{title:`Found beneath the Project Root · ${e.length}`,description:`Repositories Flow can see but is not offering. Add the ones you work in.`,children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing left to add. Either everything found is already a Project, or the Project Root holds no git repositories within three levels.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:Fq(e).map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.group===void 0?null:(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.group}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.items.map(e=>(0,U.jsxs)(B,{variant:`outline`,size:`sm`,className:`font-mono text-xs font-normal`,onClick:()=>n(e.path),children:[(0,U.jsx)(Ko,{"aria-hidden":!0}),e.name]},e.path))})]},e.group??``))})}):null}function qJ({onAdd:e}){let[t,n]=(0,H.useState)(``),[r,i]=(0,H.useState)(void 0),a=(0,H.useRef)(``);(0,H.useEffect)(()=>{if(a.current=t,!UJ(t)){i(void 0);return}let e=new AbortController,n=setTimeout(()=>{(async()=>{try{let n=await kt(`/api/directories?q=${encodeURIComponent(t)}`,{signal:e.signal});if(!n.ok)return;let r=await n.json();r.query===a.current&&i(r)}catch{}})()},150);return()=>{e.abort(),clearTimeout(n)}},[t]);let o=HJ(t);return(0,U.jsxs)(FJ,{title:`Add any directory`,description:(0,U.jsxs)(U.Fragment,{children:[`Type a name to search beneath the Project Root — repositories included, so`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`packages/api`}),` inside a monorepo is reachable. Start with `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`/`}),` or`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),` to complete a path anywhere on this machine instead.`]}),children:[(0,U.jsx)(et,{className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`api, or /home/you/elsewhere`,spellCheck:!1}),r===void 0?null:r.paths.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o===`completion`?`No directory there.`:`Nothing beneath the Project Root matches.`}):(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsxs)(`span`,{className:`pb-1 text-xs text-muted-foreground`,children:[o===`completion`?`Directories here`:`Found beneath the Project Root`,r.truncated?` — showing the first few, keep typing`:null]}),r.paths.map(t=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b py-1 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t}),(0,U.jsxs)(B,{variant:`ghost`,size:`sm`,onClick:()=>{e(t),n(``)},children:[(0,U.jsx)(Ko,{"aria-hidden":!0}),`Add`]})]},t))]})]})}function JJ({current:e,saving:t,onSave:n,onSaved:r}){let[i,a]=(0,H.useState)(e);return(0,H.useEffect)(()=>a(e),[e]),(0,U.jsxs)(FJ,{title:`Project Root`,description:(0,U.jsxs)(U.Fragment,{children:[`The directory Flow looks beneath for candidates, and the one it reports as its default Scope. Absolute, or starting with`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),`. A Project outside it can still be added by path.`]}),children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Where your repositories live`}),(0,U.jsx)(et,{className:`font-mono`,value:i,onChange:e=>a(e.target.value),placeholder:`~/workspace`,spellCheck:!1})]}),(0,U.jsx)(RJ,{dirty:i.trim()!==e,saving:t,onSave:()=>{(async()=>{let e=i.trim()===``?`Project Root cleared.`:`Project Root saved.`;await n({projects:{root:i.trim()}},e)&&await r()})()},onReset:()=>a(e)})]})}function YJ(){let{config:e}=Dt(),{save:t}=LJ(),n=e.permissions?.allow??[],r=(0,H.useCallback)(e=>{t({permissions:{allow:n.filter(t=>t!==e)}},`${e} will be asked about again.`)},[n,t]);return(0,U.jsx)(FJ,{title:`Always allowed · ${n.length}`,description:n.length===0?`Nothing yet. Answering a Permission Prompt with “Always allow on this machine” adds a tool here, and it is never asked about again until you take it back.`:`These run in every Agent Session without asking. Revoking one means the next call is asked about again — it does not undo anything already done.`,children:n.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-col`,children:n.map(e=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e}),(0,U.jsx)(B,{variant:`ghost`,size:`icon-sm`,"aria-label":`Revoke ${e}`,onClick:()=>r(e),children:(0,U.jsx)(ts,{"aria-hidden":!0})})]},e))})})}var XJ=`__unset_effort__`;function ZJ({value:e,levels:t,ariaLabel:n,allowUnset:r=!1,disabled:i=!1,onChange:a}){let o=e!==``&&!t.includes(e);return(0,U.jsxs)(Qn,{value:e||(r?XJ:null),disabled:i,onValueChange:e=>{typeof e==`string`&&a(e===XJ?``:e)},children:[(0,U.jsx)(Un,{className:`w-full`,size:`sm`,"aria-label":n,"aria-invalid":o||void 0,children:(0,U.jsx)(Xn,{children:e||`Use backend default`})}),(0,U.jsxs)(Vn,{children:[r?(0,U.jsx)(Nn,{value:XJ,children:`Use backend default`}):null,o?(0,U.jsxs)(Nn,{value:e,disabled:!0,children:[e,` (saved — unsupported)`]}):null,t.map(e=>(0,U.jsx)(Nn,{value:e,children:e},e))]})]})}var QJ=`__unset__`;function $J(){let{config:e}=Dt(),{catalogue:t,loading:n,problem:r,refresh:i}=dN();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(tY,{backends:e.backends,current:e.providers?.defaultBackend??``}),(0,U.jsx)(`div`,{className:`flex flex-col gap-3`,children:(e.backends??[]).map(i=>(0,U.jsx)(nY,{backend:i,providers:e.providers,isDefault:i===cN(e.backends,e.providers?.defaultBackend),listing:t?.find(e=>e.backend===i),loading:n,discoveryProblem:r},i))}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(B,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>void i(),children:n?`Checking models…`:`Check again`}),(0,U.jsx)(`span`,{role:r?`alert`:void 0,children:r??`Refresh after connecting a Provider. Pi lists only models with authentication configured.`})]})]})}function eY(e){return e===`pi`?`Pi`:e===`claude`?`Claude`:e}function tY({backends:e,current:t}){let{save:n,saving:r}=LJ(),[i,a]=(0,H.useState)(t);(0,H.useEffect)(()=>a(t),[t]);let o=cN(e);return(0,U.jsxs)(FJ,{title:`Default Backend`,description:`Used by web and terminal for new Agent Sessions. An explicit backend choice takes precedence.`,children:[(0,U.jsxs)(Qn,{value:i||QJ,onValueChange:e=>{typeof e==`string`&&a(e===QJ?``:e)},children:[(0,U.jsx)(Un,{className:`w-full sm:max-w-sm`,"aria-label":`Default Backend`,children:(0,U.jsx)(Xn,{children:i?eY(i):`Automatic${o?` — ${eY(o)}`:``}`})}),(0,U.jsxs)(Vn,{children:[(0,U.jsxs)(Nn,{value:QJ,children:[`Automatic`,o?` — ${eY(o)}`:``]}),t&&!e.includes(t)?(0,U.jsxs)(Nn,{value:t,disabled:!0,children:[t,` (unavailable)`]}):null,e.map(e=>(0,U.jsx)(Nn,{value:e,children:eY(e)},e))]})]}),(0,U.jsx)(RJ,{dirty:i!==t,saving:r,onReset:()=>a(t),onSave:()=>void n({providers:{defaultBackend:i}},`Default Backend saved.`)})]})}function nY({backend:e,providers:t,listing:n,loading:r,isDefault:i,discoveryProblem:a}){let{save:o,saving:s}=LJ(),c=t?.summary,l=t?.summaries?.[e]??(c?.backend===e?c:void 0),u=t?.defaults?.[e]??``,d=t?.efforts?.[e]??``,f=l?.modelId??``,p=l?.automatic??!0,[m,h]=(0,H.useState)(u),[g,_]=(0,H.useState)(d),[v,y]=(0,H.useState)(f),[b,x]=(0,H.useState)(p);function S(){h(u),_(d),y(f),x(p)}(0,H.useEffect)(S,[u,d,f,p]);let C=n?.models.find(e=>e.id===m),w=C?.effortLevels??[],T=r?`Checking model Effort support…`:a??n?.problem??(m?C?void 0:`This model is unavailable; Effort support cannot be confirmed.`:`Choose a model to confirm its Effort levels.`),E=!!C&&w.length===0,D=!!g&&(!C||!w.includes(g)),O=m!==u||g!==d||v!==f||b!==p;return(0,U.jsxs)(`details`,{name:`provider-backends`,className:`group rounded-lg border bg-card`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-3 rounded-lg p-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold`,children:eY(e)}),i?(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground`,children:`Default`}):null,O?(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Unsaved`}):null]}),(0,U.jsxs)(`p`,{className:`mt-1 truncate text-xs text-muted-foreground`,children:[C?.label??(m||`Backend model default`),g?` · ${g} effort`:``,v?` · Summary enabled`:` · No summary model`]})]}),(0,U.jsx)(dn,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 border-t p-4`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Model and effort defaults apply to new Agent Sessions only.`}),(0,U.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,U.jsx)(iY,{label:`Default Model`,backend:e,listing:n,loading:r,value:m,placeholder:`Use backend default`,onChange:h}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Default Effort`}),E?D?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{className:`text-sm`,"aria-invalid":`true`,children:[g,` (saved — unsupported)`]}),(0,U.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>_(``),children:`Use backend default`})]}):null:(0,U.jsx)(ZJ,{value:g,levels:w,ariaLabel:`${e} Default Effort`,allowUnset:!0,disabled:!!T,onChange:_}),(0,U.jsx)(`span`,{className:D?`text-xs text-destructive`:`text-xs text-muted-foreground`,role:D||T?`status`:void 0,children:D?E?`Saved Effort “${g}” is invalid because this model has no Effort control. Use the backend default.`:`Saved Effort “${g}” is not confirmed for this model. Choose a supported level or use the backend default.`:T||(E?`This model has no Effort control.`:`For the main model only. Explicit session effort takes precedence.`)})]})]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,U.jsx)(iY,{label:`Summary Model`,backend:e,listing:n,loading:r,value:v,placeholder:`None — keep the first line`,onChange:y}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Names this backend’s Agent Sessions. Does not inherit Default Effort.`}),v?(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Name new Agent Sessions automatically`}),(0,U.jsx)(ht,{checked:b,onCheckedChange:x})]}):null]})]}),(0,U.jsx)(RJ,{dirty:O,saving:s,saveDisabled:D,onReset:S,onSave:()=>void o({providers:{defaults:{[e]:m},efforts:{[e]:g},summaries:{[e]:v?{modelId:v,automatic:b}:null}}},`${e} models saved.`)}),n?.autoCompaction?(0,U.jsx)(rY,{backend:e,listing:n,current:t?.autoCompaction?.[e]}):null]})]})}function rY({backend:e,listing:t,current:n}){let{save:r,saving:i}=LJ(),[a,o]=(0,H.useState)(``),s=n?.[a],[c,l]=(0,H.useState)(`default`),[u,d]=(0,H.useState)(`80`),f=s?.mode??`default`,p=s?.mode===`enabled`?String(s.targetPercent):`80`;function m(){l(f),d(p)}(0,H.useEffect)(m,[a,f,p]);let h=[...t.models,...Object.keys(n??{}).filter(e=>!t.models.some(t=>t.id===e)).map(e=>({id:e}))],g=t.models.find(e=>e.id===a),_=t.autoCompaction===`model-change`&&!g?.contextWindow,v=Number(u),y=c!==`enabled`||!_&&Number.isInteger(v)&&v>=1&&v<=99,b=c!==f||c===`enabled`&&u!==p;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 border-t pt-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Auto-compaction`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Applies when a Backend Session opens or is Revived. Saving does not change running Backend Sessions. Manual compaction stays available.`}),(0,U.jsx)(iY,{label:`Auto-compaction model`,backend:e,listing:{...t,models:h},loading:!1,value:a,placeholder:`Choose a model`,onChange:o}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Auto-compaction mode`}),(0,U.jsxs)(Qn,{value:c,disabled:!a,onValueChange:e=>{(e==="default"||e===`disabled`||e===`enabled`)&&l(e)},children:[(0,U.jsx)(Un,{"aria-label":`${e} Auto-compaction mode`,children:(0,U.jsx)(Xn,{children:c==="default"?`Use backend default`:c===`disabled`?`Disabled`:`Enabled with target`})}),(0,U.jsxs)(Vn,{children:[(0,U.jsx)(Nn,{value:`default`,children:`Use backend default`}),(0,U.jsx)(Nn,{value:`disabled`,children:`Disabled`}),(0,U.jsx)(Nn,{value:`enabled`,disabled:_,children:`Enabled with target`})]})]})]}),c===`enabled`?(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Target percentage`}),(0,U.jsx)(et,{"aria-label":`${e} Auto-compaction target percentage`,type:`number`,min:1,max:99,step:1,disabled:_,value:u,onChange:e=>d(e.target.value)}),!y&&!_?(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`Enter an integer from 1 to 99.`}):null]}):null,_&&a?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The model context window is unknown. Percentage control is unavailable.`}):null,(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The percentage is a target, not a guarantee. `,t.autoCompaction===`startup`?`Claude may compact earlier. Backend restrictions still apply. Model changes in a running Backend Session do not change its startup threshold. If no model is selected at startup, Claude uses its own defaults.`:`Pi uses the model context window to set reserved tokens. This also changes the summary token budget. Model changes use the Settings snapshot from when the Backend Session opened.`]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(B,{size:`sm`,disabled:!a||!b||!y||i,onClick:()=>{if(!a||!y)return;let t=c==="default"?null:c===`disabled`?{mode:c}:{mode:c,targetPercent:v};r({providers:{autoCompaction:{[e]:{[a]:t}}}},`Auto-compaction saved.`)},children:i?`Saving…`:`Save`}),(0,U.jsx)(B,{size:`sm`,variant:`ghost`,disabled:!b||i,onClick:m,children:`Discard`})]})]})}function iY({label:e,backend:t,listing:n,loading:r,value:i,placeholder:a,onChange:o}){let[s,c]=(0,H.useState)(``),l=n?.models??[],u=l.filter(e=>`${e.provider??``} ${e.label??``} ${e.id}`.toLowerCase().includes(s.toLowerCase())),d=l.find(e=>e.id===i),f=i!==``&&d===void 0,p=d?`${d.provider?`${d.provider} / `:``}${d.label??d.id}`:i?`${i} (unavailable)`:a;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e}),t!==`pi`&&!r&&l.length===0?(0,U.jsx)(et,{"aria-label":`${t} ${e}`,value:i,placeholder:a,onChange:e=>o(e.target.value),spellCheck:!1,autoComplete:`off`}):(0,U.jsxs)(U.Fragment,{children:[l.length>10?(0,U.jsx)(et,{"aria-label":`Search ${t} ${e}`,placeholder:`Filter models…`,value:s,onChange:e=>c(e.target.value)}):null,(0,U.jsxs)(Qn,{value:i||QJ,onValueChange:e=>{typeof e==`string`&&o(e===QJ?``:e)},children:[(0,U.jsx)(Un,{className:`w-full`,size:`sm`,"aria-label":`${t} ${e}`,children:(0,U.jsx)(Xn,{children:p})}),(0,U.jsxs)(Vn,{children:[(0,U.jsx)(Nn,{value:QJ,children:a}),f?(0,U.jsxs)(Nn,{value:i,disabled:!0,children:[i,` (unavailable)`]}):null,u.map(e=>(0,U.jsxs)(Nn,{value:e.id,children:[e.provider?`${e.provider} / `:``,e.label??e.id]},e.id))]})]})]}),r?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Checking models…`}):null,n?.problem?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.problem}):null,t===`pi`&&!r&&l.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No authenticated models available. Connect a Provider in pi, then check again.`}):null]})}function aY(){let{config:e}=Dt(),{save:t,saving:n}=LJ(),r=e.fonts??oe,[i,a]=(0,H.useState)(r.chrome),[o,s]=(0,H.useState)(r.monospace);(0,H.useEffect)(()=>{a(r.chrome),s(r.monospace)},[r.chrome,r.monospace]);let c=i.trim()!==r.chrome||o.trim()!==r.monospace;return(0,U.jsxs)(FJ,{title:`Typefaces`,description:`A CSS font-family list. The browser uses the first family it can resolve, so name the one you want and leave a generic at the end.`,children:[(0,U.jsx)(oY,{label:`Interface`,hint:`Labels, transcript prose, buttons.`,value:i,onChange:a,preview:`The quick brown fox`,onDefault:()=>a(le().chrome)}),(0,U.jsx)(oY,{label:`Monospace`,hint:`The Shell's terminal, and everything that aligns character by character — Scopes, ids, counts.`,value:o,onChange:s,preview:`~/code   main  ✔ 1234567890`,onDefault:()=>s(le().monospace)}),(0,U.jsx)(RJ,{dirty:c,saving:n,onSave:()=>void t({fonts:{chrome:i.trim(),monospace:o.trim()}},`Typefaces saved.`),onReset:()=>{a(r.chrome),s(r.monospace)}})]})}function oY({label:e,hint:t,value:n,onChange:r,preview:i,onDefault:a}){let o=wt(n);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e}),(0,U.jsx)(B,{variant:`link`,size:`sm`,className:`h-auto p-0 text-xs`,onClick:e=>{e.preventDefault(),a()},children:`Use the default`})]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}),(0,U.jsx)(et,{className:`font-mono text-xs`,value:n,onChange:e=>r(e.target.value),spellCheck:!1,autoComplete:`off`})]}),(0,U.jsx)(`p`,{"aria-hidden":!0,className:`truncate rounded-md border bg-muted/40 px-2 py-1.5 text-sm`,style:{fontFamily:n},children:i}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.length,` famil`,o.length===1?`y`:`ies`,`: `,o.join(` → `)||`none`]})]})}var sY=[{title:`Moving around`,description:`The rail's cursor is not the Agent Session on screen. Move it, then press Enter to open what it is on.`,shortcuts:[{binding:`sidebar-next`,keys:[`j`,`ArrowDown`],description:`Next Agent Session in the rail`},{binding:`sidebar-previous`,keys:[`k`,`ArrowUp`],description:`Previous Agent Session in the rail`},{binding:`sidebar-first`,keys:[`Home`],description:`First Agent Session`},{binding:`sidebar-last`,keys:[`End`],description:`Last Agent Session`},{binding:`focus-pane`,keys:[`Enter`],description:`Open the cursored one and type in it`}]},{title:`Doing things`,description:`Nothing here spends money or sends text on a single unmodified key: n opens the New Agent Session view rather than starting one, and no shortcut sends a message or Revives one.`,shortcuts:[{binding:`new-agent-session`,keys:[`n`],description:`New Agent Session — opens the view`},{binding:`settle`,keys:[`s`],description:`Settle the Agent Session on screen`},{binding:`toggle-bottom-dock`,keys:["`"],description:`Show or minimise the bottom Dock — minimising does not end its Shells`},{binding:`toggle-right-dock`,keys:[`~`],description:`Show or minimise the right Dock`},{binding:`search`,keys:[`f`],chord:!0,description:`Find in the Presentation Transcript — opens the field, Escape closes it`},{binding:`model-picker`,keys:[`m`],description:`Model picker`},{binding:`effort-picker`,keys:[`e`],description:`Effort picker`},{binding:`blur-or-abort`,keys:[`Escape`],description:`Leave the Composer, or abort the turn — aborting discards the Steering Queue`}]},{title:`Everywhere`,shortcuts:[{binding:`command-palette`,keys:[`k`],chord:!0,description:`Command palette`},{binding:`toggle-rail`,keys:[`b`],chord:!0,description:`Show or hide the rail — drag its right edge to resize instead`},{binding:`keyboard-settings`,keys:[`?`],description:`This list`},{binding:`leave-settings`,keys:[`Escape`],description:`Leave the Settings`}]}],cY={ArrowDown:`↓`,ArrowUp:`↑`,ArrowLeft:`←`,ArrowRight:`→`};function lY(e){return cY[e]??e}function uY(){return(0,U.jsx)(U.Fragment,{children:sY.map(e=>(0,U.jsx)(FJ,{title:e.title,description:e.description,children:(0,U.jsx)(`dl`,{className:`flex flex-col`,children:e.shortcuts.map(e=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b py-1.5 last:border-b-0`,children:[(0,U.jsx)(`dt`,{className:`text-sm`,children:e.description}),(0,U.jsxs)(`dd`,{className:`flex shrink-0 items-center gap-1`,children:[e.chord===!0?(0,U.jsx)(eN,{children:`⌘/Ctrl`}):null,e.keys.map(e=>(0,U.jsx)(eN,{children:lY(e)},e))]})]},e.binding))})},e.title))})}var dY=(0,H.lazy)(()=>nj(()=>import(`./settings-workflows-1DMYfZtn.js`),__vite__mapDeps([6,1,2,3,4,5]))),fY=(0,H.lazy)(()=>nj(()=>import(`./settings-mcp-ZMIfuuZU.js`),__vite__mapDeps([7,1,2,3]))),pY=(0,H.lazy)(()=>nj(()=>import(`./settings-secrets-CgTrBpi2.js`),__vite__mapDeps([8,1,2])));function mY({section:e}){return(0,U.jsx)(`div`,{className:`transcript-scroller min-h-0 overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex ${e===`workflows`?`w-full`:`max-w-2xl`} flex-col gap-6 px-4 py-8 max-lg:pt-14 sm:px-6`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These apply to every Agent Session on this machine, not to one Scope.`}),(0,U.jsxs)(H.Suspense,{fallback:(0,U.jsx)(`p`,{children:`Loading settings…`}),children:[e===`workflows`&&(0,U.jsx)(dY,{}),e===`secrets`&&(0,U.jsx)(pY,{}),e===`mcp`&&(0,U.jsx)(fY,{})]}),e===`general`?(0,U.jsx)(VJ,{}):null,e===`projects`?(0,U.jsx)(WJ,{}):null,e===`permissions`?(0,U.jsx)(YJ,{}):null,e===`providers`?(0,U.jsx)($J,{}):null,e===`appearance`?(0,U.jsx)(aY,{}):null,e===`keyboard`?(0,U.jsx)(uY,{}):null]})})}function hY(){let{config:e}=Dt(),{sessions:t,loaded:n}=ta(),{route:r,sessionId:i,focus:a,openNewAgentSession:o,openSettings:s,leaveSettings:c}=_o(),l=ra(),[u,d]=(0,H.useState)(void 0),[f,m]=(0,H.useState)(!0),[h,g]=(0,H.useState)(!1),_=ro(),v=(0,H.useMemo)(()=>t.map(e=>e.id),[t]),y=Va(i,n?v:void 0),b=(0,H.useRef)(void 0),x=(0,H.useCallback)((e,t=!1)=>{t&&(b.current=e),a(e)},[a]);(0,H.useEffect)(()=>{b.current===i&&(b.current=void 0,y.dispatch({type:`open-workflows`}))},[y,i]);let S=Za(v),C=ri(i),[w,T]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(w||r.view!==`session`)return;if(i!==void 0){T(!0);return}if(!n)return;T(!0);let e=t[0];!e||Cr(e)===`filed-away`||a(e.id)},[w,n,t,i,a,r.view]),(0,H.useEffect)(()=>{d(e=>oo(t,e))},[t]);let E=(0,H.useCallback)(e=>{d(n=>so(t,n,e))},[t]);(0,H.useEffect)(()=>{g(!1)},[i]);let D=(0,H.useCallback)(e=>{l({type:`settle`,sessionId:e}).then(()=>{p.info(`Settled — the next message Revives it.`)})},[l]),O=(0,H.useCallback)(e=>{document.querySelector(`[data-pane] ${e}`)?.focus()},[]),k=(0,H.useMemo)(()=>({"new-agent-session":o,"sidebar-next":()=>E(1),"sidebar-previous":()=>E(-1),"sidebar-first":()=>d(t[0]?.id),"sidebar-last":()=>d(t.at(-1)?.id),"focus-pane":()=>{u&&a(u),O(`[data-composer-input]`)},...i===void 0?{}:{search:()=>{g(!0),O(`[data-transcript-search]`)}},settle:()=>{i!==void 0&&C!==void 0&&Er(C.status)&&D(i)},"toggle-bottom-dock":()=>{i!==void 0&&y.dispatch({type:`toggle`,side:`bottom`})},"toggle-right-dock":()=>{i!==void 0&&y.dispatch({type:`toggle`,side:`right`})},"toggle-rail":()=>m(e=>!e),"keyboard-settings":()=>s(`keyboard`),"leave-settings":c,"blur-or-abort":()=>{if(i===void 0||C===void 0||!xr(C.status))return;let e=C.queueDepth;l({type:`abort`,sessionId:i}).then(()=>{p.info(e>0?`aborted · ${e} queued message${e===1?``:`s`} discarded`:`aborted`)})}}),[C,e.shell,u,y,a,O,i,c,o,s,E,l,t,D]),A=r.view===`settings`;return(0,U.jsx)(sN,{handlers:k,view:r.view,children:(0,U.jsxs)(CM,{className:`h-full min-h-0`,open:f,onOpenChange:m,style:{"--sidebar-width":eo(_.width)},children:[(0,U.jsxs)(wM,{collapsible:`offcanvas`,role:`complementary`,"aria-label":A?`Settings`:`Agent Sessions`,className:`border-r border-sidebar-border`,children:[(0,U.jsx)(mJ,{width:_.width,onResize:_.set,onNudge:_.nudge}),A?(0,U.jsx)(NJ,{section:r.section,onSelect:s,onLeave:c}):(0,U.jsx)(KM,{sessions:t,focusedId:i,focusedStatus:C?.status,cursorId:u,link:C?.link,onFocus:a,onSettle:D,onNew:o,onOpenSettings:s})]}),(0,U.jsxs)(EM,{className:`mobile-safe-frame grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] overflow-hidden`,children:[(0,U.jsx)(TM,{className:`mobile-rail-trigger absolute z-30 lg:hidden`}),A?(0,U.jsx)(mY,{section:r.section}):i===void 0?w?(0,U.jsx)(uJ,{drafts:S,onCreated:x,initialBackend:r.view===`session`?r.backend:void 0}):(0,U.jsx)(`div`,{className:`min-h-0`}):(0,U.jsx)(zM,{sessionId:i,searchOpen:h,onCloseSearch:()=>g(!1),docks:y,drafts:S,shells:e.shell===!0})]})]})})}function gY(){return(0,U.jsx)(we,{children:(0,U.jsx)(jJ,{children:(0,U.jsx)(na,{children:(0,U.jsx)(Qr,{children:(0,U.jsxs)(ll,{children:[(0,U.jsx)(hY,{}),(0,U.jsx)(m,{}),(0,U.jsx)(yo,{})]})})})})})}var _Y=document.getElementById(`root`);if(!_Y)throw Error(`index.html is missing #root`);(0,hr.createRoot)(_Y).render((0,U.jsx)(H.StrictMode,{children:(0,U.jsx)(gY,{})}));export{xy as $,tA as A,Zu as At,LC as B,Xi as Bt,dN as C,Ju as Ct,$k as D,fu as Dt,gA as E,G as Et,ow as F,Ro as Ft,db as G,MC as H,Vr as Ht,BC as I,Eo as It,Dy as J,Ab as K,VC as L,xo as Lt,RE as M,Yl as Mt,jw as N,Qu as Nt,nA as O,Nu as Ot,pw as P,ds as Pt,Wv as Q,zC as R,vo as Rt,oR as S,M_ as St,$j as T,fd as Tt,OC as U,jr as Ut,PC as V,Yi as Vt,vS as W,ay as X,Jv as Y,wy as Z,kq as _,G_ as _t,nJ as a,Gv as at,hq as b,pf as bt,Yq as c,xv as ct,Lq as d,W_ as dt,Cy as et,zq as f,L_ as ft,Rq as g,pv as gt,Uq as h,dv as ht,rJ as i,sy as it,aD as j,Au as jt,eA as k,md as kt,qq as l,J as lt,Vq as m,B_ as mt,FJ as n,Ty as nt,tJ as o,jy as ot,Hq as p,V_ as pt,yS as q,LJ as r,fy as rt,Qq as s,Yv as st,ZJ as t,Ey as tt,Bq as u,P_ as ut,pq as v,hf as vt,cN as w,W as wt,sq as x,r_ as xt,vq as y,Jg as yt,RC as z,ta as zt};