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