agent-lookout 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/PRIVACY.md +41 -35
- package/README.md +26 -25
- package/SECURITY.md +14 -9
- package/dist/assets/{HistoryPanel-TXa0oPH4.js → HistoryPanel-Cwmn7YtJ.js} +1 -1
- package/dist/assets/SessionPanel-BJ5t_CPi.js +1 -0
- package/dist/assets/index-B_1Its0R.css +1 -0
- package/dist/assets/index-QSfCI-L_.js +3 -0
- package/dist/cli/agent-lookout.js +4 -4
- package/dist/cli/{chunk-OT3EGOTY.js → chunk-I6Q35DHC.js} +38 -1
- package/dist/cli/{chunk-Q73JDXXW.js → chunk-JSBQMY3Q.js} +1 -1
- package/dist/cli/{chunk-NWVEVCRT.js → chunk-LZ62RW3N.js} +8 -3
- package/dist/cli/{mcpServer-IFB2FEOZ.js → mcpServer-HJSH3WIS.js} +10 -7
- package/dist/cli/{startCommand-J3QS26SZ.js → startCommand-PR5JPWCT.js} +1545 -370
- package/dist/index.html +2 -2
- package/docs/API.md +97 -51
- package/docs/GUIDE.md +125 -28
- package/package.json +1 -1
- package/dist/assets/SessionPanel-BStoG7uq.js +0 -1
- package/dist/assets/index-BsTJp5-3.css +0 -1
- package/dist/assets/index-a7ubgAmE.js +0 -3
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HistoryPanel-TXa0oPH4.js","assets/react-C2DiJaR6.js","assets/motion-BAhdRuCw.js","assets/radix-BH0JH8UU.js","assets/SessionPanel-BStoG7uq.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{j as n,r as p,d as Bi}from"./react-C2DiJaR6.js";import{M as qi,A as Gi,m as Ki}from"./motion-BAhdRuCw.js";import{S as Vi,P as Yi,R as Ji,T as Xi,a as Qi,C as Zi,b as el,c as tl,d as nl,e as sl,D as rr,f as ar,g as ir,h as lr,i as cr,j as ol,k as rl}from"./radix-BH0JH8UU.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function s(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(r){if(r.ep)return;r.ep=!0;const a=s(r);fetch(r.href,a)}})();const al="modulepreload",il=function(e){return"/"+e},Qs={},dr=function(t,s,o){let r=Promise.resolve();if(s&&s.length>0){let d=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=i?.nonce||i?.getAttribute("nonce");r=d(s.map(c=>{if(c=il(c),c in Qs)return;Qs[c]=!0;const u=c.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":al,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),u)return new Promise((g,x)=>{h.addEventListener("load",g),h.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&a(l.reason);return t().catch(a)})},He=1440*60*1e3,ur=3600*1e3,Zs=24*ur;function mn(e){if(e%Zs===0){const s=e/Zs;return s===1?"a day":`${s} days`}const t=Math.max(1,Math.round(e/ur));return t===1?"an hour":`${t} hours`}const st=["mon","tue","wed","thu","fri","sat","sun"],eo=["longWait","idle","quietHours"],vt={min:1,max:1440,default:10},ot={min:1,max:720,default:48},Zt={longWait:{on:!1,minutes:vt.default},idle:{on:!1,hours:ot.default},quietHours:{on:!1,from:"22:00",to:"08:00",days:[...st],leaveOutAnswered:!1}},ll=36e5,cl=/^([01]\d|2[0-3]):([0-5]\d)$/;function St(e){const t=cl.exec(e);return t?Number(t[1])*60+Number(t[2]):null}function hn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function hs(e,t,s){return t.every(o=>o in e)?!s||Object.keys(e).length===t.length:!1}function fr(e,t){return Number.isSafeInteger(e)&&e>=t.min&&e<=t.max}function dl(e,t){if(!hn(e)||!hs(e,["on","minutes"],t))return null;const{on:s,minutes:o}=e;return typeof s!="boolean"||!fr(o,vt)?null:{on:s,minutes:o}}function ul(e,t){if(!hn(e)||!hs(e,["on","hours"],t))return null;const{on:s,hours:o}=e;return typeof s!="boolean"||!fr(o,ot)?null:{on:s,hours:o}}function fl(e){return!Array.isArray(e)||!e.every(t=>st.includes(t))||new Set(e).size!==e.length?null:st.filter(t=>e.includes(t))}function ml(e,t){const s=["on","from","to","days","leaveOutAnswered"];if(!hn(e)||!hs(e,s,t))return null;const{on:o,from:r,to:a,leaveOutAnswered:i}=e;if(typeof o!="boolean"||typeof i!="boolean"||typeof r!="string"||typeof a!="string")return null;const l=St(r),d=St(a);if(l===null||d===null||l===d)return null;const c=fl(e.days);return c===null?null:{on:o,from:r,to:a,days:c,leaveOutAnswered:i}}const hl={longWait:dl,idle:ul,quietHours:ml};function ps(e){const t={longWait:{...Zt.longWait},idle:{...Zt.idle},quietHours:{...Zt.quietHours,days:[...st]}},s=[];if(!hn(e))return{rules:t,unread:e===void 0?[]:[...eo]};for(const o of eo){if(e[o]===void 0)continue;const r=hl[o](e[o],!1);r===null?s.push(o):Object.assign(t,{[o]:r})}return{rules:t,unread:s}}function pl(e){return e?.idle.on?e.idle.hours*ll:He}function mr(e){return e.timeRules??Zt}function hr(e){var t,s,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(s=hr(e[t]))&&(o&&(o+=" "),o+=s)}else for(s in e)e[s]&&(o&&(o+=" "),o+=s);return o}function pr(){for(var e,t,s=0,o="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=hr(e))&&(o&&(o+=" "),o+=t);return o}const to=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,no=pr,xr=(e,t)=>s=>{var o;if(t?.variants==null)return no(e,s?.class,s?.className);const{variants:r,defaultVariants:a}=t,i=Object.keys(r).map(c=>{const u=s?.[c],f=a?.[c];if(u===null)return null;const h=to(u)||to(f);return r[c][h]}),l=s&&Object.entries(s).reduce((c,u)=>{let[f,h]=u;return h===void 0||(c[f]=h),c},{}),d=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((c,u)=>{let{class:f,className:h,...g}=u;return Object.entries(g).every(x=>{let[w,m]=x;return Array.isArray(m)?m.includes({...a,...l}[w]):{...a,...l}[w]===m})?[...c,f,h]:c},[]);return no(e,i,d,s?.class,s?.className)},xl=(e,t)=>{const s=new Array(e.length+t.length);for(let o=0;o<e.length;o++)s[o]=e[o];for(let o=0;o<t.length;o++)s[e.length+o]=t[o];return s},gl=(e,t)=>({classGroupId:e,validator:t}),gr=(e=new Map,t=null,s)=>({nextPart:e,validators:t,classGroupId:s}),sn="-",so=[],wl="arbitrary..",bl=e=>{const t=kl(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return yl(i);const l=i.split(sn),d=l[0]===""&&l.length>1?1:0;return wr(l,d,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const d=o[i],c=s[i];return d?c?xl(c,d):d:c||so}return s[i]||so}}},wr=(e,t,s)=>{if(e.length-t===0)return s.classGroupId;const r=e[t],a=s.nextPart.get(r);if(a){const c=wr(e,t+1,a);if(c)return c}const i=s.validators;if(i===null)return;const l=t===0?e.join(sn):e.slice(t).join(sn),d=i.length;for(let c=0;c<d;c++){const u=i[c];if(u.validator(l))return u.classGroupId}},yl=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),s=t.indexOf(":"),o=t.slice(0,s);return o?wl+o:void 0})(),kl=e=>{const{theme:t,classGroups:s}=e;return jl(s,t)},jl=(e,t)=>{const s=gr();for(const o in e){const r=e[o];xs(r,s,o,t)}return s},xs=(e,t,s,o)=>{const r=e.length;for(let a=0;a<r;a++){const i=e[a];Nl(i,t,s,o)}},Nl=(e,t,s,o)=>{if(typeof e=="string"){vl(e,t,s);return}if(typeof e=="function"){Sl(e,t,s,o);return}Al(e,t,s,o)},vl=(e,t,s)=>{const o=e===""?t:br(t,e);o.classGroupId=s},Sl=(e,t,s,o)=>{if(El(e)){xs(e(o),t,s,o);return}t.validators===null&&(t.validators=[]),t.validators.push(gl(s,e))},Al=(e,t,s,o)=>{const r=Object.entries(e),a=r.length;for(let i=0;i<a;i++){const[l,d]=r[i];xs(d,br(t,l),s,o)}},br=(e,t)=>{let s=e;const o=t.split(sn),r=o.length;for(let a=0;a<r;a++){const i=o[a];let l=s.nextPart.get(i);l||(l=gr(),s.nextPart.set(i,l)),s=l}return s},El=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Tl=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=Object.create(null),o=Object.create(null);const r=(a,i)=>{s[a]=i,t++,t>e&&(t=0,o=s,s=Object.create(null))};return{get(a){let i=s[a];if(i!==void 0)return i;if((i=o[a])!==void 0)return r(a,i),i},set(a,i){a in s?s[a]=i:r(a,i)}}},Jn="!",oo=":",Ml=[],ro=(e,t,s,o,r)=>({modifiers:e,hasImportantModifier:t,baseClassName:s,maybePostfixModifierPosition:o,isExternal:r}),Cl=e=>{const{prefix:t,experimentalParseClassName:s}=e;let o=r=>{const a=[];let i=0,l=0,d=0,c;const u=r.length;for(let w=0;w<u;w++){const m=r[w];if(i===0&&l===0){if(m===oo){a.push(r.slice(d,w)),d=w+1;continue}if(m==="/"){c=w;continue}}m==="["?i++:m==="]"?i--:m==="("?l++:m===")"&&l--}const f=a.length===0?r:r.slice(d);let h=f,g=!1;f.endsWith(Jn)?(h=f.slice(0,-1),g=!0):f.startsWith(Jn)&&(h=f.slice(1),g=!0);const x=c&&c>d?c-d:void 0;return ro(a,g,h,x)};if(t){const r=t+oo,a=o;o=i=>i.startsWith(r)?a(i.slice(r.length)):ro(Ml,!1,i,void 0,!0)}if(s){const r=o;o=a=>s({className:a,parseClassName:r})}return o},Il=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((s,o)=>{t.set(s,1e6+o)}),s=>{const o=[];let r=[];for(let a=0;a<s.length;a++){const i=s[a],l=i[0]==="[",d=t.has(i);l||d?(r.length>0&&(r.sort(),o.push(...r),r=[]),o.push(i)):r.push(i)}return r.length>0&&(r.sort(),o.push(...r)),o}},$l=e=>({cache:Tl(e.cacheSize),parseClassName:Cl(e),sortModifiers:Il(e),postfixLookupClassGroupIds:Ll(e),...bl(e)}),Ll=e=>{const t=Object.create(null),s=e.postfixLookupClassGroups;if(s)for(let o=0;o<s.length;o++)t[s[o]]=!0;return t},_l=/\s+/,Ol=(e,t)=>{const{parseClassName:s,getClassGroupId:o,getConflictingClassGroupIds:r,sortModifiers:a,postfixLookupClassGroupIds:i}=t,l=[],d=e.trim().split(_l);let c="";for(let u=d.length-1;u>=0;u-=1){const f=d[u],{isExternal:h,modifiers:g,hasImportantModifier:x,baseClassName:w,maybePostfixModifierPosition:m}=s(f);if(h){c=f+(c.length>0?" "+c:c);continue}let v=!!m,b;if(v){const S=w.substring(0,m);b=o(S);const y=b&&i[b]?o(w):void 0;y&&y!==b&&(b=y,v=!1)}else b=o(w);if(!b){if(!v){c=f+(c.length>0?" "+c:c);continue}if(b=o(w),!b){c=f+(c.length>0?" "+c:c);continue}v=!1}const k=g.length===0?"":g.length===1?g[0]:a(g).join(":"),N=x?k+Jn:k,j=N+b;if(l.indexOf(j)>-1)continue;l.push(j);const E=r(b,v);for(let S=0;S<E.length;++S){const y=E[S];l.push(N+y)}c=f+(c.length>0?" "+c:c)}return c},Rl=(...e)=>{let t=0,s,o,r="";for(;t<e.length;)(s=e[t++])&&(o=yr(s))&&(r&&(r+=" "),r+=o);return r},yr=e=>{if(typeof e=="string")return e;let t,s="";for(let o=0;o<e.length;o++)e[o]&&(t=yr(e[o]))&&(s&&(s+=" "),s+=t);return s},ao=(e,...t)=>{let s,o,r,a;const i=d=>{const c=t.reduce((u,f)=>f(u),e());return s=$l(c),o=s.cache.get,r=s.cache.set,a=l,l(d)},l=d=>{const c=o(d);if(c)return c;const u=Ol(d,s);return r(d,u),u};return a=i,(...d)=>a(Rl(...d))},Wl=[],K=e=>{const t=s=>s[e]||Wl;return t.isThemeGetter=!0,t.themeKey=e,t},kr=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jr=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Pl=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Dl=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Fl=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ul=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,zl=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Hl=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ee=e=>Pl.test(e),_=e=>!!e&&!Number.isNaN(Number(e)),he=e=>!!e&&Number.isInteger(Number(e)),Tn=e=>e.endsWith("%")&&_(e.slice(0,-1)),ve=e=>Dl.test(e),Nr=()=>!0,Bl=e=>Fl.test(e)&&!Ul.test(e),gs=()=>!1,ql=e=>zl.test(e),Gl=e=>Hl.test(e),Kl=e=>!T(e)&&!M(e),Vl=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Yl=e=>Ie(e,Ar,gs),T=e=>kr.test(e),Re=e=>Ie(e,Er,Bl),io=e=>Ie(e,sc,_),Jl=e=>Ie(e,Mr,Nr),Xl=e=>Ie(e,Tr,gs),lo=e=>Ie(e,vr,gs),Ql=e=>Ie(e,Sr,Gl),Ht=e=>Ie(e,Cr,ql),M=e=>jr.test(e),mt=e=>Be(e,Er),Zl=e=>Be(e,Tr),co=e=>Be(e,vr),ec=e=>Be(e,Ar),tc=e=>Be(e,Sr),Bt=e=>Be(e,Cr,!0),nc=e=>Be(e,Mr,!0),Ie=(e,t,s)=>{const o=kr.exec(e);return o?o[1]?t(o[1]):s(o[2]):!1},Be=(e,t,s=!1)=>{const o=jr.exec(e);return o?o[1]?t(o[1]):s:!1},vr=e=>e==="position"||e==="percentage",Sr=e=>e==="image"||e==="url",Ar=e=>e==="length"||e==="size"||e==="bg-size",Er=e=>e==="length",sc=e=>e==="number",Tr=e=>e==="family-name",Mr=e=>e==="number"||e==="weight",Cr=e=>e==="shadow",uo=()=>{const e=K("color"),t=K("font"),s=K("text"),o=K("font-weight"),r=K("tracking"),a=K("leading"),i=K("breakpoint"),l=K("container"),d=K("spacing"),c=K("radius"),u=K("shadow"),f=K("inset-shadow"),h=K("text-shadow"),g=K("drop-shadow"),x=K("blur"),w=K("perspective"),m=K("aspect"),v=K("ease"),b=K("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],j=()=>[...N(),M,T],E=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],y=()=>[M,T,d],C=()=>[Ee,"full","auto",...y()],q=()=>[he,"none","subgrid",M,T],z=()=>["auto",{span:["full",he,M,T]},he,M,T],ee=()=>[he,"auto",M,T],$=()=>["auto","min","max","fr",M,T],W=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",...y()],se=()=>[Ee,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...y()],ut=()=>[l,Ee,"screen","full","dvw","lvw","svw","min","max","fit",...y()],ft=()=>[Ee,"screen","full","lh","dvh","lvh","svh","min","max","fit",...y()],I=()=>[e,M,T],H=()=>[...N(),co,lo,{position:[M,T]}],Oe=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ce=()=>["auto","cover","contain",ec,Yl,{size:[M,T]}],An=()=>[Tn,mt,Re],oe=()=>["","none","full",c,M,T],re=()=>["",_,mt,Re],Dt=()=>["solid","dashed","dotted","double"],Js=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],J=()=>[_,Tn,co,lo],Xs=()=>["","none",x,M,T],Ft=()=>["none",_,M,T],Ut=()=>["none",_,M,T],En=()=>[_,M,T],zt=()=>[Ee,"full",...y()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ve],breakpoint:[ve],color:[Nr],container:[ve],"drop-shadow":[ve],ease:["in","out","in-out"],font:[Kl],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ve],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ve],shadow:[ve],spacing:["px",_],text:[ve],"text-shadow":[ve],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ee,T,M,m]}],container:["container"],"container-type":[{"@container":["","normal","size",M,T]}],"container-named":[Vl],columns:[{columns:[_,"auto",T,M,l]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:j()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:C()}],"inset-x":[{"inset-x":C()}],"inset-y":[{"inset-y":C()}],start:[{"inset-s":C(),start:C()}],end:[{"inset-e":C(),end:C()}],"inset-bs":[{"inset-bs":C()}],"inset-be":[{"inset-be":C()}],top:[{top:C()}],right:[{right:C()}],bottom:[{bottom:C()}],left:[{left:C()}],visibility:["visible","invisible","collapse"],z:[{z:[he,"auto",M,T]}],basis:[{basis:[Ee,"full","auto",l,...y()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[_,Ee,"auto","initial","none",T]}],grow:[{grow:["",_,M,T]}],shrink:[{shrink:["",_,M,T]}],order:[{order:[he,"first","last","none",M,T]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:z()}],"col-start":[{"col-start":ee()}],"col-end":[{"col-end":ee()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:z()}],"row-start":[{"row-start":ee()}],"row-end":[{"row-end":ee()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":$()}],"auto-rows":[{"auto-rows":$()}],gap:[{gap:y()}],"gap-x":[{"gap-x":y()}],"gap-y":[{"gap-y":y()}],"justify-content":[{justify:[...W(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...W()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":W()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:y()}],px:[{px:y()}],py:[{py:y()}],ps:[{ps:y()}],pe:[{pe:y()}],pbs:[{pbs:y()}],pbe:[{pbe:y()}],pt:[{pt:y()}],pr:[{pr:y()}],pb:[{pb:y()}],pl:[{pl:y()}],m:[{m:L()}],mx:[{mx:L()}],my:[{my:L()}],ms:[{ms:L()}],me:[{me:L()}],mbs:[{mbs:L()}],mbe:[{mbe:L()}],mt:[{mt:L()}],mr:[{mr:L()}],mb:[{mb:L()}],ml:[{ml:L()}],"space-x":[{"space-x":y()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":y()}],"space-y-reverse":["space-y-reverse"],size:[{size:se()}],"inline-size":[{inline:["auto",...ut()]}],"min-inline-size":[{"min-inline":["auto",...ut()]}],"max-inline-size":[{"max-inline":["none",...ut()]}],"block-size":[{block:["auto",...ft()]}],"min-block-size":[{"min-block":["auto",...ft()]}],"max-block-size":[{"max-block":["none",...ft()]}],w:[{w:[l,"screen",...se()]}],"min-w":[{"min-w":[l,"screen","none",...se()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...se()]}],h:[{h:["screen","lh",...se()]}],"min-h":[{"min-h":["screen","lh","none",...se()]}],"max-h":[{"max-h":["screen","lh","none",...se()]}],"font-size":[{text:["base",s,mt,Re]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,nc,Jl]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Tn,T]}],"font-family":[{font:[Zl,Xl,t]}],"font-features":[{"font-features":[T]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,M,T]}],"line-clamp":[{"line-clamp":[_,"none",M,io]}],leading:[{leading:["none",a,...y()]}],"list-image":[{"list-image":["none",M,T]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",M,T]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Dt(),"wavy"]}],"text-decoration-thickness":[{decoration:[_,"from-font","auto",M,Re]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[_,"auto",M,T]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:y()}],"tab-size":[{tab:[he,M,T]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",M,T]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",M,T]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:Oe()}],"bg-size":[{bg:ce()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},he,M,T],radial:["",M,T],conic:["",he,M,T]},tc,Ql]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:An()}],"gradient-via-pos":[{via:An()}],"gradient-to-pos":[{to:An()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:re()}],"border-w-x":[{"border-x":re()}],"border-w-y":[{"border-y":re()}],"border-w-s":[{"border-s":re()}],"border-w-e":[{"border-e":re()}],"border-w-bs":[{"border-bs":re()}],"border-w-be":[{"border-be":re()}],"border-w-t":[{"border-t":re()}],"border-w-r":[{"border-r":re()}],"border-w-b":[{"border-b":re()}],"border-w-l":[{"border-l":re()}],"divide-x":[{"divide-x":re()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":re()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Dt(),"hidden","none"]}],"divide-style":[{divide:[...Dt(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...Dt(),"none","hidden"]}],"outline-offset":[{"outline-offset":[_,M,T]}],"outline-w":[{outline:["",_,mt,Re]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","inner","none",u,Bt,Ht]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",f,Bt,Ht]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[_,Re]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":re()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",h,Bt,Ht]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[_,M,T]}],"mix-blend":[{"mix-blend":[...Js(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Js()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[_]}],"mask-image-linear-from-pos":[{"mask-linear-from":J()}],"mask-image-linear-to-pos":[{"mask-linear-to":J()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":J()}],"mask-image-t-to-pos":[{"mask-t-to":J()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":J()}],"mask-image-r-to-pos":[{"mask-r-to":J()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":J()}],"mask-image-b-to-pos":[{"mask-b-to":J()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":J()}],"mask-image-l-to-pos":[{"mask-l-to":J()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":J()}],"mask-image-x-to-pos":[{"mask-x-to":J()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":J()}],"mask-image-y-to-pos":[{"mask-y-to":J()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[M,T]}],"mask-image-radial-from-pos":[{"mask-radial-from":J()}],"mask-image-radial-to-pos":[{"mask-radial-to":J()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[_]}],"mask-image-conic-from-pos":[{"mask-conic-from":J()}],"mask-image-conic-to-pos":[{"mask-conic-to":J()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:Oe()}],"mask-size":[{mask:ce()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",M,T]}],filter:[{filter:["","none",M,T]}],blur:[{blur:Xs()}],brightness:[{brightness:[_,M,T]}],contrast:[{contrast:[_,M,T]}],"drop-shadow":[{"drop-shadow":["","none",g,Bt,Ht]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",_,M,T]}],"hue-rotate":[{"hue-rotate":[_,M,T]}],invert:[{invert:["",_,M,T]}],saturate:[{saturate:[_,M,T]}],sepia:[{sepia:["",_,M,T]}],"backdrop-filter":[{"backdrop-filter":["","none",M,T]}],"backdrop-blur":[{"backdrop-blur":Xs()}],"backdrop-brightness":[{"backdrop-brightness":[_,M,T]}],"backdrop-contrast":[{"backdrop-contrast":[_,M,T]}],"backdrop-grayscale":[{"backdrop-grayscale":["",_,M,T]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[_,M,T]}],"backdrop-invert":[{"backdrop-invert":["",_,M,T]}],"backdrop-opacity":[{"backdrop-opacity":[_,M,T]}],"backdrop-saturate":[{"backdrop-saturate":[_,M,T]}],"backdrop-sepia":[{"backdrop-sepia":["",_,M,T]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":y()}],"border-spacing-x":[{"border-spacing-x":y()}],"border-spacing-y":[{"border-spacing-y":y()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",M,T]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[_,"initial",M,T]}],ease:[{ease:["linear","initial",v,M,T]}],delay:[{delay:[_,M,T]}],animate:[{animate:["none",b,M,T]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,M,T]}],"perspective-origin":[{"perspective-origin":j()}],rotate:[{rotate:Ft()}],"rotate-x":[{"rotate-x":Ft()}],"rotate-y":[{"rotate-y":Ft()}],"rotate-z":[{"rotate-z":Ft()}],scale:[{scale:Ut()}],"scale-x":[{"scale-x":Ut()}],"scale-y":[{"scale-y":Ut()}],"scale-z":[{"scale-z":Ut()}],"scale-3d":["scale-3d"],skew:[{skew:En()}],"skew-x":[{"skew-x":En()}],"skew-y":[{"skew-y":En()}],transform:[{transform:[M,T,"","none","gpu","cpu"]}],"transform-origin":[{origin:j()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:zt()}],"translate-x":[{"translate-x":zt()}],"translate-y":[{"translate-y":zt()}],"translate-z":[{"translate-z":zt()}],"translate-none":["translate-none"],zoom:[{zoom:[he,M,T]}],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",M,T]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":y()}],"scroll-mx":[{"scroll-mx":y()}],"scroll-my":[{"scroll-my":y()}],"scroll-ms":[{"scroll-ms":y()}],"scroll-me":[{"scroll-me":y()}],"scroll-mbs":[{"scroll-mbs":y()}],"scroll-mbe":[{"scroll-mbe":y()}],"scroll-mt":[{"scroll-mt":y()}],"scroll-mr":[{"scroll-mr":y()}],"scroll-mb":[{"scroll-mb":y()}],"scroll-ml":[{"scroll-ml":y()}],"scroll-p":[{"scroll-p":y()}],"scroll-px":[{"scroll-px":y()}],"scroll-py":[{"scroll-py":y()}],"scroll-ps":[{"scroll-ps":y()}],"scroll-pe":[{"scroll-pe":y()}],"scroll-pbs":[{"scroll-pbs":y()}],"scroll-pbe":[{"scroll-pbe":y()}],"scroll-pt":[{"scroll-pt":y()}],"scroll-pr":[{"scroll-pr":y()}],"scroll-pb":[{"scroll-pb":y()}],"scroll-pl":[{"scroll-pl":y()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",M,T]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[_,mt,Re,io]}],stroke:[{stroke:["none",...I()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},oc=(e,{cacheSize:t,prefix:s,experimentalParseClassName:o,extend:r={},override:a={}})=>(Ye(e,"cacheSize",t),Ye(e,"prefix",s),Ye(e,"experimentalParseClassName",o),qt(e.theme,a.theme),qt(e.classGroups,a.classGroups),qt(e.conflictingClassGroups,a.conflictingClassGroups),qt(e.conflictingClassGroupModifiers,a.conflictingClassGroupModifiers),Ye(e,"postfixLookupClassGroups",a.postfixLookupClassGroups),Ye(e,"orderSensitiveModifiers",a.orderSensitiveModifiers),Gt(e.theme,r.theme),Gt(e.classGroups,r.classGroups),Gt(e.conflictingClassGroups,r.conflictingClassGroups),Gt(e.conflictingClassGroupModifiers,r.conflictingClassGroupModifiers),Xn(e,r,"postfixLookupClassGroups"),Xn(e,r,"orderSensitiveModifiers"),e),Ye=(e,t,s)=>{s!==void 0&&(e[t]=s)},qt=(e,t)=>{if(t)for(const s in t)Ye(e,s,t[s])},Gt=(e,t)=>{if(t)for(const s in t)Xn(e,t,s)},Xn=(e,t,s)=>{const o=t[s];o!==void 0&&(e[s]=e[s]?e[s].concat(o):o)},rc=(e,...t)=>typeof e=="function"?ao(uo,e,...t):ao(()=>oc(uo(),e),...t),ac=["wait","name","stat","unit","wordmark","lead","title","row","body","fact","caption","micro"],ic=["window","rail","header","row","group","log-row","control","button","button-hero","mark","icon","track","label-col","bar-needs-you","bar-working","bar-idle","waited-name"],lc=rc({extend:{theme:{text:ac,spacing:ic,leading:["tight","body"],radius:["panel","chrome","inner","row","capsule","tube","bar"],shadow:["thumb","glow","edge"],"inset-shadow":["top","well","lit"],ease:["out"],animate:["lamp","spin-loader","rise-fast","fade-in","fade-out","drop"]}}});function A(...e){return lc(pr(e))}const cc=xr(["inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap","rounded-capsule text-body font-medium","transition-[background-color,color,filter] duration-120","disabled:pointer-events-none disabled:opacity-50"],{variants:{variant:{quiet:["bg-fill-quiet text-ink-secondary inset-ring inset-ring-control-rim inset-shadow-top","hover:bg-fill-selected hover:text-ink","focus-visible:bg-fill-selected focus-visible:text-ink"],"needs-you":["bg-status-needs-you font-semibold text-on-needs-you","inset-ring inset-ring-status-needs-you-edge inset-shadow-lit shadow-glow","hover:brightness-105 active:brightness-97"]},size:{sm:"h-button min-w-16 px-4",hero:"h-button-hero px-6.5 text-row",icon:"size-button"}},defaultVariants:{variant:"quiet",size:"sm"}});function F({className:e,variant:t,size:s,asChild:o=!1,...r}){const a=o?Vi:"button";return n.jsx(a,{"data-slot":"button","data-variant":t??"quiet",...o?{}:{type:"button"},className:A(cc({variant:t,size:s}),e),...r})}const dc=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function uc(e,t,s=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:dc(e),size:24,node:t,...s.length>0?{aliases:s}:{}}}const fc=e=>{let t="",s=!1;for(const o of e){if(o==="-"||o==="_"||o<=" "){s=t.length>0;continue}t.length===0?t+=o.toLowerCase():t+=s?o.toUpperCase():o,s=!1}return t};const mc=e=>{const t=fc(e);return t.charAt(0).toUpperCase()+t.slice(1)};const Qn=(...e)=>e.filter((t,s,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===s).join(" ").trim();const We={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function Mn(e){return e!=null}function hc(e,t={}){const s=t.attributeNames??{},o=h=>s[h]??h,r=e.size??e.width??We.width,a=e.size??e.height??We.height,i=e.aliases?.filter(h=>typeof h=="string"&&h.trim()!=="").map(h=>`lucide-${h}`)??[],l=[...e.name?[`lucide-${e.name}`]:[],...i],d=t.className?.split(" ").filter(Boolean)??[],c=t.includeDefaultClasses===!1?Qn(...d):Qn("lucide",...l,...d),u=t.absoluteStrokeWidth?Number(t.strokeWidth??We["stroke-width"])*Number(e.size??e.width??We.width)/Number(t.size??t.width??We.width):t.strokeWidth??We["stroke-width"];return["svg",{...Object.entries(We).reduce((h,[g,x])=>(h[o(g)]=x,h),{}),..."color"in t&&t.color&&{[o("stroke")]:t.color},..."size"in t&&Mn(t.size)&&{[o("width")]:t.size,[o("height")]:t.size},..."width"in t&&Mn(t.width)&&{[o("width")]:t.width},..."height"in t&&Mn(t.height)&&{[o("height")]:t.height},[o("stroke-width")]:u,...c&&{[o("class")]:c},[o("viewBox")]:`0 0 ${r} ${a}`,...t.hasA11yProp===!1?{[o("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},e.node.map(h=>{const[g,x,w]=h,m=t.nonScalingStroke?{[o("vector-effect")]:"non-scaling-stroke",...x}:x;return w?[g,m,w]:[g,m]})]}function pc(e,t={}){return hc(e,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}const xc=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},gc=p.createContext({}),wc=()=>p.useContext(gc),bc=p.forwardRef(({color:e,size:t,width:s,height:o,strokeWidth:r,absoluteStrokeWidth:a,nonScalingStroke:i,className:l="",children:d,iconNode:c=[],icon:u={node:c,aliases:[],size:24},...f},h)=>{const{size:g=24,strokeWidth:x=2,absoluteStrokeWidth:w=!1,nonScalingStroke:m=!1,color:v="currentColor",className:b=""}=wc()??{},k=!!d||xc(f),[N,j,E=[]]=pc(u,{color:e??v,width:s??t??g,height:o??t??g,strokeWidth:r??x,absoluteStrokeWidth:a??w,nonScalingStroke:i??m,className:Qn(b,l),hasA11yProp:k,attributes:f});return p.createElement(N,{ref:h,...j},[...E.map(([S,y])=>p.createElement(S,y)),...Array.isArray(d)?d:[d]])});function Ne(e,t=[],s=[]){const o=typeof e=="string"?uc(e,t,s):e,r=p.forwardRef(({className:a,...i},l)=>p.createElement(bc,{ref:l,icon:o,className:a,...i}));return o.name&&(r.displayName=mc(o.name)),r}const Ir={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};Ir.node;const yc=Ne(Ir);const $r={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};$r.node;const kc=Ne($r);const Lr={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};Lr.node;const jc=Ne(Lr);const _r={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};_r.node;const Nc=Ne(_r);const Or={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Or.node;const vc=Ne(Or);const Rr={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};Rr.node;const Sc=Ne(Rr);const Wr={name:"command",size:24,node:[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]};Wr.node;const Ac=Ne(Wr);const Pr={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};Pr.node;const Ec=Ne(Pr);const Dr={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Dr.node;const Fr=Ne(Dr);const Ur={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Ur.node;const Tc=Ne(Ur),Mc={info:{box:"bg-fill-quiet inset-ring inset-ring-hairline",icon:"text-ink-muted",Icon:Ec},error:{box:"bg-fill-selected inset-ring inset-ring-rule-strong shadow-edge",icon:"text-ink",Icon:Sc}};function G({tone:e="info",title:t,children:s,action:o,className:r}){const{box:a,icon:i,Icon:l}=Mc[e];return n.jsxs("div",{"data-slot":"callout","data-tone":e,role:e==="info"?"status":"alert",className:A("flex items-start gap-3 rounded-inner px-4 py-3",a,r),children:[n.jsx(l,{"aria-hidden":!0,className:A("mt-px size-4.5 shrink-0",i),strokeWidth:1.75}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-row font-semibold text-ink",children:t}),s&&n.jsx("div",{className:"mt-0.5 text-body wrap-break-word text-ink-secondary",children:s})]}),o&&n.jsx("div",{className:"shrink-0 self-center",children:o})]})}function Cc(e){const t=[];let s="";for(const o of e.match(/[^/\\]+[/\\]*|[/\\]+/g)??[])/[\p{L}\p{N}]/u.test(o)?(t.push(s+o),s=""):s+=o;return s!==""&&t.push(s),t}function qe({children:e,...t}){const s=[];return e.split(/(\s+)/).forEach((o,r)=>{if(o==="")return;if(/^\s+$/.test(o)){s.push(o);return}const a=Cc(o);a.forEach((i,l)=>{s.push(n.jsxs(p.Fragment,{children:[n.jsx("span",{"data-part":"word",className:"inline-block max-w-full wrap-anywhere",children:i}),l<a.length-1&&n.jsx("wbr",{})]},`${r}-${l}`))})}),n.jsx("span",{"data-slot":"literal",...t,children:s})}function $e({children:e,className:t}){return n.jsx("dl",{"data-slot":"fact-list",className:A("flex flex-col",t),children:e})}function X({label:e,children:t,mono:s=!1,note:o}){return n.jsxs("div",{"data-slot":"fact-row",className:A("items-baseline border-b border-hairline py-2.5 last:border-b-0",o===void 0?A("flex justify-between gap-x-6",s&&"flex-wrap gap-y-1"):"grid grid-cols-[auto_minmax(0,1fr)] gap-x-6"),children:[n.jsx("dt",{className:"shrink-0 text-body text-ink-secondary",children:e}),n.jsx("dd",{className:A("min-w-0 text-right text-pretty text-ink",s?"ml-auto font-mono text-fact":"text-body font-medium"),children:s&&typeof t=="string"?n.jsx(qe,{children:t}):t}),o!==void 0&&n.jsx("dd",{"data-part":"note",className:"col-span-2 mt-1 text-caption text-ink-secondary",children:o})]})}const Ic=["claude","gh"],$c=new RegExp([String.raw`\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b`,String.raw`\bPATH\b`,String.raw`(?<![\w.:/~])(?:~|\.{1,2})?(?:/[\w.@%+~-]+)+/?`,String.raw`\b[A-Za-z]:\\[^\s,;]+`,String.raw`\bgh auth login\b`,String.raw`\b(?:${Ic.join("|")})\b(?![\w-]|\.\w)(?:(?: [a-z][\w-]*)*(?: --?[a-z][\w-]*)+)?`,String.raw`(?<![\w-])--[a-z][\w-]*`].join("|"),"g"),Lc=/[.,;:!?]+$/;function _c(e){const t=[],s=(r,a)=>{if(r==="")return;const i=t[t.length-1];i&&i.fact===a?i.text+=r:t.push({text:r,fact:a})};let o=0;for(const r of e.matchAll($c)){const a=r.index,i=r[0].replace(Lc,"");i!==""&&(s(e.slice(o,a),!1),s(i,!0),o=a+i.length)}return s(e.slice(o),!1),t}function V({children:e}){return n.jsx(n.Fragment,{children:_c(e).map((t,s)=>t.fact?n.jsx("code",{"data-slot":"fact",className:"font-mono text-fact",children:n.jsx(qe,{children:t.text})},s):t.text)})}const Zn="remote:",Oc=24,Rc=new RegExp(`^[A-Za-z0-9][A-Za-z0-9-]{0,${Oc-1}}$`);function on(e){return typeof e=="string"&&Rc.test(e)}function fe(e){return e.startsWith(Zn)}function rt(e){if(!e.startsWith(Zn))return null;const t=e.slice(Zn.length),s=t.indexOf(":");if(s<0)return null;const o=t.slice(0,s);return on(o)?o:null}function It(e,t){return t==null?e:`${e} on ${t}`}const Wc=["terminal","vscode","desktop","cloud","browser","unknown"],Pc={terminal:"Terminal",vscode:"VS Code",desktop:"Desktop app",cloud:"Cloud",browser:"Browser"};function $t(e){return e==="unknown"?null:Pc[e]}const rn=["needs-you","working","idle","finished","failed","unknown"],Dc=["permission","question","other"],ws=["Terminal","iTerm2"],Fc=["signal","background"],Uc=["allow","deny"],zc=["edit","too-long","hidden-characters","not-yes-or-no","right-to-left","blank-lines"],Hc=["open","draft","merged","closed"],Bc=["failing","pending","passing","none"],qc=["ok","searching","unavailable","not-set-up","error"],zr={ok:"Watching",searching:"Searching",unavailable:"Not found","not-set-up":"Not set up",error:"Not working"},tt=["working-and-idle","needs-you","finished","failed","names","jump","quiet-for","stop","answer"],Hr={"working-and-idle":"Working and idle","needs-you":"Needs you",finished:"Finished",failed:"Failed",names:"Names",jump:"Jump","quiet-for":"Quiet for",stop:"Stop",answer:"Answer"},Xe={yes:"Yes",no:"No",partly:"Partly"},Gc=["appeared","status-changed","ended","stopped","answered"],Kc=["appeared","status-changed","ended"];function bs(e){return Kc.includes(e.kind)}const Vc=["agent-lookout"],Yc=["advisory","warning","critical"];function an(e){if(e.waitingText===void 0&&e.ask===void 0)return e;const{waitingText:t,ask:s,...o}=e;return o}function Jc(e,t){return e.agent??t.find(s=>s.id===e.source)?.label??null}const Xc=new Map;function Qc(e,t){return e===null?t:t===null?e:t>e?t:e}function Zc(e,t){const s=new Map;for(const i of t.sources)(i.state==="ok"||i.state==="not-set-up")&&s.set(i.id,new Map);const o=[],r=[];for(const i of t.sessions){if(i.status!=="needs-you")continue;const l=s.get(i.source);if(!l||l.has(i.id))continue;const d=e.get(i.source);if(!d?.has(i.id)){d&&o.push(i),l.set(i.id,i.statusSince);continue}const c=d.get(i.id)??null,u=i.statusSince;c!==null&&u!==null&&u>c&&(r.push(i.id),o.push(i)),l.set(i.id,Qc(c,u))}const a=new Map(e);for(const[i,l]of s){for(const d of e.get(i)?.keys()??[])l.has(d)||r.push(d);a.set(i,l)}return{memory:a,started:o,stopped:r}}const lt=["needs-you","finished","failed","ended"],es=["needs-you"];function ed(e){return lt.includes(e)}function td(e){const t=e.trim().toLowerCase();if(t==="")return[];const s=t.split(",").map(o=>o.trim());return s.every(ed)?lt.filter(o=>s.includes(o)):null}function At(e){return lt.filter(t=>e.includes(t)).join(",")}const fo={waits:Xc,seen:new Map,over:new Map};function Kt(e){return e==="finished"||e==="failed"}function nd(e,t){return t===void 0?!1:e==="ended"||t==="ended"||t===e}function sd(e,t){const s=Zc(e.waits,t),o=new Set(s.started),r=new Map;for(const u of t.sources)(u.state==="ok"||u.state==="not-set-up")&&r.set(u.id,{basis:u.basis??"",sessions:new Map});const a=[];for(const u of t.sessions){const f=r.get(u.source);if(!f||f.sessions.has(u.id))continue;if(f.sessions.set(u.id,an(u)),o.has(u)){a.push({event:"needs-you",session:u});continue}const h=e.seen.get(u.source)?.get(f.basis)?.get(u.id);h&&h.status!==u.status&&Kt(u.status)&&a.push({event:u.status,session:u})}for(const[u,{basis:f,sessions:h}]of r)for(const[g,x]of e.seen.get(u)?.get(f)??[])!h.has(g)&&!Kt(x.status)&&a.push({event:"ended",session:x});const i=new Map;for(const[u,{sessions:f}]of r){const h=new Map(e.over.get(u));for(const[g,x]of f)Kt(x.status)||h.delete(g);i.set(u,h)}const l=a.filter(({event:u,session:f})=>{const h=i.get(f.source);return u==="needs-you"||!h?!0:nd(u,h.get(f.id))?!1:(h.set(f.id,u),!0)}),d=new Map(e.seen),c=new Map(e.over);for(const[u,{basis:f,sessions:h}]of r){const g=new Map(e.seen.get(u));g.set(f,h),d.set(u,g);const x=i.get(u);for(const[w,m]of h)Kt(m.status)&&!x.has(w)&&x.set(w,m.status);for(const w of x.keys())[...g.values()].some(m=>m.has(w))||x.delete(w);c.set(u,x)}return{memory:{waits:s.memory,seen:d,over:c},changes:l,stopped:s.stopped}}const od=["started","cleared","trimmed"],rd="clear-history",ad=6e4,id=1e3,ld="stop",cd="clean-up",Br=1e4,Qe=20,dd=["ended","became-active","not-stale","gone","unsupported","cannot-confirm","not-allowed","still-running","failed"],ud="answer",fd="/api/settings",md="/api/settings/time-rules",hd="time-rules",Le="X-Agent-Lookout-Action",pd=200,xd="X-Agent-Lookout-Notifications";function qr(e){const t=At(e);return t===""?"off":t===At(es)?"on":`on; events=${t}`}const ln=20,gd=/^(?:[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*\.?|\[[0-9A-Fa-f:.]+\])$/,wd=253;function bd(e){return e.length<=wd&&gd.test(e)}const yd=["unknown","ready","not-found","signed-out"],kd=900*1e3;function ye(e){return e.since??{at:e.startedAt,by:"started"}}function Cn(){return typeof window>"u"?null:window.Notification??null}const Gr={permission(){const e=Cn();if(!e)return"unsupported";const{permission:t}=e;return t==="granted"||t==="denied"?t:"default"},requestPermission(){const e=Cn();return e?new Promise(t=>{const s=()=>t(Gr.permission());try{e.requestPermission(s)?.then(s,s)}catch{s()}}):Promise.resolve("unsupported")},show({title:e,body:t,tag:s}){const o=Cn();if(!o)return null;try{const r=new o(e,{body:t,tag:s});return r.addEventListener("click",()=>window.focus()),{close(){try{r.close()}catch{}},onClosed(a){r.addEventListener("close",a)}}}catch{return null}}};let jd=Gr;function ys(){return jd}const ks="agent-lookout-notifications",js="agent-lookout-notification-events";function Kr(){try{return localStorage.getItem(ks)==="on"?"on":"off"}catch{return"off"}}function Vr(){try{const e=localStorage.getItem(js);return(e===null?null:td(e))??es}catch{return es}}let Ze=null,De=null,Ge=null,ts=null,In=null;const xt=new Set;let yt=null;function Lt(){Ze??=Kr(),De??=Vr();const e=ys().permission();return(!Ge||Ge.choice!==Ze||Ge.permission!==e||Ge.events!==De)&&(Ge={choice:Ze,permission:e,on:Ze==="on"&&e==="granted",events:De}),Ge}function Ns(){const e=Lt();return e.on?e.events:[]}function Te(){const e=Lt();if(e!==ts){ts=e;for(const t of xt)t()}}function Yr(e){Ze=e;try{localStorage.setItem(ks,e)}catch{}}function Nd(){if(yt)return;const e=t=>{if((t.key===null||t.key===ks)&&(Ze=Kr()),t.key===null||t.key===js){const s=Vr();(De===null||At(s)!==At(De))&&(De=s)}Te()};window.addEventListener("storage",e),window.addEventListener("focus",Te),document.addEventListener("visibilitychange",Te),yt=()=>{window.removeEventListener("storage",e),window.removeEventListener("focus",Te),document.removeEventListener("visibilitychange",Te)}}function Jr(e){return xt.size===0&&(ts=Lt()),xt.add(e),Nd(),()=>{xt.delete(e),xt.size===0&&yt&&(yt(),yt=null)}}async function vd(){const e=ys();let t=e.permission();if(t==="default")try{t=await e.requestPermission()}catch{t=e.permission()}t==="granted"&&Yr("on"),Te()}function Sd(){return In??=vd().finally(()=>{In=null}),In}function Ad(){Yr("off"),Te()}function Ed(e,t){const s=Lt().events;if(s.includes(e)===t)return;const o=lt.filter(r=>r===e?t:s.includes(r));De=o;try{localStorage.setItem(js,At(o))}catch{}Te()}const Td=(e,t)=>fetch(e,t);let Md=Td;const mo="http://app.invalid";function Cd(e){if(!e.startsWith("/"))return!1;try{return new URL(e,mo).origin===mo}catch{return!1}}function Id(){return qr(Ns())}function Z(e,t){if(!Cd(e))return Promise.reject(new TypeError(`apiRequest takes a path on this app's own server, not ${JSON.stringify(e)}.`));const s=new Headers(t?.headers);return s.set(xd,Id()),Md(e,{...t,headers:s})}const Xr=(e,t)=>{const s=setInterval(e,t);return()=>clearInterval(s)},$d=1e4,Ld=5,_d=(e,t)=>{let s=null,o=null,r=!1,a=!1,i;const l=()=>{clearTimeout(i),s?.terminate(),s=null,!(r||o)&&(o=Xr(e,t))};try{s=new Worker(new URL("/assets/beatWorker-zHI4d3P9.js",import.meta.url),{type:"module"}),s.addEventListener("message",()=>{a=!0,e()}),s.addEventListener("error",l),s.postMessage(t),i=setTimeout(()=>{a||l()},Math.max($d,t*Ld))}catch{l()}return()=>{r=!0,clearTimeout(i),s?.terminate(),s=null,o?.(),o=null}},nt=6e4;function Ab(e,t){return e.map(s=>({at:s.at,value:s[t]}))}const Eb=[{id:"15m",label:"15 min",ms:15*nt,words:"the last 15 minutes"},{id:"1h",label:"1 hour",ms:60*nt,words:"the last hour"},{id:"6h",label:"6 hours",ms:360*nt,words:"the last 6 hours"}],Od=[1,2,5,10,20,25,50,100,200,250,500,1e3];function Rd(e){const t=Math.max(1,Math.ceil(e)),s=Od.find(a=>t/a<=4)??Math.ceil(t/4),o=Math.ceil(t/s)*s,r=[];for(let a=0;a<=o;a+=s)r.push(a);return{ceiling:o,ticks:r}}const Wd=[1,2,5,10,15,30,60,120,180,360];function Qr(e,t,s){const o=t-e;if(o<=0||s<1)return[];const r=(Wd.find(l=>o/(l*nt)<=s)??720)*nt,a=new Date(e).getTimezoneOffset()*nt,i=[];for(let l=Math.ceil((e-a)/r)*r+a;l<=t;l+=r)i.push(l);return i}function Pd(e,t){if(!t)return e;if(Zr(e,t))return t;const s=t.points[0];if(!s||t.startedAt!==e.startedAt)return e;const o=e.points.filter(r=>r.at<s.at);return{...t,startedAt:e.startedAt,points:[...o,...t.points]}}function Zr(e,t){const s=ye(t);return s.by==="cleared"&&s.at!==ye(e).at}const Dd=/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/,Fd=/^[A-Za-z0-9._-]{1,100}$/,Ud=1e9;function zd(e,t){return Dd.test(e)&&Fd.test(t)&&t!=="."&&t!==".."}function Hd(e){return typeof e=="number"&&Number.isInteger(e)&&e>0&&e<=Ud}const Bd=/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)$/;function qd(e,t){const s=Bd.exec(e);if(s===null)return!1;const[,o="",r="",a=""]=s;return zd(o,r)&&a===String(t)}function Gd(e){return e.failing>0?"failing":e.pending>0?"pending":e.passing>0?"passing":"none"}const Kd="\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069",Vd=new RegExp(`[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029${Kd}]`,"g"),pn=200,Yd=80;function Jd(e,t=Yd){const s=e.replace(Vd," ").replace(/\s+/g," ").trim(),o=Array.from(s);return o.length<=t?s:`${o.slice(0,t-1).join("").trimEnd()}…`}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R(e){return typeof e=="string"&&e.trim()!==""?e:null}function P(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function B(e,t){return e.includes(t)?t:null}function ns(e,t){const s=new Set,o=[];for(const r of e){const a=t(r);!a||s.has(a.id)||(s.add(a.id),o.push(a))}return o}function Xd(e){if(!O(e))return null;const t=R(e.id),s=R(e.source);if(!t||!s)return null;const o=R(e.project),r=B(rn,e.status)??"unknown",a=!on(e.machine),i={id:t,source:s,surface:B(Wc,e.surface)??"unknown",name:R(e.name)??o??t,cwd:R(e.cwd),project:o,status:r,startedAt:P(e.startedAt),statusSince:P(e.statusSince),links:{},stale:e.stale===!0};if(r==="needs-you"){const g=B(Dc,e.waitingReason);g&&(i.waitingReason=g);const x=R(e.waitingDetail);x&&(i.waitingDetail=x);const w=R(e.waitingText);w&&(i.waitingText=w);const m=a?Zd(e.ask):null;m&&(i.ask=m)}const l=R(e.agent);l&&(i.agent=l),on(e.machine)&&(i.machine=e.machine);const d=P(e.lastWriteAt);d!==null&&(i.lastWriteAt=d);const c=P(e.pid);if(c!==null&&(i.pid=c),typeof e.alive=="boolean"&&(i.alive=e.alive),O(e.links)){const g=R(e.links.open);g&&(i.links.open=g)}const u=a?uu(e.jump):null;u&&(i.jump=u);const f=a&&O(e.stop)?B(Fc,e.stop.how):null;f&&(i.stop={how:f});const h=ou(e.git);return h&&(i.git=h),i}const Qd=/^[0-9a-f]{32}$/,ea=8e3;function $n(e){return typeof e=="string"&&e!==""&&e.length<=ea?e:null}function Zd(e){if(!O(e))return null;const{requestId:t}=e,s=R(e.tool),o=P(e.until);if(typeof t!="string"||!Qd.test(t)||!s||s.length>200||o===null||typeof e.allow!="boolean")return null;const r={requestId:t,tool:s,allow:e.allow,until:o};if(e.command!==void 0){const a=$n(e.command);if(a===null)return null;r.command=a}if(e.description!==void 0){const a=$n(e.description);if(a===null)return null;r.description=a}if(e.inputs!==void 0){if(!Array.isArray(e.inputs)||e.inputs.length>30)return null;const a=[];for(const i of e.inputs){if(!O(i)||typeof i.value!="string"||i.value.length>ea)return null;const l=$n(i.name);if(l===null)return null;a.push({name:l,value:i.value})}r.inputs=a}if(!r.allow){const a=B(zc,e.denyOnly);a&&(r.denyOnly=a)}return e.subagent===!0&&(r.subagent=!0),r}function eu(e){if(!O(e))return null;const t=B(["on","off","unavailable"],e.state),s=B(["seen","missed","unknown"],e.plugin),o=P(e.holdMs);if(!t||!s||o===null)return null;const r={state:t,plugin:s,holdMs:o},a=R(e.problem);return a&&(r.problem=a),r}const tu=pn,nu=/^[0-9a-f]{7,64}$/,su=/^[0-9a-f]{16,64}$/;function ou(e){if(!O(e))return null;const t=lu(e);if(t===null)return null;const s=cu(e.repository),o=t.branch===void 0?null:iu(e.pullRequest);return{...t,...s!==null&&{repository:s},...o!==null&&{pullRequest:o}}}const ru=1e4;function Ln(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=ru?e:null}function au(e){if(!O(e))return null;const t=Ln(e.passing),s=Ln(e.failing),o=Ln(e.pending),r=B(Bc,e.state);if(t===null||s===null||o===null||r===null)return null;const a={passing:t,failing:s,pending:o};return Gd(a)===r?{state:r,...a}:null}function iu(e){if(!O(e))return null;const{number:t,url:s}=e;if(!Hd(t))return null;const o=R(e.title),r=B(Hc,e.state),a=au(e.checks);return o===null||Array.from(o).length>pn||r===null||a===null||typeof s!="string"||!qd(s,t)?null:{number:t,title:o,state:r,checks:a,url:s}}function lu(e){if(e.commit===void 0){const s=R(e.branch);return s!==null&&Array.from(s).length<=tu?{branch:s}:null}if(e.branch!==void 0)return null;const{commit:t}=e;return typeof t=="string"&&nu.test(t)?{commit:t}:null}function cu(e){if(!O(e))return null;const t=R(e.name);if(t===null||Array.from(t).length>pn)return null;const{id:s}=e;return typeof s=="string"&&su.test(s)?{id:s,name:t}:null}const du=200;function uu(e){if(!O(e))return null;const t=R(e.place);if(!t||t.length>du)return null;if(e.kind==="tmux")return{kind:"tmux",place:t};const s=e.kind==="terminal"?B(ws,e.app):null;return s?{kind:"terminal",app:s,place:t}:null}function fu(e,t){if(!O(e))return null;const s=R(e.id);if(!s)return null;const o={id:s,label:R(e.label)??s,state:B(qc,e.state)??"error",checkedAt:P(e.checkedAt)??t},r=R(e.detail);if(r&&(o.detail=r),Array.isArray(e.watching)){const d=[];for(const c of e.watching){const u=xu(c);u&&d.push(u)}o.watching=d}const a=R(e.advice);a&&(o.advice=a);const i=R(e.basis);i&&(o.basis=i);const l=ta(e.capabilities);if(l&&(o.capabilities=l),on(e.machine)&&(o.machine=e.machine),Array.isArray(e.agents)){const d=[];for(const c of e.agents.slice(0,mu)){const u=hu(c);u&&d.push(u)}d.length>0&&(o.agents=d)}return o}const mu=20;function hu(e){if(!O(e))return null;const t=R(e.label),s=ta(e.capabilities);return t&&s?{label:t,capabilities:s}:null}function pu(e){if(!O(e))return null;if(e.level==="yes")return{level:"yes"};const t=B(["no","partly"],e.level),s=R(e.reason);return t&&s?{level:t,reason:s}:null}function ta(e){if(!O(e))return null;const t={};for(const s of tt){const o=pu(e[s]);if(!o)return null;t[s]=o}return t}function xu(e){if(!O(e))return null;const t=R(e.label),s=R(e.value);return t&&s?{label:t,value:s}:null}function gu(e){if(!O(e)||!Array.isArray(e.sessions)||!Array.isArray(e.sources))return null;const t=P(e.generatedAt);if(t===null)return null;const s=eu(e.answering);return{generatedAt:t,sources:ns(e.sources,o=>fu(o,t)),sessions:ns(e.sessions,Xd),...s&&{answering:s},...e.timeRules!==void 0&&{timeRules:ps(e.timeRules).rules},...typeof e.quiet=="boolean"&&{quiet:e.quiet}}}function wu(e){if(!O(e))return null;const t=R(e.id),s=P(e.at),o=B(Gc,e.kind);if(!t||s===null||!o)return null;const r=R(e.sessionId)??"",a={id:t,at:s,sessionId:r,sessionName:R(e.sessionName)??(r||"A session"),kind:o,severity:B(Yc,e.severity)??"advisory"},i=B(rn,e.from);i&&(a.from=i);const l=B(rn,e.to);l&&(a.to=l);const d=B(Vc,e.by);d&&(a.by=d);const c=B(Uc,e.decision);return c&&(a.decision=c),a}function bu(e){return!O(e)||!Array.isArray(e.events)?null:ns(e.events,wu)}function yu(e){if(!O(e))return null;const t=P(e.at),s=P(e.needsYou),o=P(e.working),r=P(e.idle),a=P(e.total);return t===null||s===null||o===null||r===null||a===null?null:{at:t,needsYou:s,working:o,idle:r,total:a}}function na(e){if(!O(e))return null;const t=P(e.at),s=B(od,e.by);return t===null||s===null?null:{at:t,by:s}}const ku=1024;function ho(e){const t=R(e);return t&&t.length<=ku?t:null}function ge(e){const t=P(e);return t!==null&&t>=0&&Number.isInteger(t)?t:null}function ju(e){if(!O(e))return null;const t=B(["disk","memory"],e.where),s=ge(e.maxBytes),o=ge(e.maxAgeMs);if(t===null||s===null||o===null)return null;const r=t==="disk"?ho(e.folder):null;return t==="disk"&&r===null?null:{where:t,folder:r,bytes:t==="disk"?ge(e.bytes):null,maxBytes:s,maxAgeMs:o,canClear:t==="disk"&&e.canClear===!0,problem:ho(e.problem)}}const Nu=1e3;function vu(e){if(!O(e))return null;const t=P(e.at),s=P(e.lastBefore);return t===null||s===null||s>=t?null:{at:t,lastBefore:s}}function Su(e){if(!Array.isArray(e))return[];const t=[];for(const s of e.slice(0,Nu)){const o=vu(s);o&&t.push(o)}return t.sort((s,o)=>s.at-o.at)}function Au(e){if(!O(e)||!Array.isArray(e.points))return null;const t=P(e.startedAt);if(t===null)return null;const s=[];for(const i of e.points){const l=yu(i);l&&s.push(l)}const o=na(e.since),r=ju(e.kept),a=Su(e.restarts);return{points:s,startedAt:t,...o!==null&&{since:o},...r!==null&&{kept:r},...a.length>0&&{restarts:a}}}const po=50;function sa(e){const t=ge(e.waitedMs),s=ge(e.openMs),o=ge(e.waits),r=ge(e.measuredMs);return t===null||s===null||o===null||r===null?null:{waitedMs:t,openMs:Math.min(s,t),waits:o,measuredMs:r}}function Eu(e){if(!O(e))return null;const t=R(e.day),s=P(e.from),o=P(e.to),r=sa(e);return t===null||!/^\d{4}-\d{2}-\d{2}$/.test(t)||s===null||o===null?null:r&&o>=s?{day:t,from:s,to:o,...r}:null}function Tu(e){if(!O(e))return null;const t=R(e.sessionId),s=ge(e.waitedMs),o=ge(e.waits);if(t===null||s===null||o===null)return null;const r=R(e.name);return{sessionId:t,name:r!==null&&Array.from(r).length<=pn?r:t,waitedMs:s,waits:o,open:e.open===!0}}function xo(e){if(!O(e)||!Array.isArray(e.days)||!Array.isArray(e.sessions))return null;const t=P(e.from),s=P(e.to),o=sa(e),r=ge(e.sessionCount);if(t===null||s===null||s<t||o===null||r===null)return null;const a=[];for(const d of e.days.slice(0,po)){const c=Eu(d);c&&a.push(c)}const i=[],l=new Set;for(const d of e.sessions.slice(0,po)){const c=Tu(d);!c||l.has(c.sessionId)||(l.add(c.sessionId),i.push(c))}return{from:t,to:s,...o,days:a.sort((d,c)=>d.from-c.from),sessions:i.sort((d,c)=>c.waitedMs-d.waitedMs),sessionCount:Math.max(r,i.length)}}function Mu(e){if(!O(e))return null;const t=P(e.at),s=xo(e.today),o=xo(e.sevenDays),r=na(e.since),a=B(["disk","memory"],e.where);return t===null||!s||!o||!r||!a?null:{at:t,today:s,sevenDays:o,since:r,where:a}}const Cu=300;function ze(e){const t=R(e);return t&&t.length<=Cu?t:null}function oa(e,t){if(!O(e))return null;const s=P(e.at);return s===null?null:e.sent===!0?{at:s,sent:!0}:{at:s,sent:!1,reason:ze(e.reason)??t}}function ra(e){if(!Array.isArray(e))return null;const t=e.filter(o=>typeof o=="string"),s=lt.filter(o=>t.includes(o));return s.length>0?s:null}function Iu(e){if(!O(e)||typeof e.on!="boolean")return null;const t=ze(e.to),s=ra(e.events),o=P(e.afterMs),r=e.on&&t!==null&&s!==null&&o!==null&&o>=0;return{on:r,to:r?t:null,events:r?s:null,afterMs:r?o:null,asking:r?e.asking===!0:null,problem:r?null:ze(e.problem),last:r?oa(e.last,"the email could not be sent"):null,limitedUntil:r?P(e.limitedUntil):null}}function $u(e){if(!O(e))return null;const t=P(e.at);return t===null?null:e.ok===!0?{at:t,ok:!0}:{at:t,ok:!1,reason:ze(e.reason)??"gh did not answer"}}function Lu(e){if(!O(e)||typeof e.on!="boolean")return null;const t=B(yd,e.gh),s=e.on&&t!==null;return{on:s,problem:s?null:ze(e.problem),gh:s?t:null,last:s?$u(e.last):null}}function _u(e){if(!O(e)||typeof e.on!="boolean")return null;const t=ze(e.host),s=ra(e.events),o=P(e.afterMs),r=e.on&&t!==null&&bd(t)&&s!==null&&o!==null&&o>=0;return{on:r,host:r?t:null,events:r?s:null,afterMs:r?o:null,asking:r?e.asking===!0:null,problem:r?null:ze(e.problem),last:r?oa(e.last,"the post could not be sent"):null,limitedUntil:r?P(e.limitedUntil):null}}function Ou(e){if(!O(e)||!O(e.timeRules))return null;const t=R(e.file);return t===null?null:{timeRules:ps(e.timeRules).rules,file:t,problem:R(e.problem)}}const aa=2e3,Ru=4e3,go=5e3,wo=kd,bo=3600*1e3,Wu=60*1e3,xn=pd,Pu=2,Du={phase:"connecting",snapshot:null,events:[],history:null,lastOkAt:null,problem:null,problemKind:null};class Fe extends Error{kind;constructor(t,s){super(s),this.kind=t}}async function en(e){let t;try{t=await Z(e,{headers:{accept:"application/json"},signal:AbortSignal.timeout(Ru)})}catch(s){const o=s instanceof DOMException&&s.name==="TimeoutError";throw new Fe("no-answer",o?"The local server took too long to answer.":"The local server did not answer.")}if(!t.ok)throw new Fe("error-status",`The local server answered ${e} with error ${t.status}.`);try{return await t.json()}catch{throw new Fe("not-data",`The local server answered ${e} with something that is not data.`)}}function Fu(e){const t=gu(e);if(!t)throw new Fe("not-data","The local server sent session data in a shape this page cannot read.");return t}function Uu(e){const t=bu(e);if(!t)throw new Fe("not-data","The local server sent events in a shape this page cannot read.");return t}function ia(e){const t=Au(e);if(!t)throw new Fe("not-data","The local server sent history in a shape this page cannot read.");return t}function Tb(e){return en(`/api/history?windowMs=${Math.round(e)}`).then(ia)}function zu(e,t){if(t.length===0)return e;const s=new Set(e.map(r=>r.id)),o=t.filter(r=>!s.has(r.id));return o.length===0?e:[...o,...e].sort((r,a)=>a.at-r.at).slice(0,xn)}function Hu(e={}){const t=e.now??Date.now,s=e.intervalMs??aa,o=e.beat??Xr,r=new Set;let a=Du,i=null,l=!1,d=0,c=null;function u(x){a=x;for(const w of r)w()}async function f(){if(!l){l=!0;try{const x=a.events[0]?.at??0,w=t(),m=c===null||w-c>wo-go,[v,b,k]=await Promise.allSettled([en("/api/sessions").then(Fu),en(`/api/events?since=${x}`).then(Uu),en(`/api/history?windowMs=${m?bo:wo}`).then(ia)]);let N=a;if(k.status==="fulfilled"){const j=a.history!==null&&(a.history.startedAt!==k.value.startedAt||Zr(a.history,k.value));let E;m?(E=k.value,c=w):j||a.history===null?(E=k.value,c=null):(E=Pd(a.history,k.value),c=w);const S=t()-bo-Wu;N={...N,history:{...E,points:E.points.filter(y=>y.at>=S)},events:j?[]:N.events}}if(b.status==="fulfilled"&&(N={...N,events:zu(N.events,b.value)}),v.status==="fulfilled")d=0,N={...N,phase:"live",snapshot:v.value,lastOkAt:t(),problem:null,problemKind:null};else{d+=1;const j=v.reason,E=j instanceof Fe?j:null,S=E?.message??"The local server did not answer.",y=E?.kind??"no-answer";let C;N.snapshot!==null&&N.lastOkAt!==null?C=t()-N.lastOkAt>go?"stalled":N.phase:C=d>=Pu?"unreachable":"connecting",N={...N,phase:C,problem:S,problemKind:y}}u(N)}finally{l=!1}}}function h(){i===null&&(f(),i=o(()=>{f()},s))}function g(){i!==null&&(i(),i=null)}return{subscribe(x){return r.add(x),h(),()=>{r.delete(x),r.size===0&&g()}},getState:()=>a,refresh:()=>{f()}}}const ss=1e3,gt=60*ss,wt=60*gt,_n=24*wt;function kt(e){return String(e).padStart(2,"0")}function ct(e){const t=Math.max(0,Math.floor(e));return t<gt?[{value:String(Math.floor(t/ss)),unit:"s"}]:t<wt?[{value:String(Math.floor(t/gt)),unit:"m"},{value:kt(Math.floor(t%gt/ss)),unit:"s"}]:t<_n?[{value:String(Math.floor(t/wt)),unit:"h"},{value:kt(Math.floor(t%wt/gt)),unit:"m"}]:[{value:String(Math.floor(t/_n)),unit:"d"},{value:kt(Math.floor(t%_n/wt)),unit:"h"}]}function la(e){return e.map(t=>`${t.value}${t.unit}`).join(" ")}function Y(e){return la(ct(e))}const Bu={s:"second",m:"minute",h:"hour",d:"day"};function vs(e){return e.filter((s,o)=>o===0||Number(s.value)!==0).map(s=>{const o=Number(s.value);return`${o} ${Bu[s.unit]}${o===1?"":"s"}`}).join(" ")}function ke(e){return vs(ct(e))}function Q(e){const t=new Date(e);return`${kt(t.getHours())}:${kt(t.getMinutes())}`}function le(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}const qu=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}),Gu=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"});function Ss(e,t){return(new Date(e).getFullYear()===new Date(t).getFullYear()?qu:Gu).format(new Date(e))}function ue(e,t){const s=Q(e);return le(e)===le(t)?s:`${s} on ${Ss(e,t)}`}const Ku=1e3;function we(e){return e.charAt(0).toUpperCase()+e.slice(1)}function On(e){return String(e).padStart(2,"0")}function ca(e){const t=ct(e),s=t[0];return s&&(s.unit==="m"||s.unit==="d")?[s]:t}function Et(e){return la(ca(e))}function at(e){return vs(ca(e))}function As(e){return e<Ku?"just now":`${Y(e)} ago`}function me(e){const t=new Date(e);return`${On(t.getHours())}:${On(t.getMinutes())}:${On(t.getSeconds())}`}const Vu=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"});function Yu(e,t){const s=new Date(e),o=new Date(t);return s.getFullYear()===o.getFullYear()&&s.getMonth()===o.getMonth()&&s.getDate()===o.getDate()}function Es(e){return`${Vu.format(new Date(e))} ${me(e)}`}function da(e,t){return Yu(e,t)?me(e):Es(e)}const ua="status-files";function Ju(e){return e.id===ua?"status files":e.label}function ae(e){const t=e.map(Ju);return t.length===0?"your agent tools":t.length===1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function fa(e){return e.state!=="unavailable"&&e.state!=="not-set-up"}function Xu(e){const t=e.filter(o=>o.state!=="not-set-up"),s=t.filter(fa);return s.length>0?s:t}function ma(e,t=[]){const s=new Set;for(const o of e)fa(o)&&o.id!==ua&&!fe(o.id)&&s.add(o.label);for(const o of t)o.agent!==void 0&&s.add(o.agent);return s.size>1}function Ts(e,t){return Jc(e,t)??e.source}function ha(e){const t=e.filter(s=>fe(s.id));return{away:t.filter(s=>s.state==="unavailable"||s.state==="error"),connecting:t.filter(s=>s.state==="searching")}}function pa(e){const t=[];if(e.away.length>0){const s=e.away.length===1;t.push(`${ae(e.away)} ${s?"is":"are"} not connected, so ${s?"its":"their"} sessions are not known.`)}if(e.connecting.length>0){const s=e.connecting.length===1;t.push(`${ae(e.connecting)} ${s?"is":"are"} still connecting, so ${s?"its":"their"} sessions are not known yet.`)}return t.length>0?t.join(" "):null}const Qu=/^vscode:\/\/anthropic\.claude-code\/open\?session=[A-Za-z0-9\-_.!~*'()%]{1,200}$/,Ms={"needs-you":"Needs you",working:"Working",idle:"Idle",finished:"Finished",failed:"Failed",unknown:"Unknown"};function Zu(e){const t=e.waitingDetail?.trim();return!t||e.waitingReason==="permission"&&/^permission prompt$/i.test(t)||e.waitingReason==="question"&&/^input needed$/i.test(t)?null:t}const Tt="stopped waiting after",ef="was stopped from Agent Lookout",tf="had a request allowed from Agent Lookout",nf="had a request denied from Agent Lookout";function xa(e,t=null){if(e.kind==="appeared")return"appeared";if(e.kind==="ended")return"ended";if(e.kind==="stopped")return ef;if(e.kind==="answered")return e.decision==="deny"?nf:tf;if(e.from==="needs-you"&&e.to!=="needs-you"&&t!==null)return`${Tt} ${Y(t)}`;switch(e.to){case"needs-you":return"started waiting";case"working":return"started working";case"idle":return"went idle";case"finished":return"finished";case"failed":return"failed";default:return"changed status"}}const yo={"claude-code":Qu};function sf(e){const t=e.links.open;return typeof t!="string"?null:(Object.hasOwn(yo,e.source)?yo[e.source]:void 0)?.test(t)?t:null}function Ce(e){const t=sf(e);return t!==null?{by:"link",href:t,where:$t(e.surface)??"its app"}:e.jump?.kind==="tmux"?{by:"tmux",where:`tmux, ${e.jump.place}`}:e.jump?.kind==="terminal"?{by:"terminal",app:e.jump.app,where:e.jump.place}:null}const of={ok:"Last known: watching",searching:"Last known: searching",unavailable:"Last known: not found","not-set-up":"Last known: not set up",error:"Last known: not working"},rf={ok:"Connected",searching:"Connecting",unavailable:"Not connected","not-set-up":"Not set up",error:"Not connected"},af={ok:"Last known: connected",searching:"Last known: connecting",unavailable:"Last known: not connected","not-set-up":"Last known: not set up",error:"Last known: not connected"};function Cs(e){return Object.hasOwn(zr,e)?e:"error"}function lf(e,t){const s=Cs(e.state),r=fe(e.id)?t?af:rf:t?of:zr;return{key:e.id,name:e.label,state:r[s]}}const cf=[["vscode","VS Code"],["desktop","the desktop app"],["terminal","a terminal"],["cloud","the cloud"],["browser","a browser"],["unknown","another app"]];function df(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function uf(e){const t=new Set(e.map(s=>s.surface));return t.size===1&&t.has("unknown")?"":df(cf.filter(([s])=>t.has(s)).map(([,s])=>s))}function Pe(e,t){return e.filter(s=>Cs(s.state)===t)}function ff(e,t,s,o=null){if(e==="connecting")return{key:"connecting",text:"Connecting to the local server",short:"Connecting",fact:null};if(e==="unreachable")return{key:"not-connected",text:"Not connected to the local server",short:"Not connected",fact:null};if(e==="stalled")return{key:"not-updating",text:"Not updating",short:"Not updating",fact:o===null?null:{text:`since ${me(o)}`,ticking:!1}};const r=(t?.sources??[]).filter(k=>k.state!=="not-set-up"),a=t?.sessions??[];if(r.length===0)return{key:"no-sources",text:"Not watching any agent tool",short:"Not watching",fact:null};const i=Math.max(...r.map(k=>k.checkedAt)),l={text:`checked ${As(s-i)}`,ticking:!0},d=r.filter(k=>!fe(k.id)),c=r.filter(k=>fe(k.id)),u=Pe(c,"ok"),f=Pe(c,"searching"),h=c.filter(k=>{const N=Cs(k.state);return N==="unavailable"||N==="error"}),g=u.length>0?`${ae(u)} over SSH`:"",x=k=>{if(h.length===0)return{...k,fact:l};const N=`${ae(h)} not connected`;return{...k,text:`${k.text} · ${N}`,short:`${k.short} · ${N}`,fact:l}};if(a.length>0){const k=`${a.length} ${a.length===1?"session":"sessions"}`,N=Pe(d,"ok"),j=uf(a),E=N.length>1||N.length===1&&g?`from ${ae(N)}`:j&&!g?`in ${j}`:"",S=g?`from ${g}`:"",y=[E,S].filter(Boolean).join(", and ");return x({key:"watching",text:`Watching ${k}${y?` ${y}`:""}`,short:k})}const w=Pe(d,"searching");if(w.length>0||f.length>0){const k=w.length>0?`Looking for ${ae(w)} sessions`:"",N=f.length>0?`connecting to ${ae(f)} over SSH`:"";return x({key:"searching",text:k?[k,N].filter(Boolean).join(", and "):we(N),short:k?"Looking for sessions":"Connecting over SSH"})}const m=Pe(d,"ok");if(m.length>0||u.length>0){const k=[m.length>0?ae(m):"",g].filter(Boolean).join(", and ");return x({key:"none-running",text:`Watching ${k}, no sessions running`,short:"No sessions"})}const v=Pe(d,"error");if(v.length>0)return x({key:"not-working",text:`${we(ae(v))} could not be read`,short:v.length===1?"Source not working":"Sources not working"});const b=Pe(d,"unavailable");if(b.length===0){const k=h.length===1;return{key:"not-found",text:`${ae(h)} ${k?"is":"are"} not connected`,short:`${ae(h)} not connected`,fact:l}}return x({key:"not-found",text:`${we(ae(b))} ${b.length===1?"was":"were"} not found`,short:b.length===1?"Source not found":"Sources not found"})}function ga(e){switch(e){case"error-status":return"Agent Lookout answered with an error";case"not-data":return"The answer was not session data";default:return"Agent Lookout is not answering"}}const mf=aa/1e3;function hf({lastOkAt:e,now:t,onRetry:s}){return n.jsx(G,{tone:"error",title:"Agent Lookout has stopped updating",action:n.jsx(F,{size:"sm",onClick:s,children:"Try now"}),children:n.jsxs("p",{children:["This is what it last saw, at"," ",n.jsxs("span",{className:"tabular-nums",children:[me(e),n.jsxs("span",{"data-part":"age","aria-hidden":!0,"aria-live":"off",children:[" ","(",As(t-e),")"]})]}),". Check that it is still running in your terminal. The page keeps trying and catches up on its own."]})})}const ko="font-mono text-fact";function wa({kind:e}){return e==="error-status"?n.jsx("p",{children:"Its local server is running. Restart Agent Lookout in your terminal, and open the address it prints."}):e==="not-data"?n.jsxs("p",{children:["This page is being served without its collector. Start Agent Lookout with"," ",n.jsx("code",{className:ko,children:"npm start"})," or ",n.jsx("code",{className:ko,children:"npm run dev"}),", and open the address it prints."]}):n.jsx("p",{children:"Check that Agent Lookout is still running in your terminal."})}function pf({problem:e,kind:t,onRetry:s}){return n.jsxs("section",{"data-slot":"unreachable","data-kind":t??"no-answer","aria-label":"Connection problem",className:"glass-card mx-auto mt-10 w-full max-w-155 p-6 max-mid:p-5",children:[n.jsx(G,{tone:"error",title:ga(t),action:n.jsx(F,{size:"sm",onClick:s,children:"Try now"}),children:n.jsx(wa,{kind:t})}),n.jsxs($e,{className:"mt-3",children:[n.jsx(X,{label:"What happened",children:n.jsx(V,{children:e??"The local server did not answer."})}),n.jsx(X,{label:"Asked for",mono:!0,children:"/api/sessions"}),n.jsx(X,{label:"Trying again",children:n.jsxs("span",{className:"tabular-nums",children:["every ",mf,"s"]})})]})]})}const xf=xr("inline-flex h-5 shrink-0 items-center rounded-capsule px-2 text-caption font-medium whitespace-nowrap",{variants:{tone:{neutral:"bg-fill-quiet text-ink-secondary inset-ring inset-ring-control-rim",outline:"text-ink-secondary inset-ring inset-ring-rule-strong"}},defaultVariants:{tone:"neutral"}});function dt({className:e,tone:t,...s}){return n.jsx("span",{"data-slot":"badge","data-tone":t??"neutral",className:A(xf({tone:t}),e),...s})}function Mt({session:e,className:t}){return e.machine===void 0?null:n.jsxs(dt,{"data-part":"machine",className:t,children:[n.jsx("span",{className:"sr-only",children:"on "}),e.machine]})}function gn({machine:e,className:t}){return e===null?null:n.jsxs("span",{"data-part":"machine",className:A("font-normal",t),children:[" ","on ",e]})}function _t({title:e,children:t,visual:s,compact:o=!1,className:r}){return n.jsxs("div",{"data-slot":"empty-state",className:A("flex flex-col items-center text-center",o?"px-5 py-8":"px-5 py-14",r),children:[s&&n.jsx("div",{className:"mb-4",children:s}),n.jsx("p",{className:"text-title font-semibold text-ink",children:e}),t&&n.jsx("div",{className:"mt-1.5 max-w-[52ch] text-body text-ink-secondary",children:t})]})}function U({title:e,count:t,sub:s,aside:o,titleRef:r,className:a,children:i,...l}){const d=p.useId();return n.jsxs("section",{"data-slot":"section-card","aria-labelledby":d,className:A("glass-card flex min-w-0 flex-col overflow-hidden",a),...l,children:[n.jsxs("header",{"data-part":"head",className:"flex items-baseline justify-between gap-x-4 gap-y-2 px-6 pt-5 pb-3 max-wide:flex-wrap",children:[n.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[n.jsx("h2",{ref:r,id:d,tabIndex:r?-1:void 0,className:"text-title font-semibold outline-none",children:e}),t!==void 0&&n.jsx("span",{"data-part":"count",className:"-ml-0.5 text-title font-medium text-ink-muted tabular-nums",children:t}),s!==void 0&&n.jsx("span",{"data-part":"sub",className:"text-caption text-ink-muted",children:s})]}),o!==void 0&&n.jsx("div",{"data-part":"aside",className:"min-w-0 text-caption text-ink-muted",children:o})]}),i]})}const gf={...Ms,stale:"Stale",answered:"Needed you, answered",ended:"Ended",lookout:"Agent Lookout"},wf={"needs-you":"text-status-needs-you-edge",working:"text-status-working",idle:"text-status-idle",stale:"text-status-idle",unknown:"text-status-idle",answered:"text-status-idle",lookout:"text-status-idle",finished:"text-status-finished",failed:"text-status-finished",ended:"text-ink-muted"};function te({kind:e,labelled:t=!1,breathing:s=!1,unlit:o=!1,className:r}){const a=e==="needs-you",i=a&&!o;return n.jsxs("svg",{"data-slot":"status-mark","data-kind":e,"data-lit":a?i:void 0,"data-breathing":i&&s?!0:void 0,viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",className:A("size-mark shrink-0",a&&o?"text-ink":wf[e],r),...t?{role:"img","aria-label":gf[e]}:{"aria-hidden":!0},children:[(a||e==="answered")&&n.jsxs(n.Fragment,{children:[n.jsx("circle",{"data-part":"halo",cx:"7",cy:"7",r:"6",strokeWidth:"1.2",strokeOpacity:"0.5",className:A(i&&s&&"motion-safe:animate-lamp")}),n.jsx("circle",{"data-part":"lamp",cx:"7",cy:"7",r:"3.1",strokeWidth:i?1:1.3,className:A(i&&"fill-status-needs-you")})]}),e==="working"&&n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7",cy:"7",r:"5",strokeWidth:"1.5"}),n.jsx("path",{d:"M7 2a5 5 0 0 1 0 10z",fill:"currentColor",stroke:"none"})]}),e==="idle"&&n.jsx("circle",{cx:"7",cy:"7",r:"5",strokeWidth:"1.5"}),e==="stale"&&n.jsx("circle",{cx:"7",cy:"7",r:"5",strokeWidth:"1.5",strokeDasharray:"2.62 2.62"}),e==="unknown"&&n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7",cy:"7",r:"5",strokeWidth:"1.5"}),n.jsx("path",{d:"M5 7h4",strokeWidth:"1.5",strokeLinecap:"round"})]}),e==="finished"&&n.jsx("path",{d:"M2.6 7.5l2.9 2.9 5.9-6.4",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),e==="failed"&&n.jsx("path",{d:"M3.8 3.8l6.4 6.4M10.2 3.8l-6.4 6.4",strokeWidth:"1.75",strokeLinecap:"round"}),e==="ended"&&n.jsx("path",{d:"M3.5 7h7",strokeWidth:"1.75",strokeLinecap:"round"}),e==="lookout"&&n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.5",y:"2.5",width:"9",height:"9",rx:"1.5",strokeWidth:"1.3"}),n.jsx("path",{d:"M5 11.2l6.2-6.2M2.8 9l6.2-6.2",strokeWidth:"1.1"})]})]})}const bf=250,yf=250;let os=!1;typeof window<"u"&&window.addEventListener("scroll",()=>{os=!0,setTimeout(()=>{os=!1})},{capture:!0,passive:!0});function ne({content:e,children:t,mono:s=!1,enabled:o=!0,side:r="top",align:a="center"}){const[i,l]=p.useState(!1),d=p.useRef(-1/0),c=o&&e!==null&&e!==void 0&&e!=="";return n.jsx(Yi,{delayDuration:bf,children:n.jsxs(Ji,{open:i&&c,onOpenChange:u=>{const f=os&&performance.now()-d.current<yf;!u&&f||l(u)},children:[n.jsx(Xi,{asChild:!0,onFocus:u=>{if(!u.currentTarget.matches(":focus-visible")){u.preventDefault();return}d.current=performance.now()},onBlur:()=>{d.current=-1/0},children:t}),n.jsx(Qi,{children:n.jsx(Zi,{"data-slot":"tooltip",side:r,align:a,sideOffset:6,collisionPadding:12,className:A("glass-float glass-blur z-60 max-w-[min(26rem,calc(100vw-1.5rem))] animate-in rounded-row","px-2.5 py-1.5 wrap-anywhere text-ink duration-120 fade-in-0",s?"font-mono text-fact":"text-caption font-medium"),children:s&&typeof e=="string"?n.jsx(qe,{children:e}):e})})]})})}function kf(e,t){if(e.scrollWidth>e.clientWidth)return!0;if(t===1)return!1;const s=Number.parseFloat(getComputedStyle(e).lineHeight),o=Number.isFinite(s)?s/2:1;return e.scrollHeight-e.clientHeight>o}function ie({children:e,lines:t=1,tooltip:s,mono:o=!1,href:r,target:a,className:i,...l}){const d=p.useRef(null),[c,u]=p.useState(!1),f=s??(typeof e=="string"?e:"");p.useEffect(()=>{const g=d.current;if(!g)return;const x=new ResizeObserver(()=>u(kf(g,t)));return x.observe(g),()=>x.disconnect()},[f,t]);const h=A(t===1?"truncate":"line-clamp-2","rounded-bar",i);return n.jsx(ne,{content:f,enabled:c,mono:o,children:r!==void 0?n.jsx("a",{ref:d,href:r,target:a,"data-cut":c,className:h,...l,children:e}):n.jsx("span",{ref:d,"data-cut":c,tabIndex:c?0:void 0,className:h,...l,children:e})})}const jf=8e3,jo=.75,Ot=jf;function Ke(e){return Math.round(e*100)/100}function Mb(e,t,s){const{start:o,end:r}=t,a=t.gapMs??Ot,i=r-o,l=s.right-s.left,d=e.filter(j=>j.at>=o&&j.at<=r&&Number.isFinite(j.value)).sort((j,E)=>j.at-E.at);if(i<=0||d.length===0)return{lines:[],areas:[],unmeasured:[{x:s.left,width:l}],range:null,runs:[]};let c=1/0,u=-1/0;for(const j of d)j.value<c&&(c=j.value),j.value>u&&(u=j.value);const f=Math.max(1,s.ceiling??u),h=j=>Ke(s.left+(j-o)/i*l),g=j=>Ke(s.bottom-Math.min(j,f)/f*(s.bottom-s.top)),x=[];for(const j of d){const E=x[x.length-1],S=E?.[E.length-1];E&&S&&j.at-S.at<=a?E.push(j):x.push([j])}const w=[],m=[],v=[],b=[];x.forEach((j,E)=>{const S=j[0],y=j[j.length-1];if(!S||!y)return;const C=E===0&&S.at-o<=a?o:S.at,q=E===x.length-1&&r-y.at<=a?r:y.at,z=h(C),ee=h(q);let $=`M${z} ${g(S.value)}`,W=S.value;for(const D of j)D.value!==W&&($+=`H${h(D.at)}V${g(D.value)}`,W=D.value);$+=`H${ee}`,w.push($),m.push(`${$}V${s.bottom}H${z}Z`),v.push({x:z,width:ee-z}),b.push({from:C,to:q,samples:j})});const k=[];let N=s.left;for(const j of v)j.x-N>=jo&&k.push({x:Ke(N),width:Ke(j.x-N)}),N=Math.max(N,j.x+j.width);return s.right-N>=jo&&k.push({x:Ke(N),width:Ke(s.right-N)}),{lines:w,areas:m,unmeasured:k,range:{min:c,max:u},runs:b}}function Cb(e,t){for(const s of e){if(t<s.from||t>s.to)continue;let o=0,r=s.samples.length-1;for(;o<r;){const a=Math.ceil((o+r)/2);s.samples[a].at<=t?o=a:r=a-1}return s.samples[o]??null}return null}function Nf(e,t){const s=new Set(t.filter(i=>i.status==="needs-you").map(i=>i.id)),o=new Set,r=new Map,a=new Map;for(let i=e.length-1;i>=0;i-=1){const l=e[i];if(!l||!bs(l))continue;const d=r.get(l.sessionId);d&&a.set(l,d),r.set(l.sessionId,l)}return e.map(i=>{const l=!o.has(i.sessionId);if(o.add(i.sessionId),i.to==="needs-you"){const f=l&&s.has(i.sessionId);return{event:i,mark:f?"needs-you":"answered",open:f,waitedMs:null}}if(i.kind==="stopped")return{event:i,mark:"ended",open:!1,waitedMs:null};if(i.kind==="answered")return{event:i,mark:"answered",open:!1,waitedMs:null};const d=a.get(i),c=i.from==="needs-you"&&d?.to==="needs-you"?i.at-d.at:null,u=i.to??(i.kind==="ended"?"ended":"unknown");return{event:i,mark:u,open:!1,waitedMs:c}})}function vf(e,t,s){if(s){const r=e[e.length-1];return r?{at:r.at,started:!1}:null}if(!t)return null;const o=ye(t);return o.by==="trimmed"?{at:o.at,started:!1}:o.by==="cleared"?{at:o.at,started:!0,cleared:!0}:{at:o.at,started:!0}}function Sf(e,t=Ot){if(!e)return[];const s=ye(e).at,o=(e.points??[]).map(a=>a.at).filter(a=>a>=s).sort((a,i)=>a-i),r=[];o.forEach((a,i)=>{const l=o[i-1];l!==void 0&&a-l>t&&r.push({at:a,unmeasuredMs:a-l,before:l})});for(const a of e.restarts??[])a.at<=s||r.some(l=>l.before<a.at&&a.at<=l.at)||r.push({at:a.at,unmeasuredMs:a.at-a.lastBefore,before:a.lastBefore});return r.sort((a,i)=>i.at-a.at).map(({at:a,unmeasuredMs:i})=>({at:a,unmeasuredMs:i}))}function Af(e,t){const s=[];let o=0;for(const r of e){for(;o<t.length&&t[o].at>r.event.at;)s.push({kind:"resumed",gap:t[o]}),o+=1;s.push({kind:"event",entry:r})}for(;o<t.length;o+=1)s.push({kind:"resumed",gap:t[o]});return s}const Ef=1e4;function Tf(e){return{away:!0,overview:!1,leftAt:e,since:null,inViewFrom:null}}function Mf(e,t){const s=!e.away&&e.overview,o=t.visible&&t.overview;let{leftAt:r,since:a,inViewFrom:i}=e;if(e.away&&t.visible){const c=a??r;a=c!==null&&t.newestAt!==null&&t.newestAt>c?c:null,i=null}else e.overview&&!t.overview&&t.visible&&(a=null);s&&!o&&(r=Math.max(t.now,t.newestAt??t.now)),a!==null&&(t.newestAt===null||t.newestAt<=a)&&(a=null),a!==null&&o&&t.lineInView?(i??=t.now,t.now-i>=Ef&&(a=null)):i=null,a===null&&(i=null);const l=!t.visible,d=t.overview;return l===e.away&&d===e.overview&&r===e.leftAt&&a===e.since&&i===e.inViewFrom?e:{away:l,overview:d,leftAt:r,since:a,inViewFrom:i}}function Cf(e,t){if(t===null)return 0;let s=0;for(;s<e.length&&e[s].at>t;)s+=1;return s}const wn="w-16 shrink-0 self-center font-mono text-caption whitespace-nowrap";function No({kind:e,side:t}){return n.jsx("span",{"aria-hidden":!0,"data-part":"thread","data-kind":e,className:A("absolute left-1/2 -translate-x-1/2",t==="above"?"top-0 bottom-1/2 mb-2.5":"top-1/2 bottom-0 mt-2.5",e==="line"?"w-px bg-rule":"w-0 border-l border-dotted border-ink-muted opacity-70")})}function Is({thread:e,children:t}){return n.jsxs("span",{className:"relative flex w-mark shrink-0 items-center justify-center",children:[e.above&&n.jsx(No,{kind:e.above,side:"above"}),t,e.below&&n.jsx(No,{kind:e.below,side:"below"})]})}function cn({at:e,mark:t,thread:s,lit:o=!1,className:r,children:a,...i}){return n.jsxs("li",{...i,"data-lit":o||void 0,className:A("flex min-h-log-row shrink-0 items-stretch gap-3.5 px-6 text-body",o?"text-ink":"text-ink-secondary",r),children:[n.jsx(ne,{content:Es(e),mono:!0,align:"start",children:n.jsx("time",{dateTime:new Date(e).toISOString(),className:A(wn,"rounded-bar",o?"text-ink-secondary":"text-ink-muted"),children:me(e)})}),n.jsx(Is,{thread:s,children:t}),n.jsx("div",{className:"flex min-w-0 flex-1 items-baseline gap-x-1 self-center py-2 max-mid:flex-wrap",children:a})]})}const If=p.memo(function({event:t,mark:s,open:o,waitedMs:r,above:a,below:i}){const l=xa(t,r),d=rt(t.sessionId),c=It(t.sessionName,d);return n.jsxs(cn,{"data-slot":"event-row",at:t.at,lit:o,thread:{above:a,below:i},mark:n.jsx(te,{kind:s,labelled:!0}),children:[n.jsx(ie,{"data-part":"name",tooltip:`${c} ${l}`,className:"font-semibold text-ink",children:t.sessionName}),n.jsx(gn,{machine:d,className:"shrink-0 whitespace-nowrap"}),n.jsx("span",{"data-part":"phrase",className:"max-w-full shrink-0",children:r!==null&&l.startsWith(Tt)?n.jsxs(n.Fragment,{children:[Tt," ",n.jsx("span",{className:"whitespace-nowrap tabular-nums",children:Y(r)})]}):l})]})});function vo(e){return e.charAt(0).toUpperCase()+e.slice(1)}const $f=6;function Ib({entries:e,now:t,className:s}){const o=[];let r=le(t);for(const i of e){const l=le(i.event.at);l!==r&&(r=l,o.push({kind:"day",day:r})),o.push({kind:"event",entry:i})}const a=e.length>$f;return n.jsx("ol",{"data-slot":"own-events","aria-label":"Its events, newest first",tabIndex:a?0:void 0,className:A("thin-scroll flex flex-col",a&&"max-h-57 overflow-y-auto focus-visible:-outline-offset-2",s),children:o.map((i,l)=>{const d={above:l===0?null:"line",below:l===o.length-1?null:"line"};if(i.kind==="day")return n.jsx(ba,{day:i.day,now:t,thread:d,className:"px-0"},`day-${i.day}`);const{entry:c}=i,u=xa(c.event,c.waitedMs);return n.jsx(cn,{"data-slot":"event-row",at:c.event.at,lit:c.open,thread:d,mark:n.jsx(te,{kind:c.mark,labelled:!0}),className:"px-0",children:n.jsx("span",{"data-part":"phrase",children:c.waitedMs!==null&&u.startsWith(Tt)?n.jsxs(n.Fragment,{children:[vo(Tt)," ",n.jsx("span",{className:"whitespace-nowrap tabular-nums",children:Y(c.waitedMs)})]}):vo(u)})},c.event.id)})})}function ba({day:e,now:t,thread:s,className:o}){return n.jsxs("li",{"data-slot":"event-day",className:A("flex shrink-0 items-stretch gap-3.5 px-6",o),children:[n.jsx("span",{className:A(wn,"pt-3 pb-1 font-medium text-ink-muted"),children:Ss(e,t)}),n.jsx(Is,{thread:s})]})}function Lf({since:e,now:t,thread:s,ref:o}){const r=me(e),a=le(e)===le(t)?r:`${Ss(e,t)} ${r}`;return n.jsxs("li",{ref:o,"data-slot":"event-new",className:"flex shrink-0 items-stretch gap-3.5 px-6",children:[n.jsx("span",{"aria-hidden":!0,className:wn}),n.jsx(Is,{thread:s}),n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3 py-2",children:[n.jsxs("span",{"data-part":"words",className:"min-w-0 text-caption font-medium text-ink-muted",children:["New since"," ",n.jsx("time",{dateTime:new Date(e).toISOString(),className:"whitespace-nowrap tabular-nums",children:a})]}),n.jsx("span",{"aria-hidden":!0,"data-part":"rule",className:"h-px min-w-4 flex-1 bg-rule max-mid:hidden"})]})]})}function _f(e,t,s){const[o,r]=p.useState(null);return p.useLayoutEffect(()=>{const a=e.current,i=t.current;if(!a||!i)return;const l=()=>{const c=getComputedStyle(i),u=c.position==="absolute"?a.getBoundingClientRect().height:Number.parseFloat(c.maxHeight);let f=null;if(Number.isFinite(u)&&i.scrollHeight>u+.5){const h=u-Number.parseFloat(c.paddingBottom||"0"),g=i.getBoundingClientRect().top-i.scrollTop;for(const x of i.children){const w=x.getBoundingClientRect().bottom-g;if(w>h+.01)break;f=w}}r(f)};l();const d=new ResizeObserver(l);return d.observe(a),()=>d.disconnect()},[e,t,s]),o}function Of(e,t){const s=p.useRef(null);return p.useEffect(()=>{const o=s.current;if(!e||!o||!t)return;const r=new IntersectionObserver(a=>{const i=a.at(-1);i&&t(i.isIntersecting&&i.intersectionRatio>=.5)},{threshold:[0,.5,1]});return r.observe(o),()=>{r.disconnect(),t(!1)}},[e,t]),s}function Rf({events:e,sessions:t=[],history:s=null,now:o,newSince:r=null,onNewLineInView:a,className:i}){const l=le(o),d=vf(e,s,e.length>=xn),c=Sf(s).filter(y=>!d||y.at>=d.at),u=Cf(e,r),f=[];let h=u>0?r:null,g=l;const x=y=>{h!==null&&y<=h&&(f.push({kind:"new",key:"new",since:h}),h=null);const C=le(y);C!==g&&(g=C,f.push({kind:"day",key:`day-${g}`,day:g}))};for(const y of Af(Nf(e,t),c))y.kind==="event"?(x(y.entry.event.at),f.push({kind:"event",key:y.entry.event.id,...y.entry})):(x(y.gap.at),f.push({kind:"resumed",key:`resumed-${y.gap.at}`,at:y.gap.at,unmeasuredMs:y.gap.unmeasuredMs}));d?.started&&(x(d.at),f.push({kind:"started",key:"started",at:d.at,cleared:d.cleared===!0})),h!==null&&f.push({kind:"new",key:"new",since:h});const w=u>0,m=e.length>0||c.length>0,v=p.useRef(null),b=p.useRef(null),k=_f(v,b,m?f.map(y=>y.key).join(" "):""),N=Of(w,a);let j=!1;const E=f.map((y,C)=>{const q=C===0?null:j?"dots":"line";j=y.kind==="resumed"||(y.kind==="day"||y.kind==="new")&&j;const z=C===f.length-1?null:j?"dots":"line",ee={above:q,below:z};switch(y.kind){case"day":return n.jsx(ba,{day:y.day,now:o,thread:ee},y.key);case"event":return n.jsx(If,{event:y.event,mark:y.mark,open:y.open,waitedMs:y.waitedMs,above:q,below:z},y.key);case"resumed":return n.jsx(cn,{"data-slot":"event-resumed",at:y.at,thread:ee,mark:n.jsx(te,{kind:"lookout",labelled:!0}),children:n.jsxs("span",{children:["Watching resumed,"," ",n.jsx("span",{className:"tabular-nums",children:Y(y.unmeasuredMs)})," not measured"]})},y.key);case"started":return n.jsx(cn,{"data-slot":"event-start",at:y.at,thread:ee,mark:n.jsx(te,{kind:"lookout",labelled:!0}),children:n.jsx("span",{children:y.cleared?"History cleared":"Started watching"})},y.key);case"new":return n.jsx(Lf,{ref:N,since:y.since,now:o,thread:ee},y.key)}});let S;return m?S=n.jsx("div",{ref:v,className:"relative min-h-65 flex-1 max-wide:min-h-0",children:n.jsx("ol",{ref:b,"data-slot":"event-list","data-whole-rows":k!==null||void 0,"aria-label":"Event log, newest first",tabIndex:0,className:A("thin-scroll flex flex-col overflow-y-auto pt-0.5 pb-3.5 focus-visible:-outline-offset-2","wide:absolute wide:inset-0 max-wide:max-h-120"),style:k!==null?{bottom:"auto",height:k}:void 0,children:E})}):d?.started?S=n.jsxs("div",{className:"pb-4",children:[n.jsx("ol",{"data-slot":"event-list","aria-label":"Event log, newest first",className:"flex flex-col",children:E}),n.jsxs("p",{"data-part":"unchanged",className:"flex gap-3.5 px-6 text-caption text-ink-muted",children:[n.jsx("span",{"aria-hidden":!0,className:A(wn,"invisible"),children:me(d.at)}),n.jsx("span",{"aria-hidden":!0,className:"w-mark shrink-0"}),n.jsx("span",{children:"Nothing has changed since."})]})]}):S=n.jsx(_t,{compact:!0,title:"No events yet",className:"my-auto",children:n.jsx("p",{children:"When a session starts, finishes or needs you, it is logged here."})}),n.jsx(U,{title:"Events",count:w?n.jsxs(n.Fragment,{children:[u," new",n.jsx("span",{className:"sr-only",children:", the log"})]}):void 0,aside:d?n.jsxs("span",{"data-part":"since",children:["since ",n.jsx("span",{className:"tabular-nums",children:ue(d.at,o)})]}):void 0,className:A("flex flex-col",i),children:S})}const Wf={permission:"Waiting for permission",question:"Asked you a question",other:"Waiting for you"};function ya(e){return Wf[e.waitingReason??"other"]}function $s(e){return e.name.trim()!==""?e.name:e.project||e.id}function bn(e){return It($s(e),e.machine)}function Pf(e){const t=ya(e),s=e.waitingText?.trim();return{title:bn(e),body:s?`${t}: ${s}`:t}}const rs={"needs-you":"Needs you",finished:"Finished",failed:"Failed",ended:"Ended"},Df={finished:"finished",failed:"failed",ended:"ended"};function So(e){return Df[e]}function Ff(e){return e.event==="needs-you"?Pf(e.session):{title:bn(e.session),body:rs[e.event]}}const Rt="–",Ae={working:"busy with a task",idle:"ready for a prompt",sessions:"all sessions found",noneWorking:"none working",noneIdle:"none idle",noneRunning:"none running",timeNotReported:"time not reported",notCountedYet:"not counted yet",noSource:"no source to count"};function Ao(e,t,s,o){return e?n.jsxs(n.Fragment,{children:["longest"," ",n.jsx("span",{"data-part":"note-value",className:"whitespace-nowrap tabular-nums",children:Y(s-e.since)})]}):t>0?Ae.timeNotReported:o}function Uf(e){if(e.total===0)return Ae.noneRunning;const t=[`${e.open} open`];return e.finished>0&&t.push(`${e.finished} finished`),e.failed>0&&t.push(`${e.failed} failed`),t.join(", ")}function Vt({kind:e,label:t,mark:s,value:o,note:r,onOpen:a}){return n.jsxs("div",{"data-slot":"count","data-kind":e,"data-opens":a?"":void 0,role:"group","aria-label":t,className:a?"relative -m-2 flex min-w-0 cursor-pointer items-center gap-3 rounded-inner p-2 transition-colors duration-120 hover:bg-fill-hover has-[button:focus-visible]:outline-2 has-[button:focus-visible]:outline-offset-2 has-[button:focus-visible]:outline-focus":"flex min-w-0 items-center gap-3",children:[o===null?n.jsx("span",{"data-part":"placeholder","aria-hidden":!0,className:"block h-7 w-5.5 shrink-0 rounded-bar bg-fill-selected"}):n.jsx("p",{"data-part":"value",className:"min-w-5.5 shrink-0 text-stat font-medium tabular-nums",...o===Rt?{role:"img","aria-label":"Not known"}:{},children:o}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("p",{"data-part":"label",className:"flex min-w-0 items-center gap-1.75 text-body leading-tight font-semibold text-ink",children:[s,a?n.jsx("button",{type:"button","aria-haspopup":"dialog","aria-label":`${t}: open history`,onClick:a,className:"min-w-0 cursor-pointer truncate text-left outline-none after:absolute after:inset-0 after:rounded-inner",children:t}):n.jsx("span",{className:"truncate",children:t})]}),n.jsx("p",{"data-part":"note",className:"mt-px text-caption text-pretty text-ink-secondary",children:r})]})]})}function zf({counts:e,asOf:t,onOpenHistory:s,staleAfterMs:o=He}){const{summary:r,counted:a,searching:i}=e,l=c=>r===null?null:a?c??0:Rt,d=c=>s&&a?()=>s(c):void 0;return n.jsxs("div",{"data-slot":"counts-row",role:"group","aria-label":"Summary",className:"grid grid-cols-4 gap-4 border-t border-hairline pt-4.5 max-wide:grid-cols-2 max-wide:gap-y-3.5",children:[n.jsx(Vt,{kind:"working",label:"Working",mark:n.jsx(te,{kind:"working"}),value:l(r?.working),note:r&&a?Ao(r.longestWorking,r.working,t,Ae.noneWorking):Ae.working,onOpen:d("working")}),n.jsx(Vt,{kind:"idle",label:"Idle",mark:n.jsx(te,{kind:"idle"}),value:l(r?.idle),note:r&&a?Ao(r.longestIdle,r.idle,t,Ae.noneIdle):Ae.idle,onOpen:d("idle")}),n.jsx(Vt,{kind:"stale",label:"Stale",mark:n.jsx(te,{kind:"stale"}),value:l(r?.stale),note:`idle ${mn(o)} or more`}),n.jsx(Vt,{kind:"sessions",label:"Sessions",value:l(r?.total),note:r?a?Uf(r):i?Ae.notCountedYet:Ae.noSource:Ae.sessions})]})}function Hf(e){const t=new Set((e.restarts??[]).map(s=>s.at));return t.add(e.startedAt),[...t].sort((s,o)=>s-o)}function Ls(e,t,s){const o=[];if(!e)return o;const r=e.points.map(d=>d.at).sort((d,c)=>d-c),a=Hf(e);let i=0,l=null;for(const d of r){let c=!1;for(;i<a.length&&a[i]<=d;)l&&a[i]>l.to&&(c=!0),i+=1;l&&!c&&d-l.to<=s?l.to=d:o.push(l={from:d,to:d})}return l&&t>l.to&&t-l.to<=s&&(l.to=t),o}function _s(e,t,s,o,r){const a=[];return e.forEach((i,l)=>{const d=l===0&&i.from>t.from&&i.from-t.from<=r?t.from:i.from,c=Math.max(d,t.from,o),u=Math.min(i.to,t.to,s);u>c&&a.push({from:c,to:u})}),a}function Os(e,t){const s=[];let o=t.from;for(const r of[...e].sort((a,i)=>a.from-i.from))if(!(r.to<=o)&&(r.from>o&&s.push({from:o,to:Math.min(r.from,t.to)}),o=Math.max(o,r.to),o>=t.to))break;return o<t.to&&s.push({from:o,to:t.to}),s.filter(r=>r.to>r.from)}function Eo(e,t){const s=[];for(const o of e)for(const r of t){const a=Math.max(o.from,r.from),i=Math.min(o.to,r.to);i>a&&s.push({from:a,to:i})}return s.sort((o,r)=>o.from-r.from)}function Rs(e){return e.reduce((t,s)=>t+(s.to-s.from),0)}function ka(e,t,s="in the last hour"){if(t.length===0)return s;const o=t[0];return Rs(t)>=e.to-e.from?null:t.length===1&&o.from<=e.from?`since ${Q(o.to)}`:"in the time measured"}const ja=rn,Bf=new Map(ja.map((e,t)=>[e,t]));function To(e){return Bf.get(e)??ja.length}function Mo(e,t){const s=e.toLowerCase(),o=t.toLowerCase();return s<o?-1:s>o?1:0}function qf(e,t){const s=To(e.status)-To(t.status);if(s!==0)return s;if(e.statusSince!==t.statusSince){if(e.statusSince===null)return 1;if(t.statusSince===null)return-1;const o=e.statusSince-t.statusSince;return e.status==="needs-you"?o:-o}return Mo(e.name,t.name)||Mo(e.id,t.id)}function yn(e){return e.stale&&e.status==="idle"}function Ws(e){const t=e.status==="finished"||e.status==="failed",s=e.alive===!1,o=yn(e);return{mark:o?"stale":e.status,word:o?"Stale":Ms[e.status],ended:t,stale:o,quiet:o||t||s,orphaned:s&&!t}}const Gf={"needs-you":"Needs you",working:"Working",idle:"Idle",unknown:"Status unknown"},Kf=["needs-you","working","idle","ended","unknown"];function Vf(e){switch(e.status){case"needs-you":return"needs-you";case"working":return"working";case"idle":return"idle";case"finished":case"failed":return"ended";default:return"unknown"}}function Yf(e,t){if(e!=="ended")return Gf[e];const s=t.some(r=>r.status==="failed"),o=t.some(r=>r.status==="finished");return s&&o?"Finished or failed":s?"Failed":"Finished"}function Jf(e,t){return+(t.status==="failed")-+(e.status==="failed")||qf(e,t)}function Wt(e){const t=new Map;for(const o of e){const r=Vf(o),a=t.get(r);a?a.push(o):t.set(r,[o])}const s=[];for(const o of Kf){const r=t.get(o);if(!r)continue;const a=r.filter(yn).length;s.push({id:o,label:Yf(o,r),sessions:[...r].sort(Jf),count:r.length-a,stale:a})}return s}function as(e){return Wt(e).filter(t=>t.id!=="needs-you")}function Xf(e){return Wt(e).find(t=>t.id==="needs-you")?.sessions??[]}function Qf(e){return e?.filter(t=>t.status==="needs-you").length??0}function Rn(e,t){const s=t.statusSince;return s===null?e:e===null||s<e.since?{session:t,since:s}:e}function Zf(e){const t={total:e.length,needsYou:0,working:0,idle:0,stale:0,open:0,finished:0,failed:0,longestWait:null,longestWorking:null,longestIdle:null};for(const s of e){if(yn(s)){t.stale+=1;continue}switch(s.status){case"needs-you":t.needsYou+=1,t.longestWait=Rn(t.longestWait,s);break;case"working":t.working+=1,t.longestWorking=Rn(t.longestWorking,s);break;case"idle":t.idle+=1,t.longestIdle=Rn(t.longestIdle,s);break;case"finished":t.finished+=1;break;case"failed":t.failed+=1;break}}return t.open=t.total-t.finished-t.failed,t}function Ps(e,t=[]){const s=e?Zf(e):null,o=s!==null&&(s.total>0||t.some(r=>r.state==="ok"));return{summary:s,counted:o,searching:t.some(r=>r.state==="searching")}}function Na(e){return!e.summary||!e.counted?null:e.summary.needsYou>0?"lamp":"rest"}const va=3600*1e3;function em(e,t,s,o,r,a){const i=[],l=e?.startedAt??null,d=t[0];if(d){const f=l!==null&&l<d.at?l:-1/0;d.kind!=="appeared"?i.push({from:f,to:d.at,status:d.from??"unknown",startObserved:f!==-1/0,reaches:!1}):i.push({from:f,to:d.at,status:"unseen",startObserved:f!==-1/0,reaches:!1}),t.forEach((h,g)=>{const x=t[g-1];h.kind==="appeared"&&x?.kind==="ended"&&h.at>x.at&&i.push({from:x.at,to:h.at,status:"unseen",startObserved:!0,reaches:!1});const w=t[g+1]?.at??s.to;h.kind==="ended"||w<=h.at||i.push({from:h.at,to:w,status:h.to??"unknown",startObserved:!0,reaches:!1})})}else if(e){const f=l??-1/0,h=Math.max(f,Math.min(a,e.statusSince??1/0));h>f&&i.push({from:f,to:h,status:"unknown",startObserved:l!==null,reaches:!1,notKnown:!0}),i.push({from:h,to:s.to,status:e.status,startObserved:h!==-1/0,reaches:!1})}if(!e)return i;let c=i[i.length-1];(!c||c.to!==s.to||c.status==="unseen")&&(c={from:t[t.length-1]?.at??-1/0,to:s.to,status:e.status,startObserved:!0,reaches:!1},i.push(c)),c.status=e.status;const u=e.statusSince;return u!==null&&u<o&&(u>c.from+r?(c.to=u,c={from:u,to:s.to,status:e.status,startObserved:!0,reaches:!0},i.push(c)):c.reaches=!0),o<s.to&&c.from<o&&(c.to=o,i.push({from:o,to:s.to,status:e.status,startObserved:!0,reaches:!1})),i}function tm(e,t,s,o){const r=[],a=l=>s.some(d=>d.from<l&&l<=d.to),i=(l,d,c)=>{if(d<=l)return;const u=r[r.length-1];if(u?.kind==="unmeasured"&&u.to===l){u.to=d;return}const f=!(l===o.from&&c.from<l);r.push({from:l,to:d,kind:"unmeasured",startKnown:f})};for(const l of e){const d=Math.max(l.from,o.from),c=Math.min(l.to,o.to);if(c<=d)continue;if(l.notKnown){i(d,c,l);continue}if(l.reaches&&l.status!=="unseen"){const f=l.startObserved&&d===l.from;r.push({from:d,to:c,kind:l.status,startKnown:f});continue}let u=d;for(const f of t){if(f.to<=u)continue;if(f.from>=c)break;const h=Math.max(f.from,u),g=Math.min(f.to,c);if(i(u,h,l),l.status!=="unseen"&&g>h){const x=l.startObserved&&h===l.from&&a(h);r.push({from:h,to:g,kind:l.status,startKnown:x})}u=g}i(u,c,l)}return r}function nm(e,t){return e.flatMap(s=>s.kind!=="idle"||s.to<=t?[s]:s.from>=t?[{...s,kind:"stale"}]:[{...s,to:t},{...s,from:t,kind:"stale",startKnown:!0}])}function sm(e,t){return e.at-t.at}function Sa(e){const{sessions:t,events:s,history:o,now:r}=e,a=e.gapMs??Ot,i={from:r-(e.windowMs??va),to:r},l=Math.min(e.asOf??r,r),d=new Map;let c=1/0;for(const b of s){if(b.at<c&&(c=b.at),!bs(b))continue;const k=d.get(b.sessionId);k?k.push(b):d.set(b.sessionId,[b])}for(const b of d.values())b.sort(sm);const u=Ls(o,l,a),f=Math.max(o?ye(o).at:-1/0,e.eventsFull&&c!==1/0?c:-1/0),h=_s(u,i,l,f,a),g=(b,k,N)=>{const j=em(N,d.get(b)??[],i,l,a,o?.startedAt??-1/0);let E=tm(j,h,u,i);N?.stale&&N.status==="idle"&&N.statusSince!==null&&(E=nm(E,N.statusSince+(e.staleAfterMs??He)));const S=E[E.length-1];if(N&&S&&S.to===i.to&&(S.ongoing=!0),N?.status==="needs-you")for(const y of E)y.kind==="needs-you"&&y.to===l&&(y.open=!0);return{id:b,name:k,ended:N===void 0,status:N?.status??null,stale:N?.stale??!1,segments:E}},x=Wt(t).flatMap(b=>b.sessions),w=x.map(b=>g(b.id,b.name,b)),m=new Set(x.map(b=>b.id)),v=[];for(const[b,k]of d){const N=k[k.length-1];!N||m.has(b)||N.kind!=="ended"||N.at<=i.from||v.push({at:N.at,row:g(b,N.sessionName,void 0)})}return v.sort((b,k)=>k.at-b.at||b.row.name.localeCompare(k.row.name)),{start:i.from,end:i.to,rows:[...w,...v.map(b=>b.row)],unmeasured:Os(h,i)}}function om(e,t){const{now:s,events:o}=e,r=e.heldMs??va;let a=1/0;for(const f of t.points)f.at<a&&(a=f.at);let i=1/0;for(const f of o)f.at<i&&(i=f.at);const l=[[ye(t).at,"started"],[Math.max(a===1/0?s:a,s-r),"held"]];e.eventsFull&&i!==1/0&&l.push([i,"events"]);let[d,c]=l[0];for(const[f,h]of l)f>d&&([d,c]=[f,h]);d=Math.min(d,s);const u=le(s);return d<=u?{from:u,to:s,bound:"midnight",today:!0}:{from:d,to:s,bound:c,today:!1}}function rm(e,t,s){const o=new Map;for(const a of e){if(!bs(a))continue;const i=o.get(a.sessionId);i?i.push(a):o.set(a.sessionId,[a])}let r=null;for(const a of o.values())a.sort((i,l)=>i.at-l.at),a.forEach((i,l)=>{const d=a[l-1];if(!(d?d.to==="needs-you":i.from==="needs-you")||i.to==="needs-you"||i.at<t.from||i.at>s||d&&i.at<=d.at||r&&i.at<=r.at)return;const u=i.kind==="ended"||i.to==="finished"||i.to==="failed";r={id:i.sessionId,name:i.sessionName,ms:i.at-(d?d.at:t.from),startKnown:d!==void 0,at:i.at,how:u?"ended":"answered"}});return r}function am(e){const{history:t,now:s}=e;if(!t)return null;const o=e.gapMs??Ot,r=Math.min(e.asOf??s,s),a=om(e,t),i=Sa({sessions:e.sessions,events:e.events,history:t,now:s,asOf:r,eventsFull:e.eventsFull,windowMs:s-a.from,gapMs:o}),l=[];for(const f of i.rows){let h=0,g=0,x=!1,w=!0,m=!1,v=-1/0;for(const b of f.segments)if(b.from>v&&(m=!1),v=b.to,b.kind!=="unmeasured"){if(b.kind!=="needs-you"){m=!1;continue}m||(g+=1),m=!0,h+=b.to-b.from,b.open&&(x=!0),b.startKnown===!1&&(w=!1)}h>0&&l.push({id:f.id,name:f.name,ms:h,times:g,open:x,startKnown:w})}l.sort((f,h)=>h.ms-f.ms||f.name.localeCompare(h.name));const d={from:a.from,to:Math.max(a.from,r)},c=_s(Ls(t,r,o),d,r,ye(t).at,o),u=Os(c,d);return{period:a,sessions:l,totalMs:l.reduce((f,h)=>f+h.ms,0),gaps:u,unmeasuredMs:Rs(u),lastWait:rm(e.events,a,r)}}function im(e){return e.period.today?"Waited on you today":`Waited on you since ${Q(e.period.from)}`}function Co(e){const t=`Measured since ${Q(e.period.from)}`,s=Aa(e);return s?`${t}, with ${s}.`:`${t}.`}function Aa(e){const t=e.gaps[0];if(!t||e.unmeasuredMs<=0)return null;const s=Y(e.unmeasuredMs);return e.gaps.length===1?`${s} not measured after ${Q(t.from)}`:`${s} not measured in ${e.gaps.length} breaks, the first after ${Q(t.from)}`}const lm=7*6e4;function cm({waits:e}){const t=e?im(e):"Waited on you",s=e?.sessions[0]?.ms??0,o=Math.max(lm,s);return n.jsxs("div",{"data-slot":"waited-on-you",role:"group","aria-label":t,className:"grid grid-cols-1 gap-2.5 border-t border-hairline pt-4.5",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[n.jsx("h3",{className:"min-w-0 text-body font-semibold text-ink",children:t}),e&&e.totalMs>0&&n.jsxs("p",{"data-part":"total",className:"shrink-0 text-caption text-ink-secondary",children:[n.jsx("span",{className:"text-body font-semibold text-ink tabular-nums",children:Y(e.totalMs)})," ","in all"]})]}),e&&e.sessions.length>0&&n.jsx("ul",{"data-part":"bars",className:"grid grid-cols-1 gap-1.75",children:e.sessions.map(r=>{const a=`${r.startKnown?"":"at least "}${ke(r.ms)}`,i=rt(r.id),l=It(r.name,i);return n.jsxs("li",{"data-part":"waited","data-open":r.open,className:"flex items-center gap-4 text-body leading-5 max-mid:flex-wrap max-mid:gap-y-1",children:[n.jsxs(ie,{"data-part":"who",tooltip:l,className:A("w-waited-name shrink-0 max-mid:w-auto max-mid:min-w-0 max-mid:flex-1",r.open?"font-semibold text-ink":"font-medium text-ink-secondary"),children:[r.name,n.jsx(gn,{machine:i,className:"text-ink-muted"})]}),n.jsx("span",{"data-part":"track",role:"img","aria-label":r.open?`${l} has waited ${a}, still waiting`:`${l} waited ${a}, answered`,className:"relative h-2.5 min-w-0 flex-1 before:absolute before:inset-x-0 before:top-1/2 before:h-px before:bg-hairline max-mid:order-last max-mid:basis-full",children:n.jsx("i",{"data-part":"bar",className:A("absolute inset-y-0 left-0 rounded-bar",r.open?"bar-open bar-glow":"bar-answered"),style:{width:`${Math.round(r.ms/o*1e4)/100}%`}})}),n.jsx("span",{"data-part":"value","aria-hidden":!0,className:A("w-16 shrink-0 text-right whitespace-nowrap tabular-nums",r.open?"font-semibold text-label-needs-you":"text-ink-secondary"),children:Y(r.ms)})]},r.id)})}),n.jsx("p",{"data-part":"note",className:"text-caption text-ink-secondary",children:e===null?"The history could not be read, so how long sessions waited is not known.":e.sessions.length===0?`No session waited on you. ${Co(e)}`:Co(e)})]})}const dm=1e4,um=["no-ask","not-allowable","gone","too-soon","failed"];async function fm(e,t,s,o=dm){try{const r=await Z("/api/permission/answer",{method:"POST",headers:{"Content-Type":"application/json",[Le]:ud},body:JSON.stringify({sessionId:e,requestId:t,decision:s}),signal:AbortSignal.timeout(o)}),a=await r.json(),i=typeof a=="object"&&a!==null&&!Array.isArray(a)?a:{};return r.status===200?i.ok!==!0?"failed":i.decision==="deny"?"denied":i.decision==="allow"?"allowed":"failed":um.find(l=>l===i.reason)??"failed"}catch{return"no-answer"}}function mm(e){switch(e){case"allowed":return"Allowed from Agent Lookout.";case"denied":return"Denied from Agent Lookout. Claude carries on without it.";case"gone":return"It was answered in the session, or is no longer waiting, so nothing was sent.";case"no-ask":return"That request is no longer held, so nothing was sent.";case"not-allowable":return"Only Deny is offered for this request.";case"too-soon":return"That request is being answered.";case"failed":return"The answer could not be handed to the session.";case"no-answer":return"Agent Lookout did not answer in time. The session shows whether it went on."}}function hm(e){switch(e){case"edit":return"Allow is not offered for a change to a file here, since the change itself is not shown. Answer in the session to allow it.";case"too-long":return"It is too long to show whole here, so only Deny is offered. Answer in the session to allow it.";case"hidden-characters":return"It holds characters that cannot be shown as they are, written here as their codes, so only Deny is offered.";case"not-yes-or-no":return"It is answered with more than yes or no, so only Deny is offered here.";case"right-to-left":return"It holds right-to-left letters, which can draw a command in another order than it runs, so only Deny is offered. Answer in the session to allow it.";case"blank-lines":return"It has blank lines in a row that could hide what follows them, so only Deny is offered. Answer in the session to allow it."}}function pm(e,t=!1){const s=e.subagent?t?"A subagent now asks":"A subagent asks":t?"It now asks":"Asks";return e.command!==void 0?`${s} to run`:`${s} to use ${e.tool}`}const xm=1e3;function gm(e,t={}){const{onAnswered:s,request:o=fm,settleMs:r=xm}=t,[a,i]=p.useState({kind:"idle"}),l=e.ask?.requestId??null,[d,c]=p.useState(null),u=l!==null&&d!==l,f=`${p.useId()}-answer-outcome`,h=p.useRef(!1),g=p.useRef(!1),x=p.useRef(!0);p.useEffect(()=>(x.current=!0,()=>{x.current=!1}),[]),p.useEffect(()=>{if(l===null)return;const m=setTimeout(()=>c(l),r);return()=>clearTimeout(m)},[l,r]),p.useEffect(()=>{!g.current||a.kind!=="answered"||(g.current=!1,document.getElementById(f)?.focus())},[a,f]);const w=p.useCallback(m=>{h.current||l===null||u||(h.current=!0,i({kind:"busy",decision:m,requestId:l}),o(e.id,l,m).then(v=>{h.current=!1,x.current&&((v==="allowed"||v==="denied")&&s?.(),g.current=!0,i({kind:"answered",outcome:v,requestId:l}))}))},[e.id,l,u,o,s]);return{step:a,press:w,settling:u,outcomeId:f}}function Io({text:e,label:t,part:s,whole:o}){return n.jsx("pre",{"data-part":s,"data-whole":o||void 0,tabIndex:0,"aria-label":t,className:A("rounded-row bg-fill-zebra px-3 py-2 font-mono text-fact whitespace-pre-wrap text-ink inset-ring inset-ring-hairline wrap-anywhere select-text [letter-spacing:0]! [word-spacing:normal]!",!o&&"thin-scroll max-h-60 overflow-y-auto"),children:e})}function wm({ask:e,again:t}){return n.jsxs(n.Fragment,{children:[n.jsx("p",{"data-part":"ask-heading",className:"text-body font-medium text-ink",children:pm(e,t)}),e.command!==void 0&&n.jsx("div",{className:"mt-1.5",children:n.jsx(Io,{text:e.command,label:"The whole command",part:"command",whole:e.allow})}),e.inputs!==void 0&&e.inputs.length>0&&n.jsx("dl",{"data-part":"inputs",className:"mt-1.5 flex flex-col gap-1.5",children:e.inputs.map((s,o)=>n.jsxs("div",{className:"min-w-0",children:[n.jsx("dt",{className:"font-mono text-caption text-ink-secondary wrap-anywhere",children:s.name}),n.jsx("dd",{className:"mt-0.5",children:n.jsx(Io,{text:s.value,label:s.name,part:"input",whole:e.allow})})]},o))}),e.description!==void 0&&n.jsx("p",{"data-part":"description",className:"mt-1.5 text-body text-ink-secondary",children:e.description}),!e.allow&&e.denyOnly!==void 0&&n.jsx("p",{"data-part":"deny-only",className:"mt-1.5 text-body text-ink-secondary",children:hm(e.denyOnly)})]})}function Ea({session:e,onAnswered:t,request:s,settleMs:o,focusOnLeave:r,className:a}){const i=gm(e,{onAnswered:t,request:s,settleMs:o}),l=p.useRef(null),d=p.useRef(r);return p.useEffect(()=>{d.current=r},[r]),p.useLayoutEffect(()=>()=>{const c=l.current?.contains(document.activeElement)??!1,u=d.current;!c||u===void 0||setTimeout(()=>{const f=document.activeElement;(f===null||f===document.body||!f.isConnected)&&document.getElementById(u)?.focus()},0)},[]),n.jsx(bm,{session:e,answer:i,className:a,blockRef:l})}function bm({session:e,answer:t,className:s,blockRef:o}){const{ask:r}=e,{step:a}=t,i=a.kind==="answered"?a:null,l=r!==void 0&&r.requestId!==i?.requestId?r:null;if(l===null&&i===null)return null;const d=a.kind==="busy",c=d||t.settling;return n.jsxs("section",{ref:o,"data-slot":"answer","aria-label":`Permission request of ${e.name}`,className:A("flex min-w-0 flex-col",s),children:[i!==null&&n.jsx("p",{id:t.outcomeId,tabIndex:-1,role:"status","data-part":"answer-outcome","data-outcome":i.outcome,className:A("text-body text-ink outline-none",l!==null&&"mb-2.5"),children:mm(i.outcome)}),l!==null&&n.jsxs(n.Fragment,{children:[n.jsx(wm,{ask:l,again:i!==null}),n.jsxs("div",{className:"mt-2.5 flex flex-wrap items-center gap-3",children:[n.jsx(F,{size:"sm","data-part":"deny","aria-label":`Deny, for ${e.name}`,"aria-disabled":c||void 0,onClick:()=>t.press("deny"),children:"Deny"}),l.allow&&n.jsx(F,{size:"sm","data-part":"allow","aria-label":`Allow, for ${e.name}`,"aria-disabled":c||void 0,onClick:()=>t.press("allow"),children:"Allow"})]}),n.jsx("p",{"data-part":"answering","aria-live":"polite",className:"sr-only",children:d?a.decision==="allow"?"Allowing…":"Denying…":""})]})]})}const ym="agent-lookout",km=`${ym}:`;function Ta(){return typeof location>"u"?"":location.protocol}function Ds(e=Ta()){return e===km}function jm(e=document.documentElement,t=Ta()){Ds(t)&&(e.dataset.host="app")}const Ma=4e3,Nm=ad+5e3,vm=["no-pane","pane-gone","tmux-stopped","tab-gone","not-allowed","too-soon","failed"],Sm={selected:"Selected in tmux","no-pane":"No tmux pane found","pane-gone":"That pane has closed","tmux-stopped":"tmux has stopped","tab-gone":"That tab has closed","not-allowed":"macOS did not allow it","too-soon":"Try again in a moment",failed:"Jump did not work"};function Am(e,t=null){return t!==null&&e==="selected"?`Switched to ${t}`:t!==null&&e==="no-pane"?"No tab found":Sm[e]}function Em(e,t=Ds()){return`macOS will ask once whether ${t?"Agent Lookout":"the app you started Agent Lookout from"} may control ${e}. Allow it to let Jump switch tabs.`}const Tm="To let Jump switch tabs, allow it in System Settings, Privacy & Security, Automation.";async function Mm(e,t=Ma){try{const s=await Z("/api/jump",{method:"POST",headers:{"Content-Type":"application/json",[Le]:"jump"},body:JSON.stringify({sessionId:e}),signal:AbortSignal.timeout(t)}),o=await s.json(),r=typeof o=="object"&&o!==null?o:{};return s.ok?r.ok===!0?"selected":"failed":vm.find(a=>a===r.reason)??"failed"}catch{return"failed"}}function kn({session:e,jump:t,variant:s,size:o="sm",className:r}){const a=Ce(e);if(!a)return null;const i=`Jump to ${e.name} in ${a.where}`,l=A(o==="sm"&&"w-16",r);return a.by==="link"?n.jsx(F,{asChild:!0,variant:s,size:o,className:l,children:n.jsx("a",{href:a.href,"data-part":"jump","aria-label":i,children:"Jump"})}):n.jsx(ne,{content:a.where,align:"end",children:n.jsx(F,{variant:s,size:o,className:l,"data-part":"jump","data-way":a.by,"aria-label":i,onClick:t.press,children:"Jump"})})}function Ct({session:e,jump:t,className:s}){const{outcome:o,asking:r}=t,a=Ce(e);if(o===null&&r===null&&(a===null||a.by==="link"))return null;const i=o===null?null:Am(o,a?.by==="terminal"?a.app:null),l=o==="not-allowed"?Tm:o===null&&r!==null?Em(r):null;return n.jsxs(n.Fragment,{children:[n.jsx("span",{role:"status","data-part":"jump-said",className:"sr-only",children:i!==null&&l!==null?`${i}. ${l}`:i??l}),i!==null&&n.jsx(dt,{"aria-hidden":!0,"data-part":"jump-note","data-outcome":o,tone:o==="selected"?"neutral":"outline",className:s,children:i}),l!==null&&n.jsx("span",{"aria-hidden":!0,"data-part":"jump-line",className:"basis-full text-caption text-ink-secondary",children:l})]})}function Fs({git:e,inSentence:t=!1,className:s}){const o=e.branch;if(o===void 0&&e.commit===void 0)return null;const r=o!==void 0?"on":"at",a=o!==void 0?"branch":"commit";return n.jsxs(n.Fragment,{children:[t?n.jsxs(n.Fragment,{children:[r," ",n.jsxs("span",{className:"sr-only",children:[a," "]})]}):n.jsxs("span",{className:"sr-only",children:[r," ",a," "]}),o!==void 0?n.jsx(ie,{"data-part":"branch",className:s,children:o}):n.jsx("span",{"data-part":"commit",className:A("font-mono text-fact",s),children:e.commit})]})}function Ca({parts:e,className:t}){return n.jsx("span",{"data-slot":"duration-figure",className:A("inline-flex items-baseline gap-1.5 tabular-nums",t),children:e.map(s=>n.jsxs("span",{className:"inline-flex items-baseline",children:[s.value,n.jsx("span",{"data-part":"unit",className:"ml-0.5 text-unit font-medium text-ink-secondary",children:s.unit})]},s.unit))})}function be({label:e,className:t}){return n.jsxs("div",{"data-slot":"loading",role:"status",className:A("flex items-center justify-center gap-2.5 px-6 py-14",t),children:[n.jsx("span",{"aria-hidden":!0,className:"size-mark animate-spin-loader rounded-capsule border-[1.5px] border-rule-strong border-t-ink-secondary"}),n.jsx("span",{className:"text-body font-medium text-ink-secondary",children:e})]})}const Ia="agent-lookout-automation-note",$a=new Set;function La(){try{const e=localStorage.getItem(Ia)??"";return ws.filter(t=>e.split(",").includes(t))}catch{return[]}}function Cm(e){return!$a.has(e)&&!La().includes(e)}function Im(e){const t=new Set([...La(),e]);try{localStorage.setItem(Ia,ws.filter(s=>t.has(s)).join(","))}catch{$a.add(e)}}const $m=4e3,Lm=12e3,_m=1e3;function jn(e){const t=e.id,s=Ce(e),o=s?.by==="terminal"?s.app:null,[r,a]=p.useState(null),[i,l]=p.useState(null),d=p.useRef(!1),c=p.useRef(-1/0),u=p.useRef(!0),f=p.useRef(void 0),h=p.useRef(void 0);return p.useEffect(()=>(u.current=!0,()=>{u.current=!1,clearTimeout(f.current),clearTimeout(h.current)}),[]),{press:p.useCallback(()=>{d.current||performance.now()-c.current<id||(d.current=!0,clearTimeout(f.current),a(null),o!==null&&Cm(o)&&(h.current=setTimeout(()=>{Im(o),l(o)},_m)),Mm(t,o!==null?Nm:Ma).then(x=>{d.current=!1,c.current=performance.now(),clearTimeout(h.current),u.current&&(l(null),a(x),f.current=setTimeout(()=>a(null),x==="not-allowed"?Lm:$m))}))},[t,o]),outcome:r,asking:i}}const is="#overview/session/";function Om(e){return`${is}${encodeURIComponent(e).replace(/%3A/gi,":")}`}function Rm(e){if(!e.startsWith(is))return null;const t=e.slice(is.length);if(t==="")return null;try{return decodeURIComponent(t)}catch{return t}}const _a="agent-lookout-details";function Pt(e){return Om(e)}function Oa(e){return Rm(e)}function dn(e){const t=Pt(e);window.location.hash!==t&&(window.location.hash=t,window.history.replaceState({[_a]:!0},""))}let Wn=!1;function Wm(){if(Oa(window.location.hash)===null)return;const e=window.history.state;if(typeof e=="object"&&e!==null&&_a in e){if(Wn)return;Wn=!0,window.addEventListener("hashchange",()=>{Wn=!1},{once:!0}),window.history.back()}else window.location.replace("#overview")}function Ra(e,t){if(e.defaultPrevented||!(e.target instanceof Element))return;const s=e.target.closest("a, button, [tabindex]");s&&s!==e.currentTarget&&e.currentTarget.contains(s)||window.getSelection()?.isCollapsed!==!1&&dn(t)}function Nn(e,t){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),dn(t))}function Wa({onOpen:e,children:t}){const s=p.useId();return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-haspopup":"dialog","aria-describedby":s,onClick:e,className:"-mx-1.5 -my-0.5 cursor-pointer rounded-row px-1.5 py-0.5 text-left transition-colors duration-120 hover:bg-fill-hover",children:t}),n.jsx("span",{id:s,hidden:!0,children:"Opens the history of how many sessions needed you"})]})}function Pm({id:e,count:t,onOpen:s}){return n.jsxs("h2",{id:e,"data-part":"title",tabIndex:-1,className:"flex items-center gap-2.5 text-row leading-tight font-semibold text-ink outline-none",children:[n.jsx(te,{kind:"needs-you",breathing:!0,className:"size-4.5"}),s?n.jsx(Wa,{onOpen:s,children:"Needs you"}):n.jsx("span",{children:"Needs you"}),n.jsx("span",{"data-part":"count",className:"font-medium text-ink-secondary tabular-nums",children:t})]})}function Pa({session:e,className:t}){const s=ya(e),o=Zu(e);return o?n.jsx(ne,{content:`${s}: ${o}`,children:n.jsxs("span",{"data-part":"reason-text",tabIndex:0,className:A("rounded-bar text-label-needs-you",t),children:[s,n.jsxs("span",{className:"sr-only",children:[": ",o]})]})}):n.jsx("span",{"data-part":"reason-text",className:A("text-label-needs-you",t),children:s})}function Da({session:e,className:t}){const s=e.waitingText?.trim();return!s||e.ask?null:n.jsx(ie,{"data-part":"asking",lines:2,className:A("min-w-0 text-body wrap-anywhere text-ink-secondary",t),children:s})}function Fa({session:e,agent:t,className:s}){const o=$t(e.surface),r=!!e.project||o!==null;return!r&&t===void 0?null:n.jsxs("span",{"data-part":"place",className:A("relative min-w-0 text-body text-ink-secondary",s),children:[e.project?n.jsxs(n.Fragment,{children:[n.jsx(ne,{content:e.cwd,mono:!0,children:n.jsx("span",{"data-part":"project",tabIndex:e.cwd?0:void 0,className:"rounded-bar font-medium text-ink",children:e.project})}),e.git&&n.jsxs(n.Fragment,{children:[" ",n.jsx("span",{"data-part":"git",children:n.jsx(Fs,{git:e.git,inSentence:!0,className:"inline-block max-w-full align-top font-medium text-ink"})})]}),o!==null&&n.jsxs(n.Fragment,{children:[" ","in ",n.jsx("span",{"data-part":"app",children:o})]})]}):o!==null&&n.jsxs(n.Fragment,{children:["In ",n.jsx("span",{"data-part":"app",children:o})]}),t!==void 0&&n.jsxs(n.Fragment,{children:[r&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:", "}),n.jsx("span",{"aria-hidden":!0,className:"mx-1.5",children:"·"})]}),n.jsx("span",{"data-part":"agent",children:t})]})]})}function Ua({session:e}){return e.alive===!1?n.jsx(dt,{tone:"outline",children:"Process ended"}):null}function za(e,t){return e.statusSince===null?null:Math.max(0,t-e.statusSince)}function Ha({session:e,className:t}){return n.jsx(ie,{"data-part":"name",href:Pt(e.id),onClick:s=>Nn(s,e.id),"aria-label":`${e.name}, details`,"aria-haspopup":"dialog",className:A("-mx-1.5 -my-0.5 rounded-row px-1.5 py-0.5 transition-colors duration-120 hover:bg-fill-hover",t),children:e.name})}function Dm({session:e,asOf:t,agent:s,onAnswered:o,titleId:r}){const a=za(e,t),i=jn(e);return n.jsxs("div",{"data-slot":"hero-session","data-session":e.id,className:"mt-3.5 flex items-end justify-between gap-6 max-mid:flex-col max-mid:items-stretch max-mid:gap-4",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[n.jsxs("div",{className:"flex max-w-full min-w-0 items-center gap-3",children:[n.jsx(Ha,{session:e,className:"text-name font-semibold"}),n.jsx(Ua,{session:e})]}),n.jsx(Mt,{session:e}),n.jsx(Ct,{session:e,jump:i})]}),n.jsx("p",{"data-part":"reason",className:"mt-2 flex min-w-0 text-lead font-medium",children:n.jsx(Pa,{session:e,className:"truncate"})}),n.jsx(Da,{session:e,className:"mt-1"}),n.jsx(Fa,{session:e,agent:s,className:"mt-1.5 block wrap-anywhere"}),n.jsx(Ea,{session:e,onAnswered:o,focusOnLeave:r,className:"mt-3"})]}),n.jsxs("div",{className:"flex shrink-0 items-end gap-6 max-mid:flex-wrap max-mid:justify-between max-mid:gap-y-3",children:[n.jsxs("div",{"data-part":"wait",className:"text-right max-mid:text-left",children:[n.jsx("p",{className:"text-wait font-medium whitespace-nowrap text-label-needs-you",children:a!==null?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"sr-only",children:["Waiting ",ke(a)]}),n.jsx("span",{"aria-hidden":!0,children:n.jsx(Ca,{parts:ct(a)})})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:"How long it has waited was not reported"}),n.jsx("span",{"aria-hidden":!0,children:Rt})]})}),n.jsx("p",{"data-part":"since",className:"mt-2 text-caption text-ink-secondary",children:e.statusSince!==null?n.jsxs(n.Fragment,{children:["waiting since"," ",n.jsx("span",{className:"font-semibold text-ink tabular-nums",children:Q(e.statusSince)})]}):"time not reported"})]}),n.jsx(kn,{session:e,jump:i,variant:"needs-you",size:"hero"})]})]})}function Fm({session:e,asOf:t,agent:s,onAnswered:o,titleId:r}){const a=za(e,t),i=jn(e);return n.jsxs("li",{"data-slot":"hero-session","data-session":e.id,className:"flex items-center gap-5 border-t border-hairline py-3 max-mid:flex-wrap max-mid:gap-x-4 max-mid:gap-y-2",children:[n.jsxs("div",{className:"min-w-0 flex-1 max-mid:basis-full",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsxs("div",{className:"flex max-w-full min-w-0 items-center gap-2",children:[n.jsx(Ha,{session:e,className:"text-lead font-semibold text-ink"}),n.jsx(Ua,{session:e})]}),n.jsx(Mt,{session:e}),n.jsx(Ct,{session:e,jump:i})]}),n.jsxs("p",{"data-part":"reason",className:"mt-1 flex min-w-0 flex-wrap items-baseline gap-x-3 text-body",children:[n.jsx(Pa,{session:e,className:"font-medium"}),n.jsx(Fa,{session:e,agent:s,className:"block min-w-0 wrap-anywhere"})]}),n.jsx(Da,{session:e,className:"mt-1"}),n.jsx(Ea,{session:e,onAnswered:o,focusOnLeave:r,className:"mt-2"})]}),n.jsx("p",{"data-part":"wait",className:"shrink-0 text-right text-lead font-semibold whitespace-nowrap text-label-needs-you tabular-nums max-mid:mr-auto max-mid:text-left",children:a!==null?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"sr-only",children:["Waiting ",ke(a)]}),n.jsx("span",{"aria-hidden":!0,children:Y(a)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:"How long it has waited was not reported"}),n.jsx("span",{"aria-hidden":!0,children:Rt})]})}),n.jsx(kn,{session:e,jump:i,variant:"needs-you",size:"sm"})]})}function Um(e,t){const s=rt(e.id);return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-semibold text-ink",children:e.name}),s!==null&&` on ${s}`,", ",e.how==="ended"?"ended at":"answered at"," ",n.jsx("span",{className:"tabular-nums",children:Q(e.at)}),!e.startKnown&&n.jsxs(n.Fragment,{children:[", waiting since before ",n.jsx("span",{className:"tabular-nums",children:Q(t)})]})]})}function zm({id:e,waits:t,onOpen:s,seen:o}){const r=["this computer",...o.connected.map(f=>f.label)],a=r.length>1?`${r.slice(0,-1).join(", ")} or ${r.at(-1)}`:r[0],i=o.unseen===null?"Nothing needs you":`Nothing on ${a} needs you`,l=t?.lastWait??null,d=t!==null&&t.sessions.length===0,c=t?t.period.today?"today":`since ${Q(t.period.from)}`:null,u=t&&t.sessions.length===0?Aa(t):null;return n.jsxs("div",{className:"flex items-end justify-between gap-6 max-mid:flex-col max-mid:items-start max-mid:gap-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("h2",{id:e,"data-part":"title",tabIndex:-1,className:"mt-1 flex items-center gap-3.5 text-name font-semibold text-ink outline-none",children:[n.jsx(te,{kind:"needs-you",unlit:!0,className:"size-6.5"}),s?n.jsx(Wa,{onOpen:s,children:i}):n.jsx("span",{children:i})]}),o.unseen===null?n.jsx("p",{className:"mt-2.5 max-w-md text-row text-ink-secondary",children:"When a session stops to ask for something, it will show here."}):n.jsxs("p",{"data-part":"unseen",className:"mt-2.5 max-w-md text-row text-ink-secondary",children:[o.unseen," ",n.jsx("a",{href:"#sources",className:"rounded-bar underline decoration-rule-strong underline-offset-2 transition-colors duration-120 hover:text-ink",children:"Sources"})," ","says why."]})]}),n.jsxs("div",{"data-part":"last-wait",className:"shrink-0 text-right max-mid:text-left",children:[n.jsx("p",{className:"mb-2.5 text-caption font-semibold text-ink-secondary",children:"Last wait"}),l?n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"text-wait font-normal whitespace-nowrap text-ink",children:[n.jsxs("span",{className:"sr-only",children:["The last wait lasted ",l.startKnown?"":"at least ",ke(l.ms)]}),n.jsx("span",{"aria-hidden":!0,children:n.jsx(Ca,{parts:ct(l.ms)})})]}),n.jsx("p",{"data-part":"last-note",className:"mt-2 text-caption text-ink-secondary",children:Um(l,t?.period.from??l.at)})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{"data-part":"last-note",className:"text-body text-ink-secondary",children:c&&d?`None ${c}`:"Not known"}),u&&n.jsx("p",{"data-part":"last-gaps",className:"mt-1 text-caption text-ink-secondary",children:u})]})]})]})}function Hm({id:e,counts:t,connecting:s}){return n.jsxs("div",{children:[n.jsxs("h2",{id:e,"data-part":"title",tabIndex:-1,className:"flex items-center gap-2.5 text-row leading-tight font-semibold text-ink outline-none",children:[n.jsx(te,{kind:"needs-you",unlit:!0,className:"size-4.5"}),"Needs you"]}),t.summary===null?n.jsx(be,{label:"Reading sessions",className:"justify-start px-0 pt-5 pb-1"}):n.jsxs(n.Fragment,{children:[n.jsx("p",{"data-part":"value",role:"img","aria-label":"Not known",className:"mt-3.5 text-name font-semibold text-ink",children:Rt}),n.jsx("p",{"data-part":"uncounted",className:"mt-2 max-w-md text-row text-ink-secondary",children:t.searching?s.length>0?`Agent Lookout is still connecting to ${ae(s)} over SSH. The count follows as soon as ${s.length===1?"it is":"one is"} read.`:"Agent Lookout is still looking for agents on this computer. The count follows as soon as one is read.":"No agent tool could be read, so nothing could be counted. The Sessions card says why."})]})]})}function Bm({sessions:e,sources:t=[],events:s=[],history:o=null,now:r,asOf:a=r,onOpenHistory:i,onAnswered:l,staleAfterMs:d,className:c}){const u=p.useId(),f=Ps(e,t),h=Na(f),g=p.useMemo(()=>e?Xf(e):[],[e]),x=ma(t,e??[]),w=C=>x?Ts(C,t):void 0,m=ha(t),v={connected:t.filter(C=>fe(C.id)&&C.state==="ok"),unseen:pa(m)},b=t.some(C=>C.state==="searching"&&!fe(C.id)),k=p.useMemo(()=>e&&h?am({sessions:e,events:s,history:o,now:r,asOf:a,eventsFull:s.length>=xn}):null,[e,h,s,o,r,a]),N=i&&o&&h?i:void 0,[j,...E]=g;let S,y;return h?j?(y=E.length>0?"several":"one",S=n.jsxs("div",{children:[n.jsx(Pm,{id:u,count:g.length,onOpen:N&&(()=>N("needsYou"))}),n.jsx(Dm,{session:j,asOf:a,agent:w(j),onAnswered:l,titleId:u},j.id),E.length>0&&n.jsx("ul",{"data-part":"others","aria-label":"Also waiting, longest first",className:"mt-5",children:E.map(C=>n.jsx(Fm,{session:C,asOf:a,agent:w(C),onAnswered:l,titleId:u},C.id))})]})):(y="quiet",S=n.jsx(zm,{id:u,waits:k,onOpen:N&&(()=>N("needsYou")),seen:v})):(y=f.summary===null?"loading":"uncounted",S=n.jsx(Hm,{id:u,counts:f,connecting:b?[]:m.connecting})),n.jsxs("section",{"data-slot":"hero","data-state":y,"data-light":h??void 0,"aria-labelledby":u,className:A("glass-raised flex min-w-0 flex-col justify-between gap-5 px-7 pt-6 pb-5.5 max-mid:px-5",c),children:[S,h&&(k===null||k.sessions.length>0)&&n.jsx(cm,{waits:k}),n.jsx(zf,{counts:f,asOf:a,onOpenHistory:N,staleAfterMs:d})]})}function Ba(){const e=p.useRef(null),[t,s]=p.useState(0);return p.useEffect(()=>{const o=e.current;if(!o)return;const r=new ResizeObserver(([a])=>{a&&s(Math.floor(a.contentRect.width))});return r.observe(o),()=>r.disconnect()},[]),[e,t]}const Us=6e4,qm=60*Us,un=5*Us;function Gm(e){const t=new Date(e).getTimezoneOffset()*Us;return Math.floor((e-t)/un)*un+t}function Km(e,t){const s=[];for(const o of e){if(o.status!=="needs-you")continue;if(o.statusSince!==null){s.push(o.statusSince);continue}let r=-1/0;for(const a of t)a.sessionId===o.id&&a.to==="needs-you"&&a.at>r&&(r=a.at);s.push(r)}return s.sort((o,r)=>o-r)}function Vm(e,t,s){const o=[...e.points].sort((i,l)=>i.at-l.at),r=[],a=o[0];return a&&r.push({...a,from:-1/0,to:a.at}),o.forEach((i,l)=>{const d=o[l+1];let c=i.at;d&&d.at-i.at<=s?c=d.at:!d&&t>i.at&&t-i.at<=s&&(c=t),c>i.at&&r.push({...i,from:i.at,to:c})}),r}function Ym(e){const{history:t,now:s}=e,o=e.gapMs??Ot,r=s-(e.windowMs??qm),a={from:r,to:s},i=Math.min(e.asOf??s,s),l=Ls(t,i,o),d=_s(l,a,i,t?ye(t).at:-1/0,o),c=[];for(let m=Gm(r);m<s;m+=un){const v=Math.max(m,r),b=Math.min(m+un,s);if(b<=v)continue;const k=Eo(d,[{from:v,to:b}]);c.push({from:v,to:b,measured:k,measuredMs:Rs(k),means:null})}const u=c.map(()=>({open:0,answered:0,working:0,idle:0})),f=Km(e.sessions,e.events),h=m=>f.filter(v=>v<=m).length;let g=0,x=0;if(t)for(const m of Vm(t,i,o))for(const v of Eo([m],d)){const b=[v.from,...f.filter(k=>k>v.from&&k<v.to),v.to];for(let k=0;k<b.length-1;k+=1){const N=b[k],j=b[k+1],E=Math.min(m.needsYou,h(N)),S=m.needsYou-E;g+=m.needsYou*(j-N),x+=E*(j-N),c.forEach((y,C)=>{const q=Math.min(j,y.to)-Math.max(N,y.from);if(q<=0)return;const z=u[C];z.open+=E*q,z.answered+=S*q,z.working+=m.working*q,z.idle+=m.idle*q})}}let w=0;return c.forEach((m,v)=>{if(m.measuredMs<=0)return;const b=u[v],k=j=>j/m.measuredMs,N={open:k(b.open),answered:k(b.answered),working:k(b.working),idle:k(b.idle),total:0};N.total=N.open+N.answered+N.working+N.idle,m.means=N,N.total>w&&(w=N.total)}),{start:r,end:s,buckets:c,unmeasured:Os(d,a),waitedMs:g,openMs:x,axis:Rd(w)}}const Jm=.02,et=.05,Xm=96;function de(e){return`${Math.round(e*1e5)/1e3}%`}function ls(e,t){return`${Q(e.from)} to ${e.to>=t?"now":Q(e.to)}`}function Me(e){return e.toFixed(1)}function Qm(e){const t=[e.open>=et&&`needs you ${Me(e.open)}`,e.answered>=et&&`answered ${Me(e.answered)}`,e.working>=et&&`working ${Me(e.working)}`,e.idle>=et&&`idle ${Me(e.idle)}`].filter(Boolean);return t.length>0?t.join(", "):"no sessions"}function qa(e,t){if(!e.means)return`${ls(e,t)}: not measured`;const s=e.measuredMs<e.to-e.from-1e3;return`${ls(e,t)}: ${Qm(e.means)}${s?`, measured for ${Y(e.measuredMs)}`:""}`}function Zm(e){const t=e.unmeasured.map(s=>`from ${Q(s.from)} to ${s.to>=e.end?"now":Q(s.to)}`);return["The average number of sessions in each status, every five minutes over the last hour.",t.length>0?`Not measured ${t.join(", and ")}.`:"",...e.buckets.map(s=>`${qa(s,e.end)}.`)].filter(Boolean).join(" ")}function eh(e){const t=new Set,s=e[0],o=e[e.length-1];if(s!==void 0&&t.add(s),o!==void 0&&t.add(o),e.length%2===1){const r=e[(e.length-1)/2];r!==void 0&&t.add(r)}return t}function th({means:e,ceiling:t,from:s,to:o,hour:r}){if(e.total<=0)return null;const a=r.end-r.start,i=[["open",e.open,"bar-open"],["answered",e.answered,"bar-answered"],["working",e.working,"bar-working"]];return n.jsx("div",{"aria-hidden":!0,"data-part":"bar",className:"bar-tube absolute bottom-0 z-10 flex flex-col-reverse gap-0.5 overflow-hidden rounded-t-tube rounded-b-bar",style:{left:de((s-r.start)/a),width:`max(2px, calc(${de((o-s)/a)} - 4px))`,height:de(Math.min(1,e.total/t))},children:i.map(([l,d,c])=>d>=Jm?n.jsx("i",{"data-part":"segment","data-kind":l,className:A("block shrink-0",c),style:{height:de(d/e.total)}},l):null)})}function nh({fill:e}){return n.jsx("i",{"aria-hidden":!0,className:A("block h-2.5 w-3.5 rounded-bar",e)})}function sh({hour:e}){const t=p.useId(),[s,o]=Ba(),[r,a]=p.useState(null),i=e.end-e.start,l=e.axis.ceiling,d=e.buckets.length-1,c=r===null?d:Math.min(r,d),u=e.buckets[c],f=u?qa(u,e.end):"",h=eh(e.axis.ticks),g=o>0?Qr(e.start,e.end,Math.max(1,Math.floor(o/Xm))).map(m=>({at:m,share:(m-e.start)/i})).filter(({share:m})=>m*o>=16&&m*o<=o-52):[],x=(m,v)=>{const b=e.start+(m-v.left)/v.width*i,k=e.buckets.findIndex(N=>b<N.to);a(k===-1?d:k)},w=m=>{const b={ArrowLeft:k=>k-1,ArrowDown:k=>k-1,ArrowRight:k=>k+1,ArrowUp:k=>k+1,Home:()=>0,End:()=>d}[m.key];b&&(m.preventDefault(),a(Math.min(d,Math.max(0,b(c)))))};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{"data-slot":"last-hour-chart",role:"slider",tabIndex:0,"aria-label":"Last hour, every five minutes. Arrow keys read each five minutes.","aria-describedby":t,"aria-orientation":"horizontal","aria-valuemin":0,"aria-valuemax":Math.max(0,d),"aria-valuenow":c,"aria-valuetext":f,onPointerMove:m=>x(m.clientX,m.currentTarget.getBoundingClientRect()),onPointerLeave:()=>a(null),onBlur:()=>a(null),onFocus:m=>{m.currentTarget.matches(":focus-visible")&&a(v=>v??d)},onKeyDown:w,className:"relative mt-4 mr-11.5 ml-6 min-h-28 flex-1 cursor-crosshair rounded-bar max-wide:h-50 max-wide:flex-none",children:[e.axis.ticks.map(m=>n.jsx("span",{"aria-hidden":!0,"data-part":"grid",className:A("absolute inset-x-0 block h-px",m===0?"bg-rule-strong":"bg-hairline"),style:{bottom:de(m/l)},children:h.has(m)&&n.jsx("span",{className:"absolute -top-1.75 -right-7.5 w-5.5 font-mono text-micro leading-3.5 text-ink-muted",children:m})},m)),r!==null&&u&&n.jsx("i",{"aria-hidden":!0,"data-part":"chosen",className:"absolute inset-y-0 block rounded-bar bg-fill-selected inset-ring inset-ring-rule",style:{left:de((u.from-e.start)/i),width:`calc(${de((u.to-u.from)/i)} - 2px)`}}),e.unmeasured.map(m=>n.jsx("i",{"aria-hidden":!0,"data-part":"unmeasured",className:"unmeasured-hatch absolute inset-y-0 z-0 block",style:{left:de((m.from-e.start)/i),width:de((m.to-m.from)/i)}},m.from)),e.buckets.flatMap(m=>m.means?m.measured.map(v=>n.jsx(th,{means:m.means,ceiling:l,from:v.from,to:v.to,hour:e},v.from)):[]),r!==null&&u&&n.jsxs("div",{"aria-hidden":!0,"data-part":"reading",className:"pointer-events-none absolute top-0 z-20 rounded-row bg-glass-float px-2.5 py-1.5 font-mono text-fact whitespace-nowrap inset-ring inset-ring-rule",style:(u.from-e.start)/i>.55?{right:`calc(${de((e.end-u.from)/i)} + 6px)`}:{left:`calc(${de((u.to-e.start)/i)} + 2px)`},children:[n.jsx("span",{className:"block text-ink-secondary",children:ls(u,e.end)}),u.means?n.jsxs(n.Fragment,{children:[u.means.open>=et&&n.jsxs("span",{className:"block text-label-needs-you",children:["Needs you ",Me(u.means.open)]}),u.means.answered>=et&&n.jsxs("span",{className:"block text-ink",children:["Answered ",Me(u.means.answered)]}),n.jsxs("span",{className:"block text-ink",children:["Working ",Me(u.means.working)]}),n.jsxs("span",{className:"block text-ink",children:["Idle ",Me(u.means.idle)]})]}):n.jsx("span",{className:"block text-ink",children:"Not measured"})]})]}),n.jsx("p",{id:t,className:"sr-only",children:Zm(e)}),n.jsxs("div",{ref:s,"aria-hidden":!0,"data-slot":"last-hour-axis",className:"relative mr-11.5 ml-6 h-5.5 font-mono text-micro leading-none text-ink-muted",children:[g.map(m=>n.jsx("span",{"data-part":"time-tick",className:"absolute top-1.75 -translate-x-1/2 whitespace-nowrap",style:{left:de(m.share)},children:Q(m.at)},m.at)),n.jsx("span",{"data-part":"now",className:"absolute top-1.75 right-0 whitespace-nowrap text-ink-secondary",children:"now"})]})]})}function oh({open:e}){const t=[["working","bar-working","Working"],...e?[["needs-you","bar-open","Needs you"]]:[],["answered","bar-answered","Answered"],["idle","bar-tube","Idle"],["unmeasured","unmeasured-hatch","Not measured"]];return n.jsx("ul",{"data-slot":"last-hour-legend","aria-label":"Legend",className:"flex flex-wrap items-center gap-x-3.5 gap-y-1.5 px-6 pt-2 pb-5 text-caption text-ink-secondary",children:t.map(([s,o,r])=>n.jsxs("li",{"data-kind":s,className:"flex items-center gap-1.5 whitespace-nowrap",children:[n.jsx(nh,{fill:o}),r]},s))})}function rh({sessions:e,sources:t=[],events:s=[],history:o,now:r,asOf:a=r,className:i}){const l=p.useMemo(()=>e&&o?Ym({history:o,sessions:e,events:s,now:r,asOf:a}):null,[e,o,s,r,a]),d=l?.buckets.some(f=>(f.means?.total??0)>0)??!1;let c,u="every 5 minutes";if(e===null)c=n.jsx(be,{label:"Reading the last hour"});else if(l===null)u=void 0,c=n.jsx("div",{className:"px-6 pb-5",children:n.jsx(G,{tone:"error",title:"The last hour could not be read",children:n.jsx("p",{children:"Agent Lookout did not answer when asked for its history. The page asks again every two seconds."})})});else if(d||e.length>0)c=n.jsxs(n.Fragment,{children:[n.jsx("p",{"data-part":"sum",className:"px-6 text-body text-ink-secondary",children:l.waitedMs>0?n.jsxs(n.Fragment,{children:["Sessions waited on you for"," ",n.jsx("span",{className:"font-semibold text-ink tabular-nums",children:Y(l.waitedMs)})," ","in all"]}):l.unmeasured.length>0?"No session waited on you in the time measured":"No session waited on you in the last hour"}),n.jsx(sh,{hour:l}),n.jsx(oh,{open:l.openMs>0})]});else if(t.some(f=>f.state==="searching"))c=n.jsx(be,{label:"Looking for sessions"});else if(!t.some(f=>f.state==="ok"))u=void 0,c=n.jsx("div",{className:"px-6 pb-5",children:n.jsx(G,{title:"The last hour was not measured",children:n.jsx("p",{children:"No source could be read, so there is nothing to count. The Sessions card says why."})})});else{const f=ka({from:l.start,to:l.end},l.unmeasured);c=n.jsx(_t,{compact:!0,title:f?`No sessions ${f}`:"Nothing was measured in the last hour",children:n.jsx("p",{children:"When a session runs, how many waited, worked or sat idle is drawn here."})})}return n.jsx(U,{title:"Last hour",aside:u,className:A("flex flex-col",i),children:c})}function ah(e){return(e.status==="finished"||e.status==="failed")&&e.alive!==!0}const ih=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,lh=/[\p{Cc}\\\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069]/u,$o="claude-code:";function ch(e){return`'${e.replaceAll("'","'\\''")}'`}function dh(e,t){return!ih.test(e)||typeof t!="string"||!t.startsWith("/")||lh.test(t)?null:`cd ${ch(t)} && claude --resume ${e}`}function uh(e){return e.source!=="claude-code"||!e.id.startsWith($o)?null:e.id.slice($o.length)}function Ga(e,t=ah(e)){if(e.machine!==void 0)return null;const s=uh(e);return s===null||!t?null:dh(s,e.cwd)}async function fh(e){try{const t=navigator.clipboard;return typeof t?.writeText!="function"?"refused":(await t.writeText(e),"copied")}catch{return"refused"}}const mh=2e3;function hh({text:e,children:t,copiedSaid:s,refusedSaid:o,onCopied:r,copy:a=fh,tooltip:i,tooltipMono:l=!1,className:d,...c}){const[u,f]=p.useState(!1),[h,g]=p.useState(""),x=p.useRef(!1),w=p.useRef(!0),m=p.useRef(void 0);p.useEffect(()=>(w.current=!0,()=>{w.current=!1,clearTimeout(m.current)}),[]);const v=()=>{x.current||(x.current=!0,clearTimeout(m.current),g(""),f(!1),a(e).then(k=>{x.current=!1,w.current&&(g(k==="copied"?s:o),k==="copied"&&(f(!0),m.current=setTimeout(()=>f(!1),mh)),r?.(k))}))},b=n.jsxs(F,{"data-copied":u||void 0,className:A("inline-grid",d),onClick:v,...c,children:[n.jsx("span",{"aria-hidden":u||void 0,className:A("col-start-1 row-start-1",u&&"invisible"),children:t}),n.jsx("span",{"aria-hidden":!0,className:A("col-start-1 row-start-1",!u&&"invisible"),children:"Copied"})]});return n.jsxs(n.Fragment,{children:[i?n.jsx(ne,{content:i,mono:l,align:"end",children:b}):b,n.jsx("span",{"aria-live":"polite","aria-atomic":"true","data-part":"copy-said",className:"sr-only",children:h})]})}const ph="The command was not copied. It is shown on the page, to select and copy.";function Ka({command:e,className:t}){return n.jsx("code",{"data-part":"resume-command",tabIndex:0,className:A("font-mono text-fact whitespace-pre-wrap text-ink select-all",t),children:n.jsx(qe,{children:e})})}function Va({session:e,resume:t,tooltip:s=!0,className:o}){return t.command===null?null:n.jsx(hh,{text:t.command,size:"sm","data-part":"resume","aria-label":`Copy the command that resumes ${e.name}`,copiedSaid:`Copied the command that resumes ${e.name}. Paste it in a terminal.`,refusedSaid:ph,onCopied:t.onCopied,tooltip:s?t.command:void 0,tooltipMono:!0,className:A("w-16 px-2",o),children:"Resume"})}function Ya({resume:e,className:t}){return!e.refused||e.command===null?null:n.jsxs("span",{"data-part":"resume-line",className:A("basis-full text-caption text-ink-secondary",t),children:["Not copied. Select the command to copy it:"," ",n.jsx(Ka,{command:e.command,className:"rounded-bar"})]})}function $b({resume:e,className:t}){return e.command===null?null:n.jsxs("section",{"data-part":"resume-block","aria-label":"Resume",className:A("grid gap-1.5",t),children:[n.jsx("p",{className:"text-body text-ink-secondary",children:"Resume copies this command, which goes to the session's folder and opens its conversation again. Paste it in a terminal."}),n.jsx(Ka,{command:e.command,className:"block w-fit max-w-full rounded-row bg-fill-zebra px-3 py-1.5 inset-ring inset-ring-hairline"}),e.refused&&n.jsx("p",{"data-part":"resume-refused",className:"text-body text-ink-secondary",children:"Not copied. Select the command and copy it."})]})}const xh={open:"Open",draft:"Draft",merged:"Merged",closed:"Closed"},gh=["failing","pending","passing"];function Ja(e){const t=[];for(const s of gh){const o=e[s];o!==0&&t.push(t.length===0?`${o} ${o===1?"check":"checks"} ${s}`:`${o} ${s}`)}return t.length===0?"no checks":t.join(", ")}function Lb(e){return`${xh[e.state]}, ${Ja(e.checks)}`}function wh(e){return e!==void 0&&(e.state==="open"||e.state==="draft")&&e.checks.state==="failing"}function Lo(e){return`#${e.number}: ${Ja(e.checks)}`}function Xa({git:e,className:t}){const s=e.pullRequest;if(!wh(s))return null;const o=`Pull request ${Lo(s)}`;return n.jsx(ne,{content:o,children:n.jsxs("span",{"data-part":"checks",tabIndex:0,className:A("inline-flex shrink-0 items-center self-center rounded-bar text-status-finished",t),children:[n.jsx("svg",{"data-slot":"checks-mark",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor","aria-hidden":!0,className:"size-3",children:n.jsx("path",{d:"M3.2 3.2l5.6 5.6M8.8 3.2l-5.6 5.6",strokeWidth:"1.6",strokeLinecap:"round"})}),n.jsxs("span",{className:"sr-only",children:[", pull request ",Lo(s)]})]})})}const bh=5*6e4;function Qa(e,t){if(e.status!=="working"||e.lastWriteAt===void 0)return null;const s=t-e.lastWriteAt;return s>=bh?s:null}function yh(e){return`quiet for ${Et(e)}`}function kh(e){return`quiet for ${at(e)}`}function Za({session:e,now:t,quiet:s}){const o=e.status==="finished"||e.status==="failed",r=e.statusSince,a=r!==null?t-r:null;return n.jsx(ne,{content:r!==null?`Since ${da(r,t)}`:"The source did not report a time",mono:r!==null,align:"end",children:n.jsx("span",{"data-part":"duration",className:A("shrink-0 rounded-bar whitespace-nowrap tabular-nums",s?"text-ink-secondary":"text-ink"),children:a!==null?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:o?`${at(a)} ago`:`for ${at(a)}`}),n.jsxs("span",{"aria-hidden":!0,children:[Et(a),o&&" ago"]})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:"time not reported"}),n.jsx("span",{"aria-hidden":!0,children:"–"})]})})})}function ei({session:e,now:t}){const s=Qa(e,t);return s===null||e.lastWriteAt===void 0?null:n.jsx(ne,{content:`Last write at ${da(e.lastWriteAt,t)}`,mono:!0,align:"end",children:n.jsxs("span",{"data-part":"quiet",tabIndex:0,className:"block w-fit rounded-bar leading-tight whitespace-nowrap text-ink-muted tabular-nums",children:[n.jsx("span",{className:"sr-only",children:kh(s)}),n.jsx("span",{"aria-hidden":!0,children:yh(s)})]})})}function ti(e,t){const s=Ga(e,t),[o,r]=p.useState(!1),a=p.useCallback(i=>r(i==="refused"),[]);return{command:s,refused:o&&s!==null,onCopied:a}}const Ve="px-3 first:pl-6 last:pr-4.5";function jh({session:e,now:t,actionColumn:s,narrow:o=!1,agent:r,folderColumn:a=!0,appColumn:i=!0}){const{mark:l,word:d,stale:c,quiet:u,orphaned:f}=Ws(e),h=jn(e),g=ti(e),x=$t(e.surface),w=n.jsx(Za,{session:e,now:t,quiet:u}),m=Qa(e,t)!==null&&n.jsx(ei,{session:e,now:t}),v=b=>n.jsxs("p",{"data-part":"status-under",className:"flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-px overflow-x-clip leading-tight",children:[r!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx(ie,{"data-part":"agent",className:"min-w-0",children:r}),n.jsx("span",{className:"sr-only",children:", "})]}),n.jsxs("span",{"data-part":"status-time",className:"relative flex min-w-0 grow flex-wrap items-baseline justify-between gap-x-3 gap-y-px",children:[r!==void 0&&n.jsx("span",{"aria-hidden":!0,"data-part":"dot",className:"absolute right-full mr-1",children:"·"}),b,w]}),m&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:", "}),n.jsx("span",{className:"basis-full",children:m})]})]});return n.jsxs("tr",{"data-slot":"session-row","data-session":e.id,"data-status":e.status,"data-stale":c||void 0,onClick:b=>Ra(b,e.id),className:"group relative cursor-pointer text-body text-ink-secondary",children:[n.jsx("td",{className:A(Ve,"h-row",o&&"py-2","before:pointer-events-none before:absolute before:inset-x-2.5 before:inset-y-px before:-z-10 before:rounded-inner before:transition-colors before:duration-120 group-hover:before:bg-fill-hover","group-has-[a[data-part=name]:focus-visible]:before:outline-2 group-has-[a[data-part=name]:focus-visible]:before:outline-offset-2 group-has-[a[data-part=name]:focus-visible]:before:outline-focus"),children:n.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[n.jsx(te,{kind:l}),n.jsxs("div",{className:"grid min-w-0 flex-1 gap-px",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-px",children:[n.jsxs("div",{className:"flex max-w-full min-w-0 items-center gap-2",children:[n.jsx(ie,{"data-part":"name",href:Pt(e.id),onClick:b=>Nn(b,e.id),"aria-label":`${e.name}, details`,"aria-haspopup":"dialog",className:A("text-row focus-visible:outline-none",u?"font-medium text-ink-secondary":"font-semibold text-ink"),children:e.name}),f&&n.jsx(dt,{tone:"outline",children:"Process ended"})]}),!o&&n.jsx(Mt,{session:e}),!o&&n.jsx(Ct,{session:e,jump:h}),n.jsx(Ya,{resume:g})]}),o&&n.jsx(Mt,{session:e,className:"justify-self-start"}),o&&n.jsx(Ct,{session:e,jump:h,className:"justify-self-start"}),o&&v(n.jsx("span",{"data-part":"status",className:"whitespace-nowrap",children:d}))]})]})}),r!==void 0&&!o&&n.jsx("td",{"data-part":"agent",className:Ve,children:n.jsx(ie,{className:"block min-w-0",children:r})}),a&&n.jsxs("td",{className:A(Ve,"max-mid:hidden"),children:[n.jsx(ne,{content:e.cwd,mono:!0,children:n.jsx("span",{"data-part":"project",tabIndex:e.cwd?0:void 0,className:A("block truncate rounded-bar text-ink-secondary",e.git&&"leading-tight"),children:e.project??"–"})}),e.git&&n.jsxs("span",{"data-part":"git",className:"flex min-w-0 items-center gap-1 leading-tight text-ink-muted",children:[n.jsx(Fs,{git:e.git,className:"min-w-0"}),n.jsx(Xa,{git:e.git})]})]}),i&&n.jsx("td",{"data-part":"app",className:A(Ve,"truncate max-mid:hidden"),children:x??n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,children:"–"}),n.jsx("span",{className:"sr-only",children:"app not known"})]})}),!o&&n.jsxs("td",{className:Ve,children:[n.jsxs("div",{className:A("flex items-baseline justify-between gap-2 whitespace-nowrap",m&&"leading-tight"),children:[n.jsx("span",{"data-part":"status",children:d}),w]}),m]}),s&&n.jsxs("td",{className:A(Ve,"overflow-visible text-right"),children:[n.jsx(kn,{session:e,jump:h,className:"group-hover:bg-fill-selected group-hover:text-ink"}),n.jsx(Va,{session:e,resume:g,className:"group-hover:bg-fill-selected group-hover:text-ink"})]})]})}const Nh="No repository",_o=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function vh(e){const t=new Map,s=[];for(const r of e){const a=r.git?.repository;if(a===void 0){s.push(r);continue}const i=t.get(a.id);i?(i.sessions.push(r),_o.compare(a.name,i.label)<0&&(i.label=a.name)):t.set(a.id,{id:a.id,label:a.name,sessions:[r]})}const o=[...t.values()].sort((r,a)=>_o.compare(r.label,a.label)||(r.id<a.id?-1:r.id>a.id?1:0));return s.length>0?[...o,{id:null,label:Nh,sessions:s}]:o}function Sh(e){const t=e.git?.repository?.name;return t!==void 0&&t!==e.project?t:null}function Ah({session:e,now:t,agent:s}){const{mark:o,word:r,stale:a,quiet:i,orphaned:l}=Ws(e),d=jn(e),c=ti(e),u=$t(e.surface),f=Sh(e);return n.jsxs("li",{"data-slot":"board-card","data-session":e.id,"data-status":e.status,"data-stale":a||void 0,draggable:!1,onClick:h=>Ra(h,e.id),className:A("group flex min-w-0 cursor-pointer flex-col rounded-inner bg-fill-zebra px-3.5 pt-3 pb-3 text-body text-ink-secondary inset-ring inset-ring-hairline","transition-colors duration-120 hover:bg-fill-hover","has-[a[data-part=name]:focus-visible]:outline-2 has-[a[data-part=name]:focus-visible]:outline-offset-2 has-[a[data-part=name]:focus-visible]:outline-focus"),children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsxs("div",{className:"flex max-w-full min-w-0 items-center gap-3",children:[n.jsx(te,{kind:o}),n.jsx(ie,{"data-part":"name",href:Pt(e.id),onClick:h=>Nn(h,e.id),"aria-label":`${e.name}, details`,"aria-haspopup":"dialog",className:A("text-row focus-visible:outline-none",i?"font-medium text-ink-secondary":"font-semibold text-ink"),children:e.name})]}),n.jsx(Mt,{session:e}),l&&n.jsx(dt,{tone:"outline",children:"Process ended"}),n.jsx(Ct,{session:e,jump:d}),n.jsx(Ya,{resume:c})]}),e.project&&n.jsxs("p",{"data-part":"place",className:"mt-1.5 min-w-0 leading-tight",children:[f!==null&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"inline-flex max-w-full align-top",children:[n.jsx(ie,{"data-part":"repository",className:"min-w-0",children:f}),n.jsx("span",{"aria-hidden":!0,className:"whitespace-pre",children:" ·"})]}),n.jsx("span",{className:"sr-only",children:","})," "]}),n.jsx(ne,{content:e.cwd,mono:!0,children:n.jsx("span",{"data-part":"project",tabIndex:e.cwd?0:void 0,className:"inline-block max-w-full truncate rounded-bar align-top",children:e.project})}),e.git&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("span",{"data-part":"git",className:"inline-flex max-w-full gap-1 align-top whitespace-nowrap text-ink-muted",children:[n.jsx(Fs,{git:e.git,inSentence:!0,className:"min-w-0"}),n.jsx(Xa,{git:e.git})]})]})]}),(u!==null||s!==void 0)&&n.jsxs("p",{"data-part":"where",className:"mt-1 flex min-w-0 flex-wrap gap-x-3 gap-y-px overflow-x-clip leading-tight",children:[u!==null&&n.jsx("span",{"data-part":"app",className:"whitespace-nowrap",children:u}),s!==void 0&&n.jsxs(n.Fragment,{children:[u!==null&&n.jsx("span",{className:"sr-only",children:", "}),n.jsxs("span",{className:"relative flex min-w-0",children:[u!==null&&n.jsx("span",{"aria-hidden":!0,className:"absolute right-full mr-1",children:"·"}),n.jsx(ie,{"data-part":"agent",className:"min-w-0",children:s})]})]})]}),n.jsxs("div",{className:"mt-3 flex min-w-0 flex-wrap items-center gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("p",{className:"flex items-baseline gap-1.5 leading-tight whitespace-nowrap",children:[n.jsx("span",{"data-part":"status",children:r}),n.jsx(Za,{session:e,now:t,quiet:i})]}),n.jsx(ei,{session:e,now:t})]}),n.jsx(kn,{session:e,jump:d,className:"ml-auto group-hover:bg-fill-selected group-hover:text-ink"}),n.jsx(Va,{session:e,resume:c,className:"ml-auto group-hover:bg-fill-selected group-hover:text-ink"})]})]})}const Eh=[{id:"needs-you",label:"Needs you",empty:"Nothing waiting"},{id:"working",label:"Working",empty:"Nothing working"},{id:"idle",label:"Idle",empty:"Nothing idle"},{id:"ended",label:"Finished or failed",empty:"Nothing finished or failed"}],Th=5;function Mh(e){const t=Wt(e);return{columns:Eh.map(o=>{const r=t.find(a=>a.id===o.id);return{...o,sessions:r?.sessions??[],count:r?.count??0,stale:r?.stale??0}}),unknown:t.find(o=>o.id==="unknown")?.sessions??[]}}function it({children:e}){return n.jsx("span",{"data-part":"count",className:"font-medium text-ink-muted tabular-nums",children:e})}function Ch({column:e,now:t,agentOf:s}){const o=p.useId(),r=e.sessions.slice(0,Th),a=e.sessions.length-r.length;return n.jsxs("div",{"data-slot":"board-column","data-column":e.id,className:"flex min-w-0 flex-col",children:[n.jsxs("h3",{id:o,className:"flex h-group items-end gap-3.5 px-3.5 pb-2 text-caption font-semibold text-ink-secondary",children:[n.jsxs("span",{className:"inline-flex items-baseline gap-1.5",children:[e.label,n.jsx(it,{children:e.count})]}),e.stale>0&&n.jsxs("span",{"data-part":"stale",className:"inline-flex items-baseline gap-1.5",children:["Stale",n.jsx(it,{children:e.stale})]})]}),r.length>0?n.jsx("ul",{"aria-labelledby":o,className:"flex flex-col gap-2",children:r.map(i=>n.jsx(Ah,{session:i,now:t,agent:s?.(i)},i.id))}):n.jsx("p",{"data-part":"empty",className:"px-3.5 py-2.5 text-caption text-ink-muted",children:e.empty}),a>0&&n.jsxs("p",{"data-part":"more",className:"rounded-row px-3.5 pt-2.5 text-caption text-ink-muted",children:["and ",n.jsx("span",{className:"tabular-nums",children:a})," more in the list"]})]})}function Ih({sessions:e,now:t,agentOf:s}){const{columns:o,unknown:r}=Mh(e);return n.jsxs("div",{"data-slot":"session-board",className:"@container px-2.5 pb-2.5",children:[n.jsx("div",{className:"grid grid-cols-1 gap-x-2.5 gap-y-2 @min-[26rem]:grid-cols-2 @min-[47rem]:grid-cols-4",children:o.map(a=>n.jsx(Ch,{column:a,now:t,agentOf:s},a.id))}),r.length>0&&n.jsx("p",{"data-part":"unknown",className:"rounded-row px-3.5 pt-3 pb-1 text-caption text-ink-muted",children:r.length===1?"The status of 1 session is not known. The list shows it.":`The status of ${r.length} sessions is not known. The list shows them.`})]})}const $h=Br+2e4,Lh=["gone","unsupported","cannot-confirm","not-allowed","still-running","too-soon","failed"];async function ni(e){const t=await e.json();return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}async function _b(e,t=$h){try{const s=await Z("/api/sessions/stop",{method:"POST",headers:{"Content-Type":"application/json",[Le]:ld},body:JSON.stringify({sessionId:e}),signal:AbortSignal.timeout(t)}),o=await ni(s);return s.status===200?o.ok===!0?"stopped":"failed":Lh.find(r=>r===o.reason)??"failed"}catch{return"no-answer"}}function si(e){return Br+2e4+e*11e3}async function _h(e,t=si(0)){try{const s=await Z("/api/sessions/clean-up",{method:"POST",headers:{"Content-Type":"application/json",[Le]:cd},body:JSON.stringify({sessions:[...e]}),signal:AbortSignal.timeout(t)}),o=await ni(s);if(s.status===429)return{ok:!1,reason:"too-soon"};if(s.status!==200||!Array.isArray(o.results))return{ok:!1,reason:"failed"};const r=new Map;for(const a of o.results){if(typeof a!="object"||a===null)continue;const{sessionId:i,outcome:l}=a;typeof i=="string"&&r.set(i,dd.find(d=>d===l)??"failed")}return{ok:!0,results:r}}catch{return{ok:!1,reason:"no-answer"}}}function Oh(e,t){switch(e){case"stopped":return t==="background"?"Stopped. Claude Code stopped the background job, and its conversation is kept.":"Stopped. Its process has ended, and its conversation is kept.";case"gone":return"That session has already ended.";case"unsupported":return"Agent Lookout does not stop this session.";case"cannot-confirm":return"Agent Lookout cannot confirm this process is that session, so it did not stop it.";case"not-allowed":return"Agent Lookout is not allowed to stop this process.";case"still-running":return"Asked to stop, still running. It had not ended 10 seconds later.";case"too-soon":return"Another session is being stopped. Try again in a moment.";case"failed":return t==="background"?"Claude Code did not stop the background job.":"The session could not be stopped.";case"no-answer":return"Agent Lookout did not answer in time. The list shows whether it stopped."}}const Rh={ended:"Ended","became-active":"Became active","not-stale":"Idle less than a day",gone:"Had already ended",unsupported:"Not stopped from here","cannot-confirm":"Could not confirm","not-allowed":"Not allowed","still-running":"Still running",failed:"Did not stop"};function Wh(e,t=He){return e==="not-stale"?`Idle less than ${mn(t)}`:Rh[e]}const Oo="claude-code:";function Ph(e){if(e.source!=="claude-code"||!e.id.startsWith(Oo))return null;const t=e.id.slice(Oo.length);return t===""?null:t}const oi={text:"claude --resume",fact:!0,whole:!0};function Ro(e){return`Stop ${e.name}?`}const Se=e=>({text:e,fact:!1}),ri=e=>({text:e,fact:!0});function Dh(e){const t=Ph(e);return t===null?null:[oi,Se(" "),ri(t)]}function Fh(e){const t=Dh(e),s=t?[Se("The conversation is kept, and "),...t,Se(" opens it again.")]:[Se("The conversation is kept.")];return e.stop?.how==="background"?[Se("Agent Lookout asks Claude Code to stop this background job with "),{...ri("claude stop"),whole:!0},Se(". "),...s]:e.surface==="vscode"&&t?[Se("Its process ends now. The conversation is kept: open it again from the session history in VS Code, or with "),...t,Se(".")]:[Se("Its process ends now. "),...s]}function Uh(e){return e.status==="working"?"It is working now. What it is doing will stop part-way.":e.status==="needs-you"?"It is waiting for you. The question is left unanswered.":null}const Ob="Stop it in the desktop app. Agent Lookout does not stop the desktop app's sessions, because that app looks after their processes.",zh="Stop it in the desktop app.";function ai({runs:e}){return n.jsx(n.Fragment,{children:e.map((t,s)=>t.fact?n.jsx("code",{"data-slot":"fact",className:A("font-mono text-fact",t.whole?"whitespace-nowrap":"wrap-anywhere"),children:t.text},s):t.text)})}function Rb({session:e,stop:t}){if(!e.stop)return null;const s=t.step.kind==="confirming"&&t.step.busy;return n.jsx(F,{id:t.ids.stop,size:"sm","data-part":"stop","aria-label":`Stop ${e.name}`,"aria-expanded":t.step.kind==="confirming","aria-disabled":s||void 0,onClick:t.step.kind==="confirming"?void 0:t.ask,children:"Stop"})}function Wb({session:e,stop:t,className:s}){const{step:o}=t;if(o.kind==="idle")return null;if(o.kind==="answered")return n.jsx("p",{id:t.ids.outcome,tabIndex:-1,role:"status","data-part":"stop-outcome","data-outcome":o.outcome,className:A("text-body text-ink outline-none",s),children:Oh(o.outcome,e.stop?.how??"signal")});const r=Uh(e);return n.jsxs("section",{"data-part":"stop-confirm","aria-label":Ro(e),className:A("flex flex-col gap-1",s),children:[n.jsx("p",{"data-part":"question","aria-live":"polite",className:"text-body font-medium text-ink",children:o.busy?`Stopping ${e.name}…`:Ro(e)}),n.jsx("p",{"data-part":"does",className:"text-body text-ink-secondary",children:n.jsx(ai,{runs:Fh(e)})}),r&&n.jsx("p",{"data-part":"interrupts",className:"text-body text-ink-secondary",children:r}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3",children:[n.jsx(F,{size:"sm","data-part":"confirm-stop",onClick:t.confirm,"aria-disabled":o.busy||void 0,children:"Stop session"}),n.jsx(F,{id:t.ids.cancel,size:"sm","data-part":"cancel-stop",onClick:t.cancel,"aria-disabled":o.busy||void 0,children:"Cancel"})]})]})}function ii({checked:e,onCheckedChange:t,disabled:s,className:o,...r}){return n.jsx(el,{"data-slot":"checkbox",checked:e,onCheckedChange:a=>t(a===!0),disabled:s,className:A("relative inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-bar","after:absolute after:-inset-1","bg-well text-ink inset-ring inset-ring-rule-strong inset-shadow-well","data-[state=checked]:bg-fill-selected data-[state=checked]:inset-ring-control-rim data-[state=checked]:inset-shadow-top","transition-colors duration-120 hover:data-[state=unchecked]:bg-fill-quiet","disabled:cursor-default disabled:opacity-50",o),...r,children:n.jsx(tl,{children:n.jsx(vc,{"aria-hidden":!0,className:"size-3",strokeWidth:2.5})})})}const li="agent-lookout-hidden-sessions",Hh=100,ci=new Set;function di(e){return`${e.statusSince??""} ${e.id}`}function ui(){try{const e=JSON.parse(localStorage.getItem(li)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}catch{return[]}}function fi(){return new Set([...ui(),...ci])}function Bh(e){const t=di(e),s=ui().filter(o=>o!==t);s.push(t);try{localStorage.setItem(li,JSON.stringify(s.slice(-Hh)))}catch{ci.add(t)}return fi()}function qh(e,t){const s=[];for(const o of e){if(o.source!=="claude-code"||o.alive!==!0||!yn(o)||o.statusSince===null)continue;const r=o.stop!==void 0;!r&&o.surface!=="desktop"||s.push({session:o,idleMs:Math.max(0,t-o.statusSince),endable:r})}return s.sort((o,r)=>o.session.statusSince-r.session.statusSince)}function Gh(e){return e.filter(t=>t.endable).slice(0,Qe).map(t=>({sessionId:t.session.id,statusSince:t.session.statusSince}))}const Yt=(e,t,s)=>e===1?t:s;function Kh(e,t=He){const s=f=>e.filter(h=>h===f).length,o=s("ended"),r=[`Ended ${o===0?"none":o}.`],a=s("became-active");a>0&&r.push(`Left ${a} running because ${Yt(a,"it","they")} became active.`);const i=s("not-stale");i>0&&r.push(`Left ${i} running because ${Yt(i,"it has","they have")} been idle less than ${mn(t)}.`);const l=s("cannot-confirm");l>0&&r.push(`Left ${l} running because Agent Lookout could not confirm ${Yt(l,"its process","their processes")}.`);const d=s("still-running");d>0&&r.push(`${d} asked to stop ${Yt(d,"is","are")} still running.`);const c=s("gone");c>0&&r.push(`${c} had already ended.`);const u=s("failed")+s("unsupported")+s("not-allowed");return u>0&&r.push(`${u} could not be stopped.`),r.join(" ")}const Wo="End the sessions left running?",Vh=[{text:"Each chosen session's process ends now. Its conversation is kept, and ",fact:!1},oi,{text:" opens it again. A session that has done anything since this list was drawn is left running.",fact:!1}];function Yh(e){return`End ${e} ${e===1?"session":"sessions"}`}function Jh(e){return new Set(e.filter(t=>t.endable).slice(0,Qe).map(t=>t.session.id))}function Xh(e){return e.reason==="too-soon"?"Another session is being stopped. Try again in a moment.":e.reason==="no-answer"?"Agent Lookout did not answer in time. The list shows which have ended.":"The sessions could not be ended."}function Pn({one:e,checkbox:t,outcome:s,action:o,staleAfterMs:r=He}){const{session:a}=e,i=$t(a.surface),l=[a.project,i].filter(c=>c!==null),d=s==null||s==="ended";return n.jsxs("li",{"data-slot":"left-running-row","data-session":a.id,"data-endable":e.endable||void 0,className:"flex items-start gap-3 py-1.5",children:[t?n.jsx(ii,{checked:t.checked,onCheckedChange:t.onChange,disabled:t.disabled,"aria-label":`End ${a.name}`,className:"mt-0.5"}):n.jsx(te,{kind:s==="ended"?"ended":"stale",className:"mt-0.5"}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-1.5",children:[n.jsxs("div",{className:"min-w-0 grow basis-40",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-px",children:[n.jsx(ie,{"data-part":"name",href:Pt(a.id),onClick:c=>Nn(c,a.id),"aria-label":`${a.name}, details`,"aria-haspopup":"dialog",className:"max-w-full text-row font-medium text-ink-secondary",children:a.name}),s&&n.jsx(dt,{"data-part":"outcome","data-outcome":s,tone:s==="ended"?"neutral":"outline",children:Wh(s,r)})]}),n.jsxs("p",{"data-part":"place",className:"text-caption leading-tight text-ink-secondary",children:[l.join(" · "),l.length>0&&d&&" · ",d&&n.jsxs("span",{className:"tabular-nums",children:[n.jsxs("span",{"aria-hidden":!0,children:["idle ",Et(e.idleMs)]}),n.jsxs("span",{className:"sr-only",children:["idle ",at(e.idleMs)]})]})]}),!e.endable&&n.jsx("p",{"data-part":"desktop",className:"mt-0.5 text-caption leading-tight text-ink-secondary",children:zh})]}),o]})]})}function Qh({sessions:e,now:t,onEnded:s,onGone:o,end:r=_h,staleAfterMs:a=He}){const i=`idle ${mn(a)} or more`,[l,d]=p.useState(fi),[c,u]=p.useState({kind:"list"}),[f,h]=p.useState(!1),[g,x]=p.useState(null),w=p.useRef(null),m=p.useRef(null),v=p.useRef(null),b=p.useRef(null),k=p.useRef(null),N=p.useRef(null),j=p.useRef(!0),E=p.useId();p.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]),p.useEffect(()=>{const $=N.current;if(N.current=null,$===null)return;let W;$==="cancel"?W=b.current:$==="summary"?W=k.current:$==="toggle"?W=m.current:$==="end"?W=v.current??m.current:W=[...w.current?.querySelectorAll('[data-slot="left-running-row"]')??[]].find(se=>se.dataset.session===$.hide)?.querySelector('[data-part="hide"]'),W?W.focus():w.current||o?.()},[c,l,f,o]);const S=qh(e,t).filter($=>!l.has(di($.session)));f&&c.kind==="list"&&S.length===0&&h(!1);const y=()=>{x(null),N.current="cancel",u({kind:"confirming",shown:S,chosen:Jh(S),busy:!1})},C=()=>{N.current="end",u({kind:"list"})},q=$=>{const W=S.indexOf($),D=S.filter(se=>se!==$),L=D[W]??D[W-1];N.current=L?{hide:L.session.id}:"end",d(Bh($.session))},z=()=>{N.current="toggle",h(!f)};if(c.kind==="list"&&S.length===0)return null;if(c.kind==="done"){const $=c.rows.filter(({outcome:W})=>W!=="ended").length;return n.jsxs(Dn,{ref:w,count:$,note:i,open:!0,children:[n.jsx("p",{ref:k,tabIndex:-1,role:"status","data-part":"summary",className:"mt-1 text-body text-ink outline-none",children:c.summary}),n.jsx("ul",{className:"mt-1.5",children:c.rows.map(({one:W,outcome:D})=>n.jsx(Pn,{one:W,outcome:D,staleAfterMs:a},W.session.id))}),n.jsx("div",{className:"mt-2",children:n.jsx(F,{size:"sm","data-part":"done",onClick:()=>{N.current="end",u({kind:"list"})},children:"Done"})})]})}if(c.kind==="confirming"){const{shown:$,chosen:W,busy:D}=c,L=Gh($.filter(H=>W.has(H.session.id))),se=W.size>=Qe,ut=$.filter(H=>H.endable).length>Qe,ft=$.filter(H=>W.has(H.session.id)&&H.session.stop?.how==="background").length,I=()=>{D||L.length===0||(u({...c,busy:!0}),r(L,si(ft)).then(H=>{if(!j.current)return;if(!H.ok){x(Xh(H)),N.current="cancel",u({...c,busy:!1});return}const Oe=L.map(ce=>H.results.get(ce.sessionId)??"failed");N.current="summary",u({kind:"done",rows:$.map(ce=>({one:ce,outcome:W.has(ce.session.id)?H.results.get(ce.session.id)??null:null})),summary:Kh(Oe,a)}),Oe.includes("ended")&&s?.()}))};return n.jsx(Dn,{ref:w,count:$.length,note:i,open:!0,children:n.jsxs("section",{"data-part":"end-confirm","aria-label":Wo,children:[n.jsx("p",{"data-part":"question","aria-live":"polite",className:"mt-1 text-body font-medium text-ink",children:D?`Ending ${L.length===1?"1 session":`${L.length} sessions`}…`:Wo}),n.jsx("p",{"data-part":"does",className:"mt-1 text-body text-ink-secondary",children:n.jsx(ai,{runs:Vh})}),ut&&n.jsxs("p",{"data-part":"limit",className:"mt-1 text-body text-ink-secondary",children:["Up to ",Qe," at a time."]}),n.jsx("ul",{className:"mt-1.5",children:$.map(H=>n.jsx(Pn,{one:H,checkbox:H.endable?{checked:W.has(H.session.id),disabled:D||se&&!W.has(H.session.id),onChange:Oe=>{const ce=new Set(W);Oe?ce.size<Qe&&ce.add(H.session.id):ce.delete(H.session.id),u({...c,chosen:ce})}}:void 0},H.session.id))}),g&&n.jsx("p",{"data-part":"problem",role:"status",className:"mt-1.5 text-body text-ink",children:g}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3",children:[n.jsx(F,{size:"sm","data-part":"confirm-end",onClick:I,"aria-disabled":D||L.length===0||void 0,children:Yh(L.length)}),n.jsx(F,{ref:b,size:"sm","data-part":"cancel-end",onClick:D?void 0:C,"aria-disabled":D||void 0,children:"Cancel"})]})]})})}const ee=S.some($=>$.endable);return n.jsx(Dn,{ref:w,count:S.length,note:i,open:f,action:n.jsxs(n.Fragment,{children:[f&&ee&&n.jsx(F,{ref:v,size:"sm","data-part":"end-all",onClick:y,children:"End all…"}),n.jsx(F,{ref:m,size:"sm","data-part":"review","aria-expanded":f,"aria-controls":f?E:void 0,onClick:z,children:f?"Close":"Review…"})]}),children:f&&n.jsx("ul",{id:E,className:"mt-1.5",children:S.map($=>n.jsx(Pn,{one:$,action:n.jsx(F,{size:"sm","data-part":"hide","aria-label":`Hide ${$.session.name} until it changes`,onClick:()=>q($),children:"Hide until it changes"})},$.session.id))})})}function Dn({ref:e,count:t,note:s,open:o,action:r,children:a}){return n.jsxs("section",{ref:e,"data-slot":"left-running","data-open":o||void 0,"aria-labelledby":"left-running-head",className:A("mx-2.5 mb-3 rounded-inner bg-fill-zebra px-3.5 pt-2 inset-ring inset-ring-hairline",o?"pb-3":"pb-2"),children:[n.jsxs("div",{className:"flex min-h-button flex-wrap items-center justify-between gap-x-3 gap-y-2",children:[n.jsxs("div",{className:"flex min-w-0 grow basis-32 flex-wrap items-baseline gap-x-2 gap-y-px",children:[n.jsxs("h3",{id:"left-running-head",className:"inline-flex items-baseline gap-1.5 text-caption font-semibold text-ink-secondary",children:["Left running",n.jsx(it,{children:t})]}),n.jsx("span",{"data-part":"note",className:"text-caption text-ink-secondary",children:s})]}),r&&n.jsx("div",{className:"flex items-center gap-3",children:r})]}),a]})}function je({value:e,onValueChange:t,options:s,label:o,className:r}){const a=s.findIndex(i=>i.value===e);return n.jsxs(nl,{"data-slot":"segmented-control","aria-label":o,orientation:"horizontal",value:e,onValueChange:i=>t(i),className:A("relative inline-grid rounded-capsule bg-well p-0.75","inset-ring inset-ring-control-rim inset-shadow-well",r),style:{gridTemplateColumns:`repeat(${s.length}, minmax(0, 1fr))`},children:[a!==-1&&n.jsx("span",{"aria-hidden":!0,"data-part":"thumb",className:A("pointer-events-none absolute inset-y-0.75 left-0.75 rounded-capsule bg-thumb","inset-ring inset-ring-control-rim inset-shadow-top shadow-thumb","motion-safe:transition-transform motion-safe:duration-220 motion-safe:ease-out"),style:{width:`calc((100% - 6px) / ${s.length})`,transform:`translateX(${a*100}%)`}}),s.map(i=>n.jsxs(sl,{value:i.value,"aria-label":i.name,onFocus:()=>{i.value!==e&&t(i.value)},className:A("relative flex h-control cursor-pointer items-center justify-center gap-2 rounded-capsule px-4","text-body font-medium whitespace-nowrap text-ink-secondary transition-colors duration-120","hover:text-ink data-[state=checked]:text-ink",i.icon!==void 0&&"pl-3"),children:[i.icon,i.label]},i.value))]})}function Zh(e){const t=p.useCallback(s=>{const o=window.matchMedia(e);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[e]);return p.useSyncExternalStore(t,()=>window.matchMedia(e).matches)}const ep="(max-width: 760px)";function vn(){return Zh(ep)}const tp=["list","repositories","board"],mi="agent-lookout-sessions-layout",Po="list";let fn=null;function np(){if(fn!==null)return fn;try{const e=localStorage.getItem(mi);return tp.find(t=>t===e)??Po}catch{return Po}}function sp(e){try{localStorage.setItem(mi,e),fn=null}catch{fn=e}}function op(){const[e,t]=p.useState(np),s=p.useCallback(o=>{sp(o),t(o)},[]);return[e,s]}const rp=[{value:"list",label:"List"},{value:"repositories",label:"Repos"},{value:"board",label:"Board"}];function ap({source:e}){const t=e.state==="unavailable",s=fe(e.id)?`${e.label} is not connected`:t?`${e.label} was not found`:`${e.label} could not be read`;return n.jsxs(G,{tone:t?"info":"error",title:s,children:[n.jsx("p",{children:n.jsx(V,{children:e.detail??(t?`Agent Lookout could not find ${e.label} on this computer.`:`Agent Lookout found ${e.label} but could not read its sessions.`)})}),n.jsx("p",{"data-part":"advice",children:e.advice?n.jsx(V,{children:e.advice}):t?`Install ${e.label} or start a session. It will show up here on its own.`:"It keeps trying. If this stays, restart Agent Lookout."})]})}function ht({sources:e,last:t}){return n.jsx("div",{className:A("flex flex-col gap-2 px-6",t?"pb-6":"pb-3"),children:e.map(s=>n.jsx(ap,{source:s},s.id))})}function ip(e,t){const s=e.filter(i=>!fe(i.id)),o=e.filter(i=>fe(i.id)),r=[];(s.length>0||o.length===0)&&r.push(`${ae(s)} on this computer`),o.length>0&&r.push(`the sessions on ${ae(o)}`);const a=pa(ha(t));return[`Agent Lookout is watching ${r.join(" and ")}.`,a].filter(Boolean).join(" ")}function lp({sources:e}){const t=e.filter(s=>s.state==="searching");return n.jsxs(_t,{title:"Looking for agents",children:[t.map(s=>n.jsx("p",{children:n.jsx(V,{children:s.detail??`Looking for ${s.label} sessions on this computer.`})},s.id)),n.jsx("p",{className:"mt-2 text-ink-muted",children:"It checks every two seconds. There is nothing you need to do."})]})}function Do({head:e,sessions:t,now:s,actionColumn:o,columns:r,narrow:a,agentOf:i,folderColumn:l,appColumn:d,...c}){return n.jsxs("tbody",{"data-slot":"session-group",...c,children:[n.jsx("tr",{"data-slot":"group-row",children:n.jsx("th",{scope:"rowgroup",colSpan:r,className:"h-group px-6 pt-2.5 pb-1.5 text-left align-bottom text-caption font-semibold text-ink-secondary",children:e})}),t.map(u=>n.jsx(jh,{session:u,now:s,actionColumn:o,narrow:a,agent:i?.(u),folderColumn:l,appColumn:d},u.id))]})}function cp({group:e}){const t=e.id!=="idle"||e.count>0;return n.jsxs("span",{className:"flex items-baseline gap-3.5",children:[t&&n.jsxs("span",{className:"inline-flex items-baseline gap-1.5",children:[e.label,n.jsx(it,{children:e.count})]}),e.id==="idle"&&e.stale>0&&n.jsxs("span",{"data-part":"stale",className:"inline-flex items-baseline gap-1.5",children:["Stale",n.jsx(it,{children:e.stale})]})]})}function dp({sessions:e,byRepository:t,...s}){if(!t)return as(e).map(r=>n.jsx(Do,{"data-group":r.id,head:n.jsx(cp,{group:r}),sessions:r.sessions,...s},r.id));const o=as(e).flatMap(r=>r.sessions);return vh(o).map(r=>n.jsx(Do,{"data-group":r.id===null?"no-repository":"repository","data-repository":r.id??void 0,head:n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx(ie,{"data-part":"repository",className:"min-w-0",children:r.label}),n.jsx(it,{children:r.sessions.length})]}),sessions:r.sessions,...s},r.id??""))}const xe={agent:6.25,folder:7,app:7,status:10,actions:6},up=12.5,fp=12,Fo={folder:!0,app:!0,folderRem:xe.folder};function mp(e,t,s,o){const[r,a]=p.useState(Fo);return p.useLayoutEffect(()=>{const i=e.current?.parentElement;if(!t||!i)return;const l=()=>{const c=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,u=up+xe.status+(s?xe.agent:0)+(o?xe.actions:0),f=i.clientWidth/c,h=f>=u+xe.folder,g=h&&f>=u+xe.folder+xe.app,x=f-(u+xe.folder+(g?xe.app:0)),w=Math.round(Math.min(fp,xe.folder+Math.max(0,x)/2)*4)/4;a(m=>m.folder===h&&m.app===g&&m.folderRem===w?m:{folder:h,app:g,folderRem:w})};l();const d=new ResizeObserver(l);return d.observe(i),()=>d.disconnect()},[e,t,s,o]),t?r:Fo}function hp({sessions:e,sources:t,now:s,onEnded:o,staleAfterMs:r,className:a}){const i=p.useRef(null),l=p.useRef(null),d=Xu(t),c=d.filter(L=>L.state==="unavailable"||L.state==="error"),u=d.some(L=>L.state==="searching"),f=as(e).flatMap(L=>L.sessions),[h,g]=op(),x=h==="board"&&e.length>0,w=f.some(L=>Ce(L)!==null),m=f.some(L=>Ga(L)!==null),v=w||m,b=(x?e:f).map(Ce).filter(L=>L!==null),k=b.some(L=>L.by==="tmux")?b.some(L=>L.by!=="tmux")?"Jump opens the session, or selects its pane in tmux":"Jump selects the session's pane in tmux":"Jump opens the session where it runs",N=ma(t,e),j=N?L=>Ts(L,t):void 0,E=vn(),S=N&&!E,{folder:y,app:C,folderRem:q}=mp(i,f.length>0&&!E&&!x,S,v),z=(E?1:2+(S?1:0)+(y?1:0)+(C?1:0))+(v?1:0),{counted:ee}=Ps(e,t);let $;if(x)$=n.jsxs(n.Fragment,{children:[c.length>0&&n.jsx(ht,{sources:c,last:!1}),n.jsx(Ih,{sessions:e,now:s,agentOf:j})]});else if(f.length>0)$=n.jsxs(n.Fragment,{children:[c.length>0&&n.jsx(ht,{sources:c,last:!1}),n.jsxs("table",{ref:i,"data-slot":"session-list",className:"mb-2.5 w-full table-fixed border-separate border-spacing-0",children:[n.jsxs("colgroup",{children:[n.jsx("col",{}),S&&n.jsx("col",{className:"w-25"}),y&&!E&&n.jsx("col",{style:{width:`${q}rem`}}),C&&!E&&n.jsx("col",{className:"w-28"}),!E&&n.jsx("col",{className:"w-40"}),v&&n.jsx("col",{className:"w-24"})]}),n.jsx("thead",{className:"sr-only",children:n.jsxs("tr",{children:[n.jsx("th",{scope:"col",children:"Session"}),S&&n.jsx("th",{scope:"col",children:"Agent"}),y&&!E&&n.jsx("th",{scope:"col",children:"Folder"}),C&&!E&&n.jsx("th",{scope:"col",children:"App"}),!E&&n.jsx("th",{scope:"col",children:"Status and time"}),v&&n.jsx("th",{scope:"col",children:w&&m?"Jump or resume":w?"Jump":"Resume"})]})}),n.jsx(dp,{sessions:e,byRepository:h==="repositories",now:s,actionColumn:v,columns:z,narrow:E,agentOf:j,folderColumn:y,appColumn:C})]})]});else if(e.length>0)$=n.jsxs(n.Fragment,{children:[c.length>0&&n.jsx(ht,{sources:c,last:!1}),n.jsx("p",{"data-part":"all-waiting",className:"px-6 pb-6 text-body text-ink-secondary",children:"Every session needs you. They are at the top of the page, longest wait first."})]});else if(u)$=n.jsx(lp,{sources:d});else if(c.length>0&&c.length===d.length)$=n.jsx(ht,{sources:c,last:!0});else{const L=d.filter(se=>se.state==="ok");$=n.jsxs(n.Fragment,{children:[c.length>0&&n.jsx(ht,{sources:c,last:!1}),n.jsx(_t,{title:"No agents are running",children:n.jsxs("p",{children:[ip(L,t)," A session shows up here within a few seconds of starting."]})})]})}const W=b.length>0&&n.jsx("span",{"data-part":"hint",className:"max-mid:hidden @max-[42rem]:hidden",children:k}),D=e.length>0&&n.jsx(je,{label:"Show sessions as",value:h,onValueChange:g,options:rp,className:E?void 0:"-my-2.5"});return n.jsxs(U,{title:"Sessions",titleRef:l,count:ee?e.length:void 0,aside:D&&!E?n.jsxs("div",{className:"flex items-center gap-4",children:[W,D]}):W||void 0,className:A("@container",a),children:[D&&E&&n.jsx("div",{"data-part":"layout",className:"flex px-6 pb-1",children:D}),n.jsx(Qh,{sessions:e,now:s,onEnded:o,onGone:()=>l.current?.focus(),staleAfterMs:r}),$]})}const pp={...Ms,stale:"Stale",unmeasured:"Not measured"};function xp({segment:e,from:t,share:s}){switch(e.kind){case"needs-you":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:A("block h-bar-needs-you w-full rounded-bar",e.open?"bar-open bar-glow":"bar-answered")});case"working":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"bar-working block h-bar-working w-full rounded-capsule"});case"idle":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"bar-idle block h-bar-idle w-full rounded-capsule"});case"stale":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"stale-dots block h-bar-idle w-full"});case"unknown":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"block h-1.5 w-full rounded-bar inset-ring inset-ring-status-idle"});case"finished":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"absolute left-0 h-3 w-0.5 rounded-bar bg-status-finished"});case"failed":return n.jsx("svg",{"aria-hidden":!0,"data-part":"mark",viewBox:"0 0 10 10",fill:"none",className:"absolute left-0 size-2.5 -translate-x-1/2 text-status-finished",children:n.jsx("path",{d:"M2 2l6 6M8 2l-6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})});case"unmeasured":return n.jsx("span",{"aria-hidden":!0,"data-part":"hatch",className:"absolute inset-0",style:{clipPath:"inset(3px 2px 3px 0 round var(--radius-bar))"},children:n.jsx("span",{className:"unmeasured-hatch absolute inset-y-0",style:{left:Ue(-t/s),width:Ue(1/s)}})})}}const gp=.01,wp={ArrowLeft:e=>Math.max(0,e-1),ArrowRight:(e,t)=>Math.min(t,e+1),Home:()=>0,End:(e,t)=>t};function bp(e){const t=e.to-e.from,s=e.kind==="needs-you"&&e.open===!0,o=e.startKnown===!1||s&&!e.ongoing,r=a=>[o&&"at least",a,e.ongoing&&"so far"].filter(Boolean).join(" ");return{status:e.kind==="needs-you"&&!s?"Needed you":pp[e.kind],lasted:r(Y(t)),lastedInWords:r(ke(t)),clock:`${me(e.from)} to ${e.ongoing?"now":me(e.to)}`}}function Ue(e){return`${Math.round(e*1e5)/1e3}%`}function yp(e,t,s){const o=s-t,r=e.filter(a=>a.kind==="unmeasured").map(a=>{const i=Ue((Math.max(a.from,t)-t)/o),l=`calc(${Ue((Math.min(a.to,s)-t)/o)} - 2px)`;return`black ${i}, transparent ${i} ${l}, black ${l}`});return`linear-gradient(to right, black, ${r.join(", ")}${r.length?", ":""}black)`}function kp({segments:e,start:t,end:s,label:o,rules:r=[],className:a}){const i=p.useRef(null),[l,d]=p.useState(null),c=s-t,u=c>0?e.filter(w=>w.to>w.from&&w.to>t&&w.from<s):[],f=u.length-1,h=l===null?-1:u.findIndex(w=>w.to===l),g=h===-1?f:h,x=w=>{const m=wp[w.key];if(!m||f<0)return;w.preventDefault(),i.current?.querySelectorAll('[data-part="segment"]')?.[m(g,f)]?.focus()};return n.jsxs("div",{ref:i,"data-slot":"status-track",role:"group","aria-label":`${o}: status over time. Arrow keys move along it.`,onKeyDown:x,className:A("relative h-track w-full",a),children:[c>0&&r.some(w=>w>t&&w<s)&&n.jsx("span",{"aria-hidden":!0,"data-part":"rules",className:"pointer-events-none absolute inset-0",style:{maskImage:yp(u,t,s)},children:r.filter(w=>w>t&&w<s).map(w=>n.jsx("span",{className:"absolute inset-y-0 w-px bg-hairline",style:{left:Ue((w-t)/c)}},w))}),u.map((w,m)=>{const v=Math.max(w.from,t),k=(Math.min(w.to,s)-v)/c,N=bp(w);return n.jsx(ne,{content:n.jsxs("span",{className:"flex flex-col",children:[n.jsx("span",{children:N.status}),n.jsx("span",{className:"font-mono text-fact text-ink-secondary",children:N.lasted}),n.jsx("span",{className:"font-mono text-fact text-ink-muted",children:N.clock})]}),children:n.jsx("span",{"data-part":"segment","data-kind":w.kind,"data-open":w.kind==="needs-you"?!!w.open:void 0,role:"img","aria-label":`${N.status}, ${N.lastedInWords}, ${N.clock}`,tabIndex:m===g?0:-1,onFocus:()=>d(m===f?null:w.to),className:A("absolute inset-y-0 flex min-w-0.75 items-center pr-0.5 focus-visible:z-20",k<gp&&"z-10 before:absolute before:inset-y-0 before:-inset-x-1"),style:{left:`min(${Ue((v-t)/c)}, calc(100% - 3px))`,width:Ue(k)},children:n.jsx(xp,{segment:w,from:(v-t)/c,share:k})})},m===f?"present":w.to)})]})}const jp=6,Np=96,vp=20,Sp=100;function Ap(e,t){return(e-t.start)/(t.end-t.start)}function Ep(e){return`${Math.round(e*1e5)/1e3}%`}function Tp(e){return e.status===null?null:e.stale&&e.status==="idle"?"stale":e.status}function Mp({row:e,timeline:t,rules:s,named:o}){const r=Tp(e),a=e.status==="needs-you",i=rt(e.id),l=It(e.name,i);return n.jsxs("li",{"data-slot":"timeline-row","data-ended":e.ended,className:"flex h-track items-center rounded-row odd:bg-fill-zebra",children:[o&&n.jsxs("div",{className:A("flex w-label-col shrink-0 items-center gap-3 px-3 text-body",a?"font-semibold text-ink":"font-medium text-ink-secondary"),children:[r?n.jsx(te,{kind:r}):n.jsx("span",{"aria-hidden":!0,"data-part":"no-mark",className:"size-mark shrink-0"}),n.jsxs(ie,{"data-part":"name",tooltip:l,children:[e.name,n.jsx(gn,{machine:i,className:"text-ink-muted"})]})]}),n.jsx(kp,{segments:e.segments,start:t.start,end:t.end,label:e.ended?`${l}, ended`:l,rules:s,className:"min-w-0 flex-1"})]})}const Jt="block h-2.5 w-3.5 rounded-bar",Uo="block h-bar-idle w-3.5",Cp=[{kind:"needs-you",label:"Needs you",swatch:n.jsx("i",{className:A(Jt,"bar-open")})},{kind:"answered",label:"Answered",swatch:n.jsx("i",{className:A(Jt,"bar-answered")})},{kind:"working",label:"Working",swatch:n.jsx("i",{className:A(Jt,"bar-working")})},{kind:"idle",label:"Idle",swatch:n.jsx("i",{className:A(Uo,"bar-idle rounded-capsule")})},{kind:"stale",label:"Stale",swatch:n.jsx("i",{className:A(Uo,"stale-dots")})},{kind:"finished",label:"Finished",swatch:n.jsx("i",{className:"mx-1.5 block h-3 w-0.5 rounded-bar bg-status-finished"})},{kind:"failed",label:"Failed",swatch:n.jsx(te,{kind:"failed",className:"size-2.5"})},{kind:"unknown",label:"Unknown",swatch:n.jsx("i",{className:"block h-1.5 w-3.5 rounded-bar inset-ring inset-ring-status-idle"})},{kind:"unmeasured",label:"Not measured",swatch:n.jsx("i",{className:A(Jt,"unmeasured-hatch")})}];function Ip({timeline:e}){const t=new Set(["answered","working","idle","stale","finished","unmeasured"]);for(const s of e.rows)for(const o of s.segments)o.kind==="needs-you"&&o.open&&t.add("needs-you"),(o.kind==="failed"||o.kind==="unknown")&&t.add(o.kind);return n.jsx("ul",{"data-slot":"timeline-legend","aria-label":"Legend",className:"flex flex-wrap items-center gap-x-3.5 gap-y-1.5 text-caption text-ink-secondary",children:Cp.filter(s=>t.has(s.kind)).map(s=>n.jsxs("li",{"data-kind":s.kind,className:"flex items-center gap-1.5 whitespace-nowrap",children:[n.jsx("span",{"aria-hidden":!0,className:"flex items-center",children:s.swatch}),s.label]},s.kind))})}function $p(e,t){if(t<=0)return[];const s=Math.max(1,Math.min(jp,Math.floor(t/Np)));return Qr(e.start,e.end,s).map(o=>({at:o,share:Ap(o,e)})).filter(({share:o})=>o*t>=vp&&o*t<=t-Sp).map(({at:o,share:r})=>({at:o,left:Ep(r)}))}function Lp({timeline:e,rows:t=e.rows,named:s=!0,label:o="Sessions over the last hour",className:r="px-6 pb-4.5"}){const[a,i]=Ba(),l=$p(e,i),d=l.map(c=>c.at);return n.jsxs("div",{className:r,children:[n.jsx("ul",{"data-slot":"timeline-rows","aria-label":o,children:t.map(c=>n.jsx(Mp,{row:c,timeline:e,rules:d,named:s},c.id))}),n.jsxs("div",{ref:a,"data-slot":"timeline-axis","aria-hidden":!0,className:A("relative mt-2 h-5.5 border-t border-rule font-mono text-micro leading-none text-ink-muted",s&&"ml-label-col"),children:[l.map(c=>n.jsx("span",{"data-part":"time-tick",className:"absolute top-2 -translate-x-1/2 whitespace-nowrap before:absolute before:-top-2 before:left-1/2 before:h-1 before:w-px before:bg-rule-strong",style:{left:c.left},children:Q(c.at)},c.at)),n.jsxs("span",{"data-part":"now",className:"absolute top-2 right-0 whitespace-nowrap text-ink-secondary before:absolute before:-top-2 before:right-0 before:h-1 before:w-px before:bg-rule-strong",children:[Q(e.end)," now"]})]})]})}function _p({sessions:e,sources:t=[],events:s,history:o,now:r,asOf:a=r,staleAfterMs:i,className:l}){const d=p.useMemo(()=>e&&o?Sa({sessions:e,events:s,history:o,now:r,asOf:a,eventsFull:s.length>=xn,staleAfterMs:i}):null,[e,s,o,r,a,i]);let c;if(e===null)c=n.jsx(be,{label:"Reading the last hour"});else if(d===null)c=n.jsx("div",{className:"px-6 pb-6",children:n.jsx(G,{tone:"error",title:"The last hour could not be read",children:n.jsx("p",{children:"Agent Lookout did not answer when asked for its history. The page asks again every two seconds."})})});else if(d.rows.length>0)c=n.jsx(Lp,{timeline:d});else if(t.some(u=>u.state==="searching"))c=n.jsx(be,{label:"Looking for sessions"});else if(!t.some(u=>u.state==="ok"))c=n.jsx("div",{className:"px-6 pb-6",children:n.jsx(G,{title:"The last hour was not measured",children:n.jsx("p",{children:"No source could be read, so there is no status to draw. The Sessions card says why."})})});else{const u=ka({from:d.start,to:d.end},d.unmeasured);c=n.jsx(_t,{compact:!0,title:u?`No sessions ${u}`:"Nothing was measured in the last hour",children:n.jsx("p",{children:"When a session runs, its status over time is drawn here."})})}return n.jsx(U,{title:"Timeline",sub:"last hour, one row per session",aside:d&&d.rows.length>0?n.jsx(Ip,{timeline:d}):void 0,className:l,children:c})}const Op=3e4,Rp=4e3;async function Wp(){try{const e=await Z("/api/waits",{headers:{accept:"application/json"},signal:AbortSignal.timeout(Rp)});return e.ok?Mu(await e.json()):null}catch{return null}}function _e(e){return e.measuredMs>0}function zs(e){return _e(e)?e.waits===0?"No waits":`${e.waits} ${e.waits===1?"wait":"waits"}`:"Not measured"}const Pp=new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}),Dp=new Intl.DateTimeFormat(void 0,{weekday:"long",month:"long",day:"numeric"});function cs(e,t,s=!1){const o=le(t),r=le(e.from);if(r===o)return"Today";const a=new Date(o);return a.setDate(a.getDate()-1),r===a.getTime()?"Yesterday":(s?Dp:Pp).format(new Date(e.from))}function hi(e,t){return le(e.from)===le(t)?e.openMs:0}function Fp(e,t){const s=cs(e,t,!0);if(!_e(e))return`${s}: not measured`;const o=e.waits===0?"no session waited":`waited ${ke(e.waitedMs)} in ${zs(e).toLowerCase()}`,r=hi(e,t)>0?", still waiting":"";return`${s}: ${o}${r}, measured for ${ke(e.measuredMs)}`}function Xt(e,t){return _e(e)?`${Y(e.measuredMs)} of ${t}`:`none of ${t}`}function Up(e){const{today:t,sevenDays:s,since:o,at:r}=e;if(e.where==="memory"){const i=s.measuredMs===t.measuredMs?"":`, and ${Xt(s,"the last 7 days")}`;return`History is kept in memory only, because AGENT_LOOKOUT_HISTORY is set to off, so only the time since Agent Lookout started at ${ue(o.at,r)} is counted: ${Xt(t,"today")} so far${i}.`}const a=`Only the time Agent Lookout was running is counted: ${Xt(t,"today")} so far, and ${Xt(s,"the last 7 days")}.`;return o.at<=s.from?a:o.by==="cleared"?`${a} The history was cleared at ${ue(o.at,r)}.`:`${a} The history it keeps begins at ${ue(o.at,r)}.`}function zp(e,t){const s=t-e.at;if(s<=0||le(t)!==le(e.at)||!_e(e.today))return e;const o=new Set([...e.today.sessions,...e.sevenDays.sessions].filter(l=>l.open).map(l=>l.sessionId)),r=l=>({...l,waitedMs:l.waitedMs+o.size*s,openMs:l.openMs+o.size*s,measuredMs:l.measuredMs+s}),a=l=>l.open?{...l,waitedMs:l.waitedMs+s}:l,i=l=>({...r(l),to:t,days:l.days.map((d,c)=>c===l.days.length-1?{...r(d),to:t}:d),sessions:l.sessions.map(a).sort((d,c)=>c.waitedMs-d.waitedMs||d.name.localeCompare(c.name))});return{...e,at:t,today:i(e.today),sevenDays:i(e.sevenDays)}}function Hp(e,t){const s=t==="today"?"today":"in the last 7 days";return _e(e)?`No session waited on you ${s}.`:`Nothing was measured ${s}.`}function Bp(e,t){const[s,o]=p.useState(null),[r,a]=p.useState(!1),i=e?.startedAt??null,l=e?ye(e).at:null,d=[...t].sort().join(" ");return p.useEffect(()=>{let c=!0;const u=()=>{Wp().then(g=>{c&&(g&&o(g),a(g===null))})},f=()=>{document.hidden||u()};u();const h=setInterval(f,Op);return document.addEventListener("visibilitychange",f),()=>{c=!1,clearInterval(h),document.removeEventListener("visibilitychange",f)}},[i,l,d]),s?{waits:s,status:"ready"}:{waits:null,status:r?"failed":"loading"}}const pi="–",qp=15*6e4,Gp=5,Kp=[{value:"today",label:"Today"},{value:"sevenDays",label:"7 days"}];function Vp(e){return`${Math.round(e*1e5)/1e3}%`}function Yp({today:e}){return n.jsx("p",{"data-part":"sum",className:"text-body text-ink-secondary",children:_e(e)?e.waits===0?"No session waited on you today":n.jsxs(n.Fragment,{children:["Sessions waited on you for"," ",n.jsx("span",{className:"font-semibold text-ink tabular-nums",children:Y(e.waitedMs)})," ","today, in ",zs(e).toLowerCase()]}):"Nothing was measured today"})}function zo({label:e,total:t,className:s}){const o=_e(t);return n.jsxs("div",{"data-part":"figure",className:A("min-w-0",s),children:[n.jsx("dt",{className:"text-body font-medium text-ink-secondary",children:e}),n.jsxs("dd",{"data-part":"value",className:"mt-2 text-stat font-medium whitespace-nowrap tabular-nums",children:[n.jsx("span",{className:"sr-only",children:o?ke(t.waitedMs):"Not measured"}),n.jsx("span",{"aria-hidden":!0,children:o?Y(t.waitedMs):pi})]}),n.jsx("dd",{"data-part":"count",className:"mt-2 text-caption text-ink-muted",children:zs(t)})]})}function Jp({day:e,scale:t,now:s}){const o=_e(e),r=cs(e,s)==="Today",a=hi(e,s),i=e.waitedMs-a;return n.jsxs("li",{"data-part":"day","data-day":e.day,"data-open":a>0,className:"flex items-center gap-4 text-body leading-5 max-mid:grid max-mid:grid-cols-[minmax(0,1fr)_auto] max-mid:gap-x-4 max-mid:gap-y-1.5",children:[n.jsx("span",{"data-part":"label",className:A("w-waited-name shrink-0 max-mid:col-start-1 max-mid:row-start-1 max-mid:w-auto",r?"font-semibold text-ink":"font-medium text-ink-secondary"),children:cs(e,s)}),n.jsx("span",{"data-part":"track",role:"img","aria-label":Fp(e,s),className:"relative h-2.5 min-w-0 flex-1 before:absolute before:inset-x-0 before:top-1/2 before:h-px before:bg-hairline max-mid:col-start-1 max-mid:row-start-2",children:o?e.waitedMs>0?n.jsxs("span",{"data-part":"bar",className:"absolute inset-y-0 left-0 flex min-w-0.5 gap-0.5",style:{width:Vp(Math.min(1,e.waitedMs/t))},children:[i>0&&n.jsx("i",{"data-kind":"answered",className:"block h-full min-w-0.5 rounded-bar bar-answered",style:{flexGrow:i,flexBasis:0}}),a>0&&n.jsx("i",{"data-kind":"open",className:"block h-full min-w-0.5 rounded-bar bar-open",style:{flexGrow:a,flexBasis:0}})]}):null:n.jsx("i",{"data-part":"unmeasured",className:"unmeasured-hatch absolute inset-0 block rounded-bar"})}),n.jsx("span",{"data-part":"value","aria-hidden":!0,className:"w-16 shrink-0 text-right whitespace-nowrap text-ink tabular-nums max-mid:col-start-2 max-mid:row-start-1 max-mid:justify-self-end",children:o?Y(e.waitedMs):pi}),n.jsx("span",{"data-part":"measured","aria-hidden":!0,className:"w-30 shrink-0 text-right text-caption whitespace-nowrap text-ink-muted tabular-nums max-mid:col-start-2 max-mid:row-start-2",children:o?`measured ${Y(e.measuredMs)}`:"not measured"})]})}function Xp({period:e,now:t}){const s=p.useId(),o=Math.max(0,...e.days.map(a=>a.waitedMs)),r=Math.max(qp,o);return n.jsxs("section",{"data-part":"by-day","aria-labelledby":s,className:"min-w-0",children:[n.jsx("h3",{id:s,className:"text-caption font-semibold text-ink-secondary",children:"By day"}),n.jsx("ul",{className:"mt-3 grid grid-cols-1 gap-2.5",children:e.days.map(a=>n.jsx(Jp,{day:a,scale:r,now:t},a.day))})]})}function Qp({waits:e,period:t,onPeriod:s}){const o=p.useId(),r=e[t],a=r.sessions.slice(0,Gp),i=r.sessionCount-a.length;return n.jsxs("section",{"data-part":"longest","aria-labelledby":o,className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4 max-mid:flex-col max-mid:items-start max-mid:gap-2.5",children:[n.jsx("h3",{id:o,className:"text-caption font-semibold text-ink-secondary",children:"Longest waits"}),n.jsx(je,{label:"Longest waits over",value:t,onValueChange:s,options:Kp,className:"-my-2.5 max-mid:my-0"})]}),a.length>0?n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"mt-1.5",children:a.map(l=>n.jsxs("li",{"data-part":"session","data-open":l.open,className:"flex items-start justify-between gap-4 border-b border-hairline py-2.5 last:border-b-0",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs(ie,{"data-part":"name",tooltip:It(l.name,rt(l.sessionId)),className:"block text-body font-semibold text-ink",children:[l.name,n.jsx(gn,{machine:rt(l.sessionId),className:"text-ink-secondary"})]}),n.jsxs("p",{"data-part":"times",className:"mt-0.5 text-caption text-ink-secondary",children:[l.waits," ",l.waits===1?"wait":"waits",l.open&&", waiting now"]})]}),n.jsxs("p",{"data-part":"value",className:"shrink-0 text-body font-medium whitespace-nowrap text-ink tabular-nums",children:[n.jsx("span",{className:"sr-only",children:ke(l.waitedMs)}),n.jsx("span",{"aria-hidden":!0,children:Y(l.waitedMs)})]})]},l.sessionId))}),i>0&&n.jsxs("p",{"data-part":"more",className:"mt-1 text-caption text-ink-muted",children:["and ",i," more"]})]}):n.jsx("p",{"data-part":"none",className:"mt-4 text-body text-ink-secondary",children:Hp(r,t)})]})}function Zp({waits:e}){const[t,s]=p.useState("today");return n.jsxs("div",{"data-part":"waits",className:"px-6 pb-5.5",children:[n.jsx(Yp,{today:e.today}),n.jsxs("dl",{className:"mt-4 flex items-start gap-6 max-mid:flex-col max-mid:gap-4",children:[n.jsx(zo,{label:"Today",total:e.today}),n.jsx(zo,{label:"Last 7 days",total:e.sevenDays,className:"border-l border-rule pl-6 max-mid:border-l-0 max-mid:pl-0"})]}),n.jsx("p",{"data-part":"coverage",className:"mt-4 max-w-3xl text-caption text-pretty text-ink-secondary",children:Up(e)}),n.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-x-12 gap-y-7 max-wide:grid-cols-1",children:[n.jsx(Xp,{period:e.sevenDays,now:e.at}),n.jsx(Qp,{waits:e,period:t,onPeriod:s})]})]})}function ex({history:e,sessions:t,asOf:s,className:o}){const r=t.filter(i=>i.status==="needs-you").map(i=>i.id),a=Bp(e,r);return n.jsx(U,{title:"Waits",className:o,children:a.waits?n.jsx(Zp,{waits:zp(a.waits,s)}):a.status==="failed"?n.jsx("div",{className:"px-6 pb-5",children:n.jsx(G,{tone:"error",title:"How long sessions waited could not be read",children:n.jsx("p",{children:"Agent Lookout did not answer when asked for it. The page asks again every 30 seconds."})})}):n.jsx(be,{label:"Reading waits"})})}function tx(e){return e!==null&&e.isConnected&&e.tabIndex>=0}function nx(e,t,s="jump"){const o=p.useRef(null),r=p.useRef(null);return p.useLayoutEffect(()=>{const l=r.current,d=o.current;if(!l||!d)return;const c=document.activeElement;if(c===l.element)return;if(c!==null&&c!==document.body){r.current=null;return}let u=l.element.isConnected?l.element:null;if(!u){const f=[...d.querySelectorAll(e)].filter(x=>x.getAttribute(t)===l.key),h=f.find(x=>x.getAttribute("data-slot")===l.slot)??f[0],g=x=>x===null?null:h?.querySelector(`[data-part="${x}"]`)??null;u=[g(l.part),g(s)].find(tx)??null}u?u.focus():r.current=null}),[o,{onFocus:l=>{const d=l.target,c=d.closest(e),u=c?.getAttribute(t);r.current=u?{key:u,slot:c?.getAttribute("data-slot")??null,part:d.getAttribute("data-part"),element:d}:null},onBlur:l=>{const d=l.relatedTarget;if(d instanceof Node&&o.current?.contains(d))return;if(d!==null){r.current=null;return}const c=l.target;setTimeout(()=>{r.current?.element===c&&c.isConnected&&(r.current=null)})}}]}const xi=['[data-slot="hero-session"]','[data-slot="session-row"]','[data-slot="board-card"]'],sx=xi.join(", ");function Ho(e,t){if(Ce(t)===null){dn(t.id);return}if(!e)return;const s=CSS.escape(t.id),o=e.querySelector(xi.map(a=>`${a}[data-session="${s}"]`).join(", ")),r=o?.querySelector('[data-part="jump"]');if(!o||!r){dn(t.id);return}o.scrollIntoView({block:"center"}),r.focus({preventScroll:!0,focusVisible:!0}),r.click()}function ox(e,t){const s=p.useRef(null);return p.useEffect(()=>{if(t!=="overview"||s.current===null)return;const o=s.current;s.current=null,Ho(e.current,o)},[e,t]),p.useCallback(o=>{if(t==="overview"){Ho(e.current,o);return}s.current=o,window.location.hash="#overview"},[e,t])}const pe={hero:"col-start-1 row-start-1",lastHour:"col-start-2 row-start-1 max-wide:col-start-1 max-wide:row-start-2",sessions:"col-start-1 row-start-2 max-wide:row-start-3",events:"col-start-2 row-start-2 max-wide:col-start-1 max-wide:row-start-4",timeline:"col-span-2 col-start-1 row-start-3 max-wide:col-span-1 max-wide:row-start-5",waits:"col-span-2 col-start-1 row-start-4 max-wide:col-span-1 max-wide:row-start-6"};function rx({state:e,now:t,onRetry:s,onEnded:o,onAnswered:r,onOpenHistory:a,newSince:i=null,onNewLineInView:l}){const{snapshot:d,phase:c}=e,[u,f]=nx(sx,"data-session");if(!d&&c==="unreachable")return n.jsx(pf,{problem:e.problem,kind:e.problemKind,onRetry:s});const h=c==="stalled"&&e.lastOkAt!==null?e.lastOkAt:t,g=d?.sessions??null,x=d?.sources??[],w=pl(d?.timeRules),m=Na(Ps(g,x));return n.jsxs("div",{"data-slot":"dashboard","data-phase":c,className:"flex flex-col gap-4",children:[d&&c==="stalled"&&e.lastOkAt!==null&&n.jsx(hf,{lastOkAt:e.lastOkAt,now:t,onRetry:s}),n.jsxs("div",{ref:u,...f,"data-slot":"overview-grid",className:"relative isolate grid grid-cols-[minmax(0,1.75fr)_minmax(0,1fr)] gap-4 max-wide:grid-cols-1",children:[m&&n.jsx("div",{"aria-hidden":!0,"data-slot":"hero-light","data-light":m,className:A(m==="lamp"?"lamp-light":"rest-light",pe.hero)},m),n.jsx(Bm,{sessions:g,sources:x,events:e.events,history:e.history,now:t,asOf:h,onOpenHistory:a,onAnswered:r,staleAfterMs:w,className:A("z-1",pe.hero)}),n.jsx(rh,{sessions:g,sources:x,events:e.events,history:e.history,now:t,asOf:h,className:A("z-1",pe.lastHour)}),d?n.jsxs(n.Fragment,{children:[n.jsx(hp,{sessions:d.sessions,sources:d.sources,now:h,onEnded:o,staleAfterMs:w,className:A("z-1",pe.sessions)}),n.jsx(Rf,{events:e.events,sessions:d.sessions,history:e.history,now:t,newSince:i,onNewLineInView:l,className:A("z-1",pe.events)})]}):n.jsxs(n.Fragment,{children:[n.jsx(U,{title:"Sessions",className:A("z-1",pe.sessions),children:n.jsx(be,{label:"Reading sessions"})}),n.jsx(U,{title:"Events",className:A("z-1",pe.events),children:n.jsx(be,{label:"Reading events"})})]}),n.jsx(_p,{sessions:g,sources:x,events:e.events,history:e.history,now:t,asOf:h,staleAfterMs:w,className:A("z-1",pe.timeline)}),d?n.jsx(ex,{history:e.history,sessions:d.sessions,asOf:h,className:A("z-1",pe.waits)}):n.jsx(U,{title:"Waits",className:A("z-1",pe.waits),children:n.jsx(be,{label:"Reading waits"})})]})]})}function ax({className:e}){return n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round",className:A("size-icon shrink-0",e),children:[n.jsx("rect",{x:"2.75",y:"3.25",width:"14.5",height:"4",rx:"1"}),n.jsx("rect",{x:"2.75",y:"10.25",width:"8.5",height:"6.5",rx:"1"}),n.jsx("rect",{x:"14.25",y:"10.25",width:"3",height:"6.5",rx:"1"})]})}function ix({className:e}){return n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:A("size-icon shrink-0",e),children:[n.jsx("path",{d:"M2.75 4.5h4l3.4 4.2M2.75 10h7.5M2.75 15.5h4l3.4-4.2"}),n.jsx("circle",{cx:"13.75",cy:"10",r:"3.25"})]})}function lx({className:e}){return n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:A("size-icon shrink-0",e),children:[n.jsx("path",{d:"M2.75 6.25h7M14.75 6.25h2.5M2.75 13.75h2.5M10.25 13.75h7"}),n.jsx("circle",{cx:"12.25",cy:"6.25",r:"2.25"}),n.jsx("circle",{cx:"7.75",cy:"13.75",r:"2.25"})]})}function gi({className:e}){return n.jsx("svg",{"data-slot":"icon",viewBox:"0 0 14 14","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",className:A("size-mark shrink-0",e),children:n.jsx("path",{d:"M11.9 8.4A5.2 5.2 0 0 1 5.6 2.1a5.2 5.2 0 1 0 6.3 6.3z"})})}function wi({className:e}){return n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 14 14","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",className:A("size-mark shrink-0",e),children:[n.jsx("circle",{cx:"7",cy:"7",r:"2.6"}),n.jsx("path",{d:"M7 1v1.4M7 11.6V13M1 7h1.4M11.6 7H13M2.8 2.8l1 1M10.2 10.2l1 1M2.8 11.2l1-1M10.2 3.8l1-1"})]})}const bi="agent-lookout-theme",Bo="dark",yi="(prefers-color-scheme: light)";function cx(e){return e==="light"||e==="dark"||e==="system"}function dx(){try{const e=localStorage.getItem(bi);return cx(e)?e:Bo}catch{return Bo}}function ki(){return window.matchMedia(yi).matches?"light":"dark"}function ji(e){return e==="system"?ki():e}let jt=null;const tn=new Set;let Nt=null;function Ni(){const e=getComputedStyle(document.documentElement).getPropertyValue("--ground-top").trim();if(e==="")return;let t=document.head.querySelector('meta[name="theme-color"]');t||(t=document.createElement("meta"),t.name="theme-color",document.head.append(t)),t.content!==e&&(t.content=e)}function vi(e){jt=e,document.documentElement.setAttribute("data-theme",e.resolved),Ni();for(const t of tn)t()}function ux(){if(Nt)return;const e=window.matchMedia(yi),t=()=>{jt?.preference==="system"&&vi({preference:"system",resolved:ki()})};e.addEventListener("change",t),Nt=()=>e.removeEventListener("change",t)}function Si(){if(!jt){const e=dx();jt={preference:e,resolved:ji(e)}}return jt}function fx(e){tn.add(e),ux();const{resolved:t}=Si();return document.documentElement.getAttribute("data-theme")!==t&&document.documentElement.setAttribute("data-theme",t),Ni(),()=>{tn.delete(e),tn.size===0&&Nt&&(Nt(),Nt=null)}}function mx(e){try{localStorage.setItem(bi,e)}catch{}vi({preference:e,resolved:ji(e)})}function Ai(){return{...p.useSyncExternalStore(fx,Si),setPreference:mx}}const hx=[{value:"dark",label:"Night",name:"Dark theme",icon:n.jsx(gi,{})},{value:"light",label:"Day",name:"Light theme",icon:n.jsx(wi,{})}];function px({className:e}){const{resolved:t,setPreference:s}=Ai();if(vn()){const r=t==="dark"?"light":"dark",a=r==="light"?"Switch to Day":"Switch to Night";return n.jsx(ne,{content:a,align:"end",children:n.jsx(F,{size:"icon","aria-label":a,"data-part":"theme",onClick:()=>s(r),className:e,children:t==="dark"?n.jsx(gi,{}):n.jsx(wi,{})})})}return n.jsx(je,{label:"Theme",value:t,onValueChange:s,options:hx,className:e})}const xx=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function gx(e){if(!e)return!1;if(e.isContentEditable===!0)return!0;switch(e.tagName){case"TEXTAREA":case"SELECT":return!0;case"INPUT":return!xx.has((e.type??"text").toLowerCase());default:return!1}}function Hs(e=typeof navigator>"u"?"":navigator.platform||navigator.userAgent||""){return/Mac|iPhone|iPad|iPod/.test(e)}function wx(e){return/^[a-z]$/i.test(e.key)?e.key.toLowerCase():e.code?.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function bx(e,{mac:t,typing:s}){return(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey&&!e.shiftKey&&wx(e)==="k"?"search":s||e.metaKey||e.ctrlKey||e.altKey?null:e.key==="/"?"search":e.key==="?"?"shortcuts":null}function Ei(e){return e?{shown:"⌘K",said:"Command K"}:{shown:"Ctrl+K",said:"Control K"}}function yx(e){return e?"/ Meta+K":"/ Control+K"}const qo=[{shown:"←",said:"Left arrow"},{shown:"→",said:"Right arrow"}];function kx(e){return[{title:"On every view",rows:[{does:"Find a session",keys:[{shown:"/"},Ei(e)]},{does:"Show these shortcuts",keys:[{shown:"?"}]},{does:"Close a dialog",keys:[{shown:"Esc",said:"Escape"}]}]},{title:"In the search",rows:[{does:"Move through the sessions",keys:[{shown:"↑",said:"Up arrow"},{shown:"↓",said:"Down arrow"}]},{does:"Jump to the session, or open its details",keys:[{shown:"Enter"}]}]},{title:"In a chart or the timeline",rows:[{does:"Move along it",keys:qo},{does:"Go to the first or the last",keys:[{shown:"Home"},{shown:"End"}]},{does:"Ten steps in a history chart",keys:[{shown:"Page Up"},{shown:"Page Down"}]}]},{title:"In a switch",rows:[{does:"Choose the next or the previous option",keys:qo}]}]}function jx({onSearch:e}){const t=Hs();return n.jsx(ne,{content:`Find a session: / or ${Ei(t).shown}`,align:"end",children:n.jsx(F,{size:"icon","aria-label":"Find a session","aria-haspopup":"dialog","aria-keyshortcuts":yx(t),"data-part":"search",onClick:e,children:n.jsx(Fr,{"aria-hidden":!0,className:"size-4",strokeWidth:1.75})})})}function Nx({phase:e,snapshot:t,lastOkAt:s,now:o,onSearch:r}){const a=ff(e,t,o,s),i=vn();return n.jsxs("header",{"data-slot":"header",className:"glass-chrome glass-blur sticky top-window z-30 flex h-header shrink-0 items-center gap-5 pr-2.5 pl-6 max-mid:gap-2 max-mid:pl-4",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-5 max-mid:flex-col max-mid:items-start max-mid:gap-0.5",children:[n.jsx("h1",{className:"shrink-0 text-wordmark font-semibold whitespace-nowrap",children:"Agent Lookout"}),n.jsxs("p",{"data-slot":"status-line","data-status":a.key,className:"flex max-w-full min-w-0 items-baseline gap-3 border-l border-rule pl-5 text-body text-ink-secondary max-mid:border-l-0 max-mid:pl-0",children:[n.jsx("a",{href:"#sources",className:"truncate rounded-bar transition-colors duration-120 hover:text-ink",children:i?a.short:a.text}),a.fact&&n.jsx("span",{"data-part":"checked","aria-hidden":a.fact.ticking||void 0,className:A("shrink-0 text-caption whitespace-nowrap text-ink-muted tabular-nums",a.fact.ticking&&"max-wide:hidden"),children:a.fact.text})]})]}),n.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2.5 max-mid:gap-1.5",children:[r&&n.jsx(jx,{onSearch:r}),n.jsx(px,{})]})]})}function Ti(e){return e.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function vx(e){return Ti(e).split(/\s+/u).filter(Boolean)}function Sx(e,t){return Ti([e.name,e.project,e.git?.branch,e.git?.commit,t,e.machine].filter(s=>typeof s=="string").join(" "))}function Ax(e,t,s){const o=Wt(e).flatMap(a=>a.sessions),r=vx(t);return r.length===0?o:o.filter(a=>{const i=Sx(a,s(a));return r.every(l=>i.includes(l))})}function Ex(e,t){if(e.statusSince===null)return{shown:"–",said:"time not reported"};const s=Math.max(0,t-e.statusSince);return e.status==="finished"||e.status==="failed"?{shown:`${Et(s)} ago`,said:`${at(s)} ago`}:{shown:Et(s),said:`for ${at(s)}`}}function Tx(e){if(e.project===null)return null;const{branch:t,commit:s}=e.git??{};return t!==void 0?`${e.project} on branch ${t}`:s!==void 0?`${e.project} at commit ${s}`:e.project}function Mx({session:e,agent:t,asOf:s,id:o,active:r,onPoint:a,onPick:i}){const{mark:l,word:d,quiet:c}=Ws(e),u=Ex(e,s),f=Ce(e),h=[e.name,`${d} ${u.said}`,Tx(e),e.machine===void 0?t:`${t} on ${e.machine}`,f&&`Jump to ${f.where}`].filter(Boolean).join(", "),{branch:g,commit:x}=e.git??{};return n.jsxs("li",{id:o,role:"option","aria-selected":r,"aria-label":h,"data-slot":"search-result","data-session":e.id,"data-status":e.status,onPointerMove:a,onClick:i,className:A("flex cursor-pointer items-start gap-3 rounded-inner px-3.5 py-2.5",r&&"bg-fill-selected"),children:[n.jsx(te,{kind:l,className:"mt-0.75"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex items-baseline justify-between gap-3",children:[n.jsx("span",{"data-part":"name",className:A("min-w-0 text-row wrap-anywhere",c?"font-medium text-ink-secondary":"font-semibold text-ink"),children:e.name}),n.jsxs("span",{"data-part":"status",className:"shrink-0 text-body whitespace-nowrap text-ink-secondary",children:[d," ",n.jsx("span",{"data-part":"duration",className:A("tabular-nums",c?"text-ink-secondary":"text-ink"),children:u.shown})]})]}),n.jsxs("p",{"data-part":"place",className:"text-body wrap-break-word text-ink-secondary",children:[e.project!==null&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"data-part":"project",children:e.project}),g!==void 0?n.jsxs(n.Fragment,{children:[" ","on ",n.jsx("span",{"data-part":"branch",children:g})]}):x!==void 0?n.jsxs(n.Fragment,{children:[" ","at"," ",n.jsx("span",{"data-part":"commit",className:"font-mono text-fact",children:x})]}):null," "]}),n.jsxs("span",{className:"whitespace-nowrap",children:[e.project!==null&&n.jsx("span",{"aria-hidden":!0,className:"mr-1.5 ml-0.5",children:"·"}),n.jsx("span",{"data-part":"agent",children:t}),e.machine!==void 0&&n.jsxs(n.Fragment,{children:[" ","on ",n.jsx("span",{"data-part":"machine",children:e.machine})]})]})]})]})]})}function Cx({state:e,now:t,onChoose:s,onShortcuts:o}){const[r,a]=p.useState(""),[i,l]=p.useState(null),d=p.useId(),c=e.snapshot?.sessions??[],u=e.snapshot?.sources??[],f=e.phase==="stalled"&&e.lastOkAt!==null?e.lastOkAt:t,h=S=>Ts(S,u),g=Ax(c,r,h),x=g.findIndex(S=>S.id===i),w=g.length===0?-1:Math.max(0,x),m=g[w],v=S=>`${d}-${encodeURIComponent(S.id)}`,b=m?v(m):void 0,k=m?Ce(m):null;p.useEffect(()=>{b&&document.getElementById(b)?.scrollIntoView({block:"nearest"})},[b]);const N=S=>{if(!S.nativeEvent.isComposing)if(S.key==="ArrowDown"||S.key==="ArrowUp"){S.preventDefault();const y=g[(w+(S.key==="ArrowDown"?1:-1)+g.length)%g.length];y&&l(y.id)}else S.key==="Enter"&&(S.preventDefault(),m&&s(m))},j=e.snapshot?c.length===0?"No agents are running.":g.length===0?`No session matches “${r.trim()}”.`:null:"Agent Lookout has not read any sessions yet.",E=g.length===0?j??"":`${g.length} ${g.length===1?"session":"sessions"}`;return n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"sr-only",children:"Find a session"}),n.jsxs("div",{className:"relative",children:[n.jsx(Fr,{"aria-hidden":!0,strokeWidth:1.75,className:"pointer-events-none absolute top-1/2 left-3.5 size-4 -translate-y-1/2 text-ink-muted"}),n.jsx("input",{type:"text",role:"combobox","aria-label":"Find a session","aria-expanded":!0,"aria-controls":d,"aria-autocomplete":"list","aria-activedescendant":b,"data-part":"field",placeholder:"Name, folder, branch or agent",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,enterKeyHint:"go",value:r,onChange:S=>{a(S.target.value),l(null)},onKeyDown:N,className:"h-11 w-full rounded-inner bg-transparent pr-3.5 pl-10 text-row text-ink placeholder:text-ink-muted"})]}),n.jsx("ul",{id:d,role:"listbox","aria-label":"Sessions","data-part":"results",tabIndex:-1,onPointerDown:S=>S.preventDefault(),className:"thin-scroll mt-2 max-h-[min(26rem,55vh)] overflow-y-auto border-t border-hairline pt-2",children:g.map((S,y)=>n.jsx(Mx,{session:S,agent:h(S),asOf:f,id:v(S),active:y===w,onPoint:()=>{S.id!==m?.id&&l(S.id)},onPick:()=>s(S)},S.id))}),j&&n.jsx("p",{"data-part":"empty",className:"px-3.5 pt-4 pb-6 text-center text-body text-ink-secondary",children:j}),n.jsxs("div",{className:"mt-2 flex items-baseline justify-between gap-4 border-t border-hairline px-3.5 pt-2.5 pb-1 text-caption text-ink-muted",children:[n.jsx("p",{"data-part":"enter",className:"min-w-0",children:m&&n.jsxs(n.Fragment,{children:[n.jsx("kbd",{className:"font-mono",children:"Enter"})," ",k?`jumps to it in ${k.where}`:"opens its details"]})}),n.jsxs("button",{type:"button","aria-haspopup":"dialog","data-part":"shortcuts",onClick:o,className:"-mx-1.5 -my-0.5 shrink-0 cursor-pointer rounded-row px-1.5 py-0.5 whitespace-nowrap transition-colors duration-120 hover:bg-fill-hover hover:text-ink-secondary",children:[n.jsx("kbd",{className:"font-mono",children:"?"})," for shortcuts"]})]}),n.jsx("p",{role:"status","data-part":"count",className:"sr-only",children:E})]})}function Ix({open:e,onOpenChange:t,state:s,now:o,onChoose:r,onShortcuts:a}){const i=p.useRef(null),l=p.useRef(null),d=c=>{l.current=c,t(!1)};return n.jsx(rr,{open:e,onOpenChange:t,children:n.jsxs(ar,{children:[n.jsx("div",{"aria-hidden":!0,"data-slot":"scrim","data-state":e?"open":"closed",className:"fixed inset-0 z-40 bg-scrim data-[state=closed]:animate-fade-out data-[state=open]:animate-fade-in"}),n.jsx(ir,{className:"fixed inset-0 z-50 overflow-y-auto px-4 pt-[12vh] pb-24 data-[state=closed]:animate-fade-out",children:n.jsx(lr,{"data-slot":"search-dialog","aria-describedby":void 0,className:A("glass-float glass-blur mx-auto w-[min(600px,100%)] p-2.5","data-[state=closed]:animate-drop data-[state=open]:animate-rise-fast"),onOpenAutoFocus:()=>{i.current=document.activeElement instanceof HTMLElement?document.activeElement:null,l.current=null},onCloseAutoFocus:c=>{c.preventDefault();const u=l.current,f=i.current;if(l.current=null,i.current=null,u!==null&&u!=="shortcuts"){r(u.session);return}f?.focus(),u==="shortcuts"&&a()},onKeyDown:c=>{const u=c.target instanceof HTMLInputElement&&c.target.value!=="";c.key!=="?"||u||(c.preventDefault(),d("shortcuts"))},children:n.jsx(Cx,{state:s,now:o,onChoose:c=>d({session:c}),onShortcuts:()=>d("shortcuts")})})})]})})}const $x={sm:"w-[min(440px,100%)]",default:"w-[min(600px,100%)]",wide:"w-[min(760px,100%)]"};function Lx({open:e,onOpenChange:t,title:s,description:o,size:r="default",actions:a,focusTitle:i=!1,returnFocus:l,children:d}){const c=p.useRef(null),u=p.useRef(null);return n.jsx(rr,{open:e,onOpenChange:t,children:n.jsxs(ar,{children:[n.jsx("div",{"aria-hidden":!0,"data-slot":"scrim","data-state":e?"open":"closed",className:"fixed inset-0 z-40 bg-scrim data-[state=closed]:animate-fade-out data-[state=open]:animate-fade-in"}),n.jsx(ir,{className:"fixed inset-0 z-50 overflow-y-auto px-4 pt-[6vh] pb-24 data-[state=closed]:animate-fade-out",children:n.jsxs(lr,{"data-slot":"details-modal",className:A("glass-float glass-blur mx-auto px-6 pt-5 pb-6","data-[state=closed]:animate-drop data-[state=open]:animate-rise-fast",$x[r]),...o?{}:{"aria-describedby":void 0},onOpenAutoFocus:f=>{c.current=document.activeElement instanceof HTMLElement?document.activeElement:null,i&&(f.preventDefault(),u.current?.focus())},onCloseAutoFocus:f=>{f.preventDefault();const h=l?.(c.current)??c.current;h?.isConnected&&h.focus(),c.current=null},children:[n.jsxs("header",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx(cr,{ref:u,tabIndex:i?-1:void 0,className:"text-title font-semibold wrap-anywhere outline-none",children:s}),o&&n.jsx(ol,{className:"mt-1 max-w-[56ch] text-body text-ink-secondary",children:o})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a,n.jsx(rl,{asChild:!0,children:n.jsx(F,{size:"icon","aria-label":"Close",children:n.jsx(Tc,{"aria-hidden":!0,className:"size-4",strokeWidth:1.75})})})]})]}),d]})})]})})}const _x={"⌘":Ac,"↑":Nc,"↓":yc,"←":kc,"→":jc};function Ox({shown:e}){return e.split(/([⌘↑↓←→])/).filter(Boolean).map((t,s)=>{const o=_x[t];return o?n.jsx(o,{"aria-hidden":!0,"data-sign":t,strokeWidth:1.75,className:"inline-block size-3.5"},s):t})}function Rx({keys:e}){return n.jsx(n.Fragment,{children:e.map((t,s)=>n.jsxs(p.Fragment,{children:[s>0&&n.jsx("span",{className:"font-normal text-ink-secondary",children:" or "}),t.said?n.jsxs("kbd",{className:"font-mono text-fact whitespace-nowrap",children:[n.jsx("span",{"aria-hidden":!0,children:n.jsx(Ox,{shown:t.shown})}),n.jsx("span",{className:"sr-only",children:t.said})]}):n.jsx("kbd",{className:"font-mono text-fact whitespace-nowrap",children:t.shown})]},t.shown))})}function Wx({open:e,onOpenChange:t}){const s=kx(Hs());return n.jsx(Lx,{open:e,onOpenChange:t,title:"Keyboard shortcuts",description:n.jsxs(n.Fragment,{children:[n.jsx("kbd",{className:"font-mono text-fact",children:"/"})," and"," ",n.jsx("kbd",{className:"font-mono text-fact",children:"?"})," work wherever you are not typing."]}),size:"sm",children:n.jsx("div",{"data-slot":"shortcuts",className:"mt-2",children:s.map(o=>n.jsxs("div",{"data-part":"group",className:"mt-4",children:[n.jsx("h3",{className:"text-caption font-semibold text-ink-secondary",children:o.title}),n.jsx($e,{className:"mt-0.5",children:o.rows.map(r=>n.jsx(X,{label:r.does,children:n.jsx(Rx,{keys:r.keys})},r.does))})]},o.title))})})}function Px({lit:e=!1,className:t}){return n.jsxs("svg",{"data-slot":"lookout-mark","data-lit":e,viewBox:"0 0 32 32","aria-hidden":!0,fill:"none",className:A("size-7.5 shrink-0",t),children:[n.jsx("path",{d:"M3.63 20a13 13 0 0 0 24.74 0z",fill:"currentColor",opacity:"0.13"}),n.jsx("circle",{cx:"16",cy:"16",r:"13",stroke:"currentColor",strokeWidth:"1.75"}),n.jsx("path",{d:"M3.63 20h24.74",stroke:"currentColor",strokeWidth:"1.75"}),e?n.jsxs(n.Fragment,{children:[n.jsx("circle",{"data-part":"lamp",cx:"20.6",cy:"15.1",r:"2.7",strokeWidth:"1",className:"fill-status-needs-you stroke-status-needs-you-edge"}),n.jsx("path",{"data-part":"glint",d:"M18.9 23.6h3.4",strokeWidth:"1.5",strokeLinecap:"round",className:"stroke-status-needs-you-edge"})]}):n.jsx("circle",{"data-part":"lamp",cx:"20.6",cy:"15.1",r:"2.7",stroke:"currentColor",strokeWidth:"1.4"})]})}const Dx="/api/app/update",Fx="/api/app/update/check",Ux="/api/app/update/install",zx="/api/app/update/setting",Bs={check:"check-for-updates",install:"install-update",setting:"update-setting"},Hx={translocated:"macOS runs this copy from a read-only place, because it was opened where it was downloaded. Move Agent Lookout to the Applications folder, open it from there, and check again.","disk-image":"This copy runs from its disk image or another disk. Drag Agent Lookout to the Applications folder, open it from there, and check again.","read-only":"This copy is in a folder it cannot change. Move Agent Lookout to the Applications folder, open it from there, and check again.",development:"This is a development run, which never installs an update."},Mi="#settings/updates",ds=[{id:"overview",label:"Overview",href:"#overview"},{id:"sources",label:"Sources",href:"#sources"},{id:"settings",label:"Settings",href:"#settings"}];function Bx(e){switch(e){case"#sources":return"sources";case"#settings":case Mi:return"settings";default:return"overview"}}function qx(e){return ds.find(t=>t.id===e)?.label??"Overview"}const Gx={overview:ax,sources:ix,settings:lx};function Kx(e){return e===null?"Agent Lookout":e===0?"Agent Lookout, no session needs you":`Agent Lookout, ${e} ${e===1?"session needs":"sessions need"} you`}function Vx({current:e,needsYou:t}){const s=t!==null&&t>0;return n.jsx("nav",{"data-slot":"rail","aria-label":"Views",className:"glass-chrome z-20 w-rail shrink-0 max-mid:w-14 in-app:w-rail",children:n.jsxs("div",{className:"sticky top-window flex flex-col items-center",children:[n.jsx("div",{"data-slot":"rail-buttons","aria-hidden":!0,className:"hidden h-header w-full in-app-windowed:block"}),n.jsx("a",{href:ds[0]?.href,"data-slot":"rail-mark","data-lit":s,"aria-label":Kx(t),className:"grid h-header w-full place-items-center rounded-t-chrome text-ink focus-visible:-outline-offset-2 in-app-windowed:rounded-inner",children:n.jsx(Px,{lit:s})}),n.jsx("ul",{className:"flex w-full flex-col items-center gap-1 py-3",children:ds.map(o=>{const r=Gx[o.id],a=o.id===e;return n.jsx("li",{children:n.jsxs("a",{href:o.href,"data-slot":"rail-link","data-view":o.id,"aria-current":a?"page":void 0,className:A("flex w-15.5 flex-col items-center gap-1.25 rounded-inner pt-2.5 pb-2.25","text-micro leading-none font-medium transition-colors duration-120","max-mid:w-11 max-mid:py-2.5",a?"bg-fill-selected text-ink inset-ring inset-ring-control-rim inset-shadow-top":"text-ink-secondary hover:bg-fill-hover hover:text-ink"),children:[n.jsx(r,{}),n.jsx("span",{className:"max-mid:sr-only",children:o.label})]})},o.id)})})]})})}function Go({children:e}){return n.jsx("code",{"data-slot":"fact","data-part":"install-command",className:"block w-fit max-w-full rounded-row bg-fill-zebra px-3 py-1.5 font-mono text-fact text-ink inset-ring inset-ring-hairline select-all wrap-break-word",children:n.jsx(qe,{children:e})})}function Yx(){return n.jsxs("div",{"data-part":"install",className:"mt-3 flex flex-col gap-2",children:[n.jsx("p",{className:"text-body text-ink-secondary",children:"In Claude Code, run these two commands:"}),n.jsx(Go,{children:"/plugin marketplace add Olanetsoft/agent-lookout"}),n.jsx(Go,{children:"/plugin install agent-lookout@agent-lookout"})]})}function Jx(e){switch(e.state){case"on":return"Permission prompts of Claude Code sessions with the plugin can be answered from here.";case"off":return"Permission prompts are not answered from here.";case"unavailable":return"Permission prompts cannot be answered from here."}}function Xx({answering:e}){let t=null,s=!1;return e?.state==="on"?(s=e.plugin!=="seen",t=e.plugin==="missed"?n.jsx(n.Fragment,{children:"A Claude Code session asked for permission, but its request did not reach Agent Lookout. The plugin may not be installed for it."}):e.plugin==="seen"?n.jsxs(n.Fragment,{children:["Requests from the plugin reach Agent Lookout. Each is held for"," ",ke(e.holdMs),", and the session's own prompt can still be answered meanwhile. Deny is always offered, and Allow when all of what it allows is shown."]}):n.jsx(n.Fragment,{children:"Answering needs the Agent Lookout plugin in Claude Code. Without it, a session's prompts are answered in the session only."})):e?.state==="off"?t=n.jsx(V,{children:"AGENT_LOOKOUT_ANSWER is off, so no request is held."}):e?.state==="unavailable"&&e.problem&&(t=n.jsx(V,{children:e.problem})),n.jsx(U,{title:"Permission prompts",children:n.jsxs("div",{"data-slot":"answer-card",className:"px-6 pb-6",children:[n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:e&&Jx(e)}),t&&n.jsx("p",{"data-part":"plugin","data-plugin":e?.plugin,className:"mt-3 text-body text-ink-secondary",children:t}),s&&n.jsx(Yx,{})]})})}const Qx=1e4,Zx=["memory-only","not-writing","failed"],eg=300;async function tg(e=Qx){try{const t=await Z("/api/history/clear",{method:"POST",headers:{"Content-Type":"application/json",[Le]:rd},body:"{}",signal:AbortSignal.timeout(e)}),s=await t.json(),o=typeof s=="object"&&s!==null?s:{};if(t.ok&&o.ok===!0&&typeof o.clearedAt=="number")return{ok:!0,at:o.clearedAt};const r=typeof o.error=="string"&&o.error.length<=eg?o.error:null;return{ok:!1,reason:Zx.find(a=>a===o.reason)??"failed",error:r}}catch{return{ok:!1,reason:"no-answer",error:null}}}const ng=1024,Ko=1024*1024;function Vo(e){return e<=0?"0 KB":e<Ko?`${Math.max(1,Math.round(e/ng))} KB`:`${(e/Ko).toFixed(1).replace(/\.0$/,"")} MB`}function sg(e){const t=Math.round(e/864e5);return`${t} ${t===1?"day":"days"}`}function og(e,t,s){const o=sg(e.maxAgeMs),r=Vo(e.maxBytes);return e.where==="memory"||e.folder===null?{state:"History is kept in memory only.",facts:null,note:null,explanation:["The Events log and the charts start empty each time Agent Lookout starts, because AGENT_LOOKOUT_HISTORY is set to off.",`Without it, they are kept on this computer for ${o}, so they are still there after a restart.`]}:{state:e.problem===null?`History is kept on this computer for ${o}.`:"History is kept in memory for now.",facts:{folder:e.folder,holds:e.bytes===null?"–":`${Vo(e.bytes)} of ${r}`,since:ue(t.at,s)},note:e.problem===null?null:{title:"This copy is not writing history",detail:e.problem},explanation:[e.problem===null?"The Events log and the counts behind the charts are written to this folder every few seconds, so they are still there when Agent Lookout starts again. It holds no prompt and nothing a waiting session is asking.":"The copy that writes the history writes the Events log and the counts behind the charts to this folder every few seconds, so they are still there when Agent Lookout starts again. It holds no prompt and nothing a waiting session is asking.",`A day's history is deleted ${o} after the day ends, and the oldest goes first once the files would hold more than ${r}.`]}}function rg(e){return e.reason==="no-answer"?"Agent Lookout did not answer. Try again in a moment.":e.error??"Agent Lookout could not clear it. Try again in a moment."}const ag="Clear the Events log and the charts? This cannot be undone.";function ig({history:e=null,now:t,onCleared:s,clear:o=tg}){const[r,a]=p.useState({kind:"idle"}),i=p.useRef(null),l=p.useRef(null),d=p.useRef(null);p.useEffect(()=>{const m=d.current;d.current=null,m==="cancel"?l.current?.focus():m==="clear"&&i.current?.focus()},[r]);const c=e?.kept??null;if(e===null||c===null)return n.jsx(U,{title:"History",children:n.jsx("div",{className:"px-6 pb-6",children:n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:e===null?null:"Where the history is kept could not be read."})})});const u=og(c,ye(e),t),f=c.canClear,h=r.kind==="confirming"&&f,g=()=>{d.current="cancel",a({kind:"confirming",busy:!1})},x=()=>{d.current="clear",a({kind:"idle"})},w=()=>{r.kind!=="confirming"||r.busy||(a({kind:"confirming",busy:!0}),o().then(m=>{d.current="clear",m.ok?(a({kind:"cleared",at:m.at}),s?.()):a({kind:"failed",words:rg(m)})}))};return n.jsx(U,{title:"History",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsxs("div",{className:"flex min-h-button flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:h?ag:u.state}),f&&(h?n.jsxs(n.Fragment,{children:[n.jsx(F,{size:"sm",onClick:w,"aria-disabled":r.busy||void 0,children:"Clear history"}),n.jsx(F,{ref:l,size:"sm",onClick:x,children:"Cancel"})]}):n.jsx(F,{ref:i,size:"sm",onClick:g,children:"Clear history"}))]}),u.facts&&n.jsxs($e,{className:"mt-3",children:[n.jsx(X,{label:"Folder",mono:!0,children:n.jsx(qe,{"data-part":"folder",className:"select-text",children:u.facts.folder})}),n.jsx(X,{label:"Holds",children:n.jsx("span",{className:"tabular-nums",children:u.facts.holds})}),n.jsx(X,{label:"Since",children:n.jsx("span",{className:"tabular-nums",children:u.facts.since})})]}),u.note&&n.jsx(G,{title:u.note.title,className:"mt-3",children:n.jsx("p",{children:n.jsx(V,{children:u.note.detail})})}),r.kind==="failed"&&n.jsx(G,{title:"The history could not be cleared",className:"mt-3",children:n.jsx("p",{children:n.jsx(V,{children:r.words})})}),r.kind==="cleared"&&n.jsxs("p",{"data-part":"outcome",role:"status",className:"mt-3 text-body text-ink",children:["History cleared at ",n.jsx("span",{className:"tabular-nums",children:ue(r.at,t)}),"."]}),u.explanation.map((m,v)=>n.jsx("p",{className:v===0?"mt-3 text-body text-ink-secondary":"mt-2 text-body text-ink-secondary",children:n.jsx(V,{children:m})},m))]})})}const lg="/api/app/menu-bar",cg="/api/app/menu-bar/setting",dg="menu-bar-setting",Ci=4e3;function Ii(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const{show:t}=e;return typeof t=="boolean"?{show:t}:null}async function ug(){try{const e=await Z(lg,{signal:AbortSignal.timeout(Ci)});return e.ok?Ii(await e.json()):null}catch{return null}}async function fg(e){try{const t=await Z(cg,{method:"POST",headers:{"Content-Type":"application/json",[Le]:dg},body:JSON.stringify({show:e}),signal:AbortSignal.timeout(Ci)});return t.ok?Ii(await t.json()):null}catch{return null}}function mg(){const[e,t]=p.useState(null),s=p.useRef(!0);p.useEffect(()=>(s.current=!0,ug().then(r=>{s.current&&t(r??"unknown")}),()=>{s.current=!1}),[]);const o=p.useCallback(r=>{fg(r).then(a=>{s.current&&a!==null&&t(a)})},[]);return{reading:e,setShown:o}}const hg=[{value:"off",label:"Off"},{value:"on",label:"On"}],Yo="Show in menu bar";function pg(){const{reading:e,setShown:t}=mg();return n.jsx(U,{title:"Menu bar","data-part":"menu-bar",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsxs("div",{"data-part":"row",className:"flex min-h-9 items-center justify-between gap-6",children:[e==="unknown"&&n.jsx("p",{"data-part":"state",className:"text-body font-medium text-ink",children:"Whether Agent Lookout is in the menu bar could not be read."}),e!==null&&e!=="unknown"&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,className:"text-body text-ink",children:Yo}),n.jsx(je,{label:Yo,value:e.show?"on":"off",onValueChange:s=>t(s==="on"),options:hg})]})]}),n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"While it is on, Agent Lookout's icon in the menu bar shows how many sessions need you, with the window open or closed. Click it to list them, with how long each has waited and what it is asking, and choose one to open its details."})]})})}function xg({className:e,...t}){return n.jsx("input",{"data-slot":"text-field",type:"text",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,className:A("h-control min-w-0 rounded-capsule bg-well px-3 text-center text-body text-ink tabular-nums","inset-ring inset-ring-control-rim inset-shadow-well","placeholder:text-ink-muted aria-invalid:inset-ring-rule-strong","disabled:opacity-50",e),...t})}const $i=5e3,gg=400;async function wg(){try{const e=await Z(fd,{signal:AbortSignal.timeout($i)});return e.ok?Ou(await e.json()):null}catch{return null}}async function bg(e){try{const t=await Z(md,{method:"POST",headers:{"Content-Type":"application/json",[Le]:hd},body:JSON.stringify(e),signal:AbortSignal.timeout($i)}),s=await t.json(),o=typeof s=="object"&&s!==null?s:{};return t.ok&&o.ok===!0&&o.timeRules!==void 0?{ok:!0,rules:ps(o.timeRules).rules}:{ok:!1,error:typeof o.error=="string"&&o.error.length<=gg?o.error:null}}catch{return{ok:!1,error:null}}}const yg="Agent Lookout did not answer, so nothing changed.",Fn=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function kg(e,t){const[s,o]=p.useState(null),[r,a]=p.useState(null),i=p.useRef(!0),l=p.useRef(e),d=p.useRef(null),c=p.useRef(null),u=p.useRef(0),f=p.useRef(0),h=p.useRef(Promise.resolve());p.useEffect(()=>{l.current=e}),p.useEffect(()=>(i.current=!0,wg().then(m=>{i.current&&(o(m??"unknown"),m&&(d.current=m.timeRules,c.current=m.timeRules,u.current=Date.now()))}),()=>{i.current=!1}),[]);const g=t?.timeRules,x=t?.generatedAt;p.useEffect(()=>{g===void 0||x===void 0||c.current===null||f.current>0||x<=u.current||Fn(g,c.current)||(c.current=g,d.current=g,o(m=>m!==null&&m!=="unknown"?{...m,timeRules:g}:m))},[g,x]);const w=p.useCallback(m=>{if(d.current===null)return;const v=m(d.current);Fn(v,d.current)||(d.current=v,f.current+=1,h.current=h.current.then(async()=>{try{const b=c.current;if(!i.current||b===null)return;const k=m(b);if(Fn(k,b))return;const N=await bg(k);if(!i.current)return;u.current=Date.now(),N.ok?(c.current=N.rules,a(null),o(j=>j!==null&&j!=="unknown"?{...j,timeRules:N.rules,problem:null}:j),l.current?.()):a(N.error??yg)}finally{f.current-=1,f.current===0&&c.current!==null&&(d.current=c.current)}}))},[]);return{reading:s,refused:r,change:w}}const Un={longWait:"Remind me of a long wait",idle:"Mark idle sessions stale",quietHours:"Quiet hours"},Jo="Leave answered waits out of the summary";function us(e,t){const s=e.trim();if(!/^\d{1,5}$/.test(s))return null;const o=Number(s);return o>=t.min&&o<=t.max?o:null}function jg(e){return us(e,vt)}const Ng=`Type a whole number of minutes from ${vt.min} to ${vt.max}.`,Li=ot.max/24;function vg(e){return e%24===0?{value:e/24,unit:"days"}:{value:e,unit:"hours"}}function Sg(e,t){if(t==="hours")return us(e,ot);const s=us(e,{min:1,max:Li});return s===null?null:s*24}const Ag=`Type a whole number of hours from ${ot.min} to ${ot.max}, or of days from 1 to ${Li}.`;function Eg(e){return`${e} ${e===1?"hour is":"hours is"} not a whole number of days.`}function Tg(e){const t=e.trim(),s=/^(\d{1,2})(?::?(\d{2}))?$/.exec(t);if(!s)return null;const o=`${s[1].padStart(2,"0")}:${s[2]??"00"}`;return St(o)===null?null:o}const Mg="Type a time on the 24-hour clock, such as 22:00.";function Cg(e){return`Quiet now, until ${e}. Notifications, emails and posts are held.`}const Ig="Quiet hours must begin and end at different times.",$g={mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat",sun:"Sun"},Lg={mon:"Monday",tue:"Tuesday",wed:"Wednesday",thu:"Thursday",fri:"Friday",sat:"Saturday",sun:"Sunday"};function _g(e,t,s){return st.filter(o=>o===t?s:e.includes(o))}const _i=[{value:"off",label:"Off"},{value:"on",label:"On"}],Og=[{value:"hours",label:"hours"},{value:"days",label:"days"}];function Qt({value:e,label:t,onCommit:s,className:o}){const[r,a]=p.useState(null),i=()=>{r!==null&&(a(null),r.trim()!==e&&s(r))};return n.jsx(xg,{"aria-label":t,inputMode:"numeric",enterKeyHint:"done",value:r??e,onChange:l=>a(l.target.value),onBlur:i,onKeyDown:l=>{l.key==="Enter"?i():l.key==="Escape"&&r!==null&&(l.preventDefault(),a(null))},className:o})}function zn({name:e,on:t,onSwitch:s,children:o}){return n.jsxs("li",{"data-part":"rule",className:"border-b border-hairline py-2 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center justify-between gap-6",children:[n.jsx("span",{"aria-hidden":!0,className:"text-body text-ink",children:e}),n.jsx(je,{label:e,value:t?"on":"off",onValueChange:r=>s(r==="on"),options:_i,className:"shrink-0"})]}),t&&n.jsx("div",{"data-part":"set-to",className:"mt-2 mb-1 flex flex-col gap-2 text-body text-ink-secondary",children:o})]})}function Hn({take:e,children:t}){return n.jsxs("div",{children:[n.jsx("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-2",children:t}),n.jsx("p",{"data-part":"take",role:"status",className:"mt-1 empty:hidden",children:e})]})}function Rg({children:e}){return n.jsx("span",{className:"inline-flex flex-wrap items-center gap-x-2 gap-y-2",children:e})}function Wg({onChanged:e,snapshot:t=null}){const s=t?.timeRules?{timeRules:t.timeRules,generatedAt:t.generatedAt}:null,{reading:o,refused:r,change:a}=kg(e,s),[i,l]=p.useState(null),[d,c]=p.useState(null),u=p.useId();if(o===null||o==="unknown")return n.jsx(U,{title:"Time rules",children:n.jsx("div",{className:"px-6 pb-6",children:n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:o===null?null:"The time rules could not be read."})})});const{longWait:f,idle:h,quietHours:g}=o.timeRules,x=d==="days"&&h.hours%24!==0?"hours":d??vg(h.hours).unit,w=x==="hours"?h.hours:h.hours/24,m=g.on&&t?.quiet===!0,v=(j,E)=>{l(S=>S?.rule===j?null:S),a(E)},b=(j,E,S)=>y=>{const C=S(y,o.timeRules);return C===null||typeof C=="string"?(l({rule:j,words:C??E}),!1):(v(j,q=>{const z=S(y,q);return z===null||typeof z=="string"?q:z}),!0)},k=j=>i?.rule===j?i.words:null,N=j=>b("quietHours",Mg,(E,S)=>{const y=Tg(E);if(y===null)return null;const C=j==="from"?S.quietHours.to:S.quietHours.from;return y===C?Ig:{...S,quietHours:{...S.quietHours,[j]:y}}});return n.jsx(U,{title:"Time rules",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsxs("ul",{"data-part":"rules","aria-label":"Time rules",className:"flex flex-col",children:[n.jsx(zn,{name:Un.longWait,on:f.on,onSwitch:j=>v("longWait",E=>({...E,longWait:{...E.longWait,on:j}})),children:n.jsxs(Hn,{take:k("longWait"),children:[n.jsx("span",{children:"After"}),n.jsx(Qt,{label:"Minutes of waiting before the reminder",value:String(f.minutes),onCommit:b("longWait",Ng,(j,E)=>{const S=jg(j);return S===null?null:{...E,longWait:{...E.longWait,minutes:S}}}),className:"w-16"}),n.jsxs("span",{children:[f.minutes===1?"minute":"minutes"," of waiting"]})]})}),n.jsx(zn,{name:Un.idle,on:h.on,onSwitch:j=>v("idle",E=>({...E,idle:{...E.idle,on:j}})),children:n.jsxs(Hn,{take:k("idle"),children:[n.jsx("span",{children:"After"}),n.jsxs(Rg,{children:[n.jsx(Qt,{label:x==="days"?"Days idle before stale":"Hours idle before stale",value:String(w),onCommit:b("idle",Ag,(j,E)=>{const S=Sg(j,x);return S===null?null:{...E,idle:{...E.idle,hours:S}}}),className:"w-14"}),n.jsx(je,{label:"Idle for",value:x,onValueChange:j=>{if(j==="days"&&h.hours%24!==0){c("hours"),l({rule:"idle",words:Eg(h.hours)});return}c(j),l(E=>E?.rule==="idle"?null:E)},options:Og,className:"shrink-0"}),n.jsx("span",{children:"idle"})]})]})}),n.jsxs(zn,{name:Un.quietHours,on:g.on,onSwitch:j=>v("quietHours",E=>({...E,quietHours:{...E.quietHours,on:j}})),children:[n.jsxs(Hn,{take:k("quietHours"),children:[n.jsx("span",{children:"From"}),n.jsx(Qt,{label:"Quiet from",value:g.from,onCommit:N("from"),className:"w-20"}),n.jsx("span",{children:"to"}),n.jsx(Qt,{label:"Quiet until",value:g.to,onCommit:N("to"),className:"w-20"})]}),n.jsx("p",{"data-part":"quiet-now",role:"status",className:"empty:hidden",children:m?Cg(g.to):null}),n.jsxs("div",{role:"group","aria-labelledby":u,className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsx("span",{id:u,className:"max-mid:basis-full",children:"Beginning on"}),st.map(j=>n.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-1.5 text-ink",children:[n.jsx(ii,{checked:g.days.includes(j),onCheckedChange:E=>v("quietHours",S=>({...S,quietHours:{...S.quietHours,days:_g(S.quietHours.days,j,E)}})),"aria-label":Lg[j]}),n.jsx("span",{"aria-hidden":!0,children:$g[j]})]},j))]}),g.days.length===0&&n.jsx("p",{children:"No day is ticked, so quiet hours never begin."}),n.jsxs("div",{className:"flex items-center justify-between gap-6",children:[n.jsx("span",{"aria-hidden":!0,children:Jo}),n.jsx(je,{label:Jo,value:g.leaveOutAnswered?"on":"off",onValueChange:j=>v("quietHours",E=>({...E,quietHours:{...E.quietHours,leaveOutAnswered:j==="on"}})),options:_i,className:"shrink-0"})]})]})]}),r!==null&&n.jsx(G,{title:"The time rules could not be changed",className:"mt-3",children:n.jsx("p",{children:n.jsx(V,{children:r})})}),r===null&&o.problem!==null&&n.jsx(G,{title:"The settings file could not be read",className:"mt-3",children:n.jsx("p",{children:n.jsx(V,{children:o.problem})})}),n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"A reminder goes once per wait, by each channel that is on for waits: a notification, an email or a webhook post. It says how long the session has waited, as in “checkout-flow has waited 10 minutes for permission”."}),n.jsx("p",{className:"mt-2 text-body text-ink-secondary",children:"A session idle longer than the idle rule says is stale, and a Claude Code session among them whose process still runs is listed under Left running. With the rule off, that is a day."}),n.jsx("p",{className:"mt-2 text-body text-ink-secondary",children:"During quiet hours no notification, email or post goes. When they end, a session still waiting is notified as usual, and everything else comes as one summary on each channel. Hours that run past midnight belong to the day they begin."}),n.jsx("p",{className:"mt-2 text-body text-ink-secondary",children:n.jsx(V,{children:`Agent Lookout keeps these in ${o.file}, so they hold with no dashboard open. The switches under Notifications, and the email and webhook settings, still choose what is sent.`})})]})})}const qs=4e3,Pg=3e4,Dg=["translocated","disk-image","read-only","development"];function Gs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Je=e=>typeof e=="string"&&e!=="",bt=e=>typeof e=="string"&&e.startsWith("https://"),fs=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Fg(e){if(!Gs(e))return null;switch(e.phase){case"idle":case"checking":case"up-to-date":case"no-release":return{phase:e.phase};case"downloading":return Je(e.version)&&bt(e.notesUrl)&&fs(e.received)&&fs(e.total)?{phase:"downloading",version:e.version,notesUrl:e.notesUrl,received:e.received,total:e.total}:null;case"ready":case"installing":return Je(e.version)&&bt(e.notesUrl)?{phase:e.phase,version:e.version,notesUrl:e.notesUrl}:null;case"cannot-install":{const t=Dg.find(s=>s===e.refusal);return Je(e.version)&&bt(e.notesUrl)&&t!==void 0?{phase:"cannot-install",version:e.version,notesUrl:e.notesUrl,refusal:t}:null}case"failed":{const t=e.step==="check"||e.step==="download"||e.step==="install"?e.step:null;return t===null||!Je(e.reason)?null:{phase:"failed",step:t,reason:e.reason,version:Je(e.version)?e.version:null,notesUrl:bt(e.notesUrl)?e.notesUrl:null}}default:return null}}function ms(e){if(!Gs(e))return null;const t=Fg(e.update);if(t===null||!Je(e.version)||typeof e.automatic!="boolean"||!bt(e.releasesUrl))return null;const s=e.lastCheckedAt;return{version:e.version,automatic:e.automatic,lastCheckedAt:fs(s)&&s>0?s:null,releasesUrl:e.releasesUrl,update:t}}async function Ug(e){const t=await e.json();return e.ok?ms(t):Gs(t)?ms(t.status):null}async function Xo(){try{const e=await Z(Dx,{signal:AbortSignal.timeout(qs)});return e.ok?ms(await e.json()):null}catch{return null}}async function Ks(e,t,s,o){try{const r=await Z(e,{method:"POST",headers:{"Content-Type":"application/json",[Le]:t},body:JSON.stringify(s),signal:AbortSignal.timeout(o)});return await Ug(r)}catch{return null}}function zg(){return Ks(Fx,Bs.check,{},Pg)}function Hg(){return Ks(Ux,Bs.install,{},qs)}function Bg(e){return Ks(zx,Bs.setting,{automatic:e},qs)}const qg=1e3,Gg=5e3;function Kg(e){const{phase:t}=e.update;return t==="downloading"||t==="ready"||t==="installing"}function Vg(e){if(e===null||e==="unknown")return!1;const{phase:t}=e.update;return t==="checking"||t==="downloading"||t==="installing"}function Yg(){const[e,t]=p.useState(null),[s,o]=p.useState(null),r=p.useRef(!0),a=p.useCallback(u=>{r.current&&t(u??"unknown")},[]);p.useEffect(()=>(r.current=!0,Xo().then(a),()=>{r.current=!1}),[a]);const i=Vg(e);p.useEffect(()=>{if(e===null)return;const u=setTimeout(()=>{Xo().then(a)},i?qg:Gg);return()=>clearTimeout(u)},[e,i,a]);const l=p.useCallback(()=>{o("check"),t(u=>u===null||u==="unknown"||Kg(u)?u:{...u,update:{phase:"checking"}}),zg().then(u=>{r.current&&(o(null),u!==null&&t(u))})},[]),d=p.useCallback(()=>{o("install"),Hg().then(u=>{r.current&&(o(null),u!==null&&t(u))})},[]),c=p.useCallback(u=>{Bg(u).then(f=>{r.current&&f!==null&&t(f)})},[]);return{reading:e,pressed:s,check:l,install:d,setAutomatic:c}}const Jg=1e3;let Vs=Date.now(),pt=null;const nn=new Set;function Oi(){Vs=Date.now();for(const e of nn)e()}function Qo(){document.hidden||Oi()}function Xg(e){return nn.add(e),pt===null&&(Vs=Date.now(),pt=setInterval(Oi,Jg),document.addEventListener("visibilitychange",Qo)),()=>{nn.delete(e),nn.size===0&&pt!==null&&(clearInterval(pt),pt=null,document.removeEventListener("visibilitychange",Qo))}}function Qg(){return Vs}function Sn(){return p.useSyncExternalStore(Xg,Qg)}const Zg=1024*1024;function Zo(e){return`${Math.round(e/Zg)} MB`}function ew(e,t){return e.lastCheckedAt===null?"Not yet":ue(e.lastCheckedAt,t)}function tw(e){const{update:t}=e,s={detail:null,install:!1,canCheck:!0,notesUrl:null,note:null};switch(t.phase){case"idle":return{...s,state:e.automatic?"Agent Lookout checks about once a day.":"Agent Lookout checks only when you ask."};case"checking":return{...s,state:"Checking for updates…",canCheck:!1};case"up-to-date":return{...s,state:"You're up to date."};case"no-release":return{...s,state:"The latest release has no Mac app yet."};case"not-for-this-mac":return{...s,state:"The latest release has no app for this kind of Mac."};case"downloading":return{...s,state:`Version ${t.version} is available.`,detail:t.total>0?`Downloading it: ${Zo(t.received)} of ${Zo(t.total)}.`:"Downloading it.",notesUrl:t.notesUrl};case"ready":return{...s,state:`Version ${t.version} is available.`,detail:"Downloaded and checked.",install:!0,notesUrl:t.notesUrl};case"installing":return{...s,state:`Installing version ${t.version}…`,detail:"Agent Lookout quits and opens again as the new version.",canCheck:!1,notesUrl:t.notesUrl};case"cannot-install":return{...s,state:`Version ${t.version} is available.`,note:{title:"Agent Lookout cannot update itself here",detail:Hx[t.refusal],link:t.notesUrl}};case"failed":return t.step==="check"?{...s,state:"The last check did not work.",note:{title:"Agent Lookout could not check for updates",detail:`${we(t.reason)}. Check again in a while.`,link:e.releasesUrl}}:{...s,state:t.version===null?"A newer version is available.":`Version ${t.version} is available.`,note:{title:`${t.version===null?"The new version":`Version ${t.version}`} could not be ${t.step==="install"?"installed":"downloaded"}`,detail:`${we(t.reason)}. Check again to try once more.`,link:t.notesUrl??e.releasesUrl}}}}const nw=[{value:"off",label:"Off"},{value:"on",label:"On"}],er="Check for updates automatically",tr="rounded-bar underline decoration-rule-strong underline-offset-2 transition-colors duration-120 hover:text-ink";function sw(){const{reading:e,pressed:t,check:s,install:o,setAutomatic:r}=Yg(),a=Sn(),i=p.useRef(null);p.useEffect(()=>{const c=()=>{window.location.hash===Mi&&i.current?.scrollIntoView({block:"nearest"})};return c(),window.addEventListener("hashchange",c),()=>window.removeEventListener("hashchange",c)},[]);const l=e===null||e==="unknown"?null:e,d=l===null?null:tw(l);return n.jsx(U,{ref:i,title:"Updates","data-part":"updates",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsxs("div",{className:"flex min-h-button flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:e==="unknown"?"Whether a newer version is out could not be read.":d?.state}),d!==null&&(d.install?n.jsx(F,{size:"sm",onClick:o,disabled:t!==null,children:"Install and Restart"}):n.jsx(F,{size:"sm",onClick:s,disabled:!d.canCheck||t!==null,children:"Check for Updates…"}))]}),d!==null&&(d.detail!==null||d.notesUrl!==null)&&n.jsxs("p",{"data-part":"found",className:"mt-1 text-body text-ink-secondary",children:[d.detail,d.detail!==null&&d.notesUrl!==null&&" ",d.notesUrl!==null&&n.jsx("a",{href:d.notesUrl,target:"_blank",rel:"noreferrer",className:tr,children:"Release notes"})]}),d?.note&&n.jsx(G,{title:d.note.title,className:"mt-3",children:n.jsxs("p",{children:[d.note.detail," ",n.jsx("a",{href:d.note.link,target:"_blank",rel:"noreferrer",className:tr,children:"Release page"})]})}),l!==null&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mt-3 flex items-center justify-between gap-6 border-b border-hairline py-2",children:[n.jsx("span",{"aria-hidden":!0,className:"text-body text-ink",children:er}),n.jsx(je,{label:er,value:l.automatic?"on":"off",onValueChange:c=>r(c==="on"),options:nw})]}),n.jsxs($e,{children:[n.jsxs(X,{label:"Version",mono:!0,children:["v",l.version]}),n.jsx(X,{label:"Last checked",children:n.jsx("span",{className:"tabular-nums",children:ew(l,a)})})]})]}),n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"Agent Lookout asks GitHub whether a newer version has been released when you press Check for Updates…, and about once a day while Check for updates automatically is on. It sends nothing about your sessions: GitHub sees the app's version number and your IP address, as with any web request."}),n.jsx("p",{className:"mt-2 text-body text-ink-secondary",children:"A newer version is downloaded and checked first, and installed only when you press Install and Restart. To update itself, Agent Lookout must be in a folder it can change, such as Applications."})]})})}function ow(){Sd()}function rw(){return{...p.useSyncExternalStore(Jr,Lt),turnOn:ow,turnOff:Ad,chooseEvent:Ed}}const aw=5e3;function Bn(e){const[t,s]=p.useState(null);return p.useEffect(()=>{let o=!0;const r=()=>{e().then(i=>{o&&s({status:i??"unknown",readAt:Date.now()})})};r();const a=setInterval(r,aw);return()=>{o=!1,clearInterval(a)}},[e]),t}const Ys=4e3;function Ri(e){const t=Math.round(e/1e3),s=(o,r)=>`${o} ${r}${o===1?"":"s"}`;return t>=3600&&t%3600===0?s(t/3600,"hour"):t>=60&&t%60===0?s(t/60,"minute"):s(t,"second")}function iw(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function lw(e,t){switch(e){case"needs-you":return t===0?"starts waiting":`has waited ${Ri(t)}`;case"finished":return"finishes";case"failed":return"fails";case"ended":return"ends"}}function Wi(e,t,s,o){return s.length===1&&s[0]==="needs-you"?o===0?`${e} go to ${t} as soon as a session waits.`:`${e} go to ${t} after a wait of ${Ri(o)}.`:`${e} go to ${t} when a session ${iw(s.map(r=>lw(r,o)))}.`}async function cw(){try{const e=await Z("/api/email",{signal:AbortSignal.timeout(Ys)});return e.ok?Iu(await e.json()):null}catch{return null}}function dw(e,t){return!e.on||e.to===null||e.events===null||e.afterMs===null?e.problem===null?{state:"Email is off.",asking:null,title:null,detail:"Set AGENT_LOOKOUT_EMAIL_TO and AGENT_LOOKOUT_SMTP_URL to turn it on."}:{state:"Email is off.",asking:null,title:"Email is not set up correctly",detail:`${e.problem} Correct it and start Agent Lookout again.`}:{...{state:Wi("Emails",e.to,e.events,e.afterMs),asking:e.asking?"Emails for a wait say what the session is asking.":"Emails leave out what a waiting session is asking."},...uw(e,t)}}function uw(e,t){const{last:s,limitedUntil:o}=e;if(o!==null){const r=ue(o,t);return s!==null&&!s.sent?{title:"The last email could not be sent",detail:`${we(s.reason)}. No more will be tried until ${r}, as ${ln} were tried in the last hour.`}:{title:"Emails are held back",detail:`${ln} emails were tried in the last hour, the most it tries. The next can go at ${r}.`}}return s===null?{title:null,detail:null}:s.sent?{title:null,detail:`Last sent at ${ue(s.at,t)}.`}:{title:"The last email could not be sent",detail:`${we(s.reason)}.`}}async function fw(){try{const e=await Z("/api/webhook",{signal:AbortSignal.timeout(Ys)});return e.ok?_u(await e.json()):null}catch{return null}}function mw(e,t){return!e.on||e.host===null||e.events===null||e.afterMs===null?e.problem===null?{state:"The webhook is off.",asking:null,title:null,detail:"Set AGENT_LOOKOUT_WEBHOOK_URL to turn it on."}:{state:"The webhook is off.",asking:null,title:"The webhook is not set up correctly",detail:`${e.problem} Correct it and start Agent Lookout again.`}:{...{state:Wi("Posts",e.host,e.events,e.afterMs),asking:e.asking?"Posts for a wait say what the session is asking.":"Posts leave out what a waiting session is asking."},...hw(e,t)}}function hw(e,t){const{last:s,limitedUntil:o}=e;if(o!==null){const r=ue(o,t);return s!==null&&!s.sent?{title:"The last post failed",detail:`${we(s.reason)}. No more will be tried until ${r}, as ${ln} were tried in the last hour.`}:{title:"Posts are held back",detail:`${ln} posts were tried in the last hour, the most it tries. The next can go at ${r}.`}}return s===null?{title:null,detail:null}:s.sent?{title:null,detail:`Last posted at ${ue(s.at,t)}.`}:{title:"The last post failed",detail:`${we(s.reason)}.`}}async function pw(){try{const e=await Z("/api/pull-requests",{signal:AbortSignal.timeout(Ys)});return e.ok?Lu(await e.json()):null}catch{return null}}const xw="Your own gh sends GitHub the name of each repository and branch it is asked about, with its own login.";function gw(e){return e.on&&e.gh!==null&&e.gh!=="not-found"&&e.gh!=="signed-out"}function ww(e,t){if(!e.on||e.gh===null)return e.problem===null?{state:"Pull requests are off.",asking:null,title:null,detail:"Set AGENT_LOOKOUT_PULL_REQUESTS=on to show each session's pull request and its checks, through your own gh."}:{state:"Pull requests are off.",asking:null,title:"Pull requests are not set up correctly",detail:`${e.problem} Correct it and start Agent Lookout again.`};switch(e.gh){case"not-found":return{state:"No pull request is shown.",asking:null,title:"The GitHub CLI was not found",detail:"Install gh, then sign in with gh auth login."};case"signed-out":return{state:"No pull request is shown.",asking:null,title:"The GitHub CLI is not signed in",detail:"Run gh auth login in a terminal to sign in to github.com."}}const s={state:"Pull requests are shown for branches of repositories on github.com.",asking:xw},{last:o}=e;return o===null?{...s,title:null,detail:"No session is on a branch to ask about yet."}:o.ok?{...s,title:null,detail:`Last checked at ${ue(o.at,t)}.`}:{...s,title:"The last check did not work",detail:`${o.reason.startsWith("gh")?o.reason:we(o.reason)}. It is tried again within 2 minutes.`}}const bw=[{value:"dark",label:"Night",name:"Dark theme"},{value:"light",label:"Day",name:"Light theme"},{value:"system",label:"System",name:"Follow the computer's setting"}],yw=[{value:"off",label:"Off"},{value:"on",label:"On"}];function kw({events:e,chooseEvent:t}){return n.jsx("ul",{"data-part":"events","aria-label":"What sends a notification",className:"mt-3 flex flex-col",children:lt.map(s=>n.jsxs("li",{className:"flex items-center justify-between gap-6 border-b border-hairline py-2 last:border-b-0",children:[n.jsx("span",{"aria-hidden":!0,className:"text-body text-ink",children:rs[s]}),n.jsx(je,{label:rs[s],value:e.includes(s)?"on":"off",onValueChange:o=>t(s,o==="on"),options:yw})]},s))})}function jw(){const{on:e,permission:t,events:s,turnOn:o,turnOff:r,chooseEvent:a}=rw();return n.jsx(U,{title:"Notifications",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsxs("div",{className:"flex min-h-button flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:e?"Notifications are on.":"Notifications are off."}),t!=="unsupported"&&n.jsx(F,{size:"sm",onClick:e?r:o,children:e?"Turn off notifications":"Turn on notifications"})]}),e&&n.jsx(kw,{events:s,chooseEvent:a}),e&&s.length===0&&n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"No event is switched on, so none is sent."}),t==="denied"&&n.jsx(G,{title:"Notifications are blocked",className:"mt-3",children:n.jsx("p",{children:"Your browser is blocking notifications from this address. Allow them for this address in the browser's site settings, then turn them on here."})}),t==="unsupported"&&n.jsx(G,{title:"This browser cannot show notifications",className:"mt-3",children:n.jsx("p",{children:"Open Agent Lookout in a browser that can, then turn them on here."})}),n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"With Needs you on, a notification appears each time a session starts waiting for you. It names the session and the reason, and is cleared when the session moves on."}),!e&&n.jsx("p",{className:"mt-2 text-body text-ink-secondary",children:"Once they are on, you can also be told when a session finishes or fails, or ends without saying whether it finished, as when its process stops. Those name the session and what happened, and stay until you clear them."}),n.jsxs("p",{className:"mt-2 text-body text-ink-secondary",children:["On a Mac they also arrive when no dashboard tab is open, for as long as Agent Lookout keeps running, and those stay until you clear them. What each agent can report, under"," ",n.jsx("a",{href:"#sources",className:"rounded-bar underline decoration-rule-strong underline-offset-2 transition-colors duration-120 hover:text-ink",children:"Sources"}),", says which agents can be seen waiting."]})]})})}function qn(e,t,s){return e===null?null:e.status==="unknown"?{state:t,asking:null,title:null,detail:null}:s(e.status,e.readAt)}function Gn({title:e,words:t}){return n.jsx(U,{title:e,children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:t?.state}),t?.asking&&n.jsx("p",{"data-part":"asking",className:"mt-3 text-body text-ink-secondary",children:n.jsx(V,{children:t.asking})}),t?.detail&&(t.title?n.jsx(G,{title:t.title,className:"mt-3",children:n.jsx("p",{children:n.jsx(V,{children:t.detail})})}):n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:n.jsx(V,{children:t.detail})}))]})})}function Nw(e,t,s){const o=e&&t?"the emails and posts you set up":e?"the emails you set up":t?"the webhook posts you set up":null;return s?o===null?"Sent only as repository and branch names, to GitHub through gh":`Sent only in ${o}, and repository and branch names to GitHub`:o===null?"Agent Lookout sends it nowhere":`Sent only in ${o}`}function vw({history:e=null,now:t,onHistoryCleared:s,onTimeRulesChanged:o,snapshot:r=null,inApp:a=Ds(),answering:i=null}={}){const{preference:l,setPreference:d}=Ai(),c=Sn(),u=Bn(cw),f=Bn(fw),h=Bn(pw),g=typeof u?.status=="object"&&u.status.on,x=typeof f?.status=="object"&&f.status.on,w=typeof h?.status=="object"&&gw(h.status);return n.jsxs("div",{"data-slot":"settings-view",className:"grid grid-cols-12 items-start gap-4 max-wide:flex max-wide:flex-col",children:[n.jsxs("div",{className:"col-span-8 flex min-w-0 flex-col gap-4 max-wide:w-full",children:[n.jsx(U,{title:"Theme",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsx(je,{label:"Theme",value:l,onValueChange:d,options:bw}),n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"Night is the default. System follows the setting on your computer, and changes when it does."})]})}),n.jsx(jw,{}),n.jsx(Wg,{onChanged:o,snapshot:r}),n.jsx(ig,{history:e,now:t??c,onCleared:s}),a&&n.jsx(pg,{}),a&&n.jsx(sw,{})]}),n.jsxs("div",{className:"col-span-4 flex min-w-0 flex-col gap-4 max-wide:w-full",children:[n.jsx(Gn,{title:"Email",words:qn(u,"Whether email is set up could not be read.",dw)}),n.jsx(Gn,{title:"Webhook",words:qn(f,"Whether the webhook is set up could not be read.",mw)}),n.jsx(Gn,{title:"Pull requests",words:qn(h,"Whether pull requests are shown could not be read.",ww)}),n.jsx(Xx,{answering:i}),n.jsx(U,{title:"This copy",children:n.jsxs($e,{className:"px-6 pb-3",children:[n.jsxs(X,{label:"Version",mono:!0,children:["v","0.2.5"]}),n.jsx(X,{label:"Your data",children:n.jsx(V,{children:Nw(g,x,w)})})]})})]})]})}function Sw(e){const t=[];for(const s of e){s.capabilities&&t.push({key:s.id,source:s.id,label:s.label,capabilities:s.capabilities});for(const o of s.agents??[])t.push({key:`${s.id}
|
|
3
|
-
${o.label}`,source:s.id,agent:o.label,label:`${o.label} on ${s.label}`,capabilities:o.capabilities})}return t}function Aw({cell:e}){return e.level==="yes"?n.jsx("span",{"data-part":"capability","data-level":"yes",className:"text-ink-secondary",children:Xe.yes}):n.jsx(ne,{content:e.reason,children:n.jsxs("span",{"data-part":"capability","data-level":e.level,tabIndex:0,className:"rounded-bar font-medium text-ink",children:[Xe[e.level],n.jsxs("span",{className:"sr-only",children:[": ",e.reason]})]})})}function Ew({rows:e}){const t="pr-2 pb-2 align-bottom text-caption font-medium text-ink-secondary";return n.jsxs("table",{"data-part":"table",className:"mt-3 w-full table-fixed border-collapse text-left",children:[n.jsxs("colgroup",{children:[n.jsx("col",{className:"w-28"}),tt.map(s=>n.jsx("col",{},s))]}),n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-hairline",children:[n.jsx("th",{scope:"col",className:t,children:"Agent"}),tt.map(s=>n.jsx("th",{scope:"col",className:t,children:Hr[s]},s))]})}),n.jsx("tbody",{children:e.map(s=>n.jsxs("tr",{"data-source":s.source,"data-agent":s.agent,className:"border-b border-hairline last:border-b-0",children:[n.jsx("th",{scope:"row",className:"py-2.5 pr-2 text-body font-semibold text-ink",children:s.label}),tt.map(o=>n.jsx("td",{className:"py-2.5 pr-2 text-body",children:n.jsx(Aw,{cell:s.capabilities[o]})},o))]},s.key))})]})}function Tw(e,t){return e.level==="yes"||t.level==="yes"?e.level===t.level:e.level===t.level&&e.reason===t.reason}const Mw=["jump","stop","answer"];function Cw(e,t){if(e.agent===void 0)return null;const s=t.find(r=>r.agent===void 0&&r.label===e.agent);return s&&tt.every(r=>Mw.includes(r)||Tw(s.capabilities[r],e.capabilities[r]))?s:null}function Iw({rows:e}){return n.jsx("div",{"data-part":"blocks",className:"mt-3 flex flex-col gap-4",children:e.map(t=>{const s=Cw(t,e);return s?n.jsxs("div",{"data-source":t.source,"data-agent":t.agent,children:[n.jsx("h3",{className:"text-row font-semibold text-ink",children:t.label}),n.jsxs("p",{"data-part":"same-as",className:"mt-1 text-body text-ink-secondary",children:["As ",s.label," on this computer, but"," ",n.jsxs("span",{className:"font-medium text-ink",children:["Jump: ",Xe[t.capabilities.jump.level]]}),","," ",n.jsxs("span",{className:"font-medium text-ink",children:["Stop: ",Xe[t.capabilities.stop.level]]})," ","and"," ",n.jsxs("span",{className:"font-medium text-ink",children:["Answer: ",Xe[t.capabilities.answer.level]]}),", which act on this computer only."]})]},t.key):n.jsxs("div",{"data-source":t.source,"data-agent":t.agent,children:[n.jsx("h3",{className:"text-row font-semibold text-ink",children:t.label}),n.jsx($e,{className:"mt-1",children:tt.map(o=>{const r=t.capabilities[o];return n.jsx(X,{label:Hr[o],note:r.level==="yes"?void 0:r.reason,children:n.jsx("span",{"data-part":"capability","data-level":r.level,className:r.level==="yes"?"font-normal text-ink-secondary":void 0,children:Xe[r.level]})},o)})})]},t.key)})})}function $w({sources:e}){const t=vn(),s=Sw(e);return s.length===0?null:n.jsx(U,{"data-slot":"capabilities",title:"What each agent can report",children:n.jsxs("div",{className:"px-6 pb-3",children:[n.jsxs("p",{"data-part":"lead",className:"text-body text-ink-secondary",children:["A signal marked No never appears for that agent, so not seeing it is not good news.",!t&&" Point at No or Partly, or move to it with Tab, to read why."]}),t?n.jsx(Iw,{rows:s}):n.jsx(Ew,{rows:s})]})})}function Lw(e){return e.includes("/")||e.startsWith("~")||/ --?\w/.test(e)}function _w(e){return/^\d+$/.test(e)}function Ow({source:e,sessions:t,now:s,stalled:o}){const r=lf(e,o),a=t.filter(i=>i.source===e.id).length;return n.jsx(U,{"data-slot":"source","data-state":e.state,"data-stalled":o,title:e.label,aside:n.jsx("span",{"data-part":"state",className:"text-body font-medium text-ink-secondary",children:r.state}),children:n.jsxs("div",{className:"px-6 pb-3",children:[e.detail&&n.jsx("p",{"data-part":"detail",className:"text-body wrap-break-word text-ink-secondary",children:n.jsx(V,{children:e.detail})}),e.advice&&n.jsx("p",{"data-part":"advice",className:A("text-body wrap-break-word text-ink-secondary",e.detail&&"mt-2"),children:n.jsx(V,{children:e.advice})}),n.jsxs($e,{className:"mt-2",children:[e.watching?.map((i,l)=>Lw(i.value)?n.jsx(X,{label:i.label,mono:!0,children:n.jsx(qe,{"data-part":"watching",children:i.value})},`${l}-${i.label}`):n.jsx(X,{label:i.label,children:n.jsx("span",{"data-part":"watching",className:A("wrap-anywhere",_w(i.value)&&"tabular-nums"),children:i.value})},`${l}-${i.label}`)),n.jsx(X,{label:"Sessions found",children:n.jsx("span",{className:"tabular-nums",children:a})}),n.jsx(X,{label:"Last checked",children:o?n.jsx("span",{className:"tabular-nums",children:me(e.checkedAt)}):n.jsx(ne,{content:Es(e.checkedAt),mono:!0,align:"end",children:n.jsx("span",{className:"tabular-nums",children:As(s-e.checkedAt)})})})]})]})})}function nr({children:e}){return n.jsx(U,{title:"Sources",children:n.jsx("div",{className:"px-6 pb-6",children:e})})}const Rw="Another machine is one named in AGENT_LOOKOUT_REMOTES, with Agent Lookout running there. It is read over SSH, with your own ssh, and asked for its sessions and nothing else. Its sessions carry its name, and Jump, Stop, Allow and Deny act on this computer only.";function Ww({state:e,now:t}){const{snapshot:s,phase:o}=e,r=o==="stalled",a=s?.sources.some(l=>fe(l.id))??!1;let i;return s?i=s.sources.length>0?s.sources.map(l=>n.jsx(Ow,{source:l,sessions:s.sessions,now:t,stalled:r},l.id)):n.jsx(nr,{children:n.jsx(G,{title:"No sources are set up",children:n.jsx("p",{children:"Agent Lookout is running but is not watching any agent tool."})})}):o==="unreachable"?i=n.jsx(nr,{children:n.jsx(G,{tone:"error",title:ga(e.problemKind),children:n.jsx(wa,{kind:e.problemKind})})}):i=n.jsx(U,{title:"Sources",children:n.jsx(be,{label:"Waiting for the first answer"})}),n.jsxs("div",{"data-slot":"sources-view",className:"grid grid-cols-3 items-start gap-4 max-wide:flex max-wide:flex-col",children:[n.jsxs("div",{className:"col-span-2 flex min-w-0 flex-col gap-4 max-wide:w-full",children:[r&&e.lastOkAt!==null&&n.jsx(G,{tone:"error",title:"Agent Lookout has stopped updating",children:n.jsxs("p",{children:["What follows is from"," ",n.jsx("span",{className:"tabular-nums",children:me(e.lastOkAt)}),". Check that it is still running in your terminal."]})}),i,s&&n.jsx($w,{sources:s.sources})]}),n.jsx(U,{title:"About sources",className:"col-span-1 max-wide:w-full",children:n.jsxs("div",{className:"flex flex-col gap-2 px-6 pb-6 text-body text-ink-secondary",children:[n.jsx("p",{children:"A source is an agent tool Agent Lookout finds sessions in. It reads its files and never writes to them. Agent Lookout stops a Claude Code session only when you press Stop and confirm."}),n.jsx("p",{children:"Status files are how any other agent appears: it writes a small file for each of its sessions in a folder that Agent Lookout reads."}),n.jsx("p",{children:"Unless you set up email or a webhook, Agent Lookout itself sends nothing anywhere. A command listed under a source is that tool's own program, and may reach the tool's own servers, as it does whenever it runs."}),a&&n.jsx("p",{"data-part":"machines",children:n.jsx(V,{children:Rw})})]})})]})}class Pi extends p.Component{state={error:null};static getDerivedStateFromError(t){return{error:t instanceof Error?t:new Error(String(t))}}componentDidCatch(t,s){console.error("Agent Lookout could not draw the page.",t,s.componentStack)}render(){const{error:t}=this.state;return t?n.jsxs("section",{"data-slot":"page-error","aria-label":"Page problem",className:"glass-card mx-auto mt-[6vh] w-full max-w-[620px] p-5",children:[n.jsx(G,{tone:"error",title:"Agent Lookout could not draw this page",action:n.jsx(F,{onClick:()=>this.setState({error:null}),children:"Try again"}),children:n.jsx("p",{children:"Something in the page itself went wrong. Your sessions are not affected: the page changes nothing in them unless you press Stop and confirm. If trying again does not help, reload the page."})}),n.jsx($e,{className:"mt-3",children:n.jsx(X,{label:"What happened",mono:!0,children:t.message||t.name})})]}):this.props.children}}function Pw(e){return p.useSyncExternalStore(e.subscribe,e.getState)}function Dw(e){return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}function Fw(){return document.hidden}function Di(){return p.useSyncExternalStore(Dw,Fw)}const Kn="Agent Lookout";function Uw(e){p.useEffect(()=>(document.title=e>0?`(${e}) ${Kn}`:Kn,()=>{document.title=Kn}),[e])}const Fi="agent-lookout-last-looked";function zw(){try{const e=Number(localStorage.getItem(Fi));return Number.isSafeInteger(e)&&e>0?e:null}catch{return null}}function Hw(e){try{localStorage.setItem(Fi,String(e))}catch{}}function Bw(e,t,s){const o=Di(),r=Sn(),[a,i]=p.useState(!1),[l,d]=p.useState(()=>Tf(zw())),c=Mf(l,{now:r,visible:!o&&s,overview:t,lineInView:a,newestAt:e[0]?.at??null});c!==l&&d(c);const u=p.useRef(c);return p.useEffect(()=>{u.current=c}),p.useEffect(()=>{const f=()=>{const{away:g,overview:x,leftAt:w,since:m}=u.current,v=m??(!g&&x?Date.now():w);v!==null&&Hw(v)},h=()=>{document.hidden&&f()};return document.addEventListener("visibilitychange",h),window.addEventListener("pagehide",f),()=>{document.removeEventListener("visibilitychange",h),window.removeEventListener("pagehide",f)}},[]),{since:c.since,onLineInView:i}}function qw(e){const t=p.useEffectEvent(s=>{if(s.defaultPrevented||s.repeat||s.isComposing)return;const o=gx(s.target),r=bx(s,{mac:Hs(),typing:o});r!==null&&e(r)&&s.preventDefault()});p.useEffect(()=>{const s=o=>t(o);return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[])}function Ui(e){return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}function Gw(){return Bx(window.location.hash)}function Kw(){return Oa(window.location.hash)}function Vw(){return p.useSyncExternalStore(Ui,Gw)}function Yw(){return p.useSyncExternalStore(Ui,Kw)}const Jw="agent-lookout-notifications";function Xw(e){if(typeof e!="object"||e===null)return[];const{handedOver:t}=e;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function Qw(e){let t;try{t=new BroadcastChannel(Jw),t.addEventListener("message",s=>{const o=Xw(s.data);o.length>0&&e(o)})}catch{t=null}return{handOver(s){if(!t||s.length===0)return;const o={handedOver:[...s]};try{t.postMessage(o)}catch{}},close(){t?.close(),t=null}}}function Zw(){let e=null,t=[],s=[];const o=a=>t.find(i=>i.session.id===a&&i.endedAt===null),r=a=>{for(let i=t.length-1;i>=0;i-=1){const l=t[i];if(l.session.id===a)return l}};return{holding:()=>e!==null,begin(a){e??=a},holdWait(a,i){const l=r(a.id);if(l?.begunAt===i){l.endedAt=null;return}l&&l.endedAt===null&&(l.endedAt=i),t.push({session:an(a),begunAt:i,endedAt:null})},holdOver(a,i,l){s.push({event:a,session:an(i),at:l})},waitEnded(a,i){const l=o(a);l&&(l.endedAt=i)},holdsWait:a=>o(a)!==void 0,end(a,i,l){const d=new Map(a.sessions.map(m=>[m.id,m])),c=new Map;for(const m of t){const v=d.get(m.session.id);v?.status==="needs-you"&&(m.endedAt===null||v.statusSince===m.begunAt)&&c.set(m.session.id,m)}const u=[];for(const[m,v]of c)u.push({session:d.get(m),begunAt:v.begunAt});const f=new Map,h=new Map;for(const m of t){if(c.get(m.session.id)?.begunAt===m.begunAt||l)continue;const v=Math.max(0,(m.endedAt??i)-m.begunAt);h.set(m.session.id,m.begunAt);const b=f.get(m.session.id);b?(b.waitedMs+=v,b.times+=1):f.set(m.session.id,{event:"needs-you",session:m.session,at:m.begunAt,waitedMs:v,times:1})}const g=[];for(const m of s){const v=f.get(m.session.id),b=h.get(m.session.id);v&&v.then===void 0&&b!==void 0&&m.at>=b?v.then={event:m.event,at:m.at}:g.push(m)}const x=[...f.values(),...g].sort((m,v)=>m.at-v.at),w=e??i;return e=null,t=[],s=[],{summary:x.length>0?{from:w,to:i,items:x}:null,open:u}}}}const sr=["sun","mon","tue","wed","thu","fri","sat"];function eb(e,t){if(!e.on)return!1;const s=St(e.from),o=St(e.to);if(s===null||o===null||s===o)return!1;const r=new Date(t),a=r.getHours()*60+r.getMinutes(),i=sr[r.getDay()];if(s<o)return a>=s&&a<o&&e.days.includes(i);if(a>=s)return e.days.includes(i);if(a<o){const l=sr[(r.getDay()+6)%7];return e.days.includes(l)}return!1}function tb(e){return e.quiet??eb(mr(e).quietHours,e.generatedAt)}function nb(e){return new Set(e.sources.filter(t=>t.state==="ok"||t.state==="not-set-up").map(t=>t.id))}function sb(){const e=new Map;return{observe(t,s,o){for(const a of s)e.delete(a);const r=nb(t);for(const a of t.sessions){if(a.status!=="needs-you"||!r.has(a.source))continue;const i=a.statusSince!==null&&a.statusSince<=o?a.statusSince:null,l=e.get(a.id);l&&(i===null||i===l.begunAt)||e.set(a.id,{begunAt:i??o,firstSeenAfterMs:i===null?0:o-i,reminded:new Set})}},due(t,s,o,r=()=>!0){const a=[];for(const i of t.sessions){if(i.status!=="needs-you")continue;const l=e.get(i.id);if(!l||l.reminded.has(o)||!r(i.id))continue;const d=s-l.begunAt;d<o||l.firstSeenAfterMs>=o||a.push({session:i,begunAt:l.begunAt,waitedMs:d})}return a},reminded(t,s){e.get(t)?.reminded.add(s)},toldLate(t,s,o){const r=e.get(t);r&&s-r.begunAt>=o&&r.reminded.add(o)},clear(){e.clear()}}}const ob=6e4;function zi(e){return e<ob?"under a minute":vs(ct(e).filter(t=>t.unit!=="s"))}const rb={permission:"for permission",question:"for an answer",other:"for you"};function ab(e,t){return`has waited ${zi(t)} ${rb[e.waitingReason??"other"]}`}function ib(e,t){const s=ab(e,t),o=`${s.charAt(0).toUpperCase()}${s.slice(1)}`,r=e.waitingText?.trim();return{title:bn(e),body:r?`${o}: ${r}`:o}}const lb="While quiet";function cb(e){const t=zi(e.waitedMs);return e.times===1?`waited ${t}`:`waited ${t} over ${e.times} waits`}function db(e,t=$s){const s=Jd(t(e.session));if(e.event!=="needs-you")return`${s} ${So(e.event)}`;const o=`${s} ${cb(e)}`;return e.then?`${o} then ${So(e.then.event)}`:o}function ub(e,t=4,s=$s){const o=e.slice(0,t).map(a=>db(a,s)),r=e.length-o.length;return r===0?o.length<=1?o[0]??"":`${o.slice(0,-1).join(", ")} and ${o[o.length-1]}`:`${o.join(", ")} and ${r} more`}function fb(e){return{title:lb,body:ub(e,void 0,bn)}}const mb="agent-lookout:while-quiet";function hb(e){return`agent-lookout:${e.id}`}function Vn(e){try{e.close()}catch{}}function pb({host:e,isOn:t}){let s=fo,o=null,r=null;const a=new Map,i=new Map,l=sb(),d=Zw();let c=!1;function u(x){const w=a.get(x);w&&(a.delete(x),Vn(w.notification))}function f(x,w=Ff(x)){const{session:m}=x;u(m.id);const v=i.get(m.id);v&&(i.delete(m.id),Vn(v));let b;try{b=e.show({...w,tag:hb(m)})}catch{b=null}if(!b)return;const k=b;if(x.event!=="needs-you"){i.set(m.id,k),k.onClosed(()=>{i.get(m.id)===k&&i.delete(m.id)});return}a.set(m.id,{notification:k,source:m.source}),k.onClosed(()=>{a.get(m.id)?.notification===k&&a.delete(m.id)})}function h(x){try{e.show({...x,tag:mb})}catch{}}function g(x,w){const{event:m,session:v}=x;if(m==="needs-you"){const b=v.statusSince;d.holdWait(v,b!==null&&b<=w?b:w)}else d.holdOver(m,an(v),w)}return{handle(x,w=null){if(!x)return;r=x,w!==null&&(o!==null&&o!==w&&(s=fo,l.clear()),o=w);const m=x.generatedAt,v=mr(x),b=tb(x);c=b;const k=v.longWait.minutes*6e4,N=sd(s,x);s=N.memory;for(const j of N.stopped)u(j),d.waitEnded(j,m);l.observe(x,N.stopped,m);for(const[j,{source:E}]of a){const S=s.waits.get(E);S&&!S.has(j)&&u(j)}if(d.holding()&&!b){const j=d.end(x,m,v.quietHours.leaveOutAnswered),E=j.summary?.items.filter(S=>t(S.event))??[];if(E.length>0&&h(fb(E)),t("needs-you"))for(const{session:S}of j.open)f({event:"needs-you",session:S}),v.longWait.on&&l.toldLate(S.id,m,k)}b&&d.begin(m);for(const j of N.changes)t(j.event)&&(b?g(j,m):f(j));if(!b&&v.longWait.on&&t("needs-you"))for(const j of l.due(x,m,k))l.reminded(j.session.id,k),f({event:"needs-you",session:j.session},ib(j.session,j.waitedMs))},closeAll(){const x=[...a.keys()],w=[...a.values()];a.clear();for(const{notification:m}of w)Vn(m);return x},showAgain(x){if(!r||c)return;const w=new Set(x);for(const m of r.sessions)!w.has(m.id)||m.status!=="needs-you"||s.waits.get(m.source)?.has(m.id)&&(w.delete(m.id),t("needs-you")&&f({event:"needs-you",session:m}))}}}const Yn=e=>Ns().includes(e),or=()=>qr(Ns());async function xb(){try{await Z("/api/health",{keepalive:!0})}catch{}}function gb(e){p.useEffect(()=>{const t=pb({host:{show:c=>ys().show(c)},isOn:Yn}),s=()=>{const{snapshot:c,history:u}=e.getState();t.handle(c,u?.startedAt??null)};s();const o=e.subscribe(s);let r=or(),a=Yn("needs-you");const i=Jr(()=>{const c=or();c!==r&&xb(),r=c;const u=Yn("needs-you");a&&!u&&t.closeAll(),a=u}),l=Qw(c=>t.showAgain(c)),d=()=>l.handOver(t.closeAll());return window.addEventListener("pagehide",d),()=>{o(),i(),window.removeEventListener("pagehide",d),d(),l.close()}},[e])}const wb=p.lazy(()=>dr(()=>import("./HistoryPanel-TXa0oPH4.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.HistoryPanel}))),bb=p.lazy(()=>dr(()=>import("./SessionPanel-BStoG7uq.js"),__vite__mapDeps([4,1,2,3])).then(e=>({default:e.SessionPanel}))),yb=["needsYou","working","idle"];function kb(){const e=Di(),t=(s,o)=>n.jsxs("div",{"aria-hidden":!0,"data-slot":s,"data-drift":e?"paused":void 0,className:o,children:[n.jsx("i",{className:"ground-main"}),n.jsx("i",{className:"ground-deep"}),n.jsx("i",{className:"ground-far"})]});return n.jsxs(n.Fragment,{children:[t("ground","ground"),t("ground-above","ground bottom-auto z-10 h-window bg-fixed")]})}function jb({store:e}){const[t]=p.useState(()=>e??Hu({beat:_d})),s=Pw(t);gb(t);const o=Sn(),r=Vw(),a=Yw(),[i,l]=p.useState(null),[d,c]=p.useState(!1),[u,f]=p.useState(!1),h=p.useRef(null),g=p.useRef(r),x=Bw(s.events,r==="overview",s.snapshot!==null),w=Qf(s.snapshot?.sessions);Uw(w);const m=s.snapshot?w:null;p.useEffect(()=>{g.current!==r&&(g.current=r,h.current?.focus({preventScroll:!0}),window.scrollTo({top:0}))},[r]);const v=ox(h,r);qw(k=>{if(i!==null||u||a!==null)return!1;if(k==="search")c(N=>!N);else{if(d)return!1;f(!0)}return!0});const b=s.snapshot?"dashboard":s.phase==="unreachable"?"problem":"loading";return n.jsxs(qi,{reducedMotion:"user",children:[n.jsx(kb,{}),n.jsxs("div",{"data-slot":"frame",className:"flex min-h-screen gap-window p-window",children:[n.jsx(Vx,{current:r,needsYou:m}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4 pb-7",children:[n.jsx(Nx,{phase:s.phase,snapshot:s.snapshot,lastOkAt:s.lastOkAt,now:o,onSearch:()=>c(!0)}),n.jsx("main",{ref:h,tabIndex:-1,"aria-label":qx(r),"data-view":r,className:"flex-1 outline-none",children:n.jsx(Pi,{children:r==="sources"?n.jsx(Ww,{state:s,now:o}):r==="settings"?n.jsx(vw,{history:s.history,now:o,onHistoryCleared:t.refresh,onTimeRulesChanged:t.refresh,snapshot:s.snapshot,answering:s.snapshot?.answering??null}):n.jsx(Gi,{mode:"wait",initial:!1,children:n.jsx(Ki.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18,ease:"easeOut"},children:n.jsx(rx,{state:s,now:o,onRetry:t.refresh,onEnded:t.refresh,onAnswered:t.refresh,onOpenHistory:l,newSince:x.since,onNewLineInView:x.onLineInView})},b)})},r)})]})]}),n.jsxs(p.Suspense,{fallback:null,children:[yb.map(k=>n.jsx(wb,{metric:k,open:i===k,onOpenChange:N=>l(N?k:null),state:s,now:o},k)),n.jsx(bb,{sessionId:a,onClose:Wm,state:s,now:o,onStopped:t.refresh,onAnswered:t.refresh})]}),n.jsx(Ix,{open:d,onOpenChange:c,state:s,now:o,onChoose:v,onShortcuts:()=>f(!0)}),n.jsx(Wx,{open:u,onOpenChange:f})]})}jm();const Hi=document.getElementById("root");if(!Hi)throw new Error("index.html has no #root element to render into.");Bi.createRoot(Hi).render(n.jsx(p.StrictMode,{children:n.jsx(Pi,{children:n.jsx(jb,{})})}));export{te as $,Ea as A,$t as B,G as C,Lx as D,Nf as E,X as F,vf as G,wo as H,Sa as I,Ct as J,$e as K,be as L,xn as M,Ts as N,qe as O,da as P,Ob as Q,$b as R,je as S,ie as T,Ib as U,Lp as V,yn as W,Qa as X,Zu as Y,ya as Z,yh as _,me as a,Ms as a0,ke as a1,Y as a2,am as a3,F as a4,Mb as b,A as c,Rd as d,Tb as e,Q as f,Eb as g,ye as h,Ot as i,Qf as j,we as k,mn as l,Pd as m,pl as n,_b as o,Lb as p,ti as q,Cb as r,Ab as s,Qr as t,jn as u,Wb as v,an as w,kn as x,Rb as y,Va as z};
|