agent-lookout 0.2.1 → 0.2.4

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