agent-lookout 0.2.4 → 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.
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HistoryPanel-CIjshvhu.js","assets/react-C2DiJaR6.js","assets/motion-BAhdRuCw.js","assets/radix-BH0JH8UU.js","assets/SessionPanel-eBOdTLD9.js"])))=>i.map(i=>d[i]);
2
- import{j as n,r as p,d as Ga}from"./react-C2DiJaR6.js";import{M as Ka,A as Va,m as qa}from"./motion-BAhdRuCw.js";import{S as Ya,P as Ja,R as Xa,T as Qa,a as Za,C as ei,b as ti,c as ni,d as si,e as oi,D as yo,f as ko,g as jo,h as No,i as vo,j as ri,k as ai}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 ii="modulepreload",li=function(e){return"/"+e},ks={},So=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=li(c),c in ks)return;ks[c]=!0;const u=c.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const m=document.createElement("link");if(m.rel=u?"stylesheet":ii,u||(m.as="script"),m.crossOrigin="",m.href=c,l&&m.setAttribute("nonce",l),document.head.appendChild(m),u)return new Promise((x,g)=>{m.addEventListener("load",x),m.addEventListener("error",()=>g(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)})};function Ao(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=Ao(e[t]))&&(o&&(o+=" "),o+=s)}else for(s in e)e[s]&&(o&&(o+=" "),o+=s);return o}function Eo(){for(var e,t,s=0,o="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=Ao(e))&&(o&&(o+=" "),o+=t);return o}const js=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ns=Eo,To=(e,t)=>s=>{var o;if(t?.variants==null)return Ns(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 m=js(u)||js(f);return r[c][m]}),l=s&&Object.entries(s).reduce((c,u)=>{let[f,m]=u;return m===void 0||(c[f]=m),c},{}),d=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((c,u)=>{let{class:f,className:m,...x}=u;return Object.entries(x).every(g=>{let[b,h]=g;return Array.isArray(h)?h.includes({...a,...l}[b]):{...a,...l}[b]===h})?[...c,f,m]:c},[]);return Ns(e,i,d,s?.class,s?.className)},ci=(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},di=(e,t)=>({classGroupId:e,validator:t}),Mo=(e=new Map,t=null,s)=>({nextPart:e,validators:t,classGroupId:s}),Ut="-",vs=[],ui="arbitrary..",fi=e=>{const t=hi(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return mi(i);const l=i.split(Ut),d=l[0]===""&&l.length>1?1:0;return Co(l,d,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const d=o[i],c=s[i];return d?c?ci(c,d):d:c||vs}return s[i]||vs}}},Co=(e,t,s)=>{if(e.length-t===0)return s.classGroupId;const r=e[t],a=s.nextPart.get(r);if(a){const c=Co(e,t+1,a);if(c)return c}const i=s.validators;if(i===null)return;const l=t===0?e.join(Ut):e.slice(t).join(Ut),d=i.length;for(let c=0;c<d;c++){const u=i[c];if(u.validator(l))return u.classGroupId}},mi=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?ui+o:void 0})(),hi=e=>{const{theme:t,classGroups:s}=e;return pi(s,t)},pi=(e,t)=>{const s=Mo();for(const o in e){const r=e[o];zn(r,s,o,t)}return s},zn=(e,t,s,o)=>{const r=e.length;for(let a=0;a<r;a++){const i=e[a];xi(i,t,s,o)}},xi=(e,t,s,o)=>{if(typeof e=="string"){gi(e,t,s);return}if(typeof e=="function"){bi(e,t,s,o);return}wi(e,t,s,o)},gi=(e,t,s)=>{const o=e===""?t:Io(t,e);o.classGroupId=s},bi=(e,t,s,o)=>{if(yi(e)){zn(e(o),t,s,o);return}t.validators===null&&(t.validators=[]),t.validators.push(di(s,e))},wi=(e,t,s,o)=>{const r=Object.entries(e),a=r.length;for(let i=0;i<a;i++){const[l,d]=r[i];zn(d,Io(t,l),s,o)}},Io=(e,t)=>{let s=e;const o=t.split(Ut),r=o.length;for(let a=0;a<r;a++){const i=o[a];let l=s.nextPart.get(i);l||(l=Mo(),s.nextPart.set(i,l)),s=l}return s},yi=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,ki=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)}}},vn="!",Ss=":",ji=[],As=(e,t,s,o,r)=>({modifiers:e,hasImportantModifier:t,baseClassName:s,maybePostfixModifierPosition:o,isExternal:r}),Ni=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 b=0;b<u;b++){const h=r[b];if(i===0&&l===0){if(h===Ss){a.push(r.slice(d,b)),d=b+1;continue}if(h==="/"){c=b;continue}}h==="["?i++:h==="]"?i--:h==="("?l++:h===")"&&l--}const f=a.length===0?r:r.slice(d);let m=f,x=!1;f.endsWith(vn)?(m=f.slice(0,-1),x=!0):f.startsWith(vn)&&(m=f.slice(1),x=!0);const g=c&&c>d?c-d:void 0;return As(a,x,m,g)};if(t){const r=t+Ss,a=o;o=i=>i.startsWith(r)?a(i.slice(r.length)):As(ji,!1,i,void 0,!0)}if(s){const r=o;o=a=>s({className:a,parseClassName:r})}return o},vi=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}},Si=e=>({cache:ki(e.cacheSize),parseClassName:Ni(e),sortModifiers:vi(e),postfixLookupClassGroupIds:Ai(e),...fi(e)}),Ai=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},Ei=/\s+/,Ti=(e,t)=>{const{parseClassName:s,getClassGroupId:o,getConflictingClassGroupIds:r,sortModifiers:a,postfixLookupClassGroupIds:i}=t,l=[],d=e.trim().split(Ei);let c="";for(let u=d.length-1;u>=0;u-=1){const f=d[u],{isExternal:m,modifiers:x,hasImportantModifier:g,baseClassName:b,maybePostfixModifierPosition:h}=s(f);if(m){c=f+(c.length>0?" "+c:c);continue}let v=!!h,y;if(v){const T=b.substring(0,h);y=o(T);const w=y&&i[y]?o(b):void 0;w&&w!==y&&(y=w,v=!1)}else y=o(b);if(!y){if(!v){c=f+(c.length>0?" "+c:c);continue}if(y=o(b),!y){c=f+(c.length>0?" "+c:c);continue}v=!1}const j=x.length===0?"":x.length===1?x[0]:a(x).join(":"),N=g?j+vn:j,S=N+y;if(l.indexOf(S)>-1)continue;l.push(S);const C=r(y,v);for(let T=0;T<C.length;++T){const w=C[T];l.push(N+w)}c=f+(c.length>0?" "+c:c)}return c},Mi=(...e)=>{let t=0,s,o,r="";for(;t<e.length;)(s=e[t++])&&(o=Lo(s))&&(r&&(r+=" "),r+=o);return r},Lo=e=>{if(typeof e=="string")return e;let t,s="";for(let o=0;o<e.length;o++)e[o]&&(t=Lo(e[o]))&&(s&&(s+=" "),s+=t);return s},Es=(e,...t)=>{let s,o,r,a;const i=d=>{const c=t.reduce((u,f)=>f(u),e());return s=Si(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=Ti(d,s);return r(d,u),u};return a=i,(...d)=>a(Mi(...d))},Ci=[],B=e=>{const t=s=>s[e]||Ci;return t.isThemeGetter=!0,t.themeKey=e,t},Oo=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$o=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ii=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Li=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Oi=/\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$/,$i=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,_i=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ri=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ve=e=>Ii.test(e),$=e=>!!e&&!Number.isNaN(Number(e)),ue=e=>!!e&&Number.isInteger(Number(e)),an=e=>e.endsWith("%")&&$(e.slice(0,-1)),ye=e=>Li.test(e),_o=()=>!0,Pi=e=>Oi.test(e)&&!$i.test(e),Un=()=>!1,Wi=e=>_i.test(e),Fi=e=>Ri.test(e),Di=e=>!A(e)&&!E(e),zi=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)),Ui=e=>Te(e,Wo,Un),A=e=>Oo.test(e),Ie=e=>Te(e,Fo,Pi),Ts=e=>Te(e,Ji,$),Hi=e=>Te(e,zo,_o),Bi=e=>Te(e,Do,Un),Ms=e=>Te(e,Ro,Un),Gi=e=>Te(e,Po,Fi),Ct=e=>Te(e,Uo,Wi),E=e=>$o.test(e),et=e=>Pe(e,Fo),Ki=e=>Pe(e,Do),Cs=e=>Pe(e,Ro),Vi=e=>Pe(e,Wo),qi=e=>Pe(e,Po),It=e=>Pe(e,Uo,!0),Yi=e=>Pe(e,zo,!0),Te=(e,t,s)=>{const o=Oo.exec(e);return o?o[1]?t(o[1]):s(o[2]):!1},Pe=(e,t,s=!1)=>{const o=$o.exec(e);return o?o[1]?t(o[1]):s:!1},Ro=e=>e==="position"||e==="percentage",Po=e=>e==="image"||e==="url",Wo=e=>e==="length"||e==="size"||e==="bg-size",Fo=e=>e==="length",Ji=e=>e==="number",Do=e=>e==="family-name",zo=e=>e==="number"||e==="weight",Uo=e=>e==="shadow",Is=()=>{const e=B("color"),t=B("font"),s=B("text"),o=B("font-weight"),r=B("tracking"),a=B("leading"),i=B("breakpoint"),l=B("container"),d=B("spacing"),c=B("radius"),u=B("shadow"),f=B("inset-shadow"),m=B("text-shadow"),x=B("drop-shadow"),g=B("blur"),b=B("perspective"),h=B("aspect"),v=B("ease"),y=B("animate"),j=()=>["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"],S=()=>[...N(),E,A],C=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],w=()=>[E,A,d],_=()=>[ve,"full","auto",...w()],F=()=>[ue,"none","subgrid",E,A],I=()=>["auto",{span:["full",ue,E,A]},ue,E,A],L=()=>[ue,"auto",E,A],O=()=>["auto","min","max","fr",E,A],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Y=()=>["start","end","center","stretch","center-safe","end-safe"],re=()=>["auto",...w()],we=()=>[ve,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...w()],Ze=()=>[l,ve,"screen","full","dvw","lvw","svw","min","max","fit",...w()],D=()=>[ve,"screen","full","lh","dvh","lvh","svh","min","max","fit",...w()],M=()=>[e,E,A],ae=()=>[...N(),Cs,Ms,{position:[E,A]}],gs=()=>["no-repeat",{repeat:["","x","y","space","round"]}],bs=()=>["auto","cover","contain",Vi,Ui,{size:[E,A]}],on=()=>[an,et,Ie],Z=()=>["","none","full",c,E,A],ee=()=>["",$,et,Ie],At=()=>["solid","dashed","dotted","double"],ws=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[$,an,Cs,Ms],ys=()=>["","none",g,E,A],Et=()=>["none",$,E,A],Tt=()=>["none",$,E,A],rn=()=>[$,E,A],Mt=()=>[ve,"full",...w()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ye],breakpoint:[ye],color:[_o],container:[ye],"drop-shadow":[ye],ease:["in","out","in-out"],font:[Di],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ye],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ye],shadow:[ye],spacing:["px",$],text:[ye],"text-shadow":[ye],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ve,A,E,h]}],container:["container"],"container-type":[{"@container":["","normal","size",E,A]}],"container-named":[zi],columns:[{columns:[$,"auto",A,E,l]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"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:S()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:_()}],"inset-x":[{"inset-x":_()}],"inset-y":[{"inset-y":_()}],start:[{"inset-s":_(),start:_()}],end:[{"inset-e":_(),end:_()}],"inset-bs":[{"inset-bs":_()}],"inset-be":[{"inset-be":_()}],top:[{top:_()}],right:[{right:_()}],bottom:[{bottom:_()}],left:[{left:_()}],visibility:["visible","invisible","collapse"],z:[{z:[ue,"auto",E,A]}],basis:[{basis:[ve,"full","auto",l,...w()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[$,ve,"auto","initial","none",A]}],grow:[{grow:["",$,E,A]}],shrink:[{shrink:["",$,E,A]}],order:[{order:[ue,"first","last","none",E,A]}],"grid-cols":[{"grid-cols":F()}],"col-start-end":[{col:I()}],"col-start":[{"col-start":L()}],"col-end":[{"col-end":L()}],"grid-rows":[{"grid-rows":F()}],"row-start-end":[{row:I()}],"row-start":[{"row-start":L()}],"row-end":[{"row-end":L()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...Y(),"normal"]}],"justify-self":[{"justify-self":["auto",...Y()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...Y(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Y(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...Y(),"baseline"]}],"place-self":[{"place-self":["auto",...Y()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:re()}],mx:[{mx:re()}],my:[{my:re()}],ms:[{ms:re()}],me:[{me:re()}],mbs:[{mbs:re()}],mbe:[{mbe:re()}],mt:[{mt:re()}],mr:[{mr:re()}],mb:[{mb:re()}],ml:[{ml:re()}],"space-x":[{"space-x":w()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":w()}],"space-y-reverse":["space-y-reverse"],size:[{size:we()}],"inline-size":[{inline:["auto",...Ze()]}],"min-inline-size":[{"min-inline":["auto",...Ze()]}],"max-inline-size":[{"max-inline":["none",...Ze()]}],"block-size":[{block:["auto",...D()]}],"min-block-size":[{"min-block":["auto",...D()]}],"max-block-size":[{"max-block":["none",...D()]}],w:[{w:[l,"screen",...we()]}],"min-w":[{"min-w":[l,"screen","none",...we()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...we()]}],h:[{h:["screen","lh",...we()]}],"min-h":[{"min-h":["screen","lh","none",...we()]}],"max-h":[{"max-h":["screen","lh","none",...we()]}],"font-size":[{text:["base",s,et,Ie]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,Yi,Hi]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",an,A]}],"font-family":[{font:[Ki,Bi,t]}],"font-features":[{"font-features":[A]}],"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,E,A]}],"line-clamp":[{"line-clamp":[$,"none",E,Ts]}],leading:[{leading:["none",a,...w()]}],"list-image":[{"list-image":["none",E,A]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",E,A]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...At(),"wavy"]}],"text-decoration-thickness":[{decoration:[$,"from-font","auto",E,Ie]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[$,"auto",E,A]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:w()}],"tab-size":[{tab:[ue,E,A]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",E,A]}],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",E,A]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ae()}],"bg-repeat":[{bg:gs()}],"bg-size":[{bg:bs()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ue,E,A],radial:["",E,A],conic:["",ue,E,A]},qi,Gi]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:on()}],"gradient-via-pos":[{via:on()}],"gradient-to-pos":[{to:on()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"border-w":[{border:ee()}],"border-w-x":[{"border-x":ee()}],"border-w-y":[{"border-y":ee()}],"border-w-s":[{"border-s":ee()}],"border-w-e":[{"border-e":ee()}],"border-w-bs":[{"border-bs":ee()}],"border-w-be":[{"border-be":ee()}],"border-w-t":[{"border-t":ee()}],"border-w-r":[{"border-r":ee()}],"border-w-b":[{"border-b":ee()}],"border-w-l":[{"border-l":ee()}],"divide-x":[{"divide-x":ee()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ee()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...At(),"hidden","none"]}],"divide-style":[{divide:[...At(),"hidden","none"]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...At(),"none","hidden"]}],"outline-offset":[{"outline-offset":[$,E,A]}],"outline-w":[{outline:["",$,et,Ie]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","inner","none",u,It,Ct]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",f,It,Ct]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[$,Ie]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":ee()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",m,It,Ct]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[$,E,A]}],"mix-blend":[{"mix-blend":[...ws(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ws()}],"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":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[E,A]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"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":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ae()}],"mask-repeat":[{mask:gs()}],"mask-size":[{mask:bs()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",E,A]}],filter:[{filter:["","none",E,A]}],blur:[{blur:ys()}],brightness:[{brightness:[$,E,A]}],contrast:[{contrast:[$,E,A]}],"drop-shadow":[{"drop-shadow":["","none",x,It,Ct]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",$,E,A]}],"hue-rotate":[{"hue-rotate":[$,E,A]}],invert:[{invert:["",$,E,A]}],saturate:[{saturate:[$,E,A]}],sepia:[{sepia:["",$,E,A]}],"backdrop-filter":[{"backdrop-filter":["","none",E,A]}],"backdrop-blur":[{"backdrop-blur":ys()}],"backdrop-brightness":[{"backdrop-brightness":[$,E,A]}],"backdrop-contrast":[{"backdrop-contrast":[$,E,A]}],"backdrop-grayscale":[{"backdrop-grayscale":["",$,E,A]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[$,E,A]}],"backdrop-invert":[{"backdrop-invert":["",$,E,A]}],"backdrop-opacity":[{"backdrop-opacity":[$,E,A]}],"backdrop-saturate":[{"backdrop-saturate":[$,E,A]}],"backdrop-sepia":[{"backdrop-sepia":["",$,E,A]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",E,A]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[$,"initial",E,A]}],ease:[{ease:["linear","initial",v,E,A]}],delay:[{delay:[$,E,A]}],animate:[{animate:["none",y,E,A]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,E,A]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:Et()}],"rotate-x":[{"rotate-x":Et()}],"rotate-y":[{"rotate-y":Et()}],"rotate-z":[{"rotate-z":Et()}],scale:[{scale:Tt()}],"scale-x":[{"scale-x":Tt()}],"scale-y":[{"scale-y":Tt()}],"scale-z":[{"scale-z":Tt()}],"scale-3d":["scale-3d"],skew:[{skew:rn()}],"skew-x":[{"skew-x":rn()}],"skew-y":[{"skew-y":rn()}],transform:[{transform:[E,A,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Mt()}],"translate-x":[{"translate-x":Mt()}],"translate-y":[{"translate-y":Mt()}],"translate-z":[{"translate-z":Mt()}],"translate-none":["translate-none"],zoom:[{zoom:[ue,E,A]}],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"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",E,A]}],"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":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"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",E,A]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[$,et,Ie,Ts]}],stroke:[{stroke:["none",...M()]}],"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"]}},Xi=(e,{cacheSize:t,prefix:s,experimentalParseClassName:o,extend:r={},override:a={}})=>(Ue(e,"cacheSize",t),Ue(e,"prefix",s),Ue(e,"experimentalParseClassName",o),Lt(e.theme,a.theme),Lt(e.classGroups,a.classGroups),Lt(e.conflictingClassGroups,a.conflictingClassGroups),Lt(e.conflictingClassGroupModifiers,a.conflictingClassGroupModifiers),Ue(e,"postfixLookupClassGroups",a.postfixLookupClassGroups),Ue(e,"orderSensitiveModifiers",a.orderSensitiveModifiers),Ot(e.theme,r.theme),Ot(e.classGroups,r.classGroups),Ot(e.conflictingClassGroups,r.conflictingClassGroups),Ot(e.conflictingClassGroupModifiers,r.conflictingClassGroupModifiers),Sn(e,r,"postfixLookupClassGroups"),Sn(e,r,"orderSensitiveModifiers"),e),Ue=(e,t,s)=>{s!==void 0&&(e[t]=s)},Lt=(e,t)=>{if(t)for(const s in t)Ue(e,s,t[s])},Ot=(e,t)=>{if(t)for(const s in t)Sn(e,t,s)},Sn=(e,t,s)=>{const o=t[s];o!==void 0&&(e[s]=e[s]?e[s].concat(o):o)},Qi=(e,...t)=>typeof e=="function"?Es(Is,e,...t):Es(()=>Xi(Is(),e),...t),Zi=["wait","name","stat","unit","wordmark","lead","title","row","body","fact","caption","micro"],el=["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"],tl=Qi({extend:{theme:{text:Zi,spacing:el,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 k(...e){return tl(Eo(e))}const nl=To(["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 z({className:e,variant:t,size:s,asChild:o=!1,...r}){const a=o?Ya:"button";return n.jsx(a,{"data-slot":"button","data-variant":t??"quiet",...o?{}:{type:"button"},className:k(nl({variant:t,size:s}),e),...r})}const sl=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function ol(e,t,s=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:sl(e),size:24,node:t,...s.length>0?{aliases:s}:{}}}const rl=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 al=e=>{const t=rl(e);return t.charAt(0).toUpperCase()+t.slice(1)};const An=(...e)=>e.filter((t,s,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===s).join(" ").trim();const Le={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 ln(e){return e!=null}function il(e,t={}){const s=t.attributeNames??{},o=m=>s[m]??m,r=e.size??e.width??Le.width,a=e.size??e.height??Le.height,i=e.aliases?.filter(m=>typeof m=="string"&&m.trim()!=="").map(m=>`lucide-${m}`)??[],l=[...e.name?[`lucide-${e.name}`]:[],...i],d=t.className?.split(" ").filter(Boolean)??[],c=t.includeDefaultClasses===!1?An(...d):An("lucide",...l,...d),u=t.absoluteStrokeWidth?Number(t.strokeWidth??Le["stroke-width"])*Number(e.size??e.width??Le.width)/Number(t.size??t.width??Le.width):t.strokeWidth??Le["stroke-width"];return["svg",{...Object.entries(Le).reduce((m,[x,g])=>(m[o(x)]=g,m),{}),..."color"in t&&t.color&&{[o("stroke")]:t.color},..."size"in t&&ln(t.size)&&{[o("width")]:t.size,[o("height")]:t.size},..."width"in t&&ln(t.width)&&{[o("width")]:t.width},..."height"in t&&ln(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(m=>{const[x,g,b]=m,h=t.nonScalingStroke?{[o("vector-effect")]:"non-scaling-stroke",...g}:g;return b?[x,h,b]:[x,h]})]}function ll(e,t={}){return il(e,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}const cl=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},dl=p.createContext({}),ul=()=>p.useContext(dl),fl=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},m)=>{const{size:x=24,strokeWidth:g=2,absoluteStrokeWidth:b=!1,nonScalingStroke:h=!1,color:v="currentColor",className:y=""}=ul()??{},j=!!d||cl(f),[N,S,C=[]]=ll(u,{color:e??v,width:s??t??x,height:o??t??x,strokeWidth:r??g,absoluteStrokeWidth:a??b,nonScalingStroke:i??h,className:An(y,l),hasA11yProp:j,attributes:f});return p.createElement(N,{ref:m,...S},[...C.map(([T,w])=>p.createElement(T,w)),...Array.isArray(d)?d:[d]])});function be(e,t=[],s=[]){const o=typeof e=="string"?ol(e,t,s):e,r=p.forwardRef(({className:a,...i},l)=>p.createElement(fl,{ref:l,icon:o,className:a,...i}));return o.name&&(r.displayName=al(o.name)),r}const Ho={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};Ho.node;const ml=be(Ho);const Bo={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};Bo.node;const hl=be(Bo);const Go={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};Go.node;const pl=be(Go);const Ko={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Ko.node;const xl=be(Ko);const Vo={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Vo.node;const gl=be(Vo);const qo={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"]};qo.node;const bl=be(qo);const Yo={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"}]]};Yo.node;const wl=be(Yo);const Jo={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"}]]};Jo.node;const yl=be(Jo);const Xo={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Xo.node;const Qo=be(Xo);const Zo={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Zo.node;const kl=be(Zo),jl={info:{box:"bg-fill-quiet inset-ring inset-ring-hairline",icon:"text-ink-muted",Icon:yl},error:{box:"bg-fill-selected inset-ring inset-ring-rule-strong shadow-edge",icon:"text-ink",Icon:bl}};function q({tone:e="info",title:t,children:s,action:o,className:r}){const{box:a,icon:i,Icon:l}=jl[e];return n.jsxs("div",{"data-slot":"callout","data-tone":e,role:e==="info"?"status":"alert",className:k("flex items-start gap-3 rounded-inner px-4 py-3",a,r),children:[n.jsx(l,{"aria-hidden":!0,className:k("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 Me({children:e,className:t}){return n.jsx("dl",{"data-slot":"fact-list",className:k("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:k("items-baseline border-b border-hairline py-2.5 last:border-b-0",o===void 0?"flex justify-between gap-6":"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:k("min-w-0 text-right text-pretty text-ink",s?"font-mono text-fact":"text-body font-medium"),children:t}),o!==void 0&&n.jsx("dd",{"data-part":"note",className:"col-span-2 mt-1 text-caption text-ink-secondary",children:o})]})}const Nl=["claude","gh"],vl=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(?:${Nl.join("|")})\b(?![\w-]|\.\w)(?:(?: [a-z][\w-]*)*(?: --?[a-z][\w-]*)+)?`,String.raw`(?<![\w-])--[a-z][\w-]*`].join("|"),"g"),Sl=/[.,;:!?]+$/;function Al(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(vl)){const a=r.index,i=r[0].replace(Sl,"");i!==""&&(s(e.slice(o,a),!1),s(i,!0),o=a+i.length)}return s(e.slice(o),!1),t}function le({children:e}){return n.jsx(n.Fragment,{children:Al(e).map((t,s)=>t.fact?n.jsx("code",{"data-slot":"fact",className:"font-mono text-fact",children:t.text},s):t.text)})}const El=["terminal","vscode","desktop","cloud","browser","unknown"],Tl={terminal:"Terminal",vscode:"VS Code",desktop:"Desktop app",cloud:"Cloud",browser:"Browser"};function gt(e){return e==="unknown"?null:Tl[e]}const Ht=["needs-you","working","idle","finished","failed","unknown"],Ml=["permission","question","other"],Hn=["Terminal","iTerm2"],Cl=["signal","background"],Il=["open","draft","merged","closed"],Ll=["failing","pending","passing","none"],Ol=["ok","searching","unavailable","not-set-up","error"],er={ok:"Watching",searching:"Searching",unavailable:"Not found","not-set-up":"Not set up",error:"Not working"},lt=["working-and-idle","needs-you","finished","failed","names","jump","quiet-for","stop"],tr={"working-and-idle":"Working and idle","needs-you":"Needs you",finished:"Finished",failed:"Failed",names:"Names",jump:"Jump","quiet-for":"Quiet for",stop:"Stop"},En={yes:"Yes",no:"No",partly:"Partly"},$l=["appeared","status-changed","ended","stopped"],_l=["appeared","status-changed","ended"];function nr(e){return _l.includes(e.kind)}const Rl=["agent-lookout"],Pl=["advisory","warning","critical"];function Wl(e){if(e.waitingText===void 0)return e;const{waitingText:t,...s}=e;return s}function Fl(e,t){return e.agent??t.find(s=>s.id===e.source)?.label??null}const Dl=new Map;function zl(e,t){return e===null?t:t===null?e:t>e?t:e}function Ul(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,zl(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 Xe=["needs-you","finished","failed","ended"],Tn=["needs-you"];function Hl(e){return Xe.includes(e)}function Bl(e){const t=e.trim().toLowerCase();if(t==="")return[];const s=t.split(",").map(o=>o.trim());return s.every(Hl)?Xe.filter(o=>s.includes(o)):null}function mt(e){return Xe.filter(t=>e.includes(t)).join(",")}const Ls={waits:Dl,seen:new Map,over:new Map};function $t(e){return e==="finished"||e==="failed"}function Gl(e,t){return t===void 0?!1:e==="ended"||t==="ended"||t===e}function Kl(e,t){const s=Ul(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,Wl(u)),o.has(u)){a.push({event:"needs-you",session:u});continue}const m=e.seen.get(u.source)?.get(f.basis)?.get(u.id);m&&m.status!==u.status&&$t(u.status)&&a.push({event:u.status,session:u})}for(const[u,{basis:f,sessions:m}]of r)for(const[x,g]of e.seen.get(u)?.get(f)??[])!m.has(x)&&!$t(g.status)&&a.push({event:"ended",session:g});const i=new Map;for(const[u,{sessions:f}]of r){const m=new Map(e.over.get(u));for(const[x,g]of f)$t(g.status)||m.delete(x);i.set(u,m)}const l=a.filter(({event:u,session:f})=>{const m=i.get(f.source);return u==="needs-you"||!m?!0:Gl(u,m.get(f.id))?!1:(m.set(f.id,u),!0)}),d=new Map(e.seen),c=new Map(e.over);for(const[u,{basis:f,sessions:m}]of r){const x=new Map(e.seen.get(u));x.set(f,m),d.set(u,x);const g=i.get(u);for(const[b,h]of m)$t(h.status)&&!g.has(b)&&g.set(b,h.status);for(const b of g.keys())[...x.values()].some(h=>h.has(b))||g.delete(b);c.set(u,g)}return{memory:{waits:s.memory,seen:d,over:c},changes:l,stopped:s.stopped}}const Vl=["started","cleared","trimmed"],ql="clear-history",Yl=6e4,Jl=1e3,Xl="stop",Ql="clean-up",sr=1e4,Ge=20,Zl=["ended","became-active","not-stale","gone","unsupported","cannot-confirm","not-allowed","still-running","failed"],Qe="X-Agent-Lookout-Action",ec=200,tc="X-Agent-Lookout-Notifications";function or(e){const t=mt(e);return t===""?"off":t===mt(Tn)?"on":`on; events=${t}`}const Bt=20,nc=/^(?:[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*\.?|\[[0-9A-Fa-f:.]+\])$/,sc=253;function oc(e){return e.length<=sc&&nc.test(e)}const rc=["unknown","ready","not-found","signed-out"],ac=900*1e3;function ge(e){return e.since??{at:e.startedAt,by:"started"}}function cn(){return typeof window>"u"?null:window.Notification??null}const rr={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(rr.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 ic=rr;function Bn(){return ic}const Gn="agent-lookout-notifications",Kn="agent-lookout-notification-events";function ar(){try{return localStorage.getItem(Gn)==="on"?"on":"off"}catch{return"off"}}function ir(){try{const e=localStorage.getItem(Kn);return(e===null?null:Bl(e))??Tn}catch{return Tn}}let Ke=null,Oe=null,Fe=null,Mn=null,dn=null;const ot=new Set;let ct=null;function bt(){Ke??=ar(),Oe??=ir();const e=Bn().permission();return(!Fe||Fe.choice!==Ke||Fe.permission!==e||Fe.events!==Oe)&&(Fe={choice:Ke,permission:e,on:Ke==="on"&&e==="granted",events:Oe}),Fe}function Vn(){const e=bt();return e.on?e.events:[]}function Se(){const e=bt();if(e!==Mn){Mn=e;for(const t of ot)t()}}function lr(e){Ke=e;try{localStorage.setItem(Gn,e)}catch{}}function lc(){if(ct)return;const e=t=>{if((t.key===null||t.key===Gn)&&(Ke=ar()),t.key===null||t.key===Kn){const s=ir();(Oe===null||mt(s)!==mt(Oe))&&(Oe=s)}Se()};window.addEventListener("storage",e),window.addEventListener("focus",Se),document.addEventListener("visibilitychange",Se),ct=()=>{window.removeEventListener("storage",e),window.removeEventListener("focus",Se),document.removeEventListener("visibilitychange",Se)}}function cr(e){return ot.size===0&&(Mn=bt()),ot.add(e),lc(),()=>{ot.delete(e),ot.size===0&&ct&&(ct(),ct=null)}}async function cc(){const e=Bn();let t=e.permission();if(t==="default")try{t=await e.requestPermission()}catch{t=e.permission()}t==="granted"&&lr("on"),Se()}function dc(){return dn??=cc().finally(()=>{dn=null}),dn}function uc(){lr("off"),Se()}function fc(e,t){const s=bt().events;if(s.includes(e)===t)return;const o=Xe.filter(r=>r===e?t:s.includes(r));Oe=o;try{localStorage.setItem(Kn,mt(o))}catch{}Se()}const mc=(e,t)=>fetch(e,t);let hc=mc;const Os="http://app.invalid";function pc(e){if(!e.startsWith("/"))return!1;try{return new URL(e,Os).origin===Os}catch{return!1}}function xc(){return or(Vn())}function oe(e,t){if(!pc(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(tc,xc()),hc(e,{...t,headers:s})}const dr=(e,t)=>{const s=setInterval(e,t);return()=>clearInterval(s)},gc=1e4,bc=5,wc=(e,t)=>{let s=null,o=null,r=!1,a=!1,i;const l=()=>{clearTimeout(i),s?.terminate(),s=null,!(r||o)&&(o=dr(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(gc,t*bc))}catch{l()}return()=>{r=!0,clearTimeout(i),s?.terminate(),s=null,o?.(),o=null}},qe=6e4;function Ux(e,t){return e.map(s=>({at:s.at,value:s[t]}))}const Hx=[{id:"15m",label:"15 min",ms:15*qe,words:"the last 15 minutes"},{id:"1h",label:"1 hour",ms:60*qe,words:"the last hour"},{id:"6h",label:"6 hours",ms:360*qe,words:"the last 6 hours"}],yc=[1,2,5,10,20,25,50,100,200,250,500,1e3];function kc(e){const t=Math.max(1,Math.ceil(e)),s=yc.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 jc=[1,2,5,10,15,30,60,120,180,360];function ur(e,t,s){const o=t-e;if(o<=0||s<1)return[];const r=(jc.find(l=>o/(l*qe)<=s)??720)*qe,a=new Date(e).getTimezoneOffset()*qe,i=[];for(let l=Math.ceil((e-a)/r)*r+a;l<=t;l+=r)i.push(l);return i}function Nc(e,t){if(!t)return e;if(fr(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 fr(e,t){const s=ge(t);return s.by==="cleared"&&s.at!==ge(e).at}const vc=/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/,Sc=/^[A-Za-z0-9._-]{1,100}$/,Ac=1e9;function Ec(e,t){return vc.test(e)&&Sc.test(t)&&t!=="."&&t!==".."}function Tc(e){return typeof e=="number"&&Number.isInteger(e)&&e>0&&e<=Ac}const Mc=/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)$/;function Cc(e,t){const s=Mc.exec(e);if(s===null)return!1;const[,o="",r="",a=""]=s;return Ec(o,r)&&a===String(t)}function Ic(e){return e.failing>0?"failing":e.pending>0?"pending":e.passing>0?"passing":"none"}const Yt=200;function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R(e){return typeof e=="string"&&e.trim()!==""?e:null}function W(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function V(e,t){return e.includes(t)?t:null}function Cn(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 Lc(e){if(!P(e))return null;const t=R(e.id),s=R(e.source);if(!t||!s)return null;const o=R(e.project),r=V(Ht,e.status)??"unknown",a={id:t,source:s,surface:V(El,e.surface)??"unknown",name:R(e.name)??o??t,cwd:R(e.cwd),project:o,status:r,startedAt:W(e.startedAt),statusSince:W(e.statusSince),links:{},stale:e.stale===!0};if(r==="needs-you"){const m=V(Ml,e.waitingReason);m&&(a.waitingReason=m);const x=R(e.waitingDetail);x&&(a.waitingDetail=x);const g=R(e.waitingText);g&&(a.waitingText=g)}const i=R(e.agent);i&&(a.agent=i);const l=W(e.lastWriteAt);l!==null&&(a.lastWriteAt=l);const d=W(e.pid);if(d!==null&&(a.pid=d),typeof e.alive=="boolean"&&(a.alive=e.alive),P(e.links)){const m=R(e.links.open);m&&(a.links.open=m)}const c=Hc(e.jump);c&&(a.jump=c);const u=P(e.stop)?V(Cl,e.stop.how):null;u&&(a.stop={how:u});const f=Rc(e.git);return f&&(a.git=f),a}const Oc=Yt,$c=/^[0-9a-f]{7,64}$/,_c=/^[0-9a-f]{16,64}$/;function Rc(e){if(!P(e))return null;const t=Dc(e);if(t===null)return null;const s=zc(e.repository),o=t.branch===void 0?null:Fc(e.pullRequest);return{...t,...s!==null&&{repository:s},...o!==null&&{pullRequest:o}}}const Pc=1e4;function un(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=Pc?e:null}function Wc(e){if(!P(e))return null;const t=un(e.passing),s=un(e.failing),o=un(e.pending),r=V(Ll,e.state);if(t===null||s===null||o===null||r===null)return null;const a={passing:t,failing:s,pending:o};return Ic(a)===r?{state:r,...a}:null}function Fc(e){if(!P(e))return null;const{number:t,url:s}=e;if(!Tc(t))return null;const o=R(e.title),r=V(Il,e.state),a=Wc(e.checks);return o===null||Array.from(o).length>Yt||r===null||a===null||typeof s!="string"||!Cc(s,t)?null:{number:t,title:o,state:r,checks:a,url:s}}function Dc(e){if(e.commit===void 0){const s=R(e.branch);return s!==null&&Array.from(s).length<=Oc?{branch:s}:null}if(e.branch!==void 0)return null;const{commit:t}=e;return typeof t=="string"&&$c.test(t)?{commit:t}:null}function zc(e){if(!P(e))return null;const t=R(e.name);if(t===null||Array.from(t).length>Yt)return null;const{id:s}=e;return typeof s=="string"&&_c.test(s)?{id:s,name:t}:null}const Uc=200;function Hc(e){if(!P(e))return null;const t=R(e.place);if(!t||t.length>Uc)return null;if(e.kind==="tmux")return{kind:"tmux",place:t};const s=e.kind==="terminal"?V(Hn,e.app):null;return s?{kind:"terminal",app:s,place:t}:null}function Bc(e,t){if(!P(e))return null;const s=R(e.id);if(!s)return null;const o={id:s,label:R(e.label)??s,state:V(Ol,e.state)??"error",checkedAt:W(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=Vc(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=Kc(e.capabilities);return l&&(o.capabilities=l),o}function Gc(e){if(!P(e))return null;if(e.level==="yes")return{level:"yes"};const t=V(["no","partly"],e.level),s=R(e.reason);return t&&s?{level:t,reason:s}:null}function Kc(e){if(!P(e))return null;const t={};for(const s of lt){const o=Gc(e[s]);if(!o)return null;t[s]=o}return t}function Vc(e){if(!P(e))return null;const t=R(e.label),s=R(e.value);return t&&s?{label:t,value:s}:null}function qc(e){if(!P(e)||!Array.isArray(e.sessions)||!Array.isArray(e.sources))return null;const t=W(e.generatedAt);return t===null?null:{generatedAt:t,sources:Cn(e.sources,s=>Bc(s,t)),sessions:Cn(e.sessions,Lc)}}function Yc(e){if(!P(e))return null;const t=R(e.id),s=W(e.at),o=V($l,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:V(Pl,e.severity)??"advisory"},i=V(Ht,e.from);i&&(a.from=i);const l=V(Ht,e.to);l&&(a.to=l);const d=V(Rl,e.by);return d&&(a.by=d),a}function Jc(e){return!P(e)||!Array.isArray(e.events)?null:Cn(e.events,Yc)}function Xc(e){if(!P(e))return null;const t=W(e.at),s=W(e.needsYou),o=W(e.working),r=W(e.idle),a=W(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 mr(e){if(!P(e))return null;const t=W(e.at),s=V(Vl,e.by);return t===null||s===null?null:{at:t,by:s}}const Qc=1024;function $s(e){const t=R(e);return t&&t.length<=Qc?t:null}function pe(e){const t=W(e);return t!==null&&t>=0&&Number.isInteger(t)?t:null}function Zc(e){if(!P(e))return null;const t=V(["disk","memory"],e.where),s=pe(e.maxBytes),o=pe(e.maxAgeMs);if(t===null||s===null||o===null)return null;const r=t==="disk"?$s(e.folder):null;return t==="disk"&&r===null?null:{where:t,folder:r,bytes:t==="disk"?pe(e.bytes):null,maxBytes:s,maxAgeMs:o,canClear:t==="disk"&&e.canClear===!0,problem:$s(e.problem)}}const ed=1e3;function td(e){if(!P(e))return null;const t=W(e.at),s=W(e.lastBefore);return t===null||s===null||s>=t?null:{at:t,lastBefore:s}}function nd(e){if(!Array.isArray(e))return[];const t=[];for(const s of e.slice(0,ed)){const o=td(s);o&&t.push(o)}return t.sort((s,o)=>s.at-o.at)}function sd(e){if(!P(e)||!Array.isArray(e.points))return null;const t=W(e.startedAt);if(t===null)return null;const s=[];for(const i of e.points){const l=Xc(i);l&&s.push(l)}const o=mr(e.since),r=Zc(e.kept),a=nd(e.restarts);return{points:s,startedAt:t,...o!==null&&{since:o},...r!==null&&{kept:r},...a.length>0&&{restarts:a}}}const _s=50;function hr(e){const t=pe(e.waitedMs),s=pe(e.openMs),o=pe(e.waits),r=pe(e.measuredMs);return t===null||s===null||o===null||r===null?null:{waitedMs:t,openMs:Math.min(s,t),waits:o,measuredMs:r}}function od(e){if(!P(e))return null;const t=R(e.day),s=W(e.from),o=W(e.to),r=hr(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 rd(e){if(!P(e))return null;const t=R(e.sessionId),s=pe(e.waitedMs),o=pe(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<=Yt?r:t,waitedMs:s,waits:o,open:e.open===!0}}function Rs(e){if(!P(e)||!Array.isArray(e.days)||!Array.isArray(e.sessions))return null;const t=W(e.from),s=W(e.to),o=hr(e),r=pe(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,_s)){const c=od(d);c&&a.push(c)}const i=[],l=new Set;for(const d of e.sessions.slice(0,_s)){const c=rd(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 ad(e){if(!P(e))return null;const t=W(e.at),s=Rs(e.today),o=Rs(e.sevenDays),r=mr(e.since),a=V(["disk","memory"],e.where);return t===null||!s||!o||!r||!a?null:{at:t,today:s,sevenDays:o,since:r,where:a}}const id=300;function Re(e){const t=R(e);return t&&t.length<=id?t:null}function pr(e,t){if(!P(e))return null;const s=W(e.at);return s===null?null:e.sent===!0?{at:s,sent:!0}:{at:s,sent:!1,reason:Re(e.reason)??t}}function xr(e){if(!Array.isArray(e))return null;const t=e.filter(o=>typeof o=="string"),s=Xe.filter(o=>t.includes(o));return s.length>0?s:null}function ld(e){if(!P(e)||typeof e.on!="boolean")return null;const t=Re(e.to),s=xr(e.events),o=W(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:Re(e.problem),last:r?pr(e.last,"the email could not be sent"):null,limitedUntil:r?W(e.limitedUntil):null}}function cd(e){if(!P(e))return null;const t=W(e.at);return t===null?null:e.ok===!0?{at:t,ok:!0}:{at:t,ok:!1,reason:Re(e.reason)??"gh did not answer"}}function dd(e){if(!P(e)||typeof e.on!="boolean")return null;const t=V(rc,e.gh),s=e.on&&t!==null;return{on:s,problem:s?null:Re(e.problem),gh:s?t:null,last:s?cd(e.last):null}}function ud(e){if(!P(e)||typeof e.on!="boolean")return null;const t=Re(e.host),s=xr(e.events),o=W(e.afterMs),r=e.on&&t!==null&&oc(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:Re(e.problem),last:r?pr(e.last,"the post could not be sent"):null,limitedUntil:r?W(e.limitedUntil):null}}const gr=2e3,fd=4e3,Ps=5e3,Ws=ac,Fs=3600*1e3,md=60*1e3,Jt=ec,hd=2,pd={phase:"connecting",snapshot:null,events:[],history:null,lastOkAt:null,problem:null,problemKind:null};class $e extends Error{kind;constructor(t,s){super(s),this.kind=t}}async function Ft(e){let t;try{t=await oe(e,{headers:{accept:"application/json"},signal:AbortSignal.timeout(fd)})}catch(s){const o=s instanceof DOMException&&s.name==="TimeoutError";throw new $e("no-answer",o?"The local server took too long to answer.":"The local server did not answer.")}if(!t.ok)throw new $e("error-status",`The local server answered ${e} with error ${t.status}.`);try{return await t.json()}catch{throw new $e("not-data",`The local server answered ${e} with something that is not data.`)}}function xd(e){const t=qc(e);if(!t)throw new $e("not-data","The local server sent session data in a shape this page cannot read.");return t}function gd(e){const t=Jc(e);if(!t)throw new $e("not-data","The local server sent events in a shape this page cannot read.");return t}function br(e){const t=sd(e);if(!t)throw new $e("not-data","The local server sent history in a shape this page cannot read.");return t}function Bx(e){return Ft(`/api/history?windowMs=${Math.round(e)}`).then(br)}function bd(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,Jt)}function wd(e={}){const t=e.now??Date.now,s=e.intervalMs??gr,o=e.beat??dr,r=new Set;let a=pd,i=null,l=!1,d=0,c=null;function u(g){a=g;for(const b of r)b()}async function f(){if(!l){l=!0;try{const g=a.events[0]?.at??0,b=t(),h=c===null||b-c>Ws-Ps,[v,y,j]=await Promise.allSettled([Ft("/api/sessions").then(xd),Ft(`/api/events?since=${g}`).then(gd),Ft(`/api/history?windowMs=${h?Fs:Ws}`).then(br)]);let N=a;if(j.status==="fulfilled"){const S=a.history!==null&&(a.history.startedAt!==j.value.startedAt||fr(a.history,j.value));let C;h?(C=j.value,c=b):S||a.history===null?(C=j.value,c=null):(C=Nc(a.history,j.value),c=b);const T=t()-Fs-md;N={...N,history:{...C,points:C.points.filter(w=>w.at>=T)},events:S?[]:N.events}}if(y.status==="fulfilled"&&(N={...N,events:bd(N.events,y.value)}),v.status==="fulfilled")d=0,N={...N,phase:"live",snapshot:v.value,lastOkAt:t(),problem:null,problemKind:null};else{d+=1;const S=v.reason,C=S instanceof $e?S:null,T=C?.message??"The local server did not answer.",w=C?.kind??"no-answer";let _;N.snapshot!==null&&N.lastOkAt!==null?_=t()-N.lastOkAt>Ps?"stalled":N.phase:_=d>=hd?"unreachable":"connecting",N={...N,phase:_,problem:T,problemKind:w}}u(N)}finally{l=!1}}}function m(){i===null&&(f(),i=o(()=>{f()},s))}function x(){i!==null&&(i(),i=null)}return{subscribe(g){return r.add(g),m(),()=>{r.delete(g),r.size===0&&x()}},getState:()=>a,refresh:()=>{f()}}}const In=1e3,rt=60*In,at=60*rt,fn=24*at;function dt(e){return String(e).padStart(2,"0")}function wt(e){const t=Math.max(0,Math.floor(e));return t<rt?[{value:String(Math.floor(t/In)),unit:"s"}]:t<at?[{value:String(Math.floor(t/rt)),unit:"m"},{value:dt(Math.floor(t%rt/In)),unit:"s"}]:t<fn?[{value:String(Math.floor(t/at)),unit:"h"},{value:dt(Math.floor(t%at/rt)),unit:"m"}]:[{value:String(Math.floor(t/fn)),unit:"d"},{value:dt(Math.floor(t%fn/at)),unit:"h"}]}function wr(e){return e.map(t=>`${t.value}${t.unit}`).join(" ")}function G(e){return wr(wt(e))}const yd={s:"second",m:"minute",h:"hour",d:"day"};function yr(e){return e.filter((s,o)=>o===0||Number(s.value)!==0).map(s=>{const o=Number(s.value);return`${o} ${yd[s.unit]}${o===1?"":"s"}`}).join(" ")}function je(e){return yr(wt(e))}function J(e){const t=new Date(e);return`${dt(t.getHours())}:${dt(t.getMinutes())}`}function ne(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}const kd=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}),jd=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"});function qn(e,t){return(new Date(e).getFullYear()===new Date(t).getFullYear()?kd:jd).format(new Date(e))}function ce(e,t){const s=J(e);return ne(e)===ne(t)?s:`${s} on ${qn(e,t)}`}const Nd=1e3;function Ne(e){return e.charAt(0).toUpperCase()+e.slice(1)}function mn(e){return String(e).padStart(2,"0")}function kr(e){const t=wt(e),s=t[0];return s&&(s.unit==="m"||s.unit==="d")?[s]:t}function ht(e){return wr(kr(e))}function Ye(e){return yr(kr(e))}function Yn(e){return e<Nd?"just now":`${G(e)} ago`}function de(e){const t=new Date(e);return`${mn(t.getHours())}:${mn(t.getMinutes())}:${mn(t.getSeconds())}`}const vd=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"});function Sd(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 Jn(e){return`${vd.format(new Date(e))} ${de(e)}`}function jr(e,t){return Sd(e,t)?de(e):Jn(e)}const Nr="status-files";function Ad(e){return e.id===Nr?"status files":e.label}function He(e){const t=e.map(Ad);return t.length===0?"your agent tools":t.length===1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function vr(e){return e.state!=="unavailable"&&e.state!=="not-set-up"}function Ed(e){const t=e.filter(o=>o.state!=="not-set-up"),s=t.filter(vr);return s.length>0?s:t}function Sr(e,t=[]){const s=new Set;for(const o of e)vr(o)&&o.id!==Nr&&s.add(o.label);for(const o of t)o.agent!==void 0&&s.add(o.agent);return s.size>1}function Xn(e,t){return Fl(e,t)??e.source}const Td=/^vscode:\/\/anthropic\.claude-code\/open\?session=[A-Za-z0-9\-_.!~*'()%]{1,200}$/,Qn={"needs-you":"Needs you",working:"Working",idle:"Idle",finished:"Finished",failed:"Failed",unknown:"Unknown"};function Md(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 pt="stopped waiting after",Cd="was stopped from Agent Lookout";function Ar(e,t=null){if(e.kind==="appeared")return"appeared";if(e.kind==="ended")return"ended";if(e.kind==="stopped")return Cd;if(e.from==="needs-you"&&e.to!=="needs-you"&&t!==null)return`${pt} ${G(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 Ds={"claude-code":Td};function Id(e){const t=e.links.open;return typeof t!="string"?null:(Object.hasOwn(Ds,e.source)?Ds[e.source]:void 0)?.test(t)?t:null}function Ee(e){const t=Id(e);return t!==null?{by:"link",href:t,where:gt(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 Ld={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"};function Er(e){return Object.hasOwn(er,e)?e:"error"}function Od(e,t){const s=Er(e.state);return{key:e.id,name:e.label,state:t?Ld[s]:er[s]}}const $d=[["vscode","VS Code"],["desktop","the desktop app"],["terminal","a terminal"],["cloud","the cloud"],["browser","a browser"],["unknown","another app"]];function _d(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Rd(e){const t=new Set(e.map(s=>s.surface));return t.size===1&&t.has("unknown")?"":_d($d.filter(([s])=>t.has(s)).map(([,s])=>s))}function tt(e,t){return e.filter(s=>Er(s.state)===t)}function Pd(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 ${de(o)}`,ticking:!1}};const r=(t?.sources??[]).filter(m=>m.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(m=>m.checkedAt)),l={text:`checked ${Yn(s-i)}`,ticking:!0};if(a.length>0){const m=`${a.length} ${a.length===1?"session":"sessions"}`,x=tt(r,"ok"),g=Rd(a),b=x.length>1?` from ${He(x)}`:g?` in ${g}`:"";return{key:"watching",text:`Watching ${m}${b}`,short:m,fact:l}}const d=tt(r,"searching");if(d.length>0)return{key:"searching",text:`Looking for ${He(d)} sessions`,short:"Looking for sessions",fact:l};const c=tt(r,"ok");if(c.length>0)return{key:"none-running",text:`Watching ${He(c)}, no sessions running`,short:"No sessions",fact:l};const u=tt(r,"error");if(u.length>0)return{key:"not-working",text:`${Ne(He(u))} could not be read`,short:u.length===1?"Source not working":"Sources not working",fact:l};const f=tt(r,"unavailable");return{key:"not-found",text:`${Ne(He(f))} ${f.length===1?"was":"were"} not found`,short:f.length===1?"Source not found":"Sources not found",fact:l}}function Tr(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 Wd=gr/1e3;function Fd({lastOkAt:e,now:t,onRetry:s}){return n.jsx(q,{tone:"error",title:"Agent Lookout has stopped updating",action:n.jsx(z,{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:[de(e),n.jsxs("span",{"data-part":"age","aria-hidden":!0,"aria-live":"off",children:[" ","(",Yn(t-e),")"]})]}),". Check that it is still running in your terminal. The page keeps trying and catches up on its own."]})})}const zs="font-mono text-fact";function Mr({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:zs,children:"npm start"})," or ",n.jsx("code",{className:zs,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 Dd({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(q,{tone:"error",title:Tr(t),action:n.jsx(z,{size:"sm",onClick:s,children:"Try now"}),children:n.jsx(Mr,{kind:t})}),n.jsxs(Me,{className:"mt-3",children:[n.jsx(X,{label:"What happened",children:n.jsx(le,{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 ",Wd,"s"]})})]})]})}function yt({title:e,children:t,visual:s,compact:o=!1,className:r}){return n.jsxs("div",{"data-slot":"empty-state",className:k("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:k("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 zd={...Qn,stale:"Stale",answered:"Needed you, answered",ended:"Ended",lookout:"Agent Lookout"},Ud={"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 Q({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:k("size-mark shrink-0",a&&o?"text-ink":Ud[e],r),...t?{role:"img","aria-label":zd[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:k(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:k(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 Hd=250,Bd=250;let Ln=!1;typeof window<"u"&&window.addEventListener("scroll",()=>{Ln=!0,setTimeout(()=>{Ln=!1})},{capture:!0,passive:!0});function se({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(Ja,{delayDuration:Hd,children:n.jsxs(Xa,{open:i&&c,onOpenChange:u=>{const f=Ln&&performance.now()-d.current<Bd;!u&&f||l(u)},children:[n.jsx(Qa,{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(Za,{children:n.jsx(ei,{"data-slot":"tooltip",side:r,align:a,sideOffset:6,collisionPadding:12,className:k("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:e})})]})})}function Gd(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 te({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 x=d.current;if(!x)return;const g=new ResizeObserver(()=>u(Gd(x,t)));return g.observe(x),()=>g.disconnect()},[f,t]);const m=k(t===1?"truncate":"line-clamp-2","rounded-bar",i);return n.jsx(se,{content:f,enabled:c,mono:o,children:r!==void 0?n.jsx("a",{ref:d,href:r,target:a,"data-cut":c,className:m,...l,children:e}):n.jsx("span",{ref:d,"data-cut":c,tabIndex:c?0:void 0,className:m,...l,children:e})})}const Kd=8e3,Us=.75,kt=Kd;function De(e){return Math.round(e*100)/100}function Gx(e,t,s){const{start:o,end:r}=t,a=t.gapMs??kt,i=r-o,l=s.right-s.left,d=e.filter(S=>S.at>=o&&S.at<=r&&Number.isFinite(S.value)).sort((S,C)=>S.at-C.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 S of d)S.value<c&&(c=S.value),S.value>u&&(u=S.value);const f=Math.max(1,s.ceiling??u),m=S=>De(s.left+(S-o)/i*l),x=S=>De(s.bottom-Math.min(S,f)/f*(s.bottom-s.top)),g=[];for(const S of d){const C=g[g.length-1],T=C?.[C.length-1];C&&T&&S.at-T.at<=a?C.push(S):g.push([S])}const b=[],h=[],v=[],y=[];g.forEach((S,C)=>{const T=S[0],w=S[S.length-1];if(!T||!w)return;const _=C===0&&T.at-o<=a?o:T.at,F=C===g.length-1&&r-w.at<=a?r:w.at,I=m(_),L=m(F);let O=`M${I} ${x(T.value)}`,H=T.value;for(const Y of S)Y.value!==H&&(O+=`H${m(Y.at)}V${x(Y.value)}`,H=Y.value);O+=`H${L}`,b.push(O),h.push(`${O}V${s.bottom}H${I}Z`),v.push({x:I,width:L-I}),y.push({from:_,to:F,samples:S})});const j=[];let N=s.left;for(const S of v)S.x-N>=Us&&j.push({x:De(N),width:De(S.x-N)}),N=Math.max(N,S.x+S.width);return s.right-N>=Us&&j.push({x:De(N),width:De(s.right-N)}),{lines:b,areas:h,unmeasured:j,range:{min:c,max:u},runs:y}}function Kx(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 Vd(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)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};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 qd(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=ge(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 Yd(e,t=kt){if(!e)return[];const s=ge(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 Jd(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 Xd=1e4;function Qd(e){return{away:!0,overview:!1,leftAt:e,since:null,inViewFrom:null}}function Zd(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>=Xd&&(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 eu(e,t){if(t===null)return 0;let s=0;for(;s<e.length&&e[s].at>t;)s+=1;return s}const Xt="w-16 shrink-0 self-center font-mono text-caption whitespace-nowrap";function Hs({kind:e,side:t}){return n.jsx("span",{"aria-hidden":!0,"data-part":"thread","data-kind":e,className:k("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 Zn({thread:e,children:t}){return n.jsxs("span",{className:"relative flex w-mark shrink-0 items-center justify-center",children:[e.above&&n.jsx(Hs,{kind:e.above,side:"above"}),t,e.below&&n.jsx(Hs,{kind:e.below,side:"below"})]})}function Gt({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:k("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(se,{content:Jn(e),mono:!0,align:"start",children:n.jsx("time",{dateTime:new Date(e).toISOString(),className:k(Xt,"rounded-bar",o?"text-ink-secondary":"text-ink-muted"),children:de(e)})}),n.jsx(Zn,{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 tu=p.memo(function({event:t,mark:s,open:o,waitedMs:r,above:a,below:i}){const l=Ar(t,r);return n.jsxs(Gt,{"data-slot":"event-row",at:t.at,lit:o,thread:{above:a,below:i},mark:n.jsx(Q,{kind:s,labelled:!0}),children:[n.jsx(te,{"data-part":"name",tooltip:`${t.sessionName} ${l}`,className:"font-semibold text-ink",children:t.sessionName}),n.jsx("span",{"data-part":"phrase",className:"max-w-full shrink-0",children:r!==null&&l.startsWith(pt)?n.jsxs(n.Fragment,{children:[pt," ",n.jsx("span",{className:"whitespace-nowrap tabular-nums",children:G(r)})]}):l})]})});function Bs(e){return e.charAt(0).toUpperCase()+e.slice(1)}const nu=6;function Vx({entries:e,now:t,className:s}){const o=[];let r=ne(t);for(const i of e){const l=ne(i.event.at);l!==r&&(r=l,o.push({kind:"day",day:r})),o.push({kind:"event",entry:i})}const a=e.length>nu;return n.jsx("ol",{"data-slot":"own-events","aria-label":"Its events, newest first",tabIndex:a?0:void 0,className:k("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(Cr,{day:i.day,now:t,thread:d,className:"px-0"},`day-${i.day}`);const{entry:c}=i,u=Ar(c.event,c.waitedMs);return n.jsx(Gt,{"data-slot":"event-row",at:c.event.at,lit:c.open,thread:d,mark:n.jsx(Q,{kind:c.mark,labelled:!0}),className:"px-0",children:n.jsx("span",{"data-part":"phrase",children:c.waitedMs!==null&&u.startsWith(pt)?n.jsxs(n.Fragment,{children:[Bs(pt)," ",n.jsx("span",{className:"whitespace-nowrap tabular-nums",children:G(c.waitedMs)})]}):Bs(u)})},c.event.id)})})}function Cr({day:e,now:t,thread:s,className:o}){return n.jsxs("li",{"data-slot":"event-day",className:k("flex shrink-0 items-stretch gap-3.5 px-6",o),children:[n.jsx("span",{className:k(Xt,"pt-3 pb-1 font-medium text-ink-muted"),children:qn(e,t)}),n.jsx(Zn,{thread:s})]})}function su({since:e,now:t,thread:s,ref:o}){const r=de(e),a=ne(e)===ne(t)?r:`${qn(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:Xt}),n.jsx(Zn,{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 ou(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 m=u-Number.parseFloat(c.paddingBottom||"0"),x=i.getBoundingClientRect().top-i.scrollTop;for(const g of i.children){const b=g.getBoundingClientRect().bottom-x;if(b>m+.01)break;f=b}}r(f)};l();const d=new ResizeObserver(l);return d.observe(a),()=>d.disconnect()},[e,t,s]),o}function ru(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 au({events:e,sessions:t=[],history:s=null,now:o,newSince:r=null,onNewLineInView:a,className:i}){const l=ne(o),d=qd(e,s,e.length>=Jt),c=Yd(s).filter(w=>!d||w.at>=d.at),u=eu(e,r),f=[];let m=u>0?r:null,x=l;const g=w=>{m!==null&&w<=m&&(f.push({kind:"new",key:"new",since:m}),m=null);const _=ne(w);_!==x&&(x=_,f.push({kind:"day",key:`day-${x}`,day:x}))};for(const w of Jd(Vd(e,t),c))w.kind==="event"?(g(w.entry.event.at),f.push({kind:"event",key:w.entry.event.id,...w.entry})):(g(w.gap.at),f.push({kind:"resumed",key:`resumed-${w.gap.at}`,at:w.gap.at,unmeasuredMs:w.gap.unmeasuredMs}));d?.started&&(g(d.at),f.push({kind:"started",key:"started",at:d.at,cleared:d.cleared===!0})),m!==null&&f.push({kind:"new",key:"new",since:m});const b=u>0,h=e.length>0||c.length>0,v=p.useRef(null),y=p.useRef(null),j=ou(v,y,h?f.map(w=>w.key).join(" "):""),N=ru(b,a);let S=!1;const C=f.map((w,_)=>{const F=_===0?null:S?"dots":"line";S=w.kind==="resumed"||(w.kind==="day"||w.kind==="new")&&S;const I=_===f.length-1?null:S?"dots":"line",L={above:F,below:I};switch(w.kind){case"day":return n.jsx(Cr,{day:w.day,now:o,thread:L},w.key);case"event":return n.jsx(tu,{event:w.event,mark:w.mark,open:w.open,waitedMs:w.waitedMs,above:F,below:I},w.key);case"resumed":return n.jsx(Gt,{"data-slot":"event-resumed",at:w.at,thread:L,mark:n.jsx(Q,{kind:"lookout",labelled:!0}),children:n.jsxs("span",{children:["Watching resumed,"," ",n.jsx("span",{className:"tabular-nums",children:G(w.unmeasuredMs)})," not measured"]})},w.key);case"started":return n.jsx(Gt,{"data-slot":"event-start",at:w.at,thread:L,mark:n.jsx(Q,{kind:"lookout",labelled:!0}),children:n.jsx("span",{children:w.cleared?"History cleared":"Started watching"})},w.key);case"new":return n.jsx(su,{ref:N,since:w.since,now:o,thread:L},w.key)}});let T;return h?T=n.jsx("div",{ref:v,className:"relative min-h-65 flex-1 max-wide:min-h-0",children:n.jsx("ol",{ref:y,"data-slot":"event-list","data-whole-rows":j!==null||void 0,"aria-label":"Event log, newest first",tabIndex:0,className:k("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:j!==null?{bottom:"auto",height:j}:void 0,children:C})}):d?.started?T=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:C}),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:k(Xt,"invisible"),children:de(d.at)}),n.jsx("span",{"aria-hidden":!0,className:"w-mark shrink-0"}),n.jsx("span",{children:"Nothing has changed since."})]})]}):T=n.jsx(yt,{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:b?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:ce(d.at,o)})]}):void 0,className:k("flex flex-col",i),children:T})}const iu={permission:"Waiting for permission",question:"Asked you a question",other:"Waiting for you"};function Ir(e){return iu[e.waitingReason??"other"]}function Lr(e){return e.name.trim()!==""?e.name:e.project||e.id}function lu(e){const t=Ir(e),s=e.waitingText?.trim();return{title:Lr(e),body:s?`${t}: ${s}`:t}}const On={"needs-you":"Needs you",finished:"Finished",failed:"Failed",ended:"Ended"};function cu(e){return e.event==="needs-you"?lu(e.session):{title:Lr(e.session),body:On[e.event]}}const du=1440*60*1e3,uu="a day",jt="–",he={working:"busy with a task",idle:"ready for a prompt",stale:`idle ${uu} or more`,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 Gs(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:G(s-e.since)})]}):t>0?he.timeNotReported:o}function fu(e){if(e.total===0)return he.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 _t({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===jt?{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 mu({counts:e,asOf:t,onOpenHistory:s}){const{summary:o,counted:r,searching:a}=e,i=d=>o===null?null:r?d??0:jt,l=d=>s&&r?()=>s(d):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(_t,{kind:"working",label:"Working",mark:n.jsx(Q,{kind:"working"}),value:i(o?.working),note:o&&r?Gs(o.longestWorking,o.working,t,he.noneWorking):he.working,onOpen:l("working")}),n.jsx(_t,{kind:"idle",label:"Idle",mark:n.jsx(Q,{kind:"idle"}),value:i(o?.idle),note:o&&r?Gs(o.longestIdle,o.idle,t,he.noneIdle):he.idle,onOpen:l("idle")}),n.jsx(_t,{kind:"stale",label:"Stale",mark:n.jsx(Q,{kind:"stale"}),value:i(o?.stale),note:he.stale}),n.jsx(_t,{kind:"sessions",label:"Sessions",value:i(o?.total),note:o?r?fu(o):a?he.notCountedYet:he.noSource:he.sessions})]})}function hu(e){const t=new Set((e.restarts??[]).map(s=>s.at));return t.add(e.startedAt),[...t].sort((s,o)=>s-o)}function es(e,t,s){const o=[];if(!e)return o;const r=e.points.map(d=>d.at).sort((d,c)=>d-c),a=hu(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 ts(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 ns(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 Ks(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 ss(e){return e.reduce((t,s)=>t+(s.to-s.from),0)}function Or(e,t,s="in the last hour"){if(t.length===0)return s;const o=t[0];return ss(t)>=e.to-e.from?null:t.length===1&&o.from<=e.from?`since ${J(o.to)}`:"in the time measured"}const $r=Ht,pu=new Map($r.map((e,t)=>[e,t]));function Vs(e){return pu.get(e)??$r.length}function qs(e,t){const s=e.toLowerCase(),o=t.toLowerCase();return s<o?-1:s>o?1:0}function xu(e,t){const s=Vs(e.status)-Vs(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 qs(e.name,t.name)||qs(e.id,t.id)}function Qt(e){return e.stale&&e.status==="idle"}function os(e){const t=e.status==="finished"||e.status==="failed",s=e.alive===!1,o=Qt(e);return{mark:o?"stale":e.status,word:o?"Stale":Qn[e.status],ended:t,stale:o,quiet:o||t||s,orphaned:s&&!t}}const gu={"needs-you":"Needs you",working:"Working",idle:"Idle",unknown:"Status unknown"},bu=["needs-you","working","idle","ended","unknown"];function wu(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 yu(e,t){if(e!=="ended")return gu[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 ku(e,t){return+(t.status==="failed")-+(e.status==="failed")||xu(e,t)}function Nt(e){const t=new Map;for(const o of e){const r=wu(o),a=t.get(r);a?a.push(o):t.set(r,[o])}const s=[];for(const o of bu){const r=t.get(o);if(!r)continue;const a=r.filter(Qt).length;s.push({id:o,label:yu(o,r),sessions:[...r].sort(ku),count:r.length-a,stale:a})}return s}function $n(e){return Nt(e).filter(t=>t.id!=="needs-you")}function ju(e){return Nt(e).find(t=>t.id==="needs-you")?.sessions??[]}function Nu(e){return e?.filter(t=>t.status==="needs-you").length??0}function hn(e,t){const s=t.statusSince;return s===null?e:e===null||s<e.since?{session:t,since:s}:e}function vu(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(Qt(s)){t.stale+=1;continue}switch(s.status){case"needs-you":t.needsYou+=1,t.longestWait=hn(t.longestWait,s);break;case"working":t.working+=1,t.longestWorking=hn(t.longestWorking,s);break;case"idle":t.idle+=1,t.longestIdle=hn(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 rs(e,t=[]){const s=e?vu(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 _r(e){return!e.summary||!e.counted?null:e.summary.needsYou>0?"lamp":"rest"}const Rr=3600*1e3;function Su(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((m,x)=>{const g=t[x-1];m.kind==="appeared"&&g?.kind==="ended"&&m.at>g.at&&i.push({from:g.at,to:m.at,status:"unseen",startObserved:!0,reaches:!1});const b=t[x+1]?.at??s.to;m.kind==="ended"||b<=m.at||i.push({from:m.at,to:b,status:m.to??"unknown",startObserved:!0,reaches:!1})})}else if(e){const f=l??-1/0,m=Math.max(f,Math.min(a,e.statusSince??1/0));m>f&&i.push({from:f,to:m,status:"unknown",startObserved:l!==null,reaches:!1,notKnown:!0}),i.push({from:m,to:s.to,status:e.status,startObserved:m!==-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 Au(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 m=Math.max(f.from,u),x=Math.min(f.to,c);if(i(u,m,l),l.status!=="unseen"&&x>m){const g=l.startObserved&&m===l.from&&a(m);r.push({from:m,to:x,kind:l.status,startKnown:g})}u=x}i(u,c,l)}return r}function Eu(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 Tu(e,t){return e.at-t.at}function Pr(e){const{sessions:t,events:s,history:o,now:r}=e,a=e.gapMs??kt,i={from:r-(e.windowMs??Rr),to:r},l=Math.min(e.asOf??r,r),d=new Map;let c=1/0;for(const y of s){if(y.at<c&&(c=y.at),!nr(y))continue;const j=d.get(y.sessionId);j?j.push(y):d.set(y.sessionId,[y])}for(const y of d.values())y.sort(Tu);const u=es(o,l,a),f=Math.max(o?ge(o).at:-1/0,e.eventsFull&&c!==1/0?c:-1/0),m=ts(u,i,l,f,a),x=(y,j,N)=>{const S=Su(N,d.get(y)??[],i,l,a,o?.startedAt??-1/0);let C=Au(S,m,u,i);N?.stale&&N.status==="idle"&&N.statusSince!==null&&(C=Eu(C,N.statusSince+du));const T=C[C.length-1];if(N&&T&&T.to===i.to&&(T.ongoing=!0),N?.status==="needs-you")for(const w of C)w.kind==="needs-you"&&w.to===l&&(w.open=!0);return{id:y,name:j,ended:N===void 0,status:N?.status??null,stale:N?.stale??!1,segments:C}},g=Nt(t).flatMap(y=>y.sessions),b=g.map(y=>x(y.id,y.name,y)),h=new Set(g.map(y=>y.id)),v=[];for(const[y,j]of d){const N=j[j.length-1];!N||h.has(y)||N.kind!=="ended"||N.at<=i.from||v.push({at:N.at,row:x(y,N.sessionName,void 0)})}return v.sort((y,j)=>j.at-y.at||y.row.name.localeCompare(j.row.name)),{start:i.from,end:i.to,rows:[...b,...v.map(y=>y.row)],unmeasured:ns(m,i)}}function Mu(e,t){const{now:s,events:o}=e,r=e.heldMs??Rr;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=[[ge(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,m]of l)f>d&&([d,c]=[f,m]);d=Math.min(d,s);const u=ne(s);return d<=u?{from:u,to:s,bound:"midnight",today:!0}:{from:d,to:s,bound:c,today:!1}}function Cu(e,t,s){const o=new Map;for(const a of e){if(!nr(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 Iu(e){const{history:t,now:s}=e;if(!t)return null;const o=e.gapMs??kt,r=Math.min(e.asOf??s,s),a=Mu(e,t),i=Pr({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 m=0,x=0,g=!1,b=!0,h=!1,v=-1/0;for(const y of f.segments)if(y.from>v&&(h=!1),v=y.to,y.kind!=="unmeasured"){if(y.kind!=="needs-you"){h=!1;continue}h||(x+=1),h=!0,m+=y.to-y.from,y.open&&(g=!0),y.startKnown===!1&&(b=!1)}m>0&&l.push({id:f.id,name:f.name,ms:m,times:x,open:g,startKnown:b})}l.sort((f,m)=>m.ms-f.ms||f.name.localeCompare(m.name));const d={from:a.from,to:Math.max(a.from,r)},c=ts(es(t,r,o),d,r,ge(t).at,o),u=ns(c,d);return{period:a,sessions:l,totalMs:l.reduce((f,m)=>f+m.ms,0),gaps:u,unmeasuredMs:ss(u),lastWait:Cu(e.events,a,r)}}function Lu(e){return e.period.today?"Waited on you today":`Waited on you since ${J(e.period.from)}`}function Ys(e){const t=`Measured since ${J(e.period.from)}`,s=Wr(e);return s?`${t}, with ${s}.`:`${t}.`}function Wr(e){const t=e.gaps[0];if(!t||e.unmeasuredMs<=0)return null;const s=G(e.unmeasuredMs);return e.gaps.length===1?`${s} not measured after ${J(t.from)}`:`${s} not measured in ${e.gaps.length} breaks, the first after ${J(t.from)}`}const Ou=7*6e4;function $u({waits:e}){const t=e?Lu(e):"Waited on you",s=e?.sessions[0]?.ms??0,o=Math.max(Ou,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:G(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 "}${je(r.ms)}`;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.jsx(te,{"data-part":"who",className:k("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("span",{"data-part":"track",role:"img","aria-label":r.open?`${r.name} has waited ${a}, still waiting`:`${r.name} 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:k("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:k("w-16 shrink-0 text-right whitespace-nowrap tabular-nums",r.open?"font-semibold text-label-needs-you":"text-ink-secondary"),children:G(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. ${Ys(e)}`:Ys(e)})]})}const _u=To("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 vt({className:e,tone:t,...s}){return n.jsx("span",{"data-slot":"badge","data-tone":t??"neutral",className:k(_u({tone:t}),e),...s})}const Ru="agent-lookout",Pu=`${Ru}:`;function Fr(){return typeof location>"u"?"":location.protocol}function as(e=Fr()){return e===Pu}function Wu(e=document.documentElement,t=Fr()){as(t)&&(e.dataset.host="app")}const Dr=4e3,Fu=Yl+5e3,Du=["no-pane","pane-gone","tmux-stopped","tab-gone","not-allowed","too-soon","failed"],zu={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 Uu(e,t=null){return t!==null&&e==="selected"?`Switched to ${t}`:t!==null&&e==="no-pane"?"No tab found":zu[e]}function Hu(e,t=as()){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 Bu="To let Jump switch tabs, allow it in System Settings, Privacy & Security, Automation.";async function Gu(e,t=Dr){try{const s=await oe("/api/jump",{method:"POST",headers:{"Content-Type":"application/json",[Qe]:"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":Du.find(a=>a===r.reason)??"failed"}catch{return"failed"}}function Zt({session:e,jump:t,variant:s,size:o="sm",className:r}){const a=Ee(e);if(!a)return null;const i=`Jump to ${e.name} in ${a.where}`,l=k(o==="sm"&&"w-16",r);return a.by==="link"?n.jsx(z,{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(se,{content:a.where,align:"end",children:n.jsx(z,{variant:s,size:o,className:l,"data-part":"jump","data-way":a.by,"aria-label":i,onClick:t.press,children:"Jump"})})}function xt({session:e,jump:t,className:s}){const{outcome:o,asking:r}=t,a=Ee(e);if(o===null&&r===null&&(a===null||a.by==="link"))return null;const i=o===null?null:Uu(o,a?.by==="terminal"?a.app:null),l=o==="not-allowed"?Bu:o===null&&r!==null?Hu(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(vt,{"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 is({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(te,{"data-part":"branch",className:s,children:o}):n.jsx("span",{"data-part":"commit",className:k("font-mono text-fact",s),children:e.commit})]})}function zr({parts:e,className:t}){return n.jsx("span",{"data-slot":"duration-figure",className:k("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 xe({label:e,className:t}){return n.jsxs("div",{"data-slot":"loading",role:"status",className:k("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 Ur="agent-lookout-automation-note",Hr=new Set;function Br(){try{const e=localStorage.getItem(Ur)??"";return Hn.filter(t=>e.split(",").includes(t))}catch{return[]}}function Ku(e){return!Hr.has(e)&&!Br().includes(e)}function Vu(e){const t=new Set([...Br(),e]);try{localStorage.setItem(Ur,Hn.filter(s=>t.has(s)).join(","))}catch{Hr.add(e)}}const qu=4e3,Yu=12e3,Ju=1e3;function en(e){const t=e.id,s=Ee(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),m=p.useRef(void 0);return p.useEffect(()=>(u.current=!0,()=>{u.current=!1,clearTimeout(f.current),clearTimeout(m.current)}),[]),{press:p.useCallback(()=>{d.current||performance.now()-c.current<Jl||(d.current=!0,clearTimeout(f.current),a(null),o!==null&&Ku(o)&&(m.current=setTimeout(()=>{Vu(o),l(o)},Ju)),Gu(t,o!==null?Fu:Dr).then(g=>{d.current=!1,c.current=performance.now(),clearTimeout(m.current),u.current&&(l(null),a(g),f.current=setTimeout(()=>a(null),g==="not-allowed"?Yu:qu))}))},[t,o]),outcome:r,asking:i}}const _n="#overview/session/";function Xu(e){return`${_n}${encodeURIComponent(e).replace(/%3A/gi,":")}`}function Qu(e){if(!e.startsWith(_n))return null;const t=e.slice(_n.length);if(t==="")return null;try{return decodeURIComponent(t)}catch{return t}}const Gr="agent-lookout-details";function St(e){return Xu(e)}function Kr(e){return Qu(e)}function Kt(e){const t=St(e);window.location.hash!==t&&(window.location.hash=t,window.history.replaceState({[Gr]:!0},""))}let pn=!1;function Zu(){if(Kr(window.location.hash)===null)return;const e=window.history.state;if(typeof e=="object"&&e!==null&&Gr in e){if(pn)return;pn=!0,window.addEventListener("hashchange",()=>{pn=!1},{once:!0}),window.history.back()}else window.location.replace("#overview")}function Vr(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&&Kt(t)}function tn(e,t){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),Kt(t))}function qr({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 ef({id:e,count:t,onOpen:s}){return n.jsxs("h2",{id:e,"data-part":"title",className:"flex items-center gap-2.5 text-row leading-tight font-semibold text-ink",children:[n.jsx(Q,{kind:"needs-you",breathing:!0,className:"size-4.5"}),s?n.jsx(qr,{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 Yr({session:e,className:t}){const s=Ir(e),o=Md(e);return o?n.jsx(se,{content:`${s}: ${o}`,children:n.jsxs("span",{"data-part":"reason-text",tabIndex:0,className:k("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:k("text-label-needs-you",t),children:s})}function Jr({session:e,className:t}){const s=e.waitingText?.trim();return s?n.jsx(te,{"data-part":"asking",lines:2,className:k("min-w-0 text-body wrap-anywhere text-ink-secondary",t),children:s}):null}function Xr({session:e,agent:t,className:s}){const o=gt(e.surface),r=!!e.project||o!==null;return!r&&t===void 0?null:n.jsxs("span",{"data-part":"place",className:k("relative min-w-0 text-body text-ink-secondary",s),children:[e.project?n.jsxs(n.Fragment,{children:[n.jsx(se,{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(is,{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 Qr({session:e}){return e.alive===!1?n.jsx(vt,{tone:"outline",children:"Process ended"}):null}function Zr(e,t){return e.statusSince===null?null:Math.max(0,t-e.statusSince)}function ea({session:e,className:t}){return n.jsx(te,{"data-part":"name",href:St(e.id),onClick:s=>tn(s,e.id),"aria-label":`${e.name}, details`,"aria-haspopup":"dialog",className:k("-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 tf({session:e,asOf:t,agent:s}){const o=Zr(e,t),r=en(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(ea,{session:e,className:"text-name font-semibold"}),n.jsx(Qr,{session:e})]}),n.jsx(xt,{session:e,jump:r})]}),n.jsx("p",{"data-part":"reason",className:"mt-2 flex min-w-0 text-lead font-medium",children:n.jsx(Yr,{session:e,className:"truncate"})}),n.jsx(Jr,{session:e,className:"mt-1"}),n.jsx(Xr,{session:e,agent:s,className:"mt-1.5 block wrap-anywhere"})]}),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:o!==null?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"sr-only",children:["Waiting ",je(o)]}),n.jsx("span",{"aria-hidden":!0,children:n.jsx(zr,{parts:wt(o)})})]}):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:jt})]})}),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:J(e.statusSince)})]}):"time not reported"})]}),n.jsx(Zt,{session:e,jump:r,variant:"needs-you",size:"hero"})]})]})}function nf({session:e,asOf:t,agent:s}){const o=Zr(e,t),r=en(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(ea,{session:e,className:"text-lead font-semibold text-ink"}),n.jsx(Qr,{session:e})]}),n.jsx(xt,{session:e,jump:r})]}),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(Yr,{session:e,className:"font-medium"}),n.jsx(Xr,{session:e,agent:s,className:"block min-w-0 wrap-anywhere"})]}),n.jsx(Jr,{session:e,className:"mt-1"})]}),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:o!==null?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"sr-only",children:["Waiting ",je(o)]}),n.jsx("span",{"aria-hidden":!0,children:G(o)})]}):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:jt})]})}),n.jsx(Zt,{session:e,jump:r,variant:"needs-you",size:"sm"})]})}function sf(e,t){return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-semibold text-ink",children:e.name}),","," ",e.how==="ended"?"ended at":"answered at"," ",n.jsx("span",{className:"tabular-nums",children:J(e.at)}),!e.startKnown&&n.jsxs(n.Fragment,{children:[", waiting since before ",n.jsx("span",{className:"tabular-nums",children:J(t)})]})]})}function of({id:e,waits:t,onOpen:s}){const o=t?.lastWait??null,r=t!==null&&t.sessions.length===0,a=t?t.period.today?"today":`since ${J(t.period.from)}`:null,i=t&&t.sessions.length===0?Wr(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",className:"mt-1 flex items-center gap-3.5 text-name font-semibold text-ink",children:[n.jsx(Q,{kind:"needs-you",unlit:!0,className:"size-6.5"}),s?n.jsx(qr,{onOpen:s,children:"Nothing needs you"}):n.jsx("span",{children:"Nothing needs you"})]}),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("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"}),o?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 ",o.startKnown?"":"at least ",je(o.ms)]}),n.jsx("span",{"aria-hidden":!0,children:n.jsx(zr,{parts:wt(o.ms)})})]}),n.jsx("p",{"data-part":"last-note",className:"mt-2 text-caption text-ink-secondary",children:sf(o,t?.period.from??o.at)})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{"data-part":"last-note",className:"text-body text-ink-secondary",children:a&&r?`None ${a}`:"Not known"}),i&&n.jsx("p",{"data-part":"last-gaps",className:"mt-1 text-caption text-ink-secondary",children:i})]})]})]})}function rf({id:e,counts:t}){return n.jsxs("div",{children:[n.jsxs("h2",{id:e,"data-part":"title",className:"flex items-center gap-2.5 text-row leading-tight font-semibold text-ink",children:[n.jsx(Q,{kind:"needs-you",unlit:!0,className:"size-4.5"}),"Needs you"]}),t.summary===null?n.jsx(xe,{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:jt}),n.jsx("p",{"data-part":"uncounted",className:"mt-2 max-w-md text-row text-ink-secondary",children:t.searching?"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 af({sessions:e,sources:t=[],events:s=[],history:o=null,now:r,asOf:a=r,onOpenHistory:i,className:l}){const d=p.useId(),c=rs(e,t),u=_r(c),f=p.useMemo(()=>e?ju(e):[],[e]),m=Sr(t,e??[]),x=N=>m?Xn(N,t):void 0,g=p.useMemo(()=>e&&u?Iu({sessions:e,events:s,history:o,now:r,asOf:a,eventsFull:s.length>=Jt}):null,[e,u,s,o,r,a]),b=i&&o&&u?i:void 0,[h,...v]=f;let y,j;return u?h?(j=v.length>0?"several":"one",y=n.jsxs("div",{children:[n.jsx(ef,{id:d,count:f.length,onOpen:b&&(()=>b("needsYou"))}),n.jsx(tf,{session:h,asOf:a,agent:x(h)},h.id),v.length>0&&n.jsx("ul",{"data-part":"others","aria-label":"Also waiting, longest first",className:"mt-5",children:v.map(N=>n.jsx(nf,{session:N,asOf:a,agent:x(N)},N.id))})]})):(j="quiet",y=n.jsx(of,{id:d,waits:g,onOpen:b&&(()=>b("needsYou"))})):(j=c.summary===null?"loading":"uncounted",y=n.jsx(rf,{id:d,counts:c})),n.jsxs("section",{"data-slot":"hero","data-state":j,"data-light":u??void 0,"aria-labelledby":d,className:k("glass-raised flex min-w-0 flex-col justify-between gap-5 px-7 pt-6 pb-5.5 max-mid:px-5",l),children:[y,u&&(g===null||g.sessions.length>0)&&n.jsx($u,{waits:g}),n.jsx(mu,{counts:c,asOf:a,onOpenHistory:b})]})}function ta(){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 ls=6e4,lf=60*ls,Vt=5*ls;function cf(e){const t=new Date(e).getTimezoneOffset()*ls;return Math.floor((e-t)/Vt)*Vt+t}function df(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 uf(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 ff(e){const{history:t,now:s}=e,o=e.gapMs??kt,r=s-(e.windowMs??lf),a={from:r,to:s},i=Math.min(e.asOf??s,s),l=es(t,i,o),d=ts(l,a,i,t?ge(t).at:-1/0,o),c=[];for(let h=cf(r);h<s;h+=Vt){const v=Math.max(h,r),y=Math.min(h+Vt,s);if(y<=v)continue;const j=Ks(d,[{from:v,to:y}]);c.push({from:v,to:y,measured:j,measuredMs:ss(j),means:null})}const u=c.map(()=>({open:0,answered:0,working:0,idle:0})),f=df(e.sessions,e.events),m=h=>f.filter(v=>v<=h).length;let x=0,g=0;if(t)for(const h of uf(t,i,o))for(const v of Ks([h],d)){const y=[v.from,...f.filter(j=>j>v.from&&j<v.to),v.to];for(let j=0;j<y.length-1;j+=1){const N=y[j],S=y[j+1],C=Math.min(h.needsYou,m(N)),T=h.needsYou-C;x+=h.needsYou*(S-N),g+=C*(S-N),c.forEach((w,_)=>{const F=Math.min(S,w.to)-Math.max(N,w.from);if(F<=0)return;const I=u[_];I.open+=C*F,I.answered+=T*F,I.working+=h.working*F,I.idle+=h.idle*F})}}let b=0;return c.forEach((h,v)=>{if(h.measuredMs<=0)return;const y=u[v],j=S=>S/h.measuredMs,N={open:j(y.open),answered:j(y.answered),working:j(y.working),idle:j(y.idle),total:0};N.total=N.open+N.answered+N.working+N.idle,h.means=N,N.total>b&&(b=N.total)}),{start:r,end:s,buckets:c,unmeasured:ns(d,a),waitedMs:x,openMs:g,axis:kc(b)}}const mf=.02,Ve=.05,hf=96;function ie(e){return`${Math.round(e*1e5)/1e3}%`}function Rn(e,t){return`${J(e.from)} to ${e.to>=t?"now":J(e.to)}`}function Ae(e){return e.toFixed(1)}function pf(e){const t=[e.open>=Ve&&`needs you ${Ae(e.open)}`,e.answered>=Ve&&`answered ${Ae(e.answered)}`,e.working>=Ve&&`working ${Ae(e.working)}`,e.idle>=Ve&&`idle ${Ae(e.idle)}`].filter(Boolean);return t.length>0?t.join(", "):"no sessions"}function na(e,t){if(!e.means)return`${Rn(e,t)}: not measured`;const s=e.measuredMs<e.to-e.from-1e3;return`${Rn(e,t)}: ${pf(e.means)}${s?`, measured for ${G(e.measuredMs)}`:""}`}function xf(e){const t=e.unmeasured.map(s=>`from ${J(s.from)} to ${s.to>=e.end?"now":J(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=>`${na(s,e.end)}.`)].filter(Boolean).join(" ")}function gf(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 bf({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:ie((s-r.start)/a),width:`max(2px, calc(${ie((o-s)/a)} - 4px))`,height:ie(Math.min(1,e.total/t))},children:i.map(([l,d,c])=>d>=mf?n.jsx("i",{"data-part":"segment","data-kind":l,className:k("block shrink-0",c),style:{height:ie(d/e.total)}},l):null)})}function wf({fill:e}){return n.jsx("i",{"aria-hidden":!0,className:k("block h-2.5 w-3.5 rounded-bar",e)})}function yf({hour:e}){const t=p.useId(),[s,o]=ta(),[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?na(u,e.end):"",m=gf(e.axis.ticks),x=o>0?ur(e.start,e.end,Math.max(1,Math.floor(o/hf))).map(h=>({at:h,share:(h-e.start)/i})).filter(({share:h})=>h*o>=16&&h*o<=o-52):[],g=(h,v)=>{const y=e.start+(h-v.left)/v.width*i,j=e.buckets.findIndex(N=>y<N.to);a(j===-1?d:j)},b=h=>{const y={ArrowLeft:j=>j-1,ArrowDown:j=>j-1,ArrowRight:j=>j+1,ArrowUp:j=>j+1,Home:()=>0,End:()=>d}[h.key];y&&(h.preventDefault(),a(Math.min(d,Math.max(0,y(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:h=>g(h.clientX,h.currentTarget.getBoundingClientRect()),onPointerLeave:()=>a(null),onBlur:()=>a(null),onFocus:h=>{h.currentTarget.matches(":focus-visible")&&a(v=>v??d)},onKeyDown:b,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(h=>n.jsx("span",{"aria-hidden":!0,"data-part":"grid",className:k("absolute inset-x-0 block h-px",h===0?"bg-rule-strong":"bg-hairline"),style:{bottom:ie(h/l)},children:m.has(h)&&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:h})},h)),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:ie((u.from-e.start)/i),width:`calc(${ie((u.to-u.from)/i)} - 2px)`}}),e.unmeasured.map(h=>n.jsx("i",{"aria-hidden":!0,"data-part":"unmeasured",className:"unmeasured-hatch absolute inset-y-0 z-0 block",style:{left:ie((h.from-e.start)/i),width:ie((h.to-h.from)/i)}},h.from)),e.buckets.flatMap(h=>h.means?h.measured.map(v=>n.jsx(bf,{means:h.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(${ie((e.end-u.from)/i)} + 6px)`}:{left:`calc(${ie((u.to-e.start)/i)} + 2px)`},children:[n.jsx("span",{className:"block text-ink-secondary",children:Rn(u,e.end)}),u.means?n.jsxs(n.Fragment,{children:[u.means.open>=Ve&&n.jsxs("span",{className:"block text-label-needs-you",children:["Needs you ",Ae(u.means.open)]}),u.means.answered>=Ve&&n.jsxs("span",{className:"block text-ink",children:["Answered ",Ae(u.means.answered)]}),n.jsxs("span",{className:"block text-ink",children:["Working ",Ae(u.means.working)]}),n.jsxs("span",{className:"block text-ink",children:["Idle ",Ae(u.means.idle)]})]}):n.jsx("span",{className:"block text-ink",children:"Not measured"})]})]}),n.jsx("p",{id:t,className:"sr-only",children:xf(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:[x.map(h=>n.jsx("span",{"data-part":"time-tick",className:"absolute top-1.75 -translate-x-1/2 whitespace-nowrap",style:{left:ie(h.share)},children:J(h.at)},h.at)),n.jsx("span",{"data-part":"now",className:"absolute top-1.75 right-0 whitespace-nowrap text-ink-secondary",children:"now"})]})]})}function kf({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(wf,{fill:o}),r]},s))})}function jf({sessions:e,sources:t=[],events:s=[],history:o,now:r,asOf:a=r,className:i}){const l=p.useMemo(()=>e&&o?ff({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(xe,{label:"Reading the last hour"});else if(l===null)u=void 0,c=n.jsx("div",{className:"px-6 pb-5",children:n.jsx(q,{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:G(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(yf,{hour:l}),n.jsx(kf,{open:l.openMs>0})]});else if(t.some(f=>f.state==="searching"))c=n.jsx(xe,{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(q,{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=Or({from:l.start,to:l.end},l.unmeasured);c=n.jsx(yt,{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:k("flex flex-col",i),children:c})}const Nf={open:"Open",draft:"Draft",merged:"Merged",closed:"Closed"},vf=["failing","pending","passing"];function sa(e){const t=[];for(const s of vf){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 qx(e){return`${Nf[e.state]}, ${sa(e.checks)}`}function Sf(e){return e!==void 0&&(e.state==="open"||e.state==="draft")&&e.checks.state==="failing"}function Js(e){return`#${e.number}: ${sa(e.checks)}`}function oa({git:e,className:t}){const s=e.pullRequest;if(!Sf(s))return null;const o=`Pull request ${Js(s)}`;return n.jsx(se,{content:o,children:n.jsxs("span",{"data-part":"checks",tabIndex:0,className:k("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 ",Js(s)]})]})})}const Af=5*6e4;function ra(e,t){if(e.status!=="working"||e.lastWriteAt===void 0)return null;const s=t-e.lastWriteAt;return s>=Af?s:null}function Ef(e){return`quiet for ${ht(e)}`}function Tf(e){return`quiet for ${Ye(e)}`}function aa({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(se,{content:r!==null?`Since ${jr(r,t)}`:"The source did not report a time",mono:r!==null,align:"end",children:n.jsx("span",{"data-part":"duration",className:k("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?`${Ye(a)} ago`:`for ${Ye(a)}`}),n.jsxs("span",{"aria-hidden":!0,children:[ht(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 ia({session:e,now:t}){const s=ra(e,t);return s===null||e.lastWriteAt===void 0?null:n.jsx(se,{content:`Last write at ${jr(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:Tf(s)}),n.jsx("span",{"aria-hidden":!0,children:Ef(s)})]})})}const ze="px-3 first:pl-6 last:pr-4.5";function Mf({session:e,now:t,jumpColumn:s,narrow:o=!1,agent:r,folderColumn:a=!0,appColumn:i=!0}){const{mark:l,word:d,stale:c,quiet:u,orphaned:f}=os(e),m=en(e),x=gt(e.surface),g=n.jsx(aa,{session:e,now:t,quiet:u}),b=ra(e,t)!==null&&n.jsx(ia,{session:e,now:t}),h=v=>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(te,{"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:"·"}),v,g]}),b&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:", "}),n.jsx("span",{className:"basis-full",children:b})]})]});return n.jsxs("tr",{"data-slot":"session-row","data-session":e.id,"data-status":e.status,"data-stale":c||void 0,onClick:v=>Vr(v,e.id),className:"group relative cursor-pointer text-body text-ink-secondary",children:[n.jsx("td",{className:k(ze,"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(Q,{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(te,{"data-part":"name",href:St(e.id),onClick:v=>tn(v,e.id),"aria-label":`${e.name}, details`,"aria-haspopup":"dialog",className:k("text-row focus-visible:outline-none",u?"font-medium text-ink-secondary":"font-semibold text-ink"),children:e.name}),f&&n.jsx(vt,{tone:"outline",children:"Process ended"})]}),!o&&n.jsx(xt,{session:e,jump:m})]}),o&&n.jsx(xt,{session:e,jump:m,className:"justify-self-start"}),o&&h(n.jsx("span",{"data-part":"status",className:"whitespace-nowrap",children:d}))]})]})}),r!==void 0&&!o&&n.jsx("td",{"data-part":"agent",className:ze,children:n.jsx(te,{className:"block min-w-0",children:r})}),a&&n.jsxs("td",{className:k(ze,"max-mid:hidden"),children:[n.jsx(se,{content:e.cwd,mono:!0,children:n.jsx("span",{"data-part":"project",tabIndex:e.cwd?0:void 0,className:k("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(is,{git:e.git,className:"min-w-0"}),n.jsx(oa,{git:e.git})]})]}),i&&n.jsx("td",{"data-part":"app",className:k(ze,"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:ze,children:[n.jsxs("div",{className:k("flex items-baseline justify-between gap-2 whitespace-nowrap",b&&"leading-tight"),children:[n.jsx("span",{"data-part":"status",children:d}),g]}),b]}),s&&n.jsx("td",{className:k(ze,"overflow-visible text-right"),children:n.jsx(Zt,{session:e,jump:m,className:"group-hover:bg-fill-selected group-hover:text-ink"})})]})}const Cf="No repository",Xs=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function If(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),Xs.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)=>Xs.compare(r.label,a.label)||(r.id<a.id?-1:r.id>a.id?1:0));return s.length>0?[...o,{id:null,label:Cf,sessions:s}]:o}function Lf(e){const t=e.git?.repository?.name;return t!==void 0&&t!==e.project?t:null}function Of({session:e,now:t,agent:s}){const{mark:o,word:r,stale:a,quiet:i,orphaned:l}=os(e),d=en(e),c=gt(e.surface),u=Lf(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:f=>Vr(f,e.id),className:k("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(Q,{kind:o}),n.jsx(te,{"data-part":"name",href:St(e.id),onClick:f=>tn(f,e.id),"aria-label":`${e.name}, details`,"aria-haspopup":"dialog",className:k("text-row focus-visible:outline-none",i?"font-medium text-ink-secondary":"font-semibold text-ink"),children:e.name})]}),l&&n.jsx(vt,{tone:"outline",children:"Process ended"}),n.jsx(xt,{session:e,jump:d})]}),e.project&&n.jsxs("p",{"data-part":"place",className:"mt-1.5 min-w-0 leading-tight",children:[u!==null&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"inline-flex max-w-full align-top",children:[n.jsx(te,{"data-part":"repository",className:"min-w-0",children:u}),n.jsx("span",{"aria-hidden":!0,className:"whitespace-pre",children:" ·"})]}),n.jsx("span",{className:"sr-only",children:","})," "]}),n.jsx(se,{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(is,{git:e.git,inSentence:!0,className:"min-w-0"}),n.jsx(oa,{git:e.git})]})]})]}),(c!==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:[c!==null&&n.jsx("span",{"data-part":"app",className:"whitespace-nowrap",children:c}),s!==void 0&&n.jsxs(n.Fragment,{children:[c!==null&&n.jsx("span",{className:"sr-only",children:", "}),n.jsxs("span",{className:"relative flex min-w-0",children:[c!==null&&n.jsx("span",{"aria-hidden":!0,className:"absolute right-full mr-1",children:"·"}),n.jsx(te,{"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(aa,{session:e,now:t,quiet:i})]}),n.jsx(ia,{session:e,now:t})]}),n.jsx(Zt,{session:e,jump:d,className:"ml-auto group-hover:bg-fill-selected group-hover:text-ink"})]})]})}const $f=[{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"}],_f=5;function Rf(e){const t=Nt(e);return{columns:$f.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 Je({children:e}){return n.jsx("span",{"data-part":"count",className:"font-medium text-ink-muted tabular-nums",children:e})}function Pf({column:e,now:t,agentOf:s}){const o=p.useId(),r=e.sessions.slice(0,_f),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(Je,{children:e.count})]}),e.stale>0&&n.jsxs("span",{"data-part":"stale",className:"inline-flex items-baseline gap-1.5",children:["Stale",n.jsx(Je,{children:e.stale})]})]}),r.length>0?n.jsx("ul",{"aria-labelledby":o,className:"flex flex-col gap-2",children:r.map(i=>n.jsx(Of,{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 Wf({sessions:e,now:t,agentOf:s}){const{columns:o,unknown:r}=Rf(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(Pf,{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 Ff=sr+2e4,Df=["gone","unsupported","cannot-confirm","not-allowed","still-running","too-soon","failed"];async function la(e){const t=await e.json();return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}async function Yx(e,t=Ff){try{const s=await oe("/api/sessions/stop",{method:"POST",headers:{"Content-Type":"application/json",[Qe]:Xl},body:JSON.stringify({sessionId:e}),signal:AbortSignal.timeout(t)}),o=await la(s);return s.status===200?o.ok===!0?"stopped":"failed":Df.find(r=>r===o.reason)??"failed"}catch{return"no-answer"}}function ca(e){return sr+2e4+e*11e3}async function zf(e,t=ca(0)){try{const s=await oe("/api/sessions/clean-up",{method:"POST",headers:{"Content-Type":"application/json",[Qe]:Ql},body:JSON.stringify({sessions:[...e]}),signal:AbortSignal.timeout(t)}),o=await la(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,Zl.find(d=>d===l)??"failed")}return{ok:!0,results:r}}catch{return{ok:!1,reason:"no-answer"}}}function Uf(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 Hf={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"},Qs="claude-code:";function Bf(e){if(e.source!=="claude-code"||!e.id.startsWith(Qs))return null;const t=e.id.slice(Qs.length);return t===""?null:t}const da={text:"claude --resume",fact:!0,whole:!0};function Zs(e){return`Stop ${e.name}?`}const ke=e=>({text:e,fact:!1}),ua=e=>({text:e,fact:!0});function Gf(e){const t=Bf(e);return t===null?null:[da,ke(" "),ua(t)]}function Kf(e){const t=Gf(e),s=t?[ke("The conversation is kept, and "),...t,ke(" opens it again.")]:[ke("The conversation is kept.")];return e.stop?.how==="background"?[ke("Agent Lookout asks Claude Code to stop this background job with "),{...ua("claude stop"),whole:!0},ke(". "),...s]:e.surface==="vscode"&&t?[ke("Its process ends now. The conversation is kept: open it again from the session history in VS Code, or with "),...t,ke(".")]:[ke("Its process ends now. "),...s]}function Vf(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 Jx="Stop it in the desktop app. Agent Lookout does not stop the desktop app's sessions, because that app looks after their processes.",qf="Stop it in the desktop app.";function fa({runs:e}){return n.jsx(n.Fragment,{children:e.map((t,s)=>t.fact?n.jsx("code",{"data-slot":"fact",className:k("font-mono text-fact",t.whole?"whitespace-nowrap":"wrap-anywhere"),children:t.text},s):t.text)})}function Xx({session:e,stop:t}){if(!e.stop)return null;const s=t.step.kind==="confirming"&&t.step.busy;return n.jsx(z,{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 Qx({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:k("text-body text-ink outline-none",s),children:Uf(o.outcome,e.stop?.how??"signal")});const r=Vf(e);return n.jsxs("section",{"data-part":"stop-confirm","aria-label":Zs(e),className:k("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}…`:Zs(e)}),n.jsx("p",{"data-part":"does",className:"text-body text-ink-secondary",children:n.jsx(fa,{runs:Kf(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(z,{size:"sm","data-part":"confirm-stop",onClick:t.confirm,"aria-disabled":o.busy||void 0,children:"Stop session"}),n.jsx(z,{id:t.ids.cancel,size:"sm","data-part":"cancel-stop",onClick:t.cancel,"aria-disabled":o.busy||void 0,children:"Cancel"})]})]})}function Yf({checked:e,onCheckedChange:t,disabled:s,className:o,...r}){return n.jsx(ti,{"data-slot":"checkbox",checked:e,onCheckedChange:a=>t(a===!0),disabled:s,className:k("relative inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-bar","after:absolute after:-inset-1","bg-fill-quiet text-ink inset-ring inset-ring-control-rim inset-shadow-top","transition-colors duration-120 hover:bg-fill-selected data-[state=checked]:bg-fill-selected","disabled:cursor-default disabled:opacity-50",o),...r,children:n.jsx(ni,{children:n.jsx(gl,{"aria-hidden":!0,className:"size-3",strokeWidth:2.5})})})}const ma="agent-lookout-hidden-sessions",Jf=100,ha=new Set;function pa(e){return`${e.statusSince??""} ${e.id}`}function xa(){try{const e=JSON.parse(localStorage.getItem(ma)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}catch{return[]}}function ga(){return new Set([...xa(),...ha])}function Xf(e){const t=pa(e),s=xa().filter(o=>o!==t);s.push(t);try{localStorage.setItem(ma,JSON.stringify(s.slice(-Jf)))}catch{ha.add(t)}return ga()}function Qf(e,t){const s=[];for(const o of e){if(o.source!=="claude-code"||o.alive!==!0||!Qt(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 Zf(e){return e.filter(t=>t.endable).slice(0,Ge).map(t=>({sessionId:t.session.id,statusSince:t.session.statusSince}))}const Rt=(e,t,s)=>e===1?t:s;function em(e){const t=u=>e.filter(f=>f===u).length,s=t("ended"),o=[`Ended ${s===0?"none":s}.`],r=t("became-active");r>0&&o.push(`Left ${r} running because ${Rt(r,"it","they")} became active.`);const a=t("not-stale");a>0&&o.push(`Left ${a} running because ${Rt(a,"it has","they have")} been idle less than a day.`);const i=t("cannot-confirm");i>0&&o.push(`Left ${i} running because Agent Lookout could not confirm ${Rt(i,"its process","their processes")}.`);const l=t("still-running");l>0&&o.push(`${l} asked to stop ${Rt(l,"is","are")} still running.`);const d=t("gone");d>0&&o.push(`${d} had already ended.`);const c=t("failed")+t("unsupported")+t("not-allowed");return c>0&&o.push(`${c} could not be stopped.`),o.join(" ")}const eo="End the sessions left running?",tm=[{text:"Each chosen session's process ends now. Its conversation is kept, and ",fact:!1},da,{text:" opens it again. A session that has done anything since this list was drawn is left running.",fact:!1}];function nm(e){return`End ${e} ${e===1?"session":"sessions"}`}function sm(e){return new Set(e.filter(t=>t.endable).slice(0,Ge).map(t=>t.session.id))}function om(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 xn({one:e,checkbox:t,outcome:s,action:o}){const{session:r}=e,a=gt(r.surface),i=[r.project,a].filter(d=>d!==null),l=s==null||s==="ended";return n.jsxs("li",{"data-slot":"left-running-row","data-session":r.id,"data-endable":e.endable||void 0,className:"flex items-start gap-3 py-1.5",children:[t?n.jsx(Yf,{checked:t.checked,onCheckedChange:t.onChange,disabled:t.disabled,"aria-label":`End ${r.name}`,className:"mt-0.5"}):n.jsx(Q,{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(te,{"data-part":"name",href:St(r.id),onClick:d=>tn(d,r.id),"aria-label":`${r.name}, details`,"aria-haspopup":"dialog",className:"max-w-full text-row font-medium text-ink-secondary",children:r.name}),s&&n.jsx(vt,{"data-part":"outcome","data-outcome":s,tone:s==="ended"?"neutral":"outline",children:Hf[s]})]}),n.jsxs("p",{"data-part":"place",className:"text-caption leading-tight text-ink-secondary",children:[i.join(" · "),i.length>0&&l&&" · ",l&&n.jsxs("span",{className:"tabular-nums",children:[n.jsxs("span",{"aria-hidden":!0,children:["idle ",ht(e.idleMs)]}),n.jsxs("span",{className:"sr-only",children:["idle ",Ye(e.idleMs)]})]})]}),!e.endable&&n.jsx("p",{"data-part":"desktop",className:"mt-0.5 text-caption leading-tight text-ink-secondary",children:qf})]}),o]})]})}function rm({sessions:e,now:t,onEnded:s,onGone:o,end:r=zf}){const[a,i]=p.useState(ga),[l,d]=p.useState({kind:"list"}),[c,u]=p.useState(!1),[f,m]=p.useState(null),x=p.useRef(null),g=p.useRef(null),b=p.useRef(null),h=p.useRef(null),v=p.useRef(null),y=p.useRef(null),j=p.useRef(!0),N=p.useId();p.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]),p.useEffect(()=>{const I=y.current;if(y.current=null,I===null)return;let L;I==="cancel"?L=h.current:I==="summary"?L=v.current:I==="toggle"?L=g.current:I==="end"?L=b.current??g.current:L=[...x.current?.querySelectorAll('[data-slot="left-running-row"]')??[]].find(Y=>Y.dataset.session===I.hide)?.querySelector('[data-part="hide"]'),L?L.focus():x.current||o?.()},[l,a,c,o]);const S=Qf(e,t).filter(I=>!a.has(pa(I.session)));c&&l.kind==="list"&&S.length===0&&u(!1);const C=()=>{m(null),y.current="cancel",d({kind:"confirming",shown:S,chosen:sm(S),busy:!1})},T=()=>{y.current="end",d({kind:"list"})},w=I=>{const L=S.indexOf(I),O=S.filter(Y=>Y!==I),H=O[L]??O[L-1];y.current=H?{hide:H.session.id}:"end",i(Xf(I.session))},_=()=>{y.current="toggle",u(!c)};if(l.kind==="list"&&S.length===0)return null;if(l.kind==="done"){const I=l.rows.filter(({outcome:L})=>L!=="ended").length;return n.jsxs(gn,{ref:x,count:I,open:!0,children:[n.jsx("p",{ref:v,tabIndex:-1,role:"status","data-part":"summary",className:"mt-1 text-body text-ink outline-none",children:l.summary}),n.jsx("ul",{className:"mt-1.5",children:l.rows.map(({one:L,outcome:O})=>n.jsx(xn,{one:L,outcome:O},L.session.id))}),n.jsx("div",{className:"mt-2",children:n.jsx(z,{size:"sm","data-part":"done",onClick:()=>{y.current="end",d({kind:"list"})},children:"Done"})})]})}if(l.kind==="confirming"){const{shown:I,chosen:L,busy:O}=l,H=Zf(I.filter(D=>L.has(D.session.id))),Y=L.size>=Ge,re=I.filter(D=>D.endable).length>Ge,we=I.filter(D=>L.has(D.session.id)&&D.session.stop?.how==="background").length,Ze=()=>{O||H.length===0||(d({...l,busy:!0}),r(H,ca(we)).then(D=>{if(!j.current)return;if(!D.ok){m(om(D)),y.current="cancel",d({...l,busy:!1});return}const M=H.map(ae=>D.results.get(ae.sessionId)??"failed");y.current="summary",d({kind:"done",rows:I.map(ae=>({one:ae,outcome:L.has(ae.session.id)?D.results.get(ae.session.id)??null:null})),summary:em(M)}),M.includes("ended")&&s?.()}))};return n.jsx(gn,{ref:x,count:I.length,open:!0,children:n.jsxs("section",{"data-part":"end-confirm","aria-label":eo,children:[n.jsx("p",{"data-part":"question","aria-live":"polite",className:"mt-1 text-body font-medium text-ink",children:O?`Ending ${H.length===1?"1 session":`${H.length} sessions`}…`:eo}),n.jsx("p",{"data-part":"does",className:"mt-1 text-body text-ink-secondary",children:n.jsx(fa,{runs:tm})}),re&&n.jsxs("p",{"data-part":"limit",className:"mt-1 text-body text-ink-secondary",children:["Up to ",Ge," at a time."]}),n.jsx("ul",{className:"mt-1.5",children:I.map(D=>n.jsx(xn,{one:D,checkbox:D.endable?{checked:L.has(D.session.id),disabled:O||Y&&!L.has(D.session.id),onChange:M=>{const ae=new Set(L);M?ae.size<Ge&&ae.add(D.session.id):ae.delete(D.session.id),d({...l,chosen:ae})}}:void 0},D.session.id))}),f&&n.jsx("p",{"data-part":"problem",role:"status",className:"mt-1.5 text-body text-ink",children:f}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3",children:[n.jsx(z,{size:"sm","data-part":"confirm-end",onClick:Ze,"aria-disabled":O||H.length===0||void 0,children:nm(H.length)}),n.jsx(z,{ref:h,size:"sm","data-part":"cancel-end",onClick:O?void 0:T,"aria-disabled":O||void 0,children:"Cancel"})]})]})})}const F=S.some(I=>I.endable);return n.jsx(gn,{ref:x,count:S.length,open:c,action:n.jsxs(n.Fragment,{children:[c&&F&&n.jsx(z,{ref:b,size:"sm","data-part":"end-all",onClick:C,children:"End all…"}),n.jsx(z,{ref:g,size:"sm","data-part":"review","aria-expanded":c,"aria-controls":c?N:void 0,onClick:_,children:c?"Close":"Review…"})]}),children:c&&n.jsx("ul",{id:N,className:"mt-1.5",children:S.map(I=>n.jsx(xn,{one:I,action:n.jsx(z,{size:"sm","data-part":"hide","aria-label":`Hide ${I.session.name} until it changes`,onClick:()=>w(I),children:"Hide until it changes"})},I.session.id))})})}function gn({ref:e,count:t,open:s,action:o,children:r}){return n.jsxs("section",{ref:e,"data-slot":"left-running","data-open":s||void 0,"aria-labelledby":"left-running-head",className:k("mx-2.5 mb-3 rounded-inner bg-fill-zebra px-3.5 pt-2 inset-ring inset-ring-hairline",s?"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(Je,{children:t})]}),n.jsx("span",{"data-part":"note",className:"text-caption text-ink-secondary",children:"idle a day or more"})]}),o&&n.jsx("div",{className:"flex items-center gap-3",children:o})]}),r]})}function We({value:e,onValueChange:t,options:s,label:o,className:r}){const a=s.findIndex(i=>i.value===e);return n.jsxs(si,{"data-slot":"segmented-control","aria-label":o,orientation:"horizontal",value:e,onValueChange:i=>t(i),className:k("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:k("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(oi,{value:i.value,"aria-label":i.name,onFocus:()=>{i.value!==e&&t(i.value)},className:k("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 am(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 im="(max-width: 760px)";function nn(){return am(im)}const lm=["list","repositories","board"],ba="agent-lookout-sessions-layout",to="list";let qt=null;function cm(){if(qt!==null)return qt;try{const e=localStorage.getItem(ba);return lm.find(t=>t===e)??to}catch{return to}}function dm(e){try{localStorage.setItem(ba,e),qt=null}catch{qt=e}}function um(){const[e,t]=p.useState(cm),s=p.useCallback(o=>{dm(o),t(o)},[]);return[e,s]}const fm=[{value:"list",label:"List"},{value:"repositories",label:"Repos"},{value:"board",label:"Board"}];function mm({source:e}){const t=e.state==="unavailable";return n.jsxs(q,{tone:t?"info":"error",title:t?`${e.label} was not found`:`${e.label} could not be read`,children:[n.jsx("p",{children:n.jsx(le,{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(le,{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 nt({sources:e,last:t}){return n.jsx("div",{className:k("flex flex-col gap-2 px-6",t?"pb-6":"pb-3"),children:e.map(s=>n.jsx(mm,{source:s},s.id))})}function hm({sources:e}){const t=e.filter(s=>s.state==="searching");return n.jsxs(yt,{title:"Looking for agents",children:[t.map(s=>n.jsx("p",{children:n.jsx(le,{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 no({head:e,sessions:t,now:s,jumpColumn: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(Mf,{session:u,now:s,jumpColumn:o,narrow:a,agent:i?.(u),folderColumn:l,appColumn:d},u.id))]})}function pm({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(Je,{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(Je,{children:e.stale})]})]})}function xm({sessions:e,byRepository:t,...s}){if(!t)return $n(e).map(r=>n.jsx(no,{"data-group":r.id,head:n.jsx(pm,{group:r}),sessions:r.sessions,...s},r.id));const o=$n(e).flatMap(r=>r.sessions);return If(o).map(r=>n.jsx(no,{"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(te,{"data-part":"repository",className:"min-w-0",children:r.label}),n.jsx(Je,{children:r.sessions.length})]}),sessions:r.sessions,...s},r.id??""))}const me={agent:6.25,folder:7,app:7,status:10,jump:6},gm=12.5,bm=12,so={folder:!0,app:!0,folderRem:me.folder};function wm(e,t,s,o){const[r,a]=p.useState(so);return p.useLayoutEffect(()=>{const i=e.current?.parentElement;if(!t||!i)return;const l=()=>{const c=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,u=gm+me.status+(s?me.agent:0)+(o?me.jump:0),f=i.clientWidth/c,m=f>=u+me.folder,x=m&&f>=u+me.folder+me.app,g=f-(u+me.folder+(x?me.app:0)),b=Math.round(Math.min(bm,me.folder+Math.max(0,g)/2)*4)/4;a(h=>h.folder===m&&h.app===x&&h.folderRem===b?h:{folder:m,app:x,folderRem:b})};l();const d=new ResizeObserver(l);return d.observe(i),()=>d.disconnect()},[e,t,s,o]),t?r:so}function ym({sessions:e,sources:t,now:s,onEnded:o,className:r}){const a=p.useRef(null),i=p.useRef(null),l=Ed(t),d=l.filter(O=>O.state==="unavailable"||O.state==="error"),c=l.some(O=>O.state==="searching"),u=$n(e).flatMap(O=>O.sessions),[f,m]=um(),x=f==="board"&&e.length>0,g=u.some(O=>Ee(O)!==null),b=(x?e:u).map(Ee).filter(O=>O!==null),h=b.some(O=>O.by==="tmux")?b.some(O=>O.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",v=Sr(t,e),y=v?O=>Xn(O,t):void 0,j=nn(),N=v&&!j,{folder:S,app:C,folderRem:T}=wm(a,u.length>0&&!j&&!x,N,g),w=(j?1:2+(N?1:0)+(S?1:0)+(C?1:0))+(g?1:0),{counted:_}=rs(e,t);let F;if(x)F=n.jsxs(n.Fragment,{children:[d.length>0&&n.jsx(nt,{sources:d,last:!1}),n.jsx(Wf,{sessions:e,now:s,agentOf:y})]});else if(u.length>0)F=n.jsxs(n.Fragment,{children:[d.length>0&&n.jsx(nt,{sources:d,last:!1}),n.jsxs("table",{ref:a,"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",{}),N&&n.jsx("col",{className:"w-25"}),S&&!j&&n.jsx("col",{style:{width:`${T}rem`}}),C&&!j&&n.jsx("col",{className:"w-28"}),!j&&n.jsx("col",{className:"w-40"}),g&&n.jsx("col",{className:"w-24"})]}),n.jsx("thead",{className:"sr-only",children:n.jsxs("tr",{children:[n.jsx("th",{scope:"col",children:"Session"}),N&&n.jsx("th",{scope:"col",children:"Agent"}),S&&!j&&n.jsx("th",{scope:"col",children:"Folder"}),C&&!j&&n.jsx("th",{scope:"col",children:"App"}),!j&&n.jsx("th",{scope:"col",children:"Status and time"}),g&&n.jsx("th",{scope:"col",children:"Jump"})]})}),n.jsx(xm,{sessions:e,byRepository:f==="repositories",now:s,jumpColumn:g,columns:w,narrow:j,agentOf:y,folderColumn:S,appColumn:C})]})]});else if(e.length>0)F=n.jsxs(n.Fragment,{children:[d.length>0&&n.jsx(nt,{sources:d,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(c)F=n.jsx(hm,{sources:l});else if(d.length>0&&d.length===l.length)F=n.jsx(nt,{sources:d,last:!0});else{const O=l.filter(H=>H.state==="ok");F=n.jsxs(n.Fragment,{children:[d.length>0&&n.jsx(nt,{sources:d,last:!1}),n.jsx(yt,{title:"No agents are running",children:n.jsxs("p",{children:["Agent Lookout is watching ",He(O)," on this computer. A session shows up here within a few seconds of starting."]})})]})}const I=b.length>0&&n.jsx("span",{"data-part":"hint",className:"max-mid:hidden @max-[42rem]:hidden",children:h}),L=e.length>0&&n.jsx(We,{label:"Show sessions as",value:f,onValueChange:m,options:fm,className:j?void 0:"-my-2.5"});return n.jsxs(U,{title:"Sessions",titleRef:i,count:_?e.length:void 0,aside:L&&!j?n.jsxs("div",{className:"flex items-center gap-4",children:[I,L]}):I||void 0,className:k("@container",r),children:[L&&j&&n.jsx("div",{"data-part":"layout",className:"flex px-6 pb-1",children:L}),n.jsx(rm,{sessions:e,now:s,onEnded:o,onGone:()=>i.current?.focus()}),F]})}const km={...Qn,stale:"Stale",unmeasured:"Not measured"};function jm({segment:e,from:t,share:s}){switch(e.kind){case"needs-you":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:k("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:_e(-t/s),width:_e(1/s)}})})}}const Nm=.01,vm={ArrowLeft:e=>Math.max(0,e-1),ArrowRight:(e,t)=>Math.min(t,e+1),Home:()=>0,End:(e,t)=>t};function Sm(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":km[e.kind],lasted:r(G(t)),lastedInWords:r(je(t)),clock:`${de(e.from)} to ${e.ongoing?"now":de(e.to)}`}}function _e(e){return`${Math.round(e*1e5)/1e3}%`}function Am(e,t,s){const o=s-t,r=e.filter(a=>a.kind==="unmeasured").map(a=>{const i=_e((Math.max(a.from,t)-t)/o),l=`calc(${_e((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 Em({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(b=>b.to>b.from&&b.to>t&&b.from<s):[],f=u.length-1,m=l===null?-1:u.findIndex(b=>b.to===l),x=m===-1?f:m,g=b=>{const h=vm[b.key];if(!h||f<0)return;b.preventDefault(),i.current?.querySelectorAll('[data-part="segment"]')?.[h(x,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:g,className:k("relative h-track w-full",a),children:[c>0&&r.some(b=>b>t&&b<s)&&n.jsx("span",{"aria-hidden":!0,"data-part":"rules",className:"pointer-events-none absolute inset-0",style:{maskImage:Am(u,t,s)},children:r.filter(b=>b>t&&b<s).map(b=>n.jsx("span",{className:"absolute inset-y-0 w-px bg-hairline",style:{left:_e((b-t)/c)}},b))}),u.map((b,h)=>{const v=Math.max(b.from,t),j=(Math.min(b.to,s)-v)/c,N=Sm(b);return n.jsx(se,{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":b.kind,"data-open":b.kind==="needs-you"?!!b.open:void 0,role:"img","aria-label":`${N.status}, ${N.lastedInWords}, ${N.clock}`,tabIndex:h===x?0:-1,onFocus:()=>d(h===f?null:b.to),className:k("absolute inset-y-0 flex min-w-0.75 items-center pr-0.5 focus-visible:z-20",j<Nm&&"z-10 before:absolute before:inset-y-0 before:-inset-x-1"),style:{left:`min(${_e((v-t)/c)}, calc(100% - 3px))`,width:_e(j)},children:n.jsx(jm,{segment:b,from:(v-t)/c,share:j})})},h===f?"present":b.to)})]})}const Tm=6,Mm=96,Cm=20,Im=100;function Lm(e,t){return(e-t.start)/(t.end-t.start)}function Om(e){return`${Math.round(e*1e5)/1e3}%`}function $m(e){return e.status===null?null:e.stale&&e.status==="idle"?"stale":e.status}function _m({row:e,timeline:t,rules:s,named:o}){const r=$m(e),a=e.status==="needs-you";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:k("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(Q,{kind:r}):n.jsx("span",{"aria-hidden":!0,"data-part":"no-mark",className:"size-mark shrink-0"}),n.jsx(te,{"data-part":"name",children:e.name})]}),n.jsx(Em,{segments:e.segments,start:t.start,end:t.end,label:e.ended?`${e.name}, ended`:e.name,rules:s,className:"min-w-0 flex-1"})]})}const Pt="block h-2.5 w-3.5 rounded-bar",oo="block h-bar-idle w-3.5",Rm=[{kind:"needs-you",label:"Needs you",swatch:n.jsx("i",{className:k(Pt,"bar-open")})},{kind:"answered",label:"Answered",swatch:n.jsx("i",{className:k(Pt,"bar-answered")})},{kind:"working",label:"Working",swatch:n.jsx("i",{className:k(Pt,"bar-working")})},{kind:"idle",label:"Idle",swatch:n.jsx("i",{className:k(oo,"bar-idle rounded-capsule")})},{kind:"stale",label:"Stale",swatch:n.jsx("i",{className:k(oo,"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(Q,{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:k(Pt,"unmeasured-hatch")})}];function Pm({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:Rm.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 Wm(e,t){if(t<=0)return[];const s=Math.max(1,Math.min(Tm,Math.floor(t/Mm)));return ur(e.start,e.end,s).map(o=>({at:o,share:Lm(o,e)})).filter(({share:o})=>o*t>=Cm&&o*t<=t-Im).map(({at:o,share:r})=>({at:o,left:Om(r)}))}function Fm({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]=ta(),l=Wm(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(_m,{row:c,timeline:e,rules:d,named:s},c.id))}),n.jsxs("div",{ref:a,"data-slot":"timeline-axis","aria-hidden":!0,className:k("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:J(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:[J(e.end)," now"]})]})]})}function Dm({sessions:e,sources:t=[],events:s,history:o,now:r,asOf:a=r,className:i}){const l=p.useMemo(()=>e&&o?Pr({sessions:e,events:s,history:o,now:r,asOf:a,eventsFull:s.length>=Jt}):null,[e,s,o,r,a]);let d;if(e===null)d=n.jsx(xe,{label:"Reading the last hour"});else if(l===null)d=n.jsx("div",{className:"px-6 pb-6",children:n.jsx(q,{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(l.rows.length>0)d=n.jsx(Fm,{timeline:l});else if(t.some(c=>c.state==="searching"))d=n.jsx(xe,{label:"Looking for sessions"});else if(!t.some(c=>c.state==="ok"))d=n.jsx("div",{className:"px-6 pb-6",children:n.jsx(q,{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 c=Or({from:l.start,to:l.end},l.unmeasured);d=n.jsx(yt,{compact:!0,title:c?`No sessions ${c}`:"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:l&&l.rows.length>0?n.jsx(Pm,{timeline:l}):void 0,className:i,children:d})}const zm=3e4,Um=4e3;async function Hm(){try{const e=await oe("/api/waits",{headers:{accept:"application/json"},signal:AbortSignal.timeout(Um)});return e.ok?ad(await e.json()):null}catch{return null}}function Ce(e){return e.measuredMs>0}function cs(e){return Ce(e)?e.waits===0?"No waits":`${e.waits} ${e.waits===1?"wait":"waits"}`:"Not measured"}const Bm=new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}),Gm=new Intl.DateTimeFormat(void 0,{weekday:"long",month:"long",day:"numeric"});function Pn(e,t,s=!1){const o=ne(t),r=ne(e.from);if(r===o)return"Today";const a=new Date(o);return a.setDate(a.getDate()-1),r===a.getTime()?"Yesterday":(s?Gm:Bm).format(new Date(e.from))}function wa(e,t){return ne(e.from)===ne(t)?e.openMs:0}function Km(e,t){const s=Pn(e,t,!0);if(!Ce(e))return`${s}: not measured`;const o=e.waits===0?"no session waited":`waited ${je(e.waitedMs)} in ${cs(e).toLowerCase()}`,r=wa(e,t)>0?", still waiting":"";return`${s}: ${o}${r}, measured for ${je(e.measuredMs)}`}function Wt(e,t){return Ce(e)?`${G(e.measuredMs)} of ${t}`:`none of ${t}`}function Vm(e){const{today:t,sevenDays:s,since:o,at:r}=e;if(e.where==="memory"){const i=s.measuredMs===t.measuredMs?"":`, and ${Wt(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 ${ce(o.at,r)} is counted: ${Wt(t,"today")} so far${i}.`}const a=`Only the time Agent Lookout was running is counted: ${Wt(t,"today")} so far, and ${Wt(s,"the last 7 days")}.`;return o.at<=s.from?a:o.by==="cleared"?`${a} The history was cleared at ${ce(o.at,r)}.`:`${a} The history it keeps begins at ${ce(o.at,r)}.`}function qm(e,t){const s=t-e.at;if(s<=0||ne(t)!==ne(e.at)||!Ce(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 Ym(e,t){const s=t==="today"?"today":"in the last 7 days";return Ce(e)?`No session waited on you ${s}.`:`Nothing was measured ${s}.`}function Jm(e,t){const[s,o]=p.useState(null),[r,a]=p.useState(!1),i=e?.startedAt??null,l=e?ge(e).at:null,d=[...t].sort().join(" ");return p.useEffect(()=>{let c=!0;const u=()=>{Hm().then(x=>{c&&(x&&o(x),a(x===null))})},f=()=>{document.hidden||u()};u();const m=setInterval(f,zm);return document.addEventListener("visibilitychange",f),()=>{c=!1,clearInterval(m),document.removeEventListener("visibilitychange",f)}},[i,l,d]),s?{waits:s,status:"ready"}:{waits:null,status:r?"failed":"loading"}}const ya="–",Xm=15*6e4,Qm=5,Zm=[{value:"today",label:"Today"},{value:"sevenDays",label:"7 days"}];function eh(e){return`${Math.round(e*1e5)/1e3}%`}function th({today:e}){return n.jsx("p",{"data-part":"sum",className:"text-body text-ink-secondary",children:Ce(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:G(e.waitedMs)})," ","today, in ",cs(e).toLowerCase()]}):"Nothing was measured today"})}function ro({label:e,total:t,className:s}){const o=Ce(t);return n.jsxs("div",{"data-part":"figure",className:k("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?je(t.waitedMs):"Not measured"}),n.jsx("span",{"aria-hidden":!0,children:o?G(t.waitedMs):ya})]}),n.jsx("dd",{"data-part":"count",className:"mt-2 text-caption text-ink-muted",children:cs(t)})]})}function nh({day:e,scale:t,now:s}){const o=Ce(e),r=Pn(e,s)==="Today",a=wa(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:k("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:Pn(e,s)}),n.jsx("span",{"data-part":"track",role:"img","aria-label":Km(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:eh(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?G(e.waitedMs):ya}),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 ${G(e.measuredMs)}`:"not measured"})]})}function sh({period:e,now:t}){const s=p.useId(),o=Math.max(0,...e.days.map(a=>a.waitedMs)),r=Math.max(Xm,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(nh,{day:a,scale:r,now:t},a.day))})]})}function oh({waits:e,period:t,onPeriod:s}){const o=p.useId(),r=e[t],a=r.sessions.slice(0,Qm),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(We,{label:"Longest waits over",value:t,onValueChange:s,options:Zm,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.jsx(te,{"data-part":"name",className:"block text-body font-semibold text-ink",children:l.name}),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:je(l.waitedMs)}),n.jsx("span",{"aria-hidden":!0,children:G(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:Ym(r,t)})]})}function rh({waits:e}){const[t,s]=p.useState("today");return n.jsxs("div",{"data-part":"waits",className:"px-6 pb-5.5",children:[n.jsx(th,{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(ro,{label:"Today",total:e.today}),n.jsx(ro,{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:Vm(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(sh,{period:e.sevenDays,now:e.at}),n.jsx(oh,{waits:e,period:t,onPeriod:s})]})]})}function ah({history:e,sessions:t,asOf:s,className:o}){const r=t.filter(i=>i.status==="needs-you").map(i=>i.id),a=Jm(e,r);return n.jsx(U,{title:"Waits",className:o,children:a.waits?n.jsx(rh,{waits:qm(a.waits,s)}):a.status==="failed"?n.jsx("div",{className:"px-6 pb-5",children:n.jsx(q,{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(xe,{label:"Reading waits"})})}function ih(e){return e!==null&&e.isConnected&&e.tabIndex>=0}function lh(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(g=>g.getAttribute(t)===l.key),m=f.find(g=>g.getAttribute("data-slot")===l.slot)??f[0],x=g=>g===null?null:m?.querySelector(`[data-part="${g}"]`)??null;u=[x(l.part),x(s)].find(ih)??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 ka=['[data-slot="hero-session"]','[data-slot="session-row"]','[data-slot="board-card"]'],ch=ka.join(", ");function ao(e,t){if(Ee(t)===null){Kt(t.id);return}if(!e)return;const s=CSS.escape(t.id),o=e.querySelector(ka.map(a=>`${a}[data-session="${s}"]`).join(", ")),r=o?.querySelector('[data-part="jump"]');if(!o||!r){Kt(t.id);return}o.scrollIntoView({block:"center"}),r.focus({preventScroll:!0,focusVisible:!0}),r.click()}function dh(e,t){const s=p.useRef(null);return p.useEffect(()=>{if(t!=="overview"||s.current===null)return;const o=s.current;s.current=null,ao(e.current,o)},[e,t]),p.useCallback(o=>{if(t==="overview"){ao(e.current,o);return}s.current=o,window.location.hash="#overview"},[e,t])}const fe={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 uh({state:e,now:t,onRetry:s,onEnded:o,onOpenHistory:r,newSince:a=null,onNewLineInView:i}){const{snapshot:l,phase:d}=e,[c,u]=lh(ch,"data-session");if(!l&&d==="unreachable")return n.jsx(Dd,{problem:e.problem,kind:e.problemKind,onRetry:s});const f=d==="stalled"&&e.lastOkAt!==null?e.lastOkAt:t,m=l?.sessions??null,x=l?.sources??[],g=_r(rs(m,x));return n.jsxs("div",{"data-slot":"dashboard","data-phase":d,className:"flex flex-col gap-4",children:[l&&d==="stalled"&&e.lastOkAt!==null&&n.jsx(Fd,{lastOkAt:e.lastOkAt,now:t,onRetry:s}),n.jsxs("div",{ref:c,...u,"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:[g&&n.jsx("div",{"aria-hidden":!0,"data-slot":"hero-light","data-light":g,className:k(g==="lamp"?"lamp-light":"rest-light",fe.hero)},g),n.jsx(af,{sessions:m,sources:x,events:e.events,history:e.history,now:t,asOf:f,onOpenHistory:r,className:k("z-1",fe.hero)}),n.jsx(jf,{sessions:m,sources:x,events:e.events,history:e.history,now:t,asOf:f,className:k("z-1",fe.lastHour)}),l?n.jsxs(n.Fragment,{children:[n.jsx(ym,{sessions:l.sessions,sources:l.sources,now:f,onEnded:o,className:k("z-1",fe.sessions)}),n.jsx(au,{events:e.events,sessions:l.sessions,history:e.history,now:t,newSince:a,onNewLineInView:i,className:k("z-1",fe.events)})]}):n.jsxs(n.Fragment,{children:[n.jsx(U,{title:"Sessions",className:k("z-1",fe.sessions),children:n.jsx(xe,{label:"Reading sessions"})}),n.jsx(U,{title:"Events",className:k("z-1",fe.events),children:n.jsx(xe,{label:"Reading events"})})]}),n.jsx(Dm,{sessions:m,sources:x,events:e.events,history:e.history,now:t,asOf:f,className:k("z-1",fe.timeline)}),l?n.jsx(ah,{history:e.history,sessions:l.sessions,asOf:f,className:k("z-1",fe.waits)}):n.jsx(U,{title:"Waits",className:k("z-1",fe.waits),children:n.jsx(xe,{label:"Reading waits"})})]})]})}function fh({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:k("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 mh({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:k("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 hh({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:k("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 ja({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:k("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 Na({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:k("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 va="agent-lookout-theme",io="dark",Sa="(prefers-color-scheme: light)";function ph(e){return e==="light"||e==="dark"||e==="system"}function xh(){try{const e=localStorage.getItem(va);return ph(e)?e:io}catch{return io}}function Aa(){return window.matchMedia(Sa).matches?"light":"dark"}function Ea(e){return e==="system"?Aa():e}let ut=null;const Dt=new Set;let ft=null;function Ta(){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 Ma(e){ut=e,document.documentElement.setAttribute("data-theme",e.resolved),Ta();for(const t of Dt)t()}function gh(){if(ft)return;const e=window.matchMedia(Sa),t=()=>{ut?.preference==="system"&&Ma({preference:"system",resolved:Aa()})};e.addEventListener("change",t),ft=()=>e.removeEventListener("change",t)}function Ca(){if(!ut){const e=xh();ut={preference:e,resolved:Ea(e)}}return ut}function bh(e){Dt.add(e),gh();const{resolved:t}=Ca();return document.documentElement.getAttribute("data-theme")!==t&&document.documentElement.setAttribute("data-theme",t),Ta(),()=>{Dt.delete(e),Dt.size===0&&ft&&(ft(),ft=null)}}function wh(e){try{localStorage.setItem(va,e)}catch{}Ma({preference:e,resolved:Ea(e)})}function Ia(){return{...p.useSyncExternalStore(bh,Ca),setPreference:wh}}const yh=[{value:"dark",label:"Night",name:"Dark theme",icon:n.jsx(ja,{})},{value:"light",label:"Day",name:"Light theme",icon:n.jsx(Na,{})}];function kh({className:e}){const{resolved:t,setPreference:s}=Ia();if(nn()){const r=t==="dark"?"light":"dark",a=r==="light"?"Switch to Day":"Switch to Night";return n.jsx(se,{content:a,align:"end",children:n.jsx(z,{size:"icon","aria-label":a,"data-part":"theme",onClick:()=>s(r),className:e,children:t==="dark"?n.jsx(ja,{}):n.jsx(Na,{})})})}return n.jsx(We,{label:"Theme",value:t,onValueChange:s,options:yh,className:e})}const jh=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function Nh(e){if(!e)return!1;if(e.isContentEditable===!0)return!0;switch(e.tagName){case"TEXTAREA":case"SELECT":return!0;case"INPUT":return!jh.has((e.type??"text").toLowerCase());default:return!1}}function ds(e=typeof navigator>"u"?"":navigator.platform||navigator.userAgent||""){return/Mac|iPhone|iPad|iPod/.test(e)}function vh(e){return/^[a-z]$/i.test(e.key)?e.key.toLowerCase():e.code?.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function Sh(e,{mac:t,typing:s}){return(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey&&!e.shiftKey&&vh(e)==="k"?"search":s||e.metaKey||e.ctrlKey||e.altKey?null:e.key==="/"?"search":e.key==="?"?"shortcuts":null}function La(e){return e?{shown:"⌘K",said:"Command K"}:{shown:"Ctrl+K",said:"Control K"}}function Ah(e){return e?"/ Meta+K":"/ Control+K"}const lo=[{shown:"←",said:"Left arrow"},{shown:"→",said:"Right arrow"}];function Eh(e){return[{title:"On every view",rows:[{does:"Find a session",keys:[{shown:"/"},La(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:lo},{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:lo}]}]}function Th({onSearch:e}){const t=ds();return n.jsx(se,{content:`Find a session: / or ${La(t).shown}`,align:"end",children:n.jsx(z,{size:"icon","aria-label":"Find a session","aria-haspopup":"dialog","aria-keyshortcuts":Ah(t),"data-part":"search",onClick:e,children:n.jsx(Qo,{"aria-hidden":!0,className:"size-4",strokeWidth:1.75})})})}function Mh({phase:e,snapshot:t,lastOkAt:s,now:o,onSearch:r}){const a=Pd(e,t,o,s),i=nn();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:k("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(Th,{onSearch:r}),n.jsx(kh,{})]})]})}function Oa(e){return e.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ch(e){return Oa(e).split(/\s+/u).filter(Boolean)}function Ih(e,t){return Oa([e.name,e.project,e.git?.branch,e.git?.commit,t].filter(s=>typeof s=="string").join(" "))}function Lh(e,t,s){const o=Nt(e).flatMap(a=>a.sessions),r=Ch(t);return r.length===0?o:o.filter(a=>{const i=Ih(a,s(a));return r.every(l=>i.includes(l))})}function Oh(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:`${ht(s)} ago`,said:`${Ye(s)} ago`}:{shown:ht(s),said:`for ${Ye(s)}`}}function $h(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 _h({session:e,agent:t,asOf:s,id:o,active:r,onPoint:a,onPick:i}){const{mark:l,word:d,quiet:c}=os(e),u=Oh(e,s),f=Ee(e),m=[e.name,`${d} ${u.said}`,$h(e),t,f&&`Jump to ${f.where}`].filter(Boolean).join(", "),{branch:x,commit:g}=e.git??{};return n.jsxs("li",{id:o,role:"option","aria-selected":r,"aria-label":m,"data-slot":"search-result","data-session":e.id,"data-status":e.status,onPointerMove:a,onClick:i,className:k("flex cursor-pointer items-start gap-3 rounded-inner px-3.5 py-2.5",r&&"bg-fill-selected"),children:[n.jsx(Q,{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:k("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:k("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}),x!==void 0?n.jsxs(n.Fragment,{children:[" ","on ",n.jsx("span",{"data-part":"branch",children:x})]}):g!==void 0?n.jsxs(n.Fragment,{children:[" ","at"," ",n.jsx("span",{"data-part":"commit",className:"font-mono text-fact",children:g})]}):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})]})]})]})]})}function Rh({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,m=T=>Xn(T,u),x=Lh(c,r,m),g=x.findIndex(T=>T.id===i),b=x.length===0?-1:Math.max(0,g),h=x[b],v=T=>`${d}-${encodeURIComponent(T.id)}`,y=h?v(h):void 0,j=h?Ee(h):null;p.useEffect(()=>{y&&document.getElementById(y)?.scrollIntoView({block:"nearest"})},[y]);const N=T=>{if(!T.nativeEvent.isComposing)if(T.key==="ArrowDown"||T.key==="ArrowUp"){T.preventDefault();const w=x[(b+(T.key==="ArrowDown"?1:-1)+x.length)%x.length];w&&l(w.id)}else T.key==="Enter"&&(T.preventDefault(),h&&s(h))},S=e.snapshot?c.length===0?"No agents are running.":x.length===0?`No session matches “${r.trim()}”.`:null:"Agent Lookout has not read any sessions yet.",C=x.length===0?S??"":`${x.length} ${x.length===1?"session":"sessions"}`;return n.jsxs(n.Fragment,{children:[n.jsx(vo,{className:"sr-only",children:"Find a session"}),n.jsxs("div",{className:"relative",children:[n.jsx(Qo,{"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":y,"data-part":"field",placeholder:"Name, folder, branch or agent",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,enterKeyHint:"go",value:r,onChange:T=>{a(T.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:T=>T.preventDefault(),className:"thin-scroll mt-2 max-h-[min(26rem,55vh)] overflow-y-auto border-t border-hairline pt-2",children:x.map((T,w)=>n.jsx(_h,{session:T,agent:m(T),asOf:f,id:v(T),active:w===b,onPoint:()=>{T.id!==h?.id&&l(T.id)},onPick:()=>s(T)},T.id))}),S&&n.jsx("p",{"data-part":"empty",className:"px-3.5 pt-4 pb-6 text-center text-body text-ink-secondary",children:S}),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:h&&n.jsxs(n.Fragment,{children:[n.jsx("kbd",{className:"font-mono",children:"Enter"})," ",j?`jumps to it in ${j.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:C})]})}function Ph({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(yo,{open:e,onOpenChange:t,children:n.jsxs(ko,{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(jo,{className:"fixed inset-0 z-50 overflow-y-auto px-4 pt-[12vh] pb-24 data-[state=closed]:animate-fade-out",children:n.jsx(No,{"data-slot":"search-dialog","aria-describedby":void 0,className:k("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(Rh,{state:s,now:o,onChoose:c=>d({session:c}),onShortcuts:()=>d("shortcuts")})})})]})})}const Wh={sm:"w-[min(440px,100%)]",default:"w-[min(600px,100%)]",wide:"w-[min(760px,100%)]"};function Fh({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(yo,{open:e,onOpenChange:t,children:n.jsxs(ko,{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(jo,{className:"fixed inset-0 z-50 overflow-y-auto px-4 pt-[6vh] pb-24 data-[state=closed]:animate-fade-out",children:n.jsxs(No,{"data-slot":"details-modal",className:k("glass-float glass-blur mx-auto px-6 pt-5 pb-6","data-[state=closed]:animate-drop data-[state=open]:animate-rise-fast",Wh[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 m=l?.(c.current)??c.current;m?.isConnected&&m.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(vo,{ref:u,tabIndex:i?-1:void 0,className:"text-title font-semibold wrap-anywhere outline-none",children:s}),o&&n.jsx(ri,{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(ai,{asChild:!0,children:n.jsx(z,{size:"icon","aria-label":"Close",children:n.jsx(kl,{"aria-hidden":!0,className:"size-4",strokeWidth:1.75})})})]})]}),d]})})]})})}const Dh={"⌘":wl,"↑":xl,"↓":ml,"←":hl,"→":pl};function zh({shown:e}){return e.split(/([⌘↑↓←→])/).filter(Boolean).map((t,s)=>{const o=Dh[t];return o?n.jsx(o,{"aria-hidden":!0,"data-sign":t,strokeWidth:1.75,className:"inline-block size-3.5"},s):t})}function Uh({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(zh,{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 Hh({open:e,onOpenChange:t}){const s=Eh(ds());return n.jsx(Fh,{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(Me,{className:"mt-0.5",children:o.rows.map(r=>n.jsx(X,{label:r.does,children:n.jsx(Uh,{keys:r.keys})},r.does))})]},o.title))})})}function Bh({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:k("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 Gh="/api/app/update",Kh="/api/app/update/check",Vh="/api/app/update/install",qh="/api/app/update/setting",us={check:"check-for-updates",install:"install-update",setting:"update-setting"},Yh={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."},$a="#settings/updates",Wn=[{id:"overview",label:"Overview",href:"#overview"},{id:"sources",label:"Sources",href:"#sources"},{id:"settings",label:"Settings",href:"#settings"}];function Jh(e){switch(e){case"#sources":return"sources";case"#settings":case $a:return"settings";default:return"overview"}}function Xh(e){return Wn.find(t=>t.id===e)?.label??"Overview"}const Qh={overview:fh,sources:mh,settings:hh};function Zh(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 ep({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:Wn[0]?.href,"data-slot":"rail-mark","data-lit":s,"aria-label":Zh(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(Bh,{lit:s})}),n.jsx("ul",{className:"flex w-full flex-col items-center gap-1 py-3",children:Wn.map(o=>{const r=Qh[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:k("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)})})]})})}const tp=1e4,np=["memory-only","not-writing","failed"],sp=300;async function op(e=tp){try{const t=await oe("/api/history/clear",{method:"POST",headers:{"Content-Type":"application/json",[Qe]:ql},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<=sp?o.error:null;return{ok:!1,reason:np.find(a=>a===o.reason)??"failed",error:r}}catch{return{ok:!1,reason:"no-answer",error:null}}}const rp=1024,co=1024*1024;function uo(e){return e<=0?"0 KB":e<co?`${Math.max(1,Math.round(e/rp))} KB`:`${(e/co).toFixed(1).replace(/\.0$/,"")} MB`}function ap(e){const t=Math.round(e/864e5);return`${t} ${t===1?"day":"days"}`}function ip(e,t,s){const o=ap(e.maxAgeMs),r=uo(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?"–":`${uo(e.bytes)} of ${r}`,since:ce(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 lp(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 cp="Clear the Events log and the charts? This cannot be undone.";function dp({history:e=null,now:t,onCleared:s,clear:o=op}){const[r,a]=p.useState({kind:"idle"}),i=p.useRef(null),l=p.useRef(null),d=p.useRef(null);p.useEffect(()=>{const h=d.current;d.current=null,h==="cancel"?l.current?.focus():h==="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=ip(c,ge(e),t),f=c.canClear,m=r.kind==="confirming"&&f,x=()=>{d.current="cancel",a({kind:"confirming",busy:!1})},g=()=>{d.current="clear",a({kind:"idle"})},b=()=>{r.kind!=="confirming"||r.busy||(a({kind:"confirming",busy:!0}),o().then(h=>{d.current="clear",h.ok?(a({kind:"cleared",at:h.at}),s?.()):a({kind:"failed",words:lp(h)})}))};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:m?cp:u.state}),f&&(m?n.jsxs(n.Fragment,{children:[n.jsx(z,{size:"sm",onClick:b,"aria-disabled":r.busy||void 0,children:"Clear history"}),n.jsx(z,{ref:l,size:"sm",onClick:g,children:"Cancel"})]}):n.jsx(z,{ref:i,size:"sm",onClick:x,children:"Clear history"}))]}),u.facts&&n.jsxs(Me,{className:"mt-3",children:[n.jsx(X,{label:"Folder",mono:!0,children:n.jsx("span",{"data-part":"folder",className:"wrap-anywhere select-text",children:u.facts.folder.split("/").map((h,v,y)=>n.jsxs(p.Fragment,{children:[h,v<y.length-1&&n.jsxs(n.Fragment,{children:["/",n.jsx("wbr",{})]})]},v))})}),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(q,{title:u.note.title,className:"mt-3",children:n.jsx("p",{children:n.jsx(le,{children:u.note.detail})})}),r.kind==="failed"&&n.jsx(q,{title:"The history could not be cleared",className:"mt-3",children:n.jsx("p",{children:n.jsx(le,{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:ce(r.at,t)}),"."]}),u.explanation.map((h,v)=>n.jsx("p",{className:v===0?"mt-3 text-body text-ink-secondary":"mt-2 text-body text-ink-secondary",children:n.jsx(le,{children:h})},h))]})})}const up="/api/app/menu-bar",fp="/api/app/menu-bar/setting",mp="menu-bar-setting",_a=4e3;function Ra(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 hp(){try{const e=await oe(up,{signal:AbortSignal.timeout(_a)});return e.ok?Ra(await e.json()):null}catch{return null}}async function pp(e){try{const t=await oe(fp,{method:"POST",headers:{"Content-Type":"application/json",[Qe]:mp},body:JSON.stringify({show:e}),signal:AbortSignal.timeout(_a)});return t.ok?Ra(await t.json()):null}catch{return null}}function xp(){const[e,t]=p.useState(null),s=p.useRef(!0);p.useEffect(()=>(s.current=!0,hp().then(r=>{s.current&&t(r??"unknown")}),()=>{s.current=!1}),[]);const o=p.useCallback(r=>{pp(r).then(a=>{s.current&&a!==null&&t(a)})},[]);return{reading:e,setShown:o}}const gp=[{value:"off",label:"Off"},{value:"on",label:"On"}],fo="Show in menu bar";function bp(){const{reading:e,setShown:t}=xp();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:fo}),n.jsx(We,{label:fo,value:e.show?"on":"off",onValueChange:s=>t(s==="on"),options:gp})]})]}),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."})]})})}const fs=4e3,wp=3e4,yp=["translocated","disk-image","read-only","development"];function ms(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Be=e=>typeof e=="string"&&e!=="",it=e=>typeof e=="string"&&e.startsWith("https://"),Fn=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function kp(e){if(!ms(e))return null;switch(e.phase){case"idle":case"checking":case"up-to-date":case"no-release":return{phase:e.phase};case"downloading":return Be(e.version)&&it(e.notesUrl)&&Fn(e.received)&&Fn(e.total)?{phase:"downloading",version:e.version,notesUrl:e.notesUrl,received:e.received,total:e.total}:null;case"ready":case"installing":return Be(e.version)&&it(e.notesUrl)?{phase:e.phase,version:e.version,notesUrl:e.notesUrl}:null;case"cannot-install":{const t=yp.find(s=>s===e.refusal);return Be(e.version)&&it(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||!Be(e.reason)?null:{phase:"failed",step:t,reason:e.reason,version:Be(e.version)?e.version:null,notesUrl:it(e.notesUrl)?e.notesUrl:null}}default:return null}}function Dn(e){if(!ms(e))return null;const t=kp(e.update);if(t===null||!Be(e.version)||typeof e.automatic!="boolean"||!it(e.releasesUrl))return null;const s=e.lastCheckedAt;return{version:e.version,automatic:e.automatic,lastCheckedAt:Fn(s)&&s>0?s:null,releasesUrl:e.releasesUrl,update:t}}async function jp(e){const t=await e.json();return e.ok?Dn(t):ms(t)?Dn(t.status):null}async function mo(){try{const e=await oe(Gh,{signal:AbortSignal.timeout(fs)});return e.ok?Dn(await e.json()):null}catch{return null}}async function hs(e,t,s,o){try{const r=await oe(e,{method:"POST",headers:{"Content-Type":"application/json",[Qe]:t},body:JSON.stringify(s),signal:AbortSignal.timeout(o)});return await jp(r)}catch{return null}}function Np(){return hs(Kh,us.check,{},wp)}function vp(){return hs(Vh,us.install,{},fs)}function Sp(e){return hs(qh,us.setting,{automatic:e},fs)}const Ap=1e3,Ep=5e3;function Tp(e){const{phase:t}=e.update;return t==="downloading"||t==="ready"||t==="installing"}function Mp(e){if(e===null||e==="unknown")return!1;const{phase:t}=e.update;return t==="checking"||t==="downloading"||t==="installing"}function Cp(){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,mo().then(a),()=>{r.current=!1}),[a]);const i=Mp(e);p.useEffect(()=>{if(e===null)return;const u=setTimeout(()=>{mo().then(a)},i?Ap:Ep);return()=>clearTimeout(u)},[e,i,a]);const l=p.useCallback(()=>{o("check"),t(u=>u===null||u==="unknown"||Tp(u)?u:{...u,update:{phase:"checking"}}),Np().then(u=>{r.current&&(o(null),u!==null&&t(u))})},[]),d=p.useCallback(()=>{o("install"),vp().then(u=>{r.current&&(o(null),u!==null&&t(u))})},[]),c=p.useCallback(u=>{Sp(u).then(f=>{r.current&&f!==null&&t(f)})},[]);return{reading:e,pressed:s,check:l,install:d,setAutomatic:c}}const Ip=1e3;let ps=Date.now(),st=null;const zt=new Set;function Pa(){ps=Date.now();for(const e of zt)e()}function ho(){document.hidden||Pa()}function Lp(e){return zt.add(e),st===null&&(ps=Date.now(),st=setInterval(Pa,Ip),document.addEventListener("visibilitychange",ho)),()=>{zt.delete(e),zt.size===0&&st!==null&&(clearInterval(st),st=null,document.removeEventListener("visibilitychange",ho))}}function Op(){return ps}function sn(){return p.useSyncExternalStore(Lp,Op)}const $p=1024*1024;function po(e){return`${Math.round(e/$p)} MB`}function _p(e,t){return e.lastCheckedAt===null?"Not yet":ce(e.lastCheckedAt,t)}function Rp(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: ${po(t.received)} of ${po(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:Yh[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:`${Ne(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:`${Ne(t.reason)}. Check again to try once more.`,link:t.notesUrl??e.releasesUrl}}}}const Pp=[{value:"off",label:"Off"},{value:"on",label:"On"}],xo="Check for updates automatically",go="rounded-bar underline decoration-rule-strong underline-offset-2 transition-colors duration-120 hover:text-ink";function Wp(){const{reading:e,pressed:t,check:s,install:o,setAutomatic:r}=Cp(),a=sn(),i=p.useRef(null);p.useEffect(()=>{const c=()=>{window.location.hash===$a&&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:Rp(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(z,{size:"sm",onClick:o,disabled:t!==null,children:"Install and Restart"}):n.jsx(z,{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:go,children:"Release notes"})]}),d?.note&&n.jsx(q,{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:go,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:xo}),n.jsx(We,{label:xo,value:l.automatic?"on":"off",onValueChange:c=>r(c==="on"),options:Pp})]}),n.jsxs(Me,{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:_p(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 Fp(){dc()}function Dp(){return{...p.useSyncExternalStore(cr,bt),turnOn:Fp,turnOff:uc,chooseEvent:fc}}const zp=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,zp);return()=>{o=!1,clearInterval(a)}},[e]),t}const xs=4e3;function Wa(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 Up(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function Hp(e,t){switch(e){case"needs-you":return t===0?"starts waiting":`has waited ${Wa(t)}`;case"finished":return"finishes";case"failed":return"fails";case"ended":return"ends"}}function Fa(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 ${Wa(o)}.`:`${e} go to ${t} when a session ${Up(s.map(r=>Hp(r,o)))}.`}async function Bp(){try{const e=await oe("/api/email",{signal:AbortSignal.timeout(xs)});return e.ok?ld(await e.json()):null}catch{return null}}function Gp(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:Fa("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."},...Kp(e,t)}}function Kp(e,t){const{last:s,limitedUntil:o}=e;if(o!==null){const r=ce(o,t);return s!==null&&!s.sent?{title:"The last email could not be sent",detail:`${Ne(s.reason)}. No more will be tried until ${r}, as ${Bt} were tried in the last hour.`}:{title:"Emails are held back",detail:`${Bt} 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 ${ce(s.at,t)}.`}:{title:"The last email could not be sent",detail:`${Ne(s.reason)}.`}}async function Vp(){try{const e=await oe("/api/webhook",{signal:AbortSignal.timeout(xs)});return e.ok?ud(await e.json()):null}catch{return null}}function qp(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:Fa("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."},...Yp(e,t)}}function Yp(e,t){const{last:s,limitedUntil:o}=e;if(o!==null){const r=ce(o,t);return s!==null&&!s.sent?{title:"The last post failed",detail:`${Ne(s.reason)}. No more will be tried until ${r}, as ${Bt} were tried in the last hour.`}:{title:"Posts are held back",detail:`${Bt} 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 ${ce(s.at,t)}.`}:{title:"The last post failed",detail:`${Ne(s.reason)}.`}}async function Jp(){try{const e=await oe("/api/pull-requests",{signal:AbortSignal.timeout(xs)});return e.ok?dd(await e.json()):null}catch{return null}}const Xp="Your own gh sends GitHub the name of each repository and branch it is asked about, with its own login.";function Qp(e){return e.on&&e.gh!==null&&e.gh!=="not-found"&&e.gh!=="signed-out"}function Zp(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:Xp},{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 ${ce(o.at,t)}.`}:{...s,title:"The last check did not work",detail:`${o.reason.startsWith("gh")?o.reason:Ne(o.reason)}. It is tried again within 2 minutes.`}}const ex=[{value:"dark",label:"Night",name:"Dark theme"},{value:"light",label:"Day",name:"Light theme"},{value:"system",label:"System",name:"Follow the computer's setting"}],tx=[{value:"off",label:"Off"},{value:"on",label:"On"}];function nx({events:e,chooseEvent:t}){return n.jsx("ul",{"data-part":"events","aria-label":"What sends a notification",className:"mt-3 flex flex-col",children:Xe.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:On[s]}),n.jsx(We,{label:On[s],value:e.includes(s)?"on":"off",onValueChange:o=>t(s,o==="on"),options:tx})]},s))})}function sx(){const{on:e,permission:t,events:s,turnOn:o,turnOff:r,chooseEvent:a}=Dp();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(z,{size:"sm",onClick:e?r:o,children:e?"Turn off notifications":"Turn on notifications"})]}),e&&n.jsx(nx,{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(q,{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(q,{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 wn(e,t,s){return e===null?null:e.status==="unknown"?{state:t,asking:null,title:null,detail:null}:s(e.status,e.readAt)}function yn({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(le,{children:t.asking})}),t?.detail&&(t.title?n.jsx(q,{title:t.title,className:"mt-3",children:n.jsx("p",{children:n.jsx(le,{children:t.detail})})}):n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:n.jsx(le,{children:t.detail})}))]})})}function ox(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 rx({history:e=null,now:t,onHistoryCleared:s,inApp:o=as()}={}){const{preference:r,setPreference:a}=Ia(),i=sn(),l=bn(Bp),d=bn(Vp),c=bn(Jp),u=typeof l?.status=="object"&&l.status.on,f=typeof d?.status=="object"&&d.status.on,m=typeof c?.status=="object"&&Qp(c.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(We,{label:"Theme",value:r,onValueChange:a,options:ex}),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(sx,{}),n.jsx(dp,{history:e,now:t??i,onCleared:s}),o&&n.jsx(bp,{}),o&&n.jsx(Wp,{})]}),n.jsxs("div",{className:"col-span-4 flex min-w-0 flex-col gap-4 max-wide:w-full",children:[n.jsx(yn,{title:"Email",words:wn(l,"Whether email is set up could not be read.",Gp)}),n.jsx(yn,{title:"Webhook",words:wn(d,"Whether the webhook is set up could not be read.",qp)}),n.jsx(yn,{title:"Pull requests",words:wn(c,"Whether pull requests are shown could not be read.",Zp)}),n.jsx(U,{title:"This copy",children:n.jsxs(Me,{className:"px-6 pb-3",children:[n.jsxs(X,{label:"Version",mono:!0,children:["v","0.2.4"]}),n.jsx(X,{label:"Your data",children:n.jsx(le,{children:ox(u,f,m)})})]})})]})]})}function ax(e){return e.capabilities!==void 0}function ix({cell:e}){return e.level==="yes"?n.jsx("span",{"data-part":"capability","data-level":"yes",className:"text-ink-secondary",children:En.yes}):n.jsx(se,{content:e.reason,children:n.jsxs("span",{"data-part":"capability","data-level":e.level,tabIndex:0,className:"rounded-bar font-medium text-ink",children:[En[e.level],n.jsxs("span",{className:"sr-only",children:[": ",e.reason]})]})})}function lx({sources: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"}),lt.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"}),lt.map(s=>n.jsx("th",{scope:"col",className:t,children:tr[s]},s))]})}),n.jsx("tbody",{children:e.map(s=>n.jsxs("tr",{"data-source":s.id,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}),lt.map(o=>n.jsx("td",{className:"py-2.5 pr-2 text-body",children:n.jsx(ix,{cell:s.capabilities[o]})},o))]},s.id))})]})}function cx({sources:e}){return n.jsx("div",{"data-part":"blocks",className:"mt-3 flex flex-col gap-4",children:e.map(t=>n.jsxs("div",{"data-source":t.id,children:[n.jsx("h3",{className:"text-row font-semibold text-ink",children:t.label}),n.jsx(Me,{className:"mt-1",children:lt.map(s=>{const o=t.capabilities[s];return n.jsx(X,{label:tr[s],note:o.level==="yes"?void 0:o.reason,children:n.jsx("span",{"data-part":"capability","data-level":o.level,className:o.level==="yes"?"font-normal text-ink-secondary":void 0,children:En[o.level]})},s)})})]},t.id))})}function dx({sources:e}){const t=nn(),s=e.filter(ax);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(cx,{sources:s}):n.jsx(lx,{sources:s})]})})}function ux(e){return e.includes("/")||e.startsWith("~")||/ --?\w/.test(e)}function fx(e){return/^\d+$/.test(e)}function mx({source:e,sessions:t,now:s,stalled:o}){const r=Od(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(le,{children:e.detail})}),n.jsxs(Me,{className:"mt-2",children:[e.watching?.map((i,l)=>n.jsx(X,{label:i.label,mono:ux(i.value),children:n.jsx("span",{"data-part":"watching",className:k("wrap-anywhere",fx(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:de(e.checkedAt)}):n.jsx(se,{content:Jn(e.checkedAt),mono:!0,align:"end",children:n.jsx("span",{className:"tabular-nums",children:Yn(s-e.checkedAt)})})})]})]})})}function bo({children:e}){return n.jsx(U,{title:"Sources",children:n.jsx("div",{className:"px-6 pb-6",children:e})})}function hx({state:e,now:t}){const{snapshot:s,phase:o}=e,r=o==="stalled";let a;return s?a=s.sources.length>0?s.sources.map(i=>n.jsx(mx,{source:i,sessions:s.sessions,now:t,stalled:r},i.id)):n.jsx(bo,{children:n.jsx(q,{title:"No sources are set up",children:n.jsx("p",{children:"Agent Lookout is running but is not watching any agent tool."})})}):o==="unreachable"?a=n.jsx(bo,{children:n.jsx(q,{tone:"error",title:Tr(e.problemKind),children:n.jsx(Mr,{kind:e.problemKind})})}):a=n.jsx(U,{title:"Sources",children:n.jsx(xe,{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(q,{tone:"error",title:"Agent Lookout has stopped updating",children:n.jsxs("p",{children:["What follows is from"," ",n.jsx("span",{className:"tabular-nums",children:de(e.lastOkAt)}),". Check that it is still running in your terminal."]})}),a,s&&n.jsx(dx,{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."})]})})]})}class Da 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(q,{tone:"error",title:"Agent Lookout could not draw this page",action:n.jsx(z,{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(Me,{className:"mt-3",children:n.jsx(X,{label:"What happened",mono:!0,children:t.message||t.name})})]}):this.props.children}}function px(e){return p.useSyncExternalStore(e.subscribe,e.getState)}function xx(e){return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}function gx(){return document.hidden}function za(){return p.useSyncExternalStore(xx,gx)}const kn="Agent Lookout";function bx(e){p.useEffect(()=>(document.title=e>0?`(${e}) ${kn}`:kn,()=>{document.title=kn}),[e])}const Ua="agent-lookout-last-looked";function wx(){try{const e=Number(localStorage.getItem(Ua));return Number.isSafeInteger(e)&&e>0?e:null}catch{return null}}function yx(e){try{localStorage.setItem(Ua,String(e))}catch{}}function kx(e,t,s){const o=za(),r=sn(),[a,i]=p.useState(!1),[l,d]=p.useState(()=>Qd(wx())),c=Zd(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:x,overview:g,leftAt:b,since:h}=u.current,v=h??(!x&&g?Date.now():b);v!==null&&yx(v)},m=()=>{document.hidden&&f()};return document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",f),()=>{document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",f)}},[]),{since:c.since,onLineInView:i}}function jx(e){const t=p.useEffectEvent(s=>{if(s.defaultPrevented||s.repeat||s.isComposing)return;const o=Nh(s.target),r=Sh(s,{mac:ds(),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 Ha(e){return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}function Nx(){return Jh(window.location.hash)}function vx(){return Kr(window.location.hash)}function Sx(){return p.useSyncExternalStore(Ha,Nx)}function Ax(){return p.useSyncExternalStore(Ha,vx)}const Ex="agent-lookout-notifications";function Tx(e){if(typeof e!="object"||e===null)return[];const{handedOver:t}=e;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function Mx(e){let t;try{t=new BroadcastChannel(Ex),t.addEventListener("message",s=>{const o=Tx(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 Cx(e){return`agent-lookout:${e.id}`}function jn(e){try{e.close()}catch{}}function Ix({host:e,isOn:t}){let s=Ls,o=null,r=null;const a=new Map,i=new Map;function l(c){const u=a.get(c);u&&(a.delete(c),jn(u.notification))}function d(c){const{session:u}=c;l(u.id);const f=i.get(u.id);f&&(i.delete(u.id),jn(f));let m;try{m=e.show({...cu(c),tag:Cx(u)})}catch{m=null}if(!m)return;const x=m;if(c.event!=="needs-you"){i.set(u.id,x),x.onClosed(()=>{i.get(u.id)===x&&i.delete(u.id)});return}a.set(u.id,{notification:x,source:u.source}),x.onClosed(()=>{a.get(u.id)?.notification===x&&a.delete(u.id)})}return{handle(c,u=null){if(!c)return;r=c,u!==null&&(o!==null&&o!==u&&(s=Ls),o=u);const f=Kl(s,c);s=f.memory;for(const m of f.stopped)l(m);for(const[m,{source:x}]of a){const g=s.waits.get(x);g&&!g.has(m)&&l(m)}for(const m of f.changes)t(m.event)&&d(m)},closeAll(){const c=[...a.keys()],u=[...a.values()];a.clear();for(const{notification:f}of u)jn(f);return c},showAgain(c){if(!r)return;const u=new Set(c);for(const f of r.sessions)!u.has(f.id)||f.status!=="needs-you"||s.waits.get(f.source)?.has(f.id)&&(u.delete(f.id),t("needs-you")&&d({event:"needs-you",session:f}))}}}const Nn=e=>Vn().includes(e),wo=()=>or(Vn());async function Lx(){try{await oe("/api/health",{keepalive:!0})}catch{}}function Ox(e){p.useEffect(()=>{const t=Ix({host:{show:c=>Bn().show(c)},isOn:Nn}),s=()=>{const{snapshot:c,history:u}=e.getState();t.handle(c,u?.startedAt??null)};s();const o=e.subscribe(s);let r=wo(),a=Nn("needs-you");const i=cr(()=>{const c=wo();c!==r&&Lx(),r=c;const u=Nn("needs-you");a&&!u&&t.closeAll(),a=u}),l=Mx(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 $x=p.lazy(()=>So(()=>import("./HistoryPanel-CIjshvhu.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.HistoryPanel}))),_x=p.lazy(()=>So(()=>import("./SessionPanel-eBOdTLD9.js"),__vite__mapDeps([4,1,2,3])).then(e=>({default:e.SessionPanel}))),Rx=["needsYou","working","idle"];function Px(){const e=za(),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 Wx({store:e}){const[t]=p.useState(()=>e??wd({beat:wc})),s=px(t);Ox(t);const o=sn(),r=Sx(),a=Ax(),[i,l]=p.useState(null),[d,c]=p.useState(!1),[u,f]=p.useState(!1),m=p.useRef(null),x=p.useRef(r),g=kx(s.events,r==="overview",s.snapshot!==null),b=Nu(s.snapshot?.sessions);bx(b);const h=s.snapshot?b:null;p.useEffect(()=>{x.current!==r&&(x.current=r,m.current?.focus({preventScroll:!0}),window.scrollTo({top:0}))},[r]);const v=dh(m,r);jx(j=>{if(i!==null||u||a!==null)return!1;if(j==="search")c(N=>!N);else{if(d)return!1;f(!0)}return!0});const y=s.snapshot?"dashboard":s.phase==="unreachable"?"problem":"loading";return n.jsxs(Ka,{reducedMotion:"user",children:[n.jsx(Px,{}),n.jsxs("div",{"data-slot":"frame",className:"flex min-h-screen gap-window p-window",children:[n.jsx(ep,{current:r,needsYou:h}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4 pb-7",children:[n.jsx(Mh,{phase:s.phase,snapshot:s.snapshot,lastOkAt:s.lastOkAt,now:o,onSearch:()=>c(!0)}),n.jsx("main",{ref:m,tabIndex:-1,"aria-label":Xh(r),"data-view":r,className:"flex-1 outline-none",children:n.jsx(Da,{children:r==="sources"?n.jsx(hx,{state:s,now:o}):r==="settings"?n.jsx(rx,{history:s.history,now:o,onHistoryCleared:t.refresh}):n.jsx(Va,{mode:"wait",initial:!1,children:n.jsx(qa.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18,ease:"easeOut"},children:n.jsx(uh,{state:s,now:o,onRetry:t.refresh,onEnded:t.refresh,onOpenHistory:l,newSince:g.since,onNewLineInView:g.onLineInView})},y)})},r)})]})]}),n.jsxs(p.Suspense,{fallback:null,children:[Rx.map(j=>n.jsx($x,{metric:j,open:i===j,onOpenChange:N=>l(N?j:null),state:s,now:o},j)),n.jsx(_x,{sessionId:a,onClose:Zu,state:s,now:o,onStopped:t.refresh})]}),n.jsx(Ph,{open:d,onOpenChange:c,state:s,now:o,onChoose:v,onShortcuts:()=>f(!0)}),n.jsx(Hh,{open:u,onOpenChange:f})]})}Wu();const Ba=document.getElementById("root");if(!Ba)throw new Error("index.html has no #root element to render into.");Ga.createRoot(Ba).render(n.jsx(p.StrictMode,{children:n.jsx(Da,{children:n.jsx(Wx,{})})}));export{Me as A,Xn as B,q as C,Fh as D,jr as E,X as F,Jx as G,Ws as H,Fm as I,xt as J,Qt as K,xe as L,Jt as M,ra as N,Vx as O,Md as P,Ir as Q,Ef as R,We as S,te as T,Q as U,Qn as V,je as W,G as X,Iu as Y,z as Z,de as a,Gx as b,k as c,kc as d,Bx as e,J as f,Hx as g,ge as h,kt as i,Nu as j,Ne as k,Yx as l,Nc as m,Qx as n,Zt as o,qx as p,Xx as q,Kx as r,Ux as s,ur as t,en as u,gt as v,Wl as w,Vd as x,qd as y,Pr as z};