glimmervoid 0.44.2 → 0.45.0

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 (70) hide show
  1. package/dist/bin/glimmervoid.js +8 -8
  2. package/dist/chunks/{adapters-B_ss_kZh.js → adapters-BGuI5U_-.js} +1 -1
  3. package/dist/chunks/{adapters-7AfJ6yb3.js → adapters-D99c4zCx.js} +2 -2
  4. package/dist/chunks/{agent-api-cli-zwuWZlwk.js → agent-api-cli-DIGH1v3_.js} +1 -1
  5. package/dist/chunks/{agent-api-cli-prUJ5ZGN.js → agent-api-cli-DdrR2vnB.js} +1 -1
  6. package/dist/chunks/{agent-api-core-DQwd2ClI.js → agent-api-core-D49OzKho.js} +2 -2
  7. package/dist/chunks/{config-DlKkg6IX.js → config-BLeRKmn9.js} +11 -1
  8. package/dist/chunks/{config-store-DIrwF5iQ.js → config-store-CXLnauAa.js} +2 -2
  9. package/dist/chunks/config-store-DlaaBY9p.js +1 -0
  10. package/dist/chunks/{contracts-lxJ0sQEl.js → contracts-CucdticH.js} +1 -1
  11. package/dist/chunks/{main-BCbulgNv.js → main-CX9CkTDx.js} +203 -31
  12. package/dist/chunks/{pair-cli-B3VRcrHm.js → pair-cli-BPyh48--.js} +2 -2
  13. package/dist/chunks/{remote-config-C91HwjWq.js → remote-config-B0zBDBak.js} +1 -1
  14. package/dist/chunks/{settings-cli-C9eCc60b.js → settings-cli-DzIasX94.js} +4 -4
  15. package/dist/chunks/{settings-readout-core-DK1m5TUq.js → settings-readout-core-BOv6tqdK.js} +1 -1
  16. package/dist/chunks/{ssh-sign-cli-DCnHgHqo.js → ssh-sign-cli-C_QYhDvI.js} +1 -1
  17. package/dist/client/assets/{action-status-DXcC95xv.js → action-status-DrMQzohk.js} +1 -1
  18. package/dist/client/assets/action-status-DrMQzohk.js.br +0 -0
  19. package/dist/client/assets/{benchmark-panel-Cssmnd3z.js → benchmark-panel-D09qvrAY.js} +1 -1
  20. package/dist/client/assets/benchmark-panel-D09qvrAY.js.br +0 -0
  21. package/dist/client/assets/{dom-helpers-CcEFPh-F.js → dom-helpers-CZ8NZKxw.js} +1 -1
  22. package/dist/client/assets/dom-helpers-CZ8NZKxw.js.br +0 -0
  23. package/dist/client/assets/{hooks-panel-Cli8EeBB.js → hooks-panel-R-L7DuIz.js} +1 -1
  24. package/dist/client/assets/hooks-panel-R-L7DuIz.js.br +0 -0
  25. package/dist/client/assets/{index-C8u3ZjM3.js → index-B7TvZo7W.js} +37 -37
  26. package/dist/client/assets/index-B7TvZo7W.js.br +0 -0
  27. package/dist/client/assets/{issues-panel-Bev1wadi.js → issues-panel-CyB4oq9Z.js} +1 -1
  28. package/dist/client/assets/issues-panel-CyB4oq9Z.js.br +0 -0
  29. package/dist/client/assets/{modal-CvDX5-_2.js → modal-M_mJ8--V.js} +1 -1
  30. package/dist/client/assets/modal-M_mJ8--V.js.br +0 -0
  31. package/dist/client/assets/{poll-ago-Dj148faJ.js → poll-ago-ItO-gOWA.js} +1 -1
  32. package/dist/client/assets/poll-ago-ItO-gOWA.js.br +0 -0
  33. package/dist/client/assets/{pr-queue-columns-Jleg5z3W.js → pr-queue-columns-Cu3-PADL.js} +1 -1
  34. package/dist/client/assets/pr-queue-columns-Cu3-PADL.js.br +0 -0
  35. package/dist/client/assets/{radar-panel-Dtp4ZzT3.js → radar-panel-Cl3yPWed.js} +1 -1
  36. package/dist/client/assets/radar-panel-Cl3yPWed.js.br +0 -0
  37. package/dist/client/assets/{review-queue-panel-BQvU_-xl.js → review-queue-panel-CVujzadC.js} +1 -1
  38. package/dist/client/assets/review-queue-panel-CVujzadC.js.br +0 -0
  39. package/dist/client/assets/{settings-panel-DegKCsoZ.js → settings-panel-DW5An8lQ.js} +1 -1
  40. package/dist/client/assets/settings-panel-DW5An8lQ.js.br +0 -0
  41. package/dist/client/assets/{trace-panel-DFqImX92.js → trace-panel-B6TiM5pb.js} +1 -1
  42. package/dist/client/assets/trace-panel-B6TiM5pb.js.br +0 -0
  43. package/dist/client/assets/ui-prefs-CQHZFVx6.js +1 -0
  44. package/dist/client/assets/ui-prefs-CQHZFVx6.js.br +0 -0
  45. package/dist/client/assets/{usage-panel-CEJqXYIA.js → usage-panel-D2RX3LtG.js} +1 -1
  46. package/dist/client/assets/usage-panel-D2RX3LtG.js.br +0 -0
  47. package/dist/client/assets/{visions-panel-Dm3iKlhv.js → visions-panel-BV9EKCBw.js} +1 -1
  48. package/dist/client/assets/visions-panel-BV9EKCBw.js.br +0 -0
  49. package/dist/client/index.html +6 -6
  50. package/dist/client/index.html.br +0 -0
  51. package/dist/server/index.js +1 -1
  52. package/package.json +1 -1
  53. package/dist/chunks/config-store-LYSRHNQs.js +0 -1
  54. package/dist/client/assets/action-status-DXcC95xv.js.br +0 -0
  55. package/dist/client/assets/benchmark-panel-Cssmnd3z.js.br +0 -0
  56. package/dist/client/assets/dom-helpers-CcEFPh-F.js.br +0 -0
  57. package/dist/client/assets/hooks-panel-Cli8EeBB.js.br +0 -0
  58. package/dist/client/assets/index-C8u3ZjM3.js.br +0 -0
  59. package/dist/client/assets/issues-panel-Bev1wadi.js.br +0 -0
  60. package/dist/client/assets/modal-CvDX5-_2.js.br +0 -0
  61. package/dist/client/assets/poll-ago-Dj148faJ.js.br +0 -0
  62. package/dist/client/assets/pr-queue-columns-Jleg5z3W.js.br +0 -0
  63. package/dist/client/assets/radar-panel-Dtp4ZzT3.js.br +0 -0
  64. package/dist/client/assets/review-queue-panel-BQvU_-xl.js.br +0 -0
  65. package/dist/client/assets/settings-panel-DegKCsoZ.js.br +0 -0
  66. package/dist/client/assets/trace-panel-DFqImX92.js.br +0 -0
  67. package/dist/client/assets/ui-prefs-CavQQH-s.js +0 -1
  68. package/dist/client/assets/ui-prefs-CavQQH-s.js.br +0 -0
  69. package/dist/client/assets/usage-panel-CEJqXYIA.js.br +0 -0
  70. package/dist/client/assets/visions-panel-Dm3iKlhv.js.br +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/review-queue-panel-BQvU_-xl.js","assets/dom-helpers-CcEFPh-F.js","assets/zod-BRLv4KqJ.js","assets/poll-ago-Dj148faJ.js","assets/action-status-DXcC95xv.js","assets/pr-queue-columns-Jleg5z3W.js","assets/ui-prefs-CavQQH-s.js","assets/modal-CvDX5-_2.js","assets/issues-panel-Bev1wadi.js","assets/usage-panel-CEJqXYIA.js","assets/radar-panel-Dtp4ZzT3.js","assets/visions-panel-Dm3iKlhv.js","assets/hooks-panel-Cli8EeBB.js","assets/trace-panel-DFqImX92.js","assets/benchmark-panel-Cssmnd3z.js","assets/settings-panel-DegKCsoZ.js"])))=>i.map(i=>d[i]);
2
- import{_ as e,a as t,f as n,g as r,l as i,m as a,n as o,o as s,r as c,s as l,u}from"./zod-BRLv4KqJ.js";import{$n as d,$t as f,A as p,An as m,At as h,B as g,Bn as _,Bt as v,C as y,Cn as b,Ct as x,D as S,Dn as C,Dt as w,E as T,En as E,Et as D,F as O,Fn as k,Ft as A,G as ee,Gn as te,Gt as ne,H as re,Hn as ie,Ht as j,In as ae,It as M,J as N,Jn as oe,Jt as se,K as ce,Kn as le,Kt as ue,Ln as de,Lt as fe,Mn as pe,Mt as me,Nn as he,Nt as ge,O as _e,On as ve,Ot as P,Pn as ye,Pt as be,Qn as xe,Qt as Se,R as Ce,Rn as we,Rt as Te,S as Ee,Sn as De,St as Oe,T as ke,Tn as Ae,U as je,Un as Me,Ut as Ne,Vn as Pe,Vt as Fe,W as Ie,Wn as Le,Wt as Re,Xn as ze,Xt as Be,Y as Ve,Yn as He,Yt as Ue,Zn as We,Zt as Ge,_ as Ke,_n as qe,_t as Je,an as Ye,ar as Xe,b as Ze,bn as Qe,c as $e,cn as et,cr as tt,d as nt,dn as rt,en as it,er as at,fn as ot,g as st,gn as ct,h as lt,hn as ut,in as dt,ir as ft,jn as pt,jt as F,k as mt,kn as ht,kt as gt,l as _t,ln as vt,m as I,mn as yt,n as bt,nn as xt,nr as St,o as L,or as Ct,ot as wt,p as R,pn as Tt,qn as Et,rn as z,rr as Dt,s as Ot,sn as kt,sr as At,t as jt,tn as Mt,tr as Nt,ut as Pt,v as Ft,vn as It,vt as Lt,w as Rt,wn as zt,wt as Bt,x as Vt,xn as Ht,xt as Ut,y as Wt,yn as Gt,yt as Kt,zn as qt,zt as Jt}from"./dom-helpers-CcEFPh-F.js";import{a as Yt,c as Xt,d as B,f as V,i as Zt,l as Qt,m as H,n as $t,o as en,p as tn,s as nn,u as rn}from"./poll-ago-Dj148faJ.js";import{C as an,Ct as on,Dt as sn,E as cn,Et as ln,J as un,K as dn,O as fn,Q as pn,R as mn,St as hn,T as gn,U as _n,Y as vn,Z as yn,_ as bn,_t as xn,a as Sn,at as Cn,b as wn,bt as Tn,c as En,ct as Dn,d as On,dt as kn,et as An,f as jn,ft as Mn,gt as Nn,h as Pn,ht as Fn,i as In,it as Ln,k as Rn,lt as zn,m as Bn,mt as Vn,n as Hn,o as Un,ot as Wn,p as Gn,pt as Kn,q as qn,rt as Jn,s as Yn,t as Xn,u as Zn,v as Qn,vt as $n,w as er,wt as tr,x as nr,xt as rr,y as ir,yt as ar,z as or}from"./ui-prefs-CavQQH-s.js";import{_ as sr,c as cr,d as lr,f as ur,g as dr,h as fr,i as pr,l as mr,m as hr,n as gr,o as _r,p as vr,r as yr,s as br,t as U,u as xr,v as Sr,y as Cr}from"./action-status-DXcC95xv.js";import{i as wr,n as Tr,r as Er,t as Dr}from"./modal-CvDX5-_2.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Or=new Map,kr=new Set;function Ar(e){let t=rt.safeParse(e);if(!t.success)ke(`reviews`,`dropped github-prs: ${v(t.error.issues)}`);else{Or=new Map(Object.entries(t.data.prs));for(let e of kr)e()}}function jr(e){return Or.get(e.toLowerCase())}function Mr(e){kr.add(e)}function Nr(e){return e===`remote`?`remote`:`local`}function Pr(e,t){return Nr(t)===`local`||e!==`shutdown`}var Fr=Object.freeze({setTimeoutFn:(e,t)=>setTimeout(e,t),clearTimeoutFn:e=>clearTimeout(e),setIntervalFn:(e,t)=>setInterval(e,t),clearIntervalFn:e=>clearInterval(e)});function Ir(e){return typeof e!=`object`||!e||!(`unref`in e)||typeof e.unref!=`function`||e.unref(),e}function Lr({mode:e,delayMs:t,run:n,setTimeoutFn:r=Fr.setTimeoutFn,clearTimeoutFn:i=Fr.clearTimeoutFn,unref:a=!0}){let o=null;function s(){o&&=(i(o),null)}function c(){e===`leading`&&o||(s(),o=r(()=>{o=null,n()},t),a&&Ir(o))}return{schedule:c,cancel:s,get isArmed(){return o!==null}}}function Rr(e){return`Git tracks an old Glimmervoid post-turn report in ${e===1?`1 repository`:`${e} repositories`}. Nothing reads it, so run this to stop git tracking it and commit the deletion git then shows. Glimmervoid deletes the file itself on its next start:`}var zr=Object.freeze({layout:`desktop`,activeView:`focus`,phoneScreen:null,focusedSessionId:null,selectedSessionId:null,borrowedCardId:null}),Br=e=>e||null,Vr=Object.freeze({setLayout:e=>({layout:e}),setActiveView:e=>({activeView:e}),setPhoneScreen:e=>({phoneScreen:Br(e)}),focusSession:e=>({focusedSessionId:Br(e)}),selectSession:e=>({selectedSessionId:Br(e)}),borrowCard:e=>({borrowedCardId:Br(e)})});function Hr(e){let t=Object.freeze({...zr,...e}),n=new Set;function r(){return t}function i(e){return typeof e==`function`?(n.add(e),()=>n.delete(e)):()=>{}}function a(e){let n=[];for(let r of Object.keys(e)){if(!(r in zr))throw Error(`ui-state: unknown key "${r}"`);Object.is(t[r],e[r])||n.push(r)}return n}function o(e,r){let i=Vr[e];if(!i)throw Error(`ui-state: unknown action "${e}"`);let o=i(r),s=a(o);if(s.length===0)return t;let c=t;t=Object.freeze({...t,...o});for(let e of n)try{e(t,s,c)}catch{}return t}return{snapshot:r,subscribe:i,dispatch:o}}var W=Hr(),Ur=()=>W.snapshot().activeView;function Wr(){return W.snapshot().borrowedCardId}function Gr(e,t,n,{className:r}={}){if(!e?.card||!n)return;let i=Wr();i&&i!==t&&Kr();let a=e.card;a._cardHostClass&&a._cardHostClass!==r&&a.classList.remove(a._cardHostClass),a._cardHostClass=r||``,r&&a.classList.add(r),jt(a,n),W.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function Kr(){let e=Wr();if(W.dispatch(`borrowCard`,null),!e)return null;let t=H.get(e);t?._showTerminalFace?.(),t?._setBorrowed?.(!1),t?._setActiveViewer?.(!1);let n=t?.card;return n&&(n._cardHostClass&&n.classList.remove(n._cardHostClass),delete n._cardHostClass,lt(n,rn)),e}var qr=68,Jr=42,Yr=768,Xr=.68,Zr=64,Qr=5,$r=8,ei=85;function ti(e,t,n){return Math.min(Math.max(e,t),n)}function ni({viewportWidthPx:e,viewportHeightPx:t,verticalProgress:n,isRightToLeft:r=!1,arcProgress:i=0}){let a=ti(e/Yr,Xr,1),o=(Qr+70*n*n)*t/100,s=Math.max(o,Zr),c=ei*t/100,l=ti(i*$r*t/100,Zr-s,c-s),u=-.45*e,d=1.45*e;return{scale:a,spriteWidthPx:qr,spriteHeightPx:Jr,topPx:s,startXpx:r?d:u,endXpx:r?u:d,facing:r?-1:1,arcPx:l}}function ri(e,t){let n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.round(e*n))/n}function ii(e,t,n){let r=ri(e.scale*t,n);return[[`--nyan-top`,`${e.topPx}px`],[`--nyan-scale`,String(r)],[`--nyan-width`,`${e.spriteWidthPx}px`],[`--nyan-height`,`${e.spriteHeightPx}px`],[`--nyan-start-x`,`${e.startXpx}px`],[`--nyan-end-x`,`${e.endXpx}px`],[`--nyan-facing`,String(e.facing)],[`--nyan-arc`,`${e.arcPx}px`],[`--nyan-travel`,`${Math.abs(e.endXpx-e.startXpx)/r}px`]]}var ai=ni({viewportWidthPx:1440,viewportHeightPx:900,verticalProgress:0});function oi(e,t=``){let n=L(`div`,`flying-animal-preview ${t}`.trim());n.setAttribute(`aria-hidden`,`true`),n.style.setProperty(`--nyan-width`,`${ai.spriteWidthPx}px`),n.style.setProperty(`--nyan-height`,`${ai.spriteHeightPx}px`);let r=L(`div`,`flying-animal-preview-stage`);return r.append(L(`div`,`nyan-trail ${e.trail}`),L(`div`,`nyan-sprite ${e.sprite}`)),n.append(r),n}function si(){let e=ln(In().flyingAnimalsExcludedSprites);return e===null?null:sn[e]??null}var ci=`<h2 class="dialog-title" id="add-session-title">Add Session</h2>
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/review-queue-panel-CVujzadC.js","assets/dom-helpers-CZ8NZKxw.js","assets/zod-BRLv4KqJ.js","assets/poll-ago-ItO-gOWA.js","assets/action-status-DrMQzohk.js","assets/pr-queue-columns-Cu3-PADL.js","assets/ui-prefs-CQHZFVx6.js","assets/modal-M_mJ8--V.js","assets/issues-panel-CyB4oq9Z.js","assets/usage-panel-D2RX3LtG.js","assets/radar-panel-Cl3yPWed.js","assets/visions-panel-BV9EKCBw.js","assets/hooks-panel-R-L7DuIz.js","assets/trace-panel-B6TiM5pb.js","assets/benchmark-panel-D09qvrAY.js","assets/settings-panel-DW5An8lQ.js"])))=>i.map(i=>d[i]);
2
+ import{_ as e,a as t,f as n,g as r,l as i,m as a,n as o,o as s,r as c,s as l,u}from"./zod-BRLv4KqJ.js";import{$n as d,$t as f,A as p,An as m,At as h,B as g,Bn as _,Bt as v,C as y,Cn as b,Ct as x,D as S,Dn as C,Dt as w,E as T,En as E,Et as D,F as O,Fn as k,Ft as A,G as ee,Gn as te,Gt as ne,H as re,Hn as ie,Ht as j,In as ae,It as M,J as N,Jn as oe,Jt as se,K as ce,Kn as le,Kt as ue,Ln as de,Lt as fe,Mn as pe,Mt as me,Nn as he,Nt as ge,O as _e,On as ve,Ot as P,Pn as ye,Pt as be,Qn as xe,Qt as Se,R as Ce,Rn as we,Rt as Te,S as Ee,Sn as De,St as Oe,T as ke,Tn as Ae,U as je,Un as Me,Ut as Ne,Vn as Pe,Vt as Fe,W as Ie,Wn as Le,Wt as Re,Xn as ze,Xt as Be,Y as Ve,Yn as He,Yt as Ue,Zn as We,Zt as Ge,_ as Ke,_n as qe,_t as Je,an as Ye,ar as Xe,b as Ze,bn as Qe,c as $e,cn as et,cr as tt,d as nt,dn as rt,en as it,er as at,fn as ot,g as st,gn as ct,h as lt,hn as ut,in as dt,ir as ft,jn as pt,jt as F,k as mt,kn as ht,kt as gt,l as _t,ln as vt,m as I,mn as yt,n as bt,nn as xt,nr as St,o as L,or as Ct,ot as wt,p as R,pn as Tt,qn as Et,rn as z,rr as Dt,s as Ot,sn as kt,sr as At,t as jt,tn as Mt,tr as Nt,ut as Pt,v as Ft,vn as It,vt as Lt,w as Rt,wn as zt,wt as Bt,x as Vt,xn as Ht,xt as Ut,y as Wt,yn as Gt,yt as Kt,zn as qt,zt as Jt}from"./dom-helpers-CZ8NZKxw.js";import{a as Yt,c as Xt,d as B,f as V,i as Zt,l as Qt,m as H,n as $t,o as en,p as tn,s as nn,u as rn}from"./poll-ago-ItO-gOWA.js";import{C as an,Ct as on,Dt as sn,E as cn,Et as ln,J as un,K as dn,O as fn,Q as pn,R as mn,St as hn,T as gn,U as _n,Y as vn,Z as yn,_ as bn,_t as xn,a as Sn,at as Cn,b as wn,bt as Tn,c as En,ct as Dn,d as On,dt as kn,et as An,f as jn,ft as Mn,gt as Nn,h as Pn,ht as Fn,i as In,it as Ln,k as Rn,lt as zn,m as Bn,mt as Vn,n as Hn,o as Un,ot as Wn,p as Gn,pt as Kn,q as qn,rt as Jn,s as Yn,t as Xn,u as Zn,v as Qn,vt as $n,w as er,wt as tr,x as nr,xt as rr,y as ir,yt as ar,z as or}from"./ui-prefs-CQHZFVx6.js";import{_ as sr,c as cr,d as lr,f as ur,g as dr,h as fr,i as pr,l as mr,m as hr,n as gr,o as _r,p as vr,r as yr,s as br,t as U,u as xr,v as Sr,y as Cr}from"./action-status-DrMQzohk.js";import{i as wr,n as Tr,r as Er,t as Dr}from"./modal-M_mJ8--V.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Or=new Map,kr=new Set;function Ar(e){let t=rt.safeParse(e);if(!t.success)ke(`reviews`,`dropped github-prs: ${v(t.error.issues)}`);else{Or=new Map(Object.entries(t.data.prs));for(let e of kr)e()}}function jr(e){return Or.get(e.toLowerCase())}function Mr(e){kr.add(e)}function Nr(e){return e===`remote`?`remote`:`local`}function Pr(e,t){return Nr(t)===`local`||e!==`shutdown`}var Fr=Object.freeze({setTimeoutFn:(e,t)=>setTimeout(e,t),clearTimeoutFn:e=>clearTimeout(e),setIntervalFn:(e,t)=>setInterval(e,t),clearIntervalFn:e=>clearInterval(e)});function Ir(e){return typeof e!=`object`||!e||!(`unref`in e)||typeof e.unref!=`function`||e.unref(),e}function Lr({mode:e,delayMs:t,run:n,setTimeoutFn:r=Fr.setTimeoutFn,clearTimeoutFn:i=Fr.clearTimeoutFn,unref:a=!0}){let o=null;function s(){o&&=(i(o),null)}function c(){e===`leading`&&o||(s(),o=r(()=>{o=null,n()},t),a&&Ir(o))}return{schedule:c,cancel:s,get isArmed(){return o!==null}}}function Rr(e){return`Git tracks an old Glimmervoid post-turn report in ${e===1?`1 repository`:`${e} repositories`}. Nothing reads it, so run this to stop git tracking it and commit the deletion git then shows. Glimmervoid deletes the file itself on its next start:`}var zr=Object.freeze({layout:`desktop`,activeView:`focus`,phoneScreen:null,focusedSessionId:null,selectedSessionId:null,borrowedCardId:null}),Br=e=>e||null,Vr=Object.freeze({setLayout:e=>({layout:e}),setActiveView:e=>({activeView:e}),setPhoneScreen:e=>({phoneScreen:Br(e)}),focusSession:e=>({focusedSessionId:Br(e)}),selectSession:e=>({selectedSessionId:Br(e)}),borrowCard:e=>({borrowedCardId:Br(e)})});function Hr(e){let t=Object.freeze({...zr,...e}),n=new Set;function r(){return t}function i(e){return typeof e==`function`?(n.add(e),()=>n.delete(e)):()=>{}}function a(e){let n=[];for(let r of Object.keys(e)){if(!(r in zr))throw Error(`ui-state: unknown key "${r}"`);Object.is(t[r],e[r])||n.push(r)}return n}function o(e,r){let i=Vr[e];if(!i)throw Error(`ui-state: unknown action "${e}"`);let o=i(r),s=a(o);if(s.length===0)return t;let c=t;t=Object.freeze({...t,...o});for(let e of n)try{e(t,s,c)}catch{}return t}return{snapshot:r,subscribe:i,dispatch:o}}var W=Hr(),Ur=()=>W.snapshot().activeView;function Wr(){return W.snapshot().borrowedCardId}function Gr(e,t,n,{className:r}={}){if(!e?.card||!n)return;let i=Wr();i&&i!==t&&Kr();let a=e.card;a._cardHostClass&&a._cardHostClass!==r&&a.classList.remove(a._cardHostClass),a._cardHostClass=r||``,r&&a.classList.add(r),jt(a,n),W.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function Kr(){let e=Wr();if(W.dispatch(`borrowCard`,null),!e)return null;let t=H.get(e);t?._showTerminalFace?.(),t?._setBorrowed?.(!1),t?._setActiveViewer?.(!1);let n=t?.card;return n&&(n._cardHostClass&&n.classList.remove(n._cardHostClass),delete n._cardHostClass,lt(n,rn)),e}var qr=68,Jr=42,Yr=768,Xr=.68,Zr=64,Qr=5,$r=8,ei=85;function ti(e,t,n){return Math.min(Math.max(e,t),n)}function ni({viewportWidthPx:e,viewportHeightPx:t,verticalProgress:n,isRightToLeft:r=!1,arcProgress:i=0}){let a=ti(e/Yr,Xr,1),o=(Qr+70*n*n)*t/100,s=Math.max(o,Zr),c=ei*t/100,l=ti(i*$r*t/100,Zr-s,c-s),u=-.45*e,d=1.45*e;return{scale:a,spriteWidthPx:qr,spriteHeightPx:Jr,topPx:s,startXpx:r?d:u,endXpx:r?u:d,facing:r?-1:1,arcPx:l}}function ri(e,t){let n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.round(e*n))/n}function ii(e,t,n){let r=ri(e.scale*t,n);return[[`--nyan-top`,`${e.topPx}px`],[`--nyan-scale`,String(r)],[`--nyan-width`,`${e.spriteWidthPx}px`],[`--nyan-height`,`${e.spriteHeightPx}px`],[`--nyan-start-x`,`${e.startXpx}px`],[`--nyan-end-x`,`${e.endXpx}px`],[`--nyan-facing`,String(e.facing)],[`--nyan-arc`,`${e.arcPx}px`],[`--nyan-travel`,`${Math.abs(e.endXpx-e.startXpx)/r}px`]]}var ai=ni({viewportWidthPx:1440,viewportHeightPx:900,verticalProgress:0});function oi(e,t=``){let n=L(`div`,`flying-animal-preview ${t}`.trim());n.setAttribute(`aria-hidden`,`true`),n.style.setProperty(`--nyan-width`,`${ai.spriteWidthPx}px`),n.style.setProperty(`--nyan-height`,`${ai.spriteHeightPx}px`);let r=L(`div`,`flying-animal-preview-stage`);return r.append(L(`div`,`nyan-trail ${e.trail}`),L(`div`,`nyan-sprite ${e.sprite}`)),n.append(r),n}function si(){let e=ln(In().flyingAnimalsExcludedSprites);return e===null?null:sn[e]??null}var ci=`<h2 class="dialog-title" id="add-session-title">Add Session</h2>
3
3
  <fieldset class="dialog-mode-controls" aria-label="Session kind">
4
4
  <button type="button" class="dialog-mode-button" id="add-session-single-mode" aria-pressed="true">Single repo</button>
5
5
  <button type="button" class="dialog-mode-button" id="add-session-workspace-mode" aria-pressed="false">Workspace</button>
@@ -82,20 +82,20 @@ import{_ as e,a as t,f as n,g as r,l as i,m as a,n as o,o as s,r as c,s as l,u}f
82
82
  `).split(`
83
83
  `),{slugCounts:new Map},0)}function Bo(e){let t=[],n={heading:null,id:null,level:0,blocks:[]},r=()=>{(n.heading!==null||n.blocks.length!==0)&&t.push(n)};for(let t of e)t.type===`heading`?(r(),n={heading:Ao(t.children),id:t.id,level:t.level,blocks:[t]}):n.blocks.push(t);return r(),t}function Vo(e,t){for(let n of t){if(n.type===`text`){e.append(document.createTextNode(n.text));continue}if(n.type===`code`){e.append(L(`code`,`plan-inline-code`,n.text));continue}if(n.type===`emphasis`){let t=L(`em`);Vo(t,n.children),e.append(t);continue}if(n.type===`strong`){let t=L(`strong`);Vo(t,n.children),e.append(t);continue}let t=L(`a`,`plan-link`);t.href=n.href,t.target=`_blank`,t.rel=`noopener noreferrer`,Vo(t,n.children),e.append(t)}}function Ho(e){let t=L(`li`);return Uo(t,e.children),t}function Uo(e,t){for(let n of t)if(n.type===`heading`){let t=L(`h${n.level}`,`plan-heading`);t.id=n.id,Vo(t,n.children),e.append(t)}else if(n.type===`paragraph`){let t=L(`p`,`plan-paragraph`);Vo(t,n.children),e.append(t)}else if(n.type===`list`){let t=n.ordered?L(`ol`,`plan-list`):L(`ul`,`plan-list`);t.append(...n.items.map(Ho)),e.append(t)}else if(n.type===`code`){let t=L(`pre`,`plan-code`),r=L(`code`,n.language?`language-${n.language}`:null,n.text);t.append(r),e.append(t)}else if(n.type===`table`){let t=L(`div`,`plan-table-wrap`),r=L(`table`,`plan-table`),i=L(`thead`),a=L(`tr`);for(let e of n.header){let t=L(`th`);Vo(t,e),a.append(t)}i.append(a);let o=L(`tbody`);for(let e of n.rows){let t=L(`tr`);for(let n of e){let e=L(`td`);Vo(e,n),t.append(e)}o.append(t)}r.append(i,o),t.append(r),e.append(t)}else if(n.type===`blockquote`){let t=L(`blockquote`,`plan-blockquote`);Uo(t,n.blocks),e.append(t)}else e.append(L(`hr`,`plan-rule`))}function Wo(e){let t=L(`div`,`plan-document`);return Uo(t,e),t}function Go(e,{hasComment:t,isComposing:n,onComment:r,attachmentFor:i}){let a=L(`div`,`plan-document`),o=[];for(let s of e){let e=L(`section`,`plan-section`);e.dataset.selected=`false`,e.addEventListener(`click`,()=>{for(let t of o)t.dataset.selected=String(t===e)}),o.push(e);let c=L(`div`,`plan-section-head`),l=s.blocks[0],u=l?.type===`heading`;if(u&&Uo(c,[l]),u||(e.id=`plan-introduction`),!t(s)&&!n(s)){let e=L(`button`,`plan-section-comment`,`Comment`);e.type=`button`,e.setAttribute(`aria-label`,`Comment on ${s.heading??`Introduction`}`),e.addEventListener(`click`,()=>r(s)),c.append(e)}let d=L(`div`,`plan-section-body`);Uo(d,u?s.blocks.slice(1):s.blocks),e.append(c,d);let f=i(s);f&&e.append(f),a.append(e)}return a}var Ko={added:`+`,removed:`-`,unchanged:` `,skipped:` `};function qo(e){let t=L(`div`,`plan-diff`);for(let n of e.lines){let e=L(`div`,`plan-diff-line plan-diff-${n.kind}`),r=L(`span`,`plan-diff-gutter`,Ko[n.kind]);r.setAttribute(`aria-hidden`,`true`),e.append(r,L(`span`,`plan-diff-text`,n.text)),t.append(e)}return t}var Jo=`glimmervoid-streamer-mode`,Yo=new Set,Xo=Kn(Jo,!1)===!0,Zo=null;function Qo(e){document.documentElement.toggleAttribute(`data-streamer`,e),Zo?.setAttribute(`aria-pressed`,String(e))}Qo(Xo);function $o(){return Xo}function es(e){if(Vn(Jo,e),e!==$o()){Xo=e,Qo(e);for(let t of Yo)t(e)}}function ts(e){return Yo.add(e),()=>Yo.delete(e)}async function ns(e){try{let t=await S(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:U});return t.type===`settings-error`?String(t.message):(es(e),``)}catch(e){return br(e,U)}}var rs=`Streamer mode`;async function is(){let e=!$o();e&&es(!0);let t=await ns(e);t?_r({source:rs,message:`${e?`Streamer mode is on in this browser only. The server did not save it`:`Streamer mode is still on. The server did not save the change`}: ${t} Toggle it again to retry.`,hidesInStreamerMode:!1}):gr(rs)}function as(){is()}function os(e){Zo=e,Qo($o()),e.addEventListener(`click`,as)}var ss=new Map,cs=null;function ls(e){return ss.get(e)??[]}function us(e){return ls(e).length>0}function ds(e){B(e)?.btnDocs.classList.toggle(`visible`,us(e))}function fs(e){let t=ls(e.sessionId);e.select.replaceChildren(...t.map(t=>{let n=L(`option`,null,t.name);return n.value=t.path,n.selected=t.path===e.docPath,n})),e.select.hidden=t.length<2,e.title.textContent=t.find(t=>t.path===e.docPath)?.name??e.title.textContent}function ps(e){let t=ls(e.sessionId).some(t=>t.path===e.docPath);e.btnEdit.setAttribute(`aria-pressed`,String(e.mode===`edit`)),e.btnPreview.setAttribute(`aria-pressed`,String(e.mode===`preview`)),e.textarea.hidden=e.mode!==`edit`,e.preview.hidden=e.mode!==`preview`,e.select.disabled=e.isBusy,e.btnReload.disabled=e.isBusy||!t,e.btnSave.disabled=e.isBusy||!t||e.baseHash===null||!e.hasUnsavedChanges}function ms(e,t,n=`quiet`){e.status.textContent=t,e.status.dataset.tone=n}function hs(e){e.preview.replaceChildren(Wo(zo(e.textarea.value)))}function gs(e,t){wr({title:e,message:`Your unsaved edits will be lost.`,confirmLabel:`Discard`,danger:!0,onConfirm:t})}function _s(e,t,n){e.hasUnsavedChanges?gs(t,n):n()}async function vs(e,t){try{return{reply:await S(e,t,{timeoutMs:U}),failureText:null}}catch(e){return{reply:null,failureText:br(e,U)}}}async function ys(e,t){e.docPath=t,e.isBusy=!0,e.baseHash=null,e.textarea.readOnly=!0,fs(e),ms(e,`Loading`),ps(e);let{reply:n,failureText:r}=await vs(`session-doc-read`,{id:e.sessionId,path:t});if(cs!==e||e.docPath!==t)return;e.isBusy=!1,e.textarea.readOnly=!1;let i=n?.type===`session-doc-response`?n:null;!i?.ok||i.text===void 0||i.hash===void 0?(ms(e,i?.error||r||`Could not open this doc`,`warn`),ps(e)):(e.textarea.value=i.text,e.baseHash=i.hash,e.hasUnsavedChanges=!1,e.mode===`preview`&&hs(e),ms(e,``),ps(e))}async function bs(e){if(e.btnSave.disabled||e.baseHash===null)return;e.isBusy=!0,ms(e,`Saving`),ps(e);let t=e.docPath,n=e.textarea.value,{reply:r,failureText:i}=await vs(`session-doc-save`,{id:e.sessionId,path:t,text:n,baseHash:e.baseHash});if(cs!==e||e.docPath!==t)return;e.isBusy=!1;let a=r?.type===`session-doc-save-result`?r:null;!a?.ok||a.hash===void 0?(ms(e,a?.conflict?`The agent changed this file since you opened it. Reload to see its version.`:a?.error||i||`Save failed`,`warn`),ps(e)):(e.baseHash=a.hash,e.hasUnsavedChanges=e.textarea.value!==n,ms(e,e.hasUnsavedChanges?`Unsaved changes`:`Saved`),ps(e))}function xs(e,t){e.mode=t,t===`preview`&&hs(e),ps(e),t===`edit`&&e.textarea.focus()}function Ss(e,t){let n=L(`button`,`plan-control ${t}`,e);return n.type=`button`,n}function Cs(e){let t=ls(e)[0];if(!t||cs)return;let n=()=>_s(y,`Close this doc?`,()=>y.close()),r=Er({dialogClass:`doc-editor`,closeOnBackdrop:!1,onEscape:n}),i=`doc-editor-title-${e}`,a=L(`h3`,`doc-editor-title`,t.name);a.id=i;let o=L(`select`,`plan-control doc-editor-picker`);o.setAttribute(`aria-label`,`Doc`);let s=L(`span`,`doc-editor-status`);s.setAttribute(`role`,`status`);let c=Ss(`Edit`,`doc-editor-mode`),l=Ss(`Preview`,`doc-editor-mode`),u=Ss(`Reload`,`doc-editor-reload`),d=Ss(`Save`,`doc-editor-save`),f=Ss(`Close`,`doc-editor-close`),p=L(`div`,`doc-editor-modes`);p.append(c,l);let m=L(`div`,`doc-editor-actions`);m.append(s,u,d,f);let h=L(`div`,`doc-editor-header`);h.append(a,o,p,m);let g=L(`textarea`,`plan-editor doc-editor-text`);g.spellcheck=!0,g.setAttribute(`aria-labelledby`,i);let _=L(`div`,`doc-editor-preview`),v=L(`div`,`doc-editor-body`);v.append(g,_),r.dialog.append(h,v),Dr(r.dialog,i);let y={sessionId:e,docPath:t.path,baseHash:null,hasUnsavedChanges:!1,isBusy:!1,mode:$o()?`preview`:`edit`,title:a,select:o,textarea:g,preview:_,status:s,btnEdit:c,btnPreview:l,btnReload:u,btnSave:d,close:()=>{cs=null,r.close()}};cs=y,g.addEventListener(`input`,()=>{y.hasUnsavedChanges||(y.hasUnsavedChanges=!0,ms(y,`Unsaved changes`),ps(y))}),g.addEventListener(`keydown`,e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),bs(y))}),o.addEventListener(`change`,()=>{let e=o.value;o.value=y.docPath,_s(y,`Open another doc?`,()=>{ys(y,e)})}),c.addEventListener(`click`,()=>xs(y,`edit`)),l.addEventListener(`click`,()=>xs(y,`preview`)),u.addEventListener(`click`,()=>{_s(y,`Reload this doc?`,()=>{ys(y,y.docPath)})}),d.addEventListener(`click`,()=>{bs(y)}),f.addEventListener(`click`,n),ys(y,t.path),y.mode===`edit`&&g.focus()}function ws(e){cs&&cs.sessionId===e&&(fs(cs),ps(cs),!ls(e).some(e=>e.path===cs?.docPath)&&ms(cs,`This doc is no longer surfaced, so it cannot be saved.`,`warn`))}function Ts(e){ss.set(e.id,e.docs),e.docs.length===0&&ss.delete(e.id),ds(e.id),ws(e.id)}function Es(e){let t=[...ss.keys()];ss.clear();for(let[t,n]of Object.entries(e.sessions))ss.set(t,n);for(let e of new Set([...t,...ss.keys()]))ds(e),ws(e)}function Ds({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=Er({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=L(`div`,`coherence-journal-header`),s=L(`h3`,`dialog-title`,t);s.id=n;let c=L(`button`,`btn-dialog btn-dialog-cancel`,`Close`);return c.type=`button`,o.append(s,c),a.dialog.append(o,...r),Dr(a.dialog,s.id),c.addEventListener(`click`,i),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function Os({requestPrefix:e,dialogClass:t,titleText:n,unavailableLabel:r,timeoutMs:i}){let a=null;function o(e){e.timer!==null&&clearTimeout(e.timer),e.timer=null,e.requestId=null}function s({sessionId:s,status:c,body:l,parts:u,paintBeforeRequest:d,buildRequest:f}){a?.close();let p=y(e),m=Ds({dialogClass:t,titleText:n,titleId:`${p}-title`,body:l,onCloseRequest:()=>h.close()}),h={sessionId:s,status:c,parts:u,requestId:p,timer:null,close:()=>{o(h),a===h&&(a=null),m.close()}};a=h,d?.(),m.focusClose(),T(f(p))?h.timer=setTimeout(()=>{h.requestId=null,h.timer=null,c.textContent=`${r}: request timed out`},i):(h.requestId=null,c.textContent=`${r}: not connected`)}function c(e){let t=a;return!t||t.sessionId!==e.id||t.requestId===null||t.requestId!==e.requestId?null:(o(t),t)}return{open:s,settleResponse:c,currentPanel:()=>a}}var ks=2,As={needsYou:1,broken:2,askedOfYou:3,waiting:4,settled:5},js={danger:As.broken,warn:As.askedOfYou,wait:As.waiting,ok:As.settled,muted:As.settled};function Ms(e){return e?js[e]:As.settled}function Ns(e){let t=[...e].sort((e,t)=>e.tier-t.tier),n=t.slice(ks);return{visible:t.slice(0,ks),overflowCount:n.length,overflowHoverText:n.map(e=>`${e.text} ${e.hoverText}`).join(`
84
84
  `)}}function Ps(e){return e.map(e=>[e.key,e.text,e.hoverText,e.look?.icon,e.look?.tone,e.tier].join(`|`)).join(`
85
- `)}var Fs={decision:`Decision`,retraction:`Retraction`,conjecture:`Conjecture`,resolution:`Resolution`,dismissal:`Dismissal`,defect:`Defect`,experiment:`Experiment`,close:`Close`,unable:`Unable`,escalation:`Escalation`,acknowledgement:`Acknowledgement`,enactment:`Enactment`};function Is(e){return e?.active!==!1||e.reason===Ue.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,hoverText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:As.broken}]}function Ls(e){let t=dt.safeParse(e.kind);return{heading:`${t.success?Fs[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function Rs(e,t){let n=[];return e?.active===!1&&n.push(`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`),t&&!t.journal.ok&&n.push(`Journal unavailable: ${t.journal.reason}`),{lines:n}}var zs=new Map,Bs=new Map,Vs=Os({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function Hs(e,t){Bs.delete(e),t&&Bs.set(e,t),Js(e)}function Us(e){zs.delete(e),Bs.delete(e);let t=Vs.currentPanel();t?.sessionId===e&&t.close()}function Ws(e){let t=zs.get(e.id);t&&t.updatedAt>e.updatedAt||(zs.set(e.id,e),Js(e.id))}function Gs(e){zs.clear();for(let[t,n]of Object.entries(e.sessions))zs.set(t,n);let t=Vs.currentPanel();t&&Js(t.sessionId)}function Ks(e){return Is(Bs.get(e)??null).map(t=>({...t,onActivate:()=>Ys(e)}))}function qs(e){return zs.get(e)?.journal.ok===!0}function Js(e){let t=Vs.currentPanel();if(!t||t.sessionId!==e)return;let n=Rs(Bs.get(e)??null,zs.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>L(`p`,null,e)))}function Ys(e){let t=L(`div`,`coherence-journal-reading`),n=L(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=L(`div`,`coherence-journal-entries`);Vs.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>Js(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function Xs(e){let t=Vs.settleResponse(e);t&&(e.ok?(t.status.textContent=e.entries.length===0?`No journal entries`:`${e.entries.length} journal entries (up to 200)`,t.parts.entries.replaceChildren(...e.entries.map(e=>{let t=Ls(e),n=L(`article`,`coherence-journal-entry`);return n.append(L(`h4`,null,t.heading),L(`p`,null,t.text)),t.detail&&n.append(L(`p`,null,t.detail)),t.supersedes&&n.append(L(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var Zs=/\bElectron\/\d/,Qs=new Set([`localhost`,`127.0.0.1`]);function $s(e){return Zs.test(e)}function ec({userAgent:e,pageHostname:t}){return $s(e)&&Qs.has(t)}function tc(e){return fo(e)!==null}var nc=new Set([0,1]);function rc({button:e,opensInNewTab:t}){return t&&nc.has(e)}function ic(){return ec({userAgent:navigator.userAgent,pageHostname:location.hostname})}function ac(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function oc(e){try{let t=await be();return(await fetch(`/open-external`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})})).ok}catch{return!1}}function sc(e){!ic()||!tc(e)?ac(e):oc(e).then(t=>{t||ac(e)})}function cc(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&rc({button:e.button,opensInNewTab:t.target===`_blank`})&&tc(t.href)&&(e.preventDefault(),sc(t.href))}function lc(e){ic()&&(e.addEventListener(`click`,cc,!0),e.addEventListener(`auxclick`,cc,!0))}var uc=new Map([[`plan`,`Plan ready`],[`permission`,`Needs permission`]]);function dc(e){return uc.get(e)??`Needs input`}function fc({hasPlan:e,pendingPromptKind:t,hasOpenReview:n,hasApprovedReview:r=!1}){return e&&(n||t===`plan`&&!r)?`plan`:`terminal`}function pc({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var mc=new Map(Object.entries({WAITING:`now`,COMPLETE:`later`,FAILED:`resting`,IDLE:`resting`,RUNNING:`resting`,STARTING:`resting`,INITIALIZING:`resting`,DORMANT:`resting`,DONE:`resting`}));function hc(e){return(typeof e.state==`string`?mc.get(e.state):void 0)??`resting`}function gc(e,t){return[...e].map(([e,n])=>{let r=n.currentState||z.DORMANT;return{id:e,ui:n,name:t(n),isDormant:r===z.DORMANT,state:r,unseenOutcome:n.unseenOutcome??null,ownerId:n.ownerId??null}})}function _c(e){let t=new Set(e.map(({id:e})=>e)),n=e=>e.ownerId&&t.has(e.ownerId)?e.ownerId:null,r=new Map;for(let t of e){let e=n(t);e&&r.set(e,[...r.get(e)??[],t])}return e.flatMap(e=>n(e)?[]:[e,...r.get(e.id)??[]])}function vc(e){return _c([...e].sort((e,t)=>Number(e.isDormant===!0)-Number(t.isDormant===!0)))}function yc({ownerName:e,ownedCount:t}){return e===null?t===1?`Owns 1 session`:t>1?`Owns ${t} sessions`:null:`Owned by ${e}`}function bc(e,t){return e.length?e[((t==null?-1:e.indexOf(t))+1)%e.length]:null}function xc(e,t){return t!==null&&e.includes(t)?t:e[0]??null}var Sc=new Map([[z.FAILED,`Failed`],[z.COMPLETE,`Finished`]]);function Cc(e,t){return Sc.get(e)??dc(t??``)}function wc(e,t,n){if(!e.length)return null;let r=n<0?-1:1,i=t==null?-1:e.indexOf(t);return e[((i===-1?r===1?-1:0:i)+r+e.length)%e.length]}function Tc({state:e,unseenOutcome:t}){if(e===z.WAITING)return`waiting`;let n=Se.safeParse(t);return n.success?n.data:null}function Ec(e={}){let t=Tc(e);return t!==null&&t!==`waiting`}function Dc(e={}){return Tc(e)!==null}var Oc=new Map([[`failed`,0],[`waiting`,1],[`finished`,2]]);function kc(e){let t=Tc(e);return t===null?void 0:Oc.get(t)}function Ac(e){return e.filter(e=>kc(e)!==void 0).sort((e,t)=>(kc(e)??0)-(kc(t)??0)).map(({id:e})=>e)}function jc(e,t){let n=new Map(e.map(e=>[e.id,e]));return Ac(e).flatMap(e=>{let r=n.get(e),i=r?Tc(r):null;return!r||i===null||e===t?[]:[{id:e,kind:i,name:r.name??``}]})}var Mc={headTile:32,tile:26,tileGap:4,overflowSlot:40};function Nc(e,t){if(t===0)return 0;let{headTile:n,tile:r,tileGap:i,overflowSlot:a}=Mc,o=r+i;if(n+(t-1)*o<=e)return t;let s=e-a-i-n,c=Math.floor(s/o);return Math.max(1,Math.min(t-1,1+c))}function Pc(e){let t={waitingCount:0,finishedCount:0,failedCount:0};for(let n of e||[]){let e=Tc(n||{});e===`waiting`&&t.waitingCount++,e===`failed`&&t.failedCount++,e===`finished`&&t.finishedCount++}return t}function Fc({waitingCount:e,finishedCount:t,failedCount:n}){return e+n+t}function Ic({waitingCount:e,failedCount:t}){return e+t}function Lc({waitingCount:e,finishedCount:t,failedCount:n}){let r=[];return n>0&&r.push(`${n} FAILED`),e===1&&r.push(`1 NEEDS YOU`),e>1&&r.push(`${e} NEED YOU`),t>0&&r.push(`${t} FINISHED`),r.length===0?`ALL CLEAR`:r.join(`, `)}var Rc=new Map([[`hand`,2]]),zc=1;function Bc(e){return e?typeof e==`string`&&Rc.get(e)||zc:0}function Vc(e){let t=!1,n=0;for(let r of e||[]){let e=Bc(r);e<=n||(t=typeof r!=`string`||r,n=e)}return t}var Hc=`#c084fc`,Uc=Object.freeze({failed:{icon:Wt[z.FAILED],color:`#ef4444`},waiting:{icon:Wt[z.WAITING],color:`#f59e0b`}});function Wc(e){let{waitingCount:t,failedCount:n}=Pc(Array.isArray(e)?e:[]);return t>0?`waiting`:n>0?`failed`:`idle`}function Gc(e){return Ze[e].map(({tag:e,attributes:t})=>`<${e} ${Object.entries(t).map(([e,t])=>`${e}="${t}"`).join(` `)}/>`).join(``)}function Kc(e){if(e===`idle`)return`<path d="M10 8 L22 16 L10 24Z" fill="${Hc}"/>`;let{icon:t,color:n}=Uc[e];return`<g color="${n}" transform="translate(4 4) scale(1.5)">${Gc(t)}</g>`}function qc(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="6" fill="#0a0810"/><rect x="1" y="1" width="30" height="30" rx="5" fill="none" stroke="#2a2440" stroke-width="1"/>${Kc(e)}</svg>`}function Jc(){let e=document.querySelector(`link[rel="icon"]`);if(e instanceof HTMLLinkElement)return e;let t=document.createElement(`link`);return t.rel=`icon`,t.type=`image/svg+xml`,document.head.append(t),t}var Yc=Jc(),Xc=`idle`;function Zc(e){let t=Wc([...e.values()].map(({currentState:e,unseenOutcome:t})=>({state:e,unseenOutcome:t})));t!==Xc&&(Xc=t,Yc.href=`data:image/svg+xml,${encodeURIComponent(qc(t))}`)}function Qc(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function $c(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function el({resizer:e,column:t,widthHost:n,widthProperty:r,bounds:i,keyStepPx:a,getStoredWidth:o,setStoredWidth:s,growsLeftward:c=!1}){let l=c?-1:1;e.setAttribute(`aria-valuemin`,String(i.minPx)),e.setAttribute(`aria-valuemax`,String(i.maxPx));let u=t=>{let a=Qc(t,i);return a===null?null:(n.style.setProperty(r,`${a}px`),e.setAttribute(`aria-valuenow`,String(a)),a)},d=o();d!==null&&u(d);let f=0,p=0;e.addEventListener(`pointerdown`,n=>{n.button===0&&(f=n.clientX,p=t.getBoundingClientRect().width,e.setPointerCapture(n.pointerId),e.dataset.dragging=`true`,n.preventDefault())}),e.addEventListener(`pointermove`,t=>{e.hasPointerCapture(t.pointerId)&&u(p+l*(t.clientX-f))});let m=t=>{e.releasePointerCapture(t.pointerId),delete e.dataset.dragging};e.addEventListener(`pointerup`,t=>{e.hasPointerCapture(t.pointerId)&&(m(t),s(u(p+l*(t.clientX-f))))}),e.addEventListener(`pointercancel`,t=>{e.hasPointerCapture(t.pointerId)&&(m(t),u(p))}),e.addEventListener(`dblclick`,()=>{n.style.removeProperty(r),e.setAttribute(`aria-valuenow`,String(Math.round(t.getBoundingClientRect().width))),s(null)}),e.addEventListener(`keydown`,e=>{let n=$c(e.key,a);if(n===null)return;e.preventDefault();let r=u(t.getBoundingClientRect().width+l*n);r!==null&&s(r)})}function G(e){return String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function tl(e,t,n){let r=L(`button`,`popup-menu-item ${n}`);return r.type=`button`,r.setAttribute(`role`,`menuitem`),r.setAttribute(`aria-label`,e),r.append(L(`span`,`popup-menu-item-label`,e),L(`span`,`popup-menu-item-hint`,t)),r}function nl(e){return e.key===`ArrowDown`||e.key===`ArrowUp`}function rl(e,t){let n=document.activeElement,r=n instanceof HTMLElement?e.indexOf(n):-1;e[((t.key===`ArrowDown`?r+1:r<0?e.length-1:r-1)+e.length)%e.length]?.focus()}var il=new WeakMap;function al(e){let t=il.get(e);if(t?.element.parentElement===e.card)return t;let n=t??pr(`session-action-status m-0 px-3 py-1`);return e.termWrap.before(n.element),il.set(e,n),n}function ol(e,t){let n=al(e);return mr(t,n)?(n.clear(),!0):!1}var sl=!1,cl=new Set;function ll(e){sl=!!e,Hl();for(let e of cl)e(sl)}function ul(e){return cl.add(e),()=>cl.delete(e)}function dl(){return sl}var fl=null;function pl(e){fl=e}var ml=null;function hl(e){ml=e}var gl=null;function _l(e){gl=e}var vl=[{cls:`agent-badge`,title:`Agent CLI this session supervises`},{cls:`worktree-badge`,text:`worktree`,title:`Running in a linked git worktree`,ariaLabel:`Linked git worktree`},{cls:`cloud-badge`,text:`cloud`,ariaLabel:`Runs in a Coder workspace`},{cls:`guardrails-badge`,text:`guardrails`,title:`Guardrails on: credentials, Glimmervoid state and blocked folders are off-limits to this session`,ariaLabel:`Guardrails on`},{cls:`post-turn-badge`,ariaHidden:!0},{cls:`usage-badge`,title:`Tokens and estimated API list-price cost for this conversation`},{cls:`wakeup-badge`},{cls:`prompt-badge`,title:`Waiting on a permission or input prompt`}];function yl({cls:e,text:t=``,title:n,ariaLabel:r,ariaHidden:i}){let a=L(`span`,e,t);return n&&(a.title=n),r&&a.setAttribute(`aria-label`,r),i&&a.setAttribute(`aria-hidden`,`true`),a}function bl(e){return`Runs in Coder workspace ${e}`}function xl(e,t){e.textContent=t?`SANE YOLO`:`YOLO`,e.title=t?`Skips permission prompts; Sane YOLO blocks catastrophic commands`:`Running with --dangerously-skip-permissions`}function Sl(e,t){t&&(e.dataset.saneYolo=``),t||delete e.dataset.saneYolo;let n=e.querySelector(`.perms-badge`);n&&xl(n,t)}function Cl(e,t){let n=B(e);n&&Sl(n.card,t)}function wl(e,t,n,r={}){let i=n||z.INITIALIZING,a=L(`div`,`session-card`);a.dataset.id=e,a.dataset.session=t,a.dataset.state=i,r.skipPerms&&(a.dataset.skipPerms=``),r.saneYolo&&(a.dataset.saneYolo=``),r.worktree&&(a.dataset.worktree=``),r.workspace&&(a.dataset.workspace=``),r.remoteWorkspace&&(a.dataset.remoteWorkspace=r.remoteWorkspace),r.guarded&&(a.dataset.guarded=``),r.guardrailsReleased&&(a.dataset.guardrailsReleased=``),r.ephemeral&&(a.dataset.ephemeral=``),r.path&&(a.dataset.path=String(r.path));let o=L(`div`,`session-card-header`),s=L(`span`,`session-name`,t);s.title=`Double-click or press F2 to rename`,s.tabIndex=0;let c=r.skipPerms?L(`span`,`perms-badge`):null;c&&xl(c,r.saneYolo===!0);let l=L(`span`,`session-task-title`);kl(l,r.taskTitle);let u=L(`div`,`session-actions`),d=L(`div`,`session-overflow`),f=L(`button`,`btn-action btn-session-menu visible`);f.append(sr(hr)),f.type=`button`,f.title=`Session actions`,f.setAttribute(`aria-label`,`Session actions`),f.setAttribute(`aria-haspopup`,`menu`),f.setAttribute(`aria-expanded`,`false`);let p=L(`div`,`popup-menu session-overflow-menu`);p.id=`session-menu-${e}`,p.setAttribute(`role`,`menu`),f.setAttribute(`aria-controls`,p.id);let m=tl(`Restart...`,`Into this conversation, a fresh one, or an earlier one`,`overflow-restart`);m.setAttribute(`aria-haspopup`,`dialog`);let h=tl(`Edit repositories...`,`Add or remove repositories in this workspace`,`overflow-workspace-repos`),g=tl(`Link pull request...`,`Link or unlink pull requests for this session`,`overflow-link-pr visible`),_=tl(`Conversation view`,`Show this session as messages (experimental)`,`overflow-conversation-view`);_.setAttribute(`role`,`menuitemcheckbox`),_.setAttribute(`aria-checked`,`false`);let v=tl(`Guardrails`,`Limit what this session can read, write and reach`,`overflow-guardrails`);v.setAttribute(`role`,`menuitemcheckbox`),Tl(v,a),g.onclick=()=>{p.classList.remove(`open`),f.setAttribute(`aria-expanded`,`false`),El(e)};let y=tl(`Coherence journal`,`Decisions and notes this session recorded`,`overflow-coherence-journal`);y.setAttribute(`aria-haspopup`,`dialog`);let b=()=>y.classList.toggle(`visible`,ml?.isReadable(e)===!0);f.onclick=b,f.onkeydown=b,y.onclick=()=>{p.classList.remove(`open`),f.setAttribute(`aria-expanded`,`false`),ml?.open(e)};let x=tl(`Session setup`,`MCP servers, plugins and hooks this session loaded`,`overflow-session-setup visible`);x.setAttribute(`aria-haspopup`,`dialog`),x.onclick=()=>{p.classList.remove(`open`),f.setAttribute(`aria-expanded`,`false`),gl?.(e)},p.append(m,h,_,v,y,x,g),d.append(f,p);let S=L(`button`,`btn-action btn-debug`);S.append(sr(fr)),S.title=`Debug state`,S.setAttribute(`aria-label`,`Debug session state`);let C=L(`button`,`btn-action btn-trace`);C.append(sr(dr)),C.type=`button`,C.title=`Trace`,C.setAttribute(`aria-label`,`Trace`);let w=L(`button`,`btn-action btn-remove visible`);w.append(sr(ur)),w.type=`button`,w.title=`Remove session`,w.setAttribute(`aria-label`,`Remove session`);let T=L(`button`,`btn-action btn-face-plan`,`Plan`);T.type=`button`,T.title=`Show plan`;let E=L(`button`,`btn-action btn-face-plan btn-docs`,`Docs`);E.type=`button`,E.title=`Open docs the agent surfaced`,u.append(E,T,S,C,d,w);let D=L(`div`,`session-card-tags`),O=vl.map(e=>yl(e.cls===`cloud-badge`&&r.remoteWorkspace?{...e,title:bl(r.remoteWorkspace)}:e));c&&O.push(c),D.append(...O);let k=L(`span`,`session-ownership`);k.hidden=!0,o.append(s,l,k,D,u);let A=L(`div`,`terminal-wrap`);return a.append(o,A),{card:a,header:o,nameEl:s,taskTitleEl:l,btnRestart:m,btnSessionMenu:f,btnWorkspaceRepos:h,btnConversationView:_,btnGuardrails:v,btnTrace:C,btnRemove:w,btnPlan:T,btnDocs:E,btnDebug:S,sessionMenu:p,termWrap:A}}function Tl(e,t){let n=t.dataset.guarded!==void 0,r=t.dataset.ephemeral===void 0&&(n||t.dataset.guardrailsReleased!==void 0);e.classList.toggle(`visible`,r),e.setAttribute(`aria-checked`,String(n))}function El(e){let{dialog:t,close:n,actions:r,btnCancel:i}=Tr({title:`Link pull request`}),a=L(`p`,`dialog-message`,`Paste a GitHub pull request URL or owner/repo#number.`),o=L(`input`,`dialog-input`);o.type=`text`,o.placeholder=`owner/repo#123`,o.autocomplete=`off`,o.spellcheck=!1,o.setAttribute(`aria-label`,`Pull request URL or owner/repo#number`);let s=L(`div`,`dialog-error`);s.setAttribute(`role`,`alert`);let c=L(`div`,`session-pr-chips dialog-linked-prs`);c.hidden=!0,fl?.(c,e);let l=L(`button`,`btn-dialog btn-dialog-confirm`,`Link`);l.type=`button`,r.append(l),t.append(c,a,o,s,r);function u(){let t=se(o.value);t?T({type:`link-session-pr`,id:e,key:t})?n():s.textContent=p:s.textContent=`Enter a github.com pull request URL or owner/repo#number.`}i.addEventListener(`click`,n),l.addEventListener(`click`,u),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),u())}),requestAnimationFrame(()=>o.focus())}function Dl(e,t){e.tabIndex=0,e.setAttribute(`role`,`button`),e.addEventListener(`click`,t),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())})}function Ol(e,t){let n=e.querySelector(`.session-ownership`);n&&(n.textContent=t??``,n.hidden=t===null)}function kl(e,t){e.title=t??``,t&&e.removeAttribute(`aria-label`),t||e.setAttribute(`aria-label`,`Describe the task`),!e.querySelector(`input`)&&(e.textContent=t??``)}function Al(e,t){let n=e.titleTargetEl?.isConnected?e.titleTargetEl:e.taskTitleEl;if(n.querySelector(`input`))return;let r=document.createElement(`input`);r.type=`text`,r.className=`session-title-input`,r.setAttribute(`aria-label`,`Task`),r.value=e.taskTitleIsCustom?e.taskTitle??``:``,r.placeholder=e.taskTitle??`What is this session working on?`,r.maxLength=120;let i=n.getAttribute(`role`),a=n.getAttribute(`tabindex`);n.removeAttribute(`role`),n.removeAttribute(`tabindex`),n.replaceChildren(r),r.focus(),r.select();function o(o){r.removeEventListener(`blur`,s),r.removeEventListener(`keydown`,c),o&&ol(e,{type:`set-session-title`,id:t,title:r.value.trim()}),n.replaceChildren(),i!==null&&n.setAttribute(`role`,i),a!==null&&n.setAttribute(`tabindex`,a),kl(n,e.taskTitle)}function s(){o(!0)}function c(e){e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),o(!0)),e.key===`Escape`&&(e.preventDefault(),o(!1))}r.addEventListener(`blur`,s),r.addEventListener(`keydown`,c)}var jl=`session-rename-input`;function Ml(e){return!!e?.querySelector(`.${jl}`)}function Nl(e,t,{returnsFocusToTerminal:n=!0}={}){let r=e.renameTargetEl?.isConnected?e.renameTargetEl:e.nameEl;if(!r||Ml(r))return;let i=e.card?.dataset.session??r.textContent??``,a=document.createElement(`input`);a.type=`text`,a.className=jl,a.value=i,a.maxLength=64,r.textContent=``,r.appendChild(a),a.focus(),a.select();let o=al(e);function s(t){return e.card.dataset.ephemeral===void 0?Be.test(t)?[...H.values()].some(n=>n!==e&&n.card.dataset.session===t)?`Session "${t}" already exists.`:``:Ge:`This session cannot be renamed`}function c(t=e.card?.dataset.session??i){r.textContent=t,e.nameEl&&e.nameEl!==r&&(e.nameEl.textContent=t),n&&e.term?.focus()}function l(){let e=a.value.trim(),t=e&&e!==i?s(e):``;t?(o.show(`error`,t),a.select()):u()}function u(){let n=a.value.trim();if(f(),!n||n===i){c();return}let r=s(n);r?(o.show(`error`,r),c()):ol(e,{type:`rename-session`,id:t,newName:n})?c(n):c()}function d(){f(),c()}function f(){a.removeEventListener(`blur`,u),a.removeEventListener(`keydown`,p)}function p(e){e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(e.preventDefault(),d()),e.stopPropagation()}a.addEventListener(`blur`,u),a.addEventListener(`keydown`,p)}function Pl(){let e=L(`button`,`debug-close`);return e.type=`button`,e.title=`Close`,e.setAttribute(`aria-label`,`Close debug overlay`),e.append(sr(ur)),e}function Fl(e){return e?w(new Date(e)):`-`}function Il(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function Ll(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Il(e.quietMs)})`:``}function Rl(e){let t=`<span class="debug-dim">${Fl(e.ts)}</span>`;if(e.kind===`signal`){let n=G([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${G(e.event||``)}</span>`:e.action===`gate-held`?`${t} ${n} → held <span class="debug-dim">(${Number(e.active)||0} bg)</span>`:`${t} ${n} → <span class="debug-dim">no-op</span>`}if(e.kind===`gate`){let n=(e.repeats??0)>1?` <span class="debug-dim">x${Number(e.repeats)}</span>`:``,r=Ll(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${G(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=G(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${G(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${G(e.category||`?`)}: <span class="debug-dim">${G(e.from||`?`)} → ${G(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${G(e.kind||`decision`)}</span>`}function zl(e,t){if(!e.debugOverlay)return;let n=t,r=``;if(r+=`<div class="debug-section"><div class="debug-section-title">State</div>`,r+=`<div class="debug-field"><span class="debug-label">Current:</span> <span class="debug-value">${G(n.state)}</span></div>`,r+=`</div>`,r+=`<div class="debug-section"><div class="debug-section-title">Transitions (last ${n.transitions.length})</div>`,n.transitions.length===0&&(r+=`<div class="debug-field debug-dim">No transitions recorded</div>`),n.transitions.length>0)for(let e of n.transitions){let t=e.detail&&typeof e.detail==`object`?e.detail:null,n=t?[t.signal,t.source,t.deferred?`deferred`:null].filter(Boolean):[],i=n.length>0?` <span class="debug-dim">${G(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${Fl(e.timestamp)}</span> ${G(e.from)} → ${G(e.to)} <span class="debug-label">${G(e.event)}</span>${i}</div>`}r+=`</div>`;let i=n.detection||{},a=i.lastSignal,o=i.titleState||{};r+=`<div class="debug-section"><div class="debug-section-title">Detection</div>`,r+=`<div class="debug-field"><span class="debug-label">Last signal:</span> <span class="debug-value">${a?`${G(a.signal)} (${G(a.source||`?`)}${a.confidence?`/${G(a.confidence)}`:``})`:`none`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hooks injected:</span> <span class="debug-value">${i.hooksInjected?`yes`:`no`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hook seen:</span> <span class="debug-value">${i.hookSeen?`yes`:`no (degraded → title)`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Title state:</span> <span class="debug-value">${G(o.lastKind||`none`)}${o.hasSeenSpinner?` · spun`:``}</span></div>`,r+=`</div>`;let s=i.agents||{},c=i.gate;r+=`<div class="debug-section"><div class="debug-section-title">Agents</div>`,r+=`<div class="debug-field"><span class="debug-label">Active:</span> <span class="debug-value">${Number(s.active)||0} (counted ${Number(s.counted)||0}, declared ${Number(s.declared)||0})</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Idle:</span> <span class="debug-value">${Number(s.idleNames)||0} names, ${Number(s.idleTasks)||0} tasks</span></div>`;let l=c?`held ${Il(c.heldForMs)} (seq ${Number(c.seq)||0}, lastActivity ${Number(c.lastActivitySeq)||0})`:`none`;r+=`<div class="debug-field"><span class="debug-label">Gate:</span> <span class="debug-value">${G(l)}</span></div>`,r+=`</div>`;let u=Array.isArray(n.decisions)?n.decisions:[];r+=`<div class="debug-section"><div class="debug-section-title">Decisions (last ${u.length})</div>`,u.length===0&&(r+=`<div class="debug-field debug-dim">No decisions recorded</div>`);for(let e of u)r+=`<div class="debug-field">${Rl(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(Pl())}function Bl(e,t){if(e.debugOpen){Vl(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(Pl()),e.card.appendChild(n),e.debugOverlay=n,e.debugOpen=!0,n.addEventListener(`click`,t=>{t.stopPropagation(),t.target instanceof Element&&t.target.closest(`.debug-close`)&&Vl(e)}),T({type:`debug-state`,id:t})}function Vl(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function Hl(){for(let[,e]of H)e.btnDebug.classList.toggle(`visible`,sl),e.btnTrace.classList.toggle(`visible`,sl),!sl&&e.debugOpen&&Vl(e)}function Ul(e){let t=typeof e.id==`string`?H.get(e.id):void 0;t?.debugOpen&&zl(t,e.payload)}function Wl(e){B(e)?.debugOpen&&T({type:`debug-state`,id:e})}var Gl={merged:`M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z`,draft:`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z`,conflict:`M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,behind:`M13.03 8.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L3.47 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l2.97 2.97V3.75a.75.75 0 0 1 1.5 0v7.44l2.97-2.97a.75.75 0 0 1 1.06 0Z`,failed:`M2.343 13.657A8 8 0 1 1 13.658 2.343 8 8 0 0 1 2.343 13.657ZM6.03 4.97a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042L6.94 8 4.97 9.97a.749.749 0 0 0 .326 1.275.749.749 0 0 0 .734-.215L8 9.06l1.97 1.97a.749.749 0 0 0 1.275-.326.749.749 0 0 0-.215-.734L9.06 8l1.97-1.97a.749.749 0 0 0-.326-1.275.749.749 0 0 0-.734.215L8 6.94Z`,running:`M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z`,passed:`M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z`,ready:`M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z`,"changes-requested":`M1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V4.664a.25.25 0 0 0-.073-.177l-2.914-2.914a.25.25 0 0 0-.177-.073ZM8 3.25a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0V7h-1.5a.75.75 0 0 1 0-1.5h1.5V4A.75.75 0 0 1 8 3.25Zm-3 8a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75Z`,thread:`M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z`,reviewer:`M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 13H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25v-8.5C0 1.784.784 1 1.75 1ZM1.5 2.75v8.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm5.28 1.72a.75.75 0 0 1 0 1.06L5.31 7l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.75.75 0 0 1 1.06 0Zm2.44 0a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.69 7 9.22 5.53a.75.75 0 0 1 0-1.06Z`,"your-turn":`M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z`,queued:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z`,fork:`M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z`,discarded:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm9.78-2.22-5.5 5.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l5.5-5.5a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z`,stale:`M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z`,unknown:`M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67c.169-.339.436-.701.849-.977C6.845 4.16 7.369 4 8 4a2.756 2.756 0 0 1 1.637.525c.503.377.863.965.863 1.725 0 .448-.115.83-.329 1.15-.205.307-.47.513-.692.662-.109.072-.22.138-.313.195l-.006.004a6.24 6.24 0 0 0-.26.16.952.952 0 0 0-.276.245.75.75 0 0 1-1.248-.832c.184-.264.42-.489.692-.661.103-.067.207-.132.313-.195l.007-.004c.1-.061.182-.11.258-.161a.969.969 0 0 0 .277-.245C8.96 6.514 9 6.427 9 6.25a.612.612 0 0 0-.262-.525A1.27 1.27 0 0 0 8 5.5c-.369 0-.595.09-.74.187a1.01 1.01 0 0 0-.34.398ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,none:`M2 7.75A.75.75 0 0 1 2.75 7h10a.75.75 0 0 1 0 1.5h-10A.75.75 0 0 1 2 7.75Z`};function Kl(e,t){let n=Sr(16,16);return n.classList.add(`pr-status-icon`),t&&(n.dataset.tone=t),n.append(Cr(`path`,{d:Gl[e],fill:`currentColor`})),n}function ql(e,{className:t=``,linkUrl:n,ariaLabel:r,onActivate:i}={}){let a=`signal ${t}`.trim(),o=n?$e(a,``,n,e.hoverText):L(`span`,a);return o.title=e.hoverText,r&&o.setAttribute(`aria-label`,r),e.look&&(o.dataset.tone=e.look.tone,o.append(Kl(e.look.icon,e.look.tone))),o.append(e.text),i&&Jl(o,i,!n),o}function Jl(e,t,n){e.addEventListener(`click`,e=>{e.stopPropagation(),!e.defaultPrevented&&(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t()))}),n&&(e.tabIndex=0,e.setAttribute(`role`,`button`)),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.stopPropagation(),e.preventDefault(),t()))})}function Yl(e){e.removeAttribute(`tabindex`),e.removeAttribute(`role`)}function Xl(e,t){if(e.closest(`button, a[href]`))for(let e of t){Yl(e);for(let t of e.querySelectorAll(`[role="button"]`))Yl(t)}}function Zl(e){if(e.overflowCount===0)return null;let t=L(`span`,`signal-overflow`,`+${e.overflowCount}`);return t.title=e.overflowHoverText,t}function Ql(e,t,n=e=>ql(e,e)){let r=Ps(t);if(e.dataset.signalSignature===r)return;e.dataset.signalSignature=r;let i=Ns(t),a=i.visible.map(n),o=Zl(i);o&&a.push(o),Xl(e,a),e.hidden=a.length===0,e.replaceChildren(...a)}var $l=[],eu=`plan`,tu={parked:{text:`PARKED`,hoverText:`Merge parked`,look:{icon:`failed`,tone:`danger`},tier:As.broken},merging:{text:`MERGING`,hoverText:`Merging`,look:{icon:`queued`,tone:`wait`},tier:As.waiting}};function nu(e){$l.push(e)}function ru(e){let t=tu[e];return t?[{...t,key:`merge`}]:[]}function iu(e){let t=e.closest(`.session-row`),n=t?.dataset.id;t&&n&&Ql(e,[...ru(t.dataset.merge??``),...$l.flatMap(e=>e(n))])}function au(){for(let e of document.querySelectorAll(`.session-row-signals`))iu(e)}function ou(e,t=``){let n=L(e,`session-row ${t}`.trim());return n.innerHTML=`<span class="session-row-glyph" aria-hidden="true"></span><span class="session-row-main"><span class="session-row-title"><span class="session-row-name"></span><span class="session-row-cloud" hidden></span></span><span class="session-row-task" hidden></span><span class="session-row-ownership" hidden></span><span class="session-row-meta"><span class="session-row-label"></span><span class="session-row-signals" hidden></span></span></span><span class="session-row-elapsed" aria-hidden="true"></span><span class="session-row-attention-tab" aria-hidden="true" hidden></span>`,{row:n,refs:{glyph:R(n,`.session-row-glyph`),label:R(n,`.session-row-label`),ownership:R(n,`.session-row-ownership`),name:R(n,`.session-row-name`),cloud:R(n,`.session-row-cloud`),task:R(n,`.session-row-task`),signals:R(n,`.session-row-signals`),elapsed:R(n,`.session-row-elapsed`),attentionTab:R(n,`.session-row-attention-tab`)}}}function su(e,t){let n=L(`div`,`session-row-item`),r=L(`button`,`session-row-remove`);return r.append(sr(ur)),r.type=`button`,r.title=`Remove session`,r.setAttribute(`aria-label`,`Remove session`),r.addEventListener(`click`,e=>{e.stopPropagation(),t()}),n.append(e,r),{item:n,removeButton:r}}function cu(e,t,n,r=!1,i=null){e.dataset.state=n,e.dataset.prompt=i??``;let{icon:a,label:o,isMonitoring:s}=Ke(n,r),c=i===eu?`Plan ready`:o;return e.toggleAttribute(`data-monitoring`,s),xr(t.glyph,a),t.label.textContent=c,c}function lu(e,t){return e.hidden=!t,t?(e.title=bl(t),e.firstChild||e.append(sr(vr)),e.title):null}function uu(e){let t=e.ownerId?H.get(e.ownerId):void 0,n=t?tn(t):null,r=e.card.dataset.id,i=[...H.values()].filter(e=>e.ownerId===r).length;return yc({ownerName:n,ownedCount:i})}function du(e,t,n){let r=uu(n);return t.ownership.textContent=r??``,t.ownership.hidden=r===null,e.closest(`.session-row-item`)?.toggleAttribute(`data-owned`,n.ownerId!==null&&H.has(n.ownerId)),Ol(n.card,r),r}function fu(e){return e===null?null:e===1?`next up`:`#${e} in line`}function pu(e,t,n){t.hidden=n===null,t.textContent=n===null?``:String(n),e.toggleAttribute(`data-attention-head`,n===1)}function mu(e,t,{ui:n,state:r,name:i,mergeStatus:a,attentionPosition:o}){let s=cu(e,t,r,n.awaitingBackgroundTasks,n.pendingPromptKind);t.name.textContent=i;let c=lu(t.cloud,n.card.dataset.remoteWorkspace);t.task.textContent=n.taskTitle,t.task.hidden=!n.taskTitle||n.taskTitle===i,e.dataset.merge=a,iu(t.signals),e.dataset.activity=n._activity||``,t.elapsed.textContent=Yt(n);let l=du(e,t,n);pu(e,t.attentionTab,o);let u=[i,c,n.taskTitle,s,l,fu(o)].filter(Boolean).join(`, `);return e.setAttribute(`aria-label`,u),e.title=u,s}var hu={ready:{label:`Ready`,meaning:`Ready to merge, or nothing left for you to do.`},passed:{label:`Passed`,meaning:`Checks passing, approved, or nothing open.`},failed:{label:`Failed`,meaning:`Checks failing, an automated review failed, or an auto-rebase failed.`},conflict:{label:`Conflict`,meaning:`Merge conflicts with the base branch.`},"your-turn":{label:`Your turn`,meaning:`Waiting on you: a review to give or a thread to answer.`},"changes-requested":{label:`Changes`,meaning:`A reviewer requested changes.`},thread:{label:`Threads`,meaning:`Unresolved review threads or comments.`},behind:{label:`Behind`,meaning:`The branch is behind its base.`},stale:{label:`Out of date`,meaning:`New commits landed since the automated review.`},fork:{label:`Fork`,meaning:`Opened from a fork, so it is reviewed by hand.`},running:{label:`Running`,meaning:`Checks or an automated review in progress.`},reviewer:{label:`Reviewer`,meaning:`Waiting on a reviewer.`},queued:{label:`Queued`,meaning:`Waiting for an automated review slot.`},draft:{label:`Draft`,meaning:`Still a draft.`},merged:{label:`Merged`,meaning:`Merged.`},discarded:{label:`Discarded`,meaning:`Review discarded or dismissed.`},unknown:{label:`Unknown`,meaning:`GitHub has not computed this yet.`},none:{label:`None`,meaning:`Nothing applies, such as no checks or no review requested.`}},gu=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:f[e],meaning:t}),_u=Object.freeze([gu(z.DORMANT,`Not started yet.`),gu(z.STARTING,`Setting up the worktree and booting the agent.`),gu(z.RUNNING,`The agent is mid-turn.`),gu(z.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),gu(z.WAITING,`Waiting on a permission prompt or your answer.`),gu(z.COMPLETE,`Finished a turn you have not looked at yet.`),gu(z.IDLE,`Ready for the next prompt.`),gu(z.DONE,`The agent process ended.`),gu(z.FAILED,`The agent failed to start or crashed. A red line above the terminal says why it could not start; its terminal output shows a crash.`)]);function vu(e,t){let n=L(`section`,`status-legend`),r=L(`dl`,`status-legend-rows`);return r.append(...t),n.append(L(`h2`,`status-legend-title`,e),r),n}function yu(e,t){let n=L(`div`,`status-legend-row`);return n.append(e,L(`dd`,`status-legend-meaning`,t)),n}function bu(){return vu(`Status colors`,_u.map(e=>{let t=L(`dt`,`status-legend-badge`),n=L(`span`,`status-legend-glyph`),r=L(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=yu(t,e.meaning);return cu(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function xu(){return vu(`Pull request icons`,Object.keys(hu).map(e=>{let t=hu[e],n=L(`dt`,`status-legend-badge`);return n.append(Kl(e),L(`span`,`status-legend-name`,t.label)),yu(n,t.meaning)}))}var Su=new Set(Sn());function Cu(){mn([...Su])}function wu(e){if(!e)return;let t=String(e);Su.has(t)||(Su.add(t),Cu())}function Tu(e,t){let n=new Set;for(let r of e||[]){let e=t(r);if(!e)continue;let i=String(e);n.add(i),wu(i)}return[...Su].filter(e=>!n.has(e))}function Eu(e){return!e||!Su.delete(String(e))?!1:(Cu(),!0)}function Du(e,t=`explicit-state`){let n=t===`dormant-fallback`?e||z.DORMANT:e;return n===z.DORMANT?`start-session`:n===z.COMPLETE?`dismiss`:null}function Ou({previousState:e,nextState:t,isPhoneLayout:n,isDocumentVisible:r,isDocumentFocused:i,isActiveViewer:a,hasFocusInsideTerminal:o}){return t!==z.COMPLETE||!e||e===z.COMPLETE||!r?!1:n?a:i&&o}function ku(e,t){if(!e)return null;let n=t.get(e);return!n||(n.currentState||z.DORMANT)===z.DORMANT?null:e}function Au(){return W.snapshot().selectedSessionId}function ju(e){W.dispatch(`selectSession`,e)}function Mu(e){return W.subscribe((t,n)=>{n.includes(`selectedSessionId`)&&e(t.selectedSessionId)})}function Nu(e,t=`explicit-state`){let n=H.get(e);if(!n)return null;let r=Du(n.currentState,t);return r&&ol(n,{type:r,id:e}),n}function Pu(e,{rememberFocus:t=!0}={}){ju(e),t&&or(e)}function Fu(){return ku(Un(),H)}function Iu(e=tn){return gc([...H],e)}function Lu(e,t){let n=H.get(e);return n?ol(n,t):T(t)?!0:(_r({source:`Session action`,sessionId:e,message:`${p} Try the action again once the header shows Connected.`}),!1)}async function Ru(e,t){try{let n=Bi(t),r=await S(`add-session`,{name:n,path:e},{timeoutMs:U});if(r.type===`add-session-result`&&r.ok){gr(Vu);return}if(r.type===`add-session-result`&&r.reason===`not-git`){ia({name:n,path:e});return}_r({source:Vu,message:na(r)})}catch(e){_r({source:Vu,message:`The session was not added: ${br(e,U)} Add it again once the server answers.`})}}function zu(e,t){e&&Ru(e,t)}var Bu=39e5,Vu=`Add session`,Hu=`Remove session`;function Uu(e,t){if(!t.keptPaths?.length)return`${t.error}. Removing "${tn(e)}" deletes its Coder workspace and that work with it. Push it from the session first to keep it.`;let n=t.keptPaths.map(e=>`${e.path} (${e.reason})`).join(`; `);return`Removing "${tn(e)}" deletes work that is not saved: ${n}. Commit and push it from the session first to keep it.`}async function Wu(e,t,n,r=[]){try{let i=await S(`remove-session`,{id:t,discardWork:n,confirmedKeptPaths:r},{timeoutMs:Bu});if(i.type!==`remove-session-result`||i.ok)return;if(!i.canDiscardWork){_r({source:Hu,sessionId:t,message:`"${tn(e)}" was not removed: ${i.error??`the server gave no reason`}. Try Remove again from its actions menu.`});return}wr({title:`Work not saved`,message:Uu(e,i),confirmLabel:`Discard work`,danger:!0,onConfirm:()=>{Wu(e,t,!0,(i.keptPaths??[]).map(e=>e.path))}})}catch(n){_r({source:Hu,sessionId:t,message:`"${tn(e)}" was not removed: ${br(n,Bu)} Try Remove again from its actions menu.`})}}function Gu(e,t){let n=H.get(e);if(!n)return;let r=t||n.card?.dataset.merge||`none`,i=r===`pending-review`||r===`parked`,a=n.card?.dataset.remoteWorkspace!==void 0||n.card?.dataset.workspace!==void 0;wr({title:`Remove Session`,message:i?`"${tn(n)}" has unmerged worktree changes that will be permanently discarded if you remove it. Merge or review them first to keep them. Remove anyway?`:`Remove session "${tn(n)}"?`,confirmLabel:`Remove`,danger:!0,onConfirm:()=>{a?Wu(n,e,!1):ol(n,{type:`remove-session`,id:e})}})}var Ku=Object.freeze({[z.IDLE]:`compaction_restore_idle`,[z.COMPLETE]:`compaction_restore_complete`,[z.WAITING]:`compaction_restore_waiting`});function qu(e){return Object.values(Ku).some(t=>t===e)}var Ju=new Set([`claude-code`,`codex`]),Yu=`\x1B`,Xu=`${Yu}[200~`,Zu=`${Yu}[201~`,Qu=400,$u=4e3,ed=/^\[Image: source: (.+)\]$/,td=`uploads`,nd=new Set([`Agent`,`Task`]),rd=/^Async agent launched/,id=`<task-notification>`,ad=/<tool-use-id>([^<]+)<\/tool-use-id>/,od=/<task-id>([^<]+)<\/task-id>/,sd=/agentId: ([\w-]+)/,cd=/<status>([^<]+)<\/status>/,ld=6e5;function ud(e){return typeof e==`string`&&Ju.has(e)}function dd(e,t){if(!ud(e))return null;let n=t.replace(/\r\n?/g,`
85
+ `)}var Fs={decision:`Decision`,retraction:`Retraction`,conjecture:`Conjecture`,resolution:`Resolution`,dismissal:`Dismissal`,defect:`Defect`,experiment:`Experiment`,close:`Close`,unable:`Unable`,escalation:`Escalation`,acknowledgement:`Acknowledgement`,enactment:`Enactment`};function Is(e){return e?.active!==!1||e.reason===Ue.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,hoverText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:As.broken}]}function Ls(e){let t=dt.safeParse(e.kind);return{heading:`${t.success?Fs[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function Rs(e,t){let n=[];return e?.active===!1&&n.push(`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`),t&&!t.journal.ok&&n.push(`Journal unavailable: ${t.journal.reason}`),{lines:n}}var zs=new Map,Bs=new Map,Vs=Os({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function Hs(e,t){Bs.delete(e),t&&Bs.set(e,t),Js(e)}function Us(e){zs.delete(e),Bs.delete(e);let t=Vs.currentPanel();t?.sessionId===e&&t.close()}function Ws(e){let t=zs.get(e.id);t&&t.updatedAt>e.updatedAt||(zs.set(e.id,e),Js(e.id))}function Gs(e){zs.clear();for(let[t,n]of Object.entries(e.sessions))zs.set(t,n);let t=Vs.currentPanel();t&&Js(t.sessionId)}function Ks(e){return Is(Bs.get(e)??null).map(t=>({...t,onActivate:()=>Ys(e)}))}function qs(e){return zs.get(e)?.journal.ok===!0}function Js(e){let t=Vs.currentPanel();if(!t||t.sessionId!==e)return;let n=Rs(Bs.get(e)??null,zs.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>L(`p`,null,e)))}function Ys(e){let t=L(`div`,`coherence-journal-reading`),n=L(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=L(`div`,`coherence-journal-entries`);Vs.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>Js(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function Xs(e){let t=Vs.settleResponse(e);t&&(e.ok?(t.status.textContent=e.entries.length===0?`No journal entries`:`${e.entries.length} journal entries (up to 200)`,t.parts.entries.replaceChildren(...e.entries.map(e=>{let t=Ls(e),n=L(`article`,`coherence-journal-entry`);return n.append(L(`h4`,null,t.heading),L(`p`,null,t.text)),t.detail&&n.append(L(`p`,null,t.detail)),t.supersedes&&n.append(L(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var Zs=/\bElectron\/\d/,Qs=new Set([`localhost`,`127.0.0.1`]);function $s(e){return Zs.test(e)}function ec({userAgent:e,pageHostname:t}){return $s(e)&&Qs.has(t)}function tc(e){return fo(e)!==null}var nc=new Set([0,1]);function rc({button:e,opensInNewTab:t}){return t&&nc.has(e)}function ic(){return ec({userAgent:navigator.userAgent,pageHostname:location.hostname})}function ac(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function oc(e){try{let t=await be();return(await fetch(`/open-external`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})})).ok}catch{return!1}}function sc(e){!ic()||!tc(e)?ac(e):oc(e).then(t=>{t||ac(e)})}function cc(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&rc({button:e.button,opensInNewTab:t.target===`_blank`})&&tc(t.href)&&(e.preventDefault(),sc(t.href))}function lc(e){ic()&&(e.addEventListener(`click`,cc,!0),e.addEventListener(`auxclick`,cc,!0))}var uc=new Map([[`plan`,`Plan ready`],[`permission`,`Needs permission`]]);function dc(e){return uc.get(e)??`Needs input`}function fc({hasPlan:e,pendingPromptKind:t,hasOpenReview:n,hasApprovedReview:r=!1}){return e&&(n||t===`plan`&&!r)?`plan`:`terminal`}function pc({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var mc=new Map(Object.entries({WAITING:`now`,COMPLETE:`later`,FAILED:`resting`,IDLE:`resting`,RUNNING:`resting`,STARTING:`resting`,INITIALIZING:`resting`,DORMANT:`resting`,DONE:`resting`}));function hc(e){return(typeof e.state==`string`?mc.get(e.state):void 0)??`resting`}function gc(e,t){return[...e].map(([e,n])=>{let r=n.currentState||z.DORMANT;return{id:e,ui:n,name:t(n),isDormant:r===z.DORMANT,state:r,unseenOutcome:n.unseenOutcome??null,ownerId:n.ownerId??null}})}function _c(e){let t=new Set(e.map(({id:e})=>e)),n=e=>e.ownerId&&t.has(e.ownerId)?e.ownerId:null,r=new Map;for(let t of e){let e=n(t);e&&r.set(e,[...r.get(e)??[],t])}return e.flatMap(e=>n(e)?[]:[e,...r.get(e.id)??[]])}function vc(e){return _c([...e].sort((e,t)=>Number(e.isDormant===!0)-Number(t.isDormant===!0)))}function yc({ownerName:e,ownedCount:t}){return e===null?t===1?`Owns 1 session`:t>1?`Owns ${t} sessions`:null:`Owned by ${e}`}function bc(e,t){return e.length?e[((t==null?-1:e.indexOf(t))+1)%e.length]:null}function xc(e,t){return t!==null&&e.includes(t)?t:e[0]??null}var Sc=new Map([[z.FAILED,`Failed`],[z.COMPLETE,`Finished`]]);function Cc(e,t){return Sc.get(e)??dc(t??``)}function wc(e,t,n){if(!e.length)return null;let r=n<0?-1:1,i=t==null?-1:e.indexOf(t);return e[((i===-1?r===1?-1:0:i)+r+e.length)%e.length]}function Tc({state:e,unseenOutcome:t}){if(e===z.WAITING)return`waiting`;let n=Se.safeParse(t);return n.success?n.data:null}function Ec(e={}){let t=Tc(e);return t!==null&&t!==`waiting`}function Dc(e={}){return Tc(e)!==null}var Oc=new Map([[`failed`,0],[`waiting`,1],[`finished`,2]]);function kc(e){let t=Tc(e);return t===null?void 0:Oc.get(t)}function Ac(e){return e.filter(e=>kc(e)!==void 0).sort((e,t)=>(kc(e)??0)-(kc(t)??0)).map(({id:e})=>e)}function jc(e,t){let n=new Map(e.map(e=>[e.id,e]));return Ac(e).flatMap(e=>{let r=n.get(e),i=r?Tc(r):null;return!r||i===null||e===t?[]:[{id:e,kind:i,name:r.name??``}]})}var Mc={headTile:32,tile:26,tileGap:4,overflowSlot:40};function Nc(e,t){if(t===0)return 0;let{headTile:n,tile:r,tileGap:i,overflowSlot:a}=Mc,o=r+i;if(n+(t-1)*o<=e)return t;let s=e-a-i-n,c=Math.floor(s/o);return Math.max(1,Math.min(t-1,1+c))}function Pc(e){let t={waitingCount:0,finishedCount:0,failedCount:0};for(let n of e||[]){let e=Tc(n||{});e===`waiting`&&t.waitingCount++,e===`failed`&&t.failedCount++,e===`finished`&&t.finishedCount++}return t}function Fc({waitingCount:e,finishedCount:t,failedCount:n}){return e+n+t}function Ic({waitingCount:e,failedCount:t}){return e+t}function Lc({waitingCount:e,finishedCount:t,failedCount:n}){let r=[];return n>0&&r.push(`${n} FAILED`),e===1&&r.push(`1 NEEDS YOU`),e>1&&r.push(`${e} NEED YOU`),t>0&&r.push(`${t} FINISHED`),r.length===0?`ALL CLEAR`:r.join(`, `)}var Rc=new Map([[`hand`,2]]),zc=1;function Bc(e){return e?typeof e==`string`&&Rc.get(e)||zc:0}function Vc(e){let t=!1,n=0;for(let r of e||[]){let e=Bc(r);e<=n||(t=typeof r!=`string`||r,n=e)}return t}var Hc=`#c084fc`,Uc=Object.freeze({failed:{icon:Wt[z.FAILED],color:`#ef4444`},waiting:{icon:Wt[z.WAITING],color:`#f59e0b`}});function Wc(e){let{waitingCount:t,failedCount:n}=Pc(Array.isArray(e)?e:[]);return t>0?`waiting`:n>0?`failed`:`idle`}function Gc(e){return Ze[e].map(({tag:e,attributes:t})=>`<${e} ${Object.entries(t).map(([e,t])=>`${e}="${t}"`).join(` `)}/>`).join(``)}function Kc(e){if(e===`idle`)return`<path d="M10 8 L22 16 L10 24Z" fill="${Hc}"/>`;let{icon:t,color:n}=Uc[e];return`<g color="${n}" transform="translate(4 4) scale(1.5)">${Gc(t)}</g>`}function qc(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="6" fill="#0a0810"/><rect x="1" y="1" width="30" height="30" rx="5" fill="none" stroke="#2a2440" stroke-width="1"/>${Kc(e)}</svg>`}function Jc(){let e=document.querySelector(`link[rel="icon"]`);if(e instanceof HTMLLinkElement)return e;let t=document.createElement(`link`);return t.rel=`icon`,t.type=`image/svg+xml`,document.head.append(t),t}var Yc=Jc(),Xc=`idle`;function Zc(e){let t=Wc([...e.values()].map(({currentState:e,unseenOutcome:t})=>({state:e,unseenOutcome:t})));t!==Xc&&(Xc=t,Yc.href=`data:image/svg+xml,${encodeURIComponent(qc(t))}`)}function Qc(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function $c(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function el({resizer:e,column:t,widthHost:n,widthProperty:r,bounds:i,keyStepPx:a,getStoredWidth:o,setStoredWidth:s,growsLeftward:c=!1}){let l=c?-1:1;e.setAttribute(`aria-valuemin`,String(i.minPx)),e.setAttribute(`aria-valuemax`,String(i.maxPx));let u=t=>{let a=Qc(t,i);return a===null?null:(n.style.setProperty(r,`${a}px`),e.setAttribute(`aria-valuenow`,String(a)),a)},d=o();d!==null&&u(d);let f=0,p=0;e.addEventListener(`pointerdown`,n=>{n.button===0&&(f=n.clientX,p=t.getBoundingClientRect().width,e.setPointerCapture(n.pointerId),e.dataset.dragging=`true`,n.preventDefault())}),e.addEventListener(`pointermove`,t=>{e.hasPointerCapture(t.pointerId)&&u(p+l*(t.clientX-f))});let m=t=>{e.releasePointerCapture(t.pointerId),delete e.dataset.dragging};e.addEventListener(`pointerup`,t=>{e.hasPointerCapture(t.pointerId)&&(m(t),s(u(p+l*(t.clientX-f))))}),e.addEventListener(`pointercancel`,t=>{e.hasPointerCapture(t.pointerId)&&(m(t),u(p))}),e.addEventListener(`dblclick`,()=>{n.style.removeProperty(r),e.setAttribute(`aria-valuenow`,String(Math.round(t.getBoundingClientRect().width))),s(null)}),e.addEventListener(`keydown`,e=>{let n=$c(e.key,a);if(n===null)return;e.preventDefault();let r=u(t.getBoundingClientRect().width+l*n);r!==null&&s(r)})}function G(e){return String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function tl(e,t,n){let r=L(`button`,`popup-menu-item ${n}`);return r.type=`button`,r.setAttribute(`role`,`menuitem`),r.setAttribute(`aria-label`,e),r.append(L(`span`,`popup-menu-item-label`,e),L(`span`,`popup-menu-item-hint`,t)),r}function nl(e){return e.key===`ArrowDown`||e.key===`ArrowUp`}function rl(e,t){let n=document.activeElement,r=n instanceof HTMLElement?e.indexOf(n):-1;e[((t.key===`ArrowDown`?r+1:r<0?e.length-1:r-1)+e.length)%e.length]?.focus()}var il=new WeakMap;function al(e){let t=il.get(e);if(t?.element.parentElement===e.card)return t;let n=t??pr(`session-action-status m-0 px-3 py-1`);return e.termWrap.before(n.element),il.set(e,n),n}function ol(e,t){let n=al(e);return mr(t,n)?(n.clear(),!0):!1}var sl=!1,cl=new Set;function ll(e){sl=!!e,Hl();for(let e of cl)e(sl)}function ul(e){return cl.add(e),()=>cl.delete(e)}function dl(){return sl}var fl=null;function pl(e){fl=e}var ml=null;function hl(e){ml=e}var gl=null;function _l(e){gl=e}var vl=[{cls:`agent-badge`,title:`Agent CLI this session supervises`},{cls:`worktree-badge`,text:`worktree`,title:`Running in a linked git worktree`,ariaLabel:`Linked git worktree`},{cls:`cloud-badge`,text:`cloud`,ariaLabel:`Runs in a Coder workspace`},{cls:`guardrails-badge`,text:`guardrails`,title:`Guardrails on: credentials, Glimmervoid state and blocked folders are off-limits to this session`,ariaLabel:`Guardrails on`},{cls:`post-turn-badge`,ariaHidden:!0},{cls:`usage-badge`,title:`Tokens and estimated API list-price cost for this conversation`},{cls:`wakeup-badge`},{cls:`prompt-badge`,title:`Waiting on a permission or input prompt`}];function yl({cls:e,text:t=``,title:n,ariaLabel:r,ariaHidden:i}){let a=L(`span`,e,t);return n&&(a.title=n),r&&a.setAttribute(`aria-label`,r),i&&a.setAttribute(`aria-hidden`,`true`),a}function bl(e){return`Runs in Coder workspace ${e}`}function xl(e,t){e.textContent=t?`SANE YOLO`:`YOLO`,e.title=t?`Skips permission prompts; Sane YOLO blocks catastrophic commands`:`Running with --dangerously-skip-permissions`}function Sl(e,t){t&&(e.dataset.saneYolo=``),t||delete e.dataset.saneYolo;let n=e.querySelector(`.perms-badge`);n&&xl(n,t)}function Cl(e,t){let n=B(e);n&&Sl(n.card,t)}function wl(e,t,n,r={}){let i=n||z.INITIALIZING,a=L(`div`,`session-card`);a.dataset.id=e,a.dataset.session=t,a.dataset.state=i,r.skipPerms&&(a.dataset.skipPerms=``),r.saneYolo&&(a.dataset.saneYolo=``),r.worktree&&(a.dataset.worktree=``),r.workspace&&(a.dataset.workspace=``),r.remoteWorkspace&&(a.dataset.remoteWorkspace=r.remoteWorkspace),r.guarded&&(a.dataset.guarded=``),r.guardrailsReleased&&(a.dataset.guardrailsReleased=``),r.ephemeral&&(a.dataset.ephemeral=``),r.path&&(a.dataset.path=String(r.path));let o=L(`div`,`session-card-header`),s=L(`span`,`session-name`,t);s.title=`Double-click or press F2 to rename`,s.tabIndex=0;let c=r.skipPerms?L(`span`,`perms-badge`):null;c&&xl(c,r.saneYolo===!0);let l=L(`span`,`session-task-title`);kl(l,r.taskTitle);let u=L(`div`,`session-actions`),d=L(`div`,`session-overflow`),f=L(`button`,`btn-action btn-session-menu visible`);f.append(sr(hr)),f.type=`button`,f.title=`Session actions`,f.setAttribute(`aria-label`,`Session actions`),f.setAttribute(`aria-haspopup`,`menu`),f.setAttribute(`aria-expanded`,`false`);let p=L(`div`,`popup-menu session-overflow-menu`);p.id=`session-menu-${e}`,p.setAttribute(`role`,`menu`),f.setAttribute(`aria-controls`,p.id);let m=tl(`Restart...`,`Into this conversation, a fresh one, or an earlier one`,`overflow-restart`);m.setAttribute(`aria-haspopup`,`dialog`);let h=tl(`Edit repositories...`,`Add or remove repositories in this workspace`,`overflow-workspace-repos`),g=tl(`Link pull request...`,`Link or unlink pull requests for this session`,`overflow-link-pr visible`),_=tl(`Conversation view`,`Show this session as messages (experimental)`,`overflow-conversation-view`);_.setAttribute(`role`,`menuitemcheckbox`),_.setAttribute(`aria-checked`,`false`);let v=tl(`Guardrails`,`Limit what this session can read, write and reach`,`overflow-guardrails`);v.setAttribute(`role`,`menuitemcheckbox`),Tl(v,a),g.onclick=()=>{p.classList.remove(`open`),f.setAttribute(`aria-expanded`,`false`),El(e)};let y=tl(`Coherence journal`,`Decisions and notes this session recorded`,`overflow-coherence-journal`);y.setAttribute(`aria-haspopup`,`dialog`);let b=()=>y.classList.toggle(`visible`,ml?.isReadable(e)===!0);f.onclick=b,f.onkeydown=b,y.onclick=()=>{p.classList.remove(`open`),f.setAttribute(`aria-expanded`,`false`),ml?.open(e)};let x=tl(`Session setup`,`MCP servers, plugins and hooks this session loaded`,`overflow-session-setup visible`);x.setAttribute(`aria-haspopup`,`dialog`),x.onclick=()=>{p.classList.remove(`open`),f.setAttribute(`aria-expanded`,`false`),gl?.(e)},p.append(m,h,_,v,y,x,g),d.append(f,p);let S=L(`button`,`btn-action btn-debug`);S.append(sr(fr)),S.title=`Debug state`,S.setAttribute(`aria-label`,`Debug session state`);let C=L(`button`,`btn-action btn-trace`);C.append(sr(dr)),C.type=`button`,C.title=`Trace`,C.setAttribute(`aria-label`,`Trace`);let w=L(`button`,`btn-action btn-remove visible`);w.append(sr(ur)),w.type=`button`,w.title=`Remove session`,w.setAttribute(`aria-label`,`Remove session`);let T=L(`button`,`btn-action btn-face-plan`,`Plan`);T.type=`button`,T.title=`Show plan`;let E=L(`button`,`btn-action btn-face-plan btn-docs`,`Docs`);E.type=`button`,E.title=`Open docs the agent surfaced`,u.append(E,T,S,C,d,w);let D=L(`div`,`session-card-tags`),O=vl.map(e=>yl(e.cls===`cloud-badge`&&r.remoteWorkspace?{...e,title:bl(r.remoteWorkspace)}:e));c&&O.push(c),D.append(...O);let k=L(`span`,`session-ownership`);k.hidden=!0,o.append(s,l,k,D,u);let A=L(`div`,`terminal-wrap`);return a.append(o,A),{card:a,header:o,nameEl:s,taskTitleEl:l,btnRestart:m,btnSessionMenu:f,btnWorkspaceRepos:h,btnConversationView:_,btnGuardrails:v,btnTrace:C,btnRemove:w,btnPlan:T,btnDocs:E,btnDebug:S,sessionMenu:p,termWrap:A}}function Tl(e,t){let n=t.dataset.guarded!==void 0,r=t.dataset.ephemeral===void 0&&(n||t.dataset.guardrailsReleased!==void 0);e.classList.toggle(`visible`,r),e.setAttribute(`aria-checked`,String(n))}function El(e){let{dialog:t,close:n,actions:r,btnCancel:i}=Tr({title:`Link pull request`}),a=L(`p`,`dialog-message`,`Paste a GitHub pull request URL or owner/repo#number.`),o=L(`input`,`dialog-input`);o.type=`text`,o.placeholder=`owner/repo#123`,o.autocomplete=`off`,o.spellcheck=!1,o.setAttribute(`aria-label`,`Pull request URL or owner/repo#number`);let s=L(`div`,`dialog-error`);s.setAttribute(`role`,`alert`);let c=L(`div`,`session-pr-chips dialog-linked-prs`);c.hidden=!0,fl?.(c,e);let l=L(`button`,`btn-dialog btn-dialog-confirm`,`Link`);l.type=`button`,r.append(l),t.append(c,a,o,s,r);function u(){let t=se(o.value);t?T({type:`link-session-pr`,id:e,key:t})?n():s.textContent=p:s.textContent=`Enter a github.com pull request URL or owner/repo#number.`}i.addEventListener(`click`,n),l.addEventListener(`click`,u),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),u())}),requestAnimationFrame(()=>o.focus())}function Dl(e,t){e.tabIndex=0,e.setAttribute(`role`,`button`),e.addEventListener(`click`,t),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())})}function Ol(e,t){let n=e.querySelector(`.session-ownership`);n&&(n.textContent=t??``,n.hidden=t===null)}function kl(e,t){e.title=t??``,t&&e.removeAttribute(`aria-label`),t||e.setAttribute(`aria-label`,`Describe the task`),!e.querySelector(`input`)&&(e.textContent=t??``)}function Al(e,t){let n=e.titleTargetEl?.isConnected?e.titleTargetEl:e.taskTitleEl;if(n.querySelector(`input`))return;let r=document.createElement(`input`);r.type=`text`,r.className=`session-title-input`,r.setAttribute(`aria-label`,`Task`),r.value=e.taskTitleIsCustom?e.taskTitle??``:``,r.placeholder=e.taskTitle??`What is this session working on?`,r.maxLength=120;let i=n.getAttribute(`role`),a=n.getAttribute(`tabindex`);n.removeAttribute(`role`),n.removeAttribute(`tabindex`),n.replaceChildren(r),r.focus(),r.select();function o(o){r.removeEventListener(`blur`,s),r.removeEventListener(`keydown`,c),o&&ol(e,{type:`set-session-title`,id:t,title:r.value.trim()}),n.replaceChildren(),i!==null&&n.setAttribute(`role`,i),a!==null&&n.setAttribute(`tabindex`,a),kl(n,e.taskTitle)}function s(){o(!0)}function c(e){e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),o(!0)),e.key===`Escape`&&(e.preventDefault(),o(!1))}r.addEventListener(`blur`,s),r.addEventListener(`keydown`,c)}var jl=`session-rename-input`;function Ml(e){return!!e?.querySelector(`.${jl}`)}function Nl(e,t,{returnsFocusToTerminal:n=!0}={}){let r=e.renameTargetEl?.isConnected?e.renameTargetEl:e.nameEl;if(!r||Ml(r))return;let i=e.card?.dataset.session??r.textContent??``,a=document.createElement(`input`);a.type=`text`,a.className=jl,a.value=i,a.maxLength=64,r.textContent=``,r.appendChild(a),a.focus(),a.select();let o=al(e);function s(t){return e.card.dataset.ephemeral===void 0?Be.test(t)?[...H.values()].some(n=>n!==e&&n.card.dataset.session===t)?`Session "${t}" already exists.`:``:Ge:`This session cannot be renamed`}function c(t=e.card?.dataset.session??i){r.textContent=t,e.nameEl&&e.nameEl!==r&&(e.nameEl.textContent=t),n&&e.term?.focus()}function l(){let e=a.value.trim(),t=e&&e!==i?s(e):``;t?(o.show(`error`,t),a.select()):u()}function u(){let n=a.value.trim();if(f(),!n||n===i){c();return}let r=s(n);r?(o.show(`error`,r),c()):ol(e,{type:`rename-session`,id:t,newName:n})?c(n):c()}function d(){f(),c()}function f(){a.removeEventListener(`blur`,u),a.removeEventListener(`keydown`,p)}function p(e){e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(e.preventDefault(),d()),e.stopPropagation()}a.addEventListener(`blur`,u),a.addEventListener(`keydown`,p)}function Pl(){let e=L(`button`,`debug-close`);return e.type=`button`,e.title=`Close`,e.setAttribute(`aria-label`,`Close debug overlay`),e.append(sr(ur)),e}function Fl(e){return e?w(new Date(e)):`-`}function Il(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function Ll(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Il(e.quietMs)})`:``}function Rl(e){let t=`<span class="debug-dim">${Fl(e.ts)}</span>`;if(e.kind===`signal`){let n=G([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${G(e.event||``)}</span>`:e.action===`gate-held`?`${t} ${n} → held <span class="debug-dim">(${Number(e.active)||0} bg)</span>`:`${t} ${n} → <span class="debug-dim">no-op</span>`}if(e.kind===`gate`){let n=(e.repeats??0)>1?` <span class="debug-dim">x${Number(e.repeats)}</span>`:``,r=Ll(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${G(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=G(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${G(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${G(e.category||`?`)}: <span class="debug-dim">${G(e.from||`?`)} → ${G(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${G(e.kind||`decision`)}</span>`}function zl(e,t){if(!e.debugOverlay)return;let n=t,r=``;if(r+=`<div class="debug-section"><div class="debug-section-title">State</div>`,r+=`<div class="debug-field"><span class="debug-label">Current:</span> <span class="debug-value">${G(n.state)}</span></div>`,r+=`</div>`,r+=`<div class="debug-section"><div class="debug-section-title">Transitions (last ${n.transitions.length})</div>`,n.transitions.length===0&&(r+=`<div class="debug-field debug-dim">No transitions recorded</div>`),n.transitions.length>0)for(let e of n.transitions){let t=e.detail&&typeof e.detail==`object`?e.detail:null,n=t?[t.signal,t.source,t.deferred?`deferred`:null].filter(Boolean):[],i=n.length>0?` <span class="debug-dim">${G(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${Fl(e.timestamp)}</span> ${G(e.from)} → ${G(e.to)} <span class="debug-label">${G(e.event)}</span>${i}</div>`}r+=`</div>`;let i=n.detection||{},a=i.lastSignal,o=i.titleState||{};r+=`<div class="debug-section"><div class="debug-section-title">Detection</div>`,r+=`<div class="debug-field"><span class="debug-label">Last signal:</span> <span class="debug-value">${a?`${G(a.signal)} (${G(a.source||`?`)}${a.confidence?`/${G(a.confidence)}`:``})`:`none`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hooks injected:</span> <span class="debug-value">${i.hooksInjected?`yes`:`no`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hook seen:</span> <span class="debug-value">${i.hookSeen?`yes`:`no (degraded → title)`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Title state:</span> <span class="debug-value">${G(o.lastKind||`none`)}${o.hasSeenSpinner?` · spun`:``}</span></div>`,r+=`</div>`;let s=i.agents||{},c=i.gate;r+=`<div class="debug-section"><div class="debug-section-title">Agents</div>`,r+=`<div class="debug-field"><span class="debug-label">Active:</span> <span class="debug-value">${Number(s.active)||0} (counted ${Number(s.counted)||0}, declared ${Number(s.declared)||0})</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Idle:</span> <span class="debug-value">${Number(s.idleNames)||0} names, ${Number(s.idleTasks)||0} tasks</span></div>`;let l=c?`held ${Il(c.heldForMs)} (seq ${Number(c.seq)||0}, lastActivity ${Number(c.lastActivitySeq)||0})`:`none`;r+=`<div class="debug-field"><span class="debug-label">Gate:</span> <span class="debug-value">${G(l)}</span></div>`,r+=`</div>`;let u=Array.isArray(n.decisions)?n.decisions:[];r+=`<div class="debug-section"><div class="debug-section-title">Decisions (last ${u.length})</div>`,u.length===0&&(r+=`<div class="debug-field debug-dim">No decisions recorded</div>`);for(let e of u)r+=`<div class="debug-field">${Rl(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(Pl())}function Bl(e,t){if(e.debugOpen){Vl(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(Pl()),e.card.appendChild(n),e.debugOverlay=n,e.debugOpen=!0,n.addEventListener(`click`,t=>{t.stopPropagation(),t.target instanceof Element&&t.target.closest(`.debug-close`)&&Vl(e)}),T({type:`debug-state`,id:t})}function Vl(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function Hl(){for(let[,e]of H)e.btnDebug.classList.toggle(`visible`,sl),e.btnTrace.classList.toggle(`visible`,sl),!sl&&e.debugOpen&&Vl(e)}function Ul(e){let t=typeof e.id==`string`?H.get(e.id):void 0;t?.debugOpen&&zl(t,e.payload)}function Wl(e){B(e)?.debugOpen&&T({type:`debug-state`,id:e})}var Gl={merged:`M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z`,draft:`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z`,conflict:`M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,behind:`M13.03 8.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L3.47 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l2.97 2.97V3.75a.75.75 0 0 1 1.5 0v7.44l2.97-2.97a.75.75 0 0 1 1.06 0Z`,failed:`M2.343 13.657A8 8 0 1 1 13.658 2.343 8 8 0 0 1 2.343 13.657ZM6.03 4.97a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042L6.94 8 4.97 9.97a.749.749 0 0 0 .326 1.275.749.749 0 0 0 .734-.215L8 9.06l1.97 1.97a.749.749 0 0 0 1.275-.326.749.749 0 0 0-.215-.734L9.06 8l1.97-1.97a.749.749 0 0 0-.326-1.275.749.749 0 0 0-.734.215L8 6.94Z`,running:`M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z`,passed:`M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z`,ready:`M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z`,"changes-requested":`M1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V4.664a.25.25 0 0 0-.073-.177l-2.914-2.914a.25.25 0 0 0-.177-.073ZM8 3.25a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0V7h-1.5a.75.75 0 0 1 0-1.5h1.5V4A.75.75 0 0 1 8 3.25Zm-3 8a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75Z`,thread:`M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z`,reviewer:`M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 13H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25v-8.5C0 1.784.784 1 1.75 1ZM1.5 2.75v8.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm5.28 1.72a.75.75 0 0 1 0 1.06L5.31 7l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.75.75 0 0 1 1.06 0Zm2.44 0a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.69 7 9.22 5.53a.75.75 0 0 1 0-1.06Z`,"your-turn":`M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z`,queued:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z`,fork:`M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z`,discarded:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm9.78-2.22-5.5 5.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l5.5-5.5a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z`,stale:`M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z`,unknown:`M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67c.169-.339.436-.701.849-.977C6.845 4.16 7.369 4 8 4a2.756 2.756 0 0 1 1.637.525c.503.377.863.965.863 1.725 0 .448-.115.83-.329 1.15-.205.307-.47.513-.692.662-.109.072-.22.138-.313.195l-.006.004a6.24 6.24 0 0 0-.26.16.952.952 0 0 0-.276.245.75.75 0 0 1-1.248-.832c.184-.264.42-.489.692-.661.103-.067.207-.132.313-.195l.007-.004c.1-.061.182-.11.258-.161a.969.969 0 0 0 .277-.245C8.96 6.514 9 6.427 9 6.25a.612.612 0 0 0-.262-.525A1.27 1.27 0 0 0 8 5.5c-.369 0-.595.09-.74.187a1.01 1.01 0 0 0-.34.398ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,none:`M2 7.75A.75.75 0 0 1 2.75 7h10a.75.75 0 0 1 0 1.5h-10A.75.75 0 0 1 2 7.75Z`};function Kl(e,t){let n=Sr(16,16);return n.classList.add(`pr-status-icon`),t&&(n.dataset.tone=t),n.append(Cr(`path`,{d:Gl[e],fill:`currentColor`})),n}function ql(e,{className:t=``,linkUrl:n,ariaLabel:r,onActivate:i}={}){let a=`signal ${t}`.trim(),o=n?$e(a,``,n,e.hoverText):L(`span`,a);return o.title=e.hoverText,r&&o.setAttribute(`aria-label`,r),e.look&&(o.dataset.tone=e.look.tone,o.append(Kl(e.look.icon,e.look.tone))),o.append(e.text),i&&Jl(o,i,!n),o}function Jl(e,t,n){e.addEventListener(`click`,e=>{e.stopPropagation(),!e.defaultPrevented&&(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t()))}),n&&(e.tabIndex=0,e.setAttribute(`role`,`button`)),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.stopPropagation(),e.preventDefault(),t()))})}function Yl(e){e.removeAttribute(`tabindex`),e.removeAttribute(`role`)}function Xl(e,t){if(e.closest(`button, a[href]`))for(let e of t){Yl(e);for(let t of e.querySelectorAll(`[role="button"]`))Yl(t)}}function Zl(e){if(e.overflowCount===0)return null;let t=L(`span`,`signal-overflow`,`+${e.overflowCount}`);return t.title=e.overflowHoverText,t}function Ql(e,t,n=e=>ql(e,e)){let r=Ps(t);if(e.dataset.signalSignature===r)return;e.dataset.signalSignature=r;let i=Ns(t),a=i.visible.map(n),o=Zl(i);o&&a.push(o),Xl(e,a),e.hidden=a.length===0,e.replaceChildren(...a)}var $l=[],eu=`plan`,tu={parked:{text:`PARKED`,hoverText:`Merge parked`,look:{icon:`failed`,tone:`danger`},tier:As.broken},merging:{text:`MERGING`,hoverText:`Merging`,look:{icon:`queued`,tone:`wait`},tier:As.waiting}};function nu(e){$l.push(e)}function ru(e){let t=tu[e];return t?[{...t,key:`merge`}]:[]}function iu(e){let t=e.closest(`.session-row`),n=t?.dataset.id;t&&n&&Ql(e,[...ru(t.dataset.merge??``),...$l.flatMap(e=>e(n))])}function au(){for(let e of document.querySelectorAll(`.session-row-signals`))iu(e)}function ou(e,t=``){let n=L(e,`session-row ${t}`.trim());return n.innerHTML=`<span class="session-row-glyph" aria-hidden="true"></span><span class="session-row-main"><span class="session-row-title"><span class="session-row-name"></span><span class="session-row-cloud" hidden></span></span><span class="session-row-task" hidden></span><span class="session-row-ownership" hidden></span><span class="session-row-meta"><span class="session-row-label"></span><span class="session-row-signals" hidden></span></span></span><span class="session-row-elapsed" aria-hidden="true"></span><span class="session-row-attention-tab" aria-hidden="true" hidden></span>`,{row:n,refs:{glyph:R(n,`.session-row-glyph`),label:R(n,`.session-row-label`),ownership:R(n,`.session-row-ownership`),name:R(n,`.session-row-name`),cloud:R(n,`.session-row-cloud`),task:R(n,`.session-row-task`),signals:R(n,`.session-row-signals`),elapsed:R(n,`.session-row-elapsed`),attentionTab:R(n,`.session-row-attention-tab`)}}}function su(e,t){let n=L(`div`,`session-row-item`),r=L(`button`,`session-row-remove`);return r.append(sr(ur)),r.type=`button`,r.title=`Remove session`,r.setAttribute(`aria-label`,`Remove session`),r.addEventListener(`click`,e=>{e.stopPropagation(),t()}),n.append(e,r),{item:n,removeButton:r}}function cu(e,t,n,r=!1,i=null){e.dataset.state=n,e.dataset.prompt=i??``;let{icon:a,label:o,isMonitoring:s}=Ke(n,r),c=i===eu?`Plan ready`:o;return e.toggleAttribute(`data-monitoring`,s),xr(t.glyph,a),t.label.textContent=c,c}function lu(e,t){return e.hidden=!t,t?(e.title=bl(t),e.firstChild||e.append(sr(vr)),e.title):null}function uu(e){let t=e.ownerId?H.get(e.ownerId):void 0,n=t?tn(t):null,r=e.card.dataset.id,i=[...H.values()].filter(e=>e.ownerId===r).length;return yc({ownerName:n,ownedCount:i})}function du(e,t,n){let r=uu(n);return t.ownership.textContent=r??``,t.ownership.hidden=r===null,e.closest(`.session-row-item`)?.toggleAttribute(`data-owned`,n.ownerId!==null&&H.has(n.ownerId)),Ol(n.card,r),r}function fu(e){return e===null?null:e===1?`next up`:`#${e} in line`}function pu(e,t,n){t.hidden=n===null,t.textContent=n===null?``:String(n),e.toggleAttribute(`data-attention-head`,n===1)}function mu(e,t,{ui:n,state:r,name:i,mergeStatus:a,attentionPosition:o}){let s=cu(e,t,r,n.awaitingBackgroundTasks,n.pendingPromptKind);t.name.textContent=i;let c=lu(t.cloud,n.card.dataset.remoteWorkspace);t.task.textContent=n.taskTitle,t.task.hidden=!n.taskTitle||n.taskTitle===i,e.dataset.merge=a,iu(t.signals),e.dataset.activity=n._activity||``,t.elapsed.textContent=Yt(n);let l=du(e,t,n);pu(e,t.attentionTab,o);let u=[i,c,n.taskTitle,s,l,fu(o)].filter(Boolean).join(`, `);return e.setAttribute(`aria-label`,u),e.title=u,s}var hu={ready:{label:`Ready`,meaning:`Ready to merge, or nothing left for you to do.`},passed:{label:`Passed`,meaning:`Checks passing, approved, or nothing open.`},failed:{label:`Failed`,meaning:`Checks failing, an automated review failed, or an auto-rebase failed.`},conflict:{label:`Conflict`,meaning:`Merge conflicts with the base branch.`},"your-turn":{label:`Your turn`,meaning:`Waiting on you: a review to give or a thread to answer.`},"changes-requested":{label:`Changes`,meaning:`A reviewer requested changes.`},thread:{label:`Threads`,meaning:`Unresolved review threads or comments.`},behind:{label:`Behind`,meaning:`The branch is behind its base.`},stale:{label:`Out of date`,meaning:`New commits landed since the automated review.`},fork:{label:`Fork`,meaning:`Opened from a fork, so it is reviewed by hand.`},running:{label:`Running`,meaning:`Checks or an automated review in progress.`},reviewer:{label:`Reviewer`,meaning:`Waiting on a reviewer.`},queued:{label:`Queued`,meaning:`Waiting for an automated review slot.`},draft:{label:`Draft`,meaning:`Still a draft.`},merged:{label:`Merged`,meaning:`Merged.`},discarded:{label:`Discarded`,meaning:`Review discarded or dismissed.`},unknown:{label:`Unknown`,meaning:`GitHub has not computed this yet.`},none:{label:`None`,meaning:`Nothing applies, such as no checks or no review requested.`}},gu=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:f[e],meaning:t}),_u=Object.freeze([gu(z.DORMANT,`Not started yet.`),gu(z.STARTING,`Setting up the worktree and booting the agent.`),gu(z.RUNNING,`The agent is mid-turn.`),gu(z.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),gu(z.WAITING,`Waiting on a permission prompt or your answer.`),gu(z.COMPLETE,`Finished a turn you have not looked at yet.`),gu(z.IDLE,`Ready for the next prompt.`),gu(z.DONE,`The agent process ended.`),gu(z.FAILED,`The agent failed to start or crashed. A red line above the terminal says why it could not start; its terminal output shows a crash.`)]);function vu(e,t){let n=L(`section`,`status-legend`),r=L(`dl`,`status-legend-rows`);return r.append(...t),n.append(L(`h2`,`status-legend-title`,e),r),n}function yu(e,t){let n=L(`div`,`status-legend-row`);return n.append(e,L(`dd`,`status-legend-meaning`,t)),n}function bu(){return vu(`Status colors`,_u.map(e=>{let t=L(`dt`,`status-legend-badge`),n=L(`span`,`status-legend-glyph`),r=L(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=yu(t,e.meaning);return cu(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function xu(){return vu(`Pull request icons`,Object.keys(hu).map(e=>{let t=hu[e],n=L(`dt`,`status-legend-badge`);return n.append(Kl(e),L(`span`,`status-legend-name`,t.label)),yu(n,t.meaning)}))}var Su=new Set(Sn());function Cu(){mn([...Su])}function wu(e){if(!e)return;let t=String(e);Su.has(t)||(Su.add(t),Cu())}function Tu(e,t){let n=new Set;for(let r of e||[]){let e=t(r);if(!e)continue;let i=String(e);n.add(i),wu(i)}return[...Su].filter(e=>!n.has(e))}function Eu(e){return!e||!Su.delete(String(e))?!1:(Cu(),!0)}function Du(e,t=`explicit-state`){let n=t===`dormant-fallback`?e||z.DORMANT:e;return n===z.DORMANT?`start-session`:n===z.COMPLETE?`dismiss`:null}function Ou({previousState:e,nextState:t,isPhoneLayout:n,isDocumentVisible:r,isDocumentFocused:i,isActiveViewer:a,hasFocusInsideTerminal:o}){return t!==z.COMPLETE||!e||e===z.COMPLETE||!r?!1:n?a:i&&o}function ku(e,t){if(!e)return null;let n=t.get(e);return!n||(n.currentState||z.DORMANT)===z.DORMANT?null:e}function Au(){return W.snapshot().selectedSessionId}function ju(e){W.dispatch(`selectSession`,e)}function Mu(e){return W.subscribe((t,n)=>{n.includes(`selectedSessionId`)&&e(t.selectedSessionId)})}function Nu(e,t=`explicit-state`){let n=H.get(e);if(!n)return null;let r=Du(n.currentState,t);return r&&ol(n,{type:r,id:e}),n}function Pu(e,{rememberFocus:t=!0}={}){ju(e),t&&or(e)}function Fu(){return ku(Un(),H)}function Iu(e=tn){return gc([...H],e)}function Lu(e,t){let n=H.get(e);return n?ol(n,t):T(t)?!0:(_r({source:`Session action`,sessionId:e,message:`${p} Try the action again once the header shows Connected.`}),!1)}async function Ru(e,t){try{let n=Bi(t),r=await S(`add-session`,{name:n,path:e},{timeoutMs:U});if(r.type===`add-session-result`&&r.ok){gr(Uu);return}if(r.type===`add-session-result`&&r.reason===`not-git`){ia({name:n,path:e});return}_r({source:Uu,message:na(r)})}catch(e){_r({source:Uu,message:`The session was not added: ${br(e,U)} Add it again once the server answers.`})}}function zu(e,t){e&&Ru(e,t)}async function Bu(e,t){try{let n=await S(`quick-session`,{id:e},{timeoutMs:U});if(n.type===`add-session-result`&&n.ok){gr(Uu),n.sessionId&&t(n.sessionId);return}_r({source:Uu,sessionId:e,message:na(n)})}catch(t){_r({source:Uu,sessionId:e,message:`The session was not added: ${br(t,U)} Add it again once the server answers.`})}}function Vu(e,t){Bu(e,t)}var Hu=39e5,Uu=`Add session`,Wu=`Remove session`;async function Gu(e,t,n,r=[]){try{let i=await S(`remove-session`,{id:t,discardWork:n,confirmedKeptPaths:r},{timeoutMs:Hu});if(i.type!==`remove-session-result`||i.ok)return;if(!i.canDiscardWork){_r({source:Wu,sessionId:t,message:`"${tn(e)}" was not removed: ${i.error??`the server gave no reason`}. Try Remove again from its actions menu.`});return}wr({title:`Remove Session`,message:i.error??`Remove session "${tn(e)}"?`,confirmLabel:`Remove`,danger:!0,onConfirm:()=>{Gu(e,t,!0,(i.keptPaths??[]).map(e=>e.path))}})}catch(n){_r({source:Wu,sessionId:t,message:`"${tn(e)}" was not removed: ${br(n,Hu)} Try Remove again from its actions menu.`})}}function Ku(e){let t=H.get(e);t&&Gu(t,e,!1)}var qu=Object.freeze({[z.IDLE]:`compaction_restore_idle`,[z.COMPLETE]:`compaction_restore_complete`,[z.WAITING]:`compaction_restore_waiting`});function Ju(e){return Object.values(qu).some(t=>t===e)}var Yu=new Set([`claude-code`,`codex`]),Xu=`\x1B`,Zu=`${Xu}[200~`,Qu=`${Xu}[201~`,$u=400,ed=4e3,td=/^\[Image: source: (.+)\]$/,nd=`uploads`,rd=new Set([`Agent`,`Task`]),id=/^Async agent launched/,ad=`<task-notification>`,od=/<tool-use-id>([^<]+)<\/tool-use-id>/,sd=/<task-id>([^<]+)<\/task-id>/,cd=/agentId: ([\w-]+)/,ld=/<status>([^<]+)<\/status>/,ud=6e5;function dd(e){return typeof e==`string`&&Yu.has(e)}function fd(e,t){if(!dd(e))return null;let n=t.replace(/\r\n?/g,`
86
86
  `).trim();return n?[{data:n.includes(`
87
- `)?`${Xu}${n}${Zu}`:n,delayBeforeMs:0},{data:`\r`,delayBeforeMs:Qu}]:null}function fd(e){return ud(e)?[{data:`\r`,delayBeforeMs:0}]:null}function pd(e){return ud(e)?[{data:Yu,delayBeforeMs:0}]:null}function md(e,t){return e===z.WAITING&&typeof t==`string`&&t!==``}function hd(e,t){return e.uuid??`${e.kind}-${e.ts}-${t}`}function gd(e){return typeof e.agentId==`string`}function _d(e){let t=ed.exec(e.trim());if(!t)return null;let[n,r,i]=t[1].split(/[\\/]/).slice(-3);return n!==td||!r||!i?null:`/upload/${encodeURIComponent(r)}/${encodeURIComponent(i)}`}function vd(e,t){let n=e[e.length-1];n?.kind===`user`&&n.imageUrls.push(t)}function yd(e){if(!e||typeof e!=`object`)return`Agent`;let t=e.description;return typeof t==`string`&&t.trim()?t.trim():`Agent`}function bd(e,t,n){if(!e)return;if(t.isError){e.state=`failed`;return}if(!rd.test(t.content)){e.state=`done`;return}let r=sd.exec(t.content)?.[1];r&&n.set(r,e)}function xd(e){return e.trimStart().startsWith(id)}function Sd(e,t,n){let r=ad.exec(e)?.[1];if(r)return t.get(r);let i=od.exec(e)?.[1];return i?n.get(i):void 0}function Cd(e,t,n){let r=Sd(e,t,n);r?.state===`running`&&(r.state=cd.exec(e)?.[1]===`completed`?`done`:`failed`)}function wd(e){let t=[],n=new Map,r=new Map,i=new Map,a=new Map,o=null;function s(){o&&t.push(o),o=null}function c(e,t){return o??={kind:`work`,key:e,steps:[],agentRuns:[],startedAt:t,endedAt:t},o.endedAt=Math.max(o.endedAt,t),o}return e.forEach((e,o)=>{let l=hd(e,o);if(!gd(e)){if((e.kind===`prompt`||e.kind===`expansion`)&&xd(e.text))Cd(e.text,i,a);else if(e.kind===`prompt`)s(),t.push({kind:`user`,key:l,text:e.text,at:e.ts,imageUrls:[]});else if(e.kind===`expansion`)for(let n of e.text.split(`
88
- `)){let e=_d(n);e&&vd(t,e)}else if(e.kind===`assistant`){if(!e.text.trim())return;t.push({kind:`assistant`,key:l,text:e.text,at:e.ts})}else if(e.kind===`notice`)t.push({kind:`notice`,key:l,text:e.text,at:e.ts});else if(e.kind===`thinking`)c(l,e.ts);else if(e.kind===`tool_call`){let t=c(l,e.ts),a={isRunning:!0};if(t.steps.push(a),n.set(e.toolUseId,a),r.set(e.toolUseId,t),!nd.has(e.name))return;let o={key:l,description:yd(e.input),state:`running`};t.agentRuns.push(o),i.set(e.toolUseId,o)}else if(e.kind===`tool_result`){let t=n.get(e.toolUseId),o=r.get(e.toolUseId);if(!t||!o)return;t.isRunning=!1,o.endedAt=Math.max(o.endedAt,e.ts),bd(i.get(e.toolUseId),e,a)}}}),s(),t}function Td(e){return e.flatMap(e=>e.kind===`work`?e.agentRuns.filter(e=>e.state===`running`):[])}function Ed(e){let t=e.at(-1);return t?.kind===`work`?t:null}function Dd(e){return new Set(e.flatMap(e=>e.kind===`user`?[e.key]:[]))}function Od(e,t,n){if(n-e.sentAt>ld)return!0;let r=e.text.trim();return t.some(t=>t.kind===`user`&&!e.userKeysAtSend.has(t.key)&&t.text.includes(r))}function kd(e){return`${e} ${e===1?`agent`:`agents`}`}function Ad(e){let t=Math.max(1,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}function jd(e){let t=e.agentRuns.length>0?`, ${kd(e.agentRuns.length)}`:``;return`Worked ${Ad(e.endedAt-e.startedAt)}${t}`}function Md(e,t){let n=t>0?`${kd(t)} running`:``;return e===null?n:n?`Working ${Ad(e)}, ${n}`:`Working ${Ad(e)}`}function Nd(e){return e.length<=$u?e:e.slice(e.length-$u)}var Pd=`(max-width: 768px)`,Fd=`(pointer: coarse)`;function Id({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var Ld=window.matchMedia?.(Fd),Rd=window.matchMedia?.(Pd);function zd(){return Id({coarse:!!Ld?.matches,narrowWidth:!!Rd?.matches})}function Bd(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function Vd(){W.subscribe((e,t)=>{t.includes(`layout`)&&Bd(e.layout)});let e=zd();Bd(e),W.dispatch(`setLayout`,e);let t=()=>W.dispatch(`setLayout`,zd());return Ld?.addEventListener?.(`change`,t),Rd?.addEventListener?.(`change`,t),e}function Hd(){return W.snapshot().layout===`phone`}function Ud(e){return W.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var Wd=`CommitMono`,Gd=[400,700].map(e=>`${e} 14px ${Wd}`),Kd=`monospace`;function qd(e){return e.trim().replace(/^['"]|['"]$/g,``)}function Jd(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>qd(e)!==Wd);return r.length>0?r.join(`, `):Kd}function Yd(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function Xd(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function Zd(){return document.fonts?Gd.every(e=>document.fonts.check(e)):!1}function Qd(){return Jd(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),Zd())}function $d(e){document.fonts&&Yd(document.fonts,Gd,e)}var ef=6,tf=262144,nf=16384,rf=()=>{};function af(e,t){if(t.length<=nf)e.push(t);else for(let n=0;n<t.length;n+=nf)e.push(t.slice(n,n+nf))}function of({budget:e=ef,maxChunkBytes:t=tf,requestFrame:n,cancelFrame:r}={}){let i=n||(e=>requestAnimationFrame(e)),a=r||(e=>cancelAnimationFrame(e)),o=new Map,s=[],c=0,l=null;function u(){l===null&&(l=i(h))}function d(e){return e.readIdx<e.pending.length}function f(e){d(e)||(e.pending.length=0,e.readIdx=0,e.dirty=!1)}function p(e){return!!(e?.live&&e.dirty&&!e.inFlight&&d(e))}function m(){for(let e of o.values())if(p(e))return!0;return!1}function h(){l=null;let n=s.length,r=0;for(let i=0;i<n&&r<e;i++){let e=s[(c+i)%n],a=o.get(e);if(!p(a))continue;let l=[],m=0;for(;a.readIdx<a.pending.length;){let e=a.pending[a.readIdx];if(typeof e!=`string`){if(m>0)break;a.readIdx++,e.run();continue}let n=t-m;if(m+e.length<=t)af(l,e),m+=e.length,a.readIdx++;else{m===0&&(af(l,e.slice(0,n)),m+=n,a.pending[a.readIdx]=e.slice(n));break}}let h=l.pop();if(h===void 0)f(a),r++;else{f(a),d(a)&&a.readIdx>=64&&(a.pending.splice(0,a.readIdx),a.readIdx=0),a.inFlight=!0;for(let e of l)a.write(e,rf);a.write(h,()=>{a.live&&(a.inFlight=!1,d(a)&&(a.dirty=!0,u()))}),r++}}n>0&&(c=(c+1)%n),m()&&u()}return{register(e,t){let n=o.get(e);n?(n.write=t,n.live=!0):(o.set(e,{write:t,pending:[],readIdx:0,inFlight:!1,dirty:!1,live:!0}),s.push(e))},unregister(e){let t=o.get(e);if(!t)return;t.live=!1,o.delete(e);let n=s.indexOf(e);n!==-1&&s.splice(n,1),c>=s.length&&(c=0)},enqueue(e,t){let n=o.get(e);n&&t&&(n.pending.push(t),n.dirty=!0,u())},enqueueAction(e,t){let n=o.get(e);n&&(n.pending.push({run:t}),n.dirty=!0,u())},has(e){return o.has(e)},size(){return o.size},running(){return l!==null},stop(){l!==null&&(a(l),l=null)}}}var sf=of(),cf=.3,lf=null;function uf(){return hn(lf)}function df(e){return rr(e,lf)}async function ff(){try{let e=await fetch(Fn,{credentials:`same-origin`,cache:`no-store`});e.ok&&(lf=Tn(await e.json()))}catch{}}function pf(){let e=new AudioContext;return e.state===`suspended`&&e.resume(),e}function mf(e,t){setTimeout(()=>e.close().catch(()=>{}),(t+.1)*1e3)}function hf(e){gf(xn[e]??xn.chime)}function gf(e){let t=pf(),n=t.createGain();n.gain.value=e.peakGain,n.connect(t.destination);let r=t.currentTime,i=0;for(let a of e.tones){let e=r+a.startSeconds,o=e+a.durationSeconds,s=t.createOscillator(),c=t.createGain();s.type=a.waveform,s.frequency.setValueAtTime(a.frequency,e),a.endFrequency&&s.frequency.exponentialRampToValueAtTime(a.endFrequency,o),c.gain.setValueAtTime(.001,e),c.gain.exponentialRampToValueAtTime(a.gain??1,e+.01),c.gain.exponentialRampToValueAtTime(.001,o),s.connect(c),c.connect(n),s.start(e),s.stop(o),i=Math.max(i,a.startSeconds+a.durationSeconds)}mf(t,i)}async function _f(e){try{let t=await fetch(ar(e),{credentials:`same-origin`});return t.ok?await t.arrayBuffer():null}catch{return null}}async function vf(e){let t=await _f(e);if(!t)return!1;let n=pf();try{let e=await n.decodeAudioData(t),r=n.createGain();r.gain.value=cf,r.connect(n.destination);let i=n.createBufferSource();return i.buffer=e,i.connect(r),i.start(),mf(n,e.duration),!0}catch{return n.close().catch(()=>{}),!1}}var yf=[659.25,830.61,987.77,1108.73,987.77,830.61,739.99,659.25,739.99,830.61,987.77,1108.73,987.77,830.61];function bf(){try{let e=new AudioContext;if(e.state===`suspended`&&e.resume(),e.state===`suspended`)return;let t=e.createGain();t.gain.value=.05,t.connect(e.destination);let n=.125,r=e.currentTime;for(let i=0;i<yf.length;i++){let a=r+i*n,o=e.createOscillator(),s=e.createGain();o.type=`square`,o.frequency.value=yf[i],s.gain.setValueAtTime(.001,a),s.gain.exponentialRampToValueAtTime(1,a+.01),s.gain.exponentialRampToValueAtTime(.001,a+n*.9),o.connect(s),s.connect(t),o.start(a),o.stop(a+n)}let i=r+yf.length*n;t.gain.setValueAtTime(.05,i-.05),t.gain.exponentialRampToValueAtTime(.001,i),setTimeout(()=>e.close().catch(()=>{}),(i-r+.1)*1e3)}catch{}}function xf(){try{hf(Nn)}catch{}}function Sf(e){try{let t=df(e),n=$n(t);if(!n){hf(t);return}vf(n).then(e=>{e||xf()})}catch{}}var Cf={"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.06)`,"--state-running":`#22c55e`,"--state-running-bg":`rgba(34, 197, 94, 0.06)`,"--state-waiting":`#f59e0b`,"--state-waiting-bg":`rgba(245, 158, 11, 0.08)`,"--state-failed":`#ef4444`,"--state-failed-bg":`rgba(239, 68, 68, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#eab308`,"--state-idle-bg":`rgba(234, 179, 8, 0.06)`},wf={background:`--bg-card`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#ef4444`,brightRed:`#f87171`,green:`#22c55e`,brightGreen:`#4ade80`,yellow:`#eab308`,brightYellow:`#facc15`,cyan:`#06b6d4`,brightCyan:`#22d3ee`},Tf={golgari:{label:`Golgari (Green/Black)`,colors:{"--bg":`#060b08`,"--bg-card":`#0a120e`,"--bg-header":`#081009`,"--bg-surface":`#0e1a12`,"--border":`#1a2e1f`,"--border-dim":`#122016`,"--border-hover":`#2a4a32`,"--text":`#b8ccbe`,"--text-dim":`#6a9070`,"--text-head":`#dceede`,"--text-muted":`#7a9a80`,"--accent":`#2dd4a0`,"--accent-dim":`#1a9a6e`,...Cf,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#94a3b8`,"--state-done-bg":`rgba(45, 212, 160, 0.06)`,"--state-starting":`#a78bfa`,"--state-starting-bg":`rgba(167, 139, 250, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...wf,foreground:`#c8dece`,blue:`--accent`,brightBlue:`#5ee8bc`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8dece`,brightWhite:`#e8f5ea`}},midnight:{label:`Midnight (Blue/Purple)`,colors:{"--bg":`#080816`,"--bg-card":`#0e0e20`,"--bg-header":`#0b0b1a`,"--bg-surface":`#131328`,"--border":`#1c1c38`,"--border-dim":`#141430`,"--border-hover":`#2a2a50`,"--text":`#b8b8d4`,"--text-dim":`#8585b3`,"--text-head":`#dcdcf0`,"--text-muted":`#7c7ca9`,"--accent":`#4f6ef7`,"--accent-dim":`#3a54c0`,...Cf,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#94a3b8`,"--state-done-bg":`rgba(59, 130, 246, 0.06)`,"--state-starting":`#a855f7`,"--state-starting-bg":`rgba(168, 85, 247, 0.06)`,"--state-complete":`#60a5fa`,"--state-complete-bg":`rgba(96, 165, 250, 0.06)`},terminal:{...wf,foreground:`#c8c8e0`,blue:`--accent`,brightBlue:`#60a5fa`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8c8e0`,brightWhite:`#e8e8ff`}},phyrexian:{label:`Phyrexian (Iridescent)`,colors:{"--bg":`#0a0810`,"--bg-card":`#100e18`,"--bg-header":`#0c0a14`,"--bg-surface":`#16122a`,"--border":`#2a2440`,"--border-dim":`#1e1a32`,"--border-hover":`#3e3660`,"--text":`#c8c0e0`,"--text-dim":`#8d82b9`,"--text-head":`#e8e0ff`,"--text-muted":`#8579b1`,"--accent":`#c084fc`,"--accent-dim":`#9656d6`,...Cf,"--state-monitoring":`#60a5fa`,"--state-monitoring-bg":`rgba(96, 165, 250, 0.08)`,"--state-done":`#67e8f9`,"--state-done-bg":`rgba(103, 232, 249, 0.06)`,"--state-starting":`#f472b6`,"--state-starting-bg":`rgba(244, 114, 182, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...wf,foreground:`#c8c0e0`,blue:`#67e8f9`,brightBlue:`#a5f3fc`,magenta:`--accent`,brightMagenta:`#d8b4fe`,white:`#c8c0e0`,brightWhite:`#e8e0ff`}},compleated:{label:`Compleated (Light)`,colors:{"--bg":`#ece8e0`,"--bg-card":`#f7f4ee`,"--bg-header":`#f0ece4`,"--bg-surface":`#e4e0d6`,"--border":`#b8b0a0`,"--border-dim":`#ccc6b8`,"--border-hover":`#908878`,"--text":`#2a2622`,"--text-dim":`#5a5448`,"--text-head":`#0e0c0a`,"--text-muted":`#676157`,"--accent":`#0e0c0a`,"--accent-dim":`#2a2622`,"--state-running":`#16803c`,"--state-running-bg":`rgba(22, 128, 60, 0.08)`,"--state-waiting":`#b45309`,"--state-waiting-bg":`rgba(180, 83, 9, 0.08)`,"--state-failed":`#dc2626`,"--state-failed-bg":`rgba(220, 38, 38, 0.06)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#64748b`,"--state-done-bg":`rgba(26, 24, 22, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#a16207`,"--state-idle-bg":`rgba(161, 98, 7, 0.06)`,"--state-starting":`#7c3aed`,"--state-starting-bg":`rgba(124, 58, 237, 0.06)`,"--state-complete":`#059669`,"--state-complete-bg":`rgba(5, 150, 105, 0.06)`},terminal:{background:`#faf8f4`,foreground:`#1a1816`,cursor:`#1a1816`,cursorAccent:`#faf8f4`,black:`#1a1816`,brightBlack:`#5a5448`,red:`#b91c1c`,brightRed:`#dc2626`,green:`#15803d`,brightGreen:`#16a34a`,yellow:`#92400e`,brightYellow:`#a16207`,blue:`#1d4ed8`,brightBlue:`#2563eb`,magenta:`#6d28d9`,brightMagenta:`#7c3aed`,cyan:`#0e7490`,brightCyan:`#0891b2`,white:`#5a5448`,brightWhite:`#3a3630`}},unicorn:{label:`Rainbow Unicorns (Dark)`,colors:{"--bg":`#191022`,"--bg-card":`#201730`,"--bg-header":`#1c1329`,"--bg-surface":`#281c3c`,"--border":`#3a2c52`,"--border-dim":`#2a2040`,"--border-hover":`#55407a`,"--text":`#d4c8e6`,"--text-dim":`#9a88b8`,"--text-head":`#ede4fa`,"--text-muted":`#a897c4`,"--accent":`#e8a3c4`,"--accent-dim":`#c4739e`,"--state-running":`#42d780`,"--state-running-bg":`rgba(66, 215, 128, 0.10)`,"--state-waiting":`#f79f3b`,"--state-waiting-bg":`rgba(247, 159, 59, 0.10)`,"--state-failed":`#f05442`,"--state-failed-bg":`rgba(240, 84, 66, 0.13)`,"--state-monitoring":`#2dd4bf`,"--state-monitoring-bg":`rgba(45, 212, 191, 0.08)`,"--state-done":`#f04ca4`,"--state-done-bg":`rgba(240, 76, 164, 0.13)`,"--state-initializing":`#8f87a6`,"--state-initializing-bg":`rgba(143, 135, 166, 0.08)`,"--state-idle":`#bcb02f`,"--state-idle-bg":`rgba(188, 176, 47, 0.08)`,"--state-starting":`#a17ef1`,"--state-starting-bg":`rgba(161, 126, 241, 0.08)`,"--state-complete":`#34baf4`,"--state-complete-bg":`rgba(52, 186, 244, 0.14)`},terminal:{background:`#201730`,foreground:`#d4c8e6`,cursor:`--accent`,cursorAccent:`#201730`,black:`#8c7dab`,brightBlack:`#9c8fb5`,red:`#e8887e`,brightRed:`#f4a89f`,green:`#86e0ab`,brightGreen:`#a3edc0`,yellow:`#f0c674`,brightYellow:`#f5d896`,blue:`#9cb3f0`,brightBlue:`#b5c8f5`,magenta:`#dd8ecf`,brightMagenta:`#e6a8dc`,cyan:`#7fd4d0`,brightCyan:`#a0e6e2`,white:`#d4c8e6`,brightWhite:`#f4ecfc`}},"posthog-light":{label:`PostHog (Light)`,colors:{"--bg":`#eeefe9`,"--bg-card":`#fdfdf8`,"--bg-header":`#eeefe9`,"--bg-surface":`#e5e7e0`,"--border":`#bfc1b7`,"--border-dim":`#d2d3cc`,"--border-hover":`#9ea096`,"--text":`#23251d`,"--text-dim":`#65675e`,"--text-head":`#111111`,"--text-muted":`#73756b`,"--accent":`#c03300`,"--accent-dim":`#8e2600`,"--state-running":`#237a36`,"--state-running-bg":`rgba(77, 117, 51, 0.08)`,"--state-waiting":`#b17816`,"--state-waiting-bg":`rgba(177, 120, 22, 0.10)`,"--state-failed":`#8c0d3b`,"--state-failed-bg":`rgba(140, 13, 59, 0.07)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#3e6b9e`,"--state-done-bg":`rgba(62, 107, 158, 0.08)`,"--state-initializing":`#73756b`,"--state-initializing-bg":`rgba(115, 117, 107, 0.07)`,"--state-idle":`#835c19`,"--state-idle-bg":`rgba(131, 92, 25, 0.07)`,"--state-starting":`#a621c8`,"--state-starting-bg":`rgba(166, 33, 200, 0.07)`,"--state-complete":`#34796f`,"--state-complete-bg":`rgba(52, 121, 111, 0.08)`},terminal:{background:`--bg-card`,foreground:`#23251d`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`#23251d`,brightBlack:`#65675e`,red:`#c03300`,brightRed:`#df6133`,green:`#4d7533`,brightGreen:`#6aa84f`,yellow:`#835c19`,brightYellow:`#b17816`,blue:`#3e6b9e`,brightBlue:`#2f80fa`,magenta:`#74108d`,brightMagenta:`#a621c8`,cyan:`#34796f`,brightCyan:`#30abc6`,white:`#4d4f46`,brightWhite:`#23251d`}},"posthog-dark":{label:`PostHog (Dark)`,colors:{"--bg":`#1e1f23`,"--bg-card":`#25262b`,"--bg-header":`#232429`,"--bg-surface":`#2d2e37`,"--border":`#3e424f`,"--border-dim":`#32343f`,"--border-hover":`#626674`,"--text":`#edeef4`,"--text-dim":`#aeb3c2`,"--text-head":`#fafafa`,"--text-muted":`#9ea096`,"--accent":`#f87a4c`,"--accent-dim":`#f54e00`,"--state-running":`#36c46f`,"--state-running-bg":`rgba(54, 196, 111, 0.08)`,"--state-waiting":`#f7a501`,"--state-waiting-bg":`rgba(247, 165, 1, 0.09)`,"--state-failed":`#f35454`,"--state-failed-bg":`rgba(243, 84, 84, 0.09)`,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#589df8`,"--state-done-bg":`rgba(88, 157, 248, 0.08)`,"--state-initializing":`#8f8f8c`,"--state-initializing-bg":`rgba(143, 143, 140, 0.07)`,"--state-idle":`#ffce5c`,"--state-idle-bg":`rgba(255, 206, 92, 0.07)`,"--state-starting":`#8567ff`,"--state-starting-bg":`rgba(133, 103, 255, 0.09)`,"--state-complete":`#29dbbb`,"--state-complete-bg":`rgba(41, 219, 187, 0.08)`},terminal:{background:`--bg-card`,foreground:`#edeef4`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#f35454`,brightRed:`#f87a4c`,green:`#36c46f`,brightGreen:`#96e5b6`,yellow:`#f7a501`,brightYellow:`#ffce5c`,blue:`#2f80fa`,brightBlue:`#9fc4ff`,magenta:`#8567ff`,brightMagenta:`#e2d6ff`,cyan:`#30abc6`,brightCyan:`#29dbbb`,white:`#aeb3c2`,brightWhite:`#fafafa`}}},Ef=`phyrexian`,Df=null;function Of(e){let t=Tf[e];if(!t)return;let n=Df;Df=e;let r=document.documentElement;r.dataset.theme=e;for(let[e,n]of Object.entries(t.colors))r.style.setProperty(e,n);e===`unicorn`&&n!==null&&n!==`unicorn`&&bf()}function kf(e){document.documentElement.toggleAttribute(`data-show-usage`,e)}function Af(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function jf(){let e=Tf[Df||Ef];if(!e)return{};let t=getComputedStyle(document.documentElement),n={};for(let[r,i]of Object.entries(e.terminal))n[r]=i.startsWith(`--`)?t.getPropertyValue(i).trim():i;return n}function Mf(){return Object.entries(Tf).map(([e,t])=>({id:e,label:t.label}))}var Nf=i().int().min(1).max(500),Pf=i().int().min(1).max(200);s(`type`,[u({type:l(`input`),data:a()}),u({type:l(`claim`),cols:Nf,rows:Pf}),u({type:l(`unview`)}),u({type:l(`pause-output`)}),u({type:l(`resume-output`)})]);var Ff=u({type:l(`pty-size`),cols:Nf,rows:Pf,seq:i().int().nonnegative()}),If=u({type:l(`output-beat`)}),Lf=s(`type`,[Ff,If]),Rf=`history`,zf=`output`,Bf=`paused`;o([`screen`,`deep`]);function Vf(e){try{return JSON.parse(e)}catch{return null}}function Hf(e){let t=Lf.safeParse(Vf(e));return t.success?t.data:null}function Uf(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function Wf(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function Gf(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function Kf({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&Uf(e,n))}function qf({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function Jf({isBorrowedCard:e,isTerminalFaceShown:t}){return!e||!t}function Yf({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function Xf(e,t,n){let r=new URLSearchParams;t&&r.set(Rf,`deep`),n&&r.set(zf,Bf);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function Zf({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:Kf({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function Qf({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function $f({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!Uf(e,t),s=Wf(n)?Gf(n):null,c=r&&!!s&&!Uf(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:Kf({authoritative:e,isActiveViewer:r,lastClaim:a})}}function ep(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function tp(e){let t=ep(e);return t===null?null:Hf(t)}function np(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=tp(e);return n?n.type===`output-beat`?{kind:`beat`}:t.hasSeenSize?n.seq<=t.lastSeq?{kind:`stale`}:{kind:`size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`attach-size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`ignored`}}var rp=``,ip=`\x1B`,ap=`\r`,op=new Map([[`deleteContentBackward`,rp],[`deleteByComposition`,rp],[`deleteCompositionText`,rp],[`deleteWordBackward`,ip],[`deleteSoftLineBackward`,ip],[`deleteHardLineBackward`,ip]]);function sp(e){return op.get(e)??``}var cp=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function lp(e){return typeof e!=`string`||e===``||!cp.has(e)}function up(e){return e?e.keyCode===229||e.key===`Process`:!1}function dp(e,t){let n=Array.from(e??``),r=Array.from(t??``),i=Math.min(n.length,r.length),a=0;for(;a<i&&n[a]===r[a];)a++;return rp.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,ap)}var fp=/https?:\/\/[^\s<>"']+/g,pp=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),mp={")":`(`,"]":`[`,"}":`{`};function hp(e,t){let n=0;for(let r of e)r===t&&n++;return n}function gp(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(pp.has(t)){e=e.slice(0,-1);continue}let n=mp[t];if(n&&hp(e,n)<hp(e,t))e=e.slice(0,-1);else return e}}function _p(e){let t=[];for(let n of e.matchAll(fp)){let e=gp(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var vp=50;function yp(){return{activate(e,t){sc(t)},allowNonHttpProtocols:!1}}function bp(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<vp;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<vp;)r++;let i=``,a=[];for(let t=n;t<=r;t++){let n=e.getLine(t);if(!n)break;for(let e=0;e<n.length;e++){let r=n.getCell(e);if(!r)break;if(r.getWidth()===0)continue;let o=r.getChars()||` `;for(let n=0;n<o.length;n++)i+=o[n],a.push({x:e+1,y:t+1})}}return{text:i,cellAt:a}}function xp(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=bp(r,t),o=[];for(let{start:e,end:t,url:n}of _p(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){sc(t)}})}n(o.length?o:void 0)}})}var Sp=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,Cp=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,wp=`[^\\S\\r\\n]`,Tp=`${Sp}${wp}*(?:=>|[:=])${wp}*`,Ep=`[?&][A-Za-z0-9_.-]*`,Dp=`[^\\r\\n;&|]{0,200}?`,Op=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,kp=RegExp(`(${Tp})${Cp}`,`gi`),Ap=RegExp(`(\\bBearer${wp}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),jp=[/\bAKIA[0-9A-Z]{16}\b/g,/\bgh[pousr]_[A-Za-z0-9]{16,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{20,}/g,/\bsk-[A-Za-z0-9_-]{20,}/g,/\bph[cx]_[A-Za-z0-9]{20,}\b/g,/\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g,/\beyJ[A-Za-z0-9_=-]{6,}\.[A-Za-z0-9_=-]{6,}\.[A-Za-z0-9_=-]{4,}/g,/-----BEGIN(?:[A-Z0-9 ]+)? PRIVATE KEY-----/g],Mp=[RegExp(`((?:^|\\s)--?${Sp}${wp}+)${Cp}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${wp}*=?${wp}*)${Cp}`,`g`),RegExp(`(-AsPlainText${wp}+)${Cp}`,`gi`),RegExp(`((?:^|\\s)setx${wp}+[^\\s\\r\\n]*${Sp}[^\\s\\r\\n]*${wp}+)${Cp}`,`gi`)],Np=[RegExp(`(\\bauthorization${wp}*:${wp}*Basic${wp}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${wp}+login\\b${Dp}${wp}-p(?:${wp}+|=))${Cp}`,`gi`),RegExp(`(\\bcurl\\b${Dp}${wp}(?:--user|-u)(?:${wp}+|=)[^\\s:\\r\\n]+:)${Cp}`,`gi`),RegExp(`(\\b${Op}\\b${Dp}${wp}-p)${Cp}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi];[...Mp,...Np];var Pp=[/-----END(?:[A-Z0-9 ]+)? PRIVATE KEY-----/g,/^([^\S\r\n]*)(?=[A-Za-z0-9+/]*[g-zG-Z+/])(?=[A-Za-z0-9+/=]{60,76}[^\S\r\n]*$)[A-Za-z0-9+/]+={0,2}(?=[^\S\r\n]*$)/gm],Fp=RegExp(`(${Ep}(?:${Sp}|_key)=)[^&#\\s]+`,`gi`),Ip=[kp,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${Cp}`,`g`)],Lp=[Ap,...Mp,...Np,...jp,...Pp];function Rp(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function zp(e,t){let n=0;return e.filter(e=>{for(;n<t.length&&t[n].end<=e.matchStart;)n+=1;let r=t.at(n);return!r||e.matchStart<r.matchStart})}function Bp(e){let t=[];for(let n of e.toSorted((e,t)=>e.start-t.start)){let e=t.at(-1);e&&n.start<=e.end?e.end=Math.max(e.end,n.end):t.push({...n})}return t}function Vp(e){let t=Rp(e,Fp);return Bp([...t,...Ip.flatMap(n=>zp(Rp(e,n),t)),...Lp.flatMap(t=>Rp(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var Hp=`#808080`,Up=new WeakMap;function Wp(e,t,n){return`${e}:${t}:${n}`}function Gp(e){return Wp(e.marker.line,e.x,e.width)}function Kp(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function qp(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function Jp(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function Yp(e,t,n,r){let i=``,a=[];for(let o=t;o<=n;o++){let t=e.getLine(o);if(!t)break;for(let e=0;e<t.length;e++){let n=t.getCell(e,r);if(!n)break;let s=n.getWidth();if(s===0)continue;let c=n.getChars()||` `;for(let t=0;t<c.length;t++)i+=c[t],a.push({line:o,x:e,width:s})}}return{text:i,cellAt:a}}function Xp(e,t){let n=null;for(let r of t)n&&n.line===r.line?n.width=Math.max(n.width,r.x+r.width-n.x):(n={line:r.line,x:r.x,width:r.width},e.push(n))}function Zp(e,t,n,r){let i=[];if(Vp(Jp(e,t,n)).length===0)return i;let{text:a,cellAt:o}=Yp(e,t,n,r);for(let e of Vp(a))Xp(i,o.slice(e.start,e.end));return i}function Qp(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=qp(e,i);r.push(...Zp(e,i,t,n)),i=t+1}return r}function $p(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function em(e){e.decoration.dispose(),e.marker.dispose()}function tm(e){for(let t of e.masks)em(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function nm(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function rm(e){let t=0;for(;t<e.masks.length&&e.masks[t].marker.isDisposed;)e.masks[t].decoration.dispose(),t++;t>0&&e.masks.splice(0,t)}function im(e,t){let n=new Map,r=e.masks.at(-1);for(;r&&(r.marker.isDisposed||r.marker.line>=t);)e.masks.pop(),r.marker.isDisposed&&r.decoration.dispose(),r.marker.isDisposed||n.set(Gp(r),r),r=e.masks.at(-1);return rm(e),n}function am(e,t){let n={normal:$p(),alternate:$p()},r=e.cols;function i(t){return e.buffer.active.type===t}function a(t,n){if(!i(n)||t.isDisposed)return!1;let r=t.line-e.buffer.active.viewportY;return r>=0&&r<e.rows}function o(t,n,r){t.style.backgroundColor=e.options.theme?.foreground??Hp,t.style.pointerEvents=`none`,t.style.display=a(n,r)?`block`:`none`}function s(e){for(let t of n[e].masks){let n=t.decoration.element;n&&o(n,t.marker,e)}}function c(t,n){let r=e.registerMarker(t.line-(n.baseY+n.cursorY));if(!r)return null;let i=e.registerDecoration({marker:r,x:t.x,width:t.width,layer:`top`});if(!i)return r.dispose(),null;let a=n.type;return i.onRender(e=>o(e,r,a)),{marker:r,decoration:i,x:t.x,width:t.width}}function l(){if(!$o())return;let t=e.buffer.active,r=n[t.type],i=Kp(t,nm(r,t)),a=im(r,i);for(let e of Qp(t,i)){let n=Wp(e.line,e.x,e.width),i=a.get(n);a.delete(n);let o=i??c(e,t);o&&r.masks.push(o)}for(let e of a.values())em(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){tm(n.normal),tm(n.alternate)}function d(){u(),r=e.cols,l()}let f=[e.onWriteParsed(l),e.onResize(({cols:e})=>{e!==r&&(r=e,n.normal.isFullRescanOwed=!0,n.alternate.isFullRescanOwed=!0,l())}),e.buffer.onBufferChange(e=>{tm(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=ts(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),Up.delete(e)},{once:!0}),Up.set(e,d)}function om(e){Up.get(e)?.()}function sm({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var cm=`Upload`;async function lm(e,t){return gr(cm,e),dm(e,t)}async function um(e,t){gr(cm,e);for(let n of t)await dm(e,n)}async function dm(e,t){let n={"x-glimmervoid-upload-name":encodeURIComponent(t.name)};t.type&&(n[`content-type`]=t.type);try{let r=await fetch(`/upload/${encodeURIComponent(e)}`,{method:`POST`,body:t,headers:n});return r.ok?!0:(_r({source:cm,sessionId:e,message:await fm(r,t.name)}),!1)}catch{return _r({source:cm,sessionId:e,message:`${t.name} was not uploaded because the server did not answer. Check that Glimmervoid is running, then drop the file again.`}),!1}}async function fm(e,t){try{let n=await e.json();if(n&&typeof n.error==`string`)return`${t} was not uploaded: ${n.error.replace(/\.$/,``)}. Fix that, then drop the file again.`}catch{}return`${t} was not uploaded (HTTP ${e.status}). Drop the file again, or check the Glimmervoid terminal for errors.`}var pm=10,mm=1.2,hm=.005,gm=4,_m=.08,vm=5;function ym(e,t){let n=Math.abs(t);return n<pm?!1:n>Math.abs(e)*mm}function bm(e,t,n=1/0){if(!(t>0))return{scrollLines:0,remainderPx:e};let r=Math.trunc(e/t),i=Math.max(-n,Math.min(n,r));return{scrollLines:i===0?0:-i,remainderPx:e-i*t}}function xm(e,t,n){let r=e.length>=gm?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function Sm(e){if(!e||e.length<2)return 0;let t=e[0],n=e[e.length-1],r=n.timestampMs-t.timestampMs;if(!(r>0))return 0;let i=(n.positionPx-t.positionPx)/r,a=Math.abs(i);if(!(a>=_m))return 0;let o=Math.min(a,vm);return i<0?-o:o}function Cm({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function wm(e,t){if(!e)return{scrollLines:0,state:null};let n=t-e.lastMs;if(!(n>0))return{scrollLines:0,state:e};let r=Math.abs(e.velocityPxPerMs)-hm*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=bm(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function Tm(e,t){return e===`alternate`||!!t&&t!==`none`}function Em(e,t){return!(e>0)||!(t>0)?0:e/t}var Dm=1;function Om(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function km(e,t){for(let n of e)if(n.identifier===t)return n;return null}function Am(e,t){if(Om(t))return;let n=()=>document.documentElement.dataset.layout===`phone`,r=null,i=0,a=0,o=0,s=!1,c=0,l=[],u=null,d=null,f=()=>{d!==null&&cancelAnimationFrame(d),d=null,u=null},p=()=>Tm(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return Em(e?.clientHeight||t.element?.clientHeight||0,t.rows)},h=()=>{r=null,s=!1,c=0,l=[]},g=(e,n,r)=>{let i=e<0?-1:1;for(let a=0;a<Math.abs(e);a++)t.element?.dispatchEvent(new WheelEvent(`wheel`,{deltaY:i,deltaMode:Dm,clientX:n,clientY:r,bubbles:!0,cancelable:!0}))},_=()=>{if(d=null,!u)return;if(!e.isConnected||!n()||p()){f();return}let r=t.buffer?.active?.viewportY,{scrollLines:i,state:a}=wm(u,performance.now());u=a,i!==0&&t.scrollLines(i),u&&(i!==0&&t.buffer?.active?.viewportY===r?f():d=requestAnimationFrame(_))},v=(e,t,n)=>{u=Cm({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:m(),pendingPx:n}),u&&(d=requestAnimationFrame(_))};e.addEventListener(`touchstart`,e=>{if(f(),!n()||e.touches.length!==1){h();return}let t=e.touches[0];r=t.identifier,i=t.clientX,a=t.clientY,o=t.clientY,s=!1,c=0,l=[]},{passive:!0}),e.addEventListener(`touchmove`,e=>{if(r===null||!n())return;let u=km(e.touches,r);if(!u)return;if(!s){if(!ym(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=xm([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=xm(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=bm(c,m(),d?8:void 0);c=h,f!==0&&(d?g(f,u.clientX,u.clientY):t.scrollLines(f))},{passive:!1}),e.addEventListener(`touchend`,e=>{if(!s||p()){h();return}l=xm(l,o,e.timeStamp);let t=Sm(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function jm(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function Mm(e,t,n=[]){let r=new Set(Array.isArray(n)?n:[n]),i=[];for(let n of e)e.length-i.length>=t&&!r.has(n)&&i.push(n);return i}var Nm=`modulepreload`,Pm=function(e){return`/`+e},Fm={},Im=function(e){return e.pathname.endsWith(`.css`)},Lm=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Rm=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Pm(t,n);let r=s(t),i=Im(r);return Lm(Fm,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Nm,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},zm=null,Bm=null;function Vm(){return zm}function Hm(){return zm?Promise.resolve(zm):(Bm??=Promise.all([Rm(()=>import(`./xterm-BdQ2Kshh.js`).then(e=>e.t),[]),Rm(()=>import(`./xterm-BdQ2Kshh.js`).then(e=>e.r),[]),Rm(()=>import(`./xterm-BdQ2Kshh.js`).then(e=>e.n),[])]).then(([e,t,n])=>(zm={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},zm)).catch(e=>{throw Bm=null,e}),Bm)}var Um=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,Wm=new Map;function Gm(e){return e.clientWidth>0&&e.clientHeight>0}function Km(e){let t=e.webglAddon;if(!t)return;let n=[...e.term?.element?.querySelectorAll(`canvas`)??[]];e.webglAddon=null;try{t.dispose()}catch{}for(let e of n)e.getContext(`webgl2`)?.getExtension(`WEBGL_lose_context`)?.loseContext()}function qm(e){Wm.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,Km(e)}function Jm(e){let t=[e],n=W.snapshot().borrowedCardId,r=n?H.get(n):void 0;r&&t.push(r);for(let e of Mm([...Wm.keys()],Um,t))qm(e),e.needsWebGLReload=!0}function Ym(e){e?.term&&jm({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:Gm(e.termWrap)})&&eh(e,{isForced:!0})}function Xm(){for(let e of Wm.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{qm(e),e.needsWebGLReload=!0}}}var Zm=!1;function Qm(){Zm||(Zm=!0,requestAnimationFrame(()=>{Zm=!1,Xm()}))}function $m(e){e?.addEventListener(`contextrestored`,Qm)}function eh(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){Wm.delete(e),Wm.set(e,!0);return}e.webglAddon&&(Km(e),Wm.delete(e));let n=Vm();if(!n)return;Jm(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,Wm.delete(e),e.needsWebGLReload=!0});let i=e.term;if(!i)throw Error(`webgl: the terminal was disposed before the addon loaded`);i.loadAddon(r),r.onChangeTextureAtlas($m),r.onAddTextureAtlasCanvas($m),$m(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!Gm(e.termWrap),Wm.set(e,!0),requestAnimationFrame(()=>{e.webglAddon===r&&e.term&&e.term.refresh(0,e.term.rows-1)})}catch{e.webglAddon=null,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,Wm.delete(e)}}function th(e){let t=Dn(e,Pa,{isTerminalFocused:!0},La());return t?Cn(t,document.body.dataset.activeView):!1}var nh=1024,rh=250,ih=`(max-width: 768px)`,ah=12,oh=14,sh=5e4,ch=!1;function lh(e){ch=e}var uh=!1;window.addEventListener(`blur`,()=>{uh=!0}),window.addEventListener(`focus`,()=>{uh=!1});function dh(e){let t=document.activeElement;return qf({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:uh,isPhoneLayout:Hd()})}function fh(e,t){return Jf({isBorrowedCard:W.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var ph=new WeakMap,mh=new WeakMap,hh=new WeakSet,gh=new WeakSet,_h=new WeakMap,vh=5e3,yh=15e3,bh=`Keys you type now are held and sent once the terminal reconnects.`,xh=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,Sh=`The agent copied text. The browser needs a click before it can reach your clipboard.`,Ch=`The clipboard is unavailable in this browser.`;function wh(e,t,n,r){let i=_h.get(e);i&&(i.clearTimerId!==null&&clearTimeout(i.clearTimerId),i.clearTimerId=null,i.shownKind=t,i.status.show(n,r),n!==`busy`&&(i.clearTimerId=setTimeout(()=>Th(e,t),n===`ok`?vh:yh)))}function Th(e,t){let n=_h.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function Eh(e){let t=e.buffer.active;return t.viewportY<t.baseY}function Dh(e,t,{hasNewOutput:n=!1}={}){let r=_h.get(e)?.jumpToLatestButton;if(!r)return;let i=Eh(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function Oh(e,t){if(ph.has(e)||!Eh(t))return;let n=t.buffer.active,r=n.length-n.viewportY;hh.has(e)?ph.set(e,r):mh.set(e,r)}function kh(e,t,n){let r=e.term;r&&Yf({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:hh.has(e)})&&(hh.add(e),gh.add(e),ph.set(e,r.buffer.active.length-n),ng(t))}var Ah=new WeakMap;function jh(e,t){return document.visibilityState===`visible`&&!fh(e,t)}function Mh(e,t){let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=jh(e,t);Ah.get(n)!==r&&(Ah.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function Nh(){for(let[e,t]of H)Mh(t,e)}document.addEventListener(`visibilitychange`,Nh),W.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&Nh()});function Ph(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new TextDecoder().decode(n)}function Fh(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),wh(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function Ih(e,t,n,r){let i=Ft(t);i?i.then(()=>{r&&wh(e,`clipboard`,`ok`,r)}).catch(t=>Fh(e,n,t)):wh(e,`clipboard`,`error`,Ch)}function Lh(e,t){let n=_h.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function Rh(e){let t=_h.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,Ih(e,n,`osc52 write`,`Copied to the clipboard.`))}function zh(e,t,n){let r=pr(`terminal-notice`),i=L(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=L(`button`,`btn-dialog btn-dialog-confirm`,`Copy to clipboard`);a.type=`button`,a.addEventListener(`click`,()=>Rh(t)),i.append(L(`span`,`terminal-clipboard-prompt-text`,Sh),a);let o=L(`div`,`terminal-notices`);o.append(i,r.element);let s=L(`button`,`terminal-jump-latest btn-dialog btn-dialog-ghost`,`Jump to latest`);s.type=`button`,s.hidden=!0,s.addEventListener(`click`,()=>{n.scrollToBottom(),n.focus()});let c=L(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(L(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),_h.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatestButton:s})}function Bh(e,t){return H.get(e)===t&&!t.dataWs}function Vh(e){return e.querySelector(`:scope > .terminal-connecting`)}function Hh(e){if(Vh(e))return;let t=L(`div`,`terminal-connecting`);t.append(L(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}function Uh(e){let t=Vh(e);if(!t)return;t.querySelector(`:scope > .terminal-connecting-animal`)?.remove();let n=si();n&&t.prepend(oi(n,`terminal-connecting-animal`))}var Wh=new Set,Gh=new WeakSet;function Kh(e){return Wh.add(e),()=>Wh.delete(e)}function qh(){let e=0;for(let[t,n]of H)n.card.dataset.link===`connecting`&&jh(n,t)&&e++;return e}function Jh(e){let t=sm({hasTerminal:e.term!==null||Gh.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:Qh}),n=t===`connecting`&&!Qh&&gh.has(e)?`live`:t;if(n===`none`){delete e.card.dataset.link,Yh();return}let r=n===`connecting`&&e.card.dataset.link!==`connecting`;e.card.dataset.link=n,r&&Uh(e.termWrap),Yh()}function Yh(){for(let e of Wh)e()}function Xh(e,t,n,r){Oh(t,n),sf.unregister(e),t.dataWs=null,Jh(t),t._resetGridClaim?.(),setTimeout(()=>{Bh(e,t)&&be().catch(()=>{}).then(()=>{Bh(e,t)&&Zh(e,t,n)})},r)}function Zh(e,t,n){let r=ph.get(t);ph.delete(t);let i=mh.get(t);mh.delete(t);let a=r!==void 0,o=r??i,s=!1,c=jh(t,e),l=M(location,A(Xf(e,a,!c))),u=new WebSocket(l);Ah.set(u,c),u.binaryType=`arraybuffer`,t.dataWs=u,Jh(t);let d=!1,f={hasSeenSize:!1,lastSeq:0};sf.register(e,(e,t)=>n.write(e,t)),u.addEventListener(`message`,r=>{if(t.dataWs!==u)return;let i=np(r.data,f);if(i.kind===`bytes`){nn(t);let r=s;if(s=!1,sf.enqueue(e,i.data),!r)return;let a=o??0;sf.enqueueAction(e,()=>{n.scrollToLine(Math.max(0,n.buffer.active.length-a))});return}if(i.kind===`beat`){nn(t);return}if(i.kind===`attach-size`){s=o!==void 0,a||hh.delete(t),f.hasSeenSize=!0,f.lastSeq=i.seq,n.reset(),om(n),t.ptySize={cols:i.cols,rows:i.rows},t._syncGrid?.();return}if(i.kind!==`size`)return;f.lastSeq=i.seq;let c={cols:i.cols,rows:i.rows};sf.enqueueAction(e,()=>{t.ptySize=c,t._syncGrid?.()})}),u.addEventListener(`close`,()=>{if(t.dataWs!==u)return;gh.delete(t),d||ge();let r=fe(t._dataWsRetryAttempt||0);t._dataWsRetryAttempt=(t._dataWsRetryAttempt||0)+1,Xh(e,t,n,r)}),u.addEventListener(`open`,()=>{d=!0,t._dataWsRetryAttempt=0,gh.delete(t),Jh(t),Mh(t,e),t._syncGrid?.({isActivationEdge:!0}),t._retryOwedGridClaim?.(),t._inputQueue?.length&&setTimeout(()=>{t.dataWs===u&&$h(t)},50)})}var Qh=!1;function $h(e){let t=e._inputQueue,n=e.dataWs;if(!Qh&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,Th(e,`keys`)}}function eg(){Qh=!0;for(let e of H.values())Jh(e)}function tg(){Qh=!1;for(let e of H.values())Jh(e),$h(e)}function ng(e){let t=B(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,Xh(e,t,t.term,0),n?.close()}function rg(e,t){let n=e.dataWs;e.dataWs=null,sf.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}function ig(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!Qh&&!e._inputQueue?.length&&e.dataWs?.readyState===WebSocket.OPEN)return e.dataWs.send(JSON.stringify({type:`input`,data:t})),!0;if(!e._inputQueue)return!1;let r=e.dataWs?.readyState!==WebSocket.OPEN;return e._inputQueue.length>=nh?(wh(e,`keys`,`error`,xh),!1):(e._inputQueue.push(t),r&&wh(e,`keys`,`busy`,bh),!0)}function ag(e,t,n){let r=window.matchMedia?.(ih).matches?ah:oh,i=new n.Terminal({cursorBlink:ch,fontSize:r,fontFamily:Qd(),theme:jf(),scrollback:sh,allowProposedApi:!0,linkHandler:yp()}),a=new n.FitAddon;i.loadAddon(a),Hh(e),i.open(e),zh(e,t,i),xp(i),am(i,t.abortController.signal),t.term=i,t.fitAddon=a,qm(t);let o=null,s=null,c=!1,l=null,u=null;function d(){s!==null&&(clearTimeout(s),s=null)}function f(){if(!c)return null;let e=t.fitAddon;if(!e)return null;let n=e.proposeDimensions();return n?{cols:n.cols,rows:n.rows}:null}function p(e){if(!c||!dh(t.card)||t.dataWs?.readyState!==WebSocket.OPEN)return!1;t.dataWs.send(JSON.stringify({type:`claim`,cols:e.cols,rows:e.rows})),l=e,u=null;let n=Kf({authoritative:t.ptySize??null,isActiveViewer:c,lastClaim:l});return t.card.dataset.grid=n?`following`:`exact`,!0}function m(e){d(),u=e,s=setTimeout(()=>{s=null,p(e)},rh)}function h(){u&&s===null&&p(u)}function g({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=$f({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:f(),isActiveViewer:c,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});r.resizeTo&&n.resize(r.resizeTo.cols,r.resizeTo.rows),t.card.dataset.grid=r.isFollowing?`following`:`exact`,r.keepsPendingSettle||(d(),u=null),r.sendUnview?(l=null,t.dataWs?.send(JSON.stringify({type:`unview`}))):r.owedClaim&&(e&&p(r.owedClaim)||m(r.owedClaim))}function _(){let e=Zf({authoritative:t.ptySize??null,isActiveViewer:c,isDocumentEngaged:dh(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});e!==`none`&&(d(),e===`rebid`&&(l=null),g({isActivationEdge:!0}))}let v=new ResizeObserver(()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,g()}))});v.observe(e),t.resizeObserver=v,t._syncGrid=g,t._resetGridClaim=()=>{d(),u=Qf({isActiveViewer:c,lastClaim:l,owedClaim:u}),l=null},t._retryOwedGridClaim=h,t._syncGridOnEngagementEdge=_,t._isActiveViewer=()=>c,t._setActiveViewer=e=>{c!==e&&(c=e,d(),u=null,e&&Ym(t),g({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{uh=!1,_()},{signal:t.abortController.signal}),eh(t);let y=null;i.onScroll(()=>{y===null&&(y=requestAnimationFrame(()=>{y=null,t.term&&(t.term.refresh(0,t.term.rows-1),Dh(t,t.term))}))}),i.onWriteParsed(()=>Dh(t,i,{hasNewOutput:!0})),i.parser.registerOscHandler(52,e=>{let n=e.indexOf(`;`);if(n<0)return!0;let r=e.slice(n+1);if(r===``||r===`?`)return!0;let i;try{i=Ph(r)}catch(e){return Fh(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(Ih(t,i,`osc52 write`),!0):(Lh(t,i),!0)}),i.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;if(th(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),Ih(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(ig(t,`\x1B`),!1):!0}),og(e,i,t),Am(e,i)}function og(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,Hd()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=dp(i,r.value);return i=r.value,e!==``&&(ig(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{Hd()?n(e):a()},!0)};c(`keydown`,e=>{up(e)?e.stopPropagation():(s(),queueMicrotask(o))}),c(`compositionstart`,e=>{e.stopPropagation()}),c(`compositionupdate`,e=>{e.stopPropagation()}),c(`compositionend`,e=>{e.stopPropagation(),setTimeout(s,0)}),c(`input`,e=>{if(!lp(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=sp(e.inputType);r!==``&&(ig(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function sg(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{ig(e,n),e.unseenOutcome&&T({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{kh(e,t,n)}),lg(e.termWrap,t,e.abortController.signal),Jh(e),queueMicrotask(()=>{Bh(t,e)&&Zh(t,e,n)}))}function cg(e){return!!e&&Array.from(e.types).includes(`Files`)}function lg(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),um(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{cg(t.dataTransfer)&&(t.preventDefault(),t.dataTransfer.dropEffect=`copy`,e.dataset.dropTarget=`true`)},{signal:n}),e.addEventListener(`dragleave`,t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||delete e.dataset.dropTarget},{signal:n}),e.addEventListener(`drop`,n=>{delete e.dataset.dropTarget,cg(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),um(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function ug(e,t){if(e.term||Gh.has(e))return;let n=Vm();if(n){dg(e,t,n);return}Gh.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},Hh(e.termWrap),Jh(e),Hm().then(n=>{Gh.delete(e),!(e.term||e.abortController.signal.aborted||H.get(t)!==e)&&(dg(e,t,n),e._setActiveViewer?.(r))},()=>{Gh.delete(e),Jh(e)})}function dg(e,t,n){ag(e.termWrap,e,n),sg(e,t)}function fg(e){e?._syncGridOnEngagementEdge?.()}function pg(e,t){if(!e)return;ug(e,t),Mh(e,t),Ym(e);let n=e.term;n&&(n.refresh(0,n.rows-1),fg(e))}function mg(e,t,n){e&&(n&&ug(e,t),e._setActiveViewer?.(n))}var hg=`conversation:`,gg=1e4,_g=48,vg=`, `,yg=`+`,bg=`■`,xg=`↑`,Sg=1e3,Cg={command:`Run command?`,fileChange:`Apply file changes?`,permissions:`Grant permissions?`},wg=1;function Tg(e){e?.previewUrl&&URL.revokeObjectURL(e.previewUrl)}function Eg(e,t,n){let r=L(`button`,`conversation-icon-button ${e}`,t);return r.type=`button`,r.title=n,r.setAttribute(`aria-label`,n),r}function Dg(e){return e.conversationApproval!==null||md(e.currentState,e.pendingPromptKind)}function Og(e,t,n,r,i=0){let a=n[i];a?setTimeout(()=>{B(e)===t?i>0&&Dg(t)?r(`stopped-by-prompt`):ig(t,a.data)?Og(e,t,n,r,i+1):r(`unreachable`):r(`unreachable`)},a.delayBeforeMs):r(`sent`)}function kg({signal:e,sendControl:t,showTerminal:n}){let r=L(`div`,`conversation-face`);r.hidden=!0;let i=L(`div`,`conversation-log`);i.setAttribute(`role`,`log`),i.setAttribute(`aria-live`,`polite`);let a=L(`p`,`conversation-empty`,`No conversation yet. Messages appear here as the agent works.`),o=L(`div`,`conversation-approval`);o.hidden=!0;let s=L(`p`,`conversation-bridge-note`,`Restart this Codex session to connect it to the conversation view. Until then, use the terminal.`);s.hidden=!0;let c=L(`p`,`conversation-bridge-note`,`The session trace is unavailable, so there is nothing to show here. Use the terminal.`);c.hidden=!0;let l=L(`details`,`conversation-working`),u=L(`summary`,`conversation-working-summary`);u.setAttribute(`role`,`status`);let d=L(`ul`,`conversation-agent-list`);l.append(u,d),l.hidden=!0;let f=L(`form`,`conversation-composer`),p=L(`p`,`conversation-status`);p.setAttribute(`role`,`status`);let m=L(`div`,`conversation-attachment`);m.hidden=!0;let h=L(`div`,`conversation-composer-row`),g=Eg(`conversation-attach`,yg,`Attach a photo or file`),_=L(`input`,`conversation-file-picker`);_.type=`file`,_.hidden=!0;let v=L(`textarea`,`conversation-input`);v.dataset.dashboardShortcuts=`allowed`,v.rows=1,v.placeholder=`Message the agent`,v.setAttribute(`aria-label`,`Message the agent`);let y=Eg(`conversation-stop`,bg,`Stop the current turn (Esc)`),b=Eg(`conversation-send`,xg,`Send`);b.type=`submit`,h.append(g,v,y,b),f.append(p,m,h,_),r.append(i,l,c,s,o,f);let x=null,S=[],C=0,w=!1,T=null,E=!1,D=null,O=!1,k=[],A=[],ee=null,te=!1,ne=new Set;function re(){return x?B(x)??null:null}function ie(e){p.textContent=e}function j(){v.style.height=`auto`,v.style.height=`${v.scrollHeight+v.offsetHeight-v.clientHeight}px`}function ae(){T&&clearTimeout(T.timeoutHandle),T=null}function M(){if(!x||r.hidden||!c.hidden)return;if(T){E=!0;return}let e=`${hg}${wg++}`,n=w?C:null;t(n===null?{type:`session-trace`,id:x,requestId:e,endingAt:`tail`}:{type:`session-trace`,id:x,requestId:e,after:n})?(E=!1,T={requestId:e,after:n,timeoutHandle:setTimeout(()=>{T=null,M()},gg)}):ie(`Conversation unavailable while disconnected.`)}function N(){return i.scrollHeight-i.scrollTop-i.clientHeight<=_g}function oe(e){let t=L(`a`,`conversation-image-link`);t.href=e,t.target=`_blank`,t.rel=`noopener`;let n=L(`img`,`conversation-image`);return n.src=e,n.alt=`Attached image`,n.loading=`lazy`,n.addEventListener(`error`,()=>t.remove(),{once:!0}),t.append(n),t}function se(e){let t=L(`article`,`conversation-message conversation-user is-pending`);return e.text&&t.append(L(`p`,`conversation-text`,e.text)),e.attachment?.previewUrl&&t.append(oe(e.attachment.previewUrl)),e.attachment&&!e.attachment.previewUrl&&t.append(L(`p`,`conversation-attachment-name`,e.attachment.name)),t}function ce(e){let t=L(`article`,`conversation-message conversation-${e.kind}`);return e.kind===`assistant`?(t.append(Wo(zo(e.text))),t):(t.append(L(`p`,`conversation-text`,e.text)),e.kind===`user`&&t.append(...e.imageUrls.map(oe)),t)}function le(e,t){e.replaceChildren(...t.map(e=>{let t=L(`li`,`conversation-agent is-${e.state}`);return t.append(L(`span`,`conversation-agent-name`,e.description),L(`span`,`conversation-agent-state`,e.state)),t}))}function ue(e){if(e.agentRuns.length===0)return L(`p`,`conversation-work`,jd(e));let t=L(`details`,`conversation-work`);t.open=ne.has(e.key),t.addEventListener(`toggle`,()=>{t.open?ne.add(e.key):ne.delete(e.key)});let n=L(`ul`,`conversation-agent-list`);return le(n,e.agentRuns),t.append(L(`summary`,``,jd(e)),n),t}function de(){return re()?.currentState===z.RUNNING}function fe(){let e=re(),t=Td(A),n=de()?Ed(A)?.agentRuns??[]:[],r=[...new Set([...n,...t])];if(l.hidden=!e||!de()&&t.length===0,l.hidden||!e)return;let i=de()?Math.max(0,Date.now()-e.stateSince):null;u.textContent=Md(i,t.length),l.classList.toggle(`has-agents`,r.length>0),le(d,r)}function pe(){let e=!r.hidden&&de();e&&!ee&&(ee=setInterval(fe,Sg)),!e&&ee&&(clearInterval(ee),ee=null),fe()}function me(){i.scrollTop=i.scrollHeight}function he(){let e=te||N();A=wd(S);let t=Date.now(),n=k.filter(e=>Od(e,A,t));for(let e of n)Tg(e.attachment);k=k.filter(e=>!n.includes(e));let r=[...(de()&&Ed(A)?A.slice(0,-1):A).map(e=>e.kind===`work`?ue(e):ce(e)),...k.map(se)];i.replaceChildren(...r.length>0?r:[a]),fe(),e&&(me(),requestAnimationFrame(me),w&&(te=!1))}function ge(){if(m.replaceChildren(),m.hidden=!D,D){if(D.previewUrl){let e=L(`img`,`conversation-attachment-thumbnail`);e.src=D.previewUrl,e.alt=``,m.append(e)}m.append(L(`span`,`conversation-attachment-name`,D.name))}}function _e(e){D!==e&&Tg(D),D=e,ge()}function ve(e,t=()=>{}){let n=re();if(!n||!x||!e){ie(`Unable to reach this session.`);return}ie(``);let r={sent:``,unreachable:`Unable to reach this session.`,"stopped-by-prompt":`Not sent: a prompt appeared, so the message was typed but not submitted. Check the terminal.`};Og(x,n,e,e=>{ie(r[e]),t(e)})}function P(e,n,r){x&&ie(t({type:`conversation-approval`,id:x,requestId:e.requestId,decision:n,...r?{answers:r}:{}})?``:`Unable to send the answer while disconnected.`)}function ye(e,t){let n=L(`button`,`conversation-approval-action`,e);return n.type=`button`,n.addEventListener(`click`,t),n}function be(e){return e.kind===`tool`?`Allow ${e.toolName??`this tool`}?`:Cg[e.kind]??`Approve this request?`}function xe(e){o.append(L(`p`,`conversation-approval-note`,`This request cannot be shown in full here. Read and answer it in the terminal.`));let t=L(`div`,`conversation-approval-actions`);t.append(ye(`Open terminal`,()=>n()),ye(`Decline`,()=>P(e,`decline`))),o.append(t)}function Se(e){if(o.append(L(`p`,`conversation-approval-title`,be(e)),L(`pre`,`conversation-approval-summary`,e.summary)),e.isSummaryTruncated){xe(e);return}let t=L(`div`,`conversation-approval-actions`);t.append(ye(`Approve`,()=>P(e,`accept`))),e.kind!==`tool`&&t.append(ye(`Approve for session`,()=>P(e,`acceptForSession`))),e.alwaysAllowSummary&&(o.append(L(`p`,`conversation-approval-note`,`Always allow adds, for this session only: ${e.alwaysAllowSummary}`)),t.append(ye(`Always allow`,()=>P(e,`acceptForSession`)))),t.append(ye(`Decline`,()=>P(e,`decline`))),o.append(t)}function Ce(e){let t=L(`p`,`conversation-approval-title`,e.question);return e.header&&t.prepend(L(`span`,`conversation-question-header`,e.header)),t}function we(e,t){o.append(Ce(t));let n=L(`div`,`conversation-question-options`);for(let r of t.options){let i=ye(r.label,()=>P(e,`accept`,{[t.question]:r.label}));r.description&&(i.title=r.description),n.append(i)}let r=L(`div`,`conversation-approval-actions`);r.append(ye(`Decline`,()=>P(e,`decline`))),o.append(n,r)}function Te(e,t){let n=L(`form`,`conversation-question-form`);t.forEach((e,t)=>{let r=L(`fieldset`,`conversation-question`),i=L(`legend`,`conversation-question-text`,e.question);e.header&&i.prepend(L(`span`,`conversation-question-header`,e.header)),r.append(i);for(let n of e.options){let i=L(`label`,`conversation-question-option`),a=L(`input`);a.type=e.multiSelect?`checkbox`:`radio`,a.name=`question-${t}`,a.value=n.label,i.append(a,L(`span`,``,n.label)),n.description&&(i.title=n.description),r.append(i)}n.append(r)});let r=L(`div`,`conversation-approval-actions`),i=L(`button`,`conversation-approval-action`,`Send answers`);i.type=`submit`,r.append(i,ye(`Decline`,()=>P(e,`decline`))),n.append(r),n.addEventListener(`submit`,r=>{r.preventDefault();let i={};t.forEach((e,t)=>{let r=[...n.querySelectorAll(`input[name="question-${t}"]:checked`)].map(e=>e.value);r.length>0&&(i[e.question]=r.join(vg))}),Object.keys(i).length===t.length?P(e,`accept`,i):ie(`Answer every question first.`)}),o.append(n)}function Ee(e){let t=e.questions??[];if(e.isSummaryTruncated||t.length===0){o.append(L(`p`,`conversation-approval-title`,`Claude Code has a question`),L(`pre`,`conversation-approval-summary`,e.summary)),xe(e);return}let[n]=t;t.length===1&&!n.multiSelect?we(e,n):Te(e,t)}function De(e){e.kind===`question`?Ee(e):Se(e)}function Oe(){o.append(L(`p`,`conversation-approval-title`,`The agent is waiting on a prompt`)),o.append(L(`p`,`conversation-approval-note`,`Read and answer it in the terminal.`));let e=L(`div`,`conversation-approval-actions`);e.append(ye(`Open terminal`,()=>n())),o.append(e)}function ke(){let e=re();o.replaceChildren();let t=e?.conversationApproval??null,n=e?md(e.currentState,e.pendingPromptKind):!1,r=e?.agent===`codex`&&!e.hasConversationBridge;s.hidden=!r,o.hidden=!t&&!n,b.disabled=!o.hidden||r,Ae(),e&&(t?De(t):n&&Oe())}function Ae(){g.disabled=b.disabled||O}function je(e){let t=dd(e,v.value);return t||!D?t:fd(e)}function Me(){let e=re();y.disabled=e?.currentState!==z.RUNNING,pe()}f.addEventListener(`submit`,e=>{if(e.preventDefault(),b.disabled)return;let t=je(re()?.agent);if(!t)return;let n={text:v.value.trim(),attachment:D,sentAt:Date.now(),userKeysAtSend:Dd(A)};v.value=``,j(),D=null,ge(),k.push(n),te=!0,he(),ve(t,e=>{e!==`sent`&&(Tg(n.attachment),k=k.filter(e=>e!==n),he())})},{signal:e}),v.addEventListener(`input`,j,{signal:e});let Ne=0,Pe=new ResizeObserver(()=>{let e=i.clientHeight,t=Ne===0;Ne=e,t&&e!==0&&(te=!0,me(),w&&(te=!1))});Pe.observe(i),e?.addEventListener(`abort`,()=>{ee&&clearInterval(ee),Pe.disconnect()},{once:!0}),v.addEventListener(`keydown`,e=>{e.key!==`Enter`||e.shiftKey||e.isComposing||Hd()||(e.preventDefault(),f.requestSubmit())},{signal:e}),y.addEventListener(`click`,()=>ve(pd(re()?.agent)),{signal:e}),g.addEventListener(`click`,()=>_.click(),{signal:e}),_.addEventListener(`change`,()=>{let e=_.files?.[0];if(_.value=``,!e||!x)return;if(b.disabled){ie(`Not attached: the agent is not ready for a message. Check the terminal.`);return}let t=x;O=!0,Ae(),lm(t,e).then(n=>{if(O=!1,Ae(),!n||x!==t)return;let r=e.type.startsWith(`image/`)?URL.createObjectURL(e):null;_e({name:e.name,previewUrl:r})})},{signal:e});function Fe(e){if(x!==e){x=e,S=[],C=0,w=!1,ae(),_e(null),ne.clear();for(let e of k)Tg(e.attachment);k=[],ie(``)}r.hidden=!1,c.hidden=!0,te=!0,he(),Le(),M()}function Ie(){r.hidden=!0,ae(),pe()}function Le(){r.hidden||(ke(),Me(),he())}function Re(e){if(!T||e.requestId!==T.requestId)return!1;let t=T;if(ae(),e.id!==x)return!0;let n=t.after!==null&&e.start===t.after&&!e.reset;return t.after!==null&&!n?(w=!1,S=[],M(),!0):(S=Nd(t.after===null?[...e.records]:[...S,...e.records]),C=e.next,w=!0,he(),E&&M(),!0)}function ze(e){return!T||e.requestId!==T.requestId?!1:(ae(),E=!1,c.hidden=!1,!0)}function Be(e){e!==x||r.hidden||(c.hidden=!0,M())}return{el:r,show:Fe,hide:Ie,refresh:Le,applyTraceResponse:Re,applyTraceError:ze,applyTraceChanged:Be}}function Ag(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function jg(e,t){return e||Ag(t)>0}var Mg={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},Ng=null,Pg=!1,Fg=!1,Ig=null,Lg=null,Rg=null,zg=`—`;function Bg(e){return e==null?zg:Bt(e,`GB`)}function Vg(e){return e==null?zg:h(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function Hg(e){return e==null?zg:`${Vg(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function Ug(){let e=L(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=L(`div`,`health-summary`),n=L(`button`,`health-toggle`);n.type=`button`,n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=L(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,L(`span`,`health-toggle-label`,`Health`));let i=L(`div`,`health-stats`);t.append(n,i);let a=L(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{Fg=!Fg,e.dataset.expanded=String(Fg),n.setAttribute(`aria-expanded`,String(Fg)),a.hidden=!Fg,Fg&&(T({type:`request-health-snapshot`}),Gg())}),e.append(t,a),Ig=e,Lg=i,Rg=a,e}function Wg(){if(!Lg||!Ng)return;let e=Ng,t=Ag(e.anomalies);Lg.innerHTML=`
89
- <span class="health-stat" title="V8 heap used"><span class="health-stat-label">Heap</span> ${Bg(e.process.heapUsed)}</span>
90
- <span class="health-stat" title="Resident set size (process memory)"><span class="health-stat-label">RSS</span> ${Bg(e.process.rss)}</span>
91
- <span class="health-stat" title="External buffers (PTY data lives here)"><span class="health-stat-label">Ext</span> ${Bg(e.process.external)}</span>
87
+ `)?`${Zu}${n}${Qu}`:n,delayBeforeMs:0},{data:`\r`,delayBeforeMs:$u}]:null}function pd(e){return dd(e)?[{data:`\r`,delayBeforeMs:0}]:null}function md(e){return dd(e)?[{data:Xu,delayBeforeMs:0}]:null}function hd(e,t){return e===z.WAITING&&typeof t==`string`&&t!==``}function gd(e,t){return e.uuid??`${e.kind}-${e.ts}-${t}`}function _d(e){return typeof e.agentId==`string`}function vd(e){let t=td.exec(e.trim());if(!t)return null;let[n,r,i]=t[1].split(/[\\/]/).slice(-3);return n!==nd||!r||!i?null:`/upload/${encodeURIComponent(r)}/${encodeURIComponent(i)}`}function yd(e,t){let n=e[e.length-1];n?.kind===`user`&&n.imageUrls.push(t)}function bd(e){if(!e||typeof e!=`object`)return`Agent`;let t=e.description;return typeof t==`string`&&t.trim()?t.trim():`Agent`}function xd(e,t,n){if(!e)return;if(t.isError){e.state=`failed`;return}if(!id.test(t.content)){e.state=`done`;return}let r=cd.exec(t.content)?.[1];r&&n.set(r,e)}function Sd(e){return e.trimStart().startsWith(ad)}function Cd(e,t,n){let r=od.exec(e)?.[1];if(r)return t.get(r);let i=sd.exec(e)?.[1];return i?n.get(i):void 0}function wd(e,t,n){let r=Cd(e,t,n);r?.state===`running`&&(r.state=ld.exec(e)?.[1]===`completed`?`done`:`failed`)}function Td(e){let t=[],n=new Map,r=new Map,i=new Map,a=new Map,o=null;function s(){o&&t.push(o),o=null}function c(e,t){return o??={kind:`work`,key:e,steps:[],agentRuns:[],startedAt:t,endedAt:t},o.endedAt=Math.max(o.endedAt,t),o}return e.forEach((e,o)=>{let l=gd(e,o);if(!_d(e)){if((e.kind===`prompt`||e.kind===`expansion`)&&Sd(e.text))wd(e.text,i,a);else if(e.kind===`prompt`)s(),t.push({kind:`user`,key:l,text:e.text,at:e.ts,imageUrls:[]});else if(e.kind===`expansion`)for(let n of e.text.split(`
88
+ `)){let e=vd(n);e&&yd(t,e)}else if(e.kind===`assistant`){if(!e.text.trim())return;t.push({kind:`assistant`,key:l,text:e.text,at:e.ts})}else if(e.kind===`notice`)t.push({kind:`notice`,key:l,text:e.text,at:e.ts});else if(e.kind===`thinking`)c(l,e.ts);else if(e.kind===`tool_call`){let t=c(l,e.ts),a={isRunning:!0};if(t.steps.push(a),n.set(e.toolUseId,a),r.set(e.toolUseId,t),!rd.has(e.name))return;let o={key:l,description:bd(e.input),state:`running`};t.agentRuns.push(o),i.set(e.toolUseId,o)}else if(e.kind===`tool_result`){let t=n.get(e.toolUseId),o=r.get(e.toolUseId);if(!t||!o)return;t.isRunning=!1,o.endedAt=Math.max(o.endedAt,e.ts),xd(i.get(e.toolUseId),e,a)}}}),s(),t}function Ed(e){return e.flatMap(e=>e.kind===`work`?e.agentRuns.filter(e=>e.state===`running`):[])}function Dd(e){let t=e.at(-1);return t?.kind===`work`?t:null}function Od(e){return new Set(e.flatMap(e=>e.kind===`user`?[e.key]:[]))}function kd(e,t,n){if(n-e.sentAt>ud)return!0;let r=e.text.trim();return t.some(t=>t.kind===`user`&&!e.userKeysAtSend.has(t.key)&&t.text.includes(r))}function Ad(e){return`${e} ${e===1?`agent`:`agents`}`}function jd(e){let t=Math.max(1,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}function Md(e){let t=e.agentRuns.length>0?`, ${Ad(e.agentRuns.length)}`:``;return`Worked ${jd(e.endedAt-e.startedAt)}${t}`}function Nd(e,t){let n=t>0?`${Ad(t)} running`:``;return e===null?n:n?`Working ${jd(e)}, ${n}`:`Working ${jd(e)}`}function Pd(e){return e.length<=ed?e:e.slice(e.length-ed)}var Fd=`(max-width: 768px)`,Id=`(pointer: coarse)`;function Ld({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var Rd=window.matchMedia?.(Id),zd=window.matchMedia?.(Fd);function Bd(){return Ld({coarse:!!Rd?.matches,narrowWidth:!!zd?.matches})}function Vd(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function Hd(){W.subscribe((e,t)=>{t.includes(`layout`)&&Vd(e.layout)});let e=Bd();Vd(e),W.dispatch(`setLayout`,e);let t=()=>W.dispatch(`setLayout`,Bd());return Rd?.addEventListener?.(`change`,t),zd?.addEventListener?.(`change`,t),e}function Ud(){return W.snapshot().layout===`phone`}function Wd(e){return W.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var Gd=`CommitMono`,Kd=[400,700].map(e=>`${e} 14px ${Gd}`),qd=`monospace`;function Jd(e){return e.trim().replace(/^['"]|['"]$/g,``)}function Yd(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>Jd(e)!==Gd);return r.length>0?r.join(`, `):qd}function Xd(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function Zd(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function Qd(){return document.fonts?Kd.every(e=>document.fonts.check(e)):!1}function $d(){return Yd(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),Qd())}function ef(e){document.fonts&&Xd(document.fonts,Kd,e)}var tf=6,nf=262144,rf=16384,af=()=>{};function of(e,t){if(t.length<=rf)e.push(t);else for(let n=0;n<t.length;n+=rf)e.push(t.slice(n,n+rf))}function sf({budget:e=tf,maxChunkBytes:t=nf,requestFrame:n,cancelFrame:r}={}){let i=n||(e=>requestAnimationFrame(e)),a=r||(e=>cancelAnimationFrame(e)),o=new Map,s=[],c=0,l=null;function u(){l===null&&(l=i(h))}function d(e){return e.readIdx<e.pending.length}function f(e){d(e)||(e.pending.length=0,e.readIdx=0,e.dirty=!1)}function p(e){return!!(e?.live&&e.dirty&&!e.inFlight&&d(e))}function m(){for(let e of o.values())if(p(e))return!0;return!1}function h(){l=null;let n=s.length,r=0;for(let i=0;i<n&&r<e;i++){let e=s[(c+i)%n],a=o.get(e);if(!p(a))continue;let l=[],m=0;for(;a.readIdx<a.pending.length;){let e=a.pending[a.readIdx];if(typeof e!=`string`){if(m>0)break;a.readIdx++,e.run();continue}let n=t-m;if(m+e.length<=t)of(l,e),m+=e.length,a.readIdx++;else{m===0&&(of(l,e.slice(0,n)),m+=n,a.pending[a.readIdx]=e.slice(n));break}}let h=l.pop();if(h===void 0)f(a),r++;else{f(a),d(a)&&a.readIdx>=64&&(a.pending.splice(0,a.readIdx),a.readIdx=0),a.inFlight=!0;for(let e of l)a.write(e,af);a.write(h,()=>{a.live&&(a.inFlight=!1,d(a)&&(a.dirty=!0,u()))}),r++}}n>0&&(c=(c+1)%n),m()&&u()}return{register(e,t){let n=o.get(e);n?(n.write=t,n.live=!0):(o.set(e,{write:t,pending:[],readIdx:0,inFlight:!1,dirty:!1,live:!0}),s.push(e))},unregister(e){let t=o.get(e);if(!t)return;t.live=!1,o.delete(e);let n=s.indexOf(e);n!==-1&&s.splice(n,1),c>=s.length&&(c=0)},enqueue(e,t){let n=o.get(e);n&&t&&(n.pending.push(t),n.dirty=!0,u())},enqueueAction(e,t){let n=o.get(e);n&&(n.pending.push({run:t}),n.dirty=!0,u())},has(e){return o.has(e)},size(){return o.size},running(){return l!==null},stop(){l!==null&&(a(l),l=null)}}}var cf=sf(),lf=.3,uf=null;function df(){return hn(uf)}function ff(e){return rr(e,uf)}async function pf(){try{let e=await fetch(Fn,{credentials:`same-origin`,cache:`no-store`});e.ok&&(uf=Tn(await e.json()))}catch{}}function mf(){let e=new AudioContext;return e.state===`suspended`&&e.resume(),e}function hf(e,t){setTimeout(()=>e.close().catch(()=>{}),(t+.1)*1e3)}function gf(e){_f(xn[e]??xn.chime)}function _f(e){let t=mf(),n=t.createGain();n.gain.value=e.peakGain,n.connect(t.destination);let r=t.currentTime,i=0;for(let a of e.tones){let e=r+a.startSeconds,o=e+a.durationSeconds,s=t.createOscillator(),c=t.createGain();s.type=a.waveform,s.frequency.setValueAtTime(a.frequency,e),a.endFrequency&&s.frequency.exponentialRampToValueAtTime(a.endFrequency,o),c.gain.setValueAtTime(.001,e),c.gain.exponentialRampToValueAtTime(a.gain??1,e+.01),c.gain.exponentialRampToValueAtTime(.001,o),s.connect(c),c.connect(n),s.start(e),s.stop(o),i=Math.max(i,a.startSeconds+a.durationSeconds)}hf(t,i)}async function vf(e){try{let t=await fetch(ar(e),{credentials:`same-origin`});return t.ok?await t.arrayBuffer():null}catch{return null}}async function yf(e){let t=await vf(e);if(!t)return!1;let n=mf();try{let e=await n.decodeAudioData(t),r=n.createGain();r.gain.value=lf,r.connect(n.destination);let i=n.createBufferSource();return i.buffer=e,i.connect(r),i.start(),hf(n,e.duration),!0}catch{return n.close().catch(()=>{}),!1}}var bf=[659.25,830.61,987.77,1108.73,987.77,830.61,739.99,659.25,739.99,830.61,987.77,1108.73,987.77,830.61];function xf(){try{let e=new AudioContext;if(e.state===`suspended`&&e.resume(),e.state===`suspended`)return;let t=e.createGain();t.gain.value=.05,t.connect(e.destination);let n=.125,r=e.currentTime;for(let i=0;i<bf.length;i++){let a=r+i*n,o=e.createOscillator(),s=e.createGain();o.type=`square`,o.frequency.value=bf[i],s.gain.setValueAtTime(.001,a),s.gain.exponentialRampToValueAtTime(1,a+.01),s.gain.exponentialRampToValueAtTime(.001,a+n*.9),o.connect(s),s.connect(t),o.start(a),o.stop(a+n)}let i=r+bf.length*n;t.gain.setValueAtTime(.05,i-.05),t.gain.exponentialRampToValueAtTime(.001,i),setTimeout(()=>e.close().catch(()=>{}),(i-r+.1)*1e3)}catch{}}function Sf(){try{gf(Nn)}catch{}}function Cf(e){try{let t=ff(e),n=$n(t);if(!n){gf(t);return}yf(n).then(e=>{e||Sf()})}catch{}}var wf={"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.06)`,"--state-running":`#22c55e`,"--state-running-bg":`rgba(34, 197, 94, 0.06)`,"--state-waiting":`#f59e0b`,"--state-waiting-bg":`rgba(245, 158, 11, 0.08)`,"--state-failed":`#ef4444`,"--state-failed-bg":`rgba(239, 68, 68, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#eab308`,"--state-idle-bg":`rgba(234, 179, 8, 0.06)`},Tf={background:`--bg-card`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#ef4444`,brightRed:`#f87171`,green:`#22c55e`,brightGreen:`#4ade80`,yellow:`#eab308`,brightYellow:`#facc15`,cyan:`#06b6d4`,brightCyan:`#22d3ee`},Ef={golgari:{label:`Golgari (Green/Black)`,colors:{"--bg":`#060b08`,"--bg-card":`#0a120e`,"--bg-header":`#081009`,"--bg-surface":`#0e1a12`,"--border":`#1a2e1f`,"--border-dim":`#122016`,"--border-hover":`#2a4a32`,"--text":`#b8ccbe`,"--text-dim":`#6a9070`,"--text-head":`#dceede`,"--text-muted":`#7a9a80`,"--accent":`#2dd4a0`,"--accent-dim":`#1a9a6e`,...wf,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#94a3b8`,"--state-done-bg":`rgba(45, 212, 160, 0.06)`,"--state-starting":`#a78bfa`,"--state-starting-bg":`rgba(167, 139, 250, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...Tf,foreground:`#c8dece`,blue:`--accent`,brightBlue:`#5ee8bc`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8dece`,brightWhite:`#e8f5ea`}},midnight:{label:`Midnight (Blue/Purple)`,colors:{"--bg":`#080816`,"--bg-card":`#0e0e20`,"--bg-header":`#0b0b1a`,"--bg-surface":`#131328`,"--border":`#1c1c38`,"--border-dim":`#141430`,"--border-hover":`#2a2a50`,"--text":`#b8b8d4`,"--text-dim":`#8585b3`,"--text-head":`#dcdcf0`,"--text-muted":`#7c7ca9`,"--accent":`#4f6ef7`,"--accent-dim":`#3a54c0`,...wf,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#94a3b8`,"--state-done-bg":`rgba(59, 130, 246, 0.06)`,"--state-starting":`#a855f7`,"--state-starting-bg":`rgba(168, 85, 247, 0.06)`,"--state-complete":`#60a5fa`,"--state-complete-bg":`rgba(96, 165, 250, 0.06)`},terminal:{...Tf,foreground:`#c8c8e0`,blue:`--accent`,brightBlue:`#60a5fa`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8c8e0`,brightWhite:`#e8e8ff`}},phyrexian:{label:`Phyrexian (Iridescent)`,colors:{"--bg":`#0a0810`,"--bg-card":`#100e18`,"--bg-header":`#0c0a14`,"--bg-surface":`#16122a`,"--border":`#2a2440`,"--border-dim":`#1e1a32`,"--border-hover":`#3e3660`,"--text":`#c8c0e0`,"--text-dim":`#8d82b9`,"--text-head":`#e8e0ff`,"--text-muted":`#8579b1`,"--accent":`#c084fc`,"--accent-dim":`#9656d6`,...wf,"--state-monitoring":`#60a5fa`,"--state-monitoring-bg":`rgba(96, 165, 250, 0.08)`,"--state-done":`#67e8f9`,"--state-done-bg":`rgba(103, 232, 249, 0.06)`,"--state-starting":`#f472b6`,"--state-starting-bg":`rgba(244, 114, 182, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...Tf,foreground:`#c8c0e0`,blue:`#67e8f9`,brightBlue:`#a5f3fc`,magenta:`--accent`,brightMagenta:`#d8b4fe`,white:`#c8c0e0`,brightWhite:`#e8e0ff`}},compleated:{label:`Compleated (Light)`,colors:{"--bg":`#ece8e0`,"--bg-card":`#f7f4ee`,"--bg-header":`#f0ece4`,"--bg-surface":`#e4e0d6`,"--border":`#b8b0a0`,"--border-dim":`#ccc6b8`,"--border-hover":`#908878`,"--text":`#2a2622`,"--text-dim":`#5a5448`,"--text-head":`#0e0c0a`,"--text-muted":`#676157`,"--accent":`#0e0c0a`,"--accent-dim":`#2a2622`,"--state-running":`#16803c`,"--state-running-bg":`rgba(22, 128, 60, 0.08)`,"--state-waiting":`#b45309`,"--state-waiting-bg":`rgba(180, 83, 9, 0.08)`,"--state-failed":`#dc2626`,"--state-failed-bg":`rgba(220, 38, 38, 0.06)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#64748b`,"--state-done-bg":`rgba(26, 24, 22, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#a16207`,"--state-idle-bg":`rgba(161, 98, 7, 0.06)`,"--state-starting":`#7c3aed`,"--state-starting-bg":`rgba(124, 58, 237, 0.06)`,"--state-complete":`#059669`,"--state-complete-bg":`rgba(5, 150, 105, 0.06)`},terminal:{background:`#faf8f4`,foreground:`#1a1816`,cursor:`#1a1816`,cursorAccent:`#faf8f4`,black:`#1a1816`,brightBlack:`#5a5448`,red:`#b91c1c`,brightRed:`#dc2626`,green:`#15803d`,brightGreen:`#16a34a`,yellow:`#92400e`,brightYellow:`#a16207`,blue:`#1d4ed8`,brightBlue:`#2563eb`,magenta:`#6d28d9`,brightMagenta:`#7c3aed`,cyan:`#0e7490`,brightCyan:`#0891b2`,white:`#5a5448`,brightWhite:`#3a3630`}},unicorn:{label:`Rainbow Unicorns (Dark)`,colors:{"--bg":`#191022`,"--bg-card":`#201730`,"--bg-header":`#1c1329`,"--bg-surface":`#281c3c`,"--border":`#3a2c52`,"--border-dim":`#2a2040`,"--border-hover":`#55407a`,"--text":`#d4c8e6`,"--text-dim":`#9a88b8`,"--text-head":`#ede4fa`,"--text-muted":`#a897c4`,"--accent":`#e8a3c4`,"--accent-dim":`#c4739e`,"--state-running":`#42d780`,"--state-running-bg":`rgba(66, 215, 128, 0.10)`,"--state-waiting":`#f79f3b`,"--state-waiting-bg":`rgba(247, 159, 59, 0.10)`,"--state-failed":`#f05442`,"--state-failed-bg":`rgba(240, 84, 66, 0.13)`,"--state-monitoring":`#2dd4bf`,"--state-monitoring-bg":`rgba(45, 212, 191, 0.08)`,"--state-done":`#f04ca4`,"--state-done-bg":`rgba(240, 76, 164, 0.13)`,"--state-initializing":`#8f87a6`,"--state-initializing-bg":`rgba(143, 135, 166, 0.08)`,"--state-idle":`#bcb02f`,"--state-idle-bg":`rgba(188, 176, 47, 0.08)`,"--state-starting":`#a17ef1`,"--state-starting-bg":`rgba(161, 126, 241, 0.08)`,"--state-complete":`#34baf4`,"--state-complete-bg":`rgba(52, 186, 244, 0.14)`},terminal:{background:`#201730`,foreground:`#d4c8e6`,cursor:`--accent`,cursorAccent:`#201730`,black:`#8c7dab`,brightBlack:`#9c8fb5`,red:`#e8887e`,brightRed:`#f4a89f`,green:`#86e0ab`,brightGreen:`#a3edc0`,yellow:`#f0c674`,brightYellow:`#f5d896`,blue:`#9cb3f0`,brightBlue:`#b5c8f5`,magenta:`#dd8ecf`,brightMagenta:`#e6a8dc`,cyan:`#7fd4d0`,brightCyan:`#a0e6e2`,white:`#d4c8e6`,brightWhite:`#f4ecfc`}},"posthog-light":{label:`PostHog (Light)`,colors:{"--bg":`#eeefe9`,"--bg-card":`#fdfdf8`,"--bg-header":`#eeefe9`,"--bg-surface":`#e5e7e0`,"--border":`#bfc1b7`,"--border-dim":`#d2d3cc`,"--border-hover":`#9ea096`,"--text":`#23251d`,"--text-dim":`#65675e`,"--text-head":`#111111`,"--text-muted":`#73756b`,"--accent":`#c03300`,"--accent-dim":`#8e2600`,"--state-running":`#237a36`,"--state-running-bg":`rgba(77, 117, 51, 0.08)`,"--state-waiting":`#b17816`,"--state-waiting-bg":`rgba(177, 120, 22, 0.10)`,"--state-failed":`#8c0d3b`,"--state-failed-bg":`rgba(140, 13, 59, 0.07)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#3e6b9e`,"--state-done-bg":`rgba(62, 107, 158, 0.08)`,"--state-initializing":`#73756b`,"--state-initializing-bg":`rgba(115, 117, 107, 0.07)`,"--state-idle":`#835c19`,"--state-idle-bg":`rgba(131, 92, 25, 0.07)`,"--state-starting":`#a621c8`,"--state-starting-bg":`rgba(166, 33, 200, 0.07)`,"--state-complete":`#34796f`,"--state-complete-bg":`rgba(52, 121, 111, 0.08)`},terminal:{background:`--bg-card`,foreground:`#23251d`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`#23251d`,brightBlack:`#65675e`,red:`#c03300`,brightRed:`#df6133`,green:`#4d7533`,brightGreen:`#6aa84f`,yellow:`#835c19`,brightYellow:`#b17816`,blue:`#3e6b9e`,brightBlue:`#2f80fa`,magenta:`#74108d`,brightMagenta:`#a621c8`,cyan:`#34796f`,brightCyan:`#30abc6`,white:`#4d4f46`,brightWhite:`#23251d`}},"posthog-dark":{label:`PostHog (Dark)`,colors:{"--bg":`#1e1f23`,"--bg-card":`#25262b`,"--bg-header":`#232429`,"--bg-surface":`#2d2e37`,"--border":`#3e424f`,"--border-dim":`#32343f`,"--border-hover":`#626674`,"--text":`#edeef4`,"--text-dim":`#aeb3c2`,"--text-head":`#fafafa`,"--text-muted":`#9ea096`,"--accent":`#f87a4c`,"--accent-dim":`#f54e00`,"--state-running":`#36c46f`,"--state-running-bg":`rgba(54, 196, 111, 0.08)`,"--state-waiting":`#f7a501`,"--state-waiting-bg":`rgba(247, 165, 1, 0.09)`,"--state-failed":`#f35454`,"--state-failed-bg":`rgba(243, 84, 84, 0.09)`,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#589df8`,"--state-done-bg":`rgba(88, 157, 248, 0.08)`,"--state-initializing":`#8f8f8c`,"--state-initializing-bg":`rgba(143, 143, 140, 0.07)`,"--state-idle":`#ffce5c`,"--state-idle-bg":`rgba(255, 206, 92, 0.07)`,"--state-starting":`#8567ff`,"--state-starting-bg":`rgba(133, 103, 255, 0.09)`,"--state-complete":`#29dbbb`,"--state-complete-bg":`rgba(41, 219, 187, 0.08)`},terminal:{background:`--bg-card`,foreground:`#edeef4`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#f35454`,brightRed:`#f87a4c`,green:`#36c46f`,brightGreen:`#96e5b6`,yellow:`#f7a501`,brightYellow:`#ffce5c`,blue:`#2f80fa`,brightBlue:`#9fc4ff`,magenta:`#8567ff`,brightMagenta:`#e2d6ff`,cyan:`#30abc6`,brightCyan:`#29dbbb`,white:`#aeb3c2`,brightWhite:`#fafafa`}}},Df=`phyrexian`,Of=null;function kf(e){let t=Ef[e];if(!t)return;let n=Of;Of=e;let r=document.documentElement;r.dataset.theme=e;for(let[e,n]of Object.entries(t.colors))r.style.setProperty(e,n);e===`unicorn`&&n!==null&&n!==`unicorn`&&xf()}function Af(e){document.documentElement.toggleAttribute(`data-show-usage`,e)}function jf(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function Mf(){let e=Ef[Of||Df];if(!e)return{};let t=getComputedStyle(document.documentElement),n={};for(let[r,i]of Object.entries(e.terminal))n[r]=i.startsWith(`--`)?t.getPropertyValue(i).trim():i;return n}function Nf(){return Object.entries(Ef).map(([e,t])=>({id:e,label:t.label}))}var Pf=i().int().min(1).max(500),Ff=i().int().min(1).max(200);s(`type`,[u({type:l(`input`),data:a()}),u({type:l(`claim`),cols:Pf,rows:Ff}),u({type:l(`unview`)}),u({type:l(`pause-output`)}),u({type:l(`resume-output`)})]);var If=u({type:l(`pty-size`),cols:Pf,rows:Ff,seq:i().int().nonnegative()}),Lf=u({type:l(`output-beat`)}),Rf=s(`type`,[If,Lf]),zf=`history`,Bf=`output`,Vf=`paused`;o([`screen`,`deep`]);function Hf(e){try{return JSON.parse(e)}catch{return null}}function Uf(e){let t=Rf.safeParse(Hf(e));return t.success?t.data:null}function Wf(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function Gf(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function Kf(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function qf({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&Wf(e,n))}function Jf({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function Yf({isBorrowedCard:e,isTerminalFaceShown:t}){return!e||!t}function Xf({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function Zf(e,t,n){let r=new URLSearchParams;t&&r.set(zf,`deep`),n&&r.set(Bf,Vf);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function Qf({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:qf({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function $f({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function ep({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!Wf(e,t),s=Gf(n)?Kf(n):null,c=r&&!!s&&!Wf(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:qf({authoritative:e,isActiveViewer:r,lastClaim:a})}}function tp(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function np(e){let t=tp(e);return t===null?null:Uf(t)}function rp(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=np(e);return n?n.type===`output-beat`?{kind:`beat`}:t.hasSeenSize?n.seq<=t.lastSeq?{kind:`stale`}:{kind:`size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`attach-size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`ignored`}}var ip=``,ap=`\x1B`,op=`\r`,sp=new Map([[`deleteContentBackward`,ip],[`deleteByComposition`,ip],[`deleteCompositionText`,ip],[`deleteWordBackward`,ap],[`deleteSoftLineBackward`,ap],[`deleteHardLineBackward`,ap]]);function cp(e){return sp.get(e)??``}var lp=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function up(e){return typeof e!=`string`||e===``||!lp.has(e)}function dp(e){return e?e.keyCode===229||e.key===`Process`:!1}function fp(e,t){let n=Array.from(e??``),r=Array.from(t??``),i=Math.min(n.length,r.length),a=0;for(;a<i&&n[a]===r[a];)a++;return ip.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,op)}var pp=/https?:\/\/[^\s<>"']+/g,mp=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),hp={")":`(`,"]":`[`,"}":`{`};function gp(e,t){let n=0;for(let r of e)r===t&&n++;return n}function _p(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(mp.has(t)){e=e.slice(0,-1);continue}let n=hp[t];if(n&&gp(e,n)<gp(e,t))e=e.slice(0,-1);else return e}}function vp(e){let t=[];for(let n of e.matchAll(pp)){let e=_p(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var yp=50;function bp(){return{activate(e,t){sc(t)},allowNonHttpProtocols:!1}}function xp(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<yp;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<yp;)r++;let i=``,a=[];for(let t=n;t<=r;t++){let n=e.getLine(t);if(!n)break;for(let e=0;e<n.length;e++){let r=n.getCell(e);if(!r)break;if(r.getWidth()===0)continue;let o=r.getChars()||` `;for(let n=0;n<o.length;n++)i+=o[n],a.push({x:e+1,y:t+1})}}return{text:i,cellAt:a}}function Sp(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=xp(r,t),o=[];for(let{start:e,end:t,url:n}of vp(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){sc(t)}})}n(o.length?o:void 0)}})}var Cp=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,wp=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,Tp=`[^\\S\\r\\n]`,Ep=`${Cp}${Tp}*(?:=>|[:=])${Tp}*`,Dp=`[?&][A-Za-z0-9_.-]*`,Op=`[^\\r\\n;&|]{0,200}?`,kp=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,Ap=RegExp(`(${Ep})${wp}`,`gi`),jp=RegExp(`(\\bBearer${Tp}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),Mp=[/\bAKIA[0-9A-Z]{16}\b/g,/\bgh[pousr]_[A-Za-z0-9]{16,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{20,}/g,/\bsk-[A-Za-z0-9_-]{20,}/g,/\bph[cx]_[A-Za-z0-9]{20,}\b/g,/\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g,/\beyJ[A-Za-z0-9_=-]{6,}\.[A-Za-z0-9_=-]{6,}\.[A-Za-z0-9_=-]{4,}/g,/-----BEGIN(?:[A-Z0-9 ]+)? PRIVATE KEY-----/g],Np=[RegExp(`((?:^|\\s)--?${Cp}${Tp}+)${wp}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${Tp}*=?${Tp}*)${wp}`,`g`),RegExp(`(-AsPlainText${Tp}+)${wp}`,`gi`),RegExp(`((?:^|\\s)setx${Tp}+[^\\s\\r\\n]*${Cp}[^\\s\\r\\n]*${Tp}+)${wp}`,`gi`)],Pp=[RegExp(`(\\bauthorization${Tp}*:${Tp}*Basic${Tp}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${Tp}+login\\b${Op}${Tp}-p(?:${Tp}+|=))${wp}`,`gi`),RegExp(`(\\bcurl\\b${Op}${Tp}(?:--user|-u)(?:${Tp}+|=)[^\\s:\\r\\n]+:)${wp}`,`gi`),RegExp(`(\\b${kp}\\b${Op}${Tp}-p)${wp}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi];[...Np,...Pp];var Fp=[/-----END(?:[A-Z0-9 ]+)? PRIVATE KEY-----/g,/^([^\S\r\n]*)(?=[A-Za-z0-9+/]*[g-zG-Z+/])(?=[A-Za-z0-9+/=]{60,76}[^\S\r\n]*$)[A-Za-z0-9+/]+={0,2}(?=[^\S\r\n]*$)/gm],Ip=RegExp(`(${Dp}(?:${Cp}|_key)=)[^&#\\s]+`,`gi`),Lp=[Ap,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${wp}`,`g`)],Rp=[jp,...Np,...Pp,...Mp,...Fp];function zp(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function Bp(e,t){let n=0;return e.filter(e=>{for(;n<t.length&&t[n].end<=e.matchStart;)n+=1;let r=t.at(n);return!r||e.matchStart<r.matchStart})}function Vp(e){let t=[];for(let n of e.toSorted((e,t)=>e.start-t.start)){let e=t.at(-1);e&&n.start<=e.end?e.end=Math.max(e.end,n.end):t.push({...n})}return t}function Hp(e){let t=zp(e,Ip);return Vp([...t,...Lp.flatMap(n=>Bp(zp(e,n),t)),...Rp.flatMap(t=>zp(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var Up=`#808080`,Wp=new WeakMap;function Gp(e,t,n){return`${e}:${t}:${n}`}function Kp(e){return Gp(e.marker.line,e.x,e.width)}function qp(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function Jp(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function Yp(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function Xp(e,t,n,r){let i=``,a=[];for(let o=t;o<=n;o++){let t=e.getLine(o);if(!t)break;for(let e=0;e<t.length;e++){let n=t.getCell(e,r);if(!n)break;let s=n.getWidth();if(s===0)continue;let c=n.getChars()||` `;for(let t=0;t<c.length;t++)i+=c[t],a.push({line:o,x:e,width:s})}}return{text:i,cellAt:a}}function Zp(e,t){let n=null;for(let r of t)n&&n.line===r.line?n.width=Math.max(n.width,r.x+r.width-n.x):(n={line:r.line,x:r.x,width:r.width},e.push(n))}function Qp(e,t,n,r){let i=[];if(Hp(Yp(e,t,n)).length===0)return i;let{text:a,cellAt:o}=Xp(e,t,n,r);for(let e of Hp(a))Zp(i,o.slice(e.start,e.end));return i}function $p(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=Jp(e,i);r.push(...Qp(e,i,t,n)),i=t+1}return r}function em(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function tm(e){e.decoration.dispose(),e.marker.dispose()}function nm(e){for(let t of e.masks)tm(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function rm(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function im(e){let t=0;for(;t<e.masks.length&&e.masks[t].marker.isDisposed;)e.masks[t].decoration.dispose(),t++;t>0&&e.masks.splice(0,t)}function am(e,t){let n=new Map,r=e.masks.at(-1);for(;r&&(r.marker.isDisposed||r.marker.line>=t);)e.masks.pop(),r.marker.isDisposed&&r.decoration.dispose(),r.marker.isDisposed||n.set(Kp(r),r),r=e.masks.at(-1);return im(e),n}function om(e,t){let n={normal:em(),alternate:em()},r=e.cols;function i(t){return e.buffer.active.type===t}function a(t,n){if(!i(n)||t.isDisposed)return!1;let r=t.line-e.buffer.active.viewportY;return r>=0&&r<e.rows}function o(t,n,r){t.style.backgroundColor=e.options.theme?.foreground??Up,t.style.pointerEvents=`none`,t.style.display=a(n,r)?`block`:`none`}function s(e){for(let t of n[e].masks){let n=t.decoration.element;n&&o(n,t.marker,e)}}function c(t,n){let r=e.registerMarker(t.line-(n.baseY+n.cursorY));if(!r)return null;let i=e.registerDecoration({marker:r,x:t.x,width:t.width,layer:`top`});if(!i)return r.dispose(),null;let a=n.type;return i.onRender(e=>o(e,r,a)),{marker:r,decoration:i,x:t.x,width:t.width}}function l(){if(!$o())return;let t=e.buffer.active,r=n[t.type],i=qp(t,rm(r,t)),a=am(r,i);for(let e of $p(t,i)){let n=Gp(e.line,e.x,e.width),i=a.get(n);a.delete(n);let o=i??c(e,t);o&&r.masks.push(o)}for(let e of a.values())tm(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){nm(n.normal),nm(n.alternate)}function d(){u(),r=e.cols,l()}let f=[e.onWriteParsed(l),e.onResize(({cols:e})=>{e!==r&&(r=e,n.normal.isFullRescanOwed=!0,n.alternate.isFullRescanOwed=!0,l())}),e.buffer.onBufferChange(e=>{nm(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=ts(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),Wp.delete(e)},{once:!0}),Wp.set(e,d)}function sm(e){Wp.get(e)?.()}function cm({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var lm=`Upload`;async function um(e,t){return gr(lm,e),fm(e,t)}async function dm(e,t){gr(lm,e);for(let n of t)await fm(e,n)}async function fm(e,t){let n={"x-glimmervoid-upload-name":encodeURIComponent(t.name)};t.type&&(n[`content-type`]=t.type);try{let r=await fetch(`/upload/${encodeURIComponent(e)}`,{method:`POST`,body:t,headers:n});return r.ok?!0:(_r({source:lm,sessionId:e,message:await pm(r,t.name)}),!1)}catch{return _r({source:lm,sessionId:e,message:`${t.name} was not uploaded because the server did not answer. Check that Glimmervoid is running, then drop the file again.`}),!1}}async function pm(e,t){try{let n=await e.json();if(n&&typeof n.error==`string`)return`${t} was not uploaded: ${n.error.replace(/\.$/,``)}. Fix that, then drop the file again.`}catch{}return`${t} was not uploaded (HTTP ${e.status}). Drop the file again, or check the Glimmervoid terminal for errors.`}var mm=10,hm=1.2,gm=.005,_m=4,vm=.08,ym=5;function bm(e,t){let n=Math.abs(t);return n<mm?!1:n>Math.abs(e)*hm}function xm(e,t,n=1/0){if(!(t>0))return{scrollLines:0,remainderPx:e};let r=Math.trunc(e/t),i=Math.max(-n,Math.min(n,r));return{scrollLines:i===0?0:-i,remainderPx:e-i*t}}function Sm(e,t,n){let r=e.length>=_m?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function Cm(e){if(!e||e.length<2)return 0;let t=e[0],n=e[e.length-1],r=n.timestampMs-t.timestampMs;if(!(r>0))return 0;let i=(n.positionPx-t.positionPx)/r,a=Math.abs(i);if(!(a>=vm))return 0;let o=Math.min(a,ym);return i<0?-o:o}function wm({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function Tm(e,t){if(!e)return{scrollLines:0,state:null};let n=t-e.lastMs;if(!(n>0))return{scrollLines:0,state:e};let r=Math.abs(e.velocityPxPerMs)-gm*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=xm(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function Em(e,t){return e===`alternate`||!!t&&t!==`none`}function Dm(e,t){return!(e>0)||!(t>0)?0:e/t}var Om=1;function km(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function Am(e,t){for(let n of e)if(n.identifier===t)return n;return null}function jm(e,t){if(km(t))return;let n=()=>document.documentElement.dataset.layout===`phone`,r=null,i=0,a=0,o=0,s=!1,c=0,l=[],u=null,d=null,f=()=>{d!==null&&cancelAnimationFrame(d),d=null,u=null},p=()=>Em(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return Dm(e?.clientHeight||t.element?.clientHeight||0,t.rows)},h=()=>{r=null,s=!1,c=0,l=[]},g=(e,n,r)=>{let i=e<0?-1:1;for(let a=0;a<Math.abs(e);a++)t.element?.dispatchEvent(new WheelEvent(`wheel`,{deltaY:i,deltaMode:Om,clientX:n,clientY:r,bubbles:!0,cancelable:!0}))},_=()=>{if(d=null,!u)return;if(!e.isConnected||!n()||p()){f();return}let r=t.buffer?.active?.viewportY,{scrollLines:i,state:a}=Tm(u,performance.now());u=a,i!==0&&t.scrollLines(i),u&&(i!==0&&t.buffer?.active?.viewportY===r?f():d=requestAnimationFrame(_))},v=(e,t,n)=>{u=wm({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:m(),pendingPx:n}),u&&(d=requestAnimationFrame(_))};e.addEventListener(`touchstart`,e=>{if(f(),!n()||e.touches.length!==1){h();return}let t=e.touches[0];r=t.identifier,i=t.clientX,a=t.clientY,o=t.clientY,s=!1,c=0,l=[]},{passive:!0}),e.addEventListener(`touchmove`,e=>{if(r===null||!n())return;let u=Am(e.touches,r);if(!u)return;if(!s){if(!bm(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=Sm([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=Sm(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=xm(c,m(),d?8:void 0);c=h,f!==0&&(d?g(f,u.clientX,u.clientY):t.scrollLines(f))},{passive:!1}),e.addEventListener(`touchend`,e=>{if(!s||p()){h();return}l=Sm(l,o,e.timeStamp);let t=Cm(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function Mm(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function Nm(e,t,n=[]){let r=new Set(Array.isArray(n)?n:[n]),i=[];for(let n of e)e.length-i.length>=t&&!r.has(n)&&i.push(n);return i}var Pm=`modulepreload`,Fm=function(e){return`/`+e},Im={},Lm=function(e){return e.pathname.endsWith(`.css`)},Rm=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},zm=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Fm(t,n);let r=s(t),i=Lm(r);return Rm(Im,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Pm,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Bm=null,Vm=null;function Hm(){return Bm}function Um(){return Bm?Promise.resolve(Bm):(Vm??=Promise.all([zm(()=>import(`./xterm-BdQ2Kshh.js`).then(e=>e.t),[]),zm(()=>import(`./xterm-BdQ2Kshh.js`).then(e=>e.r),[]),zm(()=>import(`./xterm-BdQ2Kshh.js`).then(e=>e.n),[])]).then(([e,t,n])=>(Bm={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},Bm)).catch(e=>{throw Vm=null,e}),Vm)}var Wm=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,Gm=new Map;function Km(e){return e.clientWidth>0&&e.clientHeight>0}function qm(e){let t=e.webglAddon;if(!t)return;let n=[...e.term?.element?.querySelectorAll(`canvas`)??[]];e.webglAddon=null;try{t.dispose()}catch{}for(let e of n)e.getContext(`webgl2`)?.getExtension(`WEBGL_lose_context`)?.loseContext()}function Jm(e){Gm.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,qm(e)}function Ym(e){let t=[e],n=W.snapshot().borrowedCardId,r=n?H.get(n):void 0;r&&t.push(r);for(let e of Nm([...Gm.keys()],Wm,t))Jm(e),e.needsWebGLReload=!0}function Xm(e){e?.term&&Mm({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:Km(e.termWrap)})&&th(e,{isForced:!0})}function Zm(){for(let e of Gm.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{Jm(e),e.needsWebGLReload=!0}}}var Qm=!1;function $m(){Qm||(Qm=!0,requestAnimationFrame(()=>{Qm=!1,Zm()}))}function eh(e){e?.addEventListener(`contextrestored`,$m)}function th(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){Gm.delete(e),Gm.set(e,!0);return}e.webglAddon&&(qm(e),Gm.delete(e));let n=Hm();if(!n)return;Ym(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,Gm.delete(e),e.needsWebGLReload=!0});let i=e.term;if(!i)throw Error(`webgl: the terminal was disposed before the addon loaded`);i.loadAddon(r),r.onChangeTextureAtlas(eh),r.onAddTextureAtlasCanvas(eh),eh(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!Km(e.termWrap),Gm.set(e,!0),requestAnimationFrame(()=>{e.webglAddon===r&&e.term&&e.term.refresh(0,e.term.rows-1)})}catch{e.webglAddon=null,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,Gm.delete(e)}}function nh(e){let t=Dn(e,Pa,{isTerminalFocused:!0},La());return t?Cn(t,document.body.dataset.activeView):!1}var rh=1024,ih=250,ah=`(max-width: 768px)`,oh=12,sh=14,ch=5e4,lh=!1;function uh(e){lh=e}var dh=!1;window.addEventListener(`blur`,()=>{dh=!0}),window.addEventListener(`focus`,()=>{dh=!1});function fh(e){let t=document.activeElement;return Jf({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:dh,isPhoneLayout:Ud()})}function ph(e,t){return Yf({isBorrowedCard:W.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var mh=new WeakMap,hh=new WeakMap,gh=new WeakSet,_h=new WeakSet,vh=new WeakMap,yh=5e3,bh=15e3,xh=`Keys you type now are held and sent once the terminal reconnects.`,Sh=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,Ch=`The agent copied text. The browser needs a click before it can reach your clipboard.`,wh=`The clipboard is unavailable in this browser.`;function Th(e,t,n,r){let i=vh.get(e);i&&(i.clearTimerId!==null&&clearTimeout(i.clearTimerId),i.clearTimerId=null,i.shownKind=t,i.status.show(n,r),n!==`busy`&&(i.clearTimerId=setTimeout(()=>Eh(e,t),n===`ok`?yh:bh)))}function Eh(e,t){let n=vh.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function Dh(e){let t=e.buffer.active;return t.viewportY<t.baseY}function Oh(e,t,{hasNewOutput:n=!1}={}){let r=vh.get(e)?.jumpToLatestButton;if(!r)return;let i=Dh(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function kh(e,t){if(mh.has(e)||!Dh(t))return;let n=t.buffer.active,r=n.length-n.viewportY;gh.has(e)?mh.set(e,r):hh.set(e,r)}function Ah(e,t,n){let r=e.term;r&&Xf({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:gh.has(e)})&&(gh.add(e),_h.add(e),mh.set(e,r.buffer.active.length-n),rg(t))}var jh=new WeakMap;function Mh(e,t){return document.visibilityState===`visible`&&!ph(e,t)}function Nh(e,t){let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=Mh(e,t);jh.get(n)!==r&&(jh.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function Ph(){for(let[e,t]of H)Nh(t,e)}document.addEventListener(`visibilitychange`,Ph),W.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&Ph()});function Fh(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new TextDecoder().decode(n)}function Ih(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),Th(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function Lh(e,t,n,r){let i=Ft(t);i?i.then(()=>{r&&Th(e,`clipboard`,`ok`,r)}).catch(t=>Ih(e,n,t)):Th(e,`clipboard`,`error`,wh)}function Rh(e,t){let n=vh.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function zh(e){let t=vh.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,Lh(e,n,`osc52 write`,`Copied to the clipboard.`))}function Bh(e,t,n){let r=pr(`terminal-notice`),i=L(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=L(`button`,`btn-dialog btn-dialog-confirm`,`Copy to clipboard`);a.type=`button`,a.addEventListener(`click`,()=>zh(t)),i.append(L(`span`,`terminal-clipboard-prompt-text`,Ch),a);let o=L(`div`,`terminal-notices`);o.append(i,r.element);let s=L(`button`,`terminal-jump-latest btn-dialog btn-dialog-ghost`,`Jump to latest`);s.type=`button`,s.hidden=!0,s.addEventListener(`click`,()=>{n.scrollToBottom(),n.focus()});let c=L(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(L(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),vh.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatestButton:s})}function Vh(e,t){return H.get(e)===t&&!t.dataWs}function Hh(e){return e.querySelector(`:scope > .terminal-connecting`)}function Uh(e){if(Hh(e))return;let t=L(`div`,`terminal-connecting`);t.append(L(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}function Wh(e){let t=Hh(e);if(!t)return;t.querySelector(`:scope > .terminal-connecting-animal`)?.remove();let n=si();n&&t.prepend(oi(n,`terminal-connecting-animal`))}var Gh=new Set,Kh=new WeakSet;function qh(e){return Gh.add(e),()=>Gh.delete(e)}function Jh(){let e=0;for(let[t,n]of H)n.card.dataset.link===`connecting`&&Mh(n,t)&&e++;return e}function Yh(e){let t=cm({hasTerminal:e.term!==null||Kh.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:$h}),n=t===`connecting`&&!$h&&_h.has(e)?`live`:t;if(n===`none`){delete e.card.dataset.link,Xh();return}let r=n===`connecting`&&e.card.dataset.link!==`connecting`;e.card.dataset.link=n,r&&Wh(e.termWrap),Xh()}function Xh(){for(let e of Gh)e()}function Zh(e,t,n,r){kh(t,n),cf.unregister(e),t.dataWs=null,Yh(t),t._resetGridClaim?.(),setTimeout(()=>{Vh(e,t)&&be().catch(()=>{}).then(()=>{Vh(e,t)&&Qh(e,t,n)})},r)}function Qh(e,t,n){let r=mh.get(t);mh.delete(t);let i=hh.get(t);hh.delete(t);let a=r!==void 0,o=r??i,s=!1,c=Mh(t,e),l=M(location,A(Zf(e,a,!c))),u=new WebSocket(l);jh.set(u,c),u.binaryType=`arraybuffer`,t.dataWs=u,Yh(t);let d=!1,f={hasSeenSize:!1,lastSeq:0};cf.register(e,(e,t)=>n.write(e,t)),u.addEventListener(`message`,r=>{if(t.dataWs!==u)return;let i=rp(r.data,f);if(i.kind===`bytes`){nn(t);let r=s;if(s=!1,cf.enqueue(e,i.data),!r)return;let a=o??0;cf.enqueueAction(e,()=>{n.scrollToLine(Math.max(0,n.buffer.active.length-a))});return}if(i.kind===`beat`){nn(t);return}if(i.kind===`attach-size`){s=o!==void 0,a||gh.delete(t),f.hasSeenSize=!0,f.lastSeq=i.seq,n.reset(),sm(n),t.ptySize={cols:i.cols,rows:i.rows},t._syncGrid?.();return}if(i.kind!==`size`)return;f.lastSeq=i.seq;let c={cols:i.cols,rows:i.rows};cf.enqueueAction(e,()=>{t.ptySize=c,t._syncGrid?.()})}),u.addEventListener(`close`,()=>{if(t.dataWs!==u)return;_h.delete(t),d||ge();let r=fe(t._dataWsRetryAttempt||0);t._dataWsRetryAttempt=(t._dataWsRetryAttempt||0)+1,Zh(e,t,n,r)}),u.addEventListener(`open`,()=>{d=!0,t._dataWsRetryAttempt=0,_h.delete(t),Yh(t),Nh(t,e),t._syncGrid?.({isActivationEdge:!0}),t._retryOwedGridClaim?.(),t._inputQueue?.length&&setTimeout(()=>{t.dataWs===u&&eg(t)},50)})}var $h=!1;function eg(e){let t=e._inputQueue,n=e.dataWs;if(!$h&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,Eh(e,`keys`)}}function tg(){$h=!0;for(let e of H.values())Yh(e)}function ng(){$h=!1;for(let e of H.values())Yh(e),eg(e)}function rg(e){let t=B(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,Zh(e,t,t.term,0),n?.close()}function ig(e,t){let n=e.dataWs;e.dataWs=null,cf.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}function ag(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!$h&&!e._inputQueue?.length&&e.dataWs?.readyState===WebSocket.OPEN)return e.dataWs.send(JSON.stringify({type:`input`,data:t})),!0;if(!e._inputQueue)return!1;let r=e.dataWs?.readyState!==WebSocket.OPEN;return e._inputQueue.length>=rh?(Th(e,`keys`,`error`,Sh),!1):(e._inputQueue.push(t),r&&Th(e,`keys`,`busy`,xh),!0)}function og(e,t,n){let r=window.matchMedia?.(ah).matches?oh:sh,i=new n.Terminal({cursorBlink:lh,fontSize:r,fontFamily:$d(),theme:Mf(),scrollback:ch,allowProposedApi:!0,linkHandler:bp()}),a=new n.FitAddon;i.loadAddon(a),Uh(e),i.open(e),Bh(e,t,i),Sp(i),om(i,t.abortController.signal),t.term=i,t.fitAddon=a,Jm(t);let o=null,s=null,c=!1,l=null,u=null;function d(){s!==null&&(clearTimeout(s),s=null)}function f(){if(!c)return null;let e=t.fitAddon;if(!e)return null;let n=e.proposeDimensions();return n?{cols:n.cols,rows:n.rows}:null}function p(e){if(!c||!fh(t.card)||t.dataWs?.readyState!==WebSocket.OPEN)return!1;t.dataWs.send(JSON.stringify({type:`claim`,cols:e.cols,rows:e.rows})),l=e,u=null;let n=qf({authoritative:t.ptySize??null,isActiveViewer:c,lastClaim:l});return t.card.dataset.grid=n?`following`:`exact`,!0}function m(e){d(),u=e,s=setTimeout(()=>{s=null,p(e)},ih)}function h(){u&&s===null&&p(u)}function g({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=ep({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:f(),isActiveViewer:c,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});r.resizeTo&&n.resize(r.resizeTo.cols,r.resizeTo.rows),t.card.dataset.grid=r.isFollowing?`following`:`exact`,r.keepsPendingSettle||(d(),u=null),r.sendUnview?(l=null,t.dataWs?.send(JSON.stringify({type:`unview`}))):r.owedClaim&&(e&&p(r.owedClaim)||m(r.owedClaim))}function _(){let e=Qf({authoritative:t.ptySize??null,isActiveViewer:c,isDocumentEngaged:fh(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});e!==`none`&&(d(),e===`rebid`&&(l=null),g({isActivationEdge:!0}))}let v=new ResizeObserver(()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,g()}))});v.observe(e),t.resizeObserver=v,t._syncGrid=g,t._resetGridClaim=()=>{d(),u=$f({isActiveViewer:c,lastClaim:l,owedClaim:u}),l=null},t._retryOwedGridClaim=h,t._syncGridOnEngagementEdge=_,t._isActiveViewer=()=>c,t._setActiveViewer=e=>{c!==e&&(c=e,d(),u=null,e&&Xm(t),g({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{dh=!1,_()},{signal:t.abortController.signal}),th(t);let y=null;i.onScroll(()=>{y===null&&(y=requestAnimationFrame(()=>{y=null,t.term&&(t.term.refresh(0,t.term.rows-1),Oh(t,t.term))}))}),i.onWriteParsed(()=>Oh(t,i,{hasNewOutput:!0})),i.parser.registerOscHandler(52,e=>{let n=e.indexOf(`;`);if(n<0)return!0;let r=e.slice(n+1);if(r===``||r===`?`)return!0;let i;try{i=Fh(r)}catch(e){return Ih(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(Lh(t,i,`osc52 write`),!0):(Rh(t,i),!0)}),i.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;if(nh(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),Lh(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(ag(t,`\x1B`),!1):!0}),sg(e,i,t),jm(e,i)}function sg(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,Ud()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=fp(i,r.value);return i=r.value,e!==``&&(ag(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{Ud()?n(e):a()},!0)};c(`keydown`,e=>{dp(e)?e.stopPropagation():(s(),queueMicrotask(o))}),c(`compositionstart`,e=>{e.stopPropagation()}),c(`compositionupdate`,e=>{e.stopPropagation()}),c(`compositionend`,e=>{e.stopPropagation(),setTimeout(s,0)}),c(`input`,e=>{if(!up(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=cp(e.inputType);r!==``&&(ag(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function cg(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{ag(e,n),e.unseenOutcome&&T({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{Ah(e,t,n)}),ug(e.termWrap,t,e.abortController.signal),Yh(e),queueMicrotask(()=>{Vh(t,e)&&Qh(t,e,n)}))}function lg(e){return!!e&&Array.from(e.types).includes(`Files`)}function ug(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),dm(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{lg(t.dataTransfer)&&(t.preventDefault(),t.dataTransfer.dropEffect=`copy`,e.dataset.dropTarget=`true`)},{signal:n}),e.addEventListener(`dragleave`,t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||delete e.dataset.dropTarget},{signal:n}),e.addEventListener(`drop`,n=>{delete e.dataset.dropTarget,lg(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),dm(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function dg(e,t){if(e.term||Kh.has(e))return;let n=Hm();if(n){fg(e,t,n);return}Kh.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},Uh(e.termWrap),Yh(e),Um().then(n=>{Kh.delete(e),!(e.term||e.abortController.signal.aborted||H.get(t)!==e)&&(fg(e,t,n),e._setActiveViewer?.(r))},()=>{Kh.delete(e),Yh(e)})}function fg(e,t,n){og(e.termWrap,e,n),cg(e,t)}function pg(e){e?._syncGridOnEngagementEdge?.()}function mg(e,t){if(!e)return;dg(e,t),Nh(e,t),Xm(e);let n=e.term;n&&(n.refresh(0,n.rows-1),pg(e))}function hg(e,t,n){e&&(n&&dg(e,t),e._setActiveViewer?.(n))}var gg=`conversation:`,_g=1e4,vg=48,yg=`, `,bg=`+`,xg=`■`,Sg=`↑`,Cg=1e3,wg={command:`Run command?`,fileChange:`Apply file changes?`,permissions:`Grant permissions?`},Tg=1;function Eg(e){e?.previewUrl&&URL.revokeObjectURL(e.previewUrl)}function Dg(e,t,n){let r=L(`button`,`conversation-icon-button ${e}`,t);return r.type=`button`,r.title=n,r.setAttribute(`aria-label`,n),r}function Og(e){return e.conversationApproval!==null||hd(e.currentState,e.pendingPromptKind)}function kg(e,t,n,r,i=0){let a=n[i];a?setTimeout(()=>{B(e)===t?i>0&&Og(t)?r(`stopped-by-prompt`):ag(t,a.data)?kg(e,t,n,r,i+1):r(`unreachable`):r(`unreachable`)},a.delayBeforeMs):r(`sent`)}function Ag({signal:e,sendControl:t,showTerminal:n}){let r=L(`div`,`conversation-face`);r.hidden=!0;let i=L(`div`,`conversation-log`);i.setAttribute(`role`,`log`),i.setAttribute(`aria-live`,`polite`);let a=L(`p`,`conversation-empty`,`No conversation yet. Messages appear here as the agent works.`),o=L(`div`,`conversation-approval`);o.hidden=!0;let s=L(`p`,`conversation-bridge-note`,`Restart this Codex session to connect it to the conversation view. Until then, use the terminal.`);s.hidden=!0;let c=L(`p`,`conversation-bridge-note`,`The session trace is unavailable, so there is nothing to show here. Use the terminal.`);c.hidden=!0;let l=L(`details`,`conversation-working`),u=L(`summary`,`conversation-working-summary`);u.setAttribute(`role`,`status`);let d=L(`ul`,`conversation-agent-list`);l.append(u,d),l.hidden=!0;let f=L(`form`,`conversation-composer`),p=L(`p`,`conversation-status`);p.setAttribute(`role`,`status`);let m=L(`div`,`conversation-attachment`);m.hidden=!0;let h=L(`div`,`conversation-composer-row`),g=Dg(`conversation-attach`,bg,`Attach a photo or file`),_=L(`input`,`conversation-file-picker`);_.type=`file`,_.hidden=!0;let v=L(`textarea`,`conversation-input`);v.dataset.dashboardShortcuts=`allowed`,v.rows=1,v.placeholder=`Message the agent`,v.setAttribute(`aria-label`,`Message the agent`);let y=Dg(`conversation-stop`,xg,`Stop the current turn (Esc)`),b=Dg(`conversation-send`,Sg,`Send`);b.type=`submit`,h.append(g,v,y,b),f.append(p,m,h,_),r.append(i,l,c,s,o,f);let x=null,S=[],C=0,w=!1,T=null,E=!1,D=null,O=!1,k=[],A=[],ee=null,te=!1,ne=new Set;function re(){return x?B(x)??null:null}function ie(e){p.textContent=e}function j(){v.style.height=`auto`,v.style.height=`${v.scrollHeight+v.offsetHeight-v.clientHeight}px`}function ae(){T&&clearTimeout(T.timeoutHandle),T=null}function M(){if(!x||r.hidden||!c.hidden)return;if(T){E=!0;return}let e=`${gg}${Tg++}`,n=w?C:null;t(n===null?{type:`session-trace`,id:x,requestId:e,endingAt:`tail`}:{type:`session-trace`,id:x,requestId:e,after:n})?(E=!1,T={requestId:e,after:n,timeoutHandle:setTimeout(()=>{T=null,M()},_g)}):ie(`Conversation unavailable while disconnected.`)}function N(){return i.scrollHeight-i.scrollTop-i.clientHeight<=vg}function oe(e){let t=L(`a`,`conversation-image-link`);t.href=e,t.target=`_blank`,t.rel=`noopener`;let n=L(`img`,`conversation-image`);return n.src=e,n.alt=`Attached image`,n.loading=`lazy`,n.addEventListener(`error`,()=>t.remove(),{once:!0}),t.append(n),t}function se(e){let t=L(`article`,`conversation-message conversation-user is-pending`);return e.text&&t.append(L(`p`,`conversation-text`,e.text)),e.attachment?.previewUrl&&t.append(oe(e.attachment.previewUrl)),e.attachment&&!e.attachment.previewUrl&&t.append(L(`p`,`conversation-attachment-name`,e.attachment.name)),t}function ce(e){let t=L(`article`,`conversation-message conversation-${e.kind}`);return e.kind===`assistant`?(t.append(Wo(zo(e.text))),t):(t.append(L(`p`,`conversation-text`,e.text)),e.kind===`user`&&t.append(...e.imageUrls.map(oe)),t)}function le(e,t){e.replaceChildren(...t.map(e=>{let t=L(`li`,`conversation-agent is-${e.state}`);return t.append(L(`span`,`conversation-agent-name`,e.description),L(`span`,`conversation-agent-state`,e.state)),t}))}function ue(e){if(e.agentRuns.length===0)return L(`p`,`conversation-work`,Md(e));let t=L(`details`,`conversation-work`);t.open=ne.has(e.key),t.addEventListener(`toggle`,()=>{t.open?ne.add(e.key):ne.delete(e.key)});let n=L(`ul`,`conversation-agent-list`);return le(n,e.agentRuns),t.append(L(`summary`,``,Md(e)),n),t}function de(){return re()?.currentState===z.RUNNING}function fe(){let e=re(),t=Ed(A),n=de()?Dd(A)?.agentRuns??[]:[],r=[...new Set([...n,...t])];if(l.hidden=!e||!de()&&t.length===0,l.hidden||!e)return;let i=de()?Math.max(0,Date.now()-e.stateSince):null;u.textContent=Nd(i,t.length),l.classList.toggle(`has-agents`,r.length>0),le(d,r)}function pe(){let e=!r.hidden&&de();e&&!ee&&(ee=setInterval(fe,Cg)),!e&&ee&&(clearInterval(ee),ee=null),fe()}function me(){i.scrollTop=i.scrollHeight}function he(){let e=te||N();A=Td(S);let t=Date.now(),n=k.filter(e=>kd(e,A,t));for(let e of n)Eg(e.attachment);k=k.filter(e=>!n.includes(e));let r=[...(de()&&Dd(A)?A.slice(0,-1):A).map(e=>e.kind===`work`?ue(e):ce(e)),...k.map(se)];i.replaceChildren(...r.length>0?r:[a]),fe(),e&&(me(),requestAnimationFrame(me),w&&(te=!1))}function ge(){if(m.replaceChildren(),m.hidden=!D,D){if(D.previewUrl){let e=L(`img`,`conversation-attachment-thumbnail`);e.src=D.previewUrl,e.alt=``,m.append(e)}m.append(L(`span`,`conversation-attachment-name`,D.name))}}function _e(e){D!==e&&Eg(D),D=e,ge()}function ve(e,t=()=>{}){let n=re();if(!n||!x||!e){ie(`Unable to reach this session.`);return}ie(``);let r={sent:``,unreachable:`Unable to reach this session.`,"stopped-by-prompt":`Not sent: a prompt appeared, so the message was typed but not submitted. Check the terminal.`};kg(x,n,e,e=>{ie(r[e]),t(e)})}function P(e,n,r){x&&ie(t({type:`conversation-approval`,id:x,requestId:e.requestId,decision:n,...r?{answers:r}:{}})?``:`Unable to send the answer while disconnected.`)}function ye(e,t){let n=L(`button`,`conversation-approval-action`,e);return n.type=`button`,n.addEventListener(`click`,t),n}function be(e){return e.kind===`tool`?`Allow ${e.toolName??`this tool`}?`:wg[e.kind]??`Approve this request?`}function xe(e){o.append(L(`p`,`conversation-approval-note`,`This request cannot be shown in full here. Read and answer it in the terminal.`));let t=L(`div`,`conversation-approval-actions`);t.append(ye(`Open terminal`,()=>n()),ye(`Decline`,()=>P(e,`decline`))),o.append(t)}function Se(e){if(o.append(L(`p`,`conversation-approval-title`,be(e)),L(`pre`,`conversation-approval-summary`,e.summary)),e.isSummaryTruncated){xe(e);return}let t=L(`div`,`conversation-approval-actions`);t.append(ye(`Approve`,()=>P(e,`accept`))),e.kind!==`tool`&&t.append(ye(`Approve for session`,()=>P(e,`acceptForSession`))),e.alwaysAllowSummary&&(o.append(L(`p`,`conversation-approval-note`,`Always allow adds, for this session only: ${e.alwaysAllowSummary}`)),t.append(ye(`Always allow`,()=>P(e,`acceptForSession`)))),t.append(ye(`Decline`,()=>P(e,`decline`))),o.append(t)}function Ce(e){let t=L(`p`,`conversation-approval-title`,e.question);return e.header&&t.prepend(L(`span`,`conversation-question-header`,e.header)),t}function we(e,t){o.append(Ce(t));let n=L(`div`,`conversation-question-options`);for(let r of t.options){let i=ye(r.label,()=>P(e,`accept`,{[t.question]:r.label}));r.description&&(i.title=r.description),n.append(i)}let r=L(`div`,`conversation-approval-actions`);r.append(ye(`Decline`,()=>P(e,`decline`))),o.append(n,r)}function Te(e,t){let n=L(`form`,`conversation-question-form`);t.forEach((e,t)=>{let r=L(`fieldset`,`conversation-question`),i=L(`legend`,`conversation-question-text`,e.question);e.header&&i.prepend(L(`span`,`conversation-question-header`,e.header)),r.append(i);for(let n of e.options){let i=L(`label`,`conversation-question-option`),a=L(`input`);a.type=e.multiSelect?`checkbox`:`radio`,a.name=`question-${t}`,a.value=n.label,i.append(a,L(`span`,``,n.label)),n.description&&(i.title=n.description),r.append(i)}n.append(r)});let r=L(`div`,`conversation-approval-actions`),i=L(`button`,`conversation-approval-action`,`Send answers`);i.type=`submit`,r.append(i,ye(`Decline`,()=>P(e,`decline`))),n.append(r),n.addEventListener(`submit`,r=>{r.preventDefault();let i={};t.forEach((e,t)=>{let r=[...n.querySelectorAll(`input[name="question-${t}"]:checked`)].map(e=>e.value);r.length>0&&(i[e.question]=r.join(yg))}),Object.keys(i).length===t.length?P(e,`accept`,i):ie(`Answer every question first.`)}),o.append(n)}function Ee(e){let t=e.questions??[];if(e.isSummaryTruncated||t.length===0){o.append(L(`p`,`conversation-approval-title`,`Claude Code has a question`),L(`pre`,`conversation-approval-summary`,e.summary)),xe(e);return}let[n]=t;t.length===1&&!n.multiSelect?we(e,n):Te(e,t)}function De(e){e.kind===`question`?Ee(e):Se(e)}function Oe(){o.append(L(`p`,`conversation-approval-title`,`The agent is waiting on a prompt`)),o.append(L(`p`,`conversation-approval-note`,`Read and answer it in the terminal.`));let e=L(`div`,`conversation-approval-actions`);e.append(ye(`Open terminal`,()=>n())),o.append(e)}function ke(){let e=re();o.replaceChildren();let t=e?.conversationApproval??null,n=e?hd(e.currentState,e.pendingPromptKind):!1,r=e?.agent===`codex`&&!e.hasConversationBridge;s.hidden=!r,o.hidden=!t&&!n,b.disabled=!o.hidden||r,Ae(),e&&(t?De(t):n&&Oe())}function Ae(){g.disabled=b.disabled||O}function je(e){let t=fd(e,v.value);return t||!D?t:pd(e)}function Me(){let e=re();y.disabled=e?.currentState!==z.RUNNING,pe()}f.addEventListener(`submit`,e=>{if(e.preventDefault(),b.disabled)return;let t=je(re()?.agent);if(!t)return;let n={text:v.value.trim(),attachment:D,sentAt:Date.now(),userKeysAtSend:Od(A)};v.value=``,j(),D=null,ge(),k.push(n),te=!0,he(),ve(t,e=>{e!==`sent`&&(Eg(n.attachment),k=k.filter(e=>e!==n),he())})},{signal:e}),v.addEventListener(`input`,j,{signal:e});let Ne=0,Pe=new ResizeObserver(()=>{let e=i.clientHeight,t=Ne===0;Ne=e,t&&e!==0&&(te=!0,me(),w&&(te=!1))});Pe.observe(i),e?.addEventListener(`abort`,()=>{ee&&clearInterval(ee),Pe.disconnect()},{once:!0}),v.addEventListener(`keydown`,e=>{e.key!==`Enter`||e.shiftKey||e.isComposing||Ud()||(e.preventDefault(),f.requestSubmit())},{signal:e}),y.addEventListener(`click`,()=>ve(md(re()?.agent)),{signal:e}),g.addEventListener(`click`,()=>_.click(),{signal:e}),_.addEventListener(`change`,()=>{let e=_.files?.[0];if(_.value=``,!e||!x)return;if(b.disabled){ie(`Not attached: the agent is not ready for a message. Check the terminal.`);return}let t=x;O=!0,Ae(),um(t,e).then(n=>{if(O=!1,Ae(),!n||x!==t)return;let r=e.type.startsWith(`image/`)?URL.createObjectURL(e):null;_e({name:e.name,previewUrl:r})})},{signal:e});function Fe(e){if(x!==e){x=e,S=[],C=0,w=!1,ae(),_e(null),ne.clear();for(let e of k)Eg(e.attachment);k=[],ie(``)}r.hidden=!1,c.hidden=!0,te=!0,he(),Le(),M()}function Ie(){r.hidden=!0,ae(),pe()}function Le(){r.hidden||(ke(),Me(),he())}function Re(e){if(!T||e.requestId!==T.requestId)return!1;let t=T;if(ae(),e.id!==x)return!0;let n=t.after!==null&&e.start===t.after&&!e.reset;return t.after!==null&&!n?(w=!1,S=[],M(),!0):(S=Pd(t.after===null?[...e.records]:[...S,...e.records]),C=e.next,w=!0,he(),E&&M(),!0)}function ze(e){return!T||e.requestId!==T.requestId?!1:(ae(),E=!1,c.hidden=!1,!0)}function Be(e){e!==x||r.hidden||(c.hidden=!0,M())}return{el:r,show:Fe,hide:Ie,refresh:Le,applyTraceResponse:Re,applyTraceError:ze,applyTraceChanged:Be}}function jg(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function Mg(e,t){return e||jg(t)>0}var Ng={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},Pg=null,Fg=!1,Ig=!1,Lg=null,Rg=null,zg=null,Bg=`—`;function Vg(e){return e==null?Bg:Bt(e,`GB`)}function Hg(e){return e==null?Bg:h(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function Ug(e){return e==null?Bg:`${Hg(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function Wg(){let e=L(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=L(`div`,`health-summary`),n=L(`button`,`health-toggle`);n.type=`button`,n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=L(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,L(`span`,`health-toggle-label`,`Health`));let i=L(`div`,`health-stats`);t.append(n,i);let a=L(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{Ig=!Ig,e.dataset.expanded=String(Ig),n.setAttribute(`aria-expanded`,String(Ig)),a.hidden=!Ig,Ig&&(T({type:`request-health-snapshot`}),Kg())}),e.append(t,a),Lg=e,Rg=i,zg=a,e}function Gg(){if(!Rg||!Pg)return;let e=Pg,t=jg(e.anomalies);Rg.innerHTML=`
89
+ <span class="health-stat" title="V8 heap used"><span class="health-stat-label">Heap</span> ${Vg(e.process.heapUsed)}</span>
90
+ <span class="health-stat" title="Resident set size (process memory)"><span class="health-stat-label">RSS</span> ${Vg(e.process.rss)}</span>
91
+ <span class="health-stat" title="External buffers (PTY data lives here)"><span class="health-stat-label">Ext</span> ${Vg(e.process.external)}</span>
92
92
  <span class="health-stat" title="Active resources (handles + requests)"><span class="health-stat-label">Hdl</span> ${e.process.activeResources}</span>
93
- <span class="health-stat" title="Memory headroom at the last start check, and starts held for memory"><span class="health-stat-label">Mem</span> ${Bg(e.memoryGate?.headroomBytes)} / ${e.memoryGate?.heldStartCount??0} held</span>
93
+ <span class="health-stat" title="Memory headroom at the last start check, and starts held for memory"><span class="health-stat-label">Mem</span> ${Vg(e.memoryGate?.headroomBytes)} / ${e.memoryGate?.heldStartCount??0} held</span>
94
94
  <span class="health-stat" title="Sessions: alivePty / total"><span class="health-stat-label">Sess</span> ${e.sessions.alivePty}/${e.sessions.total}</span>
95
95
  <span class="health-stat" title="WebSockets: control + data"><span class="health-stat-label">WS</span> ${e.websockets.control}+${e.websockets.data}</span>
96
- <span class="health-stat" title="Server uptime"><span class="health-stat-label">Up</span> ${Vg(e.uptimeSeconds)}</span>
96
+ <span class="health-stat" title="Server uptime"><span class="health-stat-label">Up</span> ${Hg(e.uptimeSeconds)}</span>
97
97
  ${t>0?`<span class="health-anomaly" title="${t} anomaly type(s), expand for details">⚠ ${t}</span>`:``}
98
- `}function Gg(){if(!Rg||!Ng)return;let e=Ng,t=e.process,n=e.websockets,r=e.sessions,i=e.anomalies,a=``;if(Ag(i)>0){let e=[];i.listenerMismatch&&e.push(`Listener count mismatch: data WS listener leaked or missing`),i.orphanPty&&e.push(`Orphan PTY: session has live PTY but state is DONE/FAILED/DORMANT`),i.destroyedReachable&&e.push(`Destroyed session still reachable in sessions map`),a=`
98
+ `}function Kg(){if(!zg||!Pg)return;let e=Pg,t=e.process,n=e.websockets,r=e.sessions,i=e.anomalies,a=``;if(jg(i)>0){let e=[];i.listenerMismatch&&e.push(`Listener count mismatch: data WS listener leaked or missing`),i.orphanPty&&e.push(`Orphan PTY: session has live PTY but state is DONE/FAILED/DORMANT`),i.destroyedReachable&&e.push(`Destroyed session still reachable in sessions map`),a=`
99
99
  <div class="health-section health-section-warn">
100
100
  <div class="health-section-title">⚠ Anomalies</div>
101
101
  ${e.map(e=>`<div class="health-row">${e}</div>`).join(``)}
@@ -103,34 +103,34 @@ import{_ as e,a as t,f as n,g as r,l as i,m as a,n as o,o as s,r as c,s as l,u}f
103
103
  `}let o=r.list.map(e=>{let t=[];e.destroyed&&t.push(`destroyed`),e.pendingRestart&&t.push(`pendingRestart`);let n=Object.entries(e.timers).filter(([,e])=>e).map(([e])=>e).join(`,`)||`none`;return`
104
104
  <tr>
105
105
  <td>${G(e.name)}</td>
106
- <td class="health-mono">${Mg[e.state]||e.state}</td>
107
- <td class="health-mono">${e.hasPty?e.ptyPid:zg}</td>
108
- <td class="health-mono">${Bg(e.outputBufferBytes)}</td>
106
+ <td class="health-mono">${Ng[e.state]||e.state}</td>
107
+ <td class="health-mono">${e.hasPty?e.ptyPid:Bg}</td>
108
+ <td class="health-mono">${Vg(e.outputBufferBytes)}</td>
109
109
  <td class="health-mono">${e.outputBufferEntries}</td>
110
110
  <td class="health-mono">${e.dataListenerCount}</td>
111
111
  <td class="health-mono health-dim">${n}</td>
112
112
  <td class="health-mono health-dim">${t.join(` `)||``}</td>
113
113
  </tr>
114
- `}).join(``);Rg.innerHTML=`
114
+ `}).join(``);zg.innerHTML=`
115
115
  ${a}
116
116
  <div class="health-section">
117
117
  <div class="health-section-title">Process</div>
118
118
  <div class="health-grid">
119
- <div class="health-row"><span class="health-label">Heap used</span><span class="health-mono">${Bg(t.heapUsed)}</span></div>
120
- <div class="health-row"><span class="health-label">Heap total</span><span class="health-mono">${Bg(t.heapTotal)}</span></div>
121
- <div class="health-row"><span class="health-label">RSS</span><span class="health-mono">${Bg(t.rss)}</span></div>
122
- <div class="health-row"><span class="health-label">External</span><span class="health-mono">${Bg(t.external)}</span></div>
123
- <div class="health-row"><span class="health-label">Array buffers</span><span class="health-mono">${Bg(t.arrayBuffers)}</span></div>
119
+ <div class="health-row"><span class="health-label">Heap used</span><span class="health-mono">${Vg(t.heapUsed)}</span></div>
120
+ <div class="health-row"><span class="health-label">Heap total</span><span class="health-mono">${Vg(t.heapTotal)}</span></div>
121
+ <div class="health-row"><span class="health-label">RSS</span><span class="health-mono">${Vg(t.rss)}</span></div>
122
+ <div class="health-row"><span class="health-label">External</span><span class="health-mono">${Vg(t.external)}</span></div>
123
+ <div class="health-row"><span class="health-label">Array buffers</span><span class="health-mono">${Vg(t.arrayBuffers)}</span></div>
124
124
  <div class="health-row"><span class="health-label">Active resources</span><span class="health-mono">${t.activeResources}</span></div>
125
- <div class="health-row"><span class="health-label">Uptime</span><span class="health-mono">${Vg(e.uptimeSeconds)}</span></div>
125
+ <div class="health-row"><span class="health-label">Uptime</span><span class="health-mono">${Hg(e.uptimeSeconds)}</span></div>
126
126
  </div>
127
127
  </div>
128
128
 
129
129
  <div class="health-section">
130
130
  <div class="health-section-title">Memory gate</div>
131
131
  <div class="health-grid">
132
- <div class="health-row"><span class="health-label">Headroom</span><span class="health-mono">${Bg(e.memoryGate?.headroomBytes)}</span></div>
133
- <div class="health-row"><span class="health-label">Read</span><span class="health-mono">${Hg(e.memoryGate?.headroomReadAtMs)}</span></div>
132
+ <div class="health-row"><span class="health-label">Headroom</span><span class="health-mono">${Vg(e.memoryGate?.headroomBytes)}</span></div>
133
+ <div class="health-row"><span class="health-label">Read</span><span class="health-mono">${Ug(e.memoryGate?.headroomReadAtMs)}</span></div>
134
134
  <div class="health-row"><span class="health-label">Starts held</span><span class="health-mono">${e.memoryGate?.heldStartCount??0}</span></div>
135
135
  </div>
136
136
  </div>
@@ -146,7 +146,7 @@ import{_ as e,a as t,f as n,g as r,l as i,m as a,n as o,o as s,r as c,s as l,u}f
146
146
 
147
147
  <div class="health-section">
148
148
  <div class="health-section-title">Sessions (${r.total} total · ${r.alivePty} alive PTY)</div>
149
- <div class="health-row health-dim">Listeners ${r.totalDataListeners} · Output buffer ${Bg(r.totalOutputBufferBytes)}</div>
149
+ <div class="health-row health-dim">Listeners ${r.totalDataListeners} · Output buffer ${Vg(r.totalOutputBufferBytes)}</div>
150
150
  <table class="health-table">
151
151
  <thead>
152
152
  <tr>
@@ -156,18 +156,18 @@ import{_ as e,a as t,f as n,g as r,l as i,m as a,n as o,o as s,r as c,s as l,u}f
156
156
  <tbody>${o||`<tr><td colspan="8" class="health-dim">No sessions</td></tr>`}</tbody>
157
157
  </table>
158
158
  </div>
159
- `}function Kg(){if(!Ig)return;let e=jg(Pg,Ng?.anomalies),t=Ig.hidden;Ig.hidden=!e,e&&t&&Ng&&(Wg(),Fg&&Gg())}function qg(e){Pg=e,Kg()}function Jg(e){if(Ig)return Ig;let t=Ug();return e.appendChild(t),Kg(),t}function Yg(e){Ng=e,Kg(),Ig&&!Ig.hidden&&(Wg(),Fg&&Gg())}var Xg=2e3,Zg=3;function Qg(e){return e.replace(/\r\n?/g,`
159
+ `}function qg(){if(!Lg)return;let e=Mg(Fg,Pg?.anomalies),t=Lg.hidden;Lg.hidden=!e,e&&t&&Pg&&(Gg(),Ig&&Kg())}function Jg(e){Fg=e,qg()}function Yg(e){if(Lg)return Lg;let t=Wg();return e.appendChild(t),qg(),t}function Xg(e){Pg=e,qg(),Lg&&!Lg.hidden&&(Gg(),Ig&&Kg())}var Zg=2e3,Qg=3;function $g(e){return e.replace(/\r\n?/g,`
160
160
  `).split(`
161
- `)}function $g(e){return{kind:`unchanged`,text:e}}function e_(e){return{kind:`skipped`,text:`${e} unchanged lines`}}function t_(e,t){return e.length<=7?e.map(t):[...e.slice(0,Zg).map(t),e_(e.length-6),...e.slice(e.length-Zg).map(t)]}function n_(e){return e}function r_(e){let t=[],n=0;for(;n<e.length;){if(e[n].kind!==`unchanged`){t.push(e[n]),n++;continue}let r=n;for(;r<e.length&&e[r].kind===`unchanged`;)r++;t.push(...t_(e.slice(n,r),n_)),n=r}return t}function i_(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return r}function a_(e,t,n){let r=Math.min(e.length,t.length)-n,i=0;for(;i<r&&e[e.length-1-i]===t[t.length-1-i];)i++;return i}function o_(e,t){let n=e.length,r=t.length;if(n===0)return t.map(e=>({kind:`added`,text:e}));if(r===0)return e.map(e=>({kind:`removed`,text:e}));let i=r+1,a=new Int32Array((n+1)*i);for(let o=n-1;o>=0;o--)for(let n=r-1;n>=0;n--){let r=o*i+n;a[r]=e[o]===t[n]?a[r+i+1]+1:Math.max(a[r+i],a[r+1])}let o=[],s=0,c=0;for(;s<n&&c<r;)e[s]===t[c]?(o.push($g(e[s])),s++,c++):a[(s+1)*i+c]>=a[s*i+c+1]?(o.push({kind:`removed`,text:e[s]}),s++):(o.push({kind:`added`,text:t[c]}),c++);for(;s<n;)o.push({kind:`removed`,text:e[s]}),s++;for(;c<r;)o.push({kind:`added`,text:t[c]}),c++;return o}function s_(e,t){let n=Qg(e),r=Qg(t),i=i_(n,r),a=a_(n,r,i),o=n.slice(i,n.length-a),s=r.slice(i,r.length-a);return o.length+s.length>Xg?{lines:[],isTooLarge:!0}:{lines:r_([...t_(n.slice(0,i),$g),...o_(o,s),...t_(n.slice(n.length-a),$g)]),isTooLarge:!1}}var c_=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function l_(e){return e===`approve`||e===`approve-accept-edits`}function u_(e){return(e.state===`decided`||e.state===`closed`)&&l_(e.lastDecision)}function d_(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&u_(n)}function f_(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function p_(e){let t=f_(e.state,e.selectedAgentId);return t?e.selectedRevision&&t.revisions.some(t=>t.revision===e.selectedRevision)?e.selectedRevision:t.revisions.at(-1)?.revision??null:null}function m_(e,t){return f_(e,t)?.openRevision?.revision??null}function h_(e,t,n){if(n===null)return null;let r=f_(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function g_(e,t){let n=t-e;return Number.isFinite(n)?D(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function __(e,t,n){return t!==null&&t.state===`open`&&t.openRevision!==null&&t.openRevision.revision===n&&e.body!==null&&e.isConnected&&e.isDraft!==!0&&!e.isDecisionInFlight}function v_(e,t,n){let r=__(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return c_.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function y_(e,t){return e.openRevision===null?t!==null&&e.approvedRevision===t?`Approved`:e.state===`released`?`Answer in the terminal`:e.state===`decided`?e.lastDecision===`revise`?`Feedback sent, waiting for the next revision`:`Approved`:`Closed`:e.openRevision.revision===t?``:`Rev ${e.openRevision.revision} is the one open`}function b_(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function x_(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+Ne}function S_(e){let t=e.plan;if(t!==void 0&&t.length===0)return`the edited plan is empty, so nothing was sent`;if(t!==void 0&&new TextEncoder().encode(t).byteLength>524288)return`the edited plan is over the plan size cap, so nothing was sent`;let n=e.comments??[];return n.length>40?`more than 40 section comments are pending, so nothing was sent`:n.find(e=>e.comment.length>4e3||(e.heading?.length??0)>4e3)?`a section comment is over ${kt} characters, so nothing was sent`:b_(e)>1e4?`the feedback composes more than the ${et} characters the hook reply carries, so nothing was sent`:x_(e)>Re?`the decision is larger than one control frame carries, so nothing was sent`:null}function C_(e){return e?`, ${e}`:``}function w_(e,t,n){if(!e.isConnected)return`Disconnected`;if(!t||n===null)return`No plan revision selected`;if(e.isDecisionInFlight)return`Sending your decision`;if(e.body===null)return`Loading`;if(e.isDraft===!0)return`Draft`;let r=y_(t,n);if(r)return r;if(e.hasUnsavedComment===!0)return`Save or cancel the open comment first.`;let i=e.pendingCommentCount??0;return i<=0?``:i===1?`1 comment to send. Remove it to approve.`:`${i} comments to send. Remove them to approve.`}function T_(e,t,n){let r=w_(e,t,n);return r?`${r}${C_(e.problem)}`:e.problem??``}function E_(e){let t=f_(e.state,e.selectedAgentId),n=p_(e);return{tabs:e.state.reviews.map(e=>({agentId:e.agentId,label:e.agentId===null?`Main`:e.agentType||`Agent`,selected:e===t})),revisions:(t?.revisions??[]).map(e=>({revision:e.revision,label:`Rev ${e.revision}`,isOpen:e.revision===t?.openRevision?.revision,receivedAt:e.receivedAt,selected:e.revision===n})),selectedAgentId:t?.agentId??null,selectedRevision:n,previousRevision:h_(e.state,t?.agentId??null,n),status:T_(e,t,n),actions:v_(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:h_(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:__(e,t,n)}]}}function D_(e,t){let n=e.reviews.findIndex(e=>e.agentId===t.agentId),r=[...(n===-1?null:e.reviews[n])?.revisions??[]],i=r.findIndex(e=>e.revision===t.revision),a={revision:t.revision,receivedAt:t.receivedAt,chars:t.chars,title:t.title};r[i===-1?r.length:i]=a,r.sort((e,t)=>e.revision-t.revision);let o={agentId:t.agentId,agentType:t.agentType,revisions:r,state:t.state,openRevision:t.state===`open`?{revision:t.revision,since:t.receivedAt}:null,approvedRevision:t.approvedRevision,lastDecision:t.lastDecision},s=[...e.reviews];return s[n===-1?s.length:n]=o,{reviews:s}}function O_({headingOffsets:e,scrollTop:t,isScrolledToEnd:n,readingLineOffset:r}){if(e.length===0)return null;if(n)return e.length-1;let i=t+r,a=0;for(let t=0;t<e.length&&!(e[t]>i);t++)a=t;return a}var k_=12,A_=8,j_=``,M_=48,N_=new Map;function P_(e,t){return JSON.stringify([e,t])}function F_(e){return e.id??j_}function I_(e,t){let n=N_.get(e);n||(n=new Map,N_.set(e,n));let r=P_(t.agentId,t.revision);for(n.delete(r),n.set(r,t.plan);n.size>k_;){let e=n.keys().next().value;if(typeof e!=`string`)break;n.delete(e)}}function L_(e){N_.delete(e)}function R_(e,t,n){return!e||n===null?null:N_.get(e)?.get(P_(t,n))??null}function z_(e){let t=L(`section`,`plan-face`);t.hidden=!0;let n=L(`header`,`plan-head`),r=L(`select`,`plan-heading-picker`);r.setAttribute(`aria-label`,`Plan section`);let i=L(`div`,`plan-view-panel`),a=L(`div`,`plan-sheet-head`),o=L(`button`,`plan-control plan-sheet-close`,`×`);o.type=`button`,o.setAttribute(`aria-label`,`Close`),a.append(L(`span`,null,`View`),o);let s=L(`div`,`plan-view-group plan-author-group`),c=L(`div`,`plan-tabs`);c.setAttribute(`role`,`tablist`),c.setAttribute(`aria-label`,`Plan author`),s.append(L(`span`,`plan-sheet-label`,`Author`),c);let l=L(`div`,`plan-view-group plan-revision-group`),u=L(`div`,`plan-revision-stepper`),d=L(`button`,`plan-control plan-revision-previous`,`‹`);d.type=`button`,d.setAttribute(`aria-label`,`Previous revision`);let f=L(`button`,`plan-control plan-revision-next`,`›`);f.type=`button`,f.setAttribute(`aria-label`,`Next revision`);let m=L(`span`,`plan-revision-label`),h=L(`span`,`plan-revision-age`);u.append(d,m,f,h);let g=L(`div`,`plan-revision-list`);g.setAttribute(`role`,`radiogroup`),g.setAttribute(`aria-label`,`Revision`),l.append(L(`span`,`plan-sheet-label`,`Revision`),u,g);let _=L(`div`,`plan-view-group plan-mode-group`),v=L(`div`,`plan-modes`);v.setAttribute(`role`,`radiogroup`),v.setAttribute(`aria-label`,`Show`),_.append(L(`span`,`plan-sheet-label`,`Show`),v);let y=L(`div`,`plan-head-spacer`),b=L(`div`,`plan-draft-notice`),x=L(`span`,`plan-draft-dot`);x.setAttribute(`aria-hidden`,`true`);let S=L(`button`,`plan-control plan-draft-chip`,`Peek draft`);S.type=`button`,b.append(x,S),i.append(a,s,l,_,y,b);let C=L(`button`,`plan-control plan-view-button`,`View`);C.type=`button`,C.setAttribute(`aria-haspopup`,`dialog`),C.setAttribute(`aria-expanded`,`false`);let w=L(`button`,`plan-control plan-minimize-button`,`Minimize`);w.type=`button`,w.addEventListener(`click`,e.showTerminal),n.append(r,i,C,w);let T=L(`div`,`plan-sheet-backdrop`),E=L(`div`,`plan-body-layout`),D=L(`nav`,`plan-heading-rail`);D.setAttribute(`aria-label`,`Plan sections`);let O=L(`article`,`plan-reading-column`);E.append(D,O);let k=L(`textarea`,`plan-editor`);k.setAttribute(`aria-label`,`Plan markdown`),k.spellcheck=!1;let A=L(`footer`,`plan-action-bar`),ee=L(`span`,`plan-status`);ee.setAttribute(`role`,`status`);let te=L(`div`,`plan-decision-slot`),ne=L(`label`,`plan-accept-edits`),re=L(`input`,`plan-accept-edits-checkbox`);re.type=`checkbox`,ne.append(re,L(`span`,null,`Accept edits`)),te.append(ne,ee),A.append(te);let ie=new Map;for(let[e,t]of[[`terminal`,`Answer in terminal`],[`revise`,`Send feedback`],[`approve`,`Approve`]]){let n=L(`button`,`plan-action`,t);n.type=`button`,n.dataset.decision=e,n.addEventListener(`click`,()=>{n.disabled||Ze(e)}),ie.set(e,n),A.append(n)}t.append(n,E,A,T);let j=null,ae={reviews:[]},M=null,N=null,oe=!0,se=``,ce=``,le=``,ue=``,de=!1,fe=null,pe=!1,me=null,he=!1,ge=!1,_e=null,ve=[],P=null,ye=null,be=new Map,xe=new Map,Se=new Map,Ce=[],we=!1,Te=null,Ee=!1;function De(e,t=!0){Ee=e,i.replaceChildren(...e?[a,_,l,s,b,y]:[a,s,l,_,y,b]),c.setAttribute(`role`,e?`radiogroup`:`tablist`);for(let t of c.querySelectorAll(`button`)){let n=t.getAttribute(`aria-selected`)===`true`||t.getAttribute(`aria-checked`)===`true`;t.setAttribute(`role`,e?`radio`:`tab`),t.removeAttribute(e?`aria-selected`:`aria-checked`),t.setAttribute(e?`aria-checked`:`aria-selected`,String(n))}i.dataset.open=String(e),T.dataset.open=String(e),C.setAttribute(`aria-expanded`,String(e)),E.inert=e,A.inert=e,r.inert=e,C.inert=e,w.inert=e,e?(i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-label`,`Plan view`),i.setAttribute(`aria-modal`,`true`),o.focus()):(i.removeAttribute(`role`),i.removeAttribute(`aria-modal`),t&&C.focus())}function Oe(e){e.addEventListener(`keydown`,t=>{let n={ArrowLeft:-1,ArrowUp:-1,ArrowRight:1,ArrowDown:1}[t.key];if(n===void 0&&t.key!==`Home`&&t.key!==`End`)return;let r=[...e.querySelectorAll(`button:not(:disabled)`)];if(r.length===0)return;t.preventDefault();let i=(r.indexOf(document.activeElement)+(n??0)+r.length)%r.length;t.key===`Home`&&(i=0),t.key===`End`&&(i=r.length-1);let a=Ee;r[i].click(),!(a&&e!==v)&&(e===v||!Ee)&&e.querySelector(`[aria-checked="true"], [aria-selected="true"]`)?.focus()})}let ke=W.subscribe((e,t)=>{t.includes(`layout`)&&Ee&&De(!1,!1)});e.signal?.addEventListener(`abort`,ke,{once:!0}),Oe(v),Oe(c),Oe(g),C.addEventListener(`click`,()=>De(!Ee)),o.addEventListener(`click`,()=>De(!1)),T.addEventListener(`click`,()=>De(!1)),i.addEventListener(`keydown`,e=>{if(!Ee)return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),De(!1);return}if(e.key!==`Tab`)return;let t=[...i.querySelectorAll(`button:not(:disabled)`)].filter(e=>e.getClientRects().length>0&&e.tabIndex>=0),n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())});function Ae(e){O.querySelector(`#${CSS.escape(e)}`)?.scrollIntoView({behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`,block:`start`})}r.addEventListener(`change`,()=>Ae(r.value));function je(){we=!1;let e=Ce.map(e=>O.querySelector(`#${CSS.escape(e.dataset.headingId??``)}`)).filter(e=>e!==null),t=O.getBoundingClientRect().top-O.scrollTop,n=O_({headingOffsets:e.map(e=>e.getBoundingClientRect().top-t),scrollTop:O.scrollTop,isScrolledToEnd:O.scrollTop>0&&O.scrollTop+O.clientHeight>=O.scrollHeight-2,readingLineOffset:M_}),i=n===null?null:e[n]?.id??null;for(let e of Ce)e.dataset.headingId===i?e.setAttribute(`aria-current`,`location`):e.removeAttribute(`aria-current`);i!==null&&(r.value=i)}function Me(){we||t.hidden||Ce.length===0||(we=!0,requestAnimationFrame(je))}O.addEventListener(`scroll`,Me,{passive:!0});function Ne(){Te=null,pe=!1,he=!1,ge=!1,_e=null}function Pe(t){P=t,e.reportProblem(t),bt()}function Fe(e){N=e,P=null,Ne(),De(!1,Ee),bt()}function Ie(e){let t=ae.reviews.find(e=>e.agentId===M)?.revisions??[],n=t[t.findIndex(e=>e.revision===N)+e];n&&Fe(n.revision)}d.addEventListener(`click`,()=>Ie(-1)),f.addEventListener(`click`,()=>Ie(1));function Le(e,t){return`${j??``}:${e??`main`}:${t??`latest`}`}function Re(){return Le(M,N)}function ze(e,t,n){return`${e??``}:${P_(t,n??0)}`}function Be(){return ze(j,M,N)}function Ve(){return xe.get(Be())??null}function He(){return Ve()?.size??0}function Ue(){if(Te===null)return!1;let e=xe.get(Te.target.bucketKey)?.get(Te.target.sectionSlot)??``;return Te.field.value.trim()!==e}function We(e){let t=xe.get(e);if(!t)return[];let n=[];for(let e of ve){let r=t.get(F_(e));r&&n.push({heading:e.heading,comment:r})}return n}function Ge(e,t){let n=t.trim(),r=xe.get(e.bucketKey)??new Map;xe.set(e.bucketKey,r),n.length===0&&r.delete(e.sectionSlot),n.length>0&&r.set(e.sectionSlot,n),r.size===0&&xe.delete(e.bucketKey),bt()}function Ke(e){if(ge||de)return;let t={bucketKey:Be(),sectionSlot:F_(e)},n=L(`div`,`plan-comment-composer`),r=L(`label`,`plan-comment-label`,`Comment on ${e.heading??`Introduction`}`),i=L(`textarea`,`plan-comment-input`);i.maxLength=kt,i.value=xe.get(t.bucketKey)?.get(t.sectionSlot)??``,r.append(i);let a=L(`div`,`plan-comment-actions`),o=L(`button`,`plan-control plan-comment-cancel`,`Cancel`);o.type=`button`;let s=L(`button`,`plan-control plan-comment-save`,`Save comment`);s.type=`button`,a.append(o,s),n.append(r,a);let c={target:t,element:n,field:i};Te=c,i.addEventListener(`input`,yt),o.addEventListener(`click`,()=>{Te===c&&(Te=null,bt())}),s.addEventListener(`click`,()=>{Te===c&&(Te=null),Ge(t,i.value)}),bt(),i.focus()}function qe(e){let t={bucketKey:Be(),sectionSlot:F_(e)};if(Te?.target.bucketKey===t.bucketKey&&Te.target.sectionSlot===t.sectionSlot)return Te.element;let n=Ve()?.get(t.sectionSlot);if(!n)return null;let r=L(`div`,`plan-comment-card`),i=L(`div`,`plan-comment-head`),a=L(`button`,`plan-control plan-comment-edit`,`Edit`);a.type=`button`,a.addEventListener(`click`,()=>Ke(e));let o=L(`button`,`plan-control plan-comment-remove`,`Remove`);return o.type=`button`,o.disabled=de,a.disabled=de,o.addEventListener(`click`,()=>Ge(t,``)),i.append(L(`span`,`plan-comment-label`,`Your comment`),a,o),r.append(i,L(`p`,`plan-comment-text`,n)),r}function Je(t,n,r={}){if(!j||n.revision===null||de)return!1;let i=S_(r);if(i!==null)return Pe(i),!1;let a={agentId:n.agentId,revision:n.revision,decision:t,...r};return e.sendDecision(j,a)?(P=null,de=!0,fe=l_(t)?n:null,bt(),!0):(Pe(p),!1)}function Ye(e){if(!pe)return{};let t=k.value;return t===R_(j,e.agentId,e.revision)?{}:{plan:t}}function Xe(e){let t=ze(j,e.agentId,e.revision),n=We(t);n.length!==0&&Je(`revise`,e,{comments:n})&&e.revision!==null&&(ye={bucketKey:t,agentId:e.agentId,revision:e.revision},bt())}function Ze(e){let t={agentId:M,revision:N};e===`revise`?Xe(t):Je(e===`approve`&&!ne.hidden&&re.checked?`approve-accept-edits`:e,t,Ye(t))}function Qe(e){Te=null,pe=e===`edit`,he=e===`changes`,pe&&me!==Be()&&(k.value=R_(j,M,N)??``,me=Be()),P=null,bt()}function $e(e){return`${e.kind}:${Le(e.agentId,e.revision)}`}function et(e){for(Se.set($e(e),e);Se.size>A_;){let e=Se.keys().next().value;if(typeof e!=`string`)break;Se.delete(e)}}function tt(e,t){return e.agentId===t.agentId?e.kind===`draft`?t.revision===0:t.revision===0?!1:e.revision===null||e.revision===t.revision:!1}function nt(e){for(let[t,n]of Se)if(tt(n,e))return Se.delete(t),n;return null}function rt(){for(let[e,t]of Se)if(t.kind===`draft`)return Se.delete(e),t;return null}function it(){if(Se.size!==1)return null;let e=Se.entries().next().value;return e?(Se.delete(e[0]),e[1]):null}function at(){if(!j)return;let t=Re();se!==t&&e.requestPlan(j,M,N??void 0)&&(se=t,et({kind:`selection`,agentId:M,revision:N}))}function ot(){t.hidden||at()}function st(){return h_(ae,M,N)}function ct(t){if(!j)return;let n=Le(M,t);le!==n&&e.requestPlan(j,M,t)&&(le=n,et({kind:`diff-base`,agentId:M,revision:t}))}function lt(){if(!j)return;let t=`${j}:${M??`main`}`;ue!==t&&e.requestDraft(j,M)&&(ue=t,et({kind:`draft`,agentId:M,revision:null}))}function ut(e,t){return`${e??``}:${t??``}`}function dt(){return ae.reviews.find(e=>e.agentId===M)?.revisions.find(e=>e.revision===N)?.receivedAt??0}function ft(){let e=be.get(ut(j,M));return e!==void 0&&e>dt()}function pt(){ge?(Ne(),bt()):(Te=null,pe=!1,he=!1,lt(),bt())}S.addEventListener(`click`,pt);function F(e){D.replaceChildren(),r.replaceChildren(),Ce=[];for(let t of e){let e=t.id??`plan-introduction`,n=t.heading??`Introduction`,i=L(`button`,`plan-heading-link`,n);i.type=`button`,i.dataset.level=String(t.level),i.dataset.headingId=e,i.title=n,i.dataset.commented=String(Ve()?.has(F_(t))===!0),Ce.push(i),i.addEventListener(`click`,()=>Ae(e)),D.append(i);let a=L(`option`,null,n);a.value=e,r.append(a)}}function mt(e){let t=st();if(t===null){O.append(L(`p`,`plan-loading`,`This is the first revision, so there is nothing to diff`));return}let n=R_(j,M,t);if(n===null){O.append(L(`p`,`plan-loading`,`Loading the previous revision`)),ct(t);return}let r=s_(n,e);r.isTooLarge?(O.append(L(`p`,`plan-loading`,`This diff is too large to show, so the newer revision stands alone`)),O.append(Wo(zo(e)))):O.append(qo(r))}function ht(e){if(O.replaceChildren(),pe){F(ve),O.append(k);return}if(e===null){if(ve=[],F(ve),ce===Re()){O.append(L(`p`,`plan-loading`,`This plan revision could not be loaded`));return}O.append(L(`p`,`plan-loading`,`Loading plan`)),at();return}let t=zo(e);if(ve=Bo(t),F(ve),he){mt(e);return}if(ge){O.append(Wo(t));return}let n=Ve();O.append(Go(ve,{hasComment:e=>n?.has(F_(e))===!0,isComposing:e=>Te?.target.bucketKey===Be()&&Te.target.sectionSlot===F_(e),onComment:Ke,attachmentFor:qe}))}function gt(e){s.hidden=e.tabs.length<2,c.replaceChildren();for(let t of e.tabs){let e=L(`button`,`plan-tab`,t.label);e.type=`button`,e.setAttribute(`role`,Ee?`radio`:`tab`),e.setAttribute(Ee?`aria-checked`:`aria-selected`,String(t.selected)),e.tabIndex=t.selected?0:-1,e.addEventListener(`click`,()=>{M=t.agentId,N=null,P=null,se=``,ce=``,le=``,ue=``,Ne(),De(!1,Ee),bt()}),c.append(e)}}function _t(){return ge?_e:R_(j,M,N)}function vt(e){return E_({state:ae,selectedAgentId:M,selectedRevision:N,body:e,isConnected:oe,isDecisionInFlight:de,isDraft:ge,pendingCommentCount:He(),hasUnsavedComment:Ue(),problem:P})}function I(e){ee.textContent=e.status,ee.hidden=e.status.length===0;let t=e.actions.some(e=>e.kind===`approve`&&e.enabled);ne.hidden=!t,re.disabled=!t;for(let t of e.actions){let e=ie.get(t.kind);e&&(e.disabled=!t.enabled)}}function yt(){I(vt(_t()))}function bt(){let e=Ee&&i.contains(document.activeElement),t=E_({state:ae,selectedAgentId:M,selectedRevision:N,body:null,isConnected:oe});(M!==t.selectedAgentId||N!==t.selectedRevision)&&Ne(),M=t.selectedAgentId,N=t.selectedRevision,me!==Be()&&(me=null);let n=_t(),a=vt(n);gt(a);let s=a.revisions.findIndex(e=>e.selected),c=a.revisions[s],l=Date.now();u.hidden=a.revisions.length<2,m.textContent=`Rev ${s+1} of ${a.revisions.length}`,h.textContent=c?g_(c.receivedAt,l):``,d.disabled=s<=0,f.disabled=s<0||s>=a.revisions.length-1,g.replaceChildren();for(let e of[...a.revisions].reverse()){let t=L(`button`,`plan-revision-option`);t.type=`button`,t.dataset.revision=String(e.revision),t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.selected)),t.tabIndex=e.selected?0:-1,t.append(L(`span`,`plan-revision-name`,e.label),L(`span`,`plan-revision-age`,g_(e.receivedAt,l))),e.isOpen&&t.append(L(`span`,`plan-revision-open`,`OPEN`)),t.addEventListener(`click`,()=>Fe(e.revision)),g.append(t)}v.replaceChildren();let p=pe?`edit`:he?`changes`:`read`,_=a.modes.find(e=>e.kind===p&&e.enabled)??a.modes[0];for(let e of a.modes){let t=L(`button`,`plan-control plan-mode`,e.label);t.type=`button`,t.dataset.mode=e.kind,t.disabled=!e.enabled,t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.kind===p)),t.tabIndex=e.kind===_.kind?0:-1,t.addEventListener(`click`,()=>{t.disabled||(Qe(e.kind),v.querySelector(`[aria-checked="true"]`)?.focus())}),v.append(t)}b.hidden=!ft()&&!ge,S.hidden=b.hidden,S.setAttribute(`aria-pressed`,String(ge)),I(a),ht(n),r.disabled=Ce.length===0,Me(),e&&!i.contains(document.activeElement)&&o.focus()}function xt(t){fe!==null&&d_(t,fe.agentId)&&(fe=null,me=null,e.showTerminal())}function St(e){Te=null,e!==j&&(fe=null,de=!1,P=null,Se.clear()),De(!1,!1),j=e,t.hidden=!1,se=``,ce=``,bt(),ot()}function Ct(){Te=null,De(!1,!1),t.hidden=!0}function wt(e,t){return t.kind!==`selection`||e.agentId!==M?!1:t.revision===null?N===null||N===e.revision:t.revision===N}function R(e){e.kind===`draft`?(ue=``,Pe(`the draft could not be read, so nothing was shown`)):e.kind===`diff-base`?le=``:ce=Le(e.agentId,e.revision)}function Tt(e){ye!==null&&m_(e,ye.agentId)!==ye.revision&&(xe.delete(ye.bucketKey),ye=null)}function Et(e){de=!1,z({reviews:e.reviews});let t=e.body;if(!t){let e=it()??rt();e!==null&&R(e);return}let n=nt(t);if(t.revision===0){if(ue=``,n===null||t.agentId!==M)return;_e=t.plan,ge=!0}else I_(e.id,t),n!==null&&wt(t,n)&&(M=t.agentId,N=t.revision,se=``,ce=``)}function z(e){let t=m_(e,M);t!==null&&t!==m_(ae,M)&&(N=t,Ne()),Tt(e),ae=e,de=!1,xt(e)}function Dt(e){let n=!1;e.state&&z(e.state),e.draft&&be.set(ut(e.draft.id,e.draft.agentId),e.draft.changedAt),e.decisionRefused&&(fe=null,de=!1,ye=null,e.refusalText&&(P=e.refusalText)),typeof e.isConnected==`boolean`&&(n=e.isConnected&&!oe,oe=e.isConnected,n&&(se=``,ce=``,le=``,ue=``,de=!1)),e.requestFailed&&(ce=se),e.response&&Et(e.response),t.hidden||bt(),(n||e.decisionRefused)&&ot()}return{el:t,show:St,hide:Ct,update:Dt}}var B_=10;function V_(e){let t=new Map;for(let n of e.files){let e=n.path.split(`/`);for(let r=0;r<e.length;r++){let i=e.slice(0,r).join(`/`),a=t.get(i);a!==void 0&&a.localeCompare(n.path)<=0||t.set(i,n.path)}}return t}function H_(e,t){let n=[],r=new Set(e.files.map(e=>e.path));for(let i of e.links){let a=t.get(i.providerRepo),o=a?.firstChangedPathByDirectory.get(i.packageDir),s=o??i.importers.find(e=>r.has(e))??i.importers[0]??i.consumerManifest,c=o&&a?a.repo:e,l=i.importerCount===1?`file`:`files`,u=i.providerChangedPathCount===1?`file`:`files`,d=i.changedImporterCount===1?`file`:`files`,f=i.isLocalLink?`Linked locally (${i.versionSpec}), so ${i.providerRepo} changes reach it now.`:`Uses ${i.versionSpec} from the registry, so ${i.providerRepo} changes reach it only after a publish.`;i.providerChangedPathCount>0&&(f+=` ${i.providerRepo} changed ${i.providerChangedPathCount} ${u} in ${i.packageDir||`the repository root`}.`),i.changedImporterCount>0&&(f+=` ${i.changedImporterCount} importing ${d} changed here.`),n.push({dedupeKey:`link:${i.providerRepo}:${i.packageName}:${e.name}`,kind:`link`,severity:6,path:s,openPath:`${c.sessionPathPrefix}${s}`,text:`${e.name} imports ${i.packageName} from ${i.providerRepo} in ${i.importerCount} ${l}`,detail:f})}for(let t of e.collisions)n.push({dedupeKey:`collision:${e.sessionPathPrefix}${t.path}:${t.otherSessionId}`,kind:`collision`,severity:5,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,text:`Also being changed in "${t.otherSessionName}"`,detail:`Another live session is changing this file, so the two may conflict.`});for(let t of e.coChangeGaps){let r=t.confidence>0?Math.round(t.support/t.confidence):0;n.push({dedupeKey:`co-change:${e.sessionPathPrefix}${t.path}:${t.partner}`,kind:`co-change`,severity:4,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,text:`Usually changes with ${t.partner}, which is not in this change`,detail:`${t.support} of the ${r} commits that touched it also touched ${t.partner}.`})}for(let t of e.untestedFiles)n.push({dedupeKey:`untested:${e.sessionPathPrefix}${t.path}`,kind:`untested`,severity:3,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,text:`No test reaches it`,detail:`No dependent test was found in the import graph.`});return n}function U_(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function W_(e,t){for(let n of e.hotspots)U_(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`,title:`${n.fixCommitCount} of its last ${n.commitCount} commits were fixes.`});for(let n of e.blastRadius)n.transitiveDependentCount<B_||U_(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`,title:`${n.transitiveDependentCount} files depend on it: ${n.directDependentCount} directly, ${n.dependentTestCount} of them tests.`})}function G_(e,t){return t.severity-e.severity||e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function K_(e){let t=new Set(e.repos.flatMap(e=>e.links.map(e=>e.providerRepo))),n=new Map;for(let r of e.repos)t.has(r.name)&&!n.has(r.name)&&n.set(r.name,{repo:r,firstChangedPathByDirectory:V_(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of H_(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);W_(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:[...r.values()].sort(G_),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function q_(e,t){let n=null;for(let r of e)t.startsWith(r.sessionPathPrefix)&&(n&&n.sessionPathPrefix.length>=r.sessionPathPrefix.length||(n=r));return n?.name??null}var J_=5;function Y_(e,t){let n=L(`button`,`review-look-line`);return n.type=`button`,n.dataset.kind=e.kind,n.title=`${e.detail} Click to open ${e.path} below.`,n.append(L(`span`,`review-look-file`,e.path),L(`span`,`review-look-text`,e.text)),n.addEventListener(`click`,()=>t(e.openPath)),n}function X_(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=L(`section`,`review-look`);if(i.append(L(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=L(`p`,`review-look-error`,`Could not check this change for anything worth a look.`);t.title=e.errors.join(`
162
- `),i.append(t)}let a=t?e.worthALook:e.worthALook.slice(0,J_);if(a.length>0){let e=L(`div`,`review-look-list`);for(let t of a)e.append(Y_(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=L(`div`,`review-look-more`),c=L(`button`,`review-look-show-all`,`Show all`);return c.type=`button`,c.addEventListener(`click`,n),s.append(L(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function Z_(e){return(e??[]).map(e=>{let t=L(`span`,`review-file-hint`,e.text);return t.title=e.title,t})}function Q_(e){let t=/^@@+ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return!Number.isFinite(n)||!Number.isFinite(r)?null:{oldStart:n,newStart:r}}function $_(e){let t=[];if(!e)return t;let n=String(e).split(/\r?\n/),r=null,i=null,a=null,o=null,s=()=>{if(a===null)return null;let e=a;return a=e+1,e},c=()=>{if(o===null)return null;let e=o;return o=e+1,e},l=e=>{let n={path:``,oldPath:null,status:`modified`,added:0,removed:0,binary:!1,hunks:[]};t.push(n),i=null;let r=/^diff --git a\/(.+?) b\/(.+)$/.exec(e);return r&&(n.oldPath=r[1]??null,n.path=r[2]??``),n};for(let e of n)if(e.startsWith(`diff --git `))r=l(e);else{if(!r){if(!e.startsWith(`--- `)&&!e.startsWith(`@@`))continue;r=l(`diff --git a/ b/`)}if(r){if(e.startsWith(`new file mode`))r.status=`added`;else if(e.startsWith(`deleted file mode`))r.status=`deleted`;else if(e.startsWith(`rename from `))r.oldPath=e.slice(12),r.status=`renamed`;else if(e.startsWith(`rename to `))r.path=e.slice(10),r.status=`renamed`;else if(e.startsWith(`Binary files`))r.binary=!0;else if(!(e.startsWith(`index `)||e.startsWith(`similarity index`)||e.startsWith(`dissimilarity index`)||e.startsWith(`old mode`)||e.startsWith(`new mode`))){if(e.startsWith(`--- `)){if(e===`--- /dev/null`){r.status=`added`;continue}if(!r.path){let t=e.slice(4).replace(/^a\//,``);t&&t!==`/dev/null`&&(r.oldPath=r.oldPath||t)}}else if(e.startsWith(`+++ `)){if(e===`+++ /dev/null`){r.status=`deleted`;continue}if(!r.path){let t=e.slice(4).replace(/^b\//,``);t&&t!==`/dev/null`&&(r.path=t)}}else if(e.startsWith(`@@`)){i={header:e,lines:[]},r.hunks.push(i);let t=Q_(e);a=t?t.oldStart:null,o=t?t.newStart:null}else if(i){if(e===``)continue;let t=e[0];if(t===`+`){i.lines.push({type:`add`,text:e.slice(1),oldLineNumber:null,newLineNumber:c()}),r.added++;continue}if(t===`-`){i.lines.push({type:`del`,text:e.slice(1),oldLineNumber:s(),newLineNumber:null}),r.removed++;continue}if(t===`\\`){i.lines.push({type:`meta`,text:e.slice(1).trim(),oldLineNumber:null,newLineNumber:null});continue}i.lines.push({type:`context`,text:t===` `?e.slice(1):e,oldLineNumber:s(),newLineNumber:c()})}}}}for(let e of t)e.path||=e.oldPath||`(unknown)`;return t}function ev(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function tv(e){let t=0,n=0;for(let r of e||[])t+=r.added||0,n+=r.removed||0;return{files:(e||[]).length,added:t,removed:n}}function nv({changedFileCount:e,hasCommits:t,canMerge:n,isWorkspace:r,live:i,effectiveBase:a}){let o=`${e} file${e===1?``:`s`} changed`,s=(t,n)=>e>0?`${o}, ${t}`:n;if(r)return{text:e>0?`${o} in this worktree`:`Changes in this worktree`,namesMergeTarget:!1};if(n){let e=sv(a);return{text:s(`ready to merge into ${e}`,`Ready to merge into ${e}`),namesMergeTarget:!0}}return i?t?{text:s(`not ready to merge`,`Not ready to merge`),namesMergeTarget:!1}:{text:s(`not committed yet`,`Not committed yet`),namesMergeTarget:!1}:{text:s(`session ended`,`Session ended`),namesMergeTarget:!1}}function rv({status:e,mergeReason:t,fetched:n,hasDiffError:r,hasChanges:i,hasCommits:a,canMerge:o,isWorkspace:s,live:c,effectiveBase:l,changedFileCount:u=0}){return e===`parked`&&t===`base-diverged`?{text:`Parked: base branch diverged`,namesMergeTarget:!1}:e===`parked`?{text:`Parked: merge conflict`,namesMergeTarget:!1}:e===`merging`?{text:`Merging`,namesMergeTarget:!1}:e===`merged`?{text:`Merged`,namesMergeTarget:!1}:r?{text:`Could not read changes`,namesMergeTarget:!1}:n?i?nv({changedFileCount:u,hasCommits:a,canMerge:o,isWorkspace:s,live:c,effectiveBase:l}):{text:`No changes yet`,namesMergeTarget:!1,isEmpty:!0}:{text:`Checking for changes`,namesMergeTarget:!1}}function iv(e,t){return e?`Edits this session makes in its worktree show up here.`:`Edits this session makes show up here, ready to merge into ${sv(t)}.`}function av(e,t){return e.namesMergeTarget?null:`merges into ${sv(t)}`}function ov({status:e,mergeReason:t,live:n,isMergeRendered:r,hasChanges:i}){return e===`parked`&&n&&t!==`base-diverged`?`resolve`:!i&&e!==`parked`&&e!==`merging`?`none`:r?`merge`:`none`}function sv(e){return e||`base`}function cv(e,t){return`Merge into ${sv(e)}, push it, and rebase this worktree, then keep working (${t})`}function lv(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function uv(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function dv({status:e,hasCommits:t,live:n,state:r}){return e===`merging`?null:t?!n&&(e===`parked`||e===`merged`)?`Session ended.`:!n||e===`parked`?null:r===`INITIALIZING`||r===`STARTING`?`Starting up. Mergeable once the session is live.`:null:n?`Nothing is committed yet. Merge opens once the session commits.`:null}function fv({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function pv(e){return e||`its upstream`}function mv(e){if(!e)return null;let t=e.branch||`Base branch`,{state:n,ahead:r,behind:i}=e,a=pv(e.upstream);return n===`no-upstream`?`${t}: no upstream`:n===`unknown`&&e.error&&e.action===void 0?`${t}: sync check failed: ${e.error}`:n===`unknown`?`${t}: sync state unknown vs ${a}`:n===`in-sync`?`${t}: in sync with ${a}`:n===`ahead`?`${t}: ${r} ahead of ${a}`:n===`behind`?`${t}: ${i} behind ${a}`:n===`diverged`?`${t}: ${r} ahead, ${i} behind ${a}`:null}function hv(e){return!e||e.fetched===!1?`recheck`:e.state===`ahead`||e.state===`behind`?`resync`:`recheck`}function gv(e,t,n){let r=n?` (${t})`:``;if(!e||hv(e)===`recheck`)return`Click to fetch and check again${r}`;let i=e.branch||`Base branch`,a=pv(e.upstream);return e.state===`behind`?`Click to fast-forward ${i} to ${a}${r}`:`Click to push ${i} to ${a}${r}`}function _v(e){return e?.state!==`in-sync`||e.fetched===!1}function vv(e){if(e.error)return`Resync failed: ${e.error}`;let t=e.branch||`The base branch`,n=pv(e.upstream);return e.action===`fast-forwarded`?`Fast-forwarded ${t} to ${n}.`:e.action===`pushed`?`Pushed ${t} to ${n}.`:e.state===`diverged`?`${t} has diverged from ${n}. Resolve manually.`:e.state===`in-sync`?null:e.state===`no-upstream`?`${t} has no upstream to resync against.`:`Could not determine sync status.`}var yv=new Set([`pending-review`,`parked`]),bv=600,xv=kn(`merge`,Pa),Sv=kn(`resolve-or-resync`,Pa),Cv={minPx:260,maxPx:700},wv=16,Tv=5e3,Ev=new Map,Dv=new Map,Ov=new Map,kv=new Map,Av=new Map,jv=new Map,Mv=new Set,Nv=new WeakMap,Pv=new WeakMap,Fv=new Set,Iv=new Set,Lv=!1,Rv=null,zv=null,K=null,Bv=null,Vv=null,Hv=null,Uv=null,Wv=null,Gv=null,Kv=!1,qv=null,Jv=null,Yv=null,Xv=null,Zv=new Map,Qv=null,$v=null;function ey(e,t){let n=L(`button`,`review-icon-button`);return n.type=`button`,n.title=e,n.setAttribute(`aria-label`,e),n.append(sr(t)),n}function ty(){Kv=!1,K?.querySelector(`.review-more-menu`)?.remove(),K?.querySelector(`.review-more-button`)?.setAttribute(`aria-expanded`,`false`)}function ny({panel:e}){if(zv=e,!zv)return;let t=zv,n=L(`div`,`review-sidebar-head`),r=L(`span`,`review-sidebar-title`,`Review`);Gv=L(`span`,`review-sidebar-session`),r.append(Gv);let i=e=>{t.toggleAttribute(`data-collapsed`,e),vn(!e)},a=ey(`Close review`,`M6 3L11 8L6 13`);a.classList.add(`review-sidebar-close`),a.addEventListener(`click`,()=>i(!0)),n.append(r,a);let o=L(`div`,`review-sidebar-rail`),s=ey(`Open review`,`M10 3L5 8L10 13`);s.classList.add(`review-sidebar-open`),s.addEventListener(`click`,()=>i(!1)),Hv=L(`div`,`review-rail-status`),Uv=L(`span`,`review-rail-added`),Wv=L(`span`,`review-rail-removed`),Hv.append(Uv,Wv),Vv=L(`span`,`review-rail-label`,`Review`),o.append(s,Vv,Hv),K=L(`div`,`review-controls`),Bv=L(`div`,`review-sidebar-body`);let c=L(`div`,`review-resize-handle`);c.setAttribute(`role`,`separator`),c.setAttribute(`aria-orientation`,`vertical`),c.setAttribute(`aria-label`,`Resize review sidebar`),c.tabIndex=0,t.append(o,n,K,Bv,c),t.toggleAttribute(`data-collapsed`,!an()),iy(Bv),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&Kv&&(e.preventDefault(),ty(),K?.querySelector(`.review-more-button`)?.focus())}),document.addEventListener(`pointerdown`,e=>{Kv&&e.target instanceof Element&&(K?.contains(e.target)&&e.target.closest(`.review-more-button, .review-more-menu`)||ty())}),el({resizer:c,column:t,widthHost:t,widthProperty:`--sidebar-width`,bounds:Cv,keyStepPx:wv,getStoredWidth:Gn,setStoredWidth:yn,growsLeftward:!0}),Mu(e=>{Kv=!1,Yv=null,Fv.clear(),Iv.clear(),Lv=!1,Rv=null,e&&jy(e),e&&!Ny(e)&&Py(e),q()}),q()}function ry(e,t){let n=Ev.get(e);Ev.set(e,t),ev(n,t)&&(Ov.delete(e),kv.delete(e),Av.delete(e),e===Au()&&My(e)),e===Au()&&q()}function iy(e){let t=!1,n=null,r=null,i=e=>T({type:`watch-session-changes`,id:e}),a=()=>{let e=t&&document.visibilityState===`visible`?Au():null;e!==n&&(r&&clearInterval(r),r=null,n=e,i(e),e&&(r=setInterval(()=>i(e),j)))};new IntersectionObserver(e=>{t=e[e.length-1]?.isIntersecting??!1,a()}).observe(e),document.addEventListener(`visibilitychange`,a),Mu(a)}function ay(e){zv&&(e?(jt(zv,e),q()):(lt(zv),q()))}function oy(e,t,n=null){let r=t||`none`;Dv.set(e,n);let i=Zv.get(e);i!==void 0&&i!==r&&Zv.delete(e),ry(e,r)}function sy(e){let t=V(e);t&&Zv.delete(t)&&t===Au()&&q()}function cy(e,t,n=null){Dv.set(e,n),Zv.delete(e),ry(e,t||`none`)}function ly(e,t){Ov.set(e,t),kv.delete(e),e===Au()&&(Rv&&By(Rv,t),q(),Vy())}function uy(e,t){let n=V(e);n&&(kv.set(n,t),n===Au()&&q())}function dy(e,t){let n=V(e);if(!n)return;let r=Ye.safeParse(t);r.success&&r.data.sessionId===n&&(Av.set(n,r.data),n===Au()&&q())}function fy(e,t){let n=V(e),r=t;jv.set(n,r),r&&r.action!==void 0&&py(n,r),n===Au()&&q()}function py(e,t){Mv.delete(e),clearTimeout($v??void 0),$v=null;let n=vv(t);Qv=n?{forId:e,text:n,isError:!!t.error}:null,Qv&&!Qv.isError&&($v=setTimeout(()=>{Qv&&Qv.forId===e&&(Qv=null),q()},5e3))}function my(e){let t=V(e);t&&t===Au()&&jy(t)}function hy(e){let t=V(e);if(t!==Au())return;let n=!Ov.has(t)||kv.has(t),r=!Av.has(t)||gy(Av.get(t));n&&jy(t),r&&!n&&My(t),q()}function gy(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function _y(e){let t=V(e);Ev.delete(t),Dv.delete(t),Ov.delete(t),kv.delete(t),Av.delete(t),jv.delete(t),Mv.delete(t),Qv&&Qv.forId===t&&(clearTimeout($v??void 0),Qv=null),t===Au()?ju(null):q()}function vy(){let e=Au(),t=e?H.get(e):null;if(!e||!t)return yy(null,`No session is open to merge.`);if(Ny(e))return yy(e,`A workspace session has no worktree to merge.`);if(Zv.has(e))return yy(e,`Merge is already on its way for "${zy(t,e)}".`);let n=Ev.get(e)||`none`,r=!!Ov.get(e)?.hasCommits,i=uv(n,Dv.get(e)||null,Dy(t.currentState,r));return ov({status:n,mergeReason:Dv.get(e)||null,live:Ay(t.currentState),isMergeRendered:i.isRendered,hasChanges:Ey(e)})!==`merge`||!i.isEnabled?yy(e,dv({status:n,hasCommits:r,live:Ay(t.currentState),state:t.currentState})??`Nothing to merge in "${zy(t,e)}" right now.`):(Oy(e,t.currentState),!0)}function yy(e,t){return Yv={forId:e,text:t},clearTimeout(Xv??void 0),Xv=setTimeout(()=>{Yv=null,q()},Tv),q(),!1}function by(){let e=Au();if(!e||Ny(e))return!1;let t=H.get(e);if(!t)return!1;let n=Ev.get(e)||`none`,r=Dv.get(e)||null;return ov({status:n,mergeReason:r,live:Ay(t.currentState),isMergeRendered:uv(n,r,!1).isRendered,hasChanges:Ey(e)})!==`resolve`||xy(e)?!1:(Sy(e),!0)}function xy(e){return qv?.forId===e&&!qv.isError}function Sy(e){let t=T({type:`resolve-session-merge`,id:e});qv=t?{forId:e,text:`Resolve prompt sent`,isError:!1}:{forId:e,text:`Not connected. The resolve prompt was not sent.`,isError:!0},clearTimeout(Jv??void 0),Jv=setTimeout(()=>{qv=null,q()},t?3e3:Tv),q()}function Cy(){let e=Au();return!e||!H.has(e)||Ny(e)||Iy(e)?!1:(Ly(e),!0)}function wy(e){if(!e)return{committed:[],uncommitted:[]};let t=Nv.get(e);if(t)return t;let n={committed:$_(e.committed?.diff||``),uncommitted:$_(e.uncommitted?.diff||``)};return Nv.set(e,n),n}function Ty(e){let t=Pv.get(e);if(t)return t;let n=K_(e);return Pv.set(e,n),n}function Ey(e){let t=wy(Ov.get(e)),n=[...t.committed,...t.uncommitted],r=Ov.get(e)??null;return fv({fetched:Ov.has(e),changedFileCount:tv(n).files,hasCommits:!!r?.hasCommits})}function Dy(e,t){return(Mt.includes(e)||e===z.RUNNING)&&t}function Oy(e,t){t===z.RUNNING?wr({title:`Merge while working`,message:`This session still looks like it is working. Merging rebases its worktree under it. Merge anyway?`,confirmLabel:`Merge anyway`,onConfirm:()=>ky(e,!0)}):ky(e,!1)}function ky(e,t){Zv.has(e)||(T(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(Zv.set(e,Ev.get(e)||`none`),e===Au()&&q()):yy(e,`Not connected. The merge was not sent.`))}function Ay(e){return e!==z.DORMANT&&e!==z.DONE&&e!==z.FAILED}function jy(e){T({type:`request-session-diff`,id:e}),My(e)}function My(e){Av.has(e)||Av.set(e,null),T({type:`request-change-map`,id:e})}function Ny(e){return H.get(e)?.card.dataset.workspace!==void 0}function Py(e){jv.set(e,null),T({type:`request-branch-sync`,id:e}),e===Au()&&q()}function Fy(e){Mv.add(e),clearTimeout($v??void 0),Qv&&Qv.forId===e&&(Qv=null),T({type:`resync-branch`,id:e}),e===Au()&&q()}function Iy(e){return Mv.has(e)||jv.get(e)===null}function Ly(e){Iy(e)||(hv(jv.get(e))===`resync`?Fy(e):Py(e))}function Ry(e,t){return t?{text:`Resyncing`,loading:!0,error:!1}:Qv&&Qv.forId===e?{text:Qv.text,loading:!1,error:Qv.isError}:null}function zy(e,t){return e?.card?.dataset.session||t}function By(e,t){if(!t)return;let{committed:n,uncommitted:r}=wy(t);for(let t of n)(t.path===e||t.oldPath===e)&&Fv.add(`committed:${t.path}`);for(let t of r)(t.path===e||t.oldPath===e)&&Fv.add(`uncommitted:${t.path}`)}function Vy(){if(!Bv||!Rv)return;let e=Bv.querySelectorAll(`.review-file`);for(let t of e)if(t.dataset.path===Rv||t.dataset.oldPath===Rv){t.scrollIntoView({block:`nearest`}),Rv=null;return}}function Hy(e){Rv=e,By(e,Ov.get(Au()??``)),q(),Vy()}function Uy(){Lv=!0,q()}function q(){let e=Bv?.scrollTop??0;Wy(),Bv&&(Bv.scrollTop=e)}function Wy(){if(!K||!Bv)return;K.replaceChildren(),Bv.replaceChildren(),Vv&&(Vv.hidden=!0),Hv&&(Hv.hidden=!0);let e=Au(),t=e?H.get(e):null;if(Ky(e,t),!e||!t){Yv&&K.append(Gy(Yv.text,!0)),qy(`No session selected`,`Click a session name to review its changes here.`);return}let n=Ny(e),r=Ev.get(e)||`none`,i=Dv.get(e)||null,a=t.currentState,o=yv.has(r),s=Ov.has(e),c=s?Ov.get(e):null,l=kv.get(e)??null,{committed:u,uncommitted:d}=wy(c),f=!!c?.hasCommits,p=Ay(a),m=uv(r,i,Dy(a,f)),h=jv.get(e),g=Mv.has(e),_=sv(t.effectiveBase),v=tv([...u,...d]),y=ov({status:r,mergeReason:i,live:p,hasChanges:fv({fetched:s,changedFileCount:v.files,hasCommits:f}),isMergeRendered:m.isRendered}),b=rv({status:r,mergeReason:i,fetched:s,hasDiffError:l!==null,hasChanges:v.files>0||f,hasCommits:f,canMerge:!n&&m.isEnabled,isWorkspace:n,live:p,effectiveBase:_,changedFileCount:v.files}),x=b.isEmpty===!0,S=x||Hd()||_v(h),C=L(`div`,`review-status-headline`);if(C.append(L(`span`,`review-status-text`,b.text)),!n&&!S){let t=mv(h);if(t){C.title=t;let n=ey(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);n.classList.add(`review-branch-sync-refresh`),n.title=gv(h,Sv,y!==`resolve`),n.disabled=Iy(e),n.setAttribute(`aria-description`,t),n.addEventListener(`click`,()=>Ly(e)),C.append(L(`span`,`sr-only`,t),n)}}x||K.append(C);let w=L(`div`,`review-status-meta`);if(s&&v.files>0&&w.append(L(`span`,`review-status-added`,`+${v.added}`),L(`span`,`review-status-removed`,`-${v.removed}`),L(`span`,`review-status-spacer`)),!n&&S){let t=Jy(e,y!==`resolve`);t&&w.append(t)}w.childElementCount>0&&K.append(w),r===`parked`&&K.append(L(`div`,`review-status-explanation`,lv(i))),Vv&&(Vv.hidden=!1),Hv&&(Hv.hidden=!1,Hv.setAttribute(`aria-label`,`${b.text}, +${v.added}, -${v.removed}`),Hv.title=b.text),Uv&&(Uv.textContent=`+${v.added}`),Wv&&(Wv.textContent=`-${v.removed}`);let T=n?null:$y(e,{status:r,reviewable:o,mergeAction:m,live:p,state:a,effectiveBase:_,primaryAction:y});T&&K.append(T);let E=n?null:Ry(e,g),D=!n&&y===`merge`&&!m.isEnabled?dv({status:r,hasCommits:f,live:p,state:a}):null;if(D){let e=L(`div`,`review-control-reason`,D);e.id=`review-merge-reason`,K.append(e),K.querySelector(`#review-merge-btn`)?.setAttribute(`aria-describedby`,e.id)}if(E?.text){let e=L(`div`,E.loading?`review-control-reason review-loading`:`review-control-reason`,E.text);e.id=`review-resync-reason`,E.error&&e.classList.add(`review-control-reason-error`),e.setAttribute(`role`,`status`),w.append(e),w.isConnected||K.insertBefore(w,C.isConnected?C.nextSibling:K.firstChild),K.querySelector(`.review-branch-sync-button, .review-branch-sync-refresh`)?.setAttribute(`aria-describedby`,e.id)}if(qv?.forId===e&&K.append(Gy(qv.text,qv.isError)),Yv&&(Yv.forId===e||Yv.forId===null)&&K.append(Gy(Yv.text,!0)),l){Bv.append(L(`p`,`review-diff-error`,l));return}if(x){qy(b.text,iv(n,_));return}let O=Av.get(e),k=O?Ty(O):null,A=k?X_(k,{isShowingAll:Lv,onShowAll:Uy,onOpenFile:Hy}):null;A&&Bv.append(A);let ee=u.length>0&&d.length>0;u.length>0&&Bv.append(Yy({kind:`committed`,label:ee?`Committed`:null,meaning:av(b,_),files:u,changeMapView:k})),d.length>0&&Bv.append(Yy({kind:`uncommitted`,label:ee?`Not committed yet`:null,meaning:null,files:d,changeMapView:k}))}function Gy(e,t){let n=L(`div`,t?`review-control-reason review-control-reason-error`:`review-resolve-sent`,e);return n.setAttribute(`role`,`status`),n}function Ky(e,t){if(!Gv)return;let n=e&&t?zy(t,e):``;Gv.textContent=n,Gv.hidden=!n,Gv.title=n}function qy(e,t){if(!Bv)return;let n=L(`div`,`review-empty`);n.append(L(`div`,`review-empty-title`,e),L(`div`,`review-empty-desc`,t)),Bv.append(n)}function Jy(e,t){let n=jv.get(e);if(n===void 0)return null;if(n===null)return L(`span`,`review-branch-sync-text review-loading`,`Checking branch sync...`);let r=mv(n)||`Base branch: sync state unknown`,i=L(`span`,`review-branch-sync-text`);n.state&&(i.dataset.syncState=n.state),n.fetched===!1&&(i.dataset.stale=`true`);let a=ey(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);return a.classList.add(`review-branch-sync-button`),a.title=gv(n,Sv,t),a.disabled=Mv.has(e),a.addEventListener(`click`,()=>Ly(e)),i.append(a,L(`span`,`review-branch-sync-label`,r)),i}function Yy({kind:e,label:t,meaning:n,files:r,changeMapView:i}){let a=L(`div`,`review-section`);a.dataset.kind=e,t&&a.append(Xy(t,n,r));let o=L(`div`,`review-diff`),s=i&&i.repos.length>1?i.repos:[],c=null;for(let t of r){let n=s.length>0?q_(s,t.path):null;n&&n!==c&&o.append(L(`div`,`review-repo-label`,n)),c=n,o.append(Zy(t,e,i))}return a.append(o),a}function Xy(e,t,n){let r=tv(n),i=L(`div`,`review-section-head`),a=L(`div`,`review-section-id`);a.append(L(`span`,`review-section-label`,e)),t&&a.append(L(`span`,`review-section-meaning`,t));let o=L(`div`,`review-section-stat`);return o.append(L(`span`,`review-stat-files`,`${r.files} file${r.files===1?``:`s`}`),L(`span`,`review-add`,`+${r.added}`),L(`span`,`review-del`,`-${r.removed}`)),i.append(a,o),i}function Zy(e,t,n){let r=`${t}:${e.path}`,i=Fv.has(r),a=L(`div`,`review-file`);a.dataset.path=e.path,e.oldPath&&(a.dataset.oldPath=e.oldPath),a.dataset.status=e.status,a.dataset.open=i?`true`:`false`;let o=L(`button`,`review-file-head`);o.type=`button`,o.setAttribute(`aria-expanded`,i?`true`:`false`);let s=L(`span`,`review-file-twisty`,i?`▾`:`▸`);s.setAttribute(`aria-hidden`,`true`);let c=L(`span`,`review-file-name`);c.append(L(`span`,`review-file-path`,e.path));let l=Z_(n?.hintsByOpenPath.get(e.path));if(l.length>0){let e=L(`span`,`review-file-hints`);e.append(...l),c.append(e)}o.append(s,c);let u=L(`span`,`review-file-counts`);if(e.binary&&u.append(L(`span`,`review-bin`,`bin`)),e.binary||u.append(L(`span`,`review-add`,`+${e.added}`),L(`span`,`review-del`,`-${e.removed}`)),o.append(u),o.addEventListener(`click`,()=>{let e=Fv.has(r);e&&Fv.delete(r),e||Fv.add(r),q()}),a.append(o),!i)return a;let d=L(`div`,`review-file-body`);if(e.binary)return d.append(L(`div`,`review-file-binary`,`Binary file not shown`)),a.append(d),a;let f=0,p=!1;for(let t of e.hunks){if(f>=bv&&!Iv.has(r)){p=!0;break}d.append(L(`div`,`review-hunk-head`,t.header));for(let e of t.lines){if(f>=bv&&!Iv.has(r)){p=!0;break}let t=L(`div`,`review-line review-line-${e.type}`),n=e.type===`add`?`+`:e.type===`del`?`-`:e.type===`meta`?`\\`:` `;t.append(L(`span`,`review-line-gutter`,n)),t.append(L(`span`,`review-line-text`,e.text)),d.append(t),f++}if(p)break}if(p){let e=L(`button`,`review-expand`,`Show the rest of this file`);e.type=`button`,e.addEventListener(`click`,()=>{Iv.add(r),q()}),d.append(e)}return a.append(d),a}function Qy({id:e,label:t,shortcut:n,title:r,disabled:i=!1,danger:a=!1,onClick:o}){let s=L(`button`,a?`review-btn review-btn-danger`:`review-btn review-btn-primary`);return s.type=`button`,e&&(s.id=e),r&&(s.title=r),s.disabled=i,s.innerHTML=n?`${t} <kbd class="review-shortcut" aria-hidden="true">${n}</kbd>`:t,s.addEventListener(`click`,o),s}function $y(e,{status:t,reviewable:n,mergeAction:r,live:i,state:a,effectiveBase:o,primaryAction:s}){let c=L(`div`,`review-actions`),l=s===`resolve`;s===`merge`&&c.append(Qy({id:`review-merge-btn`,label:`Merge`,shortcut:xv,title:cv(o,xv),disabled:!r.isEnabled||Zv.has(e),onClick:()=>Oy(e,a)})),l&&c.append(Qy({label:`Resolve`,shortcut:Sv,title:`Paste a resolve prompt into this session so the agent can finish the merge (${Sv})`,disabled:xy(e),onClick:()=>Sy(e)}));let u=L(`div`,`review-action-controls`);if(u.append(c),!n||i)return c.childElementCount>0?u:null;let d=ey(`More review actions`,hr);if(d.classList.add(`review-more-button`),d.setAttribute(`aria-haspopup`,`menu`),d.setAttribute(`aria-expanded`,String(Kv)),d.setAttribute(`aria-controls`,`review-more-menu`),d.addEventListener(`click`,()=>{Kv=!Kv,q(),(K?.querySelector(Kv?`.review-more-menu button:not(:disabled)`:`.review-more-button`)??K?.querySelector(`.review-more-button`))?.focus()}),c.append(d),!Kv)return u;let f=L(`div`,`review-more-menu`);if(f.id=`review-more-menu`,f.setAttribute(`role`,`menu`),f.setAttribute(`aria-label`,`More review actions`),n&&!i){let n=Qy({label:`Discard worktree`,danger:!0,disabled:t===`merging`,onClick:()=>{Kv=!1,q();let t=zy(H.get(e),e);wr({title:`Discard worktree`,message:`Throw away the worktree changes for "${t}"? This cannot be undone.`,confirmLabel:`Discard`,danger:!0,onConfirm:()=>T({type:`discard-session-worktree`,id:e})})}});n.setAttribute(`role`,`menuitem`),f.append(n)}return u.append(f),u}var eb=160,tb=Object.freeze({Bash:`command`,Read:`file_path`,Edit:`file_path`,MultiEdit:`file_path`,Write:`file_path`,NotebookEdit:`notebook_path`,Grep:`pattern`,Glob:`pattern`,WebFetch:`url`,WebSearch:`query`,Task:`description`,Agent:`description`,Skill:`skill`});function nb(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=eb?t:`${t.slice(0,157)}...`}function rb(e,t){let n=tb[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?nb(r):``}var ib=5e3;function ab(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function ob(e,t){if(!e.toolUseId)return ab(e.text)??`context`;let n=t.get(e.toolUseId);return n?rb(n.name,n.input)||n.name:`expansion`}function sb(e){return e.kind!==`expansion`||e.toolUseId?!1:ab(e.text)!==null}function cb(e){return e.kind===`prompt`||e.kind===`session`||sb(e)}function lb(e){return new TextEncoder().encode(e).byteLength}function ub(e){return e.kind===`prompt`||e.kind===`expansion`||e.kind===`thinking`||e.kind===`assistant`||e.kind===`notice`?e.text:e.kind===`tool_result`?e.content:e.kind===`raw`?e.line:e.kind===`tool_call`?JSON.stringify(e.input,null,2)??String(e.input??``):[`${e.vendor} ${e.vendorSessionId}`,e.transcriptPath,e.reason??``].filter(Boolean).join(`
163
- `)}var db={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`},fb=[{kind:`thinking`,label:`Thinking`},{kind:`tool_result`,label:`Tool result`},{kind:`raw`,label:`Raw`}];function pb(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:nb(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:nb(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:nb(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:nb(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:nb(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:ob(e,t)};if(e.kind===`tool_call`){let t=rb(e.name,e.input);return t?{prefix:`${e.name}: `,text:t}:{prefix:``,text:e.name}}return{prefix:`${t.get(e.toolUseId)?.name??`Tool`} result: `,text:`${lb(e.content)} bytes`}}function mb(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function hb(e,t){let n=pb(e,t),r=mb(e),i=e.kind===`tool_call`||e.kind===`tool_result`?`${n.prefix}${n.text}`:n.text,a=[],o=e.kind===`notice`?`muted`:`default`;if(e.kind===`tool_result`&&e.isError&&(o=`error`,a.push(`error`)),e.truncated===!0&&(o!==`error`&&(o=`muted`),a.push(`truncated`)),e.kind===`tool_result`){let n=t.get(e.toolUseId),r=n?e.ts-n.ts:NaN;Number.isFinite(r)&&r>=0&&a.push(r>1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`)}return{kind:e.kind,tag:db[e.kind],text:`${r}${i}`,tone:o,badges:a}}function gb(e,t){return{record:e,...hb(e,t)}}function _b(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function vb(e,t){let n=_b(e);return!n||t.has(n)?null:n}function yb(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function bb(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function xb(e,t){if(t.size!==0)for(let n of e.turns)for(let r=0;r<n.rows.length;r+=1){let i=n.rows[r],a=_b(i.record);a&&t.has(a)&&(n.rows[r]=gb(i.record,e.toolCallByUseId))}}function Sb(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function Cb(e){if(e.startedAt===null)return 0;let t=e.head?.record.ts??e.startedAt;for(let n of e.rows)t=Math.max(t,n.record.ts);return Math.max(0,t-e.startedAt)}function wb(e){let{rowCount:t,toolCallCount:n,errorCount:r,resultBytes:i}=e.metrics;return`${`${t} ${t===1?`row`:`rows`}`}, ${`${n} ${n===1?`tool`:`tools`}`}, ${`${r} ${r===1?`error`:`errors`}`}, ${Bt(i,`KB`)}, ${N(Cb(e))}`}function Tb(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function Eb(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=lb(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function Db(e,t){for(let n of t)n.kind===`tool_call`&&e.toolCallByUseId.set(n.toolUseId,n);let n=[],r=e.turns[e.turns.length-1]??null;for(let i of t){let t=vb(i,e.toolCallByUseId);t&&yb(e.unresolvedToolUseCounts,t);let a=gb(i,e.toolCallByUseId);if(cb(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:Tb()},Eb(r,a,1),e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:a,rows:[]});continue}r||(r={head:null,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:Tb()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),Eb(r,a,1);let o=e.turns.length-1,s=n[n.length-1];s&&s.turnIndex===o?s.rows.push(a):n.push({turnIndex:o,isNewTurn:!1,head:null,rows:[a]})}return n}function Ob(e,t){let n=Sb();Db(n,t);let r=new Set;for(let[t,i]of n.toolCallByUseId)e.toolCallByUseId.has(t)||(e.toolCallByUseId.set(t,i),r.add(t));let i=new Set;for(let t of r)e.unresolvedToolUseCounts.delete(t)&&i.add(t);for(let[t,r]of n.unresolvedToolUseCounts)e.toolCallByUseId.has(t)||yb(e.unresolvedToolUseCounts,t,r);let a=n.turns[n.turns.length-1],o=e.turns[0],s=!!a&&!!o&&!o.head,c=s?a.head:null,l=s?a.rows:[];if(s){n.turns.pop();let e=a.startedAt,t=o.startedAt;e!==null&&(t===null||e<t)&&(o.startedAt=a.startedAt),o.head=c,o.rows=[...l,...o.rows],o.metrics={rowCount:a.metrics.rowCount+o.metrics.rowCount,toolCallCount:a.metrics.toolCallCount+o.metrics.toolCallCount,errorCount:a.metrics.errorCount+o.metrics.errorCount,resultBytes:a.metrics.resultBytes+o.metrics.resultBytes}}return e.turns=[...n.turns,...e.turns],xb(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function kb(e){return e.rows.length+ +!!e.head}function Ab(e){let t=0;for(let n of e.turns)t+=kb(n);return t}function jb(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=_b(n.record);t&&bb(e.unresolvedToolUseCounts,t)}}function Mb(e,t){jb(e,t.head?[t.head,...t.rows]:t.rows)}function Nb(e,t){let n=e.turns[0];if(!n)return 0;let r=Math.min(t,n.rows.length);if(r<=0)return 0;let i=n.rows.slice(0,r);jb(e,i);for(let e of i)Eb(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function Pb(e,t=ib){let n=Ab(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=kb(t),Mb(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:Nb(e,n-t)}}function Fb(e){let t=[],n=new Set;for(let r of e)r.id&&r.name&&!n.has(r.id)&&(n.add(r.id),t.push({id:r.id,label:r.name}));return t}function Ib(e,t,n,r=!0){return t&&e.some(e=>e.id===t)?t:n&&e.some(e=>e.id===n)?n:r?e[0]?.id??null:null}function Lb(e){return!e.selectedSessionId||!e.isPanelVisible||e.hasPendingRequest?null:e.hasLoadedOnce?{id:e.selectedSessionId,direction:`forward`,after:e.nextOffset}:{id:e.selectedSessionId,direction:`tail`,after:0,endingAt:`tail`}}function Rb(e,t=ib){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function zb(e,t=ib){return!Rb(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function Bb(e){let{pendingRequest:t,resident:n,reply:r}=e;return!t||t.id!==r.id?`ignore`:!n||n.sessionId!==r.id?`stale`:r.reset||r.next<r.start?`reset`:t.direction===`tail`?n.hasLoadedOnce?`stale`:`seed`:t.direction===`earlier`?n.firstOffset===t.endingAt?r.next===t.endingAt?`prepend`:`reset`:`stale`:n.nextOffset===t.after?r.start===t.after?`append`:`reset`:`stale`}function Vb(e){return e.hasSelectionChanged||e.isRenderedTraceStale||!e.hasRenderedOnce}function Hb(e,t,n){return e!==0||t?null:n?.startedAt??null}function Ub(e,t){return Wb(e,t)?e.filter(e=>e!==t):[...e,t]}function Wb(e,t){return e.includes(t)}function Gb(e){return e?`No trace has been recorded for ${e.label}.`:`No sessions are available.`}var Kb=1e4,qb=null,Jb=null,Yb=[],Xb=null,Zb=null,J=null,Qb=null,$b=!1,ex=null,tx=()=>!1,nx=new Set;function rx(e){for(let t of nx)t(e)}function ix(){Qb&&=(clearTimeout(Qb.timeoutHandle),null)}function ax(){Qb=null,ex=`The trace did not load within ${Math.round(Kb/1e3)} s.`,rx({kind:`rebuild`})}function ox(e){ix(),$b=!1,ex=null,Xb=e,J=e?{sessionId:e,grouping:Sb(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,rx({kind:`selection-reset`})}function sx(e){let t=Ib(Yb,Zb,Xb,e);return Zb&&t===Zb&&(Zb=null),t!==Xb&&(ox(t),!0)}function cx(e){if(!qb)return;let t=e.endingAt===void 0?{type:`session-trace`,id:e.id,after:e.after}:{type:`session-trace`,id:e.id,endingAt:e.endingAt};qb(t)?Qb={request:e,timeoutHandle:setTimeout(ax,Kb)}:(ex=p,rx({kind:`header`}))}function lx(e=!1){if(!qb)return;let t=Lb({selectedSessionId:Xb,isPanelVisible:e||tx(),hasPendingRequest:!!Qb,hasLoadedOnce:J?.hasLoadedOnce??!1,nextOffset:J?.nextOffset??0});t&&cx(t)}function ux(){$b&&!Qb&&($b=!1,lx())}function dx(){if(!J)return;let e=Pb(J.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!J.hasDroppedEarliestRows;t&&(J.hasDroppedEarliestRows=!0),rx({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function fx(e){J&&(rx({kind:`records-appended`,appends:Db(J.grouping,e)}),dx())}function px(e){J&&(rx({kind:`records-prepended`,prepend:Ob(J.grouping,e)}),dx())}function mx(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||!Array.isArray(t.records)||typeof t.next!=`number`||typeof t.start!=`number`?null:{id:t.id,records:t.records,start:t.start,next:t.next,reset:t.reset===!0,path:typeof t.path==`string`?t.path:``}}function hx(){return{selectedSessionId:Xb,hasPendingRequest:!!Qb,hasLoadedOnce:J?.hasLoadedOnce??!1,hasDroppedEarliestRows:J?.hasDroppedEarliestRows??!1,firstOffset:J?.firstOffset??0,residentRowCount:J?Ab(J.grouping):0}}function gx(){return{sessionOptions:Yb,selectedSessionId:Xb,selectedTrace:J,pendingSessionId:Qb?.request.id??null,traceFailureText:ex}}function _x(e){nx.add(e)}function vx(e){tx=e}function yx(){if(!qb)return;let e=zb(hx());e&&cx(e)}function bx(e){Yb.some(t=>t.id===e)&&e!==Xb&&(Zb=null,ox(e),lx(),rx({kind:`rebuild`}))}function xx(){let e=sx(!0);return lx(!0),e}function Sx(e){qb=e}function Cx(e){Jb=e}function wx(e){Zb=e,Jb?.()}function Tx(e){Yb=Fb(e);let t=sx(tx());t&&lx(),rx({kind:`sessions`,hasSelectionChanged:t})}function Ex(e){let t=mx(e);if(!t)return;let n=Bb({pendingRequest:Qb?.request??null,resident:J?{sessionId:J.sessionId,firstOffset:J.firstOffset,nextOffset:J.nextOffset,hasLoadedOnce:J.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?ux():(ix(),ex&&(ex=null,rx({kind:`header`})),n===`stale`?ux():n===`reset`?(ox(t.id),J&&(J.filePath=t.path),lx(),rx({kind:`rebuild`}),ux()):J&&(J.filePath=t.path,n===`prepend`?(J.firstOffset=t.start,px(t.records),ux()):(n===`seed`&&(J.hasLoadedOnce=!0,J.firstOffset=t.start),J.nextOffset=t.next,fx(t.records),ux())))}function Dx(e){let t=e?.id;typeof t==`string`&&t===Xb&&tx()&&(Qb?$b=!0:lx())}function Ox(e){let t=e?.id;if(typeof t!=`string`||Qb?.request.id!==t)return!1;ix(),$b=!1;let n=e?.message;return ex=typeof n==`string`&&n?n:`The trace could not be read.`,rx({kind:`rebuild`}),!0}function kx(e){ix(),$b=!1,ex=e?null:p,e?(rx({kind:`header`}),lx()):rx({kind:`rebuild`})}var Ax=`Estimated list prices, not a bill.`,jx=`Enable in Settings.`,Mx=80,Nx=Object.freeze([{value:`7`,label:`Last 7 days`,days:7},{value:`30`,label:`Last 30 days`,days:30},{value:`90`,label:`Last 90 days`,days:90},{value:`all`,label:`All retained`,days:null}]),Px=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Fx=/^(\d{4})-(\d{2})-(\d{2})$/,Ix=new Set([`day`,`model`,`label`]),Lx=new Set([`model`,`label`]);function Rx(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function zx(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function Bx(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${Rx(String(Math.abs(t)))}`}function Vx(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.abs(e);if(t===0)return`$0.00`;let n=e<0?`-`:``;if(t<1e-4)return e<0?`above -$0.0001`:`<$0.0001`;if(t<.01)return`${n}$${t.toFixed(4)}`;let[r,i]=t.toFixed(2).split(`.`);return`${n}$${Rx(r)}.${i}`}function Hx(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=e<0?`-`:``,n=Math.abs(e);if(n<1e3){let e=Math.round(n);return`${e===0?``:t}${e}`}return n<999950?`${t}${zx((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${zx((n/1e6).toFixed(2))}M`:`${t}${zx((n/1e9).toFixed(2))}B`}function Ux(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${zx(e.toFixed(1))}%`}function Wx(e){let t=Number(e?.costUSD);return Number.isFinite(t)&&t>0?`costUSD`:`tokens`}function Gx(e){return e===`costUSD`?`share of cost`:`share of tokens`}function Kx(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function qx(e){let t=Fx.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=Px[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function Jx(e){let t=Yx(e);return t.length===0?``:t.length===1?qx(t[0]):`${qx(t[0])} to ${qx(t[t.length-1])}`}function Yx(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>Fx.test(e)).sort()}function Xx(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:Zx(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function Zx(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=Qx(e,n);return Fx.test(r)?r:Qx(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function Qx(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function $x(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:h(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function eS(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=Px[n.getMonth()];return r?`${r} ${n.getDate()} ${gt(n)}`:`-`}function tS(e){if(!e||typeof e!=`object`)return[];let t=[];if(Number.isFinite(e.tokensPerMinute)){let n=Number.isFinite(e.tokensPerMinuteExCache)?`${Hx(e.tokensPerMinuteExCache)} excluding cache`:``;t.push({label:`tokens per min`,value:Hx(e.tokensPerMinute),sub:n})}return Number.isFinite(e.costPerHour)&&t.push({label:`cost per hour`,value:Vx(e.costPerHour),sub:``}),t}function nS(e){if(!e||typeof e!=`object`)return``;let t=[];Number.isFinite(e.projectedTokens)&&t.push(`${Hx(e.projectedTokens)} tokens`),Number.isFinite(e.projectedCostUSD)&&t.push(Vx(e.projectedCostUSD));let n=Number.isFinite(e.remainingMinutes)?`${$x(e.remainingMinutes)} left in this block`:``;if(t.length===0)return n;let r=`-> ${t.join(`, `)} by block end`;return n?`${r}, ${n}`:r}function rS(e,t=Date.now()){let n=Number(e?.startTs),r=Number(e?.endTs);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)return null;let i=(r-n)/6e4,a=Math.min(Math.max((t-n)/6e4,0),i);return{totalMinutes:i,elapsedMinutes:a,remainingMinutes:Math.max(i-a,0),pct:Math.round(a/i*100)}}function iS(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=Mx?`warn`:`ok`}function aS(e){let t=F(e?.max,null);return t===null||t<=0?null:t}function oS(e){let t=aS(e),n=F(e?.pct,null);return t===null||n===null?null:n*100}function sS(e,t){let n=aS(t),r=F(e?.projectedTokens,null);return n===null||r===null?null:r/n*100}function cS(e){let t=oS(e);return t===null?``:`${Math.round(t)}% of ${Hx(e?.max)} tokens, the largest completed block seen`}function lS(e,t){let n=sS(e,t);return n===null?``:n>=100?`On this burn rate the block ends past that reference, at ${Math.round(n)}% of it.`:`On this burn rate the block ends at ${Math.round(n)}% of that reference.`}var uS=Object.freeze([{key:`input`,label:`input`},{key:`output`,label:`output`},{key:`cacheCreate`,label:`cache write`},{key:`cacheRead`,label:`cache read`}]);function dS(e){let t=uS.map(t=>{let n=Number(e?.[t.key]);return{spec:t,tokens:Number.isFinite(n)&&n>0?n:0}}),n=t.reduce((e,t)=>e+t.tokens,0);return n<=0?[]:t.map(e=>{let t=Kx(e.tokens,n)??0,r=Hx(e.tokens);return{key:e.spec.key,label:e.spec.label,value:r,pct:t,title:`${e.spec.label} ${r}, ${Ux(t)}`}})}var fS=Object.freeze({interactive:`Interactive`,"pr-review":`PR review`,"team-review":`PR reviews`,posthog:`PostHog`,"my-prs":`Keep mergeable`,workflows:`Workflows`,"change-map":`Change map`,visions:`Visions`,benchmark:`Benchmarks`,"agent-spawn":`Agent API`,"task-title":`Task titles`,other:`Other`}),pS=`Sessions spawned by Glimmervoid; terminal sessions count as other`,mS=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function hS(e){let t=me(e,``);return t?fS[t]||t:fS.other}function gS(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function _S(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function vS(e){return gS(e).some(e=>_S(e.lane))}var yS=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function bS(e,t,n){let r=bC(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function xS(e,t,n,r){if(!Array.isArray(t))return null;let i=t.filter(e=>e&&typeof e.lane==`string`),a=i.reduce((e,t)=>e+F(t.costUSD,0),0),o=i.reduce((e,t)=>e+F(t.tokens,0),0),s=i.filter(e=>_S(e.lane)).map(e=>({lane:String(e.lane),label:hS(e.lane),tokens:F(e.tokens,0),costUSD:F(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?Kx(c,a):Kx(l,o),d=bS(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:yS[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function SS(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:yC.map(e=>xS(e.key,r[e.key],t,n)).filter(e=>e!==null)}function CS(e){return e.planPct===null?``:`about ${Ux(e.planPct)} of plan`}function wS(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?Vx(e.costUSD):Hx(e.tokens)}`).join(`, `)}var TS=`team-review`;function ES(e){if(!Array.isArray(e?.byLane))return null;let t=gS(e).find(e=>e.lane===TS),n=F(t?.costUSD,0),r=F(t?.tokens,0),i=Wx(e?.totals),a=Kx(i===`costUSD`?n:r,e?.totals?.[i]),o=a===null?``:`${Ux(a)} of range ${i===`costUSD`?`cost`:`tokens`}`,s=[Vx(n),o,DS(t?.sessions)].filter(Boolean).join(`, `);return{label:hS(TS),value:Hx(r),sub:s}}function DS(e){let t=F(e,null);return t===null||t<=0?``:`${Bx(t)} ${t===1?`session`:`sessions`}`}function OS(e){let t=e?.rtk;return!t||typeof t!=`object`||t.available!==!0?null:t}function kS(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function AS(e){return OS(e)!==null||kS(e)!==null}function jS(e){let t=OS(e);if(!t)return null;let n=F(t.commands,0),r=n===1?`command`:`commands`;return{value:`${Hx(F(t.savedTokens,0))} tokens`,sub:`${Ux(F(t.savingsPct,0))} avg across ${Bx(n)} ${r}`}}function MS(e){let t=kS(e);if(!t)return null;let n=Hx(F(t.cacheReadTokens,0)),r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e),i=`${n} cache read tokens`;if(r.length===0)return{value:Vx(F(t.savedUSD,0)),sub:i};let a=r.length===1?`model`:`models`;return{value:Vx(F(t.savedUSD,0)),sub:`${i}, a floor (${r.length} unpriced ${a})`}}var NS=90;function PS(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&F(e.budgetUsd,null)!==null):[]}function FS(e){return e===`monthly`?`this month`:`today`}function IS(e){return`${Vx(F(e?.spentUsd,0))} of ${Vx(F(e?.budgetUsd,0))}`}function LS(e){let t=F(e?.pct,null);return t===null?0:t}function RS(e){return`${FS(e?.scope)} spend against budget`}var zS=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function BS(e){let t=Fx.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function VS(e){let t=BS(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),P(t)}function HS(e){let t=Fx.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function US(e){return{key:e,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0,days:0,sources:new Set,vendorSet:new Set,modelByName:new Map}}function WS(e,t){e.tokens+=F(t?.tokens,0),e.costUSD+=F(t?.costUSD,0),e.input+=F(t?.input,0),e.output+=F(t?.output,0),e.cacheCreate+=F(t?.cacheCreate,0),e.cacheRead+=F(t?.cacheRead,0),e.days+=1,e.sources.add(t?.source===`history`?`history`:`live`);let n=Array.isArray(t?.vendors)?t.vendors:[];for(let t of n)e.vendorSet.add(t);let r=t?.models||[];for(let t of r){t?.vendor&&e.vendorSet.add(t.vendor);let n=KC(t),r=e.modelByName.get(n)||{key:n,model:t?.model??n,vendor:t?.vendor,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0};r.tokens+=F(t?.tokens,0),r.costUSD+=F(t?.costUSD,0),r.input+=F(t?.input,0),r.output+=F(t?.output,0),r.cacheCreate+=F(t?.cacheCreate,0),r.cacheRead+=F(t?.cacheRead,0),e.modelByName.set(n,r)}}function GS(e){let{modelByName:t,sources:n,vendorSet:r,...i}=e,a={...i};return a.day=e.key,a.models=Array.from(t.values()).sort((e,t)=>t.tokens-e.tokens),a.source=n.has(`live`)?`live`:`history`,a.vendors=Array.from(r).sort(),a}function KS(e,t){let n=new Map,r=Array.isArray(e)?e:[];for(let e of r){let r=t(e?.day);if(!r)continue;let i=n.get(r)||US(r);WS(i,e),n.set(r,i)}return Array.from(n.values()).map(GS)}function qS(e){return KS(e,VS)}function JS(e){return KS(e,HS)}function YS(e,t){return t===`week`?qS(e):t===`month`?JS(e):Array.isArray(e)?[...e]:[]}var XS=/^(\d{4})-(\d{2})$/;function ZS(e,t){if(t===`month`){let t=XS.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=Px[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=qx(e);return t===`-`?t:`week of ${t}`}return qx(e)}function QS(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var $S=16,eC=Object.freeze([.05,.25,.5,.75]),tC=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function nC(e,t){let n=F(e,0),r=F(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<eC.length;e+=1)i>=eC[e]&&(a=e+1);return a}function rC(e,{weeks:t=$S,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>Fx.test(String(e?.day??``))),i=new Map(r.map(e=>[String(e.day),e])),a=n instanceof Date?n:new Date(n),o=Number.isFinite(a.getTime())?a:new Date,s=typeof n==`string`&&Fx.test(n)?n:P(o),c=BS(VS(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=P(l),d=[],f=0,p=null;for(let e of r){let t=String(e.day);(p===null||t<p)&&(p=t),!(t<u||t>s)&&(f=Math.max(f,F(e.tokens,0)))}for(let e=0;e<t;e+=1)for(let t=0;t<7;t+=1){let n=new Date(l.getFullYear(),l.getMonth(),l.getDate()+e*7+t,12),r=P(n),a=i.get(r)||null,o=r>s,c=p!==null&&r<p;d.push({day:r,week:e,weekday:t,tokens:F(a?.tokens,0),costUSD:F(a?.costUSD,0),source:a?.source===`history`?`history`:a?`live`:null,noData:o||c||!a&&p===null,tone:nC(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function iC(e){let t=qx(e?.day);if(e?.noData)return`${t}: no data`;let n=F(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${Hx(n)} tokens, ${Vx(F(e?.costUSD,0))}`}function aC(e){if(!e)return``;let t=F(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${uC(e.ratio)} the ${n} average: ${Vx(e.todayUsd)} against ${Vx(e.baselineUsd)}.`}function oC(e){return e?`This block is burning ${uC(e.ratio)} the usual rate: ${Hx(e.current)} tokens per minute against ${Hx(e.baseline)}.`:``}function sC(e){return[aC(e?.daily),oC(e?.burn)].filter(Boolean).join(` `)}function cC(e){return e?.daily||e?.burn?`warn`:`ok`}function lC(e){return!!(e?.daily||e?.burn)}function uC(e){let t=F(e,null);return t===null?`-`:`${zx(t.toFixed(1))}x`}var dC=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`});function fC(e){let t=me(e,``);return t?dC[t]||t:dC.claude}function pC(e,t){return hC(t)?fC(e?.vendor):``}function mC(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>F(t[n]?.tokens,0)-F(t[e]?.tokens,0)).map(e=>({vendor:e,label:fC(e),tokens:F(t[e]?.tokens,0),costUSD:F(t[e]?.costUSD,0)}))}function hC(e){let t=e?.byVendor;if(!t||typeof t!=`object`)return!1;let n=Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`);return n.length>1||n.length===1&&n[0]!==`claude`}var gC=`Claude only`;function _C(e){return hC(e)?gC:``}var vC=36e5,yC=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]);function bC(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=F(n.pct,null),i=F(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}var xC=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`}]);function SC(e){return e?.vendor===`codex`?`codex`:`claude`}function CC(e,t){let n=`official, from ${xC.filter(({vendor:t})=>e.includes(t)).map(({label:e})=>e).join(` and `)}`,r=e.length===1&&e[0]===`claude`?_C(t):``;return r?`${n}, ${r}`:n}function wC(e){return yC.some(t=>bC(e,t.key)!==null)}function TC(e){return bC(e,`fiveHour`)?.pct??null}function EC(e){return e===`estimated`?`estimated from the largest completed block`:``}function DC(e,t=null){let n=TC(t);if(n!==null)return iS(n);let r=iS(oS(e?.tokenLimit));return r===`ok`?iS(sS(e?.activeBlock?.projection,e?.tokenLimit)):r}function OC(e,t=null){let n=[],r=DC(e,t);r!==`ok`&&n.push(`block:${r}`),e?.anomaly?.daily&&n.push(`anomaly:daily`),e?.anomaly?.burn&&n.push(`anomaly:burn`);for(let t of PS(e)){let e=LS(t);if(e<NS)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return Ut(n)}function kC(e){let t=F(e?.pct,null);return t===null?`-`:`${Ux(t)} used`}function AC(e,t=Date.now()){let n=F(e,null);if(n===null||n<=0)return``;let r=(n-t)/6e4;return r<=0?`resetting now`:`resets in ${$x(r)}`}function jC(e,t=Date.now()){let n=F(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function MC(e,t=Date.now()){let n=F(e,null);return n===null||n<=0||t-n>vC}function NC(e,t=Date.now()){if(!MC(e,t))return``;let n=jC(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function PC(e,t=``){let n=e?.source;if(n===`fetched`){let e=me(t,``);return e?`Prices fetched from the public model price table, ${e}.`:`Prices fetched from the public model price table.`}if(n===`cache`){let e=me(t,``);return e?`Prices from the cached public model price table, ${e}.`:`Prices from the cached public model price table.`}return n===`snapshot`?`Prices from the price table bundled with this Glimmervoid build.`:n===`unavailable`?`Model prices could not be loaded, so every cost below counts as zero.`:`Pricing source not reported yet.`}function FC(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function IC(e){let t=(Array.isArray(e)?e:[]).map(e=>String(e)).filter(e=>e);if(t.length===0)return``;let n=t.length===1?`model`:`models`;return`No price for ${t.length} ${n}: ${t.join(`, `)}. Their cost counts as zero here.`}function LC(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function RC(e){if(!e||typeof e!=`object`)return``;let t=[],n=LC(e.dirs);if(n!==null&&t.push(`${Bx(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${Bx(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${Bx(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${Bx(e.lastScanMs)}ms`),t.length===0)return``;let r=`Scanned ${t.join(`, `)}.`;return e.partial===!0?`${r} Some files were skipped this pass and will be re-read on the next one.`:r}function zC(e){return me(e?.error,``)}function BC(e){let t=me(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function VC(e){return zC(e)!==``}function HC(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}function UC(e){let t=String(e??``).trim();if(!t)return``;let n=t.split(/[\\/]+/).filter(e=>e);return n.length===0?t:n[n.length-1]}function WC(e){return typeof e?.id==`string`&&e.id!==``}function GC(e){let t=me(e?.label,``);return WC(e)&&t?t:UC(e?.project)||t||`unknown project`}function KC(e){let t=typeof e==`string`?e:e?.model;return me(t,`unknown model`)}function qC(e){return String(e?.day??``)}function JC(e,t,n){if(!Ix.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?qC(e):n(e)}function YC(e,t,n,r=GC){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=JC(e,t,r),o=JC(n,t,r);if(typeof i==`string`||typeof o==`string`)return a*String(i).localeCompare(String(o));if(i!==o)return a*(i-o);let s=Number(e?.tokens),c=Number(n?.tokens),l=Number.isFinite(s)?s:0,u=Number.isFinite(c)?c:0;return l===u?r(e).localeCompare(r(n)):u-l})}function XC(e){return Lx.has(e)?`asc`:`desc`}function ZC(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:XC(t)}}function QC(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var $C=Object.freeze({key:`lastTs`,dir:`desc`}),ew=Object.freeze({key:`tokens`,dir:`desc`}),tw=Object.freeze({key:`day`,dir:`desc`});function nw(e,t=$C){return YC(e,t.key,t.dir,GC)}function rw(e,t,n=10){if(!Array.isArray(e))return{rows:[],hiddenCount:0};let r=Number.isFinite(n)?Math.max(0,Math.floor(n)):10;return t||e.length<=r?{rows:e,hiddenCount:0}:{rows:e.slice(0,r),hiddenCount:e.length-r}}function iw(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${Bx(t)} hidden`}function aw(e,t=ew){return YC(e,t.key,t.dir,KC)}function ow(e,t=tw){return YC(e,t.key,t.dir,qC)}function sw(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function cw(e,t=8){return(Array.isArray(e)?e:[]).filter(e=>e&&e.isGap!==!0).sort((e,t)=>(Number(t?.startTs)||0)-(Number(e?.startTs)||0)).slice(0,Math.max(0,t)).map(e=>({startTs:Number(e.startTs),tokens:typeof e.tokens==`number`&&Number.isFinite(e.tokens)?e.tokens:0,costUSD:typeof e.costUSD==`number`&&Number.isFinite(e.costUSD)?e.costUSD:0,isActive:e.isActive===!0}))}function lw(e){let t=F(e?.officialCostUSD,null);if(t!==null&&t>0)return{costUSD:t,source:`official`};let n=F(e?.costUSD,null);return n!==null&&n>0?{costUSD:n,source:`estimated`}:{costUSD:null,source:null}}function uw(e){let t=Number(e?.tokens);if(!Number.isFinite(t)||t<=0)return``;let{costUSD:n}=lw(e);return n===null?Hx(t):`${Hx(t)} ${Vx(n)}`}function dw(e){let{source:t}=lw(e);return t===`official`?`Tokens counted from the transcript; cost reported by Claude Code for this conversation`:`Tokens and estimated API list-price cost for this conversation`}function fw(e,t){return t===z.RUNNING?e===`restart-fresh`?{title:`Restart fresh`,message:`This agent is mid-turn. A fresh restart ends this conversation and starts a new one. Restart anyway?`,confirmLabel:`Restart fresh`,danger:!0}:e===`restart-into`?{title:`Restart`,message:`This agent is mid-turn. Restarting interrupts the current turn and switches to the earlier conversation you picked. Restart anyway?`,confirmLabel:`Restart`,danger:!0}:{title:`Restart`,message:`This agent is mid-turn. Restarting interrupts the current turn and keeps this conversation. Restart anyway?`,confirmLabel:`Restart`,danger:!1}:null}function pw(e,t,n,r){let i=it.includes(t)?`force-restart`:`restart`;return e===`restart-fresh`?{type:i,id:n,fresh:!0}:e===`restart-into`?{type:i,id:n,conversationId:r}:{type:i,id:n}}function mw(e,t,n,r=``){let i=()=>n.send(pw(e,n.readState(),t,r)),a=fw(e,n.readState());a?n.confirm({...a,onConfirm:i}):i()}var hw=`DORMANT`;function gw(e){return e?D(Date.now()-e,{rounding:`round`,wording:`compact`,suffix:` ago`,justNowBelowSeconds:60}):``}function _w(e){return[e.worktreeName,e.gitBranch?e.gitBranch.replace(/^refs\/heads\//,``):null,gw(e.mtime)].filter(Boolean).join(` · `)}function vw(e,t){let n=L(`button`,`resume-item`);return n.type=`button`,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,`false`),n.innerHTML=`<span class="resume-item-title">${G(e)}</span><span class="resume-item-meta">${G(t)}</span>`,n}async function yw(e,t,n){if(t.kind===`this`)return!0;let r=t.kind===`earlier`?t.conversationId:``,i=await cr(`resume-conversation`,{id:e,conversationId:r},n);return i?i.type===`resume-conversation-ack`&&i.ok?!0:(n.show(`error`,i.type===`error`?i.message:`The conversation was not changed.`),!1):!1}var bw={this:`restart`,fresh:`restart-fresh`,earlier:`restart-into`};function xw(e,t,n,r){let i=n.kind===`earlier`?n.conversationId:``;mw(bw[n.kind],t,{readState:r,send:t=>{ol(e,t)},confirm:wr},i)}function Sw(e,{readState:t,canListEarlier:n}){let{overlay:r,dialog:i,close:a,actions:o,btnCancel:s}=Tr({title:`Restart`,dialogClass:`dialog resume-dialog`}),c=L(`p`,`dialog-message`,n?`Restart into this conversation, a fresh one, or an earlier one from this repo (any worktree).`:`Restart into this conversation or a fresh one.`),l=L(`div`,`resume-list`);l.setAttribute(`role`,`listbox`),l.setAttribute(`aria-label`,`Conversation to restart into`);let u=L(`button`,`btn-dialog btn-dialog-confirm`,`Restart`);u.type=`button`,o.append(u);let d=pr(`dialog-error`);i.append(c,l,d.element,o);let f={kind:`this`};function p(e,t){for(let e of l.querySelectorAll(`.resume-item`))e.classList.remove(`resume-item-current`),e.setAttribute(`aria-selected`,`false`);e.classList.add(`resume-item-current`),e.setAttribute(`aria-selected`,`true`),f=t}function m(e,t,n){let r=vw(t,n);return r.addEventListener(`click`,()=>p(r,e)),l.append(r),r}p(m({kind:`this`},`This conversation`,`Keeps the current conversation`),{kind:`this`}),m({kind:`fresh`},`Fresh conversation`,`Ends this conversation and starts a new one`);async function h(t,n){i.dataset.applying=``;let r=await yw(e,n,d);delete i.dataset.applying,r&&(a(),ol(t,{type:`start-session`,id:e}))}function g(){if(i.dataset.applying!==void 0)return;let n=H.get(e);n?t()===hw?h(n,f):(a(),xw(n,e,f,t)):a()}if(s.addEventListener(`click`,a),u.addEventListener(`click`,g),requestAnimationFrame(()=>u.focus()),!n)return;let _=L(`div`,`resume-empty`,`Loading earlier conversations...`);l.append(_),S(`list-conversations`,{id:e},{timeoutMs:U}).then(e=>{if(!r.isConnected)return;if(e.error){_.textContent=`Could not list earlier conversations: ${e.error}`;return}let t=e.type===`conversations`?e.current??null:null,n=(e.type===`conversations`?e.conversations:[]).filter(e=>e.id!==t);if(n.length===0)_.textContent=`No earlier conversations found for this repo.`;else{_.remove();for(let e of n)m({kind:`earlier`,conversationId:e.id},e.title||e.id,_w(e))}}).catch(e=>{r.isConnected&&(_.textContent=`Could not list earlier conversations: ${br(e,U)}`)})}var Cw=e=>e==null?``:String(e),ww=e=>it.includes(e),Tw=e=>xt.includes(e),Ew=!1;function Dw(e){return Ew&&ud(e.agent)&&e.card.dataset.ephemeral===void 0}function Ow(e){return Dw(e)&&e.isConversationViewOn&&e.isBorrowed}function kw(e){e.btnConversationView.classList.toggle(`visible`,Dw(e)),e.btnConversationView.setAttribute(`aria-checked`,String(e.isConversationViewOn))}function Aw(e){Ew=e;for(let t of H.values())!e&&t.face===`conversation`&&t._showTerminalFace?.(),Iw(t)}function jw(e){let t=B(e);return!t||!Ow(t)?!1:(t.face=`conversation`,t.card.dataset.face=`conversation`,t.termWrap.hidden=!0,t.planFace.hide(),t.conversationFace.show(V(e)),Iw(t),Mh(t,V(e)),!0)}function Mw(e,t){let n=B(e);if(!n)return;let r=n.isConversationViewOn;n.hasConversationBridge=t.hasConversationBridge,n.conversationApproval=t.conversationApproval,n.isConversationViewOn=t.isConversationViewOn,Iw(n),n.conversationFace.refresh(),r!==t.isConversationViewOn&&(t.isConversationViewOn?jw(e):n.face===`conversation`&&n._showTerminalFace?.())}function Nw(e){return B(e.id)?.conversationFace.applyTraceResponse(e)===!0}function Pw(e){B(e.id)?.conversationFace.applyTraceError(e)}function Fw(e){B(e)?.conversationFace.applyTraceChanged(V(e))}function Iw(e){kw(e);let t=e.currentState;e.btnRestart.classList.toggle(`visible`,ww(t)||Tw(t)||t===z.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,dl()),e.btnPlan.classList.toggle(`visible`,pc(e)!==`hidden`),e.btnRemove.classList.add(`visible`)}function Lw(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function Rw(e,t){Dl(e.taskTitleEl,()=>Al(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),Nl(e,t)}),e.nameEl.addEventListener(`click`,()=>{Ml(e.nameEl)||ju(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),Nl(e,t))}),e.btnRestart.addEventListener(`click`,()=>{Lw(e),Sw(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0})}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{Lw(e),Pi(t)}),e.btnTrace.addEventListener(`click`,()=>{Lw(e),wx(t)}),e.btnDocs.addEventListener(`click`,()=>{Lw(e),Cs(t)}),e.btnConversationView.addEventListener(`click`,()=>{Lw(e),ol(e,{type:`set-session-conversation-view`,id:t,isOn:!e.isConversationViewOn})}),e.btnGuardrails.addEventListener(`click`,()=>{Lw(e),e.btnSessionMenu.focus();let n=n=>()=>{ol(e,{type:`set-session-guardrails`,id:t,isOn:n})};e.card.dataset.guarded===void 0?wr({title:`Restore guardrails`,message:`This session restarts with guardrails on, interrupting any turn in progress.`,confirmLabel:`Restore guardrails`,danger:!1,onConfirm:n(!0)}):wr({title:`Release guardrails`,message:`This session restarts without guardrails, interrupting any turn in progress. It can then read, write and reach anything your account can, including credentials and Glimmervoid itself.`,confirmLabel:`Release guardrails`,danger:!0,onConfirm:n(!1)})}),e.btnPlan.addEventListener(`click`,()=>{let n=pc(e);n!==`hidden`&&(n===`face`?Jw(t):location.hash=pa(t))}),e.btnRemove.addEventListener(`click`,()=>{Lw(e),Gu(t)}),e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation();for(let[,t]of H)t!==e&&Lw(t);let n=e.sessionMenu.classList.toggle(`open`);e.btnSessionMenu.setAttribute(`aria-expanded`,String(n))});function n(t){if(nl(t)){t.preventDefault(),t.stopPropagation();for(let[,t]of H)t!==e&&Lw(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`),rl([...e.sessionMenu.querySelectorAll(`.popup-menu-item.visible`)],t)}}e.btnSessionMenu.addEventListener(`keydown`,n),e.sessionMenu.addEventListener(`keydown`,n),document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e.sessionMenu.classList.contains(`open`)&&(t.preventDefault(),Lw(e),e.btnSessionMenu.focus())},{signal:e.abortController.signal}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;!e.sessionMenu.contains(n)&&n!==e.btnSessionMenu&&Lw(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),Bl(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&Vl(e)},{signal:e.abortController.signal})}function zw(e,t,n){let r=B(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&kl(e,r.taskTitle)}}function Bw(e){return typeof e==`string`&&H.has(e)}function Vw(){return H.size}function Hw(e){let t=e||{};t.cursorBlink!=null&&lh(t.cursorBlink),t.debugMode!=null&&(ll(t.debugMode),qg(t.debugMode));for(let[,e]of H)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function Uw(){Xd(H.values(),Qd())}function Ww(){let e=Ic(Pc([...H.values()].map(e=>({state:e.currentState,unseenOutcome:e.unseenOutcome}))));document.title=e>0?`(${e}) Glimmervoid`:`Glimmervoid`}function Gw(e,t,n,r={}){if(!rn)return;let i=V(e),a=Cw(n)||z.DORMANT,o=wl(i,Cw(t),a,r),s=a===z.DORMANT;rn.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),c.conversationFace.hide(),Iw(c),pg(c,i)}function u(){jw(i)||l()}let d=new AbortController,f=z_({signal:d.signal,requestPlan:(e,t,n)=>T({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>T({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:u,sendDecision:(e,t)=>T({type:`plan-decision`,id:e,...t}),reportProblem:e=>ST(i,e)}),p=kg({signal:d.signal,sendControl:e=>T(e),showTerminal:l});return c={term:null,fitAddon:null,webglAddon:null,needsWebGLReload:!1,webglAttachedWithoutLayout:!1,dataWs:null,card:o.card,nameEl:o.nameEl,taskTitleEl:o.taskTitleEl,taskTitle:r.taskTitle??null,taskTitleIsCustom:r.taskTitleIsCustom??!1,path:Cw(r.path),ownerId:r.ownerId??null,stateSince:typeof r.stateSince==`number`&&Number.isFinite(r.stateSince)?r.stateSince:Date.now(),sessionMenu:o.sessionMenu,termWrap:o.termWrap,btnDebug:o.btnDebug,btnRestart:o.btnRestart,btnSessionMenu:o.btnSessionMenu,btnWorkspaceRepos:o.btnWorkspaceRepos,btnConversationView:o.btnConversationView,btnGuardrails:o.btnGuardrails,btnTrace:o.btnTrace,btnPlan:o.btnPlan,btnDocs:o.btnDocs,btnRemove:o.btnRemove,debugOverlay:null,debugOpen:!1,abortController:d,currentState:a,face:`terminal`,isBorrowed:!1,hasPlan:!1,pendingPromptKind:null,planReviewState:{reviews:[]},planFace:f,conversationFace:p,conversationApproval:null,hasConversationBridge:!1,isConversationViewOn:!1},c._ensureTerminalReady=()=>pg(c,i),c._showTerminalFace=l,c._showPreferredFace=()=>{Kw(c)===`plan`?Jw(i):jw(i)||l()},c._setBorrowed=e=>{c.isBorrowed=e,Iw(c)},o.card.append(f.el,p.el),H.set(i,c),Rw(c,i),Iw(c),c.btnDocs.classList.toggle(`visible`,us(i)),a===z.RUNNING&&Qt(c,!0),s||ug(c,i),Ww(),c}function Kw(e){let t=e.planReviewState.reviews.some(e=>e.state===`open`),n=e.planReviewState.reviews.some(u_);return fc({hasPlan:e.hasPlan,pendingPromptKind:e.pendingPromptKind,hasOpenReview:t,hasApprovedReview:n})}function qw(e){let t=B(e);return!t?.isBorrowed||Kw(t)!==`plan`?!1:Jw(e)}function Jw(e){let t=B(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.conversationFace.hide(),t.planFace.show(V(e)),Iw(t),Mh(t,V(e)),!0)}function Yw(e,t){let n=B(e);n&&(n.hasPlan=t===!0,Iw(n),qw(e))}function Xw(e){let t=B(e.id);t&&(t.planReviewState=D_(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),Iw(t),qw(e.id))}function Zw(e){let t=B(e.id);t&&t.planFace.update({draft:e})}function Qw(e){let t=B(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),Iw(t))}function $w(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=B(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function eT(e){for(let[,t]of H)t.planFace.update({isConnected:e})}function tT(e,t){let n=B(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function nT(e,t){let n=B(e);if(!n)return;n.agent=typeof t==`string`?t:null,Iw(n);let r=fi(t);oT(n,`.agent-badge`,`agent`,{on:r!==``,value:r,text:r})}function rT(e,t){let n=B(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function iT(e,t,n){let r=B(e);r&&(aT(r.card,`guarded`,t),aT(r.card,`guardrailsReleased`,n),Tl(r.btnGuardrails,r.card))}function aT(e,t,n){n?e.dataset[t]=``:delete e.dataset[t]}function oT(e,t,n,r){let{on:i,value:a=``,text:o,title:s}=r,c=e.card.querySelector(t);if(i)e.card.dataset[n]=a,c&&(o!==void 0&&(c.textContent=o),s!==void 0&&(c.title=s));else{if(delete e.card.dataset[n],!c)return;o!==void 0&&(c.textContent=``),s!==void 0&&c.removeAttribute(`title`)}}function sT(e,t,n=!1){let r=B(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=_t(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function cT(e,t){let n=B(e);if(!n)return;let r=uw(t);oT(n,`.usage-badge`,`usage`,{on:!!r,text:r||``,title:r?dw(t):void 0})}function lT(e,t,n){return t?{on:!0,value:`compacting`,title:`Context compaction in progress`,text:`compacting`}:e?{on:!0,value:Cw(e),title:`Waiting on a permission or input prompt`,text:dc(Cw(e))}:n?{on:!0,value:`memory`,title:`Held until Glimmervoid has enough free memory to start it`,text:`Waiting for memory`}:{on:!1,title:``,text:``}}function uT(e,t,n=!1,r=!1){let i=B(e);i&&(i.pendingPromptKind=typeof t==`string`?t:null,oT(i,`.prompt-badge`,`prompt`,lT(t,n,r)),i.conversationFace.refresh(),!qw(e)&&(typeof t!=`string`||t===``)&&i.face===`terminal`&&jw(e))}function dT(e,t){let n=B(e);n&&(n.unseenOutcome=t??null)}function fT(e){return e?`sleeping until ~${gt(new Date(e))}`:`scheduled`}function pT(e,t){let n=B(e);n&&oT(n,`.wakeup-badge`,`wakeup`,{on:!!t,value:t?.kind||`wakeup`,text:fT(t?.at),title:t?.reason?`Scheduled revival: ${t.reason}`:`Scheduled revival pending`})}function mT(e,t){let n=B(e);if(!n)return;let r=Array.isArray(t.findings)?t.findings:[],i=t.filesFixed||0,a=null,o=0;!t.skipped&&t.mode===`fix`&&i>0&&(a=`fixed`,o=i),!t.skipped&&t.mode===`report`&&r.length>0&&(a=`flagged`,o=new Set(r.map(e=>e.file)).size);let s={};for(let e of r)s[e.rule]=(s[e.rule]||0)+(e.count||0);let c=Object.keys(s).map(e=>`${e}: ${s[e]}`).join(`, `),l=a===`fixed`?`auto-fixed`:`flagged`;oT(n,`.post-turn-badge`,`pt`,{on:!!a,value:a||void 0,text:`${a===`fixed`?`✓`:`⚠`} ${o}`,title:`Post-turn ${l} ${o} file(s)${c?` (${c})`:``}`})}function hT(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function gT(e,t,n=null){let r=B(e),i=Cw(t)||`none`;r&&hT(r.card,i),oy(V(e),i,Cw(n)||null)}function _T(e,t,n=null){let r=B(e),i=Cw(t)||`none`;r&&hT(r.card,i),cy(V(e),i,Cw(n)||null)}function vT(e,t){ly(V(e),t)}function yT(e,t){let n=B(e);if(!n)return;let r=Cw(t);n.card.dataset.session=r,n.nameEl.textContent=r}function bT(e){let t=B(e);t&&(Vl(t),H.delete(V(e)),L_(V(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),rg(t,V(e)),qm(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),Ww())}function xT(e,t,n){if(!t||!e.term)return;let r=n===z.DONE?`Session complete`:`Session failed`,i=n===z.DONE?`\x1B[34m`:`\x1B[31m`;e.term.write(`\r\n\r\n\x1b[2m${i} ${r}\x1b[0m\r\n\r\n\x1b[2m Open the session actions menu and choose Restart to start a new session.\x1b[0m\r\n`)}function ST(e,t){let n=B(e);n?al(n).show(`error`,t):_r({source:`Session`,sessionId:typeof e==`string`?e:void 0,message:t})}function CT(e,t){let n=B(e);if(!n)return;let r=n.card.querySelector(`:scope > .session-failure-reason`);if(!(n.currentState===z.FAILED&&t)){r?.remove();return}let i=r??L(`p`,`session-failure-reason`);i.setAttribute(`role`,`status`),i.textContent=t,r||n.termWrap.before(i)}function wT(e,t){e.term&&(t===z.DONE||t===z.FAILED)&&(e.term.clear(),e.term.reset())}function TT(e){let t=H.get(e);t&&Dc({state:t.currentState,unseenOutcome:t.unseenOutcome})&&document.visibilityState===`visible`&&(Hd()||document.hasFocus())&&T({type:`dismiss`,id:e,expectedState:t.currentState})}function ET(e,t,n){let r=document.activeElement;return Ou({previousState:t,nextState:n,isPhoneLayout:Hd(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}function DT(e,t,n,r=``){let i=B(e);if(!i)return;let a=Cw(t),o=i.currentState;i.currentState=a,a!==z.RUNNING&&(i.awaitingBackgroundTasks=!1),i.conversationFace.refresh(),a!==o&&(i.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),Qt(i,a===z.RUNNING)),o===z.DORMANT&&a!==z.DORMANT&&ug(i,V(e)),hc({state:a})===`resting`&&Oa(V(e)),i.card.dataset.state=a,i.card.toggleAttribute(`data-monitoring`,_t(a,i.awaitingBackgroundTasks)),Iw(i),(a===z.WAITING&&o!==z.WAITING||a===z.COMPLETE&&o!==z.COMPLETE)&&!qu(r)&&gn()&&Sf(Bn()),ET(i,o,a)&&T({type:`dismiss`,id:V(e),expectedState:z.COMPLETE});let s=a===z.DONE||a===z.FAILED,c=o!==z.DONE&&o!==z.FAILED&&o!==z.INITIALIZING;s&&c&&(i.card.classList.remove(`completion-flash`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.card.classList.add(`completion-flash`),i.card.addEventListener(`animationend`,()=>i.card.classList.remove(`completion-flash`),{once:!0})})}),gn()&&Sf(Bn())),(a===z.DONE||a===z.FAILED)&&xT(i,c,a),a===z.INITIALIZING&&wT(i,o),Ww()}var OT=`(no path)`;function kT(e){if(!e)return OT;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||`(no path)`}function AT(e,t,n){let r=Array.isArray(e)?e:[],i=new Map;for(let e of r){let n=t(e),r=n?String(n):OT,a=i.get(r);a||(a={key:r,label:r===`(no path)`?OT:kT(r),title:r,rows:[]},i.set(r,a)),a.rows.push(e)}if(n)for(let e of n){if(!e)continue;let t=String(e);t===`(no path)`||i.has(t)||i.set(t,{key:t,label:kT(t),title:t,rows:[]})}let a=[...i.values()];return a.sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0,sensitivity:`base`})||e.key.localeCompare(t.key)),{flat:i.size<=1,order:a.map(e=>e.key),groups:a}}function jT(e,t){if(!e||!Array.isArray(e.groups))return[];let n=t||new Set,r=[];if(e.flat){for(let t of e.groups)for(let e of t.rows)r.push(e.id);return r}let i=new Map(e.groups.map(e=>[e.key,e]));for(let t of e.order){if(n.has(t))continue;let e=i.get(t);if(e)for(let t of e.rows)r.push(t.id)}return r}function MT({onAdd:e,onForget:t}){let n=L(`div`,`session-group-header`),r=L(`span`,`session-group-label`),i=L(`span`,`session-group-count`),a=L(`span`,`session-group-rule`);a.setAttribute(`aria-hidden`,`true`);let o=L(`button`,`session-group-add`,`+`);o.type=`button`,o.addEventListener(`click`,()=>e(n.dataset.path,n.dataset.label));let s=L(`button`,`session-group-forget`);return s.type=`button`,s.append(sr(ur)),s.addEventListener(`click`,()=>t(n.dataset.path)),n.append(r,i,a,s,o),{header:n,label:r,count:i,addButton:o,forgetButton:s}}function NT(e,t,n){let{header:r,label:i,count:a,addButton:o,forgetButton:s}=e,c=t.key===OT,l=t.rows.length===0;r.dataset.path=t.key,r.dataset.label=t.label,r.title=t.title,r.toggleAttribute(`data-empty`,l),i.textContent=t.label,a.textContent=String(t.rows.length),a.title=`${t.rows.length} ${t.rows.length===1?`session`:`sessions`}`,o.hidden=c,s.hidden=c||!l,c||(o.title=`Add a session to ${t.label}`,o.setAttribute(`aria-label`,`Add a session to ${t.label}`)),!c&&l&&(s.title=`Remove ${t.label} from the ${n}`,s.setAttribute(`aria-label`,`Remove ${t.label} from the ${n}`))}var PT={waitingCount:0,finishedCount:0,failedCount:0},FT={failed:Wt[z.FAILED],waiting:Wt[z.WAITING],finished:Wt[z.COMPLETE]},IT={failed:`failed`,waiting:`needs you`,finished:`finished`},LT=[`NI.`,`THIS QUEUE IS DECEASED`,`AND NOW, NOTHING AT ALL`,`TOUCH GRASS, BRIEFLY`,`GO STRETCH`,`THE AGENTS ARE COPING`,`MORALE IS ADEQUATE`,`REQUIESCAT`,`STANDARDS ARE BEING MET`,`THE AGENTS WANT SPACE`,`NO CAUSE FOR ALARM`,`KINDLY GO AWAY`,`THEY COPE WITHOUT YOU`,`PRESS HARDER, PERHAPS`,`OH, WELL DONE`,`THAT DID NOTHING. AGAIN.`,`WELL. YOU TRIED.`,`SUBJECT PRESSED BUTTON`,`THE BUTTON WORKS. YOU?`,`WE HAVE NO PROBLEMS`,`THE LAWYERS SAY RELAX`,`BRING A TOWEL`],RT=2500,zT=`cubic-bezier(0.16, 1, 0.3, 1)`,BT=`cubic-bezier(0.5, 0, 0.2, 1)`,VT=260,HT=200,UT=200,WT=300,GT=28,KT=360,qT=420,JT=200,YT=3,XT=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),ZT=new WeakMap;function QT(e){let t=ZT.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function $T(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function eE(){return XT?.matches??!1}function tE(e){return e.map(e=>({easing:zT,...e}))}function nE(e,t){let n=L(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${Mc.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${Mc.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${Mc.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${Mc.overflowSlot}px`);let r=L(`span`,`attention-banner-chips`),i=L(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=L(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=L(`span`,`attention-banner-status`);o.append(r,L(`span`,`attention-banner-count`),a);let s=L(`button`,`attention-banner-jump-row`);return s.type=`button`,s.append(o),t&&(t.classList.add(`attention-banner-jump`),s.append(t)),n.addEventListener(`click`,()=>e.onJump()),n.append(s),ZT.set(n,{hooks:e,tiles:[],tileById:new Map,headId:null,flyingIds:new Set,tetheredId:null,tetheredRow:null,lastAllClearLine:null,allClearLineTimer:null,pressAnimations:[]}),typeof ResizeObserver==`function`&&new ResizeObserver(()=>iE(n)).observe(r),rE(n,PT,[]),n}function rE(e,t,n){let r=QT(e);r.tiles=n,R(e,`.attention-banner-count`).textContent=Lc(t);let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&bE(e,r),iE(e)}function iE(e){let t=QT(e),n=R(e,`.attention-banner-chips`),r=R(n,`.attention-tile-overflow`),i=$T(e),a=t.tiles.slice(0,Nc(n.clientWidth,t.tiles.length)),o=new Set(a.map(({id:e})=>e)),s=new Map;if(i)for(let[e,n]of t.tileById)s.set(e,n.getBoundingClientRect().left);let c=[...t.tileById].filter(([e])=>!o.has(e)),l=c.map(([,e])=>({left:e.offsetLeft,top:e.offsetTop}));c.forEach(([e,n],r)=>{t.tileById.delete(e),t.flyingIds.has(e)||!i?n.remove():cE(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??oE(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),sE(s,i,a===0),(s.parentElement!==n||aE(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;r.hidden=p===0,r.textContent=`+${p}`,r.title=`${p} more after these`,t.headId=a[0]?.id??null;let m=t.tiles[0]?.kind;if(m&&(e.dataset.headKind=m),m||delete e.dataset.headKind,t.tetheredId&&!o.has(t.tetheredId)&&fE(e,null),i){for(let e of d)lE(e);a.forEach(({id:e},n)=>{let r=t.tileById.get(e),i=s.get(e);if(!r||i===void 0)return;let a=i-r.getBoundingClientRect().left;e===t.headId&&e!==u?dE(r,a):a!==0&&uE(r,a,n)})}}function aE(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function oE(e,t){let n=L(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=L(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>fE(e,t)),n.addEventListener(`pointerleave`,()=>fE(e,null)),n}function sE(e,{kind:t,name:n},r){e.dataset.kind=t,e.toggleAttribute(`data-head`,r);let i=`${n}, ${IT[t]}`;e.title=i,e.setAttribute(`aria-label`,i),xr(R(e,`.attention-tile-icon`),FT[t])}function cE(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=eE()?[{opacity:1},{opacity:0}]:tE([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:UT,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function lE(e){let t=eE()?[{opacity:0},{opacity:1}]:tE([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:HT})}function uE(e,t,n){eE()||e.animate(tE([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:WT,delay:n*GT,fill:`backwards`})}function dE(e,t){eE()?e.animate([{opacity:.35},{opacity:1}],{duration:KT,easing:zT}):e.animate(tE([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:KT})}function fE(e,t){let n=QT(e),r=t?n.tileById.get(t):void 0,i=r&&t?t:null;if(i===n.tetheredId||(n.tetheredId&&n.tileById.get(n.tetheredId)?.toggleAttribute(`data-tethered`,!1),n.tetheredRow?.toggleAttribute(`data-tethered`,!1),n.tetheredRow?.style.removeProperty(`--tether`),n.tetheredId=i,n.tetheredRow=null,!r||!i))return;r.toggleAttribute(`data-tethered`,!0);let a=n.hooks.rowFor(i);if(!a)return;let o=getComputedStyle(r).getPropertyValue(`--tile`).trim();o&&a.style.setProperty(`--tether`,o),a.toggleAttribute(`data-tethered`,!0),n.tetheredRow=a}function pE(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function mE(e,t,n){let r=QT(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!$T(e)){n();return}fE(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=pE(a?.querySelector(`.session-row-glyph`)??a),c=i.cloneNode(!0);if(!(c instanceof HTMLElement)){r.flyingIds.delete(t),n();return}c.classList.add(`attention-tile-ghost`),c.setAttribute(`aria-hidden`,`true`),c.removeAttribute(`aria-label`),c.tabIndex=-1,c.style.left=`${o.left}px`,c.style.top=`${o.top}px`,c.style.width=`${o.width}px`,c.style.height=`${o.height}px`,document.body.append(c),i.style.visibility=`hidden`;let l=c.animate(hE(o,s),gE(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function hE(e,t){return!t||eE()?[{opacity:1},{opacity:0}]:[{transform:`none`,opacity:1},{transform:`translateY(-5px) scale(1.2)`,opacity:1,offset:.25},{transform:`translate(${t.left+t.width/2-(e.left+e.width/2)}px, ${t.top+t.height/2-(e.top+e.height/2)}px) scale(${Math.min(1,t.width/e.width)})`,opacity:.2}]}function gE(e){return!e||eE()?{duration:JT,fill:`forwards`}:{duration:qT,easing:BT,fill:`forwards`}}function _E(e){let t=QT(e);e.hasAttribute(`data-empty`)&&yE(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!$T(e))return;let n={duration:VT};if(t.pressAnimations.push(e.animate(tE([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!eE()){t.pressAnimations.push(e.animate(tE([{transform:`none`},{transform:`scale(0.97) translateY(1px)`,offset:.3},{transform:`none`}]),n));for(let r of e.querySelectorAll(`.attention-banner-jump .kbd`))t.pressAnimations.push(r.animate(tE([{transform:`none`},{transform:`translateY(${YT}px)`,offset:.3},{transform:`none`}]),n),r.animate(tE([{transform:`none`},{transform:`translateY(-${YT}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function vE(e){let t=LT.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??LT[0]}function yE(e,t){let n=vE(t.lastAllClearLine);t.lastAllClearLine=n,R(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>bE(e,t),RT)}function bE(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var xE=e=>e.ui.path,SE=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),CE=null,wE=null,TE=null,EE=null,DE=null,OE=null,kE=null,AE=!1,jE=!1,ME=new Map,NE=new Map,PE=new Map,FE=new Map,IE=null,LE=``,RE=[],zE=new Set;function BE(){return jT(HE(ZE()),zE)}function VE(e){let t=IE;if(IE=e||null,t&&t!==IE){let e=NE.get(t);e&&(e.tabIndex=-1,e.setAttribute(`aria-selected`,`false`))}if(IE){let e=NE.get(IE);e&&(e.tabIndex=0,e.setAttribute(`aria-selected`,`true`))}}function HE(e){return AT(e,xE,Tu(e,xE))}function UE(e){let t=FE.get(e.key),n=PE.get(e.key);return(!t||!n)&&(t=MT({onAdd:zu,onForget:e=>{Eu(e),rD()}}),n=L(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),FE.set(e.key,t),PE.set(e.key,n)),NT(t,e,`rail`),n.setAttribute(`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function WE(){return AE}function GE(){return W.snapshot().focusedSessionId}function KE({rail:e,center:t,resizer:n}){if(CE=e,TE=t,!CE||!TE)return;let r=CE,i=TE;YE(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,Wn(Pa)),wE=nE({onJump:sD,rowFor:e=>NE.get(e)},Ba());let a=L(`details`,`rail-status-key`);a.append(L(`summary`,`rail-status-key-summary`,`Status key`),bu()),r.append(wE,a),DE=L(`div`,`focus-empty`),DE.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,OE=DE.querySelector(`.focus-empty-title`),kE=DE.querySelector(`.focus-empty-desc`),EE=L(`div`,`focus-card-slot`),i.append(DE,EE),r.addEventListener(`keydown`,XE)}var qE={minPx:180,maxPx:480},JE=16;function YE(e){e&&CE&&el({resizer:e,column:CE,widthHost:CE,widthProperty:`--rail-width`,bounds:qE,keyStepPx:JE,getStoredWidth:jn,setStoredWidth:un})}function XE(e){if(e.key===`Delete`||e.key===`Backspace`){let t=e.target instanceof HTMLElement?e.target:null,n=t?.dataset.id;if(!n||NE.get(n)!==t)return;e.preventDefault(),Gu(n,ME.get(n));return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=wc(BE(),IE,e.key===`ArrowDown`?1:-1);t!=null&&(e.preventDefault(),VE(t),NE.get(t)?.focus())}function ZE(){return vc(Iu(QE))}function QE(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function $E(e){let{row:t,refs:n}=ou(`button`);t.type=`button`,t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,()=>eD(e)),t.addEventListener(`pointerenter`,()=>{wE&&fE(wE,e)}),t.addEventListener(`pointerleave`,()=>{wE&&fE(wE,null)});let{item:r,removeButton:i}=su(t,()=>Gu(e,ME.get(e)));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,Object.assign(t,{_refs:n,_row:r})}function eD(e){let t=Nu(e);t&&(pD(e),lD(t,e))}function tD(e,{id:t,ui:n,state:r,name:i},a){let o=ME.get(t)||`none`;mu(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a}),e.classList.toggle(`focused`,t===GE());let s=t===IE;e.setAttribute(`aria-selected`,String(s)),e.tabIndex=s?0:-1}function nD(e,t){if(!AE)return;let n=e?.card?.dataset.id,r=n?NE.get(n):null;r&&(t===`flag`?r.dataset.activity=e._activity||``:Xt(r._refs?.glyph))}en(nD),Zt(()=>{if(AE)for(let[e,t]of NE){let n=H.get(e);n&&(t._refs.elapsed.textContent=Yt(n))}});function rD(){if(!AE)return;let e=CE;if(!e)return;let t=ZE(),n=HE(t),r=new Set,i=jc(t,GE()),a=new Map(i.map(({id:e},t)=>[e,t+1])),o=(e,t)=>{let n=e.map(e=>e.id).join(`,`),i=t._lastOrderKey===n&&t.childElementCount===e.length;for(let n of e){let{id:e}=n;r.add(e);let o=NE.get(e);o||(o=$E(e),NE.set(e,o)),tD(o,n,a.get(e)??null),i||t.appendChild(o._row)}t._lastOrderKey=n},s=new Set(n.order),c=n.groups.map(e=>e.key).join(`
164
- `),l=c===LE;LE=c;for(let t of n.groups){let{header:n,list:r}=UE(t);l||e.append(n,r),o(t.rows,r)}for(let[e,t]of[...FE])s.has(e)||(t.header.remove(),PE.get(e)?.remove(),FE.delete(e),PE.delete(e));for(let[e,t]of NE)r.has(e)||(t._row.remove(),NE.delete(e),e===IE&&(IE=null));for(let e of[...ME.keys()])H.has(e)||ME.delete(e);let u=RE;RE=jT(n,zE);let d=GE();if(d&&!H.has(d)){W.dispatch(`focusSession`,null),IE=null;let e=iD(u,d);if(e){let t=!document.activeElement||document.activeElement===document.body;pD(e),t&&lD(H.get(e),e);return}}mD();let f=GE();if(f){let e=H.get(f);e&&e.card.parentElement!==EE&&dD(e,f)}oD(t,i)}function iD(e,t){let n=e.filter(e=>e===t||H.has(e));return n.length<2?RE.find(e=>H.has(e))??null:wc(n,t,n.indexOf(t)===n.length-1?-1:1)}function aD(){return jc(ZE(),GE())}function oD(e,t){wE&&rE(wE,Pc(e),t)}function sD(){if(!AE)return;wE&&_E(wE);let e=aD()[0]?.id;e&&cD(e)}function cD(e){if(!AE)return;NE.get(e)?.scrollIntoView({block:`nearest`}),wE&&mE(wE,e,()=>uD(e));let t=H.get(e);Nu(e),pD(e),lD(t,e)}function lD(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{AE&&GE()===t&&e.term?.focus()}))}function uD(e){if(SE?.matches||document.hidden)return;let t=NE.get(e);t?.animate&&(t.animate([{transform:`scale(1)`},{transform:`scale(1.045)`,offset:.3},{transform:`scale(1)`}],{duration:360,easing:`cubic-bezier(0.22, 1, 0.36, 1)`}),t._row.animate([{boxShadow:`0 0 0 3px var(--accent)`},{boxShadow:`0 0 0 3px transparent`}],{duration:700,easing:`ease-out`}));let n=H.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function dD(e,t){EE&&(Gr(e,t,EE,{className:`focus-centered`}),mg(e,t,!0))}function fD(){let e=GE();e&&(Wr()===e&&Kr(),W.dispatch(`focusSession`,null))}function pD(e){AE&&H.has(e)&&(TT(e),e!==GE()&&(fD(),W.dispatch(`focusSession`,e),IE=e,Pu(e),rD()))}function mD(){if(!DE||!OE||!kE)return;let e=GE(),t=!!(e&&H.has(e)),n=H.size>0;DE.hidden=t,co(DE,!n),OE.hidden=!n,kE.hidden=!n,!t&&n&&(OE.textContent=`No session selected`,kE.textContent=`Select a session from the rail on the left to focus it here.`)}function hD(e,t){ME.set(V(e),typeof t==`string`&&t?t:`none`),AE&&rD()}function gD(e){AE&&H.has(e)&&pD(e)}function _D(e){return!AE||!H.has(e)?!1:(pD(e),Jw(e))}function vD(e){if(!AE)return;let t=BE()[e-1];t&&eD(t)}function yD(e){if(!AE)return;let t=wc(BE(),IE,e);t!=null&&(eD(t),NE.get(t)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=GE();AE&&e&&TT(e)});function bD(){CE&&(AE=!0,fD(),IE=null,rD(),jE&&aD().length>0?sD():(jE&&wE&&_E(wE),SD()))}function xD(e){jE=!0;try{e()}finally{jE=!1}}function SD(){if(!AE||GE())return;let e=Fu();e&&pD(e)}function CD(){AE&&=(fD(),IE=null,!1)}var wD=`t-[0-9a-f]{8}`,TD=`No findings. Open a markdown file in a connected editor.`,ED=`No intent yet. The visions proposes one after its first pass.`,DD=`Unowned`,OD=RegExp(`^${wD}$`);function kD(){return{byProject:{},unowned:[]}}function AD(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.text==`string`?t.text:``;if(!n)return null;let r=Number(t.ts),i=Number(t.hits);return{id:typeof t.id==`string`&&OD.test(t.id)?t.id:null,text:n,uris:Array.isArray(t.uris)?t.uris.filter(e=>typeof e==`string`&&e!==``):[],ts:Number.isFinite(r)&&r>0?r:0,hits:Number.isInteger(i)&&i>0?i:1}}function jD(e){if(Array.isArray(e))return e.map(AD).filter(e=>e!==null);let t=AD(e);return t?[t]:[]}function MD(e){let t=e?.intent;if(!t||typeof t!=`object`)return kD();let n=t;if(!(Object.hasOwn(n,`byProject`)||Object.hasOwn(n,`unowned`)||Object.hasOwn(n,`global`)))return{byProject:{},unowned:jD(n)};let r=n.byProject&&typeof n.byProject==`object`?n.byProject:{},i=[];for(let[e,t]of Object.entries(r)){let n=jD(t);n.length!==0&&e&&i.push([e,n])}return{byProject:Object.fromEntries(i),unowned:jD(Object.hasOwn(n,`unowned`)?n.unowned:n.global)}}function ND(e,t){let n=typeof t?.id==`string`?t.id:null;if(!n)return e;let r=e.findIndex(e=>e.id===n);return r<=0?e:[e[r],...e.slice(0,r),...e.slice(r+1)]}function PD(e,t){let n=e||kD(),r=t?.intent;if(!r||typeof r!=`object`)return n;let i=r,a=ND(Array.isArray(i.threads)?jD(i.threads):jD(i),i.active),o=typeof t?.projectId==`string`&&t.projectId?t.projectId:null;if(!o)return{byProject:{...n.byProject},unowned:a};let s={...n.byProject};return a.length===0&&delete s[o],a.length>0&&(s[o]=a),{byProject:s,unowned:n.unowned}}function FD(e,t=null){let n=t&&typeof t.get==`function`?t.get(e):null;return typeof n==`string`&&n?n:e}function ID(e,{key:t,label:n,now:r}){return e.map((e,i)=>({key:`${t}:${e.id||i}`,label:n,text:e.text,hasText:!0,active:i===0,meta:BD(e,r)}))}function LD(e,t=null,n=Date.now()){let r=e||kD(),i=Object.entries(r.byProject||{}).filter(([e,t])=>e&&Array.isArray(t)&&t.length>0).map(([e,n])=>({projectId:e,label:FD(e,t),threads:n})).sort((e,t)=>e.label.localeCompare(t.label)).flatMap(({projectId:e,label:t,threads:r})=>ID(r,{key:e,label:t,now:n})),a=ID(Array.isArray(r.unowned)?r.unowned:[],{key:`unowned`,label:DD,now:n});return i.length+a.length>0?[...a,...i]:[{key:`unowned`,label:DD,text:ED,hasText:!1,active:!1,meta:``}]}function RD(e){return e?.text?`proposed by visions`:``}function zD(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:D(Number(t)-n,{rounding:`floor`,wording:`spelled`,suffix:` ago`,justNowBelowSeconds:60})}function BD(e,t=Date.now()){let n=RD(e);if(!n)return``;let r=typeof e?.id==`string`&&e.id?`thread ${e.id}, `:``,i=zD(e?.ts,t);return i?`${r}${n}, ${i}`:`${r}${n}`}function VD(e){let t=Number(e?.range?.start?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function HD(e){let t=Number(e?.range?.start?.character);return Number.isFinite(t)?t:0}function UD(e){let t=Number(e?.range?.start?.line);return Number.isFinite(t)?t:0}function WD(e){let t=typeof e==`string`?e:``;if(!t)return``;let n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);if(!r)return t;try{return decodeURIComponent(r)}catch{return r}}function GD(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(Math.floor(e),0):0}function KD(e){let t=GD(e);return t===1?`1 finding`:`${t} findings`}function qD(e){let t=GD(e);return t===1?`1 comment`:`${t} comments`}function JD(e){let t=GD(e?.findings?.length),n=GD(e?.comments?.length),r=typeof e?.hand==`string`&&e.hand?1:0,i=[];return r>0&&i.push(`raised hand`),t>0&&i.push(KD(t)),n>0&&i.push(qD(n)),i.length>0?i.join(`, `):KD(0)}function YD(e){let t=typeof e==`string`?e.trim():``;return t?`Raised hand: ${t}`:``}function XD(e){return(typeof e?.hand==`string`?e.hand.trim():``)||null}function ZD(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=XD(t);return i?(n.set(r,i),n):(n.delete(r),n)}function QD(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=typeof e?.hand==`string`?e.hand.trim():``;n&&r&&t.set(n,r)}return t}var $D=`hand`,eO=`unseen`,tO=`
165
- `;function nO(e){let t=2166136261,n=3266489909;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619)>>>0,n=Math.imul(n^i,2246822507)>>>0}return`${t.toString(36).padStart(7,`0`)}${n.toString(36).padStart(7,`0`)}`}function rO(e,t){return nO(JSON.stringify([e,...t]))}function iO(e,t){return rO(`finding`,[e,VD(t),String(t.code??``),String(t.message??``)])}function aO(e,t){return rO(`comment`,[e,uO(t),String(t.message??``)])}function oO(e){return rO(`fix`,[e.uri,SO(e),e.code,e.message,CO(e)])}function sO(e){return rO(`intent`,[e.key,e.text,e.active])}function cO(e,t,n,r=[],i=null){let a=[...n].map(([e,t])=>rO(`hand`,[e,t])).sort(),o=new Set;for(let r of[...e.keys(),...t.keys(),...n.keys()])o.add(rO(`document`,[r]));for(let[t,n]of e)for(let e of n)o.add(iO(t,e));for(let[e,n]of t)for(let t of n)o.add(aO(e,t));for(let e of r)o.add(oO(e));for(let e of LD(i,null,0))e.hasText&&o.add(sO(e));let s=[...o].sort();return{signature:[...a,...s].join(tO),handEntries:a,contentEntries:s}}function lO(e,t){let n=new Set(t.split(tO));return e.handEntries.some(e=>!n.has(e))?$D:e.contentEntries.some(e=>!n.has(e))?eO:null}function uO(e){let t=Number(e?.line);return!Number.isFinite(t)||t<1?`L?`:`L${Math.floor(t)}`}function dO(e){return Array.isArray(e?.diagnostics)?e.diagnostics:[]}function fO(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=dO(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function pO(e){return Array.isArray(e?.comments)?e.comments:[]}function mO(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=pO(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function hO(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.diagnostics)?e.diagnostics:[];n&&r.length!==0&&t.set(n,r)}return t}function gO(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.comments)?e.comments:[];n&&r.length!==0&&t.set(n,r)}return t}function _O(e,t=new Map,n=new Map){let r=[],i=new Set([...e.keys(),...t.keys(),...n.keys()]);for(let a of i){let i=e.get(a),o=t.get(a),s=n.get(a)||null,c=Array.isArray(i)?i:[],l=Array.isArray(o)?o:[];(c.length!==0||l.length!==0||s)&&r.push({uri:a,name:WD(a)||a,hand:s,findings:[...c].sort((e,t)=>UD(e)-UD(t)||HD(e)-HD(t)),comments:[...l].sort((e,t)=>(Number(e?.line)||0)-(Number(t?.line)||0))})}return r.sort((e,t)=>vO(e.name,t.name)||vO(e.uri,t.uri)),r}function vO(e,t){return e<t?-1:+(e>t)}var yO=`No fixes yet. Silent fixes appear here once the lane applies or is refused one.`,bO=20;function xO(e){let t=GD(e);return t===1?`1 fix`:`${t} fixes`}function SO(e){let t=Number(e?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function CO(e){return e?.applied===!0?`applied`:`refused`}function wO(e,{uri:t=``,ts:n=0}={}){if(!e||typeof e!=`object`)return null;let r=e,i=typeof r.message==`string`?r.message.trim():``;if(!i)return null;let a=Number(r.line),o=Number(r.ts??n);return{uri:typeof r.uri==`string`&&r.uri?r.uri:t,code:typeof r.code==`string`?r.code:``,line:Number.isFinite(a)&&a>0?Math.floor(a):0,message:i,applied:r.applied===!0,ts:Number.isFinite(o)&&o>0?o:0}}function TO(e){let t=typeof e?.uri==`string`?e.uri:``,n=Number(e?.ts);return wO(e?.fix,{uri:t,ts:Number.isFinite(n)?n:0})}function EO(e,t,{max:n=bO}={}){let r=TO(t);return r?[r,...e].slice(0,Math.max(0,Math.floor(n))):[...e]}function DO(e,{max:t=bO}={}){let n=Array.isArray(e?.fixes)?e.fixes:[],r=[];for(let e of n){let t=wO(e);t&&r.push(t)}return r.slice(0,Math.max(0,Math.floor(t)))}var OO=`No activity yet. The ingest lane reports what your sessions and tools are doing.`,kO=100,AO={terminal:`terminal`,agentLogs:`agent`,git:`git`,fs:`files`,shellHistory:`shell`,editor:`editor`};function jO(e){let t=typeof e==`string`?e:``;return AO[t]||t||`source`}function MO(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:D(Number(t)-n,x)}function NO(e){if(!e||typeof e!=`object`)return null;let t=e,n=Number(t.seq);if(!Number.isFinite(n))return null;let r=typeof t.summary==`string`?t.summary.trim():``;if(!r)return null;let i=Number(t.ts),a=t.scope&&typeof t.scope==`object`?t.scope:{};return{seq:Math.floor(n),source:typeof t.source==`string`?t.source:``,kind:typeof t.kind==`string`?t.kind:``,ts:Number.isFinite(i)&&i>0?i:0,summary:r,root:typeof a.root==`string`&&a.root?a.root:null,sessionId:typeof a.sessionId==`string`&&a.sessionId?a.sessionId:null}}function PO(e){let t=Array.isArray(e?.events)?e.events:[],n=[];for(let e of t){let t=NO(e);t&&n.push(t)}return n}function FO(e){let t=Number(e?.overflow);return!Number.isFinite(t)||t<=0?0:Math.floor(t)}function IO(e){let t=GD(e);return t<=0?``:t===1?`1 more event not shown`:`${t} more events not shown`}function LO(e,t){return[...e].sort((e,t)=>t.seq-e.seq).slice(0,Math.max(0,Math.floor(t)))}function RO(e,t,{max:n=kO}={}){let r=PO(t);if(r.length===0)return LO(e,n);let i=new Map;for(let t of e)i.set(t.seq,t);for(let e of r)i.set(e.seq,e);return LO([...i.values()],n)}function zO(e,{max:t=kO}={}){return LO(PO(e),t)}function BO(e){let t=GD(e);return t===1?`1 event`:`${t} events`}function VO(e){if(!e?.root)return`machine`;let t=e.root.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var HO=new Map,UO=new Map,WO=new Map,GO=kD(),KO=new Map,qO=null,JO=!0,YO=[],XO=0,ZO=[],QO=null,$O=()=>!1,ek=new Set,tk=cO(HO,UO,WO,ZO,GO),nk=Qn(),rk=Oe({getAck:()=>nk,setAck:e=>{nk=e,Ln(e)},signature:()=>tk.signature,isLooking:()=>$O()});function ik(e){for(let t of ek)t(e)}function ak(){tk=cO(HO,UO,WO,ZO,GO),tk.signature!==``&&rk.refresh(),QO?.(lO(tk,nk))}function ok(e){ik(e),ak()}function sk(){return{findingsByUri:HO,commentsByUri:UO,handsByUri:WO,intent:GO,projectNamesById:KO,isEnabled:qO,isConnected:JO,activityEvents:YO,activityOverflow:XO,fixEntries:ZO}}function ck(e){ek.add(e)}function lk(e){$O=e,ak()}function uk(e){QO=e,ak()}function dk(){tk.signature!==``&&rk.acknowledge(),ak()}function fk(e){KO=e instanceof Map?e:new Map,ik([`intent`])}function pk(e){qO=e?.visions?.enabled===!0,ik([`feed`])}function mk(e){JO=e,ik([`connection`])}function hk(e){ZO=EO(ZO,e),ok([`fixes`])}function gk(e){HO=fO(HO,e),ok([`feed`])}function _k(e){UO=mO(UO,e),ok([`feed`])}function vk(e){WO=ZD(WO,e),ok([`feed`])}function yk(e){GO=PD(GO,e),ok([`intent`])}function bk(e){YO=RO(YO,e),XO=FO(e),ok([`activity`])}function xk(e){YO=zO(e),XO=0,ok([`activity`])}function Sk(e){HO=hO(e),UO=gO(e),WO=QD(e),GO=MD(e),ZO=DO(e),ok([`intent`,`feed`,`fixes`])}var Ck=n(a(),e());u({glimmervoidId:a().min(1),event:a().min(1),token:a().nullable().optional(),payload:Ck}),u({id:a().min(1),name:a().min(1),event:a().min(1),matcher:a().optional(),type:o([`command`,`http`]),command:a().optional(),url:a().optional(),timeout:i().int().positive().optional(),enabled:t(),projects:c(a()).optional()}).passthrough();var wk=`Claude Code hooks injected into every session Glimmervoid spawns.`,Tk=`Loading hooks`,Ek=`No hooks yet. A hook runs a command, or calls a URL, when a Claude Code event fires in a Glimmervoid session. Start from one of these, or add your own.`,Dk=`Start from`,Ok=`Filter by name, event or command`,kk=`Nothing matches that filter.`,Ak=`Preview`,jk=`The entry this becomes in the per-session settings file.`,Mk=`Duplicate`,Nk=`Discard changes`,Pk=`Close the editor and lose the unsaved changes?`,Fk=`Esc cancels. Ctrl+Enter saves.`,Ik=4,Lk=`A change reaches a session at its next start or restart. Claude Code sessions only; Codex and Grok sessions do not read this file.`,Rk=`Glimmervoid's own hooks`,zk=`Always present, read-only. Status detection depends on them.`,Bk=`Your hooks`,Vk=`New hook`,Hk=`Edit hook`,Uk=`Saved to config.json.`,Wk=`All projects`,Gk=`This event takes no matcher.`,Kk=`Blank uses Claude Code's default for the event.`,qk=Object.freeze([{value:`command`,label:`Command`,hint:`Run a shell command. It receives the event JSON on stdin.`},{value:`http`,label:`HTTP`,hint:`POST the event JSON to a URL.`}]),Jk=Object.freeze([{id:`lint`,label:`Lint after edits`,summary:`PostToolUse on Edit|Write`,draft:{name:`Lint after edits`,event:`PostToolUse`,matcher:`Edit|Write`,type:`command`,command:`npx biome check --write "$(jq -r .tool_input.file_path)"`}},{id:`notify`,label:`Notify on Stop`,summary:`Stop, command`,draft:{name:`Notify on Stop`,event:`Stop`,matcher:``,type:`command`,command:`command -v notify-send >/dev/null 2>&1 && notify-send "Claude finished a turn" || { command -v osascript >/dev/null 2>&1 && osascript -e 'display notification "Claude finished a turn" with title "Claude Code"'; }`}},{id:`guard`,label:`Guard destructive Bash`,summary:`PreToolUse on Bash, exit 2 blocks`,draft:{name:`Guard destructive Bash`,event:`PreToolUse`,matcher:`Bash`,type:`command`,command:`jq -r .tool_input.command | grep -Eq "rm -rf|git push --force" && exit 2 || exit 0`}},{id:`log`,label:`Log every prompt`,summary:`UserPromptSubmit, appends JSON`,draft:{name:`Log every prompt`,event:`UserPromptSubmit`,matcher:``,type:`command`,command:`cat >> ~/.claude/prompts.jsonl`}}]),Yk=Object.freeze({hooks:[],builtin:[],events:[]});function Xk(e){return!e||typeof e.error==`string`}function Zk(e){return!e||typeof e.error!=`string`?``:e.error}function Qk(e,t){let n=e?.[t];return Array.isArray(n)?n:Yk[t]}var $k=e=>Qk(e,`hooks`),eA=e=>Qk(e,`builtin`),tA=e=>Qk(e,`events`);function nA(e){let t=e?.limits?.maxTimeoutSec;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:600}function rA(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function iA(e){let t=$k(e),n=t.filter(e=>e.enabled!==!1).length;return[{label:`yours`,value:String(t.length),tone:null},{label:`enabled`,value:String(n),tone:t.length>0&&n===0?`warn`:null},{label:`built in`,value:String(eA(e).length),tone:null}]}function aA(e,t){let n=new Map(t.map((e,t)=>[e.name,t])),r=e=>n.get(e.event)??t.length;return[...e].sort((e,t)=>{let n=r(e)-r(t);return n===0?String(e.name).localeCompare(String(t.name)):n})}function oA(e,t){let n=String(t||``).trim().toLowerCase();return n?e.filter(e=>[e.name,e.event,e.matcher,e.command,e.url].some(e=>typeof e==`string`&&e.toLowerCase().includes(n))):e}function sA(e){return e.length>=Ik}function cA(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.event===n.event?e.hooks.push(n):t.push({event:n.event,hooks:[n]})}return t}function lA(e){let t=e.type===`http`?{type:`http`,url:e.url||``}:{type:`command`,command:e.command||``};Number.isInteger(e.timeout)&&Number(e.timeout)>0&&(t.timeout=e.timeout);let n=e.matcher?{matcher:e.matcher,hooks:[t]}:{hooks:[t]};return JSON.stringify({hooks:{[e.event]:[n]}},null,2)}function uA(e){return`${e} copy`}function dA(e,t){return e.find(e=>e.name===t)||null}function fA(e,t){let n=dA(e,t);return n?n.matcher?`Matches ${n.matcher}. Blank matches every ${n.name}.`:Gk:``}function pA(e){return e.type===`http`?e.url||``:e.command||``}function mA(e){let t=qk.find(t=>t.value===e);return t?t.label:String(e||``)}function hA(e){return!Number.isInteger(e.timeout)||Number(e.timeout)<=0?``:`${e.timeout}s timeout`}function gA(e,t){let n=Array.isArray(e.projects)?e.projects:[];return n.length===0?Wk:n.map(e=>{let n=t.find(t=>t.id===e);return n?n.name:e}).join(`, `)}function _A(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function vA(e){return _A(e)}function yA(e,t){let n=Array.isArray(e.projects)?e.projects:[],r=new Set(t.map(e=>e.id));return n.filter(e=>!r.has(e))}function bA(e){let t=e[0];return{id:null,name:``,event:t?t.name:``,matcher:``,type:`command`,command:``,url:``,timeout:``,enabled:!0,projects:[]}}function xA(e){return{id:e.id??null,name:e.name||``,event:e.event||``,matcher:e.matcher||``,type:e.type===`http`?`http`:`command`,command:e.command||``,url:e.url||``,timeout:Number.isInteger(e.timeout)?String(e.timeout):``,enabled:e.enabled!==!1,projects:Array.isArray(e.projects)?[...e.projects]:[]}}function SA(e,t,n=600){if(!e.name.trim())return`Give the hook a name.`;let r=dA(t,e.event);if(!r)return`Pick an event.`;if(e.matcher.trim()&&!r.matcher)return`${r.name} takes no matcher.`;if(e.type===`http`&&r.http===!1)return`${r.name} does not support HTTP hooks.`;if(e.type===`command`&&!e.command.trim())return`Enter the command to run.`;if(e.type===`http`&&!/^https?:\/\/\S+$/i.test(e.url.trim()))return`Enter a URL starting with http:// or https://.`;if(e.timeout.trim()!==``){let t=Number(e.timeout);if(!Number.isInteger(t)||t<1||t>n)return`Timeout must be a whole number of seconds from 1 to ${n}.`}return null}function CA(e){let t={name:e.name.trim(),event:e.event,type:e.type,enabled:e.enabled!==!1};return e.id&&(t.id=e.id),e.matcher.trim()&&(t.matcher=e.matcher.trim()),e.type===`command`&&(t.command=e.command.trim()),e.type===`http`&&(t.url=e.url.trim()),e.timeout.trim()!==``&&(t.timeout=Number(e.timeout)),e.projects.length>0&&(t.projects=[...e.projects]),t}function wA(e,t){let n={...bA(t),...e.draft};return dA(t,n.event)||(n.event=bA(t).event),n}function TA(e,t){return JSON.stringify(CA(e))!==JSON.stringify(t)}function EA(e){return{...e,enabled:e.enabled===!1}}function DA(e){return`Delete the hook "${e.name}"? Sessions already running keep it until they restart.`}var OA=null,kA=null,AA=!1,jA=null,MA=new Set;function NA(){for(let e of MA)e()}function PA(){return{report:OA,hasReportSendFailed:AA}}function FA(e){MA.add(e)}function IA(e){kA=e}function LA(){if(!kA)return;jA=y(`hooks-report`);let e=kA({type:`request-hooks-report`,requestId:jA});e!==!AA&&(AA=!e,NA())}function RA(e){rA(e,jA)&&(OA=e,AA=!1,NA())}function zA(){LA()}function BA(e){return e.filter(e=>!e.hasOwnPhoneScreen).map(e=>{let t=e.label.trim();return{id:e.view,label:t,glyph:e.glyph||t.charAt(0).toUpperCase(),el:e.el}})}var VA=e=>e.ui.path;function HA({onSelectSession:e}){let t=L(`div`,`phone-board`),n=L(`header`,`phone-topbar`),r=nE({onJump:()=>{_E(r);let e=jc(x(),null)[0]?.id;e&&a(e)},rowFor:e=>d.get(e)}),i=null;function a(e){i=e,d.get(e)?.scrollIntoView({block:`nearest`}),mE(r,e,()=>{i===e&&o(e)})}function o(t){i=null,e?.(t)}let s=L(`div`,`phone-board-list`),c=L(`div`,`phone-empty`),l=L(`p`,`phone-empty-title`,`No sessions`),u=L(`p`,`phone-empty-desc`,`Spawn a session to start watching.`);c.append(l,u),t.append(n,s,c,r);let d=new Map,f=new Map,p=new WeakMap,m=new WeakMap,h=new WeakMap,g=0;nt(n);function _(e){let{row:t,refs:n}=ou(`button`);t.type=`button`,t.dataset.id=e,t.addEventListener(`click`,()=>o(e));let{item:r}=su(t,()=>Gu(e));return r.setAttribute(`role`,`listitem`),p.set(t,{refs:n,item:r}),t}function v(){let e=L(`section`,`phone-board-group`),t=MT({onAdd:zu,onForget:e=>{Eu(e),S()}}),n=L(`div`,`phone-board-group-rows`);return n.setAttribute(`role`,`list`),e.append(t.header,n),m.set(e,{...t,rows:n}),e}function y(e,t,n){let r=p.get(e);if(!r)return;let{ui:i,state:a,name:o}=t;mu(e,r.refs,{ui:i,state:a,name:o,mergeStatus:i.card?.dataset.merge||``,attentionPosition:n})}function b(e,t){let n=m.get(e);n&&(NT(n,t,`Board`),n.rows.setAttribute(`aria-label`,`${t.label} sessions`))}function x(){return vc(Iu())}function S(){let e=x(),t=AT(e,VA,Tu(e,VA)),n=Pc(e);g=Fc(n);let i=jc(e,null),a=new Map(i.map(({id:e},t)=>[e,t+1]));rE(r,n,i);let o=new Set(t.order),S=t.order.join(`,`),C=h.get(s)===S&&s.childElementCount===t.groups.length;for(let e of t.groups){let t=f.get(e.key);t||(t=v(),f.set(e.key,t)),b(t,e),C||s.appendChild(t);let n=e.rows.map(e=>e.id).join(`,`),r=m.get(t);if(!r)continue;let i=h.get(r.rows)===n&&r.rows.childElementCount===e.rows.length;for(let t of e.rows){let e=d.get(t.id);e||(e=_(t.id),d.set(t.id,e)),y(e,t,a.get(t.id)??null);let n=p.get(e);n&&(i||r.rows.appendChild(n.item))}h.set(r.rows,n)}h.set(s,S);for(let[e,t]of[...f])o.has(e)||(t.remove(),f.delete(e));let w=new Set(jT(t));for(let[e,t]of[...d]){if(w.has(e))continue;let n=p.get(t);n&&n.item.remove(),d.delete(e)}let T=t.groups.length>0,E=H.size===0;s.hidden=!T,c.hidden=T,co(c,E),l.hidden=E,u.hidden=E,r.hidden=E}function C(e,t){let n=e.card?.dataset.id,r=n?d.get(n):void 0;r&&(t===`flag`?r.dataset.activity=e._activity||``:Xt(p.get(r)?.refs.glyph))}return Zt(()=>{for(let[e,t]of d){let n=H.get(e),r=p.get(t);n&&r&&(r.refs.elapsed.textContent=Yt(n))}}),{el:t,topBarEl:n,refresh:S,renderActivity:C,getAttentionCount:()=>g}}var UA=`clipboard`,WA=`upload`,GA=24,KA=Object.freeze([Object.freeze({id:`esc`,label:`Esc`,bytes:`\x1B`,title:`Send Escape`}),Object.freeze({id:`tab`,label:`Tab`,bytes:` `,title:`Send Tab`}),Object.freeze({id:`left`,label:`←`,bytes:`\x1B[D`,isArrow:!0,title:`Arrow left`}),Object.freeze({id:`up`,label:`↑`,bytes:`\x1B[A`,isArrow:!0,title:`Arrow up`}),Object.freeze({id:`down`,label:`↓`,bytes:`\x1B[B`,isArrow:!0,title:`Arrow down`}),Object.freeze({id:`right`,label:`→`,bytes:`\x1B[C`,isArrow:!0,title:`Arrow right`}),Object.freeze({id:`paste`,label:`Paste`,bytes:null,action:UA,title:`Paste from the clipboard`}),Object.freeze({id:`attach`,label:`Attach`,bytes:null,action:WA,title:`Upload a photo or file to this session`})]);function qA(e){let t=KA.find(t=>t.id===e);return t?t.bytes:null}function JA(e){return!!e&&e.action===UA}function YA(e){return!!e&&e.action===WA}function XA(e,t,n=GA){let r=Math.abs(e)>=Math.abs(t),i=r?e:t;return Math.abs(i)<n?null:r?i>0?`right`:`left`:i>0?`down`:`up`}function ZA(e,t,n=GA){let r=XA(e,t,n);if(!r)return null;let i=r===`left`||r===`right`,a=i?e:t,o=Math.floor(Math.abs(a)/n),s=Math.sign(a)*o*n;return{arrowKeyId:r,stepCount:o,consumedX:i?s:e,consumedY:i?t:s}}var QA={" ":`\0`,"@":`\0`,"[":`\x1B`,"\\":``,"]":``,"^":``,_:``,"?":``};function $A(e){if(e.length!==1)return null;let t=e.toLowerCase();return t>=`a`&&t<=`z`?String.fromCharCode(t.charCodeAt(0)-96):QA[e]??null}function ej({send:e,getSessionId:t,reportProblem:n}){let r=L(`div`,`phone-key-strip`);r.setAttribute(`role`,`toolbar`),r.setAttribute(`aria-label`,`Terminal keys`);let i=null,a=null,o=L(`button`,`phone-key phone-key-ctrl`,`Ctrl`);o.type=`button`,o.title=`Hold Ctrl for the next key you type`,o.setAttribute(`aria-pressed`,`false`),o.addEventListener(`pointerdown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>c(!s())),r.appendChild(o);function s(){return o.getAttribute(`aria-pressed`)===`true`}function c(e){o.setAttribute(`aria-pressed`,String(e))}function l(){return s()?(c(!1),!0):!1}for(let t of KA){t.id===`left`&&r.appendChild(tj(e));let n=L(`button`,t.isArrow?`phone-key phone-key-arrow`:`phone-key`,t.label);n.type=`button`,n.dataset.key=t.id,n.title=t.title,t.isArrow&&n.setAttribute(`aria-label`,t.title),n.addEventListener(`pointerdown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>u(t,n)),r.appendChild(n)}function u(t,r){YA(t)?d(r):JA(t)?rj(e,n):e(qA(t.id))}function d(e){a=e,i||(i=L(`input`,`phone-file-picker`),i.type=`file`,i.hidden=!0,i.addEventListener(`change`,f),r.appendChild(i)),i.click()}function f(){let e=i;if(!e)return;let r=e.files?e.files[0]:null;if(e.value=``,!r)return;let o=t?.();o?p(o,r,a):n(`No session is open to upload to.`)}async function p(e,t,n){n&&(n.disabled=!0),await lm(e,t),n&&(n.disabled=!1)}return{element:r,takeHeldControl:l}}function tj(e){let t=L(`button`,`phone-key phone-arrow-pad`,`Arrows`);t.type=`button`,t.title=`Swipe to send arrow keys`;let n=null,r=null;t.addEventListener(`pointerdown`,e=>{e.preventDefault(),r===null&&(t.setPointerCapture(e.pointerId),r=e.pointerId,n={x:e.clientX,y:e.clientY})}),t.addEventListener(`pointermove`,t=>{if(t.pointerId!==r||!n)return;let i=ZA(t.clientX-n.x,t.clientY-n.y);if(i){for(let t=0;t<i.stepCount;t++)e(qA(i.arrowKeyId));n={x:n.x+i.consumedX,y:n.y+i.consumedY}}});let i=e=>{e.pointerId===r&&(r=null,n=null)};return t.addEventListener(`pointerup`,i),t.addEventListener(`pointercancel`,i),t}var nj=`Paste needs clipboard permission.`;function rj(e,t){let n=null;try{n=navigator.clipboard?.readText?.()}catch{t(nj);return}n?n.then(t=>{t&&e(t)}).catch(()=>t(nj)):t(`Paste is unavailable in this browser.`)}function ij({onBack:e,onShowChanges:t}){let n=L(`div`,`phone-terminal`),r=L(`header`,`phone-topbar phone-terminal-bar`),i=L(`button`,`phone-back`,`‹`);i.type=`button`,i.setAttribute(`aria-label`,`Back to board`),i.addEventListener(`click`,()=>e?.());let a=L(`div`,`phone-terminal-identity`),o=L(`span`,`phone-terminal-name`);o.title=`Double-tap to rename`,o.addEventListener(`dblclick`,()=>E());let s=L(`span`,`session-task-title phone-terminal-title`);Dl(s,()=>D());let c=L(`span`,`phone-terminal-badge`);c.innerHTML=`<span class="phone-terminal-glyph" aria-hidden="true"></span><span class="phone-terminal-label"></span><span class="phone-terminal-elapsed" aria-hidden="true"></span>`;let l=I(c,`.phone-terminal-glyph`,`span`),u=I(c,`.phone-terminal-label`,`span`),d=I(c,`.phone-terminal-elapsed`,`span`);u.before(o),a.append(s,c);let f=L(`button`,`phone-changes`);f.append(sr(lr)),f.type=`button`,f.title=`Show this session's code changes`,f.setAttribute(`aria-label`,`Show this session's code changes`),f.addEventListener(`click`,()=>t?.());let m=L(`div`,`phone-terminal-actions`);r.append(i,a,f,m);let h=L(`div`,`phone-card-slot`),g=L(`div`,`phone-empty`);g.innerHTML=`<p class="phone-empty-title">No session selected</p><p class="phone-empty-desc">Select a session from the board to watch it here.</p>`;let _=pr(`phone-key-status m-0 px-3 py-1`),{element:v,takeHeldControl:y}=ej({send:C,getSessionId:()=>b,reportProblem:e=>_.show(`error`,e)});n.append(r,h,g,_.element,v);let b=null,x=null,S=null;function C(e){let t=b?H.get(b):null;t&&(ig(t,e)?_.clear():_.show(`error`,p))}function w(){let e=b?H.get(b):null;e?.term&&e.term.focus()}h.addEventListener(`click`,w);function T(e){let t=$A(e);return!t||!y()?!1:(C(t),!0)}h.addEventListener(`keydown`,e=>{e.ctrlKey||e.metaKey||e.altKey||T(e.key)&&(e.preventDefault(),e.stopPropagation())},!0),h.addEventListener(`input`,e=>{e instanceof InputEvent&&e.data&&T(e.data.slice(-1))&&(e.stopPropagation(),(b?H.get(b):null)?._resetSoftKeyboardBuffer?.())},!0);function E(){let e=b?H.get(b):null;e&&b&&Nl(e,b,{returnsFocusToTerminal:!1})}function D(){let e=b?H.get(b):null;e&&b&&Al(e,b)}function O(){let e=b?H.get(b):null,t=!!e;if(g.hidden=t,h.hidden=!t,v.hidden=!t,a.hidden=!t,f.hidden=!t,!t){r.removeAttribute(`data-state`),r.removeAttribute(`data-monitoring`),r.removeAttribute(`data-prompt`);return}let n=e.currentState||z.DORMANT;cu(r,{glyph:l,label:u},n,e.awaitingBackgroundTasks,e.pendingPromptKind);let i=e.card?.dataset.session||b;Ml(o)||(o.textContent=i),s.dataset.sessionName=i??``,kl(s,e.taskTitle),d.textContent=Yt(e)}function k(){S&&=(delete S.renameTargetEl,delete S.titleTargetEl,null),o.replaceChildren(),x&&=(lt(x),x.parentElement===m&&x.remove(),null)}function A(e){let t=H.get(e);t&&(b===e&&Wr()===e&&t.card.parentElement===h||(k(),b=e,Gr(t,e,h,{className:`phone-centered`}),x=I(t.card,`.session-actions`,`div`),jt(x,m),t.renameTargetEl=o,t.titleTargetEl=s,S=t),O())}function ee(){k(),Wr()===b&&Kr(),b=null,O()}function te(){if(!b){O();return}let e=H.get(b);e?e.card.parentElement===h?O():(A(b),n.hidden||mg(e,b,!0)):ee()}function ne(){let e=b;e&&mg(H.get(e),e,!1)}function re(){te();let e=b;if(!e)return;let t=H.get(e);t&&(mg(t,e,!0),TT(e))}return Zt(()=>{let e=b?H.get(b):null;e&&(d.textContent=Yt(e))}),O(),{el:n,show:A,clear:ee,refresh:te,reveal:re,unview:ne,getSessionId:()=>b}}var aj=`board`,oj=`terminal`,sj=`changes`,cj=Object.freeze({[sj]:oj}),lj=Object.freeze([{id:aj,label:`Focus`,glyph:`▤`},{id:oj,label:`Terminal`,glyph:`▸`}]),uj=[],dj=new Map,fj=null,pj=new Map,mj=new Map,hj=new Map,gj=null,_j=null,vj=null,yj=null,bj=null,xj=null,Sj=new Map,Cj=new Set,wj={},Tj=!1,Ej=120,Dj=0,Oj=0,kj=0,Aj=null;function jj(){Dj=0,Oj=0}function Mj(){let e=window.visualViewport;fj&&(!Tj||!e?fj.removeAttribute(`data-keyboard`):(fj.style.setProperty(`--phone-vh`,`${e.height}px`),fj.style.setProperty(`--phone-vv-top`,`${e.offsetTop}px`),e.width!==Oj&&(Oj=e.width,Dj=0),Dj=Math.max(Dj,e.height),Dj-e.height>Ej?fj.dataset.keyboard=`open`:fj.removeAttribute(`data-keyboard`)))}function Nj(e,t,n=`phone-nav-item`,r=`phone-nav-dot`){let i=L(`button`,n);i.type=`button`;let a=L(`span`,`phone-nav-glyph`,t);a.setAttribute(`aria-hidden`,`true`),i.append(a,L(`span`,`phone-nav-label`,e));let o=L(`span`,r);return o.setAttribute(`aria-hidden`,`true`),o.hidden=!0,i.appendChild(o),i}function Pj(e){return e?.querySelector(`.phone-nav-dot`)||null}function Fj(e,t){e&&(e.hidden=!t,typeof t==`string`&&(e.dataset.attention=t),typeof t!=`string`&&delete e.dataset.attention)}function Ij(){let e=[];for(let t of uj){if(Cj.has(t.id))continue;let n=hj.get(t.id)||!1;e.push(n),Fj(Pj(Sj.get(t.id)),n)}Fj(Pj(bj),Vc(e))}function Lj(){let e=L(`div`,`phone-nav-more-menu`);e.hidden=!0;for(let t of uj){let n=Nj(t.label,t.glyph,`phone-nav-menu-item`,`phone-nav-dot phone-nav-menu-dot`);n.dataset.screen=t.id,n.hidden=Cj.has(t.id),n.addEventListener(`click`,()=>{Rj(!1),iM(t.id)}),Sj.set(t.id,n),e.appendChild(n)}return e}function Rj(e){xj&&bj&&(xj.hidden=!e,bj.setAttribute(`aria-expanded`,String(e)))}function zj(){return!!xj&&!xj.hidden}function Bj(){let e=L(`nav`,`phone-nav`);e.setAttribute(`aria-label`,`Screens`);for(let t of lj){let n=Nj(t.label,t.glyph);n.dataset.screen=t.id,n.addEventListener(`click`,()=>iM(t.id)),pj.set(t.id,n),e.appendChild(n)}return bj=Nj(`More`,`⋯`),bj.setAttribute(`aria-expanded`,`false`),bj.addEventListener(`click`,()=>Rj(!zj())),e.appendChild(bj),xj=Lj(),e.appendChild(xj),e}function Vj(e,t,n){let r=L(`section`,`phone-screen`);return r.dataset.screen=e,r.setAttribute(`aria-label`,t),r.hidden=!0,n&&r.appendChild(n),mj.set(e,r),r}function Hj(){if(fj)return;gj=HA({onSelectSession:Wj}),en((e,t)=>{Tj&&gj?.renderActivity(e,t)}),_j=ij({onBack:()=>iM(aj),onShowChanges:()=>iM(sj)}),vj=L(`div`,`phone-review`);let e=L(`div`,`phone-screens`),t={[aj]:gj.el,[oj]:_j.el};for(let n of lj)e.appendChild(Vj(n.id,n.label,t[n.id]));e.appendChild(Vj(sj,`Changes`,Uj(vj)));for(let t of uj){let n=L(`div`,`phone-panel phone-${t.id}`);dj.set(t.id,n),e.appendChild(Vj(t.id,t.label,n))}fj=L(`div`,`phone-shell`),fj.id=`phone-shell`,fj.append(e,Bj()),document.body.appendChild(fj),Ij(),window.visualViewport?.addEventListener(`resize`,Mj),window.visualViewport?.addEventListener(`scroll`,Mj),window.addEventListener(`popstate`,$j),document.addEventListener(`click`,e=>{zj()&&xj&&bj&&e.target instanceof Node&&(xj.contains(e.target)||bj.contains(e.target)||Rj(!1))}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&zj()&&Rj(!1)})}function Uj(e){let t=L(`div`,`phone-changes-screen`),n=L(`header`,`phone-topbar phone-changes-bar`),r=L(`button`,`phone-back`,`‹`);return r.type=`button`,r.setAttribute(`aria-label`,`Back to terminal`),r.addEventListener(`click`,()=>iM(oj)),yj=L(`span`,`phone-changes-session`),n.append(r,L(`span`,`phone-changes-title`,`Changes`),yj),t.append(n,e),t}function Wj(e){if(H.has(e)){if(!gj||!_j)throw Error(`Phone shell is not built`);Nu(e,`dormant-fallback`),Pu(e),_j.show(e),iM(oj)}}function Gj(e){return cj[e]??e}function Kj(e,t){return t?{glimmervoidScreen:e,glimmervoidNested:!0}:{glimmervoidScreen:Gj(e)}}function qj(e){let t=e?.glimmervoidScreen;return typeof t==`string`?t:null}function Jj(e){return qj(e)?e.glimmervoidNested===!0?2:1:0}function Yj(e){return e===aj?0:cj[e]||wj.canGoBack?.(e)?2:1}function Xj(e,t){let n=t?e:Gj(e);return qj(history.state)===n&&Jj(history.state)===(t?2:1)}function Zj(){if(!Tj||Aj!==null)return;let e=W.snapshot().phoneScreen||aj,t=Yj(e);if(kj>t){Aj=location.href,history.go(t-kj),kj=t;return}let n=kj===2;kj>0&&!Xj(e,n)&&history.replaceState(Kj(e,n),``),kj===0&&t>0&&(history.pushState(Kj(e,!1),``),kj=1),kj===1&&t===2&&(history.pushState(Kj(e,!0),``),kj=2)}function Qj(){let e=qj(history.state);return e&&nM(e)?(kj=Jj(history.state),e):(e&&history.replaceState(null,``),kj=0,aj)}function $j(e){if(!Tj)return;if(Aj!==null){history.replaceState(history.state,``,Aj),Aj=null,Zj();return}let t=qj(e.state),n=t&&nM(t)?t:aj;kj=Jj(e.state);let r=W.snapshot().phoneScreen;kj<2&&n===r&&wj.canGoBack?.(r)&&wj.onBack?.(r),tM(n),Zj()}function eM(e,t){for(let[n,r]of e)n===t?r.setAttribute(`aria-current`,`page`):r.removeAttribute(`aria-current`)}function tM(e){if(!bj||!_j)throw Error(`Phone shell is not built`);W.dispatch(`setPhoneScreen`,e),Rj(!1),rM();for(let[t,n]of mj)n.hidden=t!==e;wj.onScreenShown?.(e),eM(pj,Gj(e));let t=Sj.has(e);t&&bj.setAttribute(`aria-current`,`page`),t||bj.removeAttribute(`aria-current`),eM(Sj,e),e===oj?_j.reveal():_j.unview()}function nM(e){return mj.has(e)&&!Cj.has(e)}function rM(){if(!yj||!_j)return;let e=_j.getSessionId(),t=e?H.get(e):null,n=t?tn(t):``;yj.textContent=n,yj.title=n}function iM(e){fj&&nM(e)&&(tM(e),Zj())}function aM(e){uj.sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id)),xj?.append(...uj.flatMap(e=>Sj.get(e.id)??[]))}function oM(e){wj=e||{},uj=wj.panels||[]}function sM({sessionId:e,linkedScreenId:t}={}){if(Tj)return;if(Hj(),!fj||!gj||!_j)throw Error(`Phone shell is not built`);Tj=!0,fj.hidden=!1;for(let e of wj.headerControls||[])jt(e,gj.topBarEl);ay(vj);for(let e of uj)jt(e.el,dj.get(e.id)),e.el.hidden=!1;Mj(),e&&_j.show(e);let n=Qj();fM(),t&&nM(t)?iM(t):e&&n===aj?iM(oj):(tM(n),Zj())}function cM(){if(Tj){if(!fj||!_j)throw Error(`Phone shell is not built`);Tj=!1,_j.clear(),ay(null);for(let e of uj)lt(e.el);for(let e of wj.headerControls||[])lt(e);Rj(!1),fj.hidden=!0,fj.removeAttribute(`data-keyboard`),jj(),kj>0&&history.go(-kj),kj=0,Aj=null}}function lM(e){return!Tj||!gj||!_j||!H.has(e)?!1:(Wj(e),Jw(e))}function uM(){return Tj}function dM(){return Tj&&_j?_j.getSessionId():null}function fM(){if(!Tj)return;if(!gj||!_j)throw Error(`Phone shell is not built`);_M(),gj.refresh(),_j.refresh(),rM(),Gj(W.snapshot().phoneScreen||aj)===oj&&!_j.getSessionId()&&iM(aj);let e=Pj(pj.get(aj));e&&(e.hidden=gj.getAttentionCount()===0)}function pM(e){return Tj?(Wj(e),!0):!1}function mM(e){return!Tj||!nM(e)?!1:(iM(e),!0)}function hM(e,t){t&&Cj.delete(e),t||Cj.add(e);let n=Sj.get(e);n&&(n.hidden=!t);let r=mj.get(e);r&&!t&&(r.hidden=!0),Ij(),!t&&Tj&&W.snapshot().phoneScreen===e&&iM(aj)}function gM(e,t){hj.set(e,typeof t==`string`&&t?t:t===!0),Ij()}function _M(){if(!_j)throw Error(`Phone shell is not built`);if(_j.getSessionId())return;let e=Fu();e&&(_j.show(e),Pu(e,{rememberFocus:!1}))}var vM={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},yM=new Set([`FAILURE`,`ERROR`]);function bM(e){return vM[e]}function xM(e){return e.state===`MERGED`?`Already merged`:e.state===`OPEN`?e.isDraft?`Drafts cannot be merged`:e.isInMergeQueue?`Already in the merge queue`:e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?`Resolve the merge conflicts first`:e.checks.failing.length>0||e.checks.state!==null&&yM.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function SM(e){return e.state===`MERGED`?`merged`:e.isDraft?`draft`:e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?`conflicts`:e.mergeStateStatus===`BEHIND`?`behind`:e.checks.state===`FAILURE`||e.checks.state===`ERROR`?`checks-failing`:e.reviewDecision===`CHANGES_REQUESTED`?`changes-requested`:e.unresolvedThreads>0?`unresolved-threads`:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?`checks-pending`:e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?`needs-approval`:e.mergeable===`MERGEABLE`&&[`CLEAN`,`HAS_HOOKS`,`UNSTABLE`].includes(e.mergeStateStatus)?`ready`:`unknown`}function CM(e){let t=We.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:SM(t)}}var wM=`> [!NOTE]
166
- > Automated review. Not written by a human.`,TM=St.options.join(`|`),EM=String.raw`\*\*(?:\[([^\]\n]+)\]\s+)?(${TM})\*\*`;function DM(e){return[...e.matchAll(new RegExp(EM,`g`))].flatMap(e=>{let t=St.safeParse(e[2]);return t.success?[t.data]:[]})}function OM(e){let t=new RegExp(String.raw`^${EM}\s*(?:\r?\n|$)`).exec(e);if(!t)return null;let n=St.safeParse(t[2]);return n.success?{reviewer:t[1]??null,severity:n.data,length:t[0].length}:null}function kM(e){let t=e.trimStart();return t.startsWith(`> [!NOTE]
167
- > Automated review. Not written by a human.`)?t.slice(53).trim():e.trim()}var AM=`(line not in the diff)`,jM=String.raw`- ${EM}`,MM=String.raw`\*\*\x60([^\x60\n]+)\x60\*\* ${AM.replace(/[()]/g,`\\$&`)}`,NM=new RegExp(String.raw`^(?:${jM}|${MM})`,`gm`),PM=new RegExp(String.raw`^${jM}\s*(?:\x60([^\x60\n]+)\x60:\s*)?`),FM=new RegExp(String.raw`^${MM}\s*`);function IM(e){return St.options.find(t=>e.includes(t))??null}function LM(e){let t=PM.exec(e);if(t)return{severity:St.parse(t[2]),location:t[3]??null,body:e.slice(t[0].length).trim(),markdown:e};let n=FM.exec(e),r=n?e.slice(n[0].length).trim():e;return{severity:IM(DM(r)),location:n?.[1]??null,body:r,markdown:e}}function RM(e){let t=kM(e),n=t.search(NM);return(n===-1?t:t.slice(0,n)).trim()}function zM(e){let t=kM(e),n=[...t.matchAll(NM)].map(e=>e.index);return n.map((e,r)=>t.slice(e,n[r+1]).trim()).filter(Boolean).map(LM)}function BM(e,t){return!!e?.error&&!e.isRefreshing&&typeof e.nextAttemptAt==`number`&&e.nextAttemptAt>t}function VM(e,t){if(!e?.error)return null;let n=e.error.trim().replace(/[.!]+$/,``),r=e.incident?.trim().replace(/[.!]+$/,``),i=`Could not reach GitHub: ${n}.${r?` GitHub reports: ${r}.`:``}`;if(e.isRefreshing)return`${i} Refreshing.`;if(typeof e.nextAttemptAt!=`number`)return i;let a=Math.max(0,Math.ceil((e.nextAttemptAt-t)/1e3));return a===0?`${i} Retrying now.`:e.retry?`${i} Retrying in ${a}s (${e.retry.attempt} of ${e.retry.limit}).`:`${i} Next try in ${a>=60?`${Math.ceil(a/60)} min`:`${a}s`}.`}function HM(e,t,n){return e?.refreshNotice&&e.isRefreshing?e.refreshNotice:t||e?.isRefreshing?`Refreshing`:n||e?.refreshNotice||``}function UM(e,t){let n=e?.lastRefreshedAt??e?.lastSyncAt??null;if(n===null)return null;let r=Math.max(0,t-n);return!e?.error&&r<=3e5?null:r<6e4?`Last updated less than a minute ago.`:r<36e5?`Last updated ${Math.floor(r/6e4)} min ago.`:`Last updated ${Math.floor(r/36e5)} h ago.`}function WM(e,t,n,r,i,a){return{isVisible:a&&(e.state===`OPEN`||t),isPressed:t,isDisabled:n,statusText:r||(n?`Saving`:i),tone:r?`error`:n?`busy`:null}}function GM(e,t,n=``){if(!t||!e.keepMergeable)return null;let r=KM(e,!1,``,!0,n).statusText;if(e.isKeepMergeableFixInFlight)return{text:`Repairing`,tone:`warn`,title:r};let i=e.keepMergeableAttempt;return!i||i.outcome===`pushed`||i.outcome===`stopped`?null:{text:`Repair failed`,tone:`danger`,title:r}}function KM(e,t,n=``,r=!0,i=``){let a=e.keepMergeableAttempt,o=e.keepMergeable?`On`:`Off`;if(e.keepMergeable&&a&&a.outcome!==`pushed`&&a.outcome!==`stopped`){let e=i?` (${i})`:``;o=`Keep mergeable failed: ${a.reason??`The attempt produced no repair`}${e}`}return e.isKeepMergeableFixInFlight&&(o=`Keep mergeable is running`),WM(e,!!e.keepMergeable,t,n,o,r)}function qM(e){return e?.isKeepMergeableEnabled!==!1}function JM(e){return e?.isMergeQueueEnabled!==!1}function YM(e,t,n){return e?t?`Repair pushed, waiting for you`:n?`On, the last merge failed and retries an hour later once it is ready`:`On, merges as soon as it is ready`:`Not queued`}function XM(e,t,n=``,r=!0){let i=e.mergeQueuePosition!==null&&e.mergeQueuePosition!==void 0;return WM(e,i,t,n,YM(i,!!e.isMergeQueueHeldForRepairPush,!!e.mergeQueueFailure),r)}var ZM=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],QM=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],$M={conflicts:`Needs you`,behind:`Needs you`,"checks-failing":`Needs you`,"changes-requested":`Needs you`,"unresolved-threads":`Needs you`,"checks-pending":`Waiting`,"needs-approval":`Waiting`,unknown:`Waiting`,ready:`Ready to merge`,draft:`Drafts`,merged:`Merged today`},eN={merged:`Merged`,draft:`Draft`,conflicts:`Merge conflicts`,behind:`Behind base`,"checks-failing":`Checks failing`,"changes-requested":`Changes requested`,"unresolved-threads":`Unresolved threads`,"checks-pending":`Checks running`,"needs-approval":`Needs approval`,ready:`Ready to merge`,unknown:`Status unknown`},tN={merged:`muted`,draft:`muted`,conflicts:`danger`,behind:`warn`,"checks-failing":`danger`,"changes-requested":`warn`,"unresolved-threads":`warn`,"checks-pending":`wait`,"needs-approval":`wait`,ready:`ok`,unknown:`muted`},nN={merged:`merged`,draft:`draft`,conflicts:`conflict`,behind:`behind`,"checks-failing":`failed`,"changes-requested":`changes-requested`,"unresolved-threads":`thread`,"checks-pending":`running`,"needs-approval":`reviewer`,ready:`ready`,unknown:`unknown`};function rN(e){let t=e.filter(e=>e.state===`OPEN`&&!e.isCrossRepository),n=new Map(t.map(e=>[JSON.stringify([e.repo.toLowerCase(),e.headRefName]),e])),r=new Map,i=[];for(let t of e){let e=t.state===`OPEN`?n.get(JSON.stringify([t.repo.toLowerCase(),t.baseRefName])):void 0;if(!e||e.key===t.key){i.push(t);continue}let a=r.get(e.key)??[];a.push(t),r.set(e.key,a)}let a=[],o=new Set;for(let t of[...i,...e]){if(o.has(t.key))continue;let e=[],n=[{pr:t,parentKey:null,depth:0}];for(;n.length>0;){let t=n.pop();if(!t||o.has(t.pr.key))continue;o.add(t.pr.key),e.push(t);let i=r.get(t.pr.key)??[];for(let e=i.length-1;e>=0;--e)n.push({pr:i[e],parentKey:t.pr.key,depth:t.depth+1})}a.push({root:t,rows:e})}return a}function iN(e){return ZM[e.rows.reduce((e,{pr:t})=>Math.min(e,ZM.indexOf($M[t.stage])),ZM.length-1)]}function aN(e){let t=new Map(ZM.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of rN(e)){let e=t.get(iN(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return QM.flatMap(e=>t.get(e)??[])}function oN(e){return eN[e]}function sN(e){return tN[e]}function cN(e){return nN[e]}function lN(e){return e.checks.failing.length>0?{label:`Checks`,tone:`danger`,icon:`failed`,text:`${e.checks.failing.length} failing`,items:e.checks.failing}:e.checks.state===`FAILURE`||e.checks.state===`ERROR`?{label:`Checks`,tone:`danger`,icon:`failed`,text:`Failing`}:e.checks.pendingCount>0?{label:`Checks`,tone:`wait`,icon:`running`,text:`${e.checks.pendingCount} running`}:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?{label:`Checks`,tone:`wait`,icon:`running`,text:`Running`}:e.checks.state===`SUCCESS`?{label:`Checks`,tone:`ok`,icon:`passed`,text:`Passing`}:{label:`Checks`,tone:`muted`,icon:`none`,text:`No checks`}}function uN(e){return`${e} ${e===1?`approval`:`approvals`}`}function dN(e){return e.reviewRequests.map(e=>e.name).join(`, `)}function fN(e){let t=e.reviewRequests.length>0?`Requested: ${dN(e)}`:`Approval required`;return e.approvals>0?`${t}, ${uN(e.approvals)}`:t}function pN(e){let t=e.approvals>0?uN(e.approvals):`Approved`;return e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`${t}, merge blocked`}:{label:`Review`,tone:`ok`,icon:`passed`,text:t}}function mN(e){return e.reviewDecision===`CHANGES_REQUESTED`?{label:`Review`,tone:`warn`,icon:`changes-requested`,text:`Changes requested`}:e.reviewDecision===`APPROVED`?pN(e):e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:fN(e)}:e.reviewRequests.length>0?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`Requested: ${dN(e)}`}:{label:`Review`,tone:`muted`,icon:`none`,text:`No review requested`}}function hN(e,t){return t?e.lastAuthor!==t:null}function gN(e){let t=e.line===null?e.path:`${e.path}:${e.line}`;return e.isOutdated?`${t} (outdated)`:t}function _N(e){let t=e.commentCount-1;return t===0?`No replies`:`${t} ${t===1?`reply`:`replies`}, last by ${e.lastAuthor??`a deleted account`}`}function vN(e,t){let n=hN(e,t);return n===null?null:n?{tone:`warn`,icon:`your-turn`,text:`Waiting on you`}:{tone:`wait`,icon:`reviewer`,text:`Waiting on reviewer`}}function yN(e,t){return[...e.threads].sort((e,n)=>{let r=Number(hN(n,t)===!0)-Number(hN(e,t)===!0);return r===0?(Date.parse(n.lastActivityAt)||0)-(Date.parse(e.lastActivityAt)||0):r}).map(e=>({location:gN(e),url:e.url,author:e.author??`a deleted account`,excerpt:e.excerpt,replySummary:_N(e),lastActivityAt:e.lastActivityAt,waiting:vN(e,t),isWaitingOnYou:hN(e,t)===!0}))}function bN(e,t){if(e.unresolvedThreads===0)return{label:`Threads`,tone:`ok`,icon:`passed`,text:`None open`};let n=`${e.unresolvedThreads} unresolved`;if(!t||e.threads.length===0)return{label:`Threads`,tone:`warn`,icon:`thread`,text:n};let r=e.threads.filter(e=>hN(e,t)).length;return r===0?{label:`Threads`,tone:`wait`,icon:`thread`,text:`${n}, all waiting on reviewers`}:{label:`Threads`,tone:`warn`,icon:`your-turn`,text:`${n}, ${r} waiting on you`}}function xN(e){return e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?{label:`Conflicts`,tone:`danger`,icon:`conflict`,text:`Conflicts with ${e.baseRefName}`}:e.mergeable===`MERGEABLE`?{label:`Conflicts`,tone:`ok`,icon:`passed`,text:`None`}:{label:`Conflicts`,tone:`muted`,icon:`unknown`,text:`Not computed yet`}}function SN(e){let t=e.behindBy!==null&&e.behindBy>0;return e.mergeStateStatus===`BEHIND`?{label:`Base`,tone:`warn`,icon:`behind`,text:t?`${e.behindBy} behind ${e.baseRefName}`:`Behind ${e.baseRefName}`}:e.behindBy===null?{label:`Base`,tone:`muted`,icon:`unknown`,text:`Unknown`}:t?{label:`Base`,tone:`muted`,icon:`behind`,text:`${e.behindBy} behind ${e.baseRefName}, update not required`}:{label:`Base`,tone:`ok`,icon:`passed`,text:`Up to date with ${e.baseRefName}`}}var CN={APPROVED:{text:`Approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{text:`Requested changes`,tone:`warn`,icon:`changes-requested`},COMMENTED:{text:`Commented`,tone:`muted`,icon:`thread`},DISMISSED:{text:`Dismissed`,tone:`muted`,icon:`discarded`},PENDING:{text:`Pending`,tone:`wait`,icon:`running`}};function wN(e){return[...e.reviews].sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).map(e=>{let t=CN[e.state]??{text:e.state.toLowerCase().replaceAll(`_`,` `),tone:`muted`,icon:`unknown`};return{reviewer:e.reviewer??`a deleted account`,text:t.text,tone:t.tone,icon:t.icon,submittedAt:e.submittedAt}})}var TN={danger:0,warn:1,wait:2,muted:3,ok:4};function EN(e,t=null){if(e.state===`MERGED`)return[];let n=[lN(e),mN(e),bN(e,t),xN(e),SN(e)],r=e.autoRebase?[DN(e,e.autoRebase)]:[],i=e.mergeQueueFailure?[{label:`Merge when ready`,tone:`danger`,icon:`failed`,text:`Merge failed: ${e.mergeQueueFailure.message}`}]:[];return[...n,...r,...i].toSorted((e,t)=>TN[e.tone]-TN[t.tone])}function DN(e,t){return t.outcome===`rebased`?{label:`Auto-rebase`,tone:`ok`,icon:`passed`,text:t.message}:{label:`Auto-rebase`,tone:e.mergeStateStatus===`BEHIND`?`danger`:`warn`,icon:`failed`,text:t.message}}function ON(e){return e?e.configured?e.error&&e.prs.length===0?`Pull requests will show here once GitHub answers.`:`No open or recently merged pull requests found.`:`Enable Team review and set its GitHub organization in settings to see your pull requests.`:`Waiting for your pull requests.`}function kN(e,t=0){if(!e)return[];let n=VM(e,t),r=n?[{text:n,tone:`error`}]:[];return e.truncatedNote?[...r,{text:e.truncatedNote,tone:`info`}]:r}function AN(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...CM({...n,repo:r}),...e}]})}function jN(e){let t=new Map;for(let n of e)for(let e of n.links){let r=ot(e),i=t.get(r)??[];i.at(-1)?.id!==n.id&&(i.push({id:n.id,title:n.title}),t.set(r,i))}return t}function MN(e,t){if(!e)return[];let n=new Set(e.filter(e=>e.state===`OPEN`).map(e=>e.key));return t.filter(e=>e.state===`MERGED`&&n.has(e.key))}var NN=3;function PN(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,NN).map(e=>`${e.key} ${e.title}`),n=e.length-t.length,r=n>0?[...t,`and ${n} more`]:t;return{message:`Merged ${e.length} pull requests`,detailLines:r}}var FN={isVisible:!1,isDisabled:!0,statusText:``,tone:null},IN={merged:{statusText:`Merged on GitHub. Refreshing the list.`,tone:`ok`},queued:{statusText:`Added to the merge queue. Refreshing the list.`,tone:`ok`},"auto-merge":{statusText:`Auto-merge enabled. GitHub merges it once its requirements pass.`,tone:`ok`},unconfirmed:{statusText:`GitHub accepted the request but did not confirm a merge. Check GitHub.`,tone:null}};function LN(e,t){if(e.state!==`OPEN`)return FN;let n=t?.head===e.headRefOid?t:void 0;if(n?.phase===`pending`)return{isVisible:!0,isDisabled:!0,statusText:`Merging on GitHub`,tone:`busy`};if(n&&n.phase!==`failed`)return{isVisible:!0,isDisabled:!0,...IN[n.phase]};let r=xM(e);return r?{isVisible:!0,isDisabled:!0,statusText:r,tone:null}:n?.phase===`failed`?{isVisible:!0,isDisabled:!1,statusText:n.text,tone:`error`}:{isVisible:!0,isDisabled:!1,statusText:`Merges into ${e.baseRefName} with ${bM(e.mergeMethod)}`,tone:null}}function RN(e){return`Merge ${e.key} "${e.title}" into ${e.baseRefName} with ${bM(e.mergeMethod)}, your default for this repository. Glimmervoid does not delete the branch.`}function zN(e){let t=xe.safeParse(e);if(!t.success)return null;let n=e&&typeof e==`object`&&`requestId`in e?e.requestId:null;return typeof n==`string`?{...t.data,requestId:n}:null}function BN(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:Xe(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,liveHead:n.headRefOid,prStage:CM(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n),handReview:e.handReview.map(n)}}var VN={"direct-request":`Needs you`,"team-request":`Ready`,"changes-requested":`Author to fix`,"checks-failing":`Checks failing`,"checks-pending":`Checks running`,draft:`Draft`,"review-available":`Ready`,approved:`Approved`};function HN(e){return e.isDraft?{band:`not-ready`,reason:`draft`}:e.reviewDecision===`CHANGES_REQUESTED`?{band:`waiting-on-author`,reason:`changes-requested`}:e.checksState===`FAILURE`||e.checksState===`ERROR`?{band:`waiting-on-author`,reason:`checks-failing`}:e.checksState===`PENDING`||e.checksState===`EXPECTED`?{band:`not-ready`,reason:`checks-pending`}:e.requestSource===`direct`&&e.reviewDecision===`REVIEW_REQUIRED`?{band:`blocking-others`,reason:`direct-request`}:e.reviewDecision===`APPROVED`?{band:`actionable`,reason:`approved`}:{band:`actionable`,reason:e.requestSource===`direct`?`review-available`:`team-request`}}var UN={APPROVE:{label:`You approved`,tone:`ok`,icon:`passed`},COMMENT:{label:`You commented`,tone:`muted`,icon:`thread`}},WN={APPROVED:{label:`You approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{label:`You requested changes`,tone:`wait`,icon:`changes-requested`},COMMENTED:{label:`You commented`,tone:`muted`,icon:`thread`}};function GN(e){let t=(e.githubReviews??[]).filter(e=>e.isViewer).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!e.postedEvent)return t?WN[t.state]:null;if(!t)return UN[e.postedEvent];let n=Date.parse(t.submittedAt??``);return Number.isNaN(n)||e.postedAt!==void 0&&e.postedAt>n?UN[e.postedEvent]:WN[t.state]}var KN={"changes-requested":`changes-requested`,"checks-failing":`failed`,"checks-pending":`running`,draft:`draft`};function qN(e){let{reason:t}=HN(e),n=KN[t];return n?{text:VN[t],icon:n}:null}function JN(e){return qN(e)?.text??null}var YN={discarded:{tone:`muted`,icon:`discarded`,meaning:`Not mine`},handReview:{tone:`warn`,icon:`fork`,meaning:`From a fork`}};function XN(e,t){let n=JN(t);return n?`${e}, ${n}`:e}function ZN(e){if(Ct(e))return!0;let t=(e.githubReviews??[]).filter(e=>e.isViewer);return t.length===0||t.some(t=>t.commit===wP(e))}var QN={tone:`warn`,icon:`your-turn`,meaning:`Comments resolved`};function $N(e,t){if(e.prStage)return{tone:sN(e.prStage),icon:cN(e.prStage),meaning:oN(e.prStage)};let n=YN[t];if(n)return n;if(t===`inReview`)return{tone:`wait`,icon:`running`,meaning:XN(`In review`,e)};if(t===`queued`)return{tone:`muted`,icon:`queued`,meaning:XN(`Queued`,e)};if(t===`settled`&&`reviewedHead`in e){let t=ZN(e)?GN(e):null;return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`ok`,icon:`passed`,meaning:`Others reviewed`}}if(t===`posted`&&`reviewedHead`in e){let t=GN(e);return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`muted`,icon:`none`,meaning:`Posted`}}if(t===`attention`&&`status`in e)return e.status===`error`?{tone:`danger`,icon:`failed`,meaning:`Review failed`}:{tone:`warn`,icon:`stale`,meaning:`Out of date`};let r=qN(e);return r?{tone:`wait`,icon:r.icon,meaning:r.text}:t===`ready`&&`reviewedHead`in e&&nP(e)?QN:{tone:`warn`,icon:`your-turn`,meaning:`Waits on you`}}function eP(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function tP(e){return e.status===`posted`&&nP(e)}function nP(e){if(!eP(e)||Ct(e))return!1;let t=wP(e);return e.status===`posted`&&e.postedEvent===`APPROVE`&&e.reviewedHead===t?!1:!(e.githubReviews??[]).some(e=>e.isViewer&&e.state===`APPROVED`&&e.commit===t)}function rP(e){return!e||e.total===0?null:e.total===1?e.resolved===1?`Your 1 comment resolved`:`Your 1 comment unresolved`:e.resolved===e.total?`All ${e.total} of your comments resolved`:`${e.resolved} of ${e.total} of your comments resolved`}function iP(e){return`${e} ${e===1?`comment`:`comments`}`}function aP(e,t,n){let r=[`${QP(e.repo,e.number)}: ${e.title}`],i=`reviewedHead`in e?e.assessment?.goal.trim():``;if(i&&r.push(i),r.push($N(e,t).meaning),n.opened&&r.push(`Opened ${n.opened}`),n.reviewed&&r.push(`Reviewed ${n.reviewed}`),n.posted&&r.push(`Posted ${n.posted}`),!(`reviewedHead`in e))return r.join(`
168
- `);let a=rP(e.viewerThreads);a&&r.push(a);let o=e.comments.length;e.status!==`error`&&r.push(`Automated review: ${gP(e.verdict)}, ${iP(o)}`);let s=MP(e);s&&r.push(`You ${vP[s.state]} at ${At(s.approvedCommit)}${n.viewerApproval?` ${n.viewerApproval}`:``}; new commits since.`),(t===`attention`||t===`discarded`)&&r.push(gF(e));let c=IP(e,{isViewerShown:t!==`posted`});for(let[e,t]of c.entries())r.push(FP(t.text,n.githubReviews?.[e]??null));return r.join(`
169
- `)}function oP(e){let t=e.trim();return t.endsWith(`.`)?t:`${t}.`}var sP=new Set([`approve`,`approve-only`,`comment`]);function cP({action:e,outcomeText:t,pullRequest:n,warning:r,isActedSelected:i}){let a=`${n}: ${oP(t)}`;return r.trim()?{statusText:t,shouldAdvance:!1,notice:{text:`${a} ${oP(r)}`,tone:`error`}}:{statusText:t,shouldAdvance:i,notice:i&&sP.has(e)?{text:a,tone:`ok`}:null}}function lP(e,t,n){return n?QP(e,t):`#${t}`}var uP={CRITICAL:{filledCount:3,colorToken:`--state-failed`},HIGH:{filledCount:3,colorToken:`--state-waiting`},MEDIUM:{filledCount:2,colorToken:`--accent`},LOW:{filledCount:1,colorToken:`--text-dim`}},dP={APPROVE:`check`,"APPROVE WITH NITS":`dot`,"REQUEST CHANGES":`bar`,BLOCKED:`cross`},fP=`lanes-team-review`,pP=`team-review-enabled`,mP=Object.freeze({APPROVE:`approve`,"APPROVE WITH NITS":`approve with nits`,"REQUEST CHANGES":`request changes`,BLOCKED:`blocked`}),hP={APPROVE:`Approve`,"APPROVE WITH NITS":`Nits`,"REQUEST CHANGES":`Changes`,BLOCKED:`Blocked`};function gP(e){return hP[e]}var _P=Object.freeze({APPROVE:`ok`,"APPROVE WITH NITS":`info`,"REQUEST CHANGES":`warn`,BLOCKED:`crit`}),vP=Object.freeze({APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`commented`}),yP=Object.freeze({preparing:`fetching the diff`,checkout:`checking out the head`,reviewing:`agent reviewing`}),bP=Object.freeze({approve:`Approved on GitHub`,"approve-only":`Approved on GitHub`,comment:`Comment posted on GitHub`,discard:`Marked not mine. Not reviewed again until you re-run it.`,requeue:`Queued. The review starts as soon as a slot is free.`,"resolve-thread":`Thread resolved on GitHub`}),xP=Object.freeze({approve:`Posting the approval`,"approve-only":`Posting the approval`,comment:`Posting the comment`,discard:`Marking not mine`,requeue:`Queueing the review`,"resolve-thread":`Resolving thread`});function SP(e){let t={ready:[],noReviewNeeded:[],inReview:[],queued:[],handReview:[],attention:[],posted:[],discarded:[]};if(!e)return t;let n={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},r={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},i=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`],a=new Set(e.inFlight.map(e=>e.key));t.inReview.push(...e.inFlight);let o=new Set(e.drafts.filter(e=>TP(e).length>0).map(e=>e.key));t.handReview.push(...e.handReview.filter(e=>!a.has(e.key)&&!o.has(e.key)));let s=new Set(t.handReview.map(e=>e.key));for(let t of e.queued)a.has(t.key)||s.has(t.key)||r[HN(t).band].push(t);for(let e of i)t.queued.push(...r[e]);let c=new Set(t.queued.map(e=>e.key));for(let r of e.drafts){if(a.has(r.key)||c.has(r.key)||s.has(r.key))continue;if(TP(r).length>0||tP(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!AP(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[HN(r).band].push(r),(r.status===`stale`||r.status===`error`)&&!e&&t.attention.push(r),r.status===`posted`&&t.posted.push(r),r.status===`discarded`&&t.discarded.push(r)}for(let e of i)t.ready.push(...n[e]);return t}function CP(e,t){return e.commit===t?e.isViewer||Nt.has(e.state):!1}function wP(e){return e.liveHead??e.reviewedHead}function TP(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function EP(e,t){if(e.isNit)return{label:`Automatic resolution failed`,reason:``,tone:`warn`};let n=e.judgement?.head===t&&e.judgement.lastReplyAt===e.lastReplyAt?e.judgement:void 0;if(n)return{label:n.addressed?`Addressed`:`Not addressed`,reason:n.reason,tone:n.addressed?`ok`:`warn`};let r=e.unjudgeable?.head===t&&e.unjudgeable.lastReplyAt===e.lastReplyAt?e.unjudgeable:void 0;return r?{label:`Auto-check skipped`,reason:r.reason,tone:`muted`}:{label:`Auto-check pending`,reason:``,tone:`muted`}}function DP(e){return(e.threads??[]).filter(e=>!e.isResolved&&(!e.isNit||e.resolveError)).map(t=>{let n=EP(t,wP(e));return{thread:t,location:t.line===null?t.path:`${t.path}:${t.line}`,judgementLabel:n.label,judgementReason:n.reason,judgementTone:n.tone,judgementText:n.reason?`${n.label}: ${n.reason}`:n.label,canResolve:t.viewerCanResolve}})}var OP=40;function kP(e,t){return e.split(`
170
- `).reduce((e,t)=>e+Math.max(1,Math.ceil(t.length/OP)),0)>t}function AP(e){return TP(e).length>0?!0:Ct(e)?!1:nP(e)?!0:!(e.githubReviews??[]).some(t=>CP(t,wP(e)))}function jP(e,t){let n=vP[e.state];return e.isViewer?e.commit===t?`you ${n}`:`you ${n} (older commit)`:`${n} by ${e.login}`}function MP(e){if(Ct(e))return null;let t=(e.githubReviews??[]).filter(e=>e.isViewer&&Nt.has(e.state)).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!t?.commit||t.commit===wP(e)||t.state===`COMMENTED`)return null;let n=Date.parse(t.submittedAt??``);return e.reviewedAt!==void 0&&n>e.reviewedAt?null:{approvedCommit:t.commit,submittedAt:t.submittedAt,state:t.state,isReviewScopeSinceDecision:e.priorReviewedHead===t.commit}}function NP(e,t){let n=e.state===`APPROVED`?`approved this`:`requested changes`,r=e.state===`APPROVED`?`your approval`:`your request for changes`,i=`You ${n} at ${At(e.approvedCommit)}${t?` ${t}`:``}. It has new commits since`;return e.isReviewScopeSinceDecision?`${i}, so this review covers what changed after ${r}.`:`${i}.`}function PP(e){return e===`APPROVED`?`ok`:e===`CHANGES_REQUESTED`?`warn`:`muted`}function FP(e,t){return t?`${e}, ${t}`:e}function IP(e,{isViewerShown:t=!0}={}){return(e.githubReviews??[]).filter(e=>t||!e.isViewer).sort((e,t)=>Number(t.isViewer)-Number(e.isViewer)).map(t=>({login:t.login,tone:PP(t.state),text:jP(t,wP(e)),submittedAt:t.submittedAt}))}function LP(e){return uP[e]}function RP(e){return dP[e]}function zP(e){let t=DM(e.body);return t.length>0?t:e.severity?[e.severity]:[]}function BP(e){return IM(zP(e))}function VP(e){return e!==`LOW`}function HP(e){return VP(BP(e))}var UP=new Set(`ts.tsx.js.jsx.mjs.cjs.json.jsonc.css.scss.less.html.md.mdx.py.go.rs.rb.java.kt.kts.swift.c.h.cc.cpp.hpp.cs.php.sh.bash.zsh.yml.yaml.toml.ini.sql.vue.svelte.astro.lock.txt.ex.exs.erl.scala.dart.lua.tf.proto.graphql.gql.xml.gradle`.split(`.`)),WP=/^([\w.@~/-]+):\d+(?:-\d+)?$/;function GP(e){let t=WP.exec(e)?.[1];if(t===void 0)return!1;let n=t.slice(t.lastIndexOf(`/`)+1),r=n.lastIndexOf(`.`);return r<0?!1:UP.has(n.slice(r+1).toLowerCase())}var KP=/^```([^\n`]*)\n([\s\S]*?)^```[ \t]*(?=\r?$)/gm;function qP(e){let t=[],n=0;for(let r of e.matchAll(/`([^`\n]+)`/g)){let i=r.index??0;i>n&&t.push({text:e.slice(n,i),kind:`text`});let a=r[1]??``;t.push({text:a,kind:GP(a)?`citation`:`code`}),n=i+r[0].length}return n<e.length&&t.push({text:e.slice(n),kind:`text`}),t}function JP(e){return e.split(/\r?\n\s*\r?\n/).filter(Boolean).map(e=>{let t=e.match(/^(Suggested fix:|Fix:|Open question[.,:])\s*/),n=t?.[1]??``;return{kind:`prose`,lead:n,leadKind:n.startsWith(`Open question`)?`question`:n?`fix`:null,segments:qP(e.slice(t?.[0].length??0))}})}function YP(e){let t=kM(e),n=OM(t),r=n?t.slice(n.length).trim():t,i=[],a=0;for(let e of r.matchAll(KP)){let t=e.index??0;i.push(...JP(r.slice(a,t).trim()));let n=(e[1]??``).trim().split(/\s+/)[0]||null;i.push({kind:`code`,language:n,code:(e[2]??``).replace(/\r?\n$/,``)}),a=t+e[0].length}return i.push(...JP(r.slice(a).trim())),{tag:n?.reviewer??null,severity:n?.severity??null,paragraphs:i}}function XP(e){let t=e.find(e=>e.kind===`prose`);if(!t)return`Open comment`;let n=`${t.lead} ${t.segments.map(e=>e.text).join(``)}`.trim(),r=n.search(/[.!?](?=\s|$)/);return(r<0?n:n.slice(0,r+1))||`Open comment`}function ZP(e){let t=[`Fetch the diff`,`Check out the head`,`Review`,`Draft ready`],n={preparing:0,checkout:1,reviewing:2}[e];return t.map((e,t)=>({label:e,state:t<n?`done`:t===n?`active`:`todo`}))}function QP(e,t){return`${e}#${t}`}function $P(e){return e===`full`?`full`:`light`}function eF(e){return e.priorReviewedHead?`${$P(e.tier)} review of changes since ${At(e.priorReviewedHead)}`:`${$P(e.tier)} review`}function tF(e){return e.reasons.join(`, `)}function nF(e){if(!e)return[];let t=[],n=e.goal.trim(),r=e.change.trim();return n&&t.push({kind:`goal`,text:n}),r&&t.push({kind:`change`,text:r}),t}var rF=`This review ran before plain summaries existed, so only its verdict and findings remain. Re-run review to get a plain summary.`,iF=new Set([`error`,`stale`,`discarded`,`posted`]);function aF(e){return iF.has(e)}function oF(e){return e.liveHead&&e.liveHead!==e.reviewedHead?e.liveHead:null}function sF(e){let t=oF(e);return t?`Reviewed at ${At(e.reviewedHead)}. The pull request is now at ${At(t)}.`:null}function cF(e){let t=oF(e);return t?`https://github.com/${e.repo}/compare/${e.reviewedHead}...${t}`:null}function lF(e){let t=[`at ${At(e.head)}`,iP(e.comments.length)];return e.wasPosted&&t.push(`posted`),t.join(`, `)}function uF(e){let t=dF(e);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function dF(e){return mP[e]??String(e).toLowerCase()}function fF(e){return _P[e]??`dim`}function pF(e){return yP[e]??e}function mF(e,t){return`${N(t-e.startedAt)} elapsed`}function hF(e,t){let n=[mF(e,t)],r=e.deadlineAt===null?0:e.deadlineAt-t;return r>0&&n.push(`times out in ${N(r)}`),e.phase===`reviewing`&&n.push(`${e.toolCalls} ${e.toolCalls===1?`tool call`:`tool calls`}`),n.join(`, `)}function gF(e){return e.status===`stale`&&e.earlierReview?`Out of date. New commits landed after this review, so its findings may not match the code any more. Automatic review runs after the configured wait; Re-run review starts it now and hands it these findings.`:e.status===`stale`?`Out of date. New commits landed after this review, so its findings may not match the code any more. Automatic review runs after the configured wait; Re-run review starts it now.`:e.status===`discarded`?`Marked not mine. Not reviewed again until you re-run it.`:e.error||e.summary||`The review failed.`}function _F(e,t){let n=t.side===`LEFT`?` (old)`:``;return`${e}:${t.line}${n}`}function vF(e){return _F(e.path,e)}function yF(e){return _F(e.path.split(`/`).filter(Boolean).at(-1)??e.path,e)}function bF(e,t){let n=e.trim();return n?t.trim()?`${n}\n\n${t}`:n:t}function xF(e){return{key:e,action:`discard`,body:``,comments:[]}}function SF(e,t,n,r,i){return t===`approve-only`?{key:e.key,head:e.reviewedHead,action:t,body:``,comments:[]}:{key:e.key,head:e.reviewedHead,action:t,body:n,...i?{threadId:i}:{},comments:r.map(({path:e,line:t,side:n,body:r})=>({path:e,line:t,side:n,body:r}))}}function CF(e){return e.note.trim()!==``||e.comments.length>0||e.generalFindings.length>0}function wF(e,t,n){return t===`approve`&&!CF(n)?SF(e,`approve-only`,``,[]):SF(e,t,bF(n.note,[wM,RM(e.body),...n.generalFindings.map(e=>e.markdown)].filter(Boolean).join(`
161
+ `)}function e_(e){return{kind:`unchanged`,text:e}}function t_(e){return{kind:`skipped`,text:`${e} unchanged lines`}}function n_(e,t){return e.length<=7?e.map(t):[...e.slice(0,Qg).map(t),t_(e.length-6),...e.slice(e.length-Qg).map(t)]}function r_(e){return e}function i_(e){let t=[],n=0;for(;n<e.length;){if(e[n].kind!==`unchanged`){t.push(e[n]),n++;continue}let r=n;for(;r<e.length&&e[r].kind===`unchanged`;)r++;t.push(...n_(e.slice(n,r),r_)),n=r}return t}function a_(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return r}function o_(e,t,n){let r=Math.min(e.length,t.length)-n,i=0;for(;i<r&&e[e.length-1-i]===t[t.length-1-i];)i++;return i}function s_(e,t){let n=e.length,r=t.length;if(n===0)return t.map(e=>({kind:`added`,text:e}));if(r===0)return e.map(e=>({kind:`removed`,text:e}));let i=r+1,a=new Int32Array((n+1)*i);for(let o=n-1;o>=0;o--)for(let n=r-1;n>=0;n--){let r=o*i+n;a[r]=e[o]===t[n]?a[r+i+1]+1:Math.max(a[r+i],a[r+1])}let o=[],s=0,c=0;for(;s<n&&c<r;)e[s]===t[c]?(o.push(e_(e[s])),s++,c++):a[(s+1)*i+c]>=a[s*i+c+1]?(o.push({kind:`removed`,text:e[s]}),s++):(o.push({kind:`added`,text:t[c]}),c++);for(;s<n;)o.push({kind:`removed`,text:e[s]}),s++;for(;c<r;)o.push({kind:`added`,text:t[c]}),c++;return o}function c_(e,t){let n=$g(e),r=$g(t),i=a_(n,r),a=o_(n,r,i),o=n.slice(i,n.length-a),s=r.slice(i,r.length-a);return o.length+s.length>Zg?{lines:[],isTooLarge:!0}:{lines:i_([...n_(n.slice(0,i),e_),...s_(o,s),...n_(n.slice(n.length-a),e_)]),isTooLarge:!1}}var l_=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function u_(e){return e===`approve`||e===`approve-accept-edits`}function d_(e){return(e.state===`decided`||e.state===`closed`)&&u_(e.lastDecision)}function f_(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&d_(n)}function p_(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function m_(e){let t=p_(e.state,e.selectedAgentId);return t?e.selectedRevision&&t.revisions.some(t=>t.revision===e.selectedRevision)?e.selectedRevision:t.revisions.at(-1)?.revision??null:null}function h_(e,t){return p_(e,t)?.openRevision?.revision??null}function g_(e,t,n){if(n===null)return null;let r=p_(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function __(e,t){let n=t-e;return Number.isFinite(n)?D(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function v_(e,t,n){return t!==null&&t.state===`open`&&t.openRevision!==null&&t.openRevision.revision===n&&e.body!==null&&e.isConnected&&e.isDraft!==!0&&!e.isDecisionInFlight}function y_(e,t,n){let r=v_(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return l_.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function b_(e,t){return e.openRevision===null?t!==null&&e.approvedRevision===t?`Approved`:e.state===`released`?`Answer in the terminal`:e.state===`decided`?e.lastDecision===`revise`?`Feedback sent, waiting for the next revision`:`Approved`:`Closed`:e.openRevision.revision===t?``:`Rev ${e.openRevision.revision} is the one open`}function x_(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function S_(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+Ne}function C_(e){let t=e.plan;if(t!==void 0&&t.length===0)return`the edited plan is empty, so nothing was sent`;if(t!==void 0&&new TextEncoder().encode(t).byteLength>524288)return`the edited plan is over the plan size cap, so nothing was sent`;let n=e.comments??[];return n.length>40?`more than 40 section comments are pending, so nothing was sent`:n.find(e=>e.comment.length>4e3||(e.heading?.length??0)>4e3)?`a section comment is over ${kt} characters, so nothing was sent`:x_(e)>1e4?`the feedback composes more than the ${et} characters the hook reply carries, so nothing was sent`:S_(e)>Re?`the decision is larger than one control frame carries, so nothing was sent`:null}function w_(e){return e?`, ${e}`:``}function T_(e,t,n){if(!e.isConnected)return`Disconnected`;if(!t||n===null)return`No plan revision selected`;if(e.isDecisionInFlight)return`Sending your decision`;if(e.body===null)return`Loading`;if(e.isDraft===!0)return`Draft`;let r=b_(t,n);if(r)return r;if(e.hasUnsavedComment===!0)return`Save or cancel the open comment first.`;let i=e.pendingCommentCount??0;return i<=0?``:i===1?`1 comment to send. Remove it to approve.`:`${i} comments to send. Remove them to approve.`}function E_(e,t,n){let r=T_(e,t,n);return r?`${r}${w_(e.problem)}`:e.problem??``}function D_(e){let t=p_(e.state,e.selectedAgentId),n=m_(e);return{tabs:e.state.reviews.map(e=>({agentId:e.agentId,label:e.agentId===null?`Main`:e.agentType||`Agent`,selected:e===t})),revisions:(t?.revisions??[]).map(e=>({revision:e.revision,label:`Rev ${e.revision}`,isOpen:e.revision===t?.openRevision?.revision,receivedAt:e.receivedAt,selected:e.revision===n})),selectedAgentId:t?.agentId??null,selectedRevision:n,previousRevision:g_(e.state,t?.agentId??null,n),status:E_(e,t,n),actions:y_(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:g_(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:v_(e,t,n)}]}}function O_(e,t){let n=e.reviews.findIndex(e=>e.agentId===t.agentId),r=[...(n===-1?null:e.reviews[n])?.revisions??[]],i=r.findIndex(e=>e.revision===t.revision),a={revision:t.revision,receivedAt:t.receivedAt,chars:t.chars,title:t.title};r[i===-1?r.length:i]=a,r.sort((e,t)=>e.revision-t.revision);let o={agentId:t.agentId,agentType:t.agentType,revisions:r,state:t.state,openRevision:t.state===`open`?{revision:t.revision,since:t.receivedAt}:null,approvedRevision:t.approvedRevision,lastDecision:t.lastDecision},s=[...e.reviews];return s[n===-1?s.length:n]=o,{reviews:s}}function k_({headingOffsets:e,scrollTop:t,isScrolledToEnd:n,readingLineOffset:r}){if(e.length===0)return null;if(n)return e.length-1;let i=t+r,a=0;for(let t=0;t<e.length&&!(e[t]>i);t++)a=t;return a}var A_=12,j_=8,M_=``,N_=48,P_=new Map;function F_(e,t){return JSON.stringify([e,t])}function I_(e){return e.id??M_}function L_(e,t){let n=P_.get(e);n||(n=new Map,P_.set(e,n));let r=F_(t.agentId,t.revision);for(n.delete(r),n.set(r,t.plan);n.size>A_;){let e=n.keys().next().value;if(typeof e!=`string`)break;n.delete(e)}}function R_(e){P_.delete(e)}function z_(e,t,n){return!e||n===null?null:P_.get(e)?.get(F_(t,n))??null}function B_(e){let t=L(`section`,`plan-face`);t.hidden=!0;let n=L(`header`,`plan-head`),r=L(`select`,`plan-heading-picker`);r.setAttribute(`aria-label`,`Plan section`);let i=L(`div`,`plan-view-panel`),a=L(`div`,`plan-sheet-head`),o=L(`button`,`plan-control plan-sheet-close`,`×`);o.type=`button`,o.setAttribute(`aria-label`,`Close`),a.append(L(`span`,null,`View`),o);let s=L(`div`,`plan-view-group plan-author-group`),c=L(`div`,`plan-tabs`);c.setAttribute(`role`,`tablist`),c.setAttribute(`aria-label`,`Plan author`),s.append(L(`span`,`plan-sheet-label`,`Author`),c);let l=L(`div`,`plan-view-group plan-revision-group`),u=L(`div`,`plan-revision-stepper`),d=L(`button`,`plan-control plan-revision-previous`,`‹`);d.type=`button`,d.setAttribute(`aria-label`,`Previous revision`);let f=L(`button`,`plan-control plan-revision-next`,`›`);f.type=`button`,f.setAttribute(`aria-label`,`Next revision`);let m=L(`span`,`plan-revision-label`),h=L(`span`,`plan-revision-age`);u.append(d,m,f,h);let g=L(`div`,`plan-revision-list`);g.setAttribute(`role`,`radiogroup`),g.setAttribute(`aria-label`,`Revision`),l.append(L(`span`,`plan-sheet-label`,`Revision`),u,g);let _=L(`div`,`plan-view-group plan-mode-group`),v=L(`div`,`plan-modes`);v.setAttribute(`role`,`radiogroup`),v.setAttribute(`aria-label`,`Show`),_.append(L(`span`,`plan-sheet-label`,`Show`),v);let y=L(`div`,`plan-head-spacer`),b=L(`div`,`plan-draft-notice`),x=L(`span`,`plan-draft-dot`);x.setAttribute(`aria-hidden`,`true`);let S=L(`button`,`plan-control plan-draft-chip`,`Peek draft`);S.type=`button`,b.append(x,S),i.append(a,s,l,_,y,b);let C=L(`button`,`plan-control plan-view-button`,`View`);C.type=`button`,C.setAttribute(`aria-haspopup`,`dialog`),C.setAttribute(`aria-expanded`,`false`);let w=L(`button`,`plan-control plan-minimize-button`,`Minimize`);w.type=`button`,w.addEventListener(`click`,e.showTerminal),n.append(r,i,C,w);let T=L(`div`,`plan-sheet-backdrop`),E=L(`div`,`plan-body-layout`),D=L(`nav`,`plan-heading-rail`);D.setAttribute(`aria-label`,`Plan sections`);let O=L(`article`,`plan-reading-column`);E.append(D,O);let k=L(`textarea`,`plan-editor`);k.setAttribute(`aria-label`,`Plan markdown`),k.spellcheck=!1;let A=L(`footer`,`plan-action-bar`),ee=L(`span`,`plan-status`);ee.setAttribute(`role`,`status`);let te=L(`div`,`plan-decision-slot`),ne=L(`label`,`plan-accept-edits`),re=L(`input`,`plan-accept-edits-checkbox`);re.type=`checkbox`,ne.append(re,L(`span`,null,`Accept edits`)),te.append(ne,ee),A.append(te);let ie=new Map;for(let[e,t]of[[`terminal`,`Answer in terminal`],[`revise`,`Send feedback`],[`approve`,`Approve`]]){let n=L(`button`,`plan-action`,t);n.type=`button`,n.dataset.decision=e,n.addEventListener(`click`,()=>{n.disabled||Ze(e)}),ie.set(e,n),A.append(n)}t.append(n,E,A,T);let j=null,ae={reviews:[]},M=null,N=null,oe=!0,se=``,ce=``,le=``,ue=``,de=!1,fe=null,pe=!1,me=null,he=!1,ge=!1,_e=null,ve=[],P=null,ye=null,be=new Map,xe=new Map,Se=new Map,Ce=[],we=!1,Te=null,Ee=!1;function De(e,t=!0){Ee=e,i.replaceChildren(...e?[a,_,l,s,b,y]:[a,s,l,_,y,b]),c.setAttribute(`role`,e?`radiogroup`:`tablist`);for(let t of c.querySelectorAll(`button`)){let n=t.getAttribute(`aria-selected`)===`true`||t.getAttribute(`aria-checked`)===`true`;t.setAttribute(`role`,e?`radio`:`tab`),t.removeAttribute(e?`aria-selected`:`aria-checked`),t.setAttribute(e?`aria-checked`:`aria-selected`,String(n))}i.dataset.open=String(e),T.dataset.open=String(e),C.setAttribute(`aria-expanded`,String(e)),E.inert=e,A.inert=e,r.inert=e,C.inert=e,w.inert=e,e?(i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-label`,`Plan view`),i.setAttribute(`aria-modal`,`true`),o.focus()):(i.removeAttribute(`role`),i.removeAttribute(`aria-modal`),t&&C.focus())}function Oe(e){e.addEventListener(`keydown`,t=>{let n={ArrowLeft:-1,ArrowUp:-1,ArrowRight:1,ArrowDown:1}[t.key];if(n===void 0&&t.key!==`Home`&&t.key!==`End`)return;let r=[...e.querySelectorAll(`button:not(:disabled)`)];if(r.length===0)return;t.preventDefault();let i=(r.indexOf(document.activeElement)+(n??0)+r.length)%r.length;t.key===`Home`&&(i=0),t.key===`End`&&(i=r.length-1);let a=Ee;r[i].click(),!(a&&e!==v)&&(e===v||!Ee)&&e.querySelector(`[aria-checked="true"], [aria-selected="true"]`)?.focus()})}let ke=W.subscribe((e,t)=>{t.includes(`layout`)&&Ee&&De(!1,!1)});e.signal?.addEventListener(`abort`,ke,{once:!0}),Oe(v),Oe(c),Oe(g),C.addEventListener(`click`,()=>De(!Ee)),o.addEventListener(`click`,()=>De(!1)),T.addEventListener(`click`,()=>De(!1)),i.addEventListener(`keydown`,e=>{if(!Ee)return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),De(!1);return}if(e.key!==`Tab`)return;let t=[...i.querySelectorAll(`button:not(:disabled)`)].filter(e=>e.getClientRects().length>0&&e.tabIndex>=0),n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())});function Ae(e){O.querySelector(`#${CSS.escape(e)}`)?.scrollIntoView({behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`,block:`start`})}r.addEventListener(`change`,()=>Ae(r.value));function je(){we=!1;let e=Ce.map(e=>O.querySelector(`#${CSS.escape(e.dataset.headingId??``)}`)).filter(e=>e!==null),t=O.getBoundingClientRect().top-O.scrollTop,n=k_({headingOffsets:e.map(e=>e.getBoundingClientRect().top-t),scrollTop:O.scrollTop,isScrolledToEnd:O.scrollTop>0&&O.scrollTop+O.clientHeight>=O.scrollHeight-2,readingLineOffset:N_}),i=n===null?null:e[n]?.id??null;for(let e of Ce)e.dataset.headingId===i?e.setAttribute(`aria-current`,`location`):e.removeAttribute(`aria-current`);i!==null&&(r.value=i)}function Me(){we||t.hidden||Ce.length===0||(we=!0,requestAnimationFrame(je))}O.addEventListener(`scroll`,Me,{passive:!0});function Ne(){Te=null,pe=!1,he=!1,ge=!1,_e=null}function Pe(t){P=t,e.reportProblem(t),bt()}function Fe(e){N=e,P=null,Ne(),De(!1,Ee),bt()}function Ie(e){let t=ae.reviews.find(e=>e.agentId===M)?.revisions??[],n=t[t.findIndex(e=>e.revision===N)+e];n&&Fe(n.revision)}d.addEventListener(`click`,()=>Ie(-1)),f.addEventListener(`click`,()=>Ie(1));function Le(e,t){return`${j??``}:${e??`main`}:${t??`latest`}`}function Re(){return Le(M,N)}function ze(e,t,n){return`${e??``}:${F_(t,n??0)}`}function Be(){return ze(j,M,N)}function Ve(){return xe.get(Be())??null}function He(){return Ve()?.size??0}function Ue(){if(Te===null)return!1;let e=xe.get(Te.target.bucketKey)?.get(Te.target.sectionSlot)??``;return Te.field.value.trim()!==e}function We(e){let t=xe.get(e);if(!t)return[];let n=[];for(let e of ve){let r=t.get(I_(e));r&&n.push({heading:e.heading,comment:r})}return n}function Ge(e,t){let n=t.trim(),r=xe.get(e.bucketKey)??new Map;xe.set(e.bucketKey,r),n.length===0&&r.delete(e.sectionSlot),n.length>0&&r.set(e.sectionSlot,n),r.size===0&&xe.delete(e.bucketKey),bt()}function Ke(e){if(ge||de)return;let t={bucketKey:Be(),sectionSlot:I_(e)},n=L(`div`,`plan-comment-composer`),r=L(`label`,`plan-comment-label`,`Comment on ${e.heading??`Introduction`}`),i=L(`textarea`,`plan-comment-input`);i.maxLength=kt,i.value=xe.get(t.bucketKey)?.get(t.sectionSlot)??``,r.append(i);let a=L(`div`,`plan-comment-actions`),o=L(`button`,`plan-control plan-comment-cancel`,`Cancel`);o.type=`button`;let s=L(`button`,`plan-control plan-comment-save`,`Save comment`);s.type=`button`,a.append(o,s),n.append(r,a);let c={target:t,element:n,field:i};Te=c,i.addEventListener(`input`,yt),o.addEventListener(`click`,()=>{Te===c&&(Te=null,bt())}),s.addEventListener(`click`,()=>{Te===c&&(Te=null),Ge(t,i.value)}),bt(),i.focus()}function qe(e){let t={bucketKey:Be(),sectionSlot:I_(e)};if(Te?.target.bucketKey===t.bucketKey&&Te.target.sectionSlot===t.sectionSlot)return Te.element;let n=Ve()?.get(t.sectionSlot);if(!n)return null;let r=L(`div`,`plan-comment-card`),i=L(`div`,`plan-comment-head`),a=L(`button`,`plan-control plan-comment-edit`,`Edit`);a.type=`button`,a.addEventListener(`click`,()=>Ke(e));let o=L(`button`,`plan-control plan-comment-remove`,`Remove`);return o.type=`button`,o.disabled=de,a.disabled=de,o.addEventListener(`click`,()=>Ge(t,``)),i.append(L(`span`,`plan-comment-label`,`Your comment`),a,o),r.append(i,L(`p`,`plan-comment-text`,n)),r}function Je(t,n,r={}){if(!j||n.revision===null||de)return!1;let i=C_(r);if(i!==null)return Pe(i),!1;let a={agentId:n.agentId,revision:n.revision,decision:t,...r};return e.sendDecision(j,a)?(P=null,de=!0,fe=u_(t)?n:null,bt(),!0):(Pe(p),!1)}function Ye(e){if(!pe)return{};let t=k.value;return t===z_(j,e.agentId,e.revision)?{}:{plan:t}}function Xe(e){let t=ze(j,e.agentId,e.revision),n=We(t);n.length!==0&&Je(`revise`,e,{comments:n})&&e.revision!==null&&(ye={bucketKey:t,agentId:e.agentId,revision:e.revision},bt())}function Ze(e){let t={agentId:M,revision:N};e===`revise`?Xe(t):Je(e===`approve`&&!ne.hidden&&re.checked?`approve-accept-edits`:e,t,Ye(t))}function Qe(e){Te=null,pe=e===`edit`,he=e===`changes`,pe&&me!==Be()&&(k.value=z_(j,M,N)??``,me=Be()),P=null,bt()}function $e(e){return`${e.kind}:${Le(e.agentId,e.revision)}`}function et(e){for(Se.set($e(e),e);Se.size>j_;){let e=Se.keys().next().value;if(typeof e!=`string`)break;Se.delete(e)}}function tt(e,t){return e.agentId===t.agentId?e.kind===`draft`?t.revision===0:t.revision===0?!1:e.revision===null||e.revision===t.revision:!1}function nt(e){for(let[t,n]of Se)if(tt(n,e))return Se.delete(t),n;return null}function rt(){for(let[e,t]of Se)if(t.kind===`draft`)return Se.delete(e),t;return null}function it(){if(Se.size!==1)return null;let e=Se.entries().next().value;return e?(Se.delete(e[0]),e[1]):null}function at(){if(!j)return;let t=Re();se!==t&&e.requestPlan(j,M,N??void 0)&&(se=t,et({kind:`selection`,agentId:M,revision:N}))}function ot(){t.hidden||at()}function st(){return g_(ae,M,N)}function ct(t){if(!j)return;let n=Le(M,t);le!==n&&e.requestPlan(j,M,t)&&(le=n,et({kind:`diff-base`,agentId:M,revision:t}))}function lt(){if(!j)return;let t=`${j}:${M??`main`}`;ue!==t&&e.requestDraft(j,M)&&(ue=t,et({kind:`draft`,agentId:M,revision:null}))}function ut(e,t){return`${e??``}:${t??``}`}function dt(){return ae.reviews.find(e=>e.agentId===M)?.revisions.find(e=>e.revision===N)?.receivedAt??0}function ft(){let e=be.get(ut(j,M));return e!==void 0&&e>dt()}function pt(){ge?(Ne(),bt()):(Te=null,pe=!1,he=!1,lt(),bt())}S.addEventListener(`click`,pt);function F(e){D.replaceChildren(),r.replaceChildren(),Ce=[];for(let t of e){let e=t.id??`plan-introduction`,n=t.heading??`Introduction`,i=L(`button`,`plan-heading-link`,n);i.type=`button`,i.dataset.level=String(t.level),i.dataset.headingId=e,i.title=n,i.dataset.commented=String(Ve()?.has(I_(t))===!0),Ce.push(i),i.addEventListener(`click`,()=>Ae(e)),D.append(i);let a=L(`option`,null,n);a.value=e,r.append(a)}}function mt(e){let t=st();if(t===null){O.append(L(`p`,`plan-loading`,`This is the first revision, so there is nothing to diff`));return}let n=z_(j,M,t);if(n===null){O.append(L(`p`,`plan-loading`,`Loading the previous revision`)),ct(t);return}let r=c_(n,e);r.isTooLarge?(O.append(L(`p`,`plan-loading`,`This diff is too large to show, so the newer revision stands alone`)),O.append(Wo(zo(e)))):O.append(qo(r))}function ht(e){if(O.replaceChildren(),pe){F(ve),O.append(k);return}if(e===null){if(ve=[],F(ve),ce===Re()){O.append(L(`p`,`plan-loading`,`This plan revision could not be loaded`));return}O.append(L(`p`,`plan-loading`,`Loading plan`)),at();return}let t=zo(e);if(ve=Bo(t),F(ve),he){mt(e);return}if(ge){O.append(Wo(t));return}let n=Ve();O.append(Go(ve,{hasComment:e=>n?.has(I_(e))===!0,isComposing:e=>Te?.target.bucketKey===Be()&&Te.target.sectionSlot===I_(e),onComment:Ke,attachmentFor:qe}))}function gt(e){s.hidden=e.tabs.length<2,c.replaceChildren();for(let t of e.tabs){let e=L(`button`,`plan-tab`,t.label);e.type=`button`,e.setAttribute(`role`,Ee?`radio`:`tab`),e.setAttribute(Ee?`aria-checked`:`aria-selected`,String(t.selected)),e.tabIndex=t.selected?0:-1,e.addEventListener(`click`,()=>{M=t.agentId,N=null,P=null,se=``,ce=``,le=``,ue=``,Ne(),De(!1,Ee),bt()}),c.append(e)}}function _t(){return ge?_e:z_(j,M,N)}function vt(e){return D_({state:ae,selectedAgentId:M,selectedRevision:N,body:e,isConnected:oe,isDecisionInFlight:de,isDraft:ge,pendingCommentCount:He(),hasUnsavedComment:Ue(),problem:P})}function I(e){ee.textContent=e.status,ee.hidden=e.status.length===0;let t=e.actions.some(e=>e.kind===`approve`&&e.enabled);ne.hidden=!t,re.disabled=!t;for(let t of e.actions){let e=ie.get(t.kind);e&&(e.disabled=!t.enabled)}}function yt(){I(vt(_t()))}function bt(){let e=Ee&&i.contains(document.activeElement),t=D_({state:ae,selectedAgentId:M,selectedRevision:N,body:null,isConnected:oe});(M!==t.selectedAgentId||N!==t.selectedRevision)&&Ne(),M=t.selectedAgentId,N=t.selectedRevision,me!==Be()&&(me=null);let n=_t(),a=vt(n);gt(a);let s=a.revisions.findIndex(e=>e.selected),c=a.revisions[s],l=Date.now();u.hidden=a.revisions.length<2,m.textContent=`Rev ${s+1} of ${a.revisions.length}`,h.textContent=c?__(c.receivedAt,l):``,d.disabled=s<=0,f.disabled=s<0||s>=a.revisions.length-1,g.replaceChildren();for(let e of[...a.revisions].reverse()){let t=L(`button`,`plan-revision-option`);t.type=`button`,t.dataset.revision=String(e.revision),t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.selected)),t.tabIndex=e.selected?0:-1,t.append(L(`span`,`plan-revision-name`,e.label),L(`span`,`plan-revision-age`,__(e.receivedAt,l))),e.isOpen&&t.append(L(`span`,`plan-revision-open`,`OPEN`)),t.addEventListener(`click`,()=>Fe(e.revision)),g.append(t)}v.replaceChildren();let p=pe?`edit`:he?`changes`:`read`,_=a.modes.find(e=>e.kind===p&&e.enabled)??a.modes[0];for(let e of a.modes){let t=L(`button`,`plan-control plan-mode`,e.label);t.type=`button`,t.dataset.mode=e.kind,t.disabled=!e.enabled,t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.kind===p)),t.tabIndex=e.kind===_.kind?0:-1,t.addEventListener(`click`,()=>{t.disabled||(Qe(e.kind),v.querySelector(`[aria-checked="true"]`)?.focus())}),v.append(t)}b.hidden=!ft()&&!ge,S.hidden=b.hidden,S.setAttribute(`aria-pressed`,String(ge)),I(a),ht(n),r.disabled=Ce.length===0,Me(),e&&!i.contains(document.activeElement)&&o.focus()}function xt(t){fe!==null&&f_(t,fe.agentId)&&(fe=null,me=null,e.showTerminal())}function St(e){Te=null,e!==j&&(fe=null,de=!1,P=null,Se.clear()),De(!1,!1),j=e,t.hidden=!1,se=``,ce=``,bt(),ot()}function Ct(){Te=null,De(!1,!1),t.hidden=!0}function wt(e,t){return t.kind!==`selection`||e.agentId!==M?!1:t.revision===null?N===null||N===e.revision:t.revision===N}function R(e){e.kind===`draft`?(ue=``,Pe(`the draft could not be read, so nothing was shown`)):e.kind===`diff-base`?le=``:ce=Le(e.agentId,e.revision)}function Tt(e){ye!==null&&h_(e,ye.agentId)!==ye.revision&&(xe.delete(ye.bucketKey),ye=null)}function Et(e){de=!1,z({reviews:e.reviews});let t=e.body;if(!t){let e=it()??rt();e!==null&&R(e);return}let n=nt(t);if(t.revision===0){if(ue=``,n===null||t.agentId!==M)return;_e=t.plan,ge=!0}else L_(e.id,t),n!==null&&wt(t,n)&&(M=t.agentId,N=t.revision,se=``,ce=``)}function z(e){let t=h_(e,M);t!==null&&t!==h_(ae,M)&&(N=t,Ne()),Tt(e),ae=e,de=!1,xt(e)}function Dt(e){let n=!1;e.state&&z(e.state),e.draft&&be.set(ut(e.draft.id,e.draft.agentId),e.draft.changedAt),e.decisionRefused&&(fe=null,de=!1,ye=null,e.refusalText&&(P=e.refusalText)),typeof e.isConnected==`boolean`&&(n=e.isConnected&&!oe,oe=e.isConnected,n&&(se=``,ce=``,le=``,ue=``,de=!1)),e.requestFailed&&(ce=se),e.response&&Et(e.response),t.hidden||bt(),(n||e.decisionRefused)&&ot()}return{el:t,show:St,hide:Ct,update:Dt}}var V_=10;function H_(e){let t=new Map;for(let n of e.files){let e=n.path.split(`/`);for(let r=0;r<e.length;r++){let i=e.slice(0,r).join(`/`),a=t.get(i);a!==void 0&&a.localeCompare(n.path)<=0||t.set(i,n.path)}}return t}function U_(e,t){let n=[],r=new Set(e.files.map(e=>e.path));for(let i of e.links){let a=t.get(i.providerRepo),o=a?.firstChangedPathByDirectory.get(i.packageDir),s=o??i.importers.find(e=>r.has(e))??i.importers[0]??i.consumerManifest,c=o&&a?a.repo:e,l=i.importerCount===1?`file`:`files`,u=i.providerChangedPathCount===1?`file`:`files`,d=i.changedImporterCount===1?`file`:`files`,f=i.isLocalLink?`Linked locally (${i.versionSpec}), so ${i.providerRepo} changes reach it now.`:`Uses ${i.versionSpec} from the registry, so ${i.providerRepo} changes reach it only after a publish.`;i.providerChangedPathCount>0&&(f+=` ${i.providerRepo} changed ${i.providerChangedPathCount} ${u} in ${i.packageDir||`the repository root`}.`),i.changedImporterCount>0&&(f+=` ${i.changedImporterCount} importing ${d} changed here.`),n.push({dedupeKey:`link:${i.providerRepo}:${i.packageName}:${e.name}`,kind:`link`,severity:6,path:s,openPath:`${c.sessionPathPrefix}${s}`,text:`${e.name} imports ${i.packageName} from ${i.providerRepo} in ${i.importerCount} ${l}`,detail:f})}for(let t of e.collisions)n.push({dedupeKey:`collision:${e.sessionPathPrefix}${t.path}:${t.otherSessionId}`,kind:`collision`,severity:5,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,text:`Also being changed in "${t.otherSessionName}"`,detail:`Another live session is changing this file, so the two may conflict.`});for(let t of e.coChangeGaps){let r=t.confidence>0?Math.round(t.support/t.confidence):0;n.push({dedupeKey:`co-change:${e.sessionPathPrefix}${t.path}:${t.partner}`,kind:`co-change`,severity:4,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,text:`Usually changes with ${t.partner}, which is not in this change`,detail:`${t.support} of the ${r} commits that touched it also touched ${t.partner}.`})}for(let t of e.untestedFiles)n.push({dedupeKey:`untested:${e.sessionPathPrefix}${t.path}`,kind:`untested`,severity:3,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,text:`No test reaches it`,detail:`No dependent test was found in the import graph.`});return n}function W_(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function G_(e,t){for(let n of e.hotspots)W_(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`,title:`${n.fixCommitCount} of its last ${n.commitCount} commits were fixes.`});for(let n of e.blastRadius)n.transitiveDependentCount<V_||W_(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`,title:`${n.transitiveDependentCount} files depend on it: ${n.directDependentCount} directly, ${n.dependentTestCount} of them tests.`})}function K_(e,t){return t.severity-e.severity||e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function q_(e){let t=new Set(e.repos.flatMap(e=>e.links.map(e=>e.providerRepo))),n=new Map;for(let r of e.repos)t.has(r.name)&&!n.has(r.name)&&n.set(r.name,{repo:r,firstChangedPathByDirectory:H_(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of U_(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);G_(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:[...r.values()].sort(K_),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function J_(e,t){let n=null;for(let r of e)t.startsWith(r.sessionPathPrefix)&&(n&&n.sessionPathPrefix.length>=r.sessionPathPrefix.length||(n=r));return n?.name??null}var Y_=5;function X_(e,t){let n=L(`button`,`review-look-line`);return n.type=`button`,n.dataset.kind=e.kind,n.title=`${e.detail} Click to open ${e.path} below.`,n.append(L(`span`,`review-look-file`,e.path),L(`span`,`review-look-text`,e.text)),n.addEventListener(`click`,()=>t(e.openPath)),n}function Z_(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=L(`section`,`review-look`);if(i.append(L(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=L(`p`,`review-look-error`,`Could not check this change for anything worth a look.`);t.title=e.errors.join(`
162
+ `),i.append(t)}let a=t?e.worthALook:e.worthALook.slice(0,Y_);if(a.length>0){let e=L(`div`,`review-look-list`);for(let t of a)e.append(X_(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=L(`div`,`review-look-more`),c=L(`button`,`review-look-show-all`,`Show all`);return c.type=`button`,c.addEventListener(`click`,n),s.append(L(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function Q_(e){return(e??[]).map(e=>{let t=L(`span`,`review-file-hint`,e.text);return t.title=e.title,t})}function $_(e){let t=/^@@+ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return!Number.isFinite(n)||!Number.isFinite(r)?null:{oldStart:n,newStart:r}}function ev(e){let t=[];if(!e)return t;let n=String(e).split(/\r?\n/),r=null,i=null,a=null,o=null,s=()=>{if(a===null)return null;let e=a;return a=e+1,e},c=()=>{if(o===null)return null;let e=o;return o=e+1,e},l=e=>{let n={path:``,oldPath:null,status:`modified`,added:0,removed:0,binary:!1,hunks:[]};t.push(n),i=null;let r=/^diff --git a\/(.+?) b\/(.+)$/.exec(e);return r&&(n.oldPath=r[1]??null,n.path=r[2]??``),n};for(let e of n)if(e.startsWith(`diff --git `))r=l(e);else{if(!r){if(!e.startsWith(`--- `)&&!e.startsWith(`@@`))continue;r=l(`diff --git a/ b/`)}if(r){if(e.startsWith(`new file mode`))r.status=`added`;else if(e.startsWith(`deleted file mode`))r.status=`deleted`;else if(e.startsWith(`rename from `))r.oldPath=e.slice(12),r.status=`renamed`;else if(e.startsWith(`rename to `))r.path=e.slice(10),r.status=`renamed`;else if(e.startsWith(`Binary files`))r.binary=!0;else if(!(e.startsWith(`index `)||e.startsWith(`similarity index`)||e.startsWith(`dissimilarity index`)||e.startsWith(`old mode`)||e.startsWith(`new mode`))){if(e.startsWith(`--- `)){if(e===`--- /dev/null`){r.status=`added`;continue}if(!r.path){let t=e.slice(4).replace(/^a\//,``);t&&t!==`/dev/null`&&(r.oldPath=r.oldPath||t)}}else if(e.startsWith(`+++ `)){if(e===`+++ /dev/null`){r.status=`deleted`;continue}if(!r.path){let t=e.slice(4).replace(/^b\//,``);t&&t!==`/dev/null`&&(r.path=t)}}else if(e.startsWith(`@@`)){i={header:e,lines:[]},r.hunks.push(i);let t=$_(e);a=t?t.oldStart:null,o=t?t.newStart:null}else if(i){if(e===``)continue;let t=e[0];if(t===`+`){i.lines.push({type:`add`,text:e.slice(1),oldLineNumber:null,newLineNumber:c()}),r.added++;continue}if(t===`-`){i.lines.push({type:`del`,text:e.slice(1),oldLineNumber:s(),newLineNumber:null}),r.removed++;continue}if(t===`\\`){i.lines.push({type:`meta`,text:e.slice(1).trim(),oldLineNumber:null,newLineNumber:null});continue}i.lines.push({type:`context`,text:t===` `?e.slice(1):e,oldLineNumber:s(),newLineNumber:c()})}}}}for(let e of t)e.path||=e.oldPath||`(unknown)`;return t}function tv(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function nv(e){let t=0,n=0;for(let r of e||[])t+=r.added||0,n+=r.removed||0;return{files:(e||[]).length,added:t,removed:n}}function rv({changedFileCount:e,hasCommits:t,canMerge:n,isWorkspace:r,live:i,effectiveBase:a}){let o=`${e} file${e===1?``:`s`} changed`,s=(t,n)=>e>0?`${o}, ${t}`:n;if(r)return{text:e>0?`${o} in this worktree`:`Changes in this worktree`,namesMergeTarget:!1};if(n){let e=cv(a);return{text:s(`ready to merge into ${e}`,`Ready to merge into ${e}`),namesMergeTarget:!0}}return i?t?{text:s(`not ready to merge`,`Not ready to merge`),namesMergeTarget:!1}:{text:s(`not committed yet`,`Not committed yet`),namesMergeTarget:!1}:{text:s(`session ended`,`Session ended`),namesMergeTarget:!1}}function iv({status:e,mergeReason:t,fetched:n,hasDiffError:r,hasChanges:i,hasCommits:a,canMerge:o,isWorkspace:s,live:c,effectiveBase:l,changedFileCount:u=0}){return e===`parked`&&t===`base-diverged`?{text:`Parked: base branch diverged`,namesMergeTarget:!1}:e===`parked`?{text:`Parked: merge conflict`,namesMergeTarget:!1}:e===`merging`?{text:`Merging`,namesMergeTarget:!1}:e===`merged`?{text:`Merged`,namesMergeTarget:!1}:r?{text:`Could not read changes`,namesMergeTarget:!1}:n?i?rv({changedFileCount:u,hasCommits:a,canMerge:o,isWorkspace:s,live:c,effectiveBase:l}):{text:`No changes yet`,namesMergeTarget:!1,isEmpty:!0}:{text:`Checking for changes`,namesMergeTarget:!1}}function av(e,t){return e?`Edits this session makes in its worktree show up here.`:`Edits this session makes show up here, ready to merge into ${cv(t)}.`}function ov(e,t){return e.namesMergeTarget?null:`merges into ${cv(t)}`}function sv({status:e,mergeReason:t,live:n,isMergeRendered:r,hasChanges:i}){return e===`parked`&&n&&t!==`base-diverged`?`resolve`:!i&&e!==`parked`&&e!==`merging`?`none`:r?`merge`:`none`}function cv(e){return e||`base`}function lv(e,t){return`Merge into ${cv(e)}, push it, and rebase this worktree, then keep working (${t})`}function uv(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function dv(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function fv({status:e,hasCommits:t,live:n,state:r}){return e===`merging`?null:t?!n&&(e===`parked`||e===`merged`)?`Session ended.`:!n||e===`parked`?null:r===`INITIALIZING`||r===`STARTING`?`Starting up. Mergeable once the session is live.`:null:n?`Nothing is committed yet. Merge opens once the session commits.`:null}function pv({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function mv(e){return e||`its upstream`}function hv(e){if(!e)return null;let t=e.branch||`Base branch`,{state:n,ahead:r,behind:i}=e,a=mv(e.upstream);return n===`no-upstream`?`${t}: no upstream`:n===`unknown`&&e.error&&e.action===void 0?`${t}: sync check failed: ${e.error}`:n===`unknown`?`${t}: sync state unknown vs ${a}`:n===`in-sync`?`${t}: in sync with ${a}`:n===`ahead`?`${t}: ${r} ahead of ${a}`:n===`behind`?`${t}: ${i} behind ${a}`:n===`diverged`?`${t}: ${r} ahead, ${i} behind ${a}`:null}function gv(e){return!e||e.fetched===!1?`recheck`:e.state===`ahead`||e.state===`behind`?`resync`:`recheck`}function _v(e,t,n){let r=n?` (${t})`:``;if(!e||gv(e)===`recheck`)return`Click to fetch and check again${r}`;let i=e.branch||`Base branch`,a=mv(e.upstream);return e.state===`behind`?`Click to fast-forward ${i} to ${a}${r}`:`Click to push ${i} to ${a}${r}`}function vv(e){return e?.state!==`in-sync`||e.fetched===!1}function yv(e){if(e.error)return`Resync failed: ${e.error}`;let t=e.branch||`The base branch`,n=mv(e.upstream);return e.action===`fast-forwarded`?`Fast-forwarded ${t} to ${n}.`:e.action===`pushed`?`Pushed ${t} to ${n}.`:e.state===`diverged`?`${t} has diverged from ${n}. Resolve manually.`:e.state===`in-sync`?null:e.state===`no-upstream`?`${t} has no upstream to resync against.`:`Could not determine sync status.`}var bv=new Set([`pending-review`,`parked`]),xv=600,Sv=kn(`merge`,Pa),Cv=kn(`resolve-or-resync`,Pa),wv={minPx:260,maxPx:700},Tv=16,Ev=5e3,Dv=new Map,Ov=new Map,kv=new Map,Av=new Map,jv=new Map,Mv=new Map,Nv=new Set,Pv=new WeakMap,Fv=new WeakMap,Iv=new Set,Lv=new Set,Rv=!1,zv=null,Bv=null,K=null,Vv=null,Hv=null,Uv=null,Wv=null,Gv=null,Kv=null,qv=!1,Jv=null,Yv=null,Xv=null,Zv=null,Qv=new Map,$v=null,ey=null;function ty(e,t){let n=L(`button`,`review-icon-button`);return n.type=`button`,n.title=e,n.setAttribute(`aria-label`,e),n.append(sr(t)),n}function ny(){qv=!1,K?.querySelector(`.review-more-menu`)?.remove(),K?.querySelector(`.review-more-button`)?.setAttribute(`aria-expanded`,`false`)}function ry({panel:e}){if(Bv=e,!Bv)return;let t=Bv,n=L(`div`,`review-sidebar-head`),r=L(`span`,`review-sidebar-title`,`Review`);Kv=L(`span`,`review-sidebar-session`),r.append(Kv);let i=e=>{t.toggleAttribute(`data-collapsed`,e),vn(!e)},a=ty(`Close review`,`M6 3L11 8L6 13`);a.classList.add(`review-sidebar-close`),a.addEventListener(`click`,()=>i(!0)),n.append(r,a);let o=L(`div`,`review-sidebar-rail`),s=ty(`Open review`,`M10 3L5 8L10 13`);s.classList.add(`review-sidebar-open`),s.addEventListener(`click`,()=>i(!1)),Uv=L(`div`,`review-rail-status`),Wv=L(`span`,`review-rail-added`),Gv=L(`span`,`review-rail-removed`),Uv.append(Wv,Gv),Hv=L(`span`,`review-rail-label`,`Review`),o.append(s,Hv,Uv),K=L(`div`,`review-controls`),Vv=L(`div`,`review-sidebar-body`);let c=L(`div`,`review-resize-handle`);c.setAttribute(`role`,`separator`),c.setAttribute(`aria-orientation`,`vertical`),c.setAttribute(`aria-label`,`Resize review sidebar`),c.tabIndex=0,t.append(o,n,K,Vv,c),t.toggleAttribute(`data-collapsed`,!an()),ay(Vv),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&qv&&(e.preventDefault(),ny(),K?.querySelector(`.review-more-button`)?.focus())}),document.addEventListener(`pointerdown`,e=>{qv&&e.target instanceof Element&&(K?.contains(e.target)&&e.target.closest(`.review-more-button, .review-more-menu`)||ny())}),el({resizer:c,column:t,widthHost:t,widthProperty:`--sidebar-width`,bounds:wv,keyStepPx:Tv,getStoredWidth:Gn,setStoredWidth:yn,growsLeftward:!0}),Mu(e=>{qv=!1,Xv=null,Iv.clear(),Lv.clear(),Rv=!1,zv=null,e&&My(e),e&&!Py(e)&&Fy(e),q()}),q()}function iy(e,t){let n=Dv.get(e);Dv.set(e,t),tv(n,t)&&(kv.delete(e),Av.delete(e),jv.delete(e),e===Au()&&Ny(e)),e===Au()&&q()}function ay(e){let t=!1,n=null,r=null,i=e=>T({type:`watch-session-changes`,id:e}),a=()=>{let e=t&&document.visibilityState===`visible`?Au():null;e!==n&&(r&&clearInterval(r),r=null,n=e,i(e),e&&(r=setInterval(()=>i(e),j)))};new IntersectionObserver(e=>{t=e[e.length-1]?.isIntersecting??!1,a()}).observe(e),document.addEventListener(`visibilitychange`,a),Mu(a)}function oy(e){Bv&&(e?(jt(Bv,e),q()):(lt(Bv),q()))}function sy(e,t,n=null){let r=t||`none`;Ov.set(e,n);let i=Qv.get(e);i!==void 0&&i!==r&&Qv.delete(e),iy(e,r)}function cy(e){let t=V(e);t&&Qv.delete(t)&&t===Au()&&q()}function ly(e,t,n=null){Ov.set(e,n),Qv.delete(e),iy(e,t||`none`)}function uy(e,t){kv.set(e,t),Av.delete(e),e===Au()&&(zv&&Vy(zv,t),q(),Hy())}function dy(e,t){let n=V(e);n&&(Av.set(n,t),n===Au()&&q())}function fy(e,t){let n=V(e);if(!n)return;let r=Ye.safeParse(t);r.success&&r.data.sessionId===n&&(jv.set(n,r.data),n===Au()&&q())}function py(e,t){let n=V(e),r=t;Mv.set(n,r),r&&r.action!==void 0&&my(n,r),n===Au()&&q()}function my(e,t){Nv.delete(e),clearTimeout(ey??void 0),ey=null;let n=yv(t);$v=n?{forId:e,text:n,isError:!!t.error}:null,$v&&!$v.isError&&(ey=setTimeout(()=>{$v&&$v.forId===e&&($v=null),q()},5e3))}function hy(e){let t=V(e);t&&t===Au()&&My(t)}function gy(e){let t=V(e);if(t!==Au())return;let n=!kv.has(t)||Av.has(t),r=!jv.has(t)||_y(jv.get(t));n&&My(t),r&&!n&&Ny(t),q()}function _y(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function vy(e){let t=V(e);Dv.delete(t),Ov.delete(t),kv.delete(t),Av.delete(t),jv.delete(t),Mv.delete(t),Nv.delete(t),$v&&$v.forId===t&&(clearTimeout(ey??void 0),$v=null),t===Au()?ju(null):q()}function yy(){let e=Au(),t=e?H.get(e):null;if(!e||!t)return by(null,`No session is open to merge.`);if(Py(e))return by(e,`A workspace session has no worktree to merge.`);if(Qv.has(e))return by(e,`Merge is already on its way for "${By(t,e)}".`);let n=Dv.get(e)||`none`,r=!!kv.get(e)?.hasCommits,i=dv(n,Ov.get(e)||null,Oy(t.currentState,r));return sv({status:n,mergeReason:Ov.get(e)||null,live:jy(t.currentState),isMergeRendered:i.isRendered,hasChanges:Dy(e)})!==`merge`||!i.isEnabled?by(e,fv({status:n,hasCommits:r,live:jy(t.currentState),state:t.currentState})??`Nothing to merge in "${By(t,e)}" right now.`):(ky(e,t.currentState),!0)}function by(e,t){return Xv={forId:e,text:t},clearTimeout(Zv??void 0),Zv=setTimeout(()=>{Xv=null,q()},Ev),q(),!1}function xy(){let e=Au();if(!e||Py(e))return!1;let t=H.get(e);if(!t)return!1;let n=Dv.get(e)||`none`,r=Ov.get(e)||null;return sv({status:n,mergeReason:r,live:jy(t.currentState),isMergeRendered:dv(n,r,!1).isRendered,hasChanges:Dy(e)})!==`resolve`||Sy(e)?!1:(Cy(e),!0)}function Sy(e){return Jv?.forId===e&&!Jv.isError}function Cy(e){let t=T({type:`resolve-session-merge`,id:e});Jv=t?{forId:e,text:`Resolve prompt sent`,isError:!1}:{forId:e,text:`Not connected. The resolve prompt was not sent.`,isError:!0},clearTimeout(Yv??void 0),Yv=setTimeout(()=>{Jv=null,q()},t?3e3:Ev),q()}function wy(){let e=Au();return!e||!H.has(e)||Py(e)||Ly(e)?!1:(Ry(e),!0)}function Ty(e){if(!e)return{committed:[],uncommitted:[]};let t=Pv.get(e);if(t)return t;let n={committed:ev(e.committed?.diff||``),uncommitted:ev(e.uncommitted?.diff||``)};return Pv.set(e,n),n}function Ey(e){let t=Fv.get(e);if(t)return t;let n=q_(e);return Fv.set(e,n),n}function Dy(e){let t=Ty(kv.get(e)),n=[...t.committed,...t.uncommitted],r=kv.get(e)??null;return pv({fetched:kv.has(e),changedFileCount:nv(n).files,hasCommits:!!r?.hasCommits})}function Oy(e,t){return(Mt.includes(e)||e===z.RUNNING)&&t}function ky(e,t){t===z.RUNNING?wr({title:`Merge while working`,message:`This session still looks like it is working. Merging rebases its worktree under it. Merge anyway?`,confirmLabel:`Merge anyway`,onConfirm:()=>Ay(e,!0)}):Ay(e,!1)}function Ay(e,t){Qv.has(e)||(T(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(Qv.set(e,Dv.get(e)||`none`),e===Au()&&q()):by(e,`Not connected. The merge was not sent.`))}function jy(e){return e!==z.DORMANT&&e!==z.DONE&&e!==z.FAILED}function My(e){T({type:`request-session-diff`,id:e}),Ny(e)}function Ny(e){jv.has(e)||jv.set(e,null),T({type:`request-change-map`,id:e})}function Py(e){return H.get(e)?.card.dataset.workspace!==void 0}function Fy(e){Mv.set(e,null),T({type:`request-branch-sync`,id:e}),e===Au()&&q()}function Iy(e){Nv.add(e),clearTimeout(ey??void 0),$v&&$v.forId===e&&($v=null),T({type:`resync-branch`,id:e}),e===Au()&&q()}function Ly(e){return Nv.has(e)||Mv.get(e)===null}function Ry(e){Ly(e)||(gv(Mv.get(e))===`resync`?Iy(e):Fy(e))}function zy(e,t){return t?{text:`Resyncing`,loading:!0,error:!1}:$v&&$v.forId===e?{text:$v.text,loading:!1,error:$v.isError}:null}function By(e,t){return e?.card?.dataset.session||t}function Vy(e,t){if(!t)return;let{committed:n,uncommitted:r}=Ty(t);for(let t of n)(t.path===e||t.oldPath===e)&&Iv.add(`committed:${t.path}`);for(let t of r)(t.path===e||t.oldPath===e)&&Iv.add(`uncommitted:${t.path}`)}function Hy(){if(!Vv||!zv)return;let e=Vv.querySelectorAll(`.review-file`);for(let t of e)if(t.dataset.path===zv||t.dataset.oldPath===zv){t.scrollIntoView({block:`nearest`}),zv=null;return}}function Uy(e){zv=e,Vy(e,kv.get(Au()??``)),q(),Hy()}function Wy(){Rv=!0,q()}function q(){let e=Vv?.scrollTop??0;Gy(),Vv&&(Vv.scrollTop=e)}function Gy(){if(!K||!Vv)return;K.replaceChildren(),Vv.replaceChildren(),Hv&&(Hv.hidden=!0),Uv&&(Uv.hidden=!0);let e=Au(),t=e?H.get(e):null;if(qy(e,t),!e||!t){Xv&&K.append(Ky(Xv.text,!0)),Jy(`No session selected`,`Click a session name to review its changes here.`);return}let n=Py(e),r=Dv.get(e)||`none`,i=Ov.get(e)||null,a=t.currentState,o=bv.has(r),s=kv.has(e),c=s?kv.get(e):null,l=Av.get(e)??null,{committed:u,uncommitted:d}=Ty(c),f=!!c?.hasCommits,p=jy(a),m=dv(r,i,Oy(a,f)),h=Mv.get(e),g=Nv.has(e),_=cv(t.effectiveBase),v=nv([...u,...d]),y=sv({status:r,mergeReason:i,live:p,hasChanges:pv({fetched:s,changedFileCount:v.files,hasCommits:f}),isMergeRendered:m.isRendered}),b=iv({status:r,mergeReason:i,fetched:s,hasDiffError:l!==null,hasChanges:v.files>0||f,hasCommits:f,canMerge:!n&&m.isEnabled,isWorkspace:n,live:p,effectiveBase:_,changedFileCount:v.files}),x=b.isEmpty===!0,S=x||Ud()||vv(h),C=L(`div`,`review-status-headline`);if(C.append(L(`span`,`review-status-text`,b.text)),!n&&!S){let t=hv(h);if(t){C.title=t;let n=ty(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);n.classList.add(`review-branch-sync-refresh`),n.title=_v(h,Cv,y!==`resolve`),n.disabled=Ly(e),n.setAttribute(`aria-description`,t),n.addEventListener(`click`,()=>Ry(e)),C.append(L(`span`,`sr-only`,t),n)}}x||K.append(C);let w=L(`div`,`review-status-meta`);if(s&&v.files>0&&w.append(L(`span`,`review-status-added`,`+${v.added}`),L(`span`,`review-status-removed`,`-${v.removed}`),L(`span`,`review-status-spacer`)),!n&&S){let t=Yy(e,y!==`resolve`);t&&w.append(t)}w.childElementCount>0&&K.append(w),r===`parked`&&K.append(L(`div`,`review-status-explanation`,uv(i))),Hv&&(Hv.hidden=!1),Uv&&(Uv.hidden=!1,Uv.setAttribute(`aria-label`,`${b.text}, +${v.added}, -${v.removed}`),Uv.title=b.text),Wv&&(Wv.textContent=`+${v.added}`),Gv&&(Gv.textContent=`-${v.removed}`);let T=n?null:eb(e,{status:r,reviewable:o,mergeAction:m,live:p,state:a,effectiveBase:_,primaryAction:y});T&&K.append(T);let E=n?null:zy(e,g),D=!n&&y===`merge`&&!m.isEnabled?fv({status:r,hasCommits:f,live:p,state:a}):null;if(D){let e=L(`div`,`review-control-reason`,D);e.id=`review-merge-reason`,K.append(e),K.querySelector(`#review-merge-btn`)?.setAttribute(`aria-describedby`,e.id)}if(E?.text){let e=L(`div`,E.loading?`review-control-reason review-loading`:`review-control-reason`,E.text);e.id=`review-resync-reason`,E.error&&e.classList.add(`review-control-reason-error`),e.setAttribute(`role`,`status`),w.append(e),w.isConnected||K.insertBefore(w,C.isConnected?C.nextSibling:K.firstChild),K.querySelector(`.review-branch-sync-button, .review-branch-sync-refresh`)?.setAttribute(`aria-describedby`,e.id)}if(Jv?.forId===e&&K.append(Ky(Jv.text,Jv.isError)),Xv&&(Xv.forId===e||Xv.forId===null)&&K.append(Ky(Xv.text,!0)),l){Vv.append(L(`p`,`review-diff-error`,l));return}if(x){Jy(b.text,av(n,_));return}let O=jv.get(e),k=O?Ey(O):null,A=k?Z_(k,{isShowingAll:Rv,onShowAll:Wy,onOpenFile:Uy}):null;A&&Vv.append(A);let ee=u.length>0&&d.length>0;u.length>0&&Vv.append(Xy({kind:`committed`,label:ee?`Committed`:null,meaning:ov(b,_),files:u,changeMapView:k})),d.length>0&&Vv.append(Xy({kind:`uncommitted`,label:ee?`Not committed yet`:null,meaning:null,files:d,changeMapView:k}))}function Ky(e,t){let n=L(`div`,t?`review-control-reason review-control-reason-error`:`review-resolve-sent`,e);return n.setAttribute(`role`,`status`),n}function qy(e,t){if(!Kv)return;let n=e&&t?By(t,e):``;Kv.textContent=n,Kv.hidden=!n,Kv.title=n}function Jy(e,t){if(!Vv)return;let n=L(`div`,`review-empty`);n.append(L(`div`,`review-empty-title`,e),L(`div`,`review-empty-desc`,t)),Vv.append(n)}function Yy(e,t){let n=Mv.get(e);if(n===void 0)return null;if(n===null)return L(`span`,`review-branch-sync-text review-loading`,`Checking branch sync...`);let r=hv(n)||`Base branch: sync state unknown`,i=L(`span`,`review-branch-sync-text`);n.state&&(i.dataset.syncState=n.state),n.fetched===!1&&(i.dataset.stale=`true`);let a=ty(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);return a.classList.add(`review-branch-sync-button`),a.title=_v(n,Cv,t),a.disabled=Nv.has(e),a.addEventListener(`click`,()=>Ry(e)),i.append(a,L(`span`,`review-branch-sync-label`,r)),i}function Xy({kind:e,label:t,meaning:n,files:r,changeMapView:i}){let a=L(`div`,`review-section`);a.dataset.kind=e,t&&a.append(Zy(t,n,r));let o=L(`div`,`review-diff`),s=i&&i.repos.length>1?i.repos:[],c=null;for(let t of r){let n=s.length>0?J_(s,t.path):null;n&&n!==c&&o.append(L(`div`,`review-repo-label`,n)),c=n,o.append(Qy(t,e,i))}return a.append(o),a}function Zy(e,t,n){let r=nv(n),i=L(`div`,`review-section-head`),a=L(`div`,`review-section-id`);a.append(L(`span`,`review-section-label`,e)),t&&a.append(L(`span`,`review-section-meaning`,t));let o=L(`div`,`review-section-stat`);return o.append(L(`span`,`review-stat-files`,`${r.files} file${r.files===1?``:`s`}`),L(`span`,`review-add`,`+${r.added}`),L(`span`,`review-del`,`-${r.removed}`)),i.append(a,o),i}function Qy(e,t,n){let r=`${t}:${e.path}`,i=Iv.has(r),a=L(`div`,`review-file`);a.dataset.path=e.path,e.oldPath&&(a.dataset.oldPath=e.oldPath),a.dataset.status=e.status,a.dataset.open=i?`true`:`false`;let o=L(`button`,`review-file-head`);o.type=`button`,o.setAttribute(`aria-expanded`,i?`true`:`false`);let s=L(`span`,`review-file-twisty`,i?`▾`:`▸`);s.setAttribute(`aria-hidden`,`true`);let c=L(`span`,`review-file-name`);c.append(L(`span`,`review-file-path`,e.path));let l=Q_(n?.hintsByOpenPath.get(e.path));if(l.length>0){let e=L(`span`,`review-file-hints`);e.append(...l),c.append(e)}o.append(s,c);let u=L(`span`,`review-file-counts`);if(e.binary&&u.append(L(`span`,`review-bin`,`bin`)),e.binary||u.append(L(`span`,`review-add`,`+${e.added}`),L(`span`,`review-del`,`-${e.removed}`)),o.append(u),o.addEventListener(`click`,()=>{let e=Iv.has(r);e&&Iv.delete(r),e||Iv.add(r),q()}),a.append(o),!i)return a;let d=L(`div`,`review-file-body`);if(e.binary)return d.append(L(`div`,`review-file-binary`,`Binary file not shown`)),a.append(d),a;let f=0,p=!1;for(let t of e.hunks){if(f>=xv&&!Lv.has(r)){p=!0;break}d.append(L(`div`,`review-hunk-head`,t.header));for(let e of t.lines){if(f>=xv&&!Lv.has(r)){p=!0;break}let t=L(`div`,`review-line review-line-${e.type}`),n=e.type===`add`?`+`:e.type===`del`?`-`:e.type===`meta`?`\\`:` `;t.append(L(`span`,`review-line-gutter`,n)),t.append(L(`span`,`review-line-text`,e.text)),d.append(t),f++}if(p)break}if(p){let e=L(`button`,`review-expand`,`Show the rest of this file`);e.type=`button`,e.addEventListener(`click`,()=>{Lv.add(r),q()}),d.append(e)}return a.append(d),a}function $y({id:e,label:t,shortcut:n,title:r,disabled:i=!1,danger:a=!1,onClick:o}){let s=L(`button`,a?`review-btn review-btn-danger`:`review-btn review-btn-primary`);return s.type=`button`,e&&(s.id=e),r&&(s.title=r),s.disabled=i,s.innerHTML=n?`${t} <kbd class="review-shortcut" aria-hidden="true">${n}</kbd>`:t,s.addEventListener(`click`,o),s}function eb(e,{status:t,reviewable:n,mergeAction:r,live:i,state:a,effectiveBase:o,primaryAction:s}){let c=L(`div`,`review-actions`),l=s===`resolve`;s===`merge`&&c.append($y({id:`review-merge-btn`,label:`Merge`,shortcut:Sv,title:lv(o,Sv),disabled:!r.isEnabled||Qv.has(e),onClick:()=>ky(e,a)})),l&&c.append($y({label:`Resolve`,shortcut:Cv,title:`Paste a resolve prompt into this session so the agent can finish the merge (${Cv})`,disabled:Sy(e),onClick:()=>Cy(e)}));let u=L(`div`,`review-action-controls`);if(u.append(c),!n||i)return c.childElementCount>0?u:null;let d=ty(`More review actions`,hr);if(d.classList.add(`review-more-button`),d.setAttribute(`aria-haspopup`,`menu`),d.setAttribute(`aria-expanded`,String(qv)),d.setAttribute(`aria-controls`,`review-more-menu`),d.addEventListener(`click`,()=>{qv=!qv,q(),(K?.querySelector(qv?`.review-more-menu button:not(:disabled)`:`.review-more-button`)??K?.querySelector(`.review-more-button`))?.focus()}),c.append(d),!qv)return u;let f=L(`div`,`review-more-menu`);if(f.id=`review-more-menu`,f.setAttribute(`role`,`menu`),f.setAttribute(`aria-label`,`More review actions`),n&&!i){let n=$y({label:`Discard worktree`,danger:!0,disabled:t===`merging`,onClick:()=>{qv=!1,q();let t=By(H.get(e),e);wr({title:`Discard worktree`,message:`Throw away the worktree changes for "${t}"? This cannot be undone.`,confirmLabel:`Discard`,danger:!0,onConfirm:()=>T({type:`discard-session-worktree`,id:e})})}});n.setAttribute(`role`,`menuitem`),f.append(n)}return u.append(f),u}var tb=160,nb=Object.freeze({Bash:`command`,Read:`file_path`,Edit:`file_path`,MultiEdit:`file_path`,Write:`file_path`,NotebookEdit:`notebook_path`,Grep:`pattern`,Glob:`pattern`,WebFetch:`url`,WebSearch:`query`,Task:`description`,Agent:`description`,Skill:`skill`});function rb(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=tb?t:`${t.slice(0,157)}...`}function ib(e,t){let n=nb[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?rb(r):``}var ab=5e3;function ob(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function sb(e,t){if(!e.toolUseId)return ob(e.text)??`context`;let n=t.get(e.toolUseId);return n?ib(n.name,n.input)||n.name:`expansion`}function cb(e){return e.kind!==`expansion`||e.toolUseId?!1:ob(e.text)!==null}function lb(e){return e.kind===`prompt`||e.kind===`session`||cb(e)}function ub(e){return new TextEncoder().encode(e).byteLength}function db(e){return e.kind===`prompt`||e.kind===`expansion`||e.kind===`thinking`||e.kind===`assistant`||e.kind===`notice`?e.text:e.kind===`tool_result`?e.content:e.kind===`raw`?e.line:e.kind===`tool_call`?JSON.stringify(e.input,null,2)??String(e.input??``):[`${e.vendor} ${e.vendorSessionId}`,e.transcriptPath,e.reason??``].filter(Boolean).join(`
163
+ `)}var fb={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`},pb=[{kind:`thinking`,label:`Thinking`},{kind:`tool_result`,label:`Tool result`},{kind:`raw`,label:`Raw`}];function mb(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:rb(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:rb(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:rb(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:rb(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:rb(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:sb(e,t)};if(e.kind===`tool_call`){let t=ib(e.name,e.input);return t?{prefix:`${e.name}: `,text:t}:{prefix:``,text:e.name}}return{prefix:`${t.get(e.toolUseId)?.name??`Tool`} result: `,text:`${ub(e.content)} bytes`}}function hb(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function gb(e,t){let n=mb(e,t),r=hb(e),i=e.kind===`tool_call`||e.kind===`tool_result`?`${n.prefix}${n.text}`:n.text,a=[],o=e.kind===`notice`?`muted`:`default`;if(e.kind===`tool_result`&&e.isError&&(o=`error`,a.push(`error`)),e.truncated===!0&&(o!==`error`&&(o=`muted`),a.push(`truncated`)),e.kind===`tool_result`){let n=t.get(e.toolUseId),r=n?e.ts-n.ts:NaN;Number.isFinite(r)&&r>=0&&a.push(r>1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`)}return{kind:e.kind,tag:fb[e.kind],text:`${r}${i}`,tone:o,badges:a}}function _b(e,t){return{record:e,...gb(e,t)}}function vb(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function yb(e,t){let n=vb(e);return!n||t.has(n)?null:n}function bb(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function xb(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function Sb(e,t){if(t.size!==0)for(let n of e.turns)for(let r=0;r<n.rows.length;r+=1){let i=n.rows[r],a=vb(i.record);a&&t.has(a)&&(n.rows[r]=_b(i.record,e.toolCallByUseId))}}function Cb(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function wb(e){if(e.startedAt===null)return 0;let t=e.head?.record.ts??e.startedAt;for(let n of e.rows)t=Math.max(t,n.record.ts);return Math.max(0,t-e.startedAt)}function Tb(e){let{rowCount:t,toolCallCount:n,errorCount:r,resultBytes:i}=e.metrics;return`${`${t} ${t===1?`row`:`rows`}`}, ${`${n} ${n===1?`tool`:`tools`}`}, ${`${r} ${r===1?`error`:`errors`}`}, ${Bt(i,`KB`)}, ${N(wb(e))}`}function Eb(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function Db(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=ub(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function Ob(e,t){for(let n of t)n.kind===`tool_call`&&e.toolCallByUseId.set(n.toolUseId,n);let n=[],r=e.turns[e.turns.length-1]??null;for(let i of t){let t=yb(i,e.toolCallByUseId);t&&bb(e.unresolvedToolUseCounts,t);let a=_b(i,e.toolCallByUseId);if(lb(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:Eb()},Db(r,a,1),e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:a,rows:[]});continue}r||(r={head:null,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:Eb()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),Db(r,a,1);let o=e.turns.length-1,s=n[n.length-1];s&&s.turnIndex===o?s.rows.push(a):n.push({turnIndex:o,isNewTurn:!1,head:null,rows:[a]})}return n}function kb(e,t){let n=Cb();Ob(n,t);let r=new Set;for(let[t,i]of n.toolCallByUseId)e.toolCallByUseId.has(t)||(e.toolCallByUseId.set(t,i),r.add(t));let i=new Set;for(let t of r)e.unresolvedToolUseCounts.delete(t)&&i.add(t);for(let[t,r]of n.unresolvedToolUseCounts)e.toolCallByUseId.has(t)||bb(e.unresolvedToolUseCounts,t,r);let a=n.turns[n.turns.length-1],o=e.turns[0],s=!!a&&!!o&&!o.head,c=s?a.head:null,l=s?a.rows:[];if(s){n.turns.pop();let e=a.startedAt,t=o.startedAt;e!==null&&(t===null||e<t)&&(o.startedAt=a.startedAt),o.head=c,o.rows=[...l,...o.rows],o.metrics={rowCount:a.metrics.rowCount+o.metrics.rowCount,toolCallCount:a.metrics.toolCallCount+o.metrics.toolCallCount,errorCount:a.metrics.errorCount+o.metrics.errorCount,resultBytes:a.metrics.resultBytes+o.metrics.resultBytes}}return e.turns=[...n.turns,...e.turns],Sb(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function Ab(e){return e.rows.length+ +!!e.head}function jb(e){let t=0;for(let n of e.turns)t+=Ab(n);return t}function Mb(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=vb(n.record);t&&xb(e.unresolvedToolUseCounts,t)}}function Nb(e,t){Mb(e,t.head?[t.head,...t.rows]:t.rows)}function Pb(e,t){let n=e.turns[0];if(!n)return 0;let r=Math.min(t,n.rows.length);if(r<=0)return 0;let i=n.rows.slice(0,r);Mb(e,i);for(let e of i)Db(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function Fb(e,t=ab){let n=jb(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=Ab(t),Nb(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:Pb(e,n-t)}}function Ib(e){let t=[],n=new Set;for(let r of e)r.id&&r.name&&!n.has(r.id)&&(n.add(r.id),t.push({id:r.id,label:r.name}));return t}function Lb(e,t,n,r=!0){return t&&e.some(e=>e.id===t)?t:n&&e.some(e=>e.id===n)?n:r?e[0]?.id??null:null}function Rb(e){return!e.selectedSessionId||!e.isPanelVisible||e.hasPendingRequest?null:e.hasLoadedOnce?{id:e.selectedSessionId,direction:`forward`,after:e.nextOffset}:{id:e.selectedSessionId,direction:`tail`,after:0,endingAt:`tail`}}function zb(e,t=ab){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function Bb(e,t=ab){return!zb(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function Vb(e){let{pendingRequest:t,resident:n,reply:r}=e;return!t||t.id!==r.id?`ignore`:!n||n.sessionId!==r.id?`stale`:r.reset||r.next<r.start?`reset`:t.direction===`tail`?n.hasLoadedOnce?`stale`:`seed`:t.direction===`earlier`?n.firstOffset===t.endingAt?r.next===t.endingAt?`prepend`:`reset`:`stale`:n.nextOffset===t.after?r.start===t.after?`append`:`reset`:`stale`}function Hb(e){return e.hasSelectionChanged||e.isRenderedTraceStale||!e.hasRenderedOnce}function Ub(e,t,n){return e!==0||t?null:n?.startedAt??null}function Wb(e,t){return Gb(e,t)?e.filter(e=>e!==t):[...e,t]}function Gb(e,t){return e.includes(t)}function Kb(e){return e?`No trace has been recorded for ${e.label}.`:`No sessions are available.`}var qb=1e4,Jb=null,Yb=null,Xb=[],Zb=null,Qb=null,J=null,$b=null,ex=!1,tx=null,nx=()=>!1,rx=new Set;function ix(e){for(let t of rx)t(e)}function ax(){$b&&=(clearTimeout($b.timeoutHandle),null)}function ox(){$b=null,tx=`The trace did not load within ${Math.round(qb/1e3)} s.`,ix({kind:`rebuild`})}function sx(e){ax(),ex=!1,tx=null,Zb=e,J=e?{sessionId:e,grouping:Cb(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,ix({kind:`selection-reset`})}function cx(e){let t=Lb(Xb,Qb,Zb,e);return Qb&&t===Qb&&(Qb=null),t!==Zb&&(sx(t),!0)}function lx(e){if(!Jb)return;let t=e.endingAt===void 0?{type:`session-trace`,id:e.id,after:e.after}:{type:`session-trace`,id:e.id,endingAt:e.endingAt};Jb(t)?$b={request:e,timeoutHandle:setTimeout(ox,qb)}:(tx=p,ix({kind:`header`}))}function ux(e=!1){if(!Jb)return;let t=Rb({selectedSessionId:Zb,isPanelVisible:e||nx(),hasPendingRequest:!!$b,hasLoadedOnce:J?.hasLoadedOnce??!1,nextOffset:J?.nextOffset??0});t&&lx(t)}function dx(){ex&&!$b&&(ex=!1,ux())}function fx(){if(!J)return;let e=Fb(J.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!J.hasDroppedEarliestRows;t&&(J.hasDroppedEarliestRows=!0),ix({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function px(e){J&&(ix({kind:`records-appended`,appends:Ob(J.grouping,e)}),fx())}function mx(e){J&&(ix({kind:`records-prepended`,prepend:kb(J.grouping,e)}),fx())}function hx(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||!Array.isArray(t.records)||typeof t.next!=`number`||typeof t.start!=`number`?null:{id:t.id,records:t.records,start:t.start,next:t.next,reset:t.reset===!0,path:typeof t.path==`string`?t.path:``}}function gx(){return{selectedSessionId:Zb,hasPendingRequest:!!$b,hasLoadedOnce:J?.hasLoadedOnce??!1,hasDroppedEarliestRows:J?.hasDroppedEarliestRows??!1,firstOffset:J?.firstOffset??0,residentRowCount:J?jb(J.grouping):0}}function _x(){return{sessionOptions:Xb,selectedSessionId:Zb,selectedTrace:J,pendingSessionId:$b?.request.id??null,traceFailureText:tx}}function vx(e){rx.add(e)}function yx(e){nx=e}function bx(){if(!Jb)return;let e=Bb(gx());e&&lx(e)}function xx(e){Xb.some(t=>t.id===e)&&e!==Zb&&(Qb=null,sx(e),ux(),ix({kind:`rebuild`}))}function Sx(){let e=cx(!0);return ux(!0),e}function Cx(e){Jb=e}function wx(e){Yb=e}function Tx(e){Qb=e,Yb?.()}function Ex(e){Xb=Ib(e);let t=cx(nx());t&&ux(),ix({kind:`sessions`,hasSelectionChanged:t})}function Dx(e){let t=hx(e);if(!t)return;let n=Vb({pendingRequest:$b?.request??null,resident:J?{sessionId:J.sessionId,firstOffset:J.firstOffset,nextOffset:J.nextOffset,hasLoadedOnce:J.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?dx():(ax(),tx&&(tx=null,ix({kind:`header`})),n===`stale`?dx():n===`reset`?(sx(t.id),J&&(J.filePath=t.path),ux(),ix({kind:`rebuild`}),dx()):J&&(J.filePath=t.path,n===`prepend`?(J.firstOffset=t.start,mx(t.records),dx()):(n===`seed`&&(J.hasLoadedOnce=!0,J.firstOffset=t.start),J.nextOffset=t.next,px(t.records),dx())))}function Ox(e){let t=e?.id;typeof t==`string`&&t===Zb&&nx()&&($b?ex=!0:ux())}function kx(e){let t=e?.id;if(typeof t!=`string`||$b?.request.id!==t)return!1;ax(),ex=!1;let n=e?.message;return tx=typeof n==`string`&&n?n:`The trace could not be read.`,ix({kind:`rebuild`}),!0}function Ax(e){ax(),ex=!1,tx=e?null:p,e?(ix({kind:`header`}),ux()):ix({kind:`rebuild`})}var jx=`Estimated list prices, not a bill.`,Mx=`Enable in Settings.`,Nx=80,Px=Object.freeze([{value:`7`,label:`Last 7 days`,days:7},{value:`30`,label:`Last 30 days`,days:30},{value:`90`,label:`Last 90 days`,days:90},{value:`all`,label:`All retained`,days:null}]),Fx=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Ix=/^(\d{4})-(\d{2})-(\d{2})$/,Lx=new Set([`day`,`model`,`label`]),Rx=new Set([`model`,`label`]);function zx(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function Bx(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function Vx(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${zx(String(Math.abs(t)))}`}function Hx(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.abs(e);if(t===0)return`$0.00`;let n=e<0?`-`:``;if(t<1e-4)return e<0?`above -$0.0001`:`<$0.0001`;if(t<.01)return`${n}$${t.toFixed(4)}`;let[r,i]=t.toFixed(2).split(`.`);return`${n}$${zx(r)}.${i}`}function Ux(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=e<0?`-`:``,n=Math.abs(e);if(n<1e3){let e=Math.round(n);return`${e===0?``:t}${e}`}return n<999950?`${t}${Bx((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${Bx((n/1e6).toFixed(2))}M`:`${t}${Bx((n/1e9).toFixed(2))}B`}function Wx(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${Bx(e.toFixed(1))}%`}function Gx(e){let t=Number(e?.costUSD);return Number.isFinite(t)&&t>0?`costUSD`:`tokens`}function Kx(e){return e===`costUSD`?`share of cost`:`share of tokens`}function qx(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function Jx(e){let t=Ix.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=Fx[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function Yx(e){let t=Xx(e);return t.length===0?``:t.length===1?Jx(t[0]):`${Jx(t[0])} to ${Jx(t[t.length-1])}`}function Xx(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>Ix.test(e)).sort()}function Zx(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:Qx(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function Qx(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=$x(e,n);return Ix.test(r)?r:$x(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function $x(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function eS(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:h(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function tS(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=Fx[n.getMonth()];return r?`${r} ${n.getDate()} ${gt(n)}`:`-`}function nS(e){if(!e||typeof e!=`object`)return[];let t=[];if(Number.isFinite(e.tokensPerMinute)){let n=Number.isFinite(e.tokensPerMinuteExCache)?`${Ux(e.tokensPerMinuteExCache)} excluding cache`:``;t.push({label:`tokens per min`,value:Ux(e.tokensPerMinute),sub:n})}return Number.isFinite(e.costPerHour)&&t.push({label:`cost per hour`,value:Hx(e.costPerHour),sub:``}),t}function rS(e){if(!e||typeof e!=`object`)return``;let t=[];Number.isFinite(e.projectedTokens)&&t.push(`${Ux(e.projectedTokens)} tokens`),Number.isFinite(e.projectedCostUSD)&&t.push(Hx(e.projectedCostUSD));let n=Number.isFinite(e.remainingMinutes)?`${eS(e.remainingMinutes)} left in this block`:``;if(t.length===0)return n;let r=`-> ${t.join(`, `)} by block end`;return n?`${r}, ${n}`:r}function iS(e,t=Date.now()){let n=Number(e?.startTs),r=Number(e?.endTs);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)return null;let i=(r-n)/6e4,a=Math.min(Math.max((t-n)/6e4,0),i);return{totalMinutes:i,elapsedMinutes:a,remainingMinutes:Math.max(i-a,0),pct:Math.round(a/i*100)}}function aS(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=Nx?`warn`:`ok`}function oS(e){let t=F(e?.max,null);return t===null||t<=0?null:t}function sS(e){let t=oS(e),n=F(e?.pct,null);return t===null||n===null?null:n*100}function cS(e,t){let n=oS(t),r=F(e?.projectedTokens,null);return n===null||r===null?null:r/n*100}function lS(e){let t=sS(e);return t===null?``:`${Math.round(t)}% of ${Ux(e?.max)} tokens, the largest completed block seen`}function uS(e,t){let n=cS(e,t);return n===null?``:n>=100?`On this burn rate the block ends past that reference, at ${Math.round(n)}% of it.`:`On this burn rate the block ends at ${Math.round(n)}% of that reference.`}var dS=Object.freeze([{key:`input`,label:`input`},{key:`output`,label:`output`},{key:`cacheCreate`,label:`cache write`},{key:`cacheRead`,label:`cache read`}]);function fS(e){let t=dS.map(t=>{let n=Number(e?.[t.key]);return{spec:t,tokens:Number.isFinite(n)&&n>0?n:0}}),n=t.reduce((e,t)=>e+t.tokens,0);return n<=0?[]:t.map(e=>{let t=qx(e.tokens,n)??0,r=Ux(e.tokens);return{key:e.spec.key,label:e.spec.label,value:r,pct:t,title:`${e.spec.label} ${r}, ${Wx(t)}`}})}var pS=Object.freeze({interactive:`Interactive`,"pr-review":`PR review`,"team-review":`PR reviews`,posthog:`PostHog`,"my-prs":`Keep mergeable`,workflows:`Workflows`,"change-map":`Change map`,visions:`Visions`,benchmark:`Benchmarks`,"agent-spawn":`Agent API`,"task-title":`Task titles`,other:`Other`}),mS=`Sessions spawned by Glimmervoid; terminal sessions count as other`,hS=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function gS(e){let t=me(e,``);return t?pS[t]||t:pS.other}function _S(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function vS(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function yS(e){return _S(e).some(e=>vS(e.lane))}var bS=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function xS(e,t,n){let r=xC(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function SS(e,t,n,r){if(!Array.isArray(t))return null;let i=t.filter(e=>e&&typeof e.lane==`string`),a=i.reduce((e,t)=>e+F(t.costUSD,0),0),o=i.reduce((e,t)=>e+F(t.tokens,0),0),s=i.filter(e=>vS(e.lane)).map(e=>({lane:String(e.lane),label:gS(e.lane),tokens:F(e.tokens,0),costUSD:F(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?qx(c,a):qx(l,o),d=xS(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:bS[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function CS(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:bC.map(e=>SS(e.key,r[e.key],t,n)).filter(e=>e!==null)}function wS(e){return e.planPct===null?``:`about ${Wx(e.planPct)} of plan`}function TS(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?Hx(e.costUSD):Ux(e.tokens)}`).join(`, `)}var ES=`team-review`;function DS(e){if(!Array.isArray(e?.byLane))return null;let t=_S(e).find(e=>e.lane===ES),n=F(t?.costUSD,0),r=F(t?.tokens,0),i=Gx(e?.totals),a=qx(i===`costUSD`?n:r,e?.totals?.[i]),o=a===null?``:`${Wx(a)} of range ${i===`costUSD`?`cost`:`tokens`}`,s=[Hx(n),o,OS(t?.sessions)].filter(Boolean).join(`, `);return{label:gS(ES),value:Ux(r),sub:s}}function OS(e){let t=F(e,null);return t===null||t<=0?``:`${Vx(t)} ${t===1?`session`:`sessions`}`}function kS(e){let t=e?.rtk;return!t||typeof t!=`object`||t.available!==!0?null:t}function AS(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function jS(e){return kS(e)!==null||AS(e)!==null}function MS(e){let t=kS(e);if(!t)return null;let n=F(t.commands,0),r=n===1?`command`:`commands`;return{value:`${Ux(F(t.savedTokens,0))} tokens`,sub:`${Wx(F(t.savingsPct,0))} avg across ${Vx(n)} ${r}`}}function NS(e){let t=AS(e);if(!t)return null;let n=Ux(F(t.cacheReadTokens,0)),r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e),i=`${n} cache read tokens`;if(r.length===0)return{value:Hx(F(t.savedUSD,0)),sub:i};let a=r.length===1?`model`:`models`;return{value:Hx(F(t.savedUSD,0)),sub:`${i}, a floor (${r.length} unpriced ${a})`}}var PS=90;function FS(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&F(e.budgetUsd,null)!==null):[]}function IS(e){return e===`monthly`?`this month`:`today`}function LS(e){return`${Hx(F(e?.spentUsd,0))} of ${Hx(F(e?.budgetUsd,0))}`}function RS(e){let t=F(e?.pct,null);return t===null?0:t}function zS(e){return`${IS(e?.scope)} spend against budget`}var BS=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function VS(e){let t=Ix.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function HS(e){let t=VS(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),P(t)}function US(e){let t=Ix.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function WS(e){return{key:e,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0,days:0,sources:new Set,vendorSet:new Set,modelByName:new Map}}function GS(e,t){e.tokens+=F(t?.tokens,0),e.costUSD+=F(t?.costUSD,0),e.input+=F(t?.input,0),e.output+=F(t?.output,0),e.cacheCreate+=F(t?.cacheCreate,0),e.cacheRead+=F(t?.cacheRead,0),e.days+=1,e.sources.add(t?.source===`history`?`history`:`live`);let n=Array.isArray(t?.vendors)?t.vendors:[];for(let t of n)e.vendorSet.add(t);let r=t?.models||[];for(let t of r){t?.vendor&&e.vendorSet.add(t.vendor);let n=qC(t),r=e.modelByName.get(n)||{key:n,model:t?.model??n,vendor:t?.vendor,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0};r.tokens+=F(t?.tokens,0),r.costUSD+=F(t?.costUSD,0),r.input+=F(t?.input,0),r.output+=F(t?.output,0),r.cacheCreate+=F(t?.cacheCreate,0),r.cacheRead+=F(t?.cacheRead,0),e.modelByName.set(n,r)}}function KS(e){let{modelByName:t,sources:n,vendorSet:r,...i}=e,a={...i};return a.day=e.key,a.models=Array.from(t.values()).sort((e,t)=>t.tokens-e.tokens),a.source=n.has(`live`)?`live`:`history`,a.vendors=Array.from(r).sort(),a}function qS(e,t){let n=new Map,r=Array.isArray(e)?e:[];for(let e of r){let r=t(e?.day);if(!r)continue;let i=n.get(r)||WS(r);GS(i,e),n.set(r,i)}return Array.from(n.values()).map(KS)}function JS(e){return qS(e,HS)}function YS(e){return qS(e,US)}function XS(e,t){return t===`week`?JS(e):t===`month`?YS(e):Array.isArray(e)?[...e]:[]}var ZS=/^(\d{4})-(\d{2})$/;function QS(e,t){if(t===`month`){let t=ZS.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=Fx[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=Jx(e);return t===`-`?t:`week of ${t}`}return Jx(e)}function $S(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var eC=16,tC=Object.freeze([.05,.25,.5,.75]),nC=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function rC(e,t){let n=F(e,0),r=F(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<tC.length;e+=1)i>=tC[e]&&(a=e+1);return a}function iC(e,{weeks:t=eC,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>Ix.test(String(e?.day??``))),i=new Map(r.map(e=>[String(e.day),e])),a=n instanceof Date?n:new Date(n),o=Number.isFinite(a.getTime())?a:new Date,s=typeof n==`string`&&Ix.test(n)?n:P(o),c=VS(HS(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=P(l),d=[],f=0,p=null;for(let e of r){let t=String(e.day);(p===null||t<p)&&(p=t),!(t<u||t>s)&&(f=Math.max(f,F(e.tokens,0)))}for(let e=0;e<t;e+=1)for(let t=0;t<7;t+=1){let n=new Date(l.getFullYear(),l.getMonth(),l.getDate()+e*7+t,12),r=P(n),a=i.get(r)||null,o=r>s,c=p!==null&&r<p;d.push({day:r,week:e,weekday:t,tokens:F(a?.tokens,0),costUSD:F(a?.costUSD,0),source:a?.source===`history`?`history`:a?`live`:null,noData:o||c||!a&&p===null,tone:rC(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function aC(e){let t=Jx(e?.day);if(e?.noData)return`${t}: no data`;let n=F(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${Ux(n)} tokens, ${Hx(F(e?.costUSD,0))}`}function oC(e){if(!e)return``;let t=F(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${dC(e.ratio)} the ${n} average: ${Hx(e.todayUsd)} against ${Hx(e.baselineUsd)}.`}function sC(e){return e?`This block is burning ${dC(e.ratio)} the usual rate: ${Ux(e.current)} tokens per minute against ${Ux(e.baseline)}.`:``}function cC(e){return[oC(e?.daily),sC(e?.burn)].filter(Boolean).join(` `)}function lC(e){return e?.daily||e?.burn?`warn`:`ok`}function uC(e){return!!(e?.daily||e?.burn)}function dC(e){let t=F(e,null);return t===null?`-`:`${Bx(t.toFixed(1))}x`}var fC=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`});function pC(e){let t=me(e,``);return t?fC[t]||t:fC.claude}function mC(e,t){return gC(t)?pC(e?.vendor):``}function hC(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>F(t[n]?.tokens,0)-F(t[e]?.tokens,0)).map(e=>({vendor:e,label:pC(e),tokens:F(t[e]?.tokens,0),costUSD:F(t[e]?.costUSD,0)}))}function gC(e){let t=e?.byVendor;if(!t||typeof t!=`object`)return!1;let n=Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`);return n.length>1||n.length===1&&n[0]!==`claude`}var _C=`Claude only`;function vC(e){return gC(e)?_C:``}var yC=36e5,bC=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]);function xC(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=F(n.pct,null),i=F(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}var SC=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`}]);function CC(e){return e?.vendor===`codex`?`codex`:`claude`}function wC(e,t){let n=`official, from ${SC.filter(({vendor:t})=>e.includes(t)).map(({label:e})=>e).join(` and `)}`,r=e.length===1&&e[0]===`claude`?vC(t):``;return r?`${n}, ${r}`:n}function TC(e){return bC.some(t=>xC(e,t.key)!==null)}function EC(e){return xC(e,`fiveHour`)?.pct??null}function DC(e){return e===`estimated`?`estimated from the largest completed block`:``}function OC(e,t=null){let n=EC(t);if(n!==null)return aS(n);let r=aS(sS(e?.tokenLimit));return r===`ok`?aS(cS(e?.activeBlock?.projection,e?.tokenLimit)):r}function kC(e,t=null){let n=[],r=OC(e,t);r!==`ok`&&n.push(`block:${r}`),e?.anomaly?.daily&&n.push(`anomaly:daily`),e?.anomaly?.burn&&n.push(`anomaly:burn`);for(let t of FS(e)){let e=RS(t);if(e<PS)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return Ut(n)}function AC(e){let t=F(e?.pct,null);return t===null?`-`:`${Wx(t)} used`}function jC(e,t=Date.now()){let n=F(e,null);if(n===null||n<=0)return``;let r=(n-t)/6e4;return r<=0?`resetting now`:`resets in ${eS(r)}`}function MC(e,t=Date.now()){let n=F(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function NC(e,t=Date.now()){let n=F(e,null);return n===null||n<=0||t-n>yC}function PC(e,t=Date.now()){if(!NC(e,t))return``;let n=MC(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function FC(e,t=``){let n=e?.source;if(n===`fetched`){let e=me(t,``);return e?`Prices fetched from the public model price table, ${e}.`:`Prices fetched from the public model price table.`}if(n===`cache`){let e=me(t,``);return e?`Prices from the cached public model price table, ${e}.`:`Prices from the cached public model price table.`}return n===`snapshot`?`Prices from the price table bundled with this Glimmervoid build.`:n===`unavailable`?`Model prices could not be loaded, so every cost below counts as zero.`:`Pricing source not reported yet.`}function IC(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function LC(e){let t=(Array.isArray(e)?e:[]).map(e=>String(e)).filter(e=>e);if(t.length===0)return``;let n=t.length===1?`model`:`models`;return`No price for ${t.length} ${n}: ${t.join(`, `)}. Their cost counts as zero here.`}function RC(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function zC(e){if(!e||typeof e!=`object`)return``;let t=[],n=RC(e.dirs);if(n!==null&&t.push(`${Vx(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${Vx(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${Vx(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${Vx(e.lastScanMs)}ms`),t.length===0)return``;let r=`Scanned ${t.join(`, `)}.`;return e.partial===!0?`${r} Some files were skipped this pass and will be re-read on the next one.`:r}function BC(e){return me(e?.error,``)}function VC(e){let t=me(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function HC(e){return BC(e)!==``}function UC(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}function WC(e){let t=String(e??``).trim();if(!t)return``;let n=t.split(/[\\/]+/).filter(e=>e);return n.length===0?t:n[n.length-1]}function GC(e){return typeof e?.id==`string`&&e.id!==``}function KC(e){let t=me(e?.label,``);return GC(e)&&t?t:WC(e?.project)||t||`unknown project`}function qC(e){let t=typeof e==`string`?e:e?.model;return me(t,`unknown model`)}function JC(e){return String(e?.day??``)}function YC(e,t,n){if(!Lx.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?JC(e):n(e)}function XC(e,t,n,r=KC){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=YC(e,t,r),o=YC(n,t,r);if(typeof i==`string`||typeof o==`string`)return a*String(i).localeCompare(String(o));if(i!==o)return a*(i-o);let s=Number(e?.tokens),c=Number(n?.tokens),l=Number.isFinite(s)?s:0,u=Number.isFinite(c)?c:0;return l===u?r(e).localeCompare(r(n)):u-l})}function ZC(e){return Rx.has(e)?`asc`:`desc`}function QC(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:ZC(t)}}function $C(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var ew=Object.freeze({key:`lastTs`,dir:`desc`}),tw=Object.freeze({key:`tokens`,dir:`desc`}),nw=Object.freeze({key:`day`,dir:`desc`});function rw(e,t=ew){return XC(e,t.key,t.dir,KC)}function iw(e,t,n=10){if(!Array.isArray(e))return{rows:[],hiddenCount:0};let r=Number.isFinite(n)?Math.max(0,Math.floor(n)):10;return t||e.length<=r?{rows:e,hiddenCount:0}:{rows:e.slice(0,r),hiddenCount:e.length-r}}function aw(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${Vx(t)} hidden`}function ow(e,t=tw){return XC(e,t.key,t.dir,qC)}function sw(e,t=nw){return XC(e,t.key,t.dir,JC)}function cw(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function lw(e,t=8){return(Array.isArray(e)?e:[]).filter(e=>e&&e.isGap!==!0).sort((e,t)=>(Number(t?.startTs)||0)-(Number(e?.startTs)||0)).slice(0,Math.max(0,t)).map(e=>({startTs:Number(e.startTs),tokens:typeof e.tokens==`number`&&Number.isFinite(e.tokens)?e.tokens:0,costUSD:typeof e.costUSD==`number`&&Number.isFinite(e.costUSD)?e.costUSD:0,isActive:e.isActive===!0}))}function uw(e){let t=F(e?.officialCostUSD,null);if(t!==null&&t>0)return{costUSD:t,source:`official`};let n=F(e?.costUSD,null);return n!==null&&n>0?{costUSD:n,source:`estimated`}:{costUSD:null,source:null}}function dw(e){let t=Number(e?.tokens);if(!Number.isFinite(t)||t<=0)return``;let{costUSD:n}=uw(e);return n===null?Ux(t):`${Ux(t)} ${Hx(n)}`}function fw(e){let{source:t}=uw(e);return t===`official`?`Tokens counted from the transcript; cost reported by Claude Code for this conversation`:`Tokens and estimated API list-price cost for this conversation`}function pw(e,t){return t===z.RUNNING?e===`restart-fresh`?{title:`Restart fresh`,message:`This agent is mid-turn. A fresh restart ends this conversation and starts a new one. Restart anyway?`,confirmLabel:`Restart fresh`,danger:!0}:e===`restart-into`?{title:`Restart`,message:`This agent is mid-turn. Restarting interrupts the current turn and switches to the earlier conversation you picked. Restart anyway?`,confirmLabel:`Restart`,danger:!0}:{title:`Restart`,message:`This agent is mid-turn. Restarting interrupts the current turn and keeps this conversation. Restart anyway?`,confirmLabel:`Restart`,danger:!1}:null}function mw(e,t,n,r){let i=it.includes(t)?`force-restart`:`restart`;return e===`restart-fresh`?{type:i,id:n,fresh:!0}:e===`restart-into`?{type:i,id:n,conversationId:r}:{type:i,id:n}}function hw(e,t,n,r=``){let i=()=>n.send(mw(e,n.readState(),t,r)),a=pw(e,n.readState());a?n.confirm({...a,onConfirm:i}):i()}var gw=`DORMANT`;function _w(e){return e?D(Date.now()-e,{rounding:`round`,wording:`compact`,suffix:` ago`,justNowBelowSeconds:60}):``}function vw(e){return[e.worktreeName,e.gitBranch?e.gitBranch.replace(/^refs\/heads\//,``):null,_w(e.mtime)].filter(Boolean).join(` · `)}function yw(e,t){let n=L(`button`,`resume-item`);return n.type=`button`,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,`false`),n.innerHTML=`<span class="resume-item-title">${G(e)}</span><span class="resume-item-meta">${G(t)}</span>`,n}async function bw(e,t,n){if(t.kind===`this`)return!0;let r=t.kind===`earlier`?t.conversationId:``,i=await cr(`resume-conversation`,{id:e,conversationId:r},n);return i?i.type===`resume-conversation-ack`&&i.ok?!0:(n.show(`error`,i.type===`error`?i.message:`The conversation was not changed.`),!1):!1}var xw={this:`restart`,fresh:`restart-fresh`,earlier:`restart-into`};function Sw(e,t,n,r){let i=n.kind===`earlier`?n.conversationId:``;hw(xw[n.kind],t,{readState:r,send:t=>{ol(e,t)},confirm:wr},i)}function Cw(e,{readState:t,canListEarlier:n}){let{overlay:r,dialog:i,close:a,actions:o,btnCancel:s}=Tr({title:`Restart`,dialogClass:`dialog resume-dialog`}),c=L(`p`,`dialog-message`,n?`Restart into this conversation, a fresh one, or an earlier one from this repo (any worktree).`:`Restart into this conversation or a fresh one.`),l=L(`div`,`resume-list`);l.setAttribute(`role`,`listbox`),l.setAttribute(`aria-label`,`Conversation to restart into`);let u=L(`button`,`btn-dialog btn-dialog-confirm`,`Restart`);u.type=`button`,o.append(u);let d=pr(`dialog-error`);i.append(c,l,d.element,o);let f={kind:`this`};function p(e,t){for(let e of l.querySelectorAll(`.resume-item`))e.classList.remove(`resume-item-current`),e.setAttribute(`aria-selected`,`false`);e.classList.add(`resume-item-current`),e.setAttribute(`aria-selected`,`true`),f=t}function m(e,t,n){let r=yw(t,n);return r.addEventListener(`click`,()=>p(r,e)),l.append(r),r}p(m({kind:`this`},`This conversation`,`Keeps the current conversation`),{kind:`this`}),m({kind:`fresh`},`Fresh conversation`,`Ends this conversation and starts a new one`);async function h(t,n){i.dataset.applying=``;let r=await bw(e,n,d);delete i.dataset.applying,r&&(a(),ol(t,{type:`start-session`,id:e}))}function g(){if(i.dataset.applying!==void 0)return;let n=H.get(e);n?t()===gw?h(n,f):(a(),Sw(n,e,f,t)):a()}if(s.addEventListener(`click`,a),u.addEventListener(`click`,g),requestAnimationFrame(()=>u.focus()),!n)return;let _=L(`div`,`resume-empty`,`Loading earlier conversations...`);l.append(_),S(`list-conversations`,{id:e},{timeoutMs:U}).then(e=>{if(!r.isConnected)return;if(e.error){_.textContent=`Could not list earlier conversations: ${e.error}`;return}let t=e.type===`conversations`?e.current??null:null,n=(e.type===`conversations`?e.conversations:[]).filter(e=>e.id!==t);if(n.length===0)_.textContent=`No earlier conversations found for this repo.`;else{_.remove();for(let e of n)m({kind:`earlier`,conversationId:e.id},e.title||e.id,vw(e))}}).catch(e=>{r.isConnected&&(_.textContent=`Could not list earlier conversations: ${br(e,U)}`)})}var ww=e=>e==null?``:String(e),Tw=e=>it.includes(e),Ew=e=>xt.includes(e),Dw=!1;function Ow(e){return Dw&&dd(e.agent)&&e.card.dataset.ephemeral===void 0}function kw(e){return Ow(e)&&e.isConversationViewOn&&e.isBorrowed}function Aw(e){e.btnConversationView.classList.toggle(`visible`,Ow(e)),e.btnConversationView.setAttribute(`aria-checked`,String(e.isConversationViewOn))}function jw(e){Dw=e;for(let t of H.values())!e&&t.face===`conversation`&&t._showTerminalFace?.(),Lw(t)}function Mw(e){let t=B(e);return!t||!kw(t)?!1:(t.face=`conversation`,t.card.dataset.face=`conversation`,t.termWrap.hidden=!0,t.planFace.hide(),t.conversationFace.show(V(e)),Lw(t),Nh(t,V(e)),!0)}function Nw(e,t){let n=B(e);if(!n)return;let r=n.isConversationViewOn;n.hasConversationBridge=t.hasConversationBridge,n.conversationApproval=t.conversationApproval,n.isConversationViewOn=t.isConversationViewOn,Lw(n),n.conversationFace.refresh(),r!==t.isConversationViewOn&&(t.isConversationViewOn?Mw(e):n.face===`conversation`&&n._showTerminalFace?.())}function Pw(e){return B(e.id)?.conversationFace.applyTraceResponse(e)===!0}function Fw(e){B(e.id)?.conversationFace.applyTraceError(e)}function Iw(e){B(e)?.conversationFace.applyTraceChanged(V(e))}function Lw(e){Aw(e);let t=e.currentState;e.btnRestart.classList.toggle(`visible`,Tw(t)||Ew(t)||t===z.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,dl()),e.btnPlan.classList.toggle(`visible`,pc(e)!==`hidden`),e.btnRemove.classList.add(`visible`)}function Rw(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function zw(e,t){Dl(e.taskTitleEl,()=>Al(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),Nl(e,t)}),e.nameEl.addEventListener(`click`,()=>{Ml(e.nameEl)||ju(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),Nl(e,t))}),e.btnRestart.addEventListener(`click`,()=>{Rw(e),Cw(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0})}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{Rw(e),Pi(t)}),e.btnTrace.addEventListener(`click`,()=>{Rw(e),Tx(t)}),e.btnDocs.addEventListener(`click`,()=>{Rw(e),Cs(t)}),e.btnConversationView.addEventListener(`click`,()=>{Rw(e),ol(e,{type:`set-session-conversation-view`,id:t,isOn:!e.isConversationViewOn})}),e.btnGuardrails.addEventListener(`click`,()=>{Rw(e),e.btnSessionMenu.focus();let n=n=>()=>{ol(e,{type:`set-session-guardrails`,id:t,isOn:n})};e.card.dataset.guarded===void 0?wr({title:`Restore guardrails`,message:`This session restarts with guardrails on, interrupting any turn in progress.`,confirmLabel:`Restore guardrails`,danger:!1,onConfirm:n(!0)}):wr({title:`Release guardrails`,message:`This session restarts without guardrails, interrupting any turn in progress. It can then read, write and reach anything your account can, including credentials and Glimmervoid itself.`,confirmLabel:`Release guardrails`,danger:!0,onConfirm:n(!1)})}),e.btnPlan.addEventListener(`click`,()=>{let n=pc(e);n!==`hidden`&&(n===`face`?Yw(t):location.hash=pa(t))}),e.btnRemove.addEventListener(`click`,()=>{Rw(e),Ku(t)}),e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation();for(let[,t]of H)t!==e&&Rw(t);let n=e.sessionMenu.classList.toggle(`open`);e.btnSessionMenu.setAttribute(`aria-expanded`,String(n))});function n(t){if(nl(t)){t.preventDefault(),t.stopPropagation();for(let[,t]of H)t!==e&&Rw(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`),rl([...e.sessionMenu.querySelectorAll(`.popup-menu-item.visible`)],t)}}e.btnSessionMenu.addEventListener(`keydown`,n),e.sessionMenu.addEventListener(`keydown`,n),document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e.sessionMenu.classList.contains(`open`)&&(t.preventDefault(),Rw(e),e.btnSessionMenu.focus())},{signal:e.abortController.signal}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;!e.sessionMenu.contains(n)&&n!==e.btnSessionMenu&&Rw(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),Bl(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&Vl(e)},{signal:e.abortController.signal})}function Bw(e,t,n){let r=B(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&kl(e,r.taskTitle)}}function Vw(e){return typeof e==`string`&&H.has(e)}function Hw(){return H.size}function Uw(e){let t=e||{};t.cursorBlink!=null&&uh(t.cursorBlink),t.debugMode!=null&&(ll(t.debugMode),Jg(t.debugMode));for(let[,e]of H)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function Ww(){Zd(H.values(),$d())}function Gw(){let e=Ic(Pc([...H.values()].map(e=>({state:e.currentState,unseenOutcome:e.unseenOutcome}))));document.title=e>0?`(${e}) Glimmervoid`:`Glimmervoid`}function Kw(e,t,n,r={}){if(!rn)return;let i=V(e),a=ww(n)||z.DORMANT,o=wl(i,ww(t),a,r),s=a===z.DORMANT;rn.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),c.conversationFace.hide(),Lw(c),mg(c,i)}function u(){Mw(i)||l()}let d=new AbortController,f=B_({signal:d.signal,requestPlan:(e,t,n)=>T({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>T({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:u,sendDecision:(e,t)=>T({type:`plan-decision`,id:e,...t}),reportProblem:e=>CT(i,e)}),p=Ag({signal:d.signal,sendControl:e=>T(e),showTerminal:l});return c={term:null,fitAddon:null,webglAddon:null,needsWebGLReload:!1,webglAttachedWithoutLayout:!1,dataWs:null,card:o.card,nameEl:o.nameEl,taskTitleEl:o.taskTitleEl,taskTitle:r.taskTitle??null,taskTitleIsCustom:r.taskTitleIsCustom??!1,path:ww(r.path),ownerId:r.ownerId??null,stateSince:typeof r.stateSince==`number`&&Number.isFinite(r.stateSince)?r.stateSince:Date.now(),sessionMenu:o.sessionMenu,termWrap:o.termWrap,btnDebug:o.btnDebug,btnRestart:o.btnRestart,btnSessionMenu:o.btnSessionMenu,btnWorkspaceRepos:o.btnWorkspaceRepos,btnConversationView:o.btnConversationView,btnGuardrails:o.btnGuardrails,btnTrace:o.btnTrace,btnPlan:o.btnPlan,btnDocs:o.btnDocs,btnRemove:o.btnRemove,debugOverlay:null,debugOpen:!1,abortController:d,currentState:a,face:`terminal`,isBorrowed:!1,hasPlan:!1,pendingPromptKind:null,planReviewState:{reviews:[]},planFace:f,conversationFace:p,conversationApproval:null,hasConversationBridge:!1,isConversationViewOn:!1},c._ensureTerminalReady=()=>mg(c,i),c._showTerminalFace=l,c._showPreferredFace=()=>{qw(c)===`plan`?Yw(i):Mw(i)||l()},c._setBorrowed=e=>{c.isBorrowed=e,Lw(c)},o.card.append(f.el,p.el),H.set(i,c),zw(c,i),Lw(c),c.btnDocs.classList.toggle(`visible`,us(i)),a===z.RUNNING&&Qt(c,!0),s||dg(c,i),Gw(),c}function qw(e){let t=e.planReviewState.reviews.some(e=>e.state===`open`),n=e.planReviewState.reviews.some(d_);return fc({hasPlan:e.hasPlan,pendingPromptKind:e.pendingPromptKind,hasOpenReview:t,hasApprovedReview:n})}function Jw(e){let t=B(e);return!t?.isBorrowed||qw(t)!==`plan`?!1:Yw(e)}function Yw(e){let t=B(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.conversationFace.hide(),t.planFace.show(V(e)),Lw(t),Nh(t,V(e)),!0)}function Xw(e,t){let n=B(e);n&&(n.hasPlan=t===!0,Lw(n),Jw(e))}function Zw(e){let t=B(e.id);t&&(t.planReviewState=O_(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),Lw(t),Jw(e.id))}function Qw(e){let t=B(e.id);t&&t.planFace.update({draft:e})}function $w(e){let t=B(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),Lw(t))}function eT(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=B(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function tT(e){for(let[,t]of H)t.planFace.update({isConnected:e})}function nT(e,t){let n=B(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function rT(e,t){let n=B(e);if(!n)return;n.agent=typeof t==`string`?t:null,Lw(n);let r=fi(t);sT(n,`.agent-badge`,`agent`,{on:r!==``,value:r,text:r})}function iT(e,t){let n=B(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function aT(e,t,n){let r=B(e);r&&(oT(r.card,`guarded`,t),oT(r.card,`guardrailsReleased`,n),Tl(r.btnGuardrails,r.card))}function oT(e,t,n){n?e.dataset[t]=``:delete e.dataset[t]}function sT(e,t,n,r){let{on:i,value:a=``,text:o,title:s}=r,c=e.card.querySelector(t);if(i)e.card.dataset[n]=a,c&&(o!==void 0&&(c.textContent=o),s!==void 0&&(c.title=s));else{if(delete e.card.dataset[n],!c)return;o!==void 0&&(c.textContent=``),s!==void 0&&c.removeAttribute(`title`)}}function cT(e,t,n=!1){let r=B(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=_t(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function lT(e,t){let n=B(e);if(!n)return;let r=dw(t);sT(n,`.usage-badge`,`usage`,{on:!!r,text:r||``,title:r?fw(t):void 0})}function uT(e,t,n){return t?{on:!0,value:`compacting`,title:`Context compaction in progress`,text:`compacting`}:e?{on:!0,value:ww(e),title:`Waiting on a permission or input prompt`,text:dc(ww(e))}:n?{on:!0,value:`memory`,title:`Held until Glimmervoid has enough free memory to start it`,text:`Waiting for memory`}:{on:!1,title:``,text:``}}function dT(e,t,n=!1,r=!1){let i=B(e);i&&(i.pendingPromptKind=typeof t==`string`?t:null,sT(i,`.prompt-badge`,`prompt`,uT(t,n,r)),i.conversationFace.refresh(),!Jw(e)&&(typeof t!=`string`||t===``)&&i.face===`terminal`&&Mw(e))}function fT(e,t){let n=B(e);n&&(n.unseenOutcome=t??null)}function pT(e){return e?`sleeping until ~${gt(new Date(e))}`:`scheduled`}function mT(e,t){let n=B(e);n&&sT(n,`.wakeup-badge`,`wakeup`,{on:!!t,value:t?.kind||`wakeup`,text:pT(t?.at),title:t?.reason?`Scheduled revival: ${t.reason}`:`Scheduled revival pending`})}function hT(e,t){let n=B(e);if(!n)return;let r=Array.isArray(t.findings)?t.findings:[],i=t.filesFixed||0,a=null,o=0;!t.skipped&&t.mode===`fix`&&i>0&&(a=`fixed`,o=i),!t.skipped&&t.mode===`report`&&r.length>0&&(a=`flagged`,o=new Set(r.map(e=>e.file)).size);let s={};for(let e of r)s[e.rule]=(s[e.rule]||0)+(e.count||0);let c=Object.keys(s).map(e=>`${e}: ${s[e]}`).join(`, `),l=a===`fixed`?`auto-fixed`:`flagged`;sT(n,`.post-turn-badge`,`pt`,{on:!!a,value:a||void 0,text:`${a===`fixed`?`✓`:`⚠`} ${o}`,title:`Post-turn ${l} ${o} file(s)${c?` (${c})`:``}`})}function gT(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function _T(e,t,n=null){let r=B(e),i=ww(t)||`none`;r&&gT(r.card,i),sy(V(e),i,ww(n)||null)}function vT(e,t,n=null){let r=B(e),i=ww(t)||`none`;r&&gT(r.card,i),ly(V(e),i,ww(n)||null)}function yT(e,t){uy(V(e),t)}function bT(e,t){let n=B(e);if(!n)return;let r=ww(t);n.card.dataset.session=r,n.nameEl.textContent=r}function xT(e){let t=B(e);t&&(Vl(t),H.delete(V(e)),R_(V(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),ig(t,V(e)),Jm(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),Gw())}function ST(e,t,n){if(!t||!e.term)return;let r=n===z.DONE?`Session complete`:`Session failed`,i=n===z.DONE?`\x1B[34m`:`\x1B[31m`;e.term.write(`\r\n\r\n\x1b[2m${i} ${r}\x1b[0m\r\n\r\n\x1b[2m Open the session actions menu and choose Restart to start a new session.\x1b[0m\r\n`)}function CT(e,t){let n=B(e);n?al(n).show(`error`,t):_r({source:`Session`,sessionId:typeof e==`string`?e:void 0,message:t})}function wT(e,t){let n=B(e);if(!n)return;let r=n.card.querySelector(`:scope > .session-failure-reason`);if(!(n.currentState===z.FAILED&&t)){r?.remove();return}let i=r??L(`p`,`session-failure-reason`);i.setAttribute(`role`,`status`),i.textContent=t,r||n.termWrap.before(i)}function TT(e,t){e.term&&(t===z.DONE||t===z.FAILED)&&(e.term.clear(),e.term.reset())}function ET(e){let t=H.get(e);t&&Dc({state:t.currentState,unseenOutcome:t.unseenOutcome})&&document.visibilityState===`visible`&&(Ud()||document.hasFocus())&&T({type:`dismiss`,id:e,expectedState:t.currentState})}function DT(e,t,n){let r=document.activeElement;return Ou({previousState:t,nextState:n,isPhoneLayout:Ud(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}function OT(e,t,n,r=``){let i=B(e);if(!i)return;let a=ww(t),o=i.currentState;i.currentState=a,a!==z.RUNNING&&(i.awaitingBackgroundTasks=!1),i.conversationFace.refresh(),a!==o&&(i.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),Qt(i,a===z.RUNNING)),o===z.DORMANT&&a!==z.DORMANT&&dg(i,V(e)),hc({state:a})===`resting`&&Oa(V(e)),i.card.dataset.state=a,i.card.toggleAttribute(`data-monitoring`,_t(a,i.awaitingBackgroundTasks)),Lw(i),(a===z.WAITING&&o!==z.WAITING||a===z.COMPLETE&&o!==z.COMPLETE)&&!Ju(r)&&gn()&&Cf(Bn()),DT(i,o,a)&&T({type:`dismiss`,id:V(e),expectedState:z.COMPLETE});let s=a===z.DONE||a===z.FAILED,c=o!==z.DONE&&o!==z.FAILED&&o!==z.INITIALIZING;s&&c&&(i.card.classList.remove(`completion-flash`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.card.classList.add(`completion-flash`),i.card.addEventListener(`animationend`,()=>i.card.classList.remove(`completion-flash`),{once:!0})})}),gn()&&Cf(Bn())),(a===z.DONE||a===z.FAILED)&&ST(i,c,a),a===z.INITIALIZING&&TT(i,o),Gw()}var kT=`(no path)`;function AT(e){if(!e)return kT;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||`(no path)`}function jT(e,t,n){let r=Array.isArray(e)?e:[],i=new Map;for(let e of r){let n=t(e),r=n?String(n):kT,a=i.get(r);a||(a={key:r,label:r===`(no path)`?kT:AT(r),title:r,rows:[]},i.set(r,a)),a.rows.push(e)}if(n)for(let e of n){if(!e)continue;let t=String(e);t===`(no path)`||i.has(t)||i.set(t,{key:t,label:AT(t),title:t,rows:[]})}let a=[...i.values()];return a.sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0,sensitivity:`base`})||e.key.localeCompare(t.key)),{flat:i.size<=1,order:a.map(e=>e.key),groups:a}}function MT(e,t){if(!e||!Array.isArray(e.groups))return[];let n=t||new Set,r=[];if(e.flat){for(let t of e.groups)for(let e of t.rows)r.push(e.id);return r}let i=new Map(e.groups.map(e=>[e.key,e]));for(let t of e.order){if(n.has(t))continue;let e=i.get(t);if(e)for(let t of e.rows)r.push(t.id)}return r}function NT({onAdd:e,onForget:t}){let n=L(`div`,`session-group-header`),r=L(`span`,`session-group-label`),i=L(`span`,`session-group-count`),a=L(`span`,`session-group-rule`);a.setAttribute(`aria-hidden`,`true`);let o=L(`button`,`session-group-add`,`+`);o.type=`button`,o.addEventListener(`click`,()=>e(n.dataset.path,n.dataset.label));let s=L(`button`,`session-group-forget`);return s.type=`button`,s.append(sr(ur)),s.addEventListener(`click`,()=>t(n.dataset.path)),n.append(r,i,a,s,o),{header:n,label:r,count:i,addButton:o,forgetButton:s}}function PT(e,t,n){let{header:r,label:i,count:a,addButton:o,forgetButton:s}=e,c=t.key===kT,l=t.rows.length===0;r.dataset.path=t.key,r.dataset.label=t.label,r.title=t.title,r.toggleAttribute(`data-empty`,l),i.textContent=t.label,a.textContent=String(t.rows.length),a.title=`${t.rows.length} ${t.rows.length===1?`session`:`sessions`}`,o.hidden=c,s.hidden=c||!l,c||(o.title=`Add a session to ${t.label}`,o.setAttribute(`aria-label`,`Add a session to ${t.label}`)),!c&&l&&(s.title=`Remove ${t.label} from the ${n}`,s.setAttribute(`aria-label`,`Remove ${t.label} from the ${n}`))}var FT={waitingCount:0,finishedCount:0,failedCount:0},IT={failed:Wt[z.FAILED],waiting:Wt[z.WAITING],finished:Wt[z.COMPLETE]},LT={failed:`failed`,waiting:`needs you`,finished:`finished`},RT=[`NI.`,`THIS QUEUE IS DECEASED`,`AND NOW, NOTHING AT ALL`,`TOUCH GRASS, BRIEFLY`,`GO STRETCH`,`THE AGENTS ARE COPING`,`MORALE IS ADEQUATE`,`REQUIESCAT`,`STANDARDS ARE BEING MET`,`THE AGENTS WANT SPACE`,`NO CAUSE FOR ALARM`,`KINDLY GO AWAY`,`THEY COPE WITHOUT YOU`,`PRESS HARDER, PERHAPS`,`OH, WELL DONE`,`THAT DID NOTHING. AGAIN.`,`WELL. YOU TRIED.`,`SUBJECT PRESSED BUTTON`,`THE BUTTON WORKS. YOU?`,`WE HAVE NO PROBLEMS`,`THE LAWYERS SAY RELAX`,`BRING A TOWEL`],zT=2500,BT=`cubic-bezier(0.16, 1, 0.3, 1)`,VT=`cubic-bezier(0.5, 0, 0.2, 1)`,HT=260,UT=200,WT=200,GT=300,KT=28,qT=360,JT=420,YT=200,XT=3,ZT=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),QT=new WeakMap;function $T(e){let t=QT.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function eE(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function tE(){return ZT?.matches??!1}function nE(e){return e.map(e=>({easing:BT,...e}))}function rE(e,t){let n=L(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${Mc.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${Mc.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${Mc.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${Mc.overflowSlot}px`);let r=L(`span`,`attention-banner-chips`),i=L(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=L(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=L(`span`,`attention-banner-status`);o.append(r,L(`span`,`attention-banner-count`),a);let s=L(`button`,`attention-banner-jump-row`);return s.type=`button`,s.append(o),t&&(t.classList.add(`attention-banner-jump`),s.append(t)),n.addEventListener(`click`,()=>e.onJump()),n.append(s),QT.set(n,{hooks:e,tiles:[],tileById:new Map,headId:null,flyingIds:new Set,tetheredId:null,tetheredRow:null,lastAllClearLine:null,allClearLineTimer:null,pressAnimations:[]}),typeof ResizeObserver==`function`&&new ResizeObserver(()=>aE(n)).observe(r),iE(n,FT,[]),n}function iE(e,t,n){let r=$T(e);r.tiles=n,R(e,`.attention-banner-count`).textContent=Lc(t);let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&xE(e,r),aE(e)}function aE(e){let t=$T(e),n=R(e,`.attention-banner-chips`),r=R(n,`.attention-tile-overflow`),i=eE(e),a=t.tiles.slice(0,Nc(n.clientWidth,t.tiles.length)),o=new Set(a.map(({id:e})=>e)),s=new Map;if(i)for(let[e,n]of t.tileById)s.set(e,n.getBoundingClientRect().left);let c=[...t.tileById].filter(([e])=>!o.has(e)),l=c.map(([,e])=>({left:e.offsetLeft,top:e.offsetTop}));c.forEach(([e,n],r)=>{t.tileById.delete(e),t.flyingIds.has(e)||!i?n.remove():lE(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??sE(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),cE(s,i,a===0),(s.parentElement!==n||oE(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;r.hidden=p===0,r.textContent=`+${p}`,r.title=`${p} more after these`,t.headId=a[0]?.id??null;let m=t.tiles[0]?.kind;if(m&&(e.dataset.headKind=m),m||delete e.dataset.headKind,t.tetheredId&&!o.has(t.tetheredId)&&pE(e,null),i){for(let e of d)uE(e);a.forEach(({id:e},n)=>{let r=t.tileById.get(e),i=s.get(e);if(!r||i===void 0)return;let a=i-r.getBoundingClientRect().left;e===t.headId&&e!==u?fE(r,a):a!==0&&dE(r,a,n)})}}function oE(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function sE(e,t){let n=L(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=L(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>pE(e,t)),n.addEventListener(`pointerleave`,()=>pE(e,null)),n}function cE(e,{kind:t,name:n},r){e.dataset.kind=t,e.toggleAttribute(`data-head`,r);let i=`${n}, ${LT[t]}`;e.title=i,e.setAttribute(`aria-label`,i),xr(R(e,`.attention-tile-icon`),IT[t])}function lE(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=tE()?[{opacity:1},{opacity:0}]:nE([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:WT,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function uE(e){let t=tE()?[{opacity:0},{opacity:1}]:nE([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:UT})}function dE(e,t,n){tE()||e.animate(nE([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:GT,delay:n*KT,fill:`backwards`})}function fE(e,t){tE()?e.animate([{opacity:.35},{opacity:1}],{duration:qT,easing:BT}):e.animate(nE([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:qT})}function pE(e,t){let n=$T(e),r=t?n.tileById.get(t):void 0,i=r&&t?t:null;if(i===n.tetheredId||(n.tetheredId&&n.tileById.get(n.tetheredId)?.toggleAttribute(`data-tethered`,!1),n.tetheredRow?.toggleAttribute(`data-tethered`,!1),n.tetheredRow?.style.removeProperty(`--tether`),n.tetheredId=i,n.tetheredRow=null,!r||!i))return;r.toggleAttribute(`data-tethered`,!0);let a=n.hooks.rowFor(i);if(!a)return;let o=getComputedStyle(r).getPropertyValue(`--tile`).trim();o&&a.style.setProperty(`--tether`,o),a.toggleAttribute(`data-tethered`,!0),n.tetheredRow=a}function mE(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function hE(e,t,n){let r=$T(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!eE(e)){n();return}pE(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=mE(a?.querySelector(`.session-row-glyph`)??a),c=i.cloneNode(!0);if(!(c instanceof HTMLElement)){r.flyingIds.delete(t),n();return}c.classList.add(`attention-tile-ghost`),c.setAttribute(`aria-hidden`,`true`),c.removeAttribute(`aria-label`),c.tabIndex=-1,c.style.left=`${o.left}px`,c.style.top=`${o.top}px`,c.style.width=`${o.width}px`,c.style.height=`${o.height}px`,document.body.append(c),i.style.visibility=`hidden`;let l=c.animate(gE(o,s),_E(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function gE(e,t){return!t||tE()?[{opacity:1},{opacity:0}]:[{transform:`none`,opacity:1},{transform:`translateY(-5px) scale(1.2)`,opacity:1,offset:.25},{transform:`translate(${t.left+t.width/2-(e.left+e.width/2)}px, ${t.top+t.height/2-(e.top+e.height/2)}px) scale(${Math.min(1,t.width/e.width)})`,opacity:.2}]}function _E(e){return!e||tE()?{duration:YT,fill:`forwards`}:{duration:JT,easing:VT,fill:`forwards`}}function vE(e){let t=$T(e);e.hasAttribute(`data-empty`)&&bE(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!eE(e))return;let n={duration:HT};if(t.pressAnimations.push(e.animate(nE([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!tE()){t.pressAnimations.push(e.animate(nE([{transform:`none`},{transform:`scale(0.97) translateY(1px)`,offset:.3},{transform:`none`}]),n));for(let r of e.querySelectorAll(`.attention-banner-jump .kbd`))t.pressAnimations.push(r.animate(nE([{transform:`none`},{transform:`translateY(${XT}px)`,offset:.3},{transform:`none`}]),n),r.animate(nE([{transform:`none`},{transform:`translateY(-${XT}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function yE(e){let t=RT.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??RT[0]}function bE(e,t){let n=yE(t.lastAllClearLine);t.lastAllClearLine=n,R(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>xE(e,t),zT)}function xE(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var SE=e=>e.ui.path,CE=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),wE=null,TE=null,EE=null,DE=null,OE=null,kE=null,AE=null,jE=!1,ME=!1,NE=new Map,PE=new Map,FE=new Map,IE=new Map,LE=null,RE=``,zE=[],BE=new Set;function VE(){return MT(UE(QE()),BE)}function HE(e){let t=LE;if(LE=e||null,t&&t!==LE){let e=PE.get(t);e&&(e.tabIndex=-1,e.setAttribute(`aria-selected`,`false`))}if(LE){let e=PE.get(LE);e&&(e.tabIndex=0,e.setAttribute(`aria-selected`,`true`))}}function UE(e){return jT(e,SE,Tu(e,SE))}function WE(e){let t=IE.get(e.key),n=FE.get(e.key);return(!t||!n)&&(t=NT({onAdd:zu,onForget:e=>{Eu(e),iD()}}),n=L(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),IE.set(e.key,t),FE.set(e.key,n)),PT(t,e,`rail`),n.setAttribute(`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function GE(){return jE}function KE(){return W.snapshot().focusedSessionId}function qE({rail:e,center:t,resizer:n}){if(wE=e,EE=t,!wE||!EE)return;let r=wE,i=EE;XE(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,Wn(Pa)),TE=rE({onJump:cD,rowFor:e=>PE.get(e)},Ba());let a=L(`details`,`rail-status-key`);a.append(L(`summary`,`rail-status-key-summary`,`Status key`),bu()),r.append(TE,a),OE=L(`div`,`focus-empty`),OE.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,kE=OE.querySelector(`.focus-empty-title`),AE=OE.querySelector(`.focus-empty-desc`),DE=L(`div`,`focus-card-slot`),i.append(OE,DE),r.addEventListener(`keydown`,ZE)}var JE={minPx:180,maxPx:480},YE=16;function XE(e){e&&wE&&el({resizer:e,column:wE,widthHost:wE,widthProperty:`--rail-width`,bounds:JE,keyStepPx:YE,getStoredWidth:jn,setStoredWidth:un})}function ZE(e){if(e.key===`Delete`||e.key===`Backspace`){let t=e.target instanceof HTMLElement?e.target:null,n=t?.dataset.id;if(!n||PE.get(n)!==t)return;e.preventDefault(),Ku(n);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=wc(VE(),LE,e.key===`ArrowDown`?1:-1);t!=null&&(e.preventDefault(),HE(t),PE.get(t)?.focus())}function QE(){return vc(Iu($E))}function $E(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function eD(e){let{row:t,refs:n}=ou(`button`);t.type=`button`,t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,()=>tD(e)),t.addEventListener(`pointerenter`,()=>{TE&&pE(TE,e)}),t.addEventListener(`pointerleave`,()=>{TE&&pE(TE,null)});let{item:r,removeButton:i}=su(t,()=>Ku(e));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,Object.assign(t,{_refs:n,_row:r})}function tD(e){let t=Nu(e);t&&(mD(e),uD(t,e))}function nD(e,{id:t,ui:n,state:r,name:i},a){let o=NE.get(t)||`none`;mu(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a}),e.classList.toggle(`focused`,t===KE());let s=t===LE;e.setAttribute(`aria-selected`,String(s)),e.tabIndex=s?0:-1}function rD(e,t){if(!jE)return;let n=e?.card?.dataset.id,r=n?PE.get(n):null;r&&(t===`flag`?r.dataset.activity=e._activity||``:Xt(r._refs?.glyph))}en(rD),Zt(()=>{if(jE)for(let[e,t]of PE){let n=H.get(e);n&&(t._refs.elapsed.textContent=Yt(n))}});function iD(){if(!jE)return;let e=wE;if(!e)return;let t=QE(),n=UE(t),r=new Set,i=jc(t,KE()),a=new Map(i.map(({id:e},t)=>[e,t+1])),o=(e,t)=>{let n=e.map(e=>e.id).join(`,`),i=t._lastOrderKey===n&&t.childElementCount===e.length;for(let n of e){let{id:e}=n;r.add(e);let o=PE.get(e);o||(o=eD(e),PE.set(e,o)),nD(o,n,a.get(e)??null),i||t.appendChild(o._row)}t._lastOrderKey=n},s=new Set(n.order),c=n.groups.map(e=>e.key).join(`
164
+ `),l=c===RE;RE=c;for(let t of n.groups){let{header:n,list:r}=WE(t);l||e.append(n,r),o(t.rows,r)}for(let[e,t]of[...IE])s.has(e)||(t.header.remove(),FE.get(e)?.remove(),IE.delete(e),FE.delete(e));for(let[e,t]of PE)r.has(e)||(t._row.remove(),PE.delete(e),e===LE&&(LE=null));for(let e of[...NE.keys()])H.has(e)||NE.delete(e);let u=zE;zE=MT(n,BE);let d=KE();if(d&&!H.has(d)){W.dispatch(`focusSession`,null),LE=null;let e=aD(u,d);if(e){let t=!document.activeElement||document.activeElement===document.body;mD(e),t&&uD(H.get(e),e);return}}hD();let f=KE();if(f){let e=H.get(f);e&&e.card.parentElement!==DE&&fD(e,f)}sD(t,i)}function aD(e,t){let n=e.filter(e=>e===t||H.has(e));return n.length<2?zE.find(e=>H.has(e))??null:wc(n,t,n.indexOf(t)===n.length-1?-1:1)}function oD(){return jc(QE(),KE())}function sD(e,t){TE&&iE(TE,Pc(e),t)}function cD(){if(!jE)return;TE&&vE(TE);let e=oD()[0]?.id;e&&lD(e)}function lD(e){if(!jE)return;PE.get(e)?.scrollIntoView({block:`nearest`}),TE&&hE(TE,e,()=>dD(e));let t=H.get(e);Nu(e),mD(e),uD(t,e)}function uD(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{jE&&KE()===t&&e.term?.focus()}))}function dD(e){if(CE?.matches||document.hidden)return;let t=PE.get(e);t?.animate&&(t.animate([{transform:`scale(1)`},{transform:`scale(1.045)`,offset:.3},{transform:`scale(1)`}],{duration:360,easing:`cubic-bezier(0.22, 1, 0.36, 1)`}),t._row.animate([{boxShadow:`0 0 0 3px var(--accent)`},{boxShadow:`0 0 0 3px transparent`}],{duration:700,easing:`ease-out`}));let n=H.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function fD(e,t){DE&&(Gr(e,t,DE,{className:`focus-centered`}),hg(e,t,!0))}function pD(){let e=KE();e&&(Wr()===e&&Kr(),W.dispatch(`focusSession`,null))}function mD(e){jE&&H.has(e)&&(ET(e),e!==KE()&&(pD(),W.dispatch(`focusSession`,e),LE=e,Pu(e),iD()))}function hD(){if(!OE||!kE||!AE)return;let e=KE(),t=!!(e&&H.has(e)),n=H.size>0;OE.hidden=t,co(OE,!n),kE.hidden=!n,AE.hidden=!n,!t&&n&&(kE.textContent=`No session selected`,AE.textContent=`Select a session from the rail on the left to focus it here.`)}function gD(e,t){NE.set(V(e),typeof t==`string`&&t?t:`none`),jE&&iD()}function _D(e){jE&&H.has(e)&&mD(e)}function vD(e){return!jE||!H.has(e)?!1:(mD(e),Yw(e))}function yD(e){if(!jE)return;let t=VE()[e-1];t&&tD(t)}function bD(e){if(!jE)return;let t=wc(VE(),LE,e);t!=null&&(tD(t),PE.get(t)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=KE();jE&&e&&ET(e)});function xD(){wE&&(jE=!0,pD(),LE=null,iD(),ME&&oD().length>0?cD():(ME&&TE&&vE(TE),CD()))}function SD(e){ME=!0;try{e()}finally{ME=!1}}function CD(){if(!jE||KE())return;let e=Fu();e&&mD(e)}function wD(){jE&&=(pD(),LE=null,!1)}var TD=`t-[0-9a-f]{8}`,ED=`No findings. Open a markdown file in a connected editor.`,DD=`No intent yet. The visions proposes one after its first pass.`,OD=`Unowned`,kD=RegExp(`^${TD}$`);function AD(){return{byProject:{},unowned:[]}}function jD(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.text==`string`?t.text:``;if(!n)return null;let r=Number(t.ts),i=Number(t.hits);return{id:typeof t.id==`string`&&kD.test(t.id)?t.id:null,text:n,uris:Array.isArray(t.uris)?t.uris.filter(e=>typeof e==`string`&&e!==``):[],ts:Number.isFinite(r)&&r>0?r:0,hits:Number.isInteger(i)&&i>0?i:1}}function MD(e){if(Array.isArray(e))return e.map(jD).filter(e=>e!==null);let t=jD(e);return t?[t]:[]}function ND(e){let t=e?.intent;if(!t||typeof t!=`object`)return AD();let n=t;if(!(Object.hasOwn(n,`byProject`)||Object.hasOwn(n,`unowned`)||Object.hasOwn(n,`global`)))return{byProject:{},unowned:MD(n)};let r=n.byProject&&typeof n.byProject==`object`?n.byProject:{},i=[];for(let[e,t]of Object.entries(r)){let n=MD(t);n.length!==0&&e&&i.push([e,n])}return{byProject:Object.fromEntries(i),unowned:MD(Object.hasOwn(n,`unowned`)?n.unowned:n.global)}}function PD(e,t){let n=typeof t?.id==`string`?t.id:null;if(!n)return e;let r=e.findIndex(e=>e.id===n);return r<=0?e:[e[r],...e.slice(0,r),...e.slice(r+1)]}function FD(e,t){let n=e||AD(),r=t?.intent;if(!r||typeof r!=`object`)return n;let i=r,a=PD(Array.isArray(i.threads)?MD(i.threads):MD(i),i.active),o=typeof t?.projectId==`string`&&t.projectId?t.projectId:null;if(!o)return{byProject:{...n.byProject},unowned:a};let s={...n.byProject};return a.length===0&&delete s[o],a.length>0&&(s[o]=a),{byProject:s,unowned:n.unowned}}function ID(e,t=null){let n=t&&typeof t.get==`function`?t.get(e):null;return typeof n==`string`&&n?n:e}function LD(e,{key:t,label:n,now:r}){return e.map((e,i)=>({key:`${t}:${e.id||i}`,label:n,text:e.text,hasText:!0,active:i===0,meta:VD(e,r)}))}function RD(e,t=null,n=Date.now()){let r=e||AD(),i=Object.entries(r.byProject||{}).filter(([e,t])=>e&&Array.isArray(t)&&t.length>0).map(([e,n])=>({projectId:e,label:ID(e,t),threads:n})).sort((e,t)=>e.label.localeCompare(t.label)).flatMap(({projectId:e,label:t,threads:r})=>LD(r,{key:e,label:t,now:n})),a=LD(Array.isArray(r.unowned)?r.unowned:[],{key:`unowned`,label:OD,now:n});return i.length+a.length>0?[...a,...i]:[{key:`unowned`,label:OD,text:DD,hasText:!1,active:!1,meta:``}]}function zD(e){return e?.text?`proposed by visions`:``}function BD(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:D(Number(t)-n,{rounding:`floor`,wording:`spelled`,suffix:` ago`,justNowBelowSeconds:60})}function VD(e,t=Date.now()){let n=zD(e);if(!n)return``;let r=typeof e?.id==`string`&&e.id?`thread ${e.id}, `:``,i=BD(e?.ts,t);return i?`${r}${n}, ${i}`:`${r}${n}`}function HD(e){let t=Number(e?.range?.start?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function UD(e){let t=Number(e?.range?.start?.character);return Number.isFinite(t)?t:0}function WD(e){let t=Number(e?.range?.start?.line);return Number.isFinite(t)?t:0}function GD(e){let t=typeof e==`string`?e:``;if(!t)return``;let n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);if(!r)return t;try{return decodeURIComponent(r)}catch{return r}}function KD(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(Math.floor(e),0):0}function qD(e){let t=KD(e);return t===1?`1 finding`:`${t} findings`}function JD(e){let t=KD(e);return t===1?`1 comment`:`${t} comments`}function YD(e){let t=KD(e?.findings?.length),n=KD(e?.comments?.length),r=typeof e?.hand==`string`&&e.hand?1:0,i=[];return r>0&&i.push(`raised hand`),t>0&&i.push(qD(t)),n>0&&i.push(JD(n)),i.length>0?i.join(`, `):qD(0)}function XD(e){let t=typeof e==`string`?e.trim():``;return t?`Raised hand: ${t}`:``}function ZD(e){return(typeof e?.hand==`string`?e.hand.trim():``)||null}function QD(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=ZD(t);return i?(n.set(r,i),n):(n.delete(r),n)}function $D(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=typeof e?.hand==`string`?e.hand.trim():``;n&&r&&t.set(n,r)}return t}var eO=`hand`,tO=`unseen`,nO=`
165
+ `;function rO(e){let t=2166136261,n=3266489909;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619)>>>0,n=Math.imul(n^i,2246822507)>>>0}return`${t.toString(36).padStart(7,`0`)}${n.toString(36).padStart(7,`0`)}`}function iO(e,t){return rO(JSON.stringify([e,...t]))}function aO(e,t){return iO(`finding`,[e,HD(t),String(t.code??``),String(t.message??``)])}function oO(e,t){return iO(`comment`,[e,dO(t),String(t.message??``)])}function sO(e){return iO(`fix`,[e.uri,CO(e),e.code,e.message,wO(e)])}function cO(e){return iO(`intent`,[e.key,e.text,e.active])}function lO(e,t,n,r=[],i=null){let a=[...n].map(([e,t])=>iO(`hand`,[e,t])).sort(),o=new Set;for(let r of[...e.keys(),...t.keys(),...n.keys()])o.add(iO(`document`,[r]));for(let[t,n]of e)for(let e of n)o.add(aO(t,e));for(let[e,n]of t)for(let t of n)o.add(oO(e,t));for(let e of r)o.add(sO(e));for(let e of RD(i,null,0))e.hasText&&o.add(cO(e));let s=[...o].sort();return{signature:[...a,...s].join(nO),handEntries:a,contentEntries:s}}function uO(e,t){let n=new Set(t.split(nO));return e.handEntries.some(e=>!n.has(e))?eO:e.contentEntries.some(e=>!n.has(e))?tO:null}function dO(e){let t=Number(e?.line);return!Number.isFinite(t)||t<1?`L?`:`L${Math.floor(t)}`}function fO(e){return Array.isArray(e?.diagnostics)?e.diagnostics:[]}function pO(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=fO(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function mO(e){return Array.isArray(e?.comments)?e.comments:[]}function hO(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=mO(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function gO(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.diagnostics)?e.diagnostics:[];n&&r.length!==0&&t.set(n,r)}return t}function _O(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.comments)?e.comments:[];n&&r.length!==0&&t.set(n,r)}return t}function vO(e,t=new Map,n=new Map){let r=[],i=new Set([...e.keys(),...t.keys(),...n.keys()]);for(let a of i){let i=e.get(a),o=t.get(a),s=n.get(a)||null,c=Array.isArray(i)?i:[],l=Array.isArray(o)?o:[];(c.length!==0||l.length!==0||s)&&r.push({uri:a,name:GD(a)||a,hand:s,findings:[...c].sort((e,t)=>WD(e)-WD(t)||UD(e)-UD(t)),comments:[...l].sort((e,t)=>(Number(e?.line)||0)-(Number(t?.line)||0))})}return r.sort((e,t)=>yO(e.name,t.name)||yO(e.uri,t.uri)),r}function yO(e,t){return e<t?-1:+(e>t)}var bO=`No fixes yet. Silent fixes appear here once the lane applies or is refused one.`,xO=20;function SO(e){let t=KD(e);return t===1?`1 fix`:`${t} fixes`}function CO(e){let t=Number(e?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function wO(e){return e?.applied===!0?`applied`:`refused`}function TO(e,{uri:t=``,ts:n=0}={}){if(!e||typeof e!=`object`)return null;let r=e,i=typeof r.message==`string`?r.message.trim():``;if(!i)return null;let a=Number(r.line),o=Number(r.ts??n);return{uri:typeof r.uri==`string`&&r.uri?r.uri:t,code:typeof r.code==`string`?r.code:``,line:Number.isFinite(a)&&a>0?Math.floor(a):0,message:i,applied:r.applied===!0,ts:Number.isFinite(o)&&o>0?o:0}}function EO(e){let t=typeof e?.uri==`string`?e.uri:``,n=Number(e?.ts);return TO(e?.fix,{uri:t,ts:Number.isFinite(n)?n:0})}function DO(e,t,{max:n=xO}={}){let r=EO(t);return r?[r,...e].slice(0,Math.max(0,Math.floor(n))):[...e]}function OO(e,{max:t=xO}={}){let n=Array.isArray(e?.fixes)?e.fixes:[],r=[];for(let e of n){let t=TO(e);t&&r.push(t)}return r.slice(0,Math.max(0,Math.floor(t)))}var kO=`No activity yet. The ingest lane reports what your sessions and tools are doing.`,AO=100,jO={terminal:`terminal`,agentLogs:`agent`,git:`git`,fs:`files`,shellHistory:`shell`,editor:`editor`};function MO(e){let t=typeof e==`string`?e:``;return jO[t]||t||`source`}function NO(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:D(Number(t)-n,x)}function PO(e){if(!e||typeof e!=`object`)return null;let t=e,n=Number(t.seq);if(!Number.isFinite(n))return null;let r=typeof t.summary==`string`?t.summary.trim():``;if(!r)return null;let i=Number(t.ts),a=t.scope&&typeof t.scope==`object`?t.scope:{};return{seq:Math.floor(n),source:typeof t.source==`string`?t.source:``,kind:typeof t.kind==`string`?t.kind:``,ts:Number.isFinite(i)&&i>0?i:0,summary:r,root:typeof a.root==`string`&&a.root?a.root:null,sessionId:typeof a.sessionId==`string`&&a.sessionId?a.sessionId:null}}function FO(e){let t=Array.isArray(e?.events)?e.events:[],n=[];for(let e of t){let t=PO(e);t&&n.push(t)}return n}function IO(e){let t=Number(e?.overflow);return!Number.isFinite(t)||t<=0?0:Math.floor(t)}function LO(e){let t=KD(e);return t<=0?``:t===1?`1 more event not shown`:`${t} more events not shown`}function RO(e,t){return[...e].sort((e,t)=>t.seq-e.seq).slice(0,Math.max(0,Math.floor(t)))}function zO(e,t,{max:n=AO}={}){let r=FO(t);if(r.length===0)return RO(e,n);let i=new Map;for(let t of e)i.set(t.seq,t);for(let e of r)i.set(e.seq,e);return RO([...i.values()],n)}function BO(e,{max:t=AO}={}){return RO(FO(e),t)}function VO(e){let t=KD(e);return t===1?`1 event`:`${t} events`}function HO(e){if(!e?.root)return`machine`;let t=e.root.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var UO=new Map,WO=new Map,GO=new Map,KO=AD(),qO=new Map,JO=null,YO=!0,XO=[],ZO=0,QO=[],$O=null,ek=()=>!1,tk=new Set,nk=lO(UO,WO,GO,QO,KO),rk=Qn(),ik=Oe({getAck:()=>rk,setAck:e=>{rk=e,Ln(e)},signature:()=>nk.signature,isLooking:()=>ek()});function ak(e){for(let t of tk)t(e)}function ok(){nk=lO(UO,WO,GO,QO,KO),nk.signature!==``&&ik.refresh(),$O?.(uO(nk,rk))}function sk(e){ak(e),ok()}function ck(){return{findingsByUri:UO,commentsByUri:WO,handsByUri:GO,intent:KO,projectNamesById:qO,isEnabled:JO,isConnected:YO,activityEvents:XO,activityOverflow:ZO,fixEntries:QO}}function lk(e){tk.add(e)}function uk(e){ek=e,ok()}function dk(e){$O=e,ok()}function fk(){nk.signature!==``&&ik.acknowledge(),ok()}function pk(e){qO=e instanceof Map?e:new Map,ak([`intent`])}function mk(e){JO=e?.visions?.enabled===!0,ak([`feed`])}function hk(e){YO=e,ak([`connection`])}function gk(e){QO=DO(QO,e),sk([`fixes`])}function _k(e){UO=pO(UO,e),sk([`feed`])}function vk(e){WO=hO(WO,e),sk([`feed`])}function yk(e){GO=QD(GO,e),sk([`feed`])}function bk(e){KO=FD(KO,e),sk([`intent`])}function xk(e){XO=zO(XO,e),ZO=IO(e),sk([`activity`])}function Sk(e){XO=BO(e),ZO=0,sk([`activity`])}function Ck(e){UO=gO(e),WO=_O(e),GO=$D(e),KO=ND(e),QO=OO(e),sk([`intent`,`feed`,`fixes`])}var wk=n(a(),e());u({glimmervoidId:a().min(1),event:a().min(1),token:a().nullable().optional(),payload:wk}),u({id:a().min(1),name:a().min(1),event:a().min(1),matcher:a().optional(),type:o([`command`,`http`]),command:a().optional(),url:a().optional(),timeout:i().int().positive().optional(),enabled:t(),projects:c(a()).optional()}).passthrough();var Tk=`Claude Code hooks injected into every session Glimmervoid spawns.`,Ek=`Loading hooks`,Dk=`No hooks yet. A hook runs a command, or calls a URL, when a Claude Code event fires in a Glimmervoid session. Start from one of these, or add your own.`,Ok=`Start from`,kk=`Filter by name, event or command`,Ak=`Nothing matches that filter.`,jk=`Preview`,Mk=`The entry this becomes in the per-session settings file.`,Nk=`Duplicate`,Pk=`Discard changes`,Fk=`Close the editor and lose the unsaved changes?`,Ik=`Esc cancels. Ctrl+Enter saves.`,Lk=4,Rk=`A change reaches a session at its next start or restart. Claude Code sessions only; Codex and Grok sessions do not read this file.`,zk=`Glimmervoid's own hooks`,Bk=`Always present, read-only. Status detection depends on them.`,Vk=`Your hooks`,Hk=`New hook`,Uk=`Edit hook`,Wk=`Saved to config.json.`,Gk=`All projects`,Kk=`This event takes no matcher.`,qk=`Blank uses Claude Code's default for the event.`,Jk=Object.freeze([{value:`command`,label:`Command`,hint:`Run a shell command. It receives the event JSON on stdin.`},{value:`http`,label:`HTTP`,hint:`POST the event JSON to a URL.`}]),Yk=Object.freeze([{id:`lint`,label:`Lint after edits`,summary:`PostToolUse on Edit|Write`,draft:{name:`Lint after edits`,event:`PostToolUse`,matcher:`Edit|Write`,type:`command`,command:`npx biome check --write "$(jq -r .tool_input.file_path)"`}},{id:`notify`,label:`Notify on Stop`,summary:`Stop, command`,draft:{name:`Notify on Stop`,event:`Stop`,matcher:``,type:`command`,command:`command -v notify-send >/dev/null 2>&1 && notify-send "Claude finished a turn" || { command -v osascript >/dev/null 2>&1 && osascript -e 'display notification "Claude finished a turn" with title "Claude Code"'; }`}},{id:`guard`,label:`Guard destructive Bash`,summary:`PreToolUse on Bash, exit 2 blocks`,draft:{name:`Guard destructive Bash`,event:`PreToolUse`,matcher:`Bash`,type:`command`,command:`jq -r .tool_input.command | grep -Eq "rm -rf|git push --force" && exit 2 || exit 0`}},{id:`log`,label:`Log every prompt`,summary:`UserPromptSubmit, appends JSON`,draft:{name:`Log every prompt`,event:`UserPromptSubmit`,matcher:``,type:`command`,command:`cat >> ~/.claude/prompts.jsonl`}}]),Xk=Object.freeze({hooks:[],builtin:[],events:[]});function Zk(e){return!e||typeof e.error==`string`}function Qk(e){return!e||typeof e.error!=`string`?``:e.error}function $k(e,t){let n=e?.[t];return Array.isArray(n)?n:Xk[t]}var eA=e=>$k(e,`hooks`),tA=e=>$k(e,`builtin`),nA=e=>$k(e,`events`);function rA(e){let t=e?.limits?.maxTimeoutSec;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:600}function iA(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function aA(e){let t=eA(e),n=t.filter(e=>e.enabled!==!1).length;return[{label:`yours`,value:String(t.length),tone:null},{label:`enabled`,value:String(n),tone:t.length>0&&n===0?`warn`:null},{label:`built in`,value:String(tA(e).length),tone:null}]}function oA(e,t){let n=new Map(t.map((e,t)=>[e.name,t])),r=e=>n.get(e.event)??t.length;return[...e].sort((e,t)=>{let n=r(e)-r(t);return n===0?String(e.name).localeCompare(String(t.name)):n})}function sA(e,t){let n=String(t||``).trim().toLowerCase();return n?e.filter(e=>[e.name,e.event,e.matcher,e.command,e.url].some(e=>typeof e==`string`&&e.toLowerCase().includes(n))):e}function cA(e){return e.length>=Lk}function lA(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.event===n.event?e.hooks.push(n):t.push({event:n.event,hooks:[n]})}return t}function uA(e){let t=e.type===`http`?{type:`http`,url:e.url||``}:{type:`command`,command:e.command||``};Number.isInteger(e.timeout)&&Number(e.timeout)>0&&(t.timeout=e.timeout);let n=e.matcher?{matcher:e.matcher,hooks:[t]}:{hooks:[t]};return JSON.stringify({hooks:{[e.event]:[n]}},null,2)}function dA(e){return`${e} copy`}function fA(e,t){return e.find(e=>e.name===t)||null}function pA(e,t){let n=fA(e,t);return n?n.matcher?`Matches ${n.matcher}. Blank matches every ${n.name}.`:Kk:``}function mA(e){return e.type===`http`?e.url||``:e.command||``}function hA(e){let t=Jk.find(t=>t.value===e);return t?t.label:String(e||``)}function gA(e){return!Number.isInteger(e.timeout)||Number(e.timeout)<=0?``:`${e.timeout}s timeout`}function _A(e,t){let n=Array.isArray(e.projects)?e.projects:[];return n.length===0?Gk:n.map(e=>{let n=t.find(t=>t.id===e);return n?n.name:e}).join(`, `)}function vA(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function yA(e){return vA(e)}function bA(e,t){let n=Array.isArray(e.projects)?e.projects:[],r=new Set(t.map(e=>e.id));return n.filter(e=>!r.has(e))}function xA(e){let t=e[0];return{id:null,name:``,event:t?t.name:``,matcher:``,type:`command`,command:``,url:``,timeout:``,enabled:!0,projects:[]}}function SA(e){return{id:e.id??null,name:e.name||``,event:e.event||``,matcher:e.matcher||``,type:e.type===`http`?`http`:`command`,command:e.command||``,url:e.url||``,timeout:Number.isInteger(e.timeout)?String(e.timeout):``,enabled:e.enabled!==!1,projects:Array.isArray(e.projects)?[...e.projects]:[]}}function CA(e,t,n=600){if(!e.name.trim())return`Give the hook a name.`;let r=fA(t,e.event);if(!r)return`Pick an event.`;if(e.matcher.trim()&&!r.matcher)return`${r.name} takes no matcher.`;if(e.type===`http`&&r.http===!1)return`${r.name} does not support HTTP hooks.`;if(e.type===`command`&&!e.command.trim())return`Enter the command to run.`;if(e.type===`http`&&!/^https?:\/\/\S+$/i.test(e.url.trim()))return`Enter a URL starting with http:// or https://.`;if(e.timeout.trim()!==``){let t=Number(e.timeout);if(!Number.isInteger(t)||t<1||t>n)return`Timeout must be a whole number of seconds from 1 to ${n}.`}return null}function wA(e){let t={name:e.name.trim(),event:e.event,type:e.type,enabled:e.enabled!==!1};return e.id&&(t.id=e.id),e.matcher.trim()&&(t.matcher=e.matcher.trim()),e.type===`command`&&(t.command=e.command.trim()),e.type===`http`&&(t.url=e.url.trim()),e.timeout.trim()!==``&&(t.timeout=Number(e.timeout)),e.projects.length>0&&(t.projects=[...e.projects]),t}function TA(e,t){let n={...xA(t),...e.draft};return fA(t,n.event)||(n.event=xA(t).event),n}function EA(e,t){return JSON.stringify(wA(e))!==JSON.stringify(t)}function DA(e){return{...e,enabled:e.enabled===!1}}function OA(e){return`Delete the hook "${e.name}"? Sessions already running keep it until they restart.`}var kA=null,AA=null,jA=!1,MA=null,NA=new Set;function PA(){for(let e of NA)e()}function FA(){return{report:kA,hasReportSendFailed:jA}}function IA(e){NA.add(e)}function LA(e){AA=e}function RA(){if(!AA)return;MA=y(`hooks-report`);let e=AA({type:`request-hooks-report`,requestId:MA});e!==!jA&&(jA=!e,PA())}function zA(e){iA(e,MA)&&(kA=e,jA=!1,PA())}function BA(){RA()}function VA(e){return e.filter(e=>!e.hasOwnPhoneScreen).map(e=>{let t=e.label.trim();return{id:e.view,label:t,glyph:e.glyph||t.charAt(0).toUpperCase(),el:e.el}})}var HA=e=>e.ui.path;function UA({onSelectSession:e}){let t=L(`div`,`phone-board`),n=L(`header`,`phone-topbar`),r=rE({onJump:()=>{vE(r);let e=jc(x(),null)[0]?.id;e&&a(e)},rowFor:e=>d.get(e)}),i=null;function a(e){i=e,d.get(e)?.scrollIntoView({block:`nearest`}),hE(r,e,()=>{i===e&&o(e)})}function o(t){i=null,e?.(t)}let s=L(`div`,`phone-board-list`),c=L(`div`,`phone-empty`),l=L(`p`,`phone-empty-title`,`No sessions`),u=L(`p`,`phone-empty-desc`,`Spawn a session to start watching.`);c.append(l,u),t.append(n,s,c,r);let d=new Map,f=new Map,p=new WeakMap,m=new WeakMap,h=new WeakMap,g=0;nt(n);function _(e){let{row:t,refs:n}=ou(`button`);t.type=`button`,t.dataset.id=e,t.addEventListener(`click`,()=>o(e));let{item:r}=su(t,()=>Ku(e));return r.setAttribute(`role`,`listitem`),p.set(t,{refs:n,item:r}),t}function v(){let e=L(`section`,`phone-board-group`),t=NT({onAdd:zu,onForget:e=>{Eu(e),S()}}),n=L(`div`,`phone-board-group-rows`);return n.setAttribute(`role`,`list`),e.append(t.header,n),m.set(e,{...t,rows:n}),e}function y(e,t,n){let r=p.get(e);if(!r)return;let{ui:i,state:a,name:o}=t;mu(e,r.refs,{ui:i,state:a,name:o,mergeStatus:i.card?.dataset.merge||``,attentionPosition:n})}function b(e,t){let n=m.get(e);n&&(PT(n,t,`Board`),n.rows.setAttribute(`aria-label`,`${t.label} sessions`))}function x(){return vc(Iu())}function S(){let e=x(),t=jT(e,HA,Tu(e,HA)),n=Pc(e);g=Fc(n);let i=jc(e,null),a=new Map(i.map(({id:e},t)=>[e,t+1]));iE(r,n,i);let o=new Set(t.order),S=t.order.join(`,`),C=h.get(s)===S&&s.childElementCount===t.groups.length;for(let e of t.groups){let t=f.get(e.key);t||(t=v(),f.set(e.key,t)),b(t,e),C||s.appendChild(t);let n=e.rows.map(e=>e.id).join(`,`),r=m.get(t);if(!r)continue;let i=h.get(r.rows)===n&&r.rows.childElementCount===e.rows.length;for(let t of e.rows){let e=d.get(t.id);e||(e=_(t.id),d.set(t.id,e)),y(e,t,a.get(t.id)??null);let n=p.get(e);n&&(i||r.rows.appendChild(n.item))}h.set(r.rows,n)}h.set(s,S);for(let[e,t]of[...f])o.has(e)||(t.remove(),f.delete(e));let w=new Set(MT(t));for(let[e,t]of[...d]){if(w.has(e))continue;let n=p.get(t);n&&n.item.remove(),d.delete(e)}let T=t.groups.length>0,E=H.size===0;s.hidden=!T,c.hidden=T,co(c,E),l.hidden=E,u.hidden=E,r.hidden=E}function C(e,t){let n=e.card?.dataset.id,r=n?d.get(n):void 0;r&&(t===`flag`?r.dataset.activity=e._activity||``:Xt(p.get(r)?.refs.glyph))}return Zt(()=>{for(let[e,t]of d){let n=H.get(e),r=p.get(t);n&&r&&(r.refs.elapsed.textContent=Yt(n))}}),{el:t,topBarEl:n,refresh:S,renderActivity:C,getAttentionCount:()=>g}}var WA=`clipboard`,GA=`upload`,KA=24,qA=Object.freeze([Object.freeze({id:`esc`,label:`Esc`,bytes:`\x1B`,title:`Send Escape`}),Object.freeze({id:`tab`,label:`Tab`,bytes:` `,title:`Send Tab`}),Object.freeze({id:`left`,label:`←`,bytes:`\x1B[D`,isArrow:!0,title:`Arrow left`}),Object.freeze({id:`up`,label:`↑`,bytes:`\x1B[A`,isArrow:!0,title:`Arrow up`}),Object.freeze({id:`down`,label:`↓`,bytes:`\x1B[B`,isArrow:!0,title:`Arrow down`}),Object.freeze({id:`right`,label:`→`,bytes:`\x1B[C`,isArrow:!0,title:`Arrow right`}),Object.freeze({id:`paste`,label:`Paste`,bytes:null,action:WA,title:`Paste from the clipboard`}),Object.freeze({id:`attach`,label:`Attach`,bytes:null,action:GA,title:`Upload a photo or file to this session`})]);function JA(e){let t=qA.find(t=>t.id===e);return t?t.bytes:null}function YA(e){return!!e&&e.action===WA}function XA(e){return!!e&&e.action===GA}function ZA(e,t,n=KA){let r=Math.abs(e)>=Math.abs(t),i=r?e:t;return Math.abs(i)<n?null:r?i>0?`right`:`left`:i>0?`down`:`up`}function QA(e,t,n=KA){let r=ZA(e,t,n);if(!r)return null;let i=r===`left`||r===`right`,a=i?e:t,o=Math.floor(Math.abs(a)/n),s=Math.sign(a)*o*n;return{arrowKeyId:r,stepCount:o,consumedX:i?s:e,consumedY:i?t:s}}var $A={" ":`\0`,"@":`\0`,"[":`\x1B`,"\\":``,"]":``,"^":``,_:``,"?":``};function ej(e){if(e.length!==1)return null;let t=e.toLowerCase();return t>=`a`&&t<=`z`?String.fromCharCode(t.charCodeAt(0)-96):$A[e]??null}function tj({send:e,getSessionId:t,reportProblem:n}){let r=L(`div`,`phone-key-strip`);r.setAttribute(`role`,`toolbar`),r.setAttribute(`aria-label`,`Terminal keys`);let i=null,a=null,o=L(`button`,`phone-key phone-key-ctrl`,`Ctrl`);o.type=`button`,o.title=`Hold Ctrl for the next key you type`,o.setAttribute(`aria-pressed`,`false`),o.addEventListener(`pointerdown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>c(!s())),r.appendChild(o);function s(){return o.getAttribute(`aria-pressed`)===`true`}function c(e){o.setAttribute(`aria-pressed`,String(e))}function l(){return s()?(c(!1),!0):!1}for(let t of qA){t.id===`left`&&r.appendChild(nj(e));let n=L(`button`,t.isArrow?`phone-key phone-key-arrow`:`phone-key`,t.label);n.type=`button`,n.dataset.key=t.id,n.title=t.title,t.isArrow&&n.setAttribute(`aria-label`,t.title),n.addEventListener(`pointerdown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>u(t,n)),r.appendChild(n)}function u(t,r){XA(t)?d(r):YA(t)?ij(e,n):e(JA(t.id))}function d(e){a=e,i||(i=L(`input`,`phone-file-picker`),i.type=`file`,i.hidden=!0,i.addEventListener(`change`,f),r.appendChild(i)),i.click()}function f(){let e=i;if(!e)return;let r=e.files?e.files[0]:null;if(e.value=``,!r)return;let o=t?.();o?p(o,r,a):n(`No session is open to upload to.`)}async function p(e,t,n){n&&(n.disabled=!0),await um(e,t),n&&(n.disabled=!1)}return{element:r,takeHeldControl:l}}function nj(e){let t=L(`button`,`phone-key phone-arrow-pad`,`Arrows`);t.type=`button`,t.title=`Swipe to send arrow keys`;let n=null,r=null;t.addEventListener(`pointerdown`,e=>{e.preventDefault(),r===null&&(t.setPointerCapture(e.pointerId),r=e.pointerId,n={x:e.clientX,y:e.clientY})}),t.addEventListener(`pointermove`,t=>{if(t.pointerId!==r||!n)return;let i=QA(t.clientX-n.x,t.clientY-n.y);if(i){for(let t=0;t<i.stepCount;t++)e(JA(i.arrowKeyId));n={x:n.x+i.consumedX,y:n.y+i.consumedY}}});let i=e=>{e.pointerId===r&&(r=null,n=null)};return t.addEventListener(`pointerup`,i),t.addEventListener(`pointercancel`,i),t}var rj=`Paste needs clipboard permission.`;function ij(e,t){let n=null;try{n=navigator.clipboard?.readText?.()}catch{t(rj);return}n?n.then(t=>{t&&e(t)}).catch(()=>t(rj)):t(`Paste is unavailable in this browser.`)}function aj({onBack:e,onShowChanges:t}){let n=L(`div`,`phone-terminal`),r=L(`header`,`phone-topbar phone-terminal-bar`),i=L(`button`,`phone-back`,`‹`);i.type=`button`,i.setAttribute(`aria-label`,`Back to board`),i.addEventListener(`click`,()=>e?.());let a=L(`div`,`phone-terminal-identity`),o=L(`span`,`phone-terminal-name`);o.title=`Double-tap to rename`,o.addEventListener(`dblclick`,()=>E());let s=L(`span`,`session-task-title phone-terminal-title`);Dl(s,()=>D());let c=L(`span`,`phone-terminal-badge`);c.innerHTML=`<span class="phone-terminal-glyph" aria-hidden="true"></span><span class="phone-terminal-label"></span><span class="phone-terminal-elapsed" aria-hidden="true"></span>`;let l=I(c,`.phone-terminal-glyph`,`span`),u=I(c,`.phone-terminal-label`,`span`),d=I(c,`.phone-terminal-elapsed`,`span`);u.before(o),a.append(s,c);let f=L(`button`,`phone-changes`);f.append(sr(lr)),f.type=`button`,f.title=`Show this session's code changes`,f.setAttribute(`aria-label`,`Show this session's code changes`),f.addEventListener(`click`,()=>t?.());let m=L(`div`,`phone-terminal-actions`);r.append(i,a,f,m);let h=L(`div`,`phone-card-slot`),g=L(`div`,`phone-empty`);g.innerHTML=`<p class="phone-empty-title">No session selected</p><p class="phone-empty-desc">Select a session from the board to watch it here.</p>`;let _=pr(`phone-key-status m-0 px-3 py-1`),{element:v,takeHeldControl:y}=tj({send:C,getSessionId:()=>b,reportProblem:e=>_.show(`error`,e)});n.append(r,h,g,_.element,v);let b=null,x=null,S=null;function C(e){let t=b?H.get(b):null;t&&(ag(t,e)?_.clear():_.show(`error`,p))}function w(){let e=b?H.get(b):null;e?.term&&e.term.focus()}h.addEventListener(`click`,w);function T(e){let t=ej(e);return!t||!y()?!1:(C(t),!0)}h.addEventListener(`keydown`,e=>{e.ctrlKey||e.metaKey||e.altKey||T(e.key)&&(e.preventDefault(),e.stopPropagation())},!0),h.addEventListener(`input`,e=>{e instanceof InputEvent&&e.data&&T(e.data.slice(-1))&&(e.stopPropagation(),(b?H.get(b):null)?._resetSoftKeyboardBuffer?.())},!0);function E(){let e=b?H.get(b):null;e&&b&&Nl(e,b,{returnsFocusToTerminal:!1})}function D(){let e=b?H.get(b):null;e&&b&&Al(e,b)}function O(){let e=b?H.get(b):null,t=!!e;if(g.hidden=t,h.hidden=!t,v.hidden=!t,a.hidden=!t,f.hidden=!t,!t){r.removeAttribute(`data-state`),r.removeAttribute(`data-monitoring`),r.removeAttribute(`data-prompt`);return}let n=e.currentState||z.DORMANT;cu(r,{glyph:l,label:u},n,e.awaitingBackgroundTasks,e.pendingPromptKind);let i=e.card?.dataset.session||b;Ml(o)||(o.textContent=i),s.dataset.sessionName=i??``,kl(s,e.taskTitle),d.textContent=Yt(e)}function k(){S&&=(delete S.renameTargetEl,delete S.titleTargetEl,null),o.replaceChildren(),x&&=(lt(x),x.parentElement===m&&x.remove(),null)}function A(e){let t=H.get(e);t&&(b===e&&Wr()===e&&t.card.parentElement===h||(k(),b=e,Gr(t,e,h,{className:`phone-centered`}),x=I(t.card,`.session-actions`,`div`),jt(x,m),t.renameTargetEl=o,t.titleTargetEl=s,S=t),O())}function ee(){k(),Wr()===b&&Kr(),b=null,O()}function te(){if(!b){O();return}let e=H.get(b);e?e.card.parentElement===h?O():(A(b),n.hidden||hg(e,b,!0)):ee()}function ne(){let e=b;e&&hg(H.get(e),e,!1)}function re(){te();let e=b;if(!e)return;let t=H.get(e);t&&(hg(t,e,!0),ET(e))}return Zt(()=>{let e=b?H.get(b):null;e&&(d.textContent=Yt(e))}),O(),{el:n,show:A,clear:ee,refresh:te,reveal:re,unview:ne,getSessionId:()=>b}}var oj=`board`,sj=`terminal`,cj=`changes`,lj=Object.freeze({[cj]:sj}),uj=Object.freeze([{id:oj,label:`Focus`,glyph:`▤`},{id:sj,label:`Terminal`,glyph:`▸`}]),dj=[],fj=new Map,pj=null,mj=new Map,hj=new Map,gj=new Map,_j=null,vj=null,yj=null,bj=null,xj=null,Sj=null,Cj=new Map,wj=new Set,Tj={},Ej=!1,Dj=120,Oj=0,kj=0,Aj=0,jj=null;function Mj(){Oj=0,kj=0}function Nj(){let e=window.visualViewport;pj&&(!Ej||!e?pj.removeAttribute(`data-keyboard`):(pj.style.setProperty(`--phone-vh`,`${e.height}px`),pj.style.setProperty(`--phone-vv-top`,`${e.offsetTop}px`),e.width!==kj&&(kj=e.width,Oj=0),Oj=Math.max(Oj,e.height),Oj-e.height>Dj?pj.dataset.keyboard=`open`:pj.removeAttribute(`data-keyboard`)))}function Pj(e,t,n=`phone-nav-item`,r=`phone-nav-dot`){let i=L(`button`,n);i.type=`button`;let a=L(`span`,`phone-nav-glyph`,t);a.setAttribute(`aria-hidden`,`true`),i.append(a,L(`span`,`phone-nav-label`,e));let o=L(`span`,r);return o.setAttribute(`aria-hidden`,`true`),o.hidden=!0,i.appendChild(o),i}function Fj(e){return e?.querySelector(`.phone-nav-dot`)||null}function Ij(e,t){e&&(e.hidden=!t,typeof t==`string`&&(e.dataset.attention=t),typeof t!=`string`&&delete e.dataset.attention)}function Lj(){let e=[];for(let t of dj){if(wj.has(t.id))continue;let n=gj.get(t.id)||!1;e.push(n),Ij(Fj(Cj.get(t.id)),n)}Ij(Fj(xj),Vc(e))}function Rj(){let e=L(`div`,`phone-nav-more-menu`);e.hidden=!0;for(let t of dj){let n=Pj(t.label,t.glyph,`phone-nav-menu-item`,`phone-nav-dot phone-nav-menu-dot`);n.dataset.screen=t.id,n.hidden=wj.has(t.id),n.addEventListener(`click`,()=>{zj(!1),aM(t.id)}),Cj.set(t.id,n),e.appendChild(n)}return e}function zj(e){Sj&&xj&&(Sj.hidden=!e,xj.setAttribute(`aria-expanded`,String(e)))}function Bj(){return!!Sj&&!Sj.hidden}function Vj(){let e=L(`nav`,`phone-nav`);e.setAttribute(`aria-label`,`Screens`);for(let t of uj){let n=Pj(t.label,t.glyph);n.dataset.screen=t.id,n.addEventListener(`click`,()=>aM(t.id)),mj.set(t.id,n),e.appendChild(n)}return xj=Pj(`More`,`⋯`),xj.setAttribute(`aria-expanded`,`false`),xj.addEventListener(`click`,()=>zj(!Bj())),e.appendChild(xj),Sj=Rj(),e.appendChild(Sj),e}function Hj(e,t,n){let r=L(`section`,`phone-screen`);return r.dataset.screen=e,r.setAttribute(`aria-label`,t),r.hidden=!0,n&&r.appendChild(n),hj.set(e,r),r}function Uj(){if(pj)return;_j=UA({onSelectSession:Gj}),en((e,t)=>{Ej&&_j?.renderActivity(e,t)}),vj=aj({onBack:()=>aM(oj),onShowChanges:()=>aM(cj)}),yj=L(`div`,`phone-review`);let e=L(`div`,`phone-screens`),t={[oj]:_j.el,[sj]:vj.el};for(let n of uj)e.appendChild(Hj(n.id,n.label,t[n.id]));e.appendChild(Hj(cj,`Changes`,Wj(yj)));for(let t of dj){let n=L(`div`,`phone-panel phone-${t.id}`);fj.set(t.id,n),e.appendChild(Hj(t.id,t.label,n))}pj=L(`div`,`phone-shell`),pj.id=`phone-shell`,pj.append(e,Vj()),document.body.appendChild(pj),Lj(),window.visualViewport?.addEventListener(`resize`,Nj),window.visualViewport?.addEventListener(`scroll`,Nj),window.addEventListener(`popstate`,eM),document.addEventListener(`click`,e=>{Bj()&&Sj&&xj&&e.target instanceof Node&&(Sj.contains(e.target)||xj.contains(e.target)||zj(!1))}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&Bj()&&zj(!1)})}function Wj(e){let t=L(`div`,`phone-changes-screen`),n=L(`header`,`phone-topbar phone-changes-bar`),r=L(`button`,`phone-back`,`‹`);return r.type=`button`,r.setAttribute(`aria-label`,`Back to terminal`),r.addEventListener(`click`,()=>aM(sj)),bj=L(`span`,`phone-changes-session`),n.append(r,L(`span`,`phone-changes-title`,`Changes`),bj),t.append(n,e),t}function Gj(e){if(H.has(e)){if(!_j||!vj)throw Error(`Phone shell is not built`);Nu(e,`dormant-fallback`),Pu(e),vj.show(e),aM(sj)}}function Kj(e){return lj[e]??e}function qj(e,t){return t?{glimmervoidScreen:e,glimmervoidNested:!0}:{glimmervoidScreen:Kj(e)}}function Jj(e){let t=e?.glimmervoidScreen;return typeof t==`string`?t:null}function Yj(e){return Jj(e)?e.glimmervoidNested===!0?2:1:0}function Xj(e){return e===oj?0:lj[e]||Tj.canGoBack?.(e)?2:1}function Zj(e,t){let n=t?e:Kj(e);return Jj(history.state)===n&&Yj(history.state)===(t?2:1)}function Qj(){if(!Ej||jj!==null)return;let e=W.snapshot().phoneScreen||oj,t=Xj(e);if(Aj>t){jj=location.href,history.go(t-Aj),Aj=t;return}let n=Aj===2;Aj>0&&!Zj(e,n)&&history.replaceState(qj(e,n),``),Aj===0&&t>0&&(history.pushState(qj(e,!1),``),Aj=1),Aj===1&&t===2&&(history.pushState(qj(e,!0),``),Aj=2)}function $j(){let e=Jj(history.state);return e&&rM(e)?(Aj=Yj(history.state),e):(e&&history.replaceState(null,``),Aj=0,oj)}function eM(e){if(!Ej)return;if(jj!==null){history.replaceState(history.state,``,jj),jj=null,Qj();return}let t=Jj(e.state),n=t&&rM(t)?t:oj;Aj=Yj(e.state);let r=W.snapshot().phoneScreen;Aj<2&&n===r&&Tj.canGoBack?.(r)&&Tj.onBack?.(r),nM(n),Qj()}function tM(e,t){for(let[n,r]of e)n===t?r.setAttribute(`aria-current`,`page`):r.removeAttribute(`aria-current`)}function nM(e){if(!xj||!vj)throw Error(`Phone shell is not built`);W.dispatch(`setPhoneScreen`,e),zj(!1),iM();for(let[t,n]of hj)n.hidden=t!==e;Tj.onScreenShown?.(e),tM(mj,Kj(e));let t=Cj.has(e);t&&xj.setAttribute(`aria-current`,`page`),t||xj.removeAttribute(`aria-current`),tM(Cj,e),e===sj?vj.reveal():vj.unview()}function rM(e){return hj.has(e)&&!wj.has(e)}function iM(){if(!bj||!vj)return;let e=vj.getSessionId(),t=e?H.get(e):null,n=t?tn(t):``;bj.textContent=n,bj.title=n}function aM(e){pj&&rM(e)&&(nM(e),Qj())}function oM(e){dj.sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id)),Sj?.append(...dj.flatMap(e=>Cj.get(e.id)??[]))}function sM(e){Tj=e||{},dj=Tj.panels||[]}function cM({sessionId:e,linkedScreenId:t}={}){if(Ej)return;if(Uj(),!pj||!_j||!vj)throw Error(`Phone shell is not built`);Ej=!0,pj.hidden=!1;for(let e of Tj.headerControls||[])jt(e,_j.topBarEl);oy(yj);for(let e of dj)jt(e.el,fj.get(e.id)),e.el.hidden=!1;Nj(),e&&vj.show(e);let n=$j();pM(),t&&rM(t)?aM(t):e&&n===oj?aM(sj):(nM(n),Qj())}function lM(){if(Ej){if(!pj||!vj)throw Error(`Phone shell is not built`);Ej=!1,vj.clear(),oy(null);for(let e of dj)lt(e.el);for(let e of Tj.headerControls||[])lt(e);zj(!1),pj.hidden=!0,pj.removeAttribute(`data-keyboard`),Mj(),Aj>0&&history.go(-Aj),Aj=0,jj=null}}function uM(e){return!Ej||!_j||!vj||!H.has(e)?!1:(Gj(e),Yw(e))}function dM(){return Ej}function fM(){return Ej&&vj?vj.getSessionId():null}function pM(){if(!Ej)return;if(!_j||!vj)throw Error(`Phone shell is not built`);vM(),_j.refresh(),vj.refresh(),iM(),Kj(W.snapshot().phoneScreen||oj)===sj&&!vj.getSessionId()&&aM(oj);let e=Fj(mj.get(oj));e&&(e.hidden=_j.getAttentionCount()===0)}function mM(e){return Ej?(Gj(e),!0):!1}function hM(e){return!Ej||!rM(e)?!1:(aM(e),!0)}function gM(e,t){t&&wj.delete(e),t||wj.add(e);let n=Cj.get(e);n&&(n.hidden=!t);let r=hj.get(e);r&&!t&&(r.hidden=!0),Lj(),!t&&Ej&&W.snapshot().phoneScreen===e&&aM(oj)}function _M(e,t){gj.set(e,typeof t==`string`&&t?t:t===!0),Lj()}function vM(){if(!vj)throw Error(`Phone shell is not built`);if(vj.getSessionId())return;let e=Fu();e&&(vj.show(e),Pu(e,{rememberFocus:!1}))}var yM={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},bM=new Set([`FAILURE`,`ERROR`]);function xM(e){return yM[e]}function SM(e){return e.state===`MERGED`?`Already merged`:e.state===`OPEN`?e.isDraft?`Drafts cannot be merged`:e.isInMergeQueue?`Already in the merge queue`:e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?`Resolve the merge conflicts first`:e.checks.failing.length>0||e.checks.state!==null&&bM.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function CM(e){return e.state===`MERGED`?`merged`:e.isDraft?`draft`:e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?`conflicts`:e.mergeStateStatus===`BEHIND`?`behind`:e.checks.state===`FAILURE`||e.checks.state===`ERROR`?`checks-failing`:e.reviewDecision===`CHANGES_REQUESTED`?`changes-requested`:e.unresolvedThreads>0?`unresolved-threads`:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?`checks-pending`:e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?`needs-approval`:e.mergeable===`MERGEABLE`&&[`CLEAN`,`HAS_HOOKS`,`UNSTABLE`].includes(e.mergeStateStatus)?`ready`:`unknown`}function wM(e){let t=We.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:CM(t)}}var TM=`> [!NOTE]
166
+ > Automated review. Not written by a human.`,EM=St.options.join(`|`),DM=String.raw`\*\*(?:\[([^\]\n]+)\]\s+)?(${EM})\*\*`;function OM(e){return[...e.matchAll(new RegExp(DM,`g`))].flatMap(e=>{let t=St.safeParse(e[2]);return t.success?[t.data]:[]})}function kM(e){let t=new RegExp(String.raw`^${DM}\s*(?:\r?\n|$)`).exec(e);if(!t)return null;let n=St.safeParse(t[2]);return n.success?{reviewer:t[1]??null,severity:n.data,length:t[0].length}:null}function AM(e){let t=e.trimStart();return t.startsWith(`> [!NOTE]
167
+ > Automated review. Not written by a human.`)?t.slice(53).trim():e.trim()}var jM=`(line not in the diff)`,MM=String.raw`- ${DM}`,NM=String.raw`\*\*\x60([^\x60\n]+)\x60\*\* ${jM.replace(/[()]/g,`\\$&`)}`,PM=new RegExp(String.raw`^(?:${MM}|${NM})`,`gm`),FM=new RegExp(String.raw`^${MM}\s*(?:\x60([^\x60\n]+)\x60:\s*)?`),IM=new RegExp(String.raw`^${NM}\s*`);function LM(e){return St.options.find(t=>e.includes(t))??null}function RM(e){let t=FM.exec(e);if(t)return{severity:St.parse(t[2]),location:t[3]??null,body:e.slice(t[0].length).trim(),markdown:e};let n=IM.exec(e),r=n?e.slice(n[0].length).trim():e;return{severity:LM(OM(r)),location:n?.[1]??null,body:r,markdown:e}}function zM(e){let t=AM(e),n=t.search(PM);return(n===-1?t:t.slice(0,n)).trim()}function BM(e){let t=AM(e),n=[...t.matchAll(PM)].map(e=>e.index);return n.map((e,r)=>t.slice(e,n[r+1]).trim()).filter(Boolean).map(RM)}function VM(e,t){return!!e?.error&&!e.isRefreshing&&typeof e.nextAttemptAt==`number`&&e.nextAttemptAt>t}function HM(e,t){if(!e?.error)return null;let n=e.error.trim().replace(/[.!]+$/,``),r=e.incident?.trim().replace(/[.!]+$/,``),i=`Could not reach GitHub: ${n}.${r?` GitHub reports: ${r}.`:``}`;if(e.isRefreshing)return`${i} Refreshing.`;if(typeof e.nextAttemptAt!=`number`)return i;let a=Math.max(0,Math.ceil((e.nextAttemptAt-t)/1e3));return a===0?`${i} Retrying now.`:e.retry?`${i} Retrying in ${a}s (${e.retry.attempt} of ${e.retry.limit}).`:`${i} Next try in ${a>=60?`${Math.ceil(a/60)} min`:`${a}s`}.`}function UM(e,t,n){return e?.refreshNotice&&e.isRefreshing?e.refreshNotice:t||e?.isRefreshing?`Refreshing`:n||e?.refreshNotice||``}function WM(e,t){let n=e?.lastRefreshedAt??e?.lastSyncAt??null;if(n===null)return null;let r=Math.max(0,t-n);return!e?.error&&r<=3e5?null:r<6e4?`Last updated less than a minute ago.`:r<36e5?`Last updated ${Math.floor(r/6e4)} min ago.`:`Last updated ${Math.floor(r/36e5)} h ago.`}function GM(e,t,n,r,i,a){return{isVisible:a&&(e.state===`OPEN`||t),isPressed:t,isDisabled:n,statusText:r||(n?`Saving`:i),tone:r?`error`:n?`busy`:null}}function KM(e,t,n=``){if(!t||!e.keepMergeable)return null;let r=qM(e,!1,``,!0,n).statusText;if(e.isKeepMergeableFixInFlight)return{text:`Repairing`,tone:`warn`,title:r};let i=e.keepMergeableAttempt;return!i||i.outcome===`pushed`||i.outcome===`stopped`?null:{text:`Repair failed`,tone:`danger`,title:r}}function qM(e,t,n=``,r=!0,i=``){let a=e.keepMergeableAttempt,o=e.keepMergeable?`On`:`Off`;if(e.keepMergeable&&a&&a.outcome!==`pushed`&&a.outcome!==`stopped`){let e=i?` (${i})`:``;o=`Keep mergeable failed: ${a.reason??`The attempt produced no repair`}${e}`}return e.isKeepMergeableFixInFlight&&(o=`Keep mergeable is running`),GM(e,!!e.keepMergeable,t,n,o,r)}function JM(e){return e?.isKeepMergeableEnabled!==!1}function YM(e){return e?.isMergeQueueEnabled!==!1}function XM(e,t,n){return e?t?`Repair pushed, waiting for you`:n?`On, the last merge failed and retries an hour later once it is ready`:`On, merges as soon as it is ready`:`Not queued`}function ZM(e,t,n=``,r=!0){let i=e.mergeQueuePosition!==null&&e.mergeQueuePosition!==void 0;return GM(e,i,t,n,XM(i,!!e.isMergeQueueHeldForRepairPush,!!e.mergeQueueFailure),r)}var QM=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],$M=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],eN={conflicts:`Needs you`,behind:`Needs you`,"checks-failing":`Needs you`,"changes-requested":`Needs you`,"unresolved-threads":`Needs you`,"checks-pending":`Waiting`,"needs-approval":`Waiting`,unknown:`Waiting`,ready:`Ready to merge`,draft:`Drafts`,merged:`Merged today`},tN={merged:`Merged`,draft:`Draft`,conflicts:`Merge conflicts`,behind:`Behind base`,"checks-failing":`Checks failing`,"changes-requested":`Changes requested`,"unresolved-threads":`Unresolved threads`,"checks-pending":`Checks running`,"needs-approval":`Needs approval`,ready:`Ready to merge`,unknown:`Status unknown`},nN={merged:`muted`,draft:`muted`,conflicts:`danger`,behind:`warn`,"checks-failing":`danger`,"changes-requested":`warn`,"unresolved-threads":`warn`,"checks-pending":`wait`,"needs-approval":`wait`,ready:`ok`,unknown:`muted`},rN={merged:`merged`,draft:`draft`,conflicts:`conflict`,behind:`behind`,"checks-failing":`failed`,"changes-requested":`changes-requested`,"unresolved-threads":`thread`,"checks-pending":`running`,"needs-approval":`reviewer`,ready:`ready`,unknown:`unknown`};function iN(e){let t=e.filter(e=>e.state===`OPEN`&&!e.isCrossRepository),n=new Map(t.map(e=>[JSON.stringify([e.repo.toLowerCase(),e.headRefName]),e])),r=new Map,i=[];for(let t of e){let e=t.state===`OPEN`?n.get(JSON.stringify([t.repo.toLowerCase(),t.baseRefName])):void 0;if(!e||e.key===t.key){i.push(t);continue}let a=r.get(e.key)??[];a.push(t),r.set(e.key,a)}let a=[],o=new Set;for(let t of[...i,...e]){if(o.has(t.key))continue;let e=[],n=[{pr:t,parentKey:null,depth:0}];for(;n.length>0;){let t=n.pop();if(!t||o.has(t.pr.key))continue;o.add(t.pr.key),e.push(t);let i=r.get(t.pr.key)??[];for(let e=i.length-1;e>=0;--e)n.push({pr:i[e],parentKey:t.pr.key,depth:t.depth+1})}a.push({root:t,rows:e})}return a}function aN(e){return QM[e.rows.reduce((e,{pr:t})=>Math.min(e,QM.indexOf(eN[t.stage])),QM.length-1)]}function oN(e){let t=new Map(QM.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of iN(e)){let e=t.get(aN(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return $M.flatMap(e=>t.get(e)??[])}function sN(e){return tN[e]}function cN(e){return nN[e]}function lN(e){return rN[e]}function uN(e){return e.checks.failing.length>0?{label:`Checks`,tone:`danger`,icon:`failed`,text:`${e.checks.failing.length} failing`,items:e.checks.failing}:e.checks.state===`FAILURE`||e.checks.state===`ERROR`?{label:`Checks`,tone:`danger`,icon:`failed`,text:`Failing`}:e.checks.pendingCount>0?{label:`Checks`,tone:`wait`,icon:`running`,text:`${e.checks.pendingCount} running`}:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?{label:`Checks`,tone:`wait`,icon:`running`,text:`Running`}:e.checks.state===`SUCCESS`?{label:`Checks`,tone:`ok`,icon:`passed`,text:`Passing`}:{label:`Checks`,tone:`muted`,icon:`none`,text:`No checks`}}function dN(e){return`${e} ${e===1?`approval`:`approvals`}`}function fN(e){return e.reviewRequests.map(e=>e.name).join(`, `)}function pN(e){let t=e.reviewRequests.length>0?`Requested: ${fN(e)}`:`Approval required`;return e.approvals>0?`${t}, ${dN(e.approvals)}`:t}function mN(e){let t=e.approvals>0?dN(e.approvals):`Approved`;return e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`${t}, merge blocked`}:{label:`Review`,tone:`ok`,icon:`passed`,text:t}}function hN(e){return e.reviewDecision===`CHANGES_REQUESTED`?{label:`Review`,tone:`warn`,icon:`changes-requested`,text:`Changes requested`}:e.reviewDecision===`APPROVED`?mN(e):e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:pN(e)}:e.reviewRequests.length>0?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`Requested: ${fN(e)}`}:{label:`Review`,tone:`muted`,icon:`none`,text:`No review requested`}}function gN(e,t){return t?e.lastAuthor!==t:null}function _N(e){let t=e.line===null?e.path:`${e.path}:${e.line}`;return e.isOutdated?`${t} (outdated)`:t}function vN(e){let t=e.commentCount-1;return t===0?`No replies`:`${t} ${t===1?`reply`:`replies`}, last by ${e.lastAuthor??`a deleted account`}`}function yN(e,t){let n=gN(e,t);return n===null?null:n?{tone:`warn`,icon:`your-turn`,text:`Waiting on you`}:{tone:`wait`,icon:`reviewer`,text:`Waiting on reviewer`}}function bN(e,t){return[...e.threads].sort((e,n)=>{let r=Number(gN(n,t)===!0)-Number(gN(e,t)===!0);return r===0?(Date.parse(n.lastActivityAt)||0)-(Date.parse(e.lastActivityAt)||0):r}).map(e=>({location:_N(e),url:e.url,author:e.author??`a deleted account`,excerpt:e.excerpt,replySummary:vN(e),lastActivityAt:e.lastActivityAt,waiting:yN(e,t),isWaitingOnYou:gN(e,t)===!0}))}function xN(e,t){if(e.unresolvedThreads===0)return{label:`Threads`,tone:`ok`,icon:`passed`,text:`None open`};let n=`${e.unresolvedThreads} unresolved`;if(!t||e.threads.length===0)return{label:`Threads`,tone:`warn`,icon:`thread`,text:n};let r=e.threads.filter(e=>gN(e,t)).length;return r===0?{label:`Threads`,tone:`wait`,icon:`thread`,text:`${n}, all waiting on reviewers`}:{label:`Threads`,tone:`warn`,icon:`your-turn`,text:`${n}, ${r} waiting on you`}}function SN(e){return e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?{label:`Conflicts`,tone:`danger`,icon:`conflict`,text:`Conflicts with ${e.baseRefName}`}:e.mergeable===`MERGEABLE`?{label:`Conflicts`,tone:`ok`,icon:`passed`,text:`None`}:{label:`Conflicts`,tone:`muted`,icon:`unknown`,text:`Not computed yet`}}function CN(e){let t=e.behindBy!==null&&e.behindBy>0;return e.mergeStateStatus===`BEHIND`?{label:`Base`,tone:`warn`,icon:`behind`,text:t?`${e.behindBy} behind ${e.baseRefName}`:`Behind ${e.baseRefName}`}:e.behindBy===null?{label:`Base`,tone:`muted`,icon:`unknown`,text:`Unknown`}:t?{label:`Base`,tone:`muted`,icon:`behind`,text:`${e.behindBy} behind ${e.baseRefName}, update not required`}:{label:`Base`,tone:`ok`,icon:`passed`,text:`Up to date with ${e.baseRefName}`}}var wN={APPROVED:{text:`Approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{text:`Requested changes`,tone:`warn`,icon:`changes-requested`},COMMENTED:{text:`Commented`,tone:`muted`,icon:`thread`},DISMISSED:{text:`Dismissed`,tone:`muted`,icon:`discarded`},PENDING:{text:`Pending`,tone:`wait`,icon:`running`}};function TN(e){return[...e.reviews].sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).map(e=>{let t=wN[e.state]??{text:e.state.toLowerCase().replaceAll(`_`,` `),tone:`muted`,icon:`unknown`};return{reviewer:e.reviewer??`a deleted account`,text:t.text,tone:t.tone,icon:t.icon,submittedAt:e.submittedAt}})}var EN={danger:0,warn:1,wait:2,muted:3,ok:4};function DN(e,t=null){if(e.state===`MERGED`)return[];let n=[uN(e),hN(e),xN(e,t),SN(e),CN(e)],r=e.autoRebase?[ON(e,e.autoRebase)]:[],i=e.mergeQueueFailure?[{label:`Merge when ready`,tone:`danger`,icon:`failed`,text:`Merge failed: ${e.mergeQueueFailure.message}`}]:[];return[...n,...r,...i].toSorted((e,t)=>EN[e.tone]-EN[t.tone])}function ON(e,t){return t.outcome===`rebased`?{label:`Auto-rebase`,tone:`ok`,icon:`passed`,text:t.message}:{label:`Auto-rebase`,tone:e.mergeStateStatus===`BEHIND`?`danger`:`warn`,icon:`failed`,text:t.message}}function kN(e){return e?e.configured?e.error&&e.prs.length===0?`Pull requests will show here once GitHub answers.`:`No open or recently merged pull requests found.`:`Enable Team review and set its GitHub organization in settings to see your pull requests.`:`Waiting for your pull requests.`}function AN(e,t=0){if(!e)return[];let n=HM(e,t),r=n?[{text:n,tone:`error`}]:[];return e.truncatedNote?[...r,{text:e.truncatedNote,tone:`info`}]:r}function jN(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...wM({...n,repo:r}),...e}]})}function MN(e){let t=new Map;for(let n of e)for(let e of n.links){let r=ot(e),i=t.get(r)??[];i.at(-1)?.id!==n.id&&(i.push({id:n.id,title:n.title}),t.set(r,i))}return t}function NN(e,t){if(!e)return[];let n=new Set(e.filter(e=>e.state===`OPEN`).map(e=>e.key));return t.filter(e=>e.state===`MERGED`&&n.has(e.key))}var PN=3;function FN(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,PN).map(e=>`${e.key} ${e.title}`),n=e.length-t.length,r=n>0?[...t,`and ${n} more`]:t;return{message:`Merged ${e.length} pull requests`,detailLines:r}}var IN={isVisible:!1,isDisabled:!0,statusText:``,tone:null},LN={merged:{statusText:`Merged on GitHub. Refreshing the list.`,tone:`ok`},queued:{statusText:`Added to the merge queue. Refreshing the list.`,tone:`ok`},"auto-merge":{statusText:`Auto-merge enabled. GitHub merges it once its requirements pass.`,tone:`ok`},unconfirmed:{statusText:`GitHub accepted the request but did not confirm a merge. Check GitHub.`,tone:null}};function RN(e,t){if(e.state!==`OPEN`)return IN;let n=t?.head===e.headRefOid?t:void 0;if(n?.phase===`pending`)return{isVisible:!0,isDisabled:!0,statusText:`Merging on GitHub`,tone:`busy`};if(n&&n.phase!==`failed`)return{isVisible:!0,isDisabled:!0,...LN[n.phase]};let r=SM(e);return r?{isVisible:!0,isDisabled:!0,statusText:r,tone:null}:n?.phase===`failed`?{isVisible:!0,isDisabled:!1,statusText:n.text,tone:`error`}:{isVisible:!0,isDisabled:!1,statusText:`Merges into ${e.baseRefName} with ${xM(e.mergeMethod)}`,tone:null}}function zN(e){return`Merge ${e.key} "${e.title}" into ${e.baseRefName} with ${xM(e.mergeMethod)}, your default for this repository. Glimmervoid does not delete the branch.`}function BN(e){let t=xe.safeParse(e);if(!t.success)return null;let n=e&&typeof e==`object`&&`requestId`in e?e.requestId:null;return typeof n==`string`?{...t.data,requestId:n}:null}function VN(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:Xe(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,liveHead:n.headRefOid,prStage:wM(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n),handReview:e.handReview.map(n)}}var HN={"direct-request":`Needs you`,"team-request":`Ready`,"changes-requested":`Author to fix`,"checks-failing":`Checks failing`,"checks-pending":`Checks running`,draft:`Draft`,"review-available":`Ready`,approved:`Approved`};function UN(e){return e.isDraft?{band:`not-ready`,reason:`draft`}:e.reviewDecision===`CHANGES_REQUESTED`?{band:`waiting-on-author`,reason:`changes-requested`}:e.checksState===`FAILURE`||e.checksState===`ERROR`?{band:`waiting-on-author`,reason:`checks-failing`}:e.checksState===`PENDING`||e.checksState===`EXPECTED`?{band:`not-ready`,reason:`checks-pending`}:e.requestSource===`direct`&&e.reviewDecision===`REVIEW_REQUIRED`?{band:`blocking-others`,reason:`direct-request`}:e.reviewDecision===`APPROVED`?{band:`actionable`,reason:`approved`}:{band:`actionable`,reason:e.requestSource===`direct`?`review-available`:`team-request`}}var WN={APPROVE:{label:`You approved`,tone:`ok`,icon:`passed`},COMMENT:{label:`You commented`,tone:`muted`,icon:`thread`}},GN={APPROVED:{label:`You approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{label:`You requested changes`,tone:`wait`,icon:`changes-requested`},COMMENTED:{label:`You commented`,tone:`muted`,icon:`thread`}};function KN(e){let t=(e.githubReviews??[]).filter(e=>e.isViewer).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!e.postedEvent)return t?GN[t.state]:null;if(!t)return WN[e.postedEvent];let n=Date.parse(t.submittedAt??``);return Number.isNaN(n)||e.postedAt!==void 0&&e.postedAt>n?WN[e.postedEvent]:GN[t.state]}var qN={"changes-requested":`changes-requested`,"checks-failing":`failed`,"checks-pending":`running`,draft:`draft`};function JN(e){let{reason:t}=UN(e),n=qN[t];return n?{text:HN[t],icon:n}:null}function YN(e){return JN(e)?.text??null}var XN={discarded:{tone:`muted`,icon:`discarded`,meaning:`Not mine`},handReview:{tone:`warn`,icon:`fork`,meaning:`From a fork`}};function ZN(e,t){let n=YN(t);return n?`${e}, ${n}`:e}function QN(e){if(Ct(e))return!0;let t=(e.githubReviews??[]).filter(e=>e.isViewer);return t.length===0||t.some(t=>t.commit===TP(e))}var $N={tone:`warn`,icon:`your-turn`,meaning:`Comments resolved`};function eP(e,t){if(e.prStage)return{tone:cN(e.prStage),icon:lN(e.prStage),meaning:sN(e.prStage)};let n=XN[t];if(n)return n;if(t===`inReview`)return{tone:`wait`,icon:`running`,meaning:ZN(`In review`,e)};if(t===`queued`)return{tone:`muted`,icon:`queued`,meaning:ZN(`Queued`,e)};if(t===`settled`&&`reviewedHead`in e){let t=QN(e)?KN(e):null;return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`ok`,icon:`passed`,meaning:`Others reviewed`}}if(t===`posted`&&`reviewedHead`in e){let t=KN(e);return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`muted`,icon:`none`,meaning:`Posted`}}if(t===`attention`&&`status`in e)return e.status===`error`?{tone:`danger`,icon:`failed`,meaning:`Review failed`}:{tone:`warn`,icon:`stale`,meaning:`Out of date`};let r=JN(e);return r?{tone:`wait`,icon:r.icon,meaning:r.text}:t===`ready`&&`reviewedHead`in e&&rP(e)?$N:{tone:`warn`,icon:`your-turn`,meaning:`Waits on you`}}function tP(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function nP(e){return e.status===`posted`&&rP(e)}function rP(e){if(!tP(e)||Ct(e))return!1;let t=TP(e);return e.status===`posted`&&e.postedEvent===`APPROVE`&&e.reviewedHead===t?!1:!(e.githubReviews??[]).some(e=>e.isViewer&&e.state===`APPROVED`&&e.commit===t)}function iP(e){return!e||e.total===0?null:e.total===1?e.resolved===1?`Your 1 comment resolved`:`Your 1 comment unresolved`:e.resolved===e.total?`All ${e.total} of your comments resolved`:`${e.resolved} of ${e.total} of your comments resolved`}function aP(e){return`${e} ${e===1?`comment`:`comments`}`}function oP(e,t,n){let r=[`${$P(e.repo,e.number)}: ${e.title}`],i=`reviewedHead`in e?e.assessment?.goal.trim():``;if(i&&r.push(i),r.push(eP(e,t).meaning),n.opened&&r.push(`Opened ${n.opened}`),n.reviewed&&r.push(`Reviewed ${n.reviewed}`),n.posted&&r.push(`Posted ${n.posted}`),!(`reviewedHead`in e))return r.join(`
168
+ `);let a=iP(e.viewerThreads);a&&r.push(a);let o=e.comments.length;e.status!==`error`&&r.push(`Automated review: ${_P(e.verdict)}, ${aP(o)}`);let s=NP(e);s&&r.push(`You ${yP[s.state]} at ${At(s.approvedCommit)}${n.viewerApproval?` ${n.viewerApproval}`:``}; new commits since.`),(t===`attention`||t===`discarded`)&&r.push(_F(e));let c=LP(e,{isViewerShown:t!==`posted`});for(let[e,t]of c.entries())r.push(IP(t.text,n.githubReviews?.[e]??null));return r.join(`
169
+ `)}function sP(e){let t=e.trim();return t.endsWith(`.`)?t:`${t}.`}var cP=new Set([`approve`,`approve-only`,`comment`]);function lP({action:e,outcomeText:t,pullRequest:n,warning:r,isActedSelected:i}){let a=`${n}: ${sP(t)}`;return r.trim()?{statusText:t,shouldAdvance:!1,notice:{text:`${a} ${sP(r)}`,tone:`error`}}:{statusText:t,shouldAdvance:i,notice:i&&cP.has(e)?{text:a,tone:`ok`}:null}}function uP(e,t,n){return n?$P(e,t):`#${t}`}var dP={CRITICAL:{filledCount:3,colorToken:`--state-failed`},HIGH:{filledCount:3,colorToken:`--state-waiting`},MEDIUM:{filledCount:2,colorToken:`--accent`},LOW:{filledCount:1,colorToken:`--text-dim`}},fP={APPROVE:`check`,"APPROVE WITH NITS":`dot`,"REQUEST CHANGES":`bar`,BLOCKED:`cross`},pP=`lanes-team-review`,mP=`team-review-enabled`,hP=Object.freeze({APPROVE:`approve`,"APPROVE WITH NITS":`approve with nits`,"REQUEST CHANGES":`request changes`,BLOCKED:`blocked`}),gP={APPROVE:`Approve`,"APPROVE WITH NITS":`Nits`,"REQUEST CHANGES":`Changes`,BLOCKED:`Blocked`};function _P(e){return gP[e]}var vP=Object.freeze({APPROVE:`ok`,"APPROVE WITH NITS":`info`,"REQUEST CHANGES":`warn`,BLOCKED:`crit`}),yP=Object.freeze({APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`commented`}),bP=Object.freeze({preparing:`fetching the diff`,checkout:`checking out the head`,reviewing:`agent reviewing`}),xP=Object.freeze({approve:`Approved on GitHub`,"approve-only":`Approved on GitHub`,comment:`Comment posted on GitHub`,discard:`Marked not mine. Not reviewed again until you re-run it.`,requeue:`Queued. The review starts as soon as a slot is free.`,"resolve-thread":`Thread resolved on GitHub`}),SP=Object.freeze({approve:`Posting the approval`,"approve-only":`Posting the approval`,comment:`Posting the comment`,discard:`Marking not mine`,requeue:`Queueing the review`,"resolve-thread":`Resolving thread`});function CP(e){let t={ready:[],noReviewNeeded:[],inReview:[],queued:[],handReview:[],attention:[],posted:[],discarded:[]};if(!e)return t;let n={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},r={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},i=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`],a=new Set(e.inFlight.map(e=>e.key));t.inReview.push(...e.inFlight);let o=new Set(e.drafts.filter(e=>EP(e).length>0).map(e=>e.key));t.handReview.push(...e.handReview.filter(e=>!a.has(e.key)&&!o.has(e.key)));let s=new Set(t.handReview.map(e=>e.key));for(let t of e.queued)a.has(t.key)||s.has(t.key)||r[UN(t).band].push(t);for(let e of i)t.queued.push(...r[e]);let c=new Set(t.queued.map(e=>e.key));for(let r of e.drafts){if(a.has(r.key)||c.has(r.key)||s.has(r.key))continue;if(EP(r).length>0||nP(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!jP(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[UN(r).band].push(r),(r.status===`stale`||r.status===`error`)&&!e&&t.attention.push(r),r.status===`posted`&&t.posted.push(r),r.status===`discarded`&&t.discarded.push(r)}for(let e of i)t.ready.push(...n[e]);return t}function wP(e,t){return e.commit===t?e.isViewer||Nt.has(e.state):!1}function TP(e){return e.liveHead??e.reviewedHead}function EP(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function DP(e,t){if(e.isNit)return{label:`Automatic resolution failed`,reason:``,tone:`warn`};let n=e.judgement?.head===t&&e.judgement.lastReplyAt===e.lastReplyAt?e.judgement:void 0;if(n)return{label:n.addressed?`Addressed`:`Not addressed`,reason:n.reason,tone:n.addressed?`ok`:`warn`};let r=e.unjudgeable?.head===t&&e.unjudgeable.lastReplyAt===e.lastReplyAt?e.unjudgeable:void 0;return r?{label:`Auto-check skipped`,reason:r.reason,tone:`muted`}:{label:`Auto-check pending`,reason:``,tone:`muted`}}function OP(e){return(e.threads??[]).filter(e=>!e.isResolved&&(!e.isNit||e.resolveError)).map(t=>{let n=DP(t,TP(e));return{thread:t,location:t.line===null?t.path:`${t.path}:${t.line}`,judgementLabel:n.label,judgementReason:n.reason,judgementTone:n.tone,judgementText:n.reason?`${n.label}: ${n.reason}`:n.label,canResolve:t.viewerCanResolve}})}var kP=40;function AP(e,t){return e.split(`
170
+ `).reduce((e,t)=>e+Math.max(1,Math.ceil(t.length/kP)),0)>t}function jP(e){return EP(e).length>0?!0:Ct(e)?!1:rP(e)?!0:!(e.githubReviews??[]).some(t=>wP(t,TP(e)))}function MP(e,t){let n=yP[e.state];return e.isViewer?e.commit===t?`you ${n}`:`you ${n} (older commit)`:`${n} by ${e.login}`}function NP(e){if(Ct(e))return null;let t=(e.githubReviews??[]).filter(e=>e.isViewer&&Nt.has(e.state)).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!t?.commit||t.commit===TP(e)||t.state===`COMMENTED`)return null;let n=Date.parse(t.submittedAt??``);return e.reviewedAt!==void 0&&n>e.reviewedAt?null:{approvedCommit:t.commit,submittedAt:t.submittedAt,state:t.state,isReviewScopeSinceDecision:e.priorReviewedHead===t.commit}}function PP(e,t){let n=e.state===`APPROVED`?`approved this`:`requested changes`,r=e.state===`APPROVED`?`your approval`:`your request for changes`,i=`You ${n} at ${At(e.approvedCommit)}${t?` ${t}`:``}. It has new commits since`;return e.isReviewScopeSinceDecision?`${i}, so this review covers what changed after ${r}.`:`${i}.`}function FP(e){return e===`APPROVED`?`ok`:e===`CHANGES_REQUESTED`?`warn`:`muted`}function IP(e,t){return t?`${e}, ${t}`:e}function LP(e,{isViewerShown:t=!0}={}){return(e.githubReviews??[]).filter(e=>t||!e.isViewer).sort((e,t)=>Number(t.isViewer)-Number(e.isViewer)).map(t=>({login:t.login,tone:FP(t.state),text:MP(t,TP(e)),submittedAt:t.submittedAt}))}function RP(e){return dP[e]}function zP(e){return fP[e]}function BP(e){let t=OM(e.body);return t.length>0?t:e.severity?[e.severity]:[]}function VP(e){return LM(BP(e))}function HP(e){return e!==`LOW`}function UP(e){return HP(VP(e))}var WP=new Set(`ts.tsx.js.jsx.mjs.cjs.json.jsonc.css.scss.less.html.md.mdx.py.go.rs.rb.java.kt.kts.swift.c.h.cc.cpp.hpp.cs.php.sh.bash.zsh.yml.yaml.toml.ini.sql.vue.svelte.astro.lock.txt.ex.exs.erl.scala.dart.lua.tf.proto.graphql.gql.xml.gradle`.split(`.`)),GP=/^([\w.@~/-]+):\d+(?:-\d+)?$/;function KP(e){let t=GP.exec(e)?.[1];if(t===void 0)return!1;let n=t.slice(t.lastIndexOf(`/`)+1),r=n.lastIndexOf(`.`);return r<0?!1:WP.has(n.slice(r+1).toLowerCase())}var qP=/^```([^\n`]*)\n([\s\S]*?)^```[ \t]*(?=\r?$)/gm;function JP(e){let t=[],n=0;for(let r of e.matchAll(/`([^`\n]+)`/g)){let i=r.index??0;i>n&&t.push({text:e.slice(n,i),kind:`text`});let a=r[1]??``;t.push({text:a,kind:KP(a)?`citation`:`code`}),n=i+r[0].length}return n<e.length&&t.push({text:e.slice(n),kind:`text`}),t}function YP(e){return e.split(/\r?\n\s*\r?\n/).filter(Boolean).map(e=>{let t=e.match(/^(Suggested fix:|Fix:|Open question[.,:])\s*/),n=t?.[1]??``;return{kind:`prose`,lead:n,leadKind:n.startsWith(`Open question`)?`question`:n?`fix`:null,segments:JP(e.slice(t?.[0].length??0))}})}function XP(e){let t=AM(e),n=kM(t),r=n?t.slice(n.length).trim():t,i=[],a=0;for(let e of r.matchAll(qP)){let t=e.index??0;i.push(...YP(r.slice(a,t).trim()));let n=(e[1]??``).trim().split(/\s+/)[0]||null;i.push({kind:`code`,language:n,code:(e[2]??``).replace(/\r?\n$/,``)}),a=t+e[0].length}return i.push(...YP(r.slice(a).trim())),{tag:n?.reviewer??null,severity:n?.severity??null,paragraphs:i}}function ZP(e){let t=e.find(e=>e.kind===`prose`);if(!t)return`Open comment`;let n=`${t.lead} ${t.segments.map(e=>e.text).join(``)}`.trim(),r=n.search(/[.!?](?=\s|$)/);return(r<0?n:n.slice(0,r+1))||`Open comment`}function QP(e){let t=[`Fetch the diff`,`Check out the head`,`Review`,`Draft ready`],n={preparing:0,checkout:1,reviewing:2}[e];return t.map((e,t)=>({label:e,state:t<n?`done`:t===n?`active`:`todo`}))}function $P(e,t){return`${e}#${t}`}function eF(e){return e===`full`?`full`:`light`}function tF(e){return e.priorReviewedHead?`${eF(e.tier)} review of changes since ${At(e.priorReviewedHead)}`:`${eF(e.tier)} review`}function nF(e){return e.reasons.join(`, `)}function rF(e){if(!e)return[];let t=[],n=e.goal.trim(),r=e.change.trim();return n&&t.push({kind:`goal`,text:n}),r&&t.push({kind:`change`,text:r}),t}var iF=`This review ran before plain summaries existed, so only its verdict and findings remain. Re-run review to get a plain summary.`,aF=new Set([`error`,`stale`,`discarded`,`posted`]);function oF(e){return aF.has(e)}function sF(e){return e.liveHead&&e.liveHead!==e.reviewedHead?e.liveHead:null}function cF(e){let t=sF(e);return t?`Reviewed at ${At(e.reviewedHead)}. The pull request is now at ${At(t)}.`:null}function lF(e){let t=sF(e);return t?`https://github.com/${e.repo}/compare/${e.reviewedHead}...${t}`:null}function uF(e){let t=[`at ${At(e.head)}`,aP(e.comments.length)];return e.wasPosted&&t.push(`posted`),t.join(`, `)}function dF(e){let t=fF(e);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function fF(e){return hP[e]??String(e).toLowerCase()}function pF(e){return vP[e]??`dim`}function mF(e){return bP[e]??e}function hF(e,t){return`${N(t-e.startedAt)} elapsed`}function gF(e,t){let n=[hF(e,t)],r=e.deadlineAt===null?0:e.deadlineAt-t;return r>0&&n.push(`times out in ${N(r)}`),e.phase===`reviewing`&&n.push(`${e.toolCalls} ${e.toolCalls===1?`tool call`:`tool calls`}`),n.join(`, `)}function _F(e){return e.status===`stale`&&e.earlierReview?`Out of date. New commits landed after this review, so its findings may not match the code any more. Automatic review runs after the configured wait; Re-run review starts it now and hands it these findings.`:e.status===`stale`?`Out of date. New commits landed after this review, so its findings may not match the code any more. Automatic review runs after the configured wait; Re-run review starts it now.`:e.status===`discarded`?`Marked not mine. Not reviewed again until you re-run it.`:e.error||e.summary||`The review failed.`}function vF(e,t){let n=t.side===`LEFT`?` (old)`:``;return`${e}:${t.line}${n}`}function yF(e){return vF(e.path,e)}function bF(e){return vF(e.path.split(`/`).filter(Boolean).at(-1)??e.path,e)}function xF(e,t){let n=e.trim();return n?t.trim()?`${n}\n\n${t}`:n:t}function SF(e){return{key:e,action:`discard`,body:``,comments:[]}}function CF(e,t,n,r,i){return t===`approve-only`?{key:e.key,head:e.reviewedHead,action:t,body:``,comments:[]}:{key:e.key,head:e.reviewedHead,action:t,body:n,...i?{threadId:i}:{},comments:r.map(({path:e,line:t,side:n,body:r})=>({path:e,line:t,side:n,body:r}))}}function wF(e){return e.note.trim()!==``||e.comments.length>0||e.generalFindings.length>0}function TF(e,t,n){return t===`approve`&&!wF(n)?CF(e,`approve-only`,``,[]):CF(e,t,xF(n.note,[TM,zM(e.body),...n.generalFindings.map(e=>e.markdown)].filter(Boolean).join(`
171
171
 
172
- `)),n.comments)}function TF(e){let t=e.comments.length+e.generalFindings.length;return[e.note.trim()?`your note`:``,t?`${t} ${t===1?`finding`:`findings`}`:``].filter(Boolean).join(` and `)}function EF(e,t){let n=TF(t);return n?`Posts ${n}, labeled as an automated review, at ${At(e.reviewedHead)}.`:`Nothing ticked: Approve posts a bare approval, Comment needs a finding or a note.`}function DF(e,t){let n=TF(t);return e===`approve`&&n?`Approved on GitHub with ${n}`:e===`comment`&&n?`Commented on GitHub with ${n}`:MF(e)}var OF=Object.freeze({approve:`Approve`,"approve-only":`Approve`,comment:`Comment`,discard:`Not mine`,requeue:`Re-run review`,"resolve-thread":`Resolve`});function kF(e){return OF[e]}function AF(e){return e.status===`ready`?{primary:[`approve`,`comment`],secondary:[`requeue`,`discard`]}:ft(e)?{primary:[`approve-only`],secondary:[`requeue`]}:e.status===`error`||e.status===`stale`?{primary:[`requeue`],secondary:[`discard`]}:aF(e.status)?{primary:[`requeue`],secondary:[]}:{primary:[],secondary:[]}}function jF(e){return xP[e]}function MF(e){return bP[e]}function NF(e){return e===0?`Picked for review. It starts on the next poll.`:`Waiting for a free review slot. It starts as soon as ${e===1?`the review`:`one of the ${e} reviews`} in progress finishes.`}function PF(e){return e?e.configured?e.error?`Review drafts will show here once GitHub answers.`:`No review drafts yet. New teammate pull requests show up here after the next poll.`:e.reason?`Team review is not running: ${e.reason}.`:`Team review is off.`:`Waiting for the team review lane.`}function FF(e){return e?.configured&&e.reason||null}function IF(e){return`${e.key}@${e.reviewedHead}:${e.status}:${e.summary}:${IP(e).map(e=>e.text).join(`, `)}`}function LF(e){return`reviewedHead`in e?JSON.stringify([e.prCreatedAt,e.reviewedAt,e.postedAt,e.githubReviews,e.liveHead,e.priorReviewedHead,e.viewerThreads]):JSON.stringify([e.prCreatedAt,e.priorReviewedHead])}var RF=null,zF=null,BF=new Set;function VF(e){for(let t of BF)t(e)}function HF(){zF=BN(RF,jr),VF({kind:`status`})}function UF(e){BF.add(e)}function WF(){return zF}function GF(){return SP(zF)}function KF(e){let t=Dt.safeParse(e);t.success?(RF=t.data,HF()):ke(`reviews`,`dropped team-review-status: ${v(t.error.issues)}`)}function qF(e){VF({kind:`action-result`,message:e})}function JF(e){VF({kind:`open-session-result`,message:e})}function YF(e){VF({kind:`connection`,isConnected:e})}Mr(HF);var XF=1.2,ZF=1.55,QF=.12,$F=523.25,eI=2,tI=8,Y=(e,t,n)=>({semitone:e,startBeat:t,beats:n}),nI={melody:[Y(7,4,.5),Y(11,4.5,.5),Y(12,5,3)],bass:[Y(-5,4,1),Y(-12,5,3)]},rI=[{melody:[Y(0,0,1),Y(4,1,1),Y(7,2,1),Y(9,3,1)],bass:[Y(-12,0,2),Y(-8,2,2)]},{melody:[Y(7,0,.67),Y(7,.67,.67),Y(7,1.33,.67),Y(9,2,1),Y(5,3,1)],bass:[Y(-12,0,2),Y(-7,2,2)]},{melody:[Y(5,0,1),Y(9,1,1),Y(7,2,1),Y(4,3,1)],bass:[Y(-7,0,2),Y(-12,2,2)]},{melody:[Y(12,0,.5),Y(7,.5,.5),Y(12,1,.5),Y(16,1.5,.5),Y(16,2,1),Y(14,3,1)],bass:[Y(-12,0,2),Y(-3,2,2)]},{melody:[Y(4,0,1),Y(7,1,1),Y(4,2,.5),Y(5,2.5,.5),Y(7,3,.5),Y(4,3.5,.5)],bass:[Y(-8,0,2),Y(-12,2,2)]}].map(e=>({melody:[...e.melody,...nI.melody],bass:[...e.bass,...nI.bass]}));function iI(e,t){return $F*2**((e+t)/12)}function aI(e,t){let n=(e,n,r)=>e.map(e=>({frequency:iI(e.semitone,t),startSeconds:ZF+e.startBeat*QF,durationSeconds:e.beats*QF,waveform:n,gain:r}));return[...n(e.melody,`square`,.2),...n(e.melody,`triangle`,.5),...n(e.bass,`triangle`,.6)]}var oI=[{frequency:220,endFrequency:880,startSeconds:0,durationSeconds:.32,waveform:`triangle`,gain:.25},{frequency:160,endFrequency:45,startSeconds:XF,durationSeconds:.28,waveform:`sine`,gain:1},{frequency:1400,endFrequency:380,startSeconds:XF,durationSeconds:.06,waveform:`square`,gain:.12}];function sI(e){let t=rI[e%rI.length],n=Math.min(e*eI,tI);return{peakGain:.1,tones:[...oI,...aI(t,n)]}}function cI(e){return Math.round(Math.sqrt(2*e/780)*1e3)}function lI(e,t,n=Math.random){return Math.round(e+n()*(t-e))}function uI(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var dI=.6,fI=.25,pI=1.6;function mI(e){return Math.min(dI+e*fI,pI)}var hI=[`var(--accent)`,`var(--state-running)`,`var(--state-idle)`,`var(--state-waiting)`,`var(--state-failed)`];function gI(e,t=Math.random){let n=lI(320,520,t),r=lI(1800,2800,t);return[[`--confetti-start-x`,`${lI(4,96,t)}%`],[`--confetti-x`,`${lI(-140,140,t)}px`],[`--confetti-rise`,`${-lI(20,55,t)}px`],[`--confetti-fall`,`${lI(45,70,t)}vh`],[`--confetti-rise-ms`,`${n}ms`],[`--confetti-fall-ms`,`${r}ms`],[`--confetti-flight-ms`,`${n+r}ms`],[`--confetti-tilt`,`${lI(0,180,t)}deg`],[`--confetti-spin`,`${lI(-360,360,t)}deg`],[`--confetti-flutter-ms`,`${lI(160,340,t)}ms`],[`--confetti-delay`,`${lI(0,160,t)}ms`],[`--confetti-color`,hI[e%hI.length]]]}var _I=`<svg viewBox="0 0 36 36" aria-hidden="true"><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="17"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="13"/><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="9"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="5"/></svg>`,vI=`<svg viewBox="0 0 26 8" aria-hidden="true"><path class="merge-bullseye-dart-flight" d="M0 0L7 3V5L0 8L2 4Z"/><rect class="merge-bullseye-dart-shaft" x="6" y="3.3" width="8" height="1.4"/><rect class="merge-bullseye-dart-barrel" x="13" y="2.5" width="7" height="3" rx="1"/><path class="merge-bullseye-dart-tip" d="M20 3L26 4L20 5Z"/></svg>`;function yI(){let e=Ot(`div`,`merge-bullseye-target`,_I);return e.append(L(`span`,`merge-bullseye-ripple`)),e}function bI(){let e=L(`div`,`merge-bullseye-dart-drift`),t=L(`div`,`merge-bullseye-dart-arc`),n=L(`div`,`merge-bullseye-dart-aim`);return n.append(Ot(`div`,`merge-bullseye-dart`,vI)),t.append(n),e.append(t),e}function xI(){let e=L(`div`,`merge-bullseye-range`),t=L(`div`,`merge-bullseye-track`);return t.append(bI()),e.append(yI(),t),e}var SI={title:`BULLSEYE!`,buildScene:xI},CI=6,wI=30,TI=-14,EI=16;function DI(e=Math.random){return[[`--crosshair-start-left`,`${lI(CI,wI,e)}%`],[`--crosshair-start-offset-y`,`${lI(TI,EI,e)}px`]]}var OI=`<svg viewBox="0 0 26 40" aria-hidden="true"><path class="merge-headshot-target-body" d="M9 13H17L18 16Q25 18 25 24V40H1V24Q1 18 8 16Z"/><circle class="merge-headshot-target-head" cx="13" cy="7" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="7" r="3"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="2.5"/></svg>`,kI=`<svg viewBox="0 0 22 22" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M11 0V5M11 17V22M0 11H5M17 11H22"/><circle class="merge-headshot-crosshair-dot" cx="11" cy="11" r="1"/></svg>`,AI=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3L8 8M21 3L16 8M3 21L8 16M21 21L16 16"/></svg>`;function jI(){let e=L(`div`,`merge-headshot-sweep`);st(e,DI());let t=L(`div`,`merge-headshot-aim`);t.append(Ot(`div`,`merge-headshot-crosshair`,kI));let n=L(`div`,`merge-headshot-bob`);return n.append(t,Ot(`div`,`merge-headshot-hitmarker`,AI)),e.append(n),e}function MI(){let e=L(`div`,`merge-headshot-range`),t=L(`div`,`merge-headshot-track`);return t.append(jI()),e.append(Ot(`div`,`merge-headshot-target`,OI),t),e}var NI={title:`HEADSHOT!`,buildScene:MI},PI=[`10`,`J`,`Q`,`K`,`A`],FI=160,II=19,LI=5,RI=9,zI=780,BI=70,VI=70,HI=35;function UI(e){let t=PI.length-1,n=e-t/2;return{offsetPx:n*II,titleSpreadFraction:n/t,tiltDegrees:n*LI,bottomPx:RI-n**2,dealLeadMs:zI-e*BI,flipLeadMs:FI+(t-e)*VI,waveDelayMs:e*HI}}function WI(e){return[[`--card-offset`,`${e.offsetPx}px`],[`--card-title-spread`,String(e.titleSpreadFraction)],[`--card-tilt`,`${e.tiltDegrees}deg`],[`--card-bottom`,`${e.bottomPx}px`],[`--card-deal-lead-ms`,`${e.dealLeadMs}ms`],[`--card-flip-lead-ms`,`${e.flipLeadMs}ms`],[`--card-wave-delay-ms`,`${e.waveDelayMs}ms`]]}function GI(){return[[`--card-flip-ms`,`${FI}ms`]]}var KI=`<svg viewBox="0 0 10 9" aria-hidden="true"><path d="M5 8.5C5 8.5 0 5.3 0 2.6C0 1.1 1.2 0 2.6 0C3.6 0 4.5 .6 5 1.4C5.5 .6 6.4 0 7.4 0C8.8 0 10 1.1 10 2.6C10 5.3 5 8.5 5 8.5Z"/></svg>`;function qI(e,t){let n=L(`div`,`merge-flush-deal`);st(n,WI(UI(t)));let r=L(`div`,`merge-flush-hop`),i=L(`div`,`merge-flush-card`),a=L(`div`,`merge-flush-face`);return a.append(L(`span`,`merge-flush-rank`,e)),a.insertAdjacentHTML(`beforeend`,KI),i.append(L(`div`,`merge-flush-back`),a),r.append(i),n.append(r),n}function JI(){let e=L(`div`,`merge-flush-table`);return st(e,GI()),e.append(...PI.map(qI)),e}var YI={title:`ROYAL FLUSH!`,buildScene:JI},XI=[1,2,3,4],ZI=14,QI=3,$I=3,eL=10,tL=20,nL=2,rL=28,iL=18,aL=.01,oL=1.5,sL=2200,cL=1,lL=120,uL=.35,dL=15,fL=105,pL=4,mL=65,hL=145;function gL(e){return Math.round(e/(Math.PI*iL)*360)}function _L(e){return tL-e*nL}function vL(e){return e.rowIndex*ZI+e.depthIndex*QI}function yL(e,t,n){return Array.from({length:n},(r,i)=>e+(t-e)*i/(n-1))}function bL(){return XI.flatMap((e,t)=>Array.from({length:e},(n,r)=>({rowIndex:t,depthIndex:e-1-r})))}function xL(e,t){let n=uI(yL(dL,fL,e),t),r=uI(yL(mL,hL,e),t);return n.map((e,n)=>({angleDegrees:e+lI(-4,pL,t),depthScalePercent:Math.round(r[n])}))}function SL(e,t,n){let r=lI(240,380,n),i=t.angleDegrees*Math.PI/180,a=r*Math.cos(i),o=(r*Math.sin(i))**2/1560,s=lI(15,45,n),c=cI(o),l=cI(o+s),u=c+l,d=lI(540,1080,n),f=a>=0?1:-1,p=vL(e);return{depthIndex:e.depthIndex,launchAngleDegrees:t.angleDegrees,distanceFromHeadPinPx:p,layer:_L(e.depthIndex),flyXPx:Math.round(a*u/1e3),peakRisePx:Math.round(o),landingDropPx:s,riseMs:c,fallMs:l,flightMs:u,spinDegrees:Math.round(f*d*u/1e3),glintMs:Math.round(180/d*1e3),depthScalePercent:t.depthScalePercent,delayMs:Math.round(p/uL)}}function CL(e=Math.random){let t=bL(),n=xL(t.length,e);return t.map((t,r)=>SL(t,n[r],e))}function wL(e){return[[`--pin-left`,`${e.distanceFromHeadPinPx}px`],[`--pin-raise`,`${e.depthIndex*$I}px`],[`--pin-shade`,`${100-e.depthIndex*12}%`],[`--pin-fly-x`,`${e.flyXPx}px`],[`--pin-peak-y`,`${-e.peakRisePx}px`],[`--pin-land-y`,`${e.landingDropPx}px`],[`--pin-rise-ms`,`${e.riseMs}ms`],[`--pin-fall-ms`,`${e.fallMs}ms`],[`--pin-flight-ms`,`${e.flightMs}ms`],[`--pin-spin`,`${e.spinDegrees}deg`],[`--pin-glint-ms`,`${e.glintMs}ms`],[`--pin-depth-scale`,`${e.depthScalePercent}%`],[`--pin-depth-shade`,`${e.depthScalePercent-10}%`],[`--pin-delay`,`${e.delayMs}ms`],[`--pin-layer`,String(e.layer)]]}function TL(){return _L(oL)}function EL(){return Math.max(...bL().map(vL))+eL}function DL(){let e=EL(),t=rL+e+iL-cL;return[[`--ball-follow-px`,`${lL}px`],[`--ball-follow-ms`,`${Math.round(lL/uL)}ms`],[`--ball-follow-spin`,`${gL(lL)}deg`],[`--ball-size`,`${iL}px`],[`--ball-approach-spin`,`${sL}deg`],[`--ball-impact-inset`,`${t}px`],[`--ball-layer`,String(TL())],[`--rack-right`,`${rL}px`],[`--rack-width`,`${e}px`],[`--pin-width`,`${eL}px`]]}function OL(e=Math.random){return e()>=aL?null:sn[Math.floor(e()*sn.length)].sprite}var kL=`<svg viewBox="0 0 10 24" aria-hidden="true"><path class="merge-strike-pin-body" d="M5 0C7 0 7.6 2 7.2 4C6.9 5.6 6.3 6.6 6.4 8C6.6 10 9.6 12 9.6 16C9.6 19.5 8.4 22 7.6 24H2.4C1.6 22 .4 19.5 .4 16C.4 12 3.4 10 3.6 8C3.7 6.6 3.1 5.6 2.8 4C2.4 2 3 0 5 0Z"/><path class="merge-strike-pin-stripe" d="M3.1 5.2H6.9V6.2H3.1ZM3.4 7H6.6V8H3.4Z"/></svg>`;function AL(e){let t=L(`span`,`merge-strike-pin`);return t.append(Ot(`span`,`merge-strike-pin-arc`,kL)),st(t,wL(e)),t}function jL(){let e=OL();if(!e)return L(`span`,`merge-strike-ball`);let t=L(`span`,`merge-strike-ball is-animal`);return t.append(L(`span`,`nyan-sprite ${e}`)),t}function ML(){let e=L(`div`,`merge-strike-lane`);st(e,DL());let t=L(`div`,`merge-strike-rack`);t.append(...CL().map(AL));let n=L(`div`,`merge-strike-track`);return n.append(jL()),e.append(t,n),e}var NL={title:`STRIKE!`,buildScene:ML},PL=20,FL=92,IL=23,LL=7,RL=-40;function zL(){let e=cI(72),t=cI(69),n=780*t/1e3;return{launchHeightPx:PL,peakHeightPx:FL,heightThroughRimPx:IL,heightLeavingNetPx:LL,heightOutOfCardPx:RL,riseMs:e,fallToRimMs:t,speedThroughRimPxPerSecond:n,netCatchMs:Math.round(32/n*1e3),dropMs:cI(47)}}function BL(e=zL()){return[[`--ball-launch-y`,`${-e.launchHeightPx}px`],[`--ball-peak-y`,`${-e.peakHeightPx}px`],[`--ball-rim-y`,`${-e.heightThroughRimPx}px`],[`--ball-net-exit-y`,`${-e.heightLeavingNetPx}px`],[`--ball-drop-out-y`,`${-e.heightOutOfCardPx}px`],[`--ball-rise-ms`,`${e.riseMs}ms`],[`--ball-fall-to-rim-ms`,`${e.fallToRimMs}ms`],[`--ball-to-rim-ms`,`${e.riseMs+e.fallToRimMs}ms`],[`--ball-net-catch-ms`,`${e.netCatchMs}ms`],[`--ball-drop-ms`,`${e.dropMs}ms`]]}var VL=`<svg viewBox="0 0 40 48" aria-hidden="true"><rect class="merge-swish-pole" x="36" y="28" width="2" height="20"/><rect class="merge-swish-backboard" x="35" y="2" width="3" height="26" rx="1"/><path class="merge-swish-rim" d="M31 18H35M7 18A12 2.5 0 0 1 31 18"/></svg>`,HL=`<svg viewBox="0 0 40 48" aria-hidden="true"><g class="merge-swish-net"><path d="M8 18L12 32M13.5 18L15.5 32M19 18V32M24.5 18L22.5 32M30 18L26 32M9.5 23Q19 25 28.5 23M11 28Q19 29.5 27 28"/></g><path class="merge-swish-rim" d="M7 18A12 2.5 0 0 0 31 18"/></svg>`;function UL(){let e=L(`div`,`merge-swish-ball-drift`),t=L(`div`,`merge-swish-ball-arc`);return t.append(L(`span`,`merge-swish-ball`)),e.append(t),e}function WL(){let e=L(`div`,`merge-swish-court`);st(e,BL());let t=L(`div`,`merge-swish-track`);return t.append(UL()),e.append(Ot(`div`,`merge-swish-hoop-back`,VL),t,Ot(`div`,`merge-swish-hoop-front`,HL)),e}var GL=[NL,{title:`SWISH!`,buildScene:WL},SI,NI,YI],KL=48,qL=5600,JL=20,YL=null,XL=[],ZL=null,QL=!1,$L=0;function eR(e){let t=L(`span`,`merge-confetti-piece`),n=L(`span`,`merge-confetti-arc`);return n.append(L(`span`,`merge-confetti-paper`)),t.append(n),st(t,gI(e)),t}function tR(e){let t=L(`p`,`merge-celebration-title`);return t.setAttribute(`aria-hidden`,`true`),Array.from(e).forEach((e,n)=>{let r=L(`span`,`merge-celebration-letter`,e);r.style.setProperty(`--letter-delay`,`${n*45}ms`),t.append(r)}),t}function nR(e,t,n){let r=t.firstElementChild,i=t.lastElementChild;r instanceof HTMLElement&&i instanceof HTMLElement&&(e.style.setProperty(`--celebration-title-width`,`${i.offsetLeft+i.offsetWidth-r.offsetLeft}px`),e.style.setProperty(`--celebration-title-center-y`,`${t.offsetTop+t.offsetHeight/2-n.offsetTop}px`))}function rR(e){let t=L(`div`,`merge-celebration-scene`);return t.setAttribute(`aria-hidden`,`true`),t.append(e.buildScene()),t}function iR(){return GL[Math.floor(Math.random()*GL.length)]}function aR(e){if(gn())try{gf(sI(e))}catch{}}function oR(e){let t=L(`ul`,`merge-celebration-details`);for(let n of e)t.append(L(`li`,`merge-celebration-detail`,n));return t}function sR(e,t,n){YL?.remove(),aR(n);let r=L(`div`,`merge-celebration`);r.setAttribute(`role`,`status`);let i=L(`div`,`merge-celebration-card`),a=L(`div`,`merge-celebration-stage`),o=tR(t.title),s=rR(t);a.append(o,L(`p`,`merge-celebration-message`,e.message),oR(e.detailLines),s);let c=L(`div`,`merge-confetti`);c.style.setProperty(`--confetti-scale`,String(mI(n)));for(let e=0;e<KL;e+=1)c.append(eR(e));i.append(c,a),r.append(i),document.body.append(r),nR(a,o,s),YL=r,window.setTimeout(()=>{r.remove(),YL===r&&(YL=null)},qL)}function cR(e){return QL?`playing`:e?`queued`:`empty`}function lR(){if(!ZL)return;let e=XL.length>0;ZL.tray.dataset.state=cR(e),ZL.count.textContent=e?String(XL.length):``,ZL.button.disabled=QL||!e}function uR(){let e=XL.shift();QL=e!==void 0,lR(),e&&(sR(e.text,e.scene,$L),$L+=1,window.setTimeout(uR,qL))}function dR(e,t,n){ZL={tray:e,button:t,count:n},t.addEventListener(`click`,()=>{$L=0,uR()}),lR()}function fR(e,t=iR()){XL.push({text:e,scene:t}),XL.length>JL&&XL.shift(),lR()}var pR=null,mR=null,hR=new Set,gR=new Map,_R=!1,vR=new Set;function yR(e){for(let t of vR)t(e)}function bR(){return[...gR].flatMap(([e,t])=>{let n=H.get(e);return!n||t.length===0?[]:[{id:e,title:tn(n)||e,links:t}]})}function xR(){let e=AN(pR?.prs??[],jr),t=MN(mR,e);mR=e,TR(t),yR({kind:`prs`})}function SR(){_R||(_R=!0,queueMicrotask(()=>{_R=!1,xR()}))}function CR(e){vR.add(e)}function wR(){return{prs:AN(pR?.prs??[],jr),status:pR,sessionsByPrKey:jN(bR())}}function TR(e){let t=e.filter(e=>!hR.has(e.key));if(t.length!==0){for(let e of t)hR.add(e.key);fR(PN(t))}}function ER(e){gR=e,SR()}function DR(){yR({kind:`session-state`})}function OR(e){let t=d.safeParse(e);t.success?(pR=t.data,xR()):ke(`reviews`,`dropped my-prs-status: ${v(t.error.issues)}`)}function kR(e){yR({kind:`merge-result`,message:e})}function AR(e){yR({kind:`connection`,isConnected:e})}Mr(SR);var jR=[{id:`all`,label:`All`},{id:`reviewing`,label:`Reviewing`},{id:`mine`,label:`Mine`}],MR={turn:`Your turn`,working:`Agent working`,waiting:`Waiting on others`,aside:`Set aside`},NR=[`turn`,`working`,`waiting`,`aside`],PR={conflicts:`turn`,behind:`turn`,"checks-failing":`turn`,"changes-requested":`turn`,"unresolved-threads":`turn`,ready:`turn`,"checks-pending":`waiting`,"needs-approval":`waiting`,unknown:`waiting`,draft:`aside`,merged:`aside`},FR={directAsk:0,followUp:1,mineNeedsYou:2,teamReady:3,mineReady:4,failedReview:5,staleReview:6,fork:7};function IR(e,t){return{source:`team`,key:`team:${e.key}`,prKey:ot(e),kind:t,review:e}}function LR(e){return e.status===`ready`?HN(e).band===`blocking-others`?FR.directAsk:FR.teamReady:FR.followUp}function RR(e){return[...e.ready.map(e=>({item:IR(e,`ready`),group:`turn`,turnRank:LR(e)})),...e.attention.map(e=>({item:IR(e,`attention`),group:`turn`,turnRank:e.status===`error`?FR.failedReview:FR.staleReview})),...e.handReview.map(e=>({item:IR(e,`handReview`),group:`turn`,turnRank:FR.fork})),...e.inReview.map(e=>({item:IR(e,`inReview`),group:`working`,turnRank:0})),...e.queued.map(e=>({item:IR(e,`queued`),group:`working`,turnRank:0})),...e.noReviewNeeded.map(e=>({item:IR(e,`settled`),group:`waiting`,turnRank:0})),...e.posted.map(e=>({item:IR(e,`posted`),group:`waiting`,turnRank:0})),...e.discarded.map(e=>({item:IR(e,`discarded`),group:`aside`,turnRank:0}))]}function zR(e,t){let n=PR[e.stage];return n===`turn`&&e.stage!==`ready`&&t.has(ot(e))?`working`:n}function BR(e,t){return aN(e).flatMap(e=>e.rows).map(({pr:e,parentKey:n})=>({item:{source:`mine`,key:`mine:${e.key}`,prKey:ot(e),pr:e,stackedOn:n},group:zR(e,t),turnRank:e.stage===`ready`?FR.mineReady:FR.mineNeedsYou}))}function VR(e,t,n){let r=[...RR(e),...BR(t,n)];return NR.map(e=>{let t=r.filter(t=>t.group===e),n=e===`turn`?t.toSorted((e,t)=>e.turnRank-t.turnRank):t;return{id:e,title:MR[e],items:n.map(e=>e.item)}})}function HR(e,t){if(t===`all`)return[...e];let n=t===`reviewing`?`team`:`mine`;return e.map(e=>({...e,items:e.items.filter(e=>e.source===n)}))}function UR(e){return e.find(e=>e.id===`turn`)?.items??[]}function WR(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function GR(e,t){return WR(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function KR(e){return e.source===`mine`?QP(e.pr.repo,e.pr.number):QP(e.review.repo,e.review.number)}function qR(e){return e.source===`team`?e.kind===`attention`&&`status`in e.review&&e.review.status===`error`?`failed`:`waiting`:e.pr.stage===`ready`?`finished`:e.pr.stage===`checks-failing`||e.pr.stage===`conflicts`?`failed`:`waiting`}function JR(e){return UR(e).map(e=>({id:e.key,kind:qR(e),name:KR(e)}))}function YR(e){return{waitingCount:e.filter(e=>e.kind===`waiting`).length,finishedCount:e.filter(e=>e.kind===`finished`).length,failedCount:e.filter(e=>e.kind===`failed`).length}}function XR(e,t){return JR(e).filter(e=>e.id!==t)}function ZR({capturedOrder:e,actedKey:t,groups:n}){let r=UR(n).map(e=>e.key).filter(e=>e!==t),i=new Set(r);return e.slice(e.indexOf(t)+1).find(e=>i.has(e))??e.find(e=>i.has(e))??r[0]??null}function QR(e,t){let n=UR(e).map(e=>e.key),r=t?n.indexOf(t):-1;return r===-1?``:`${r+1} of ${n.length} in Your turn`}function $R(e){return e.source===`mine`?`${e.key}@${e.pr.stage}`:`reviewedHead`in e.review?`${e.review.key}@${e.review.reviewedHead}`:`${e.review.key}@${e.kind}`}function ez(e){return UR(e).map($R)}function tz({turnEntries:e,acknowledged:t,unseen:n,isLooking:r}){let i=new Set(e),a=new Set(t.split(`|`).filter(e=>i.has(e))),o=new Set(n.split(`|`).filter(e=>i.has(e))),s=[...i].filter(e=>!a.has(e));if(r)return{isShown:!1,acknowledged:Ut([...i]),unseen:Ut([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:Ut([...a]),unseen:Ut([...o])}}function nz(e){let t=e.find(e=>e.id===`working`)?.items.length??0;return t===0?`Nothing needs you right now.`:`Nothing needs you right now. ${t} ${t===1?`pull request is`:`pull requests are`} with an agent.`}function rz(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function iz(e){let t=e.filter(e=>e?.configured===!0);if(t.length===0)return e.find(e=>e!==null)??null;let n=t.toSorted((e,t)=>(e.lastRefreshedAt??e.lastSyncAt??0)-(t.lastRefreshedAt??t.lastSyncAt??0));return{...t.find(e=>e.error)??n[0],isRefreshing:t.some(e=>e.isRefreshing)}}var az=[],oz=null,sz=null,cz=null,lz=!1,uz=null,dz=En(),fz=Zn(),pz=new Set(fz.split(`|`).filter(Boolean)),mz=new Set,hz=new Set;function gz(e){for(let t of hz)t(e)}function _z(e){e!==dz&&(dz=e,_n(e))}function vz(e){e!==fz&&(fz=e,pz=new Set(e.split(`|`).filter(Boolean)),dn(e))}function yz(){return WF()!==null&&wR().status!==null}function bz(){if(!yz())return;let e=tz({turnEntries:ez(az),acknowledged:dz,unseen:fz,isLooking:sz?.isLooking()??!1});_z(e.acknowledged),vz(e.unseen),uz?.(e.isShown)}function xz(e){cz=e,gz({kind:`reveal`})}function Sz(e){hz.add(e)}function Cz(e){sz=e,bz()}function wz(){let{prs:e,sessionsByPrKey:t}=wR();return az=VR(GF(),e,new Set(t.keys())),bz(),az}function Tz(){yz()&&(_z(Ut(ez(az))),bz())}function Ez(e){uz=e,bz()}function Dz(){return fz}function Oz(e){return pz.has(e)}function kz(e){return pz.has(e)?(vz(Ut([...pz].filter(t=>t!==e))),!0):!1}function Az(e){oz=e}function jz(){return oz}function Mz(){let e=cz;return cz=null,e}function Nz(e){if(e!==lz){lz=e;for(let e of mz)e()}}function Pz(e){mz.add(e)}function Fz(){return document.documentElement.dataset.layout===`phone`&&lz}function Iz(){Fz()&&gz({kind:`return-to-queue`})}function Lz(){let e=XR(az,sz?.selectedKey()??null)[0]?.id??null;return e?(xz(e),!0):!1}function Rz(e){let t=az.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!oz?.openReviews()?!1:(xz(t.key),Tz(),!0)}UF(e=>{e.kind===`status`&&wz()}),CR(e=>{e.kind===`prs`&&wz()});var zz={OPEN:0,MERGED:1,CLOSED:2};function Bz(e){return e?zz[e.state]:zz.OPEN}function Vz(e,t){let n=`${e.repo}#${e.number}`,r=`#${e.number}`;if(!t)return{key:n,text:r,url:e.url,hoverText:e.repo,look:null,tier:Ms(void 0)};let i=sN(t.stage);return{key:n,text:r,url:t.url,hoverText:`${e.repo}: ${t.title} (${oN(t.stage)})`,look:{icon:cN(t.stage),tone:i},tier:Ms(i)}}function Hz(e,t){let n=e.map(e=>{let n=t(ot(e));return{link:e,pr:n?CM(n):void 0}});return n.sort((e,t)=>Bz(e.pr)-Bz(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>Vz(e,t))}var Uz=new Map;function Wz(e){return document.querySelectorAll(`[data-pr-chips-for="${CSS.escape(e)}"]`)}function Gz(e){return Hz(Uz.get(e)??[],jr).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,hoverText:`${e.hoverText}. Show in Reviews; Cmd/Ctrl-click opens GitHub`,onActivate:()=>{Rz(e.key)||sc(e.url)}}))}function Kz(e,t){let n=ql(e,e),r=L(`button`,`session-pr-chip-unlink`);r.append(sr(ur)),r.type=`button`,r.title=`Unlink ${e.key} from this session`,r.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),r.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),wr({title:`Unlink pull request`,message:`Unlink ${e.key} from this session? Its checks and reviews stop showing here until you link it again.`,confirmLabel:`Unlink`,danger:!0,onConfirm:()=>{Lu(t,{type:`unlink-session-pr`,id:t,key:e.key})}})});let i=L(`span`,`session-pr-chip-item`);return i.append(n,r),i}function qz(e,t){e.dataset.prChipsFor=t,Ql(e,Gz(t),e=>Kz(e,t))}function Jz(e){for(let t of e){let e=t.dataset.prChipsFor;e&&qz(t,e)}au()}function Yz(e,t){let n=at.shape.links.safeParse(t??[]);Uz.set(e,n.success?n.data:[]),Jz(Wz(e)),ER(Uz)}function Xz(e){Uz.delete(e),ER(Uz)}Mr(()=>Jz(document.querySelectorAll(`[data-pr-chips-for]`)));var Zz=null,Qz=new Set;function $z(){Zz?.setAttribute(`aria-pressed`,String(!gn()))}function eB(e){pn(e),$z();for(let t of Qz)t(e)}function tB(e){Qz.add(e)}function nB(e){Zz=e,$z(),e.addEventListener(`click`,()=>eB(!gn()))}var rB={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},iB=null,aB=null,oB=!0,sB=new Map,cB=new Map,lB=new Set;function uB(){for(let e of lB)e()}function dB(e){lB.add(e)}function fB(){return{status:iB,isServerConnected:oB,pendingActionBySuite:sB,outcomeBySuite:cB}}function pB(e){aB=e}function mB(e,t){aB?.({type:`benchmark-action`,requestId:y(`benchmark`),suiteId:e,action:t})===!0?(sB.set(e,t),cB.set(e,rB[t]),uB()):(cB.set(e,p),uB())}function hB(e){if(oB=e,!e){for(let e of sB.keys())cB.delete(e);sB.clear()}uB()}function gB(e){iB=e,uB()}function _B(e){sB.delete(e.suiteId);let t=iB?.suites.find(t=>t.id===e.suiteId)?.candidateCount??0,n={mine:`Mining finished. ${t} candidate${t===1?``:`s`} awaiting approval in the candidates folder.`,run:`Run ${e.runId??``} started.`,cancel:`Run cancelled.`};cB.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),uB()}var vB=45e3,yB=`The server did not answer within ${vB/1e3} s.`,bB=`Select the issue to load its description.`,xB=null,SB=null,CB=new Map,wB=null,TB=new Map,EB=new Map,DB=new Map,OB=new Map,kB=new Map,AB=new Set;function jB(e){for(let t of AB)t(e)}function MB(e){return`${e.key}:${e.updatedAt}`}function NB(e){let t=TB.get(e);t&&(TB.delete(e),EB.set(t.issueKey,{text:yB,tone:`error`}),jB(`detail`))}function PB(e){let t=TB.get(e);return t?(clearTimeout(t.timeoutHandle),TB.delete(e),t):null}function FB(){return{latestStatus:SB,issueByKey:CB,selectedKey:xB}}function IB(e){AB.add(e)}function LB(e){xB=e}function RB(e){return[...TB.values()].some(t=>t.issueKey===e.key)}function zB(e){return EB.get(e.key)}function BB(e){let t=MB(e),n=OB.get(t);return n===``?`No description.`:n??kB.get(t)??`Loading description.`}function VB(e){let t=MB(e);if(OB.has(t)||[...DB.values()].some(e=>e.cacheKey===t))return;let n=y(`issue-detail`);kB.delete(t),wB?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?DB.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{DB.delete(n),kB.set(t,`${yB} ${bB}`),jB(`detail`)},vB)}):kB.set(t,`${p} ${bB}`)}function HB(e){let t=e.projectId;if(!t||RB(e))return;let n=y(`open-issue-session`);wB?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(TB.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>NB(n),vB)}),EB.set(e.key,{text:`Opening session.`,tone:`busy`}),jB(`detail`)):(EB.set(e.key,{text:p,tone:`error`}),jB(`detail`))}function UB(e){wB?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function WB(e){wB=e}function GB(){jB(`session-state`)}function KB(e){if(!e){for(let e of TB.values())clearTimeout(e.timeoutHandle),EB.set(e.issueKey,{text:p,tone:`error`});TB.clear();for(let e of DB.values())clearTimeout(e.timeoutHandle),kB.set(e.cacheKey,`${p} ${bB}`);DB.clear(),jB(`status`)}}function qB(e){let t=SB?.issues.find(e=>e.key===xB);SB=e,CB=new Map(e.issues.map(e=>[e.key,e]));let n=e.issues.find(e=>e.key===xB);n&&n.updatedAt!==t?.updatedAt&&VB(n),jB(`status`)}function JB(e){let t=DB.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),DB.delete(e.requestId),e.ok&&e.body!==null&&OB.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&kB.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),jB(`detail`))}function YB(e){if(typeof e.requestId!=`string`)return;let t=PB(e.requestId);if(!t)return;let n=t.issueKey;if(e.ok===!0){let r=typeof e.sessionName==`string`?e.sessionName:`issue #${t.issueNumber}`,i=e.pending===!0?` Prompt queued.`:``,a=e.existing===!0?`already open`:`created`;EB.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=SB?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),jB(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;EB.set(n,{text:r,tone:`error`}),jB(`detail`)}var XB=null,ZB=null,QB=null,$B=()=>!1,eV=new Set,tV=new Set,nV=Oe({getAck:On,setAck:qn,signature:()=>wt({posthog:XB}),isLooking:()=>$B()});function rV(e){for(let t of tV)t(e)}function iV(){ZB?.(nV.refresh())}function aV(){return{latest:XB,archivedLocally:eV,traceOpener:QB}}function oV(e){tV.add(e)}function sV(e){$B=e,iV()}function cV(e){eV.add(e)}function lV(){nV.acknowledge(),iV()}function uV(e){ZB=e,iV()}function dV(e){QB=e}function fV(e){XB=e,Pt(XB,eV),rV({kind:`status`}),iV()}function pV(e){let t=ce(XB,e.projectId,e.issueId)?.inFlight===!0;Ie(XB,e)&&rV({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function mV(e){let t=ee(XB,e);rV({kind:`investigation-finished`,frame:e,isPatched:t}),t&&iV()}var hV=Os({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function gV(e){let t=L(`ul`,`session-setup-list`);return t.append(...e.map(e=>L(`li`,null,e))),t}function _V(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=bt(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[L(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=L(`div`,`session-setup-plugin`);return t.append(L(`h3`,null,e.name)),e.skills.length>0&&t.append(L(`p`,`session-setup-label`,`Skills`),gV(e.skills)),e.agents.length>0&&t.append(L(`p`,`session-setup-label`,`Agents`),gV(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[gV(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=L(`p`,`session-setup-hook`);return t.append(L(`span`,null,e.event),L(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>L(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[gV(t.skills)]:[]),n(`Agents`,t.agents.length>0?[gV(t.agents)]:[])}function vV(e){let t=L(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=L(`div`,`session-setup-sections`);hV.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function yV(e){let t=hV.settleResponse(e);if(!t)return;if(!e.ok||!e.setup){t.status.textContent=e.error||`Could not read session setup`;return}let n=t.parts.sections;_V(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function bV(e){return{skipPerms:e.skipPerms??e.dangerouslySkipPermissions??!1,saneYolo:e.saneYolo===!0,worktree:e.worktree??e.isWorktree??!1,workspace:e.workspace??e.isWorkspace??!1,remoteWorkspace:e.remoteWorkspace??null,guarded:e.guarded??e.isGuarded??!1,guardrailsReleased:e.guardrailsReleased??e.isGuardrailsReleased??!1,ephemeral:e.ephemeral===!0,ownerId:e.ownerId??null,path:e.path,stateSince:e.stateSince,taskTitle:typeof e.taskTitle==`string`?e.taskTitle:null,taskTitleIsCustom:e.taskTitleIsCustom===!0}}var xV={maxConcurrentInvestigations:Math.ceil,minUsersToInvestigate:Math.ceil,userEscalationThreshold:Math.ceil,trafficSpikeMinUsers:Math.ceil,trafficSpikeBaselineDays:Math.floor};[...Object.entries(xV).map(([e,t])=>({path:[`posthog`,e],min:1,round:t}))];var SV=Object.freeze([`auto`,`calculate`,`display`]),CV=Object.freeze([`codex`,`grok`]),wV=Object.freeze([`dailyUsd`,`monthlyUsd`]),X=e=>t({error:`${e} must be a boolean`}).optional(),TV=(e,t=!1)=>{let n=a({error:`${e} must be a string`});return(t?n.transform(e=>e.trim()):n).optional()},EV=e=>e.label?e.label:e.max==null?e.exclusiveMin?`greater than ${e.min}`:`at least ${e.min}`:`between ${e.min} and ${e.max}`,DV=(e,t=zt)=>i({error:`${e} must be ${EV(t)}`}).finite().refine(e=>!t.exclusiveMin||e>t.min,{message:`${e} must be ${EV(t)}`}).refine(e=>t.exclusiveMin||e>=t.min,{message:`${e} must be ${EV(t)}`}).refine(e=>t.max==null||e<=t.max,{message:`${e} must be ${EV(t)}`}).optional(),OV=(e,t)=>DV(e,t).unwrap().int({error:`${e} must be a whole number ${EV(t)}`}).optional(),kV=(e,t)=>i({error:`${e} must be an integer between ${t.min} and ${t.max}`}).int({error:`${e} must be an integer between ${t.min} and ${t.max}`}).min(t.min,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).max(t.max,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).optional(),AV=(e,t)=>u(t,{error:`${e} must be an object`}).nullable().optional(),jV=Object.freeze([`release`,`main`]),MV=Object.freeze([`report`,`fix`]);u({refiner:u({enabled:X(`taskTitle.refiner.enabled`),model:TV(`taskTitle.refiner.model`,!0),minIntervalSeconds:DV(`taskTitle.refiner.minIntervalSeconds`,{min:0}),timeoutSeconds:DV(`taskTitle.refiner.timeoutSeconds`,we)},{error:`taskTitle.refiner must be an object`}).nullable().optional()},{error:`taskTitle must be an object`}).nullable().optional();var NV={enabled:X(`branchGc.enabled`),worktrees:X(`branchGc.worktrees`),prefixes:c(a({error:`branchGc.prefixes must be an array of strings`}).min(1,{error:`branchGc.prefixes entries must be non-empty strings`}),{error:`branchGc.prefixes must be an array of strings`}).optional(),dryRun:X(`branchGc.dryRun`),staleDays:DV(`branchGc.staleDays`,ut),deleteUnmerged:X(`branchGc.deleteUnmerged`),intervalMs:DV(`branchGc.intervalMs`,yt)},PV=u(NV,{error:`branchGc must be an object`});AV(`branchGc`,NV),PV.omit({prefixes:!0,dryRun:!0,worktrees:!0}).nullable().optional(),Object.freeze([`enabled`,`deleteUnmerged`]),Object.freeze([`staleDays`,`intervalMs`]),AV(`postTurnChecks`,{mode:o(MV,{error:`postTurnChecks.mode must be one of report, fix`}).optional()}),AV(`visions`,{enabled:X(`visions.enabled`),autoFix:X(`visions.autoFix`),projects:c(a({error:`visions.projects must be an array of strings`}),{error:`visions.projects must be an array of strings`}).optional(),dispatch:AV(`visions.dispatch`,{enabled:X(`visions.dispatch.enabled`),model:TV(`visions.dispatch.model`,!0),quietMs:OV(`visions.dispatch.quietMs`,oe),cooldownMs:OV(`visions.dispatch.cooldownMs`,Le),maxPerHour:OV(`visions.dispatch.maxPerHour`,Et),activityMaxPerHour:OV(`visions.dispatch.activityMaxPerHour`,Me),dispatchTimeoutSeconds:OV(`visions.dispatch.dispatchTimeoutSeconds`,te)}),intent:AV(`visions.intent`,{threadTtlMs:OV(`visions.intent.threadTtlMs`,le)})}),u({teams:c(a({error:`github.teams must be an array of org/slug strings`}).refine(e=>tt(e)!==null,{message:`github.teams entries must be org/slug with valid GitHub segments`}),{error:`github.teams must be an array of org/slug strings`}).optional()},{error:`github must be an object`}).nullable().optional(),AV(`teamReview`,{enabled:X(`teamReview.enabled`),autoRebaseMyPrs:X(`teamReview.autoRebaseMyPrs`),keepMergeableEnabled:X(`teamReview.keepMergeableEnabled`),mergeQueueEnabled:X(`teamReview.mergeQueueEnabled`),keepMergeableTimeoutMinutes:kV(`teamReview.keepMergeableTimeoutMinutes`,Qe),org:TV(`teamReview.org`,!0),team:TV(`teamReview.team`,!0),skill:TV(`teamReview.skill`,!0),reReviewAfterHours:DV(`teamReview.reReviewAfterHours`),skipIdleAfterDays:DV(`teamReview.skipIdleAfterDays`)}),AV(`benchmarks`,{enabled:X(`benchmarks.enabled`)}),AV(`coherence`,{enabled:X(`coherence.enabled`)});var FV={intervalMinutes:C,maxConcurrentInvestigations:ht,investigationTimeoutSeconds:ve,fixTimeoutSeconds:E,minUsersToInvestigate:m,userEscalationThreshold:Ae,recurrenceWindowDays:pt,transientRecurrenceLimit:ae,trafficSpikeMultiplier:k,trafficSpikeMinUsers:ye,trafficSpikeCooldownMinutes:he,trafficSpikeBaselineDays:pe};AV(`posthog`,{enabled:X(`posthog.enabled`),recurrenceDedupe:X(`posthog.recurrenceDedupe`),trafficSpikeEnabled:X(`posthog.trafficSpikeEnabled`),autoFix:X(`posthog.autoFix`),host:TV(`posthog.host`,!0).refine(e=>e==null||!e||/^https?:\/\//i.test(e),{message:`posthog.host must be an http(s) URL`}),apiKey:TV(`posthog.apiKey`,!0),repoPath:TV(`posthog.repoPath`,!0),projects:r([l(`all`),c(i({error:`posthog.projects must be "all" or an array of positive integer project ids`}).int({error:`posthog.projects must be "all" or an array of positive integer project ids`}).positive({error:`posthog.projects must be "all" or an array of positive integer project ids`}),{error:`posthog.projects must be "all" or an array of positive integer project ids`})],{error:`posthog.projects must be "all" or an array of positive integer project ids`}).optional(),projectMap:n(a(),e(),{error:`posthog.projectMap must be an object`}).optional(),...Object.fromEntries(Object.entries(FV).map(([e,t])=>[e,Object.hasOwn(xV,e)?OV(`posthog.${e}`,t):DV(`posthog.${e}`,t)]))}),`${SV.join(`, `)}`,Object.fromEntries(CV.map(e=>[e,X(`usage.vendors.${e}`)])),Object.fromEntries(wV.map(e=>[e,i({error:`usage.budget.${e} must be a positive number or null`}).positive({error:`usage.budget.${e} must be a positive number or null`}).nullable().optional()])),AV(`telegram`,{botToken:TV(`telegram.botToken`,!0),chatId:TV(`telegram.chatId`,!0)}),u({enabled:X(`ingest.enabled`)},{error:`ingest must be an object`}).passthrough().optional(),u({enabled:X(`trace.enabled`)},{error:`trace must be an object`}).optional(),u({enabled:X(`planReview.enabled`)},{error:`planReview must be an object`}).optional();var IV=e=>c(a({error:`${e} must be an array of paths`}).trim().min(1,{error:`${e} must be an array of paths`}),{error:`${e} must be an array of paths`}).optional(),LV={unguardedRepos:IV(`guardrails.unguardedRepos`),blockedPaths:IV(`guardrails.blockedPaths`),unreadablePaths:IV(`guardrails.unreadablePaths`)};u(LV,{error:`guardrails must be an object`}).passthrough().optional();var RV={enabled:X(`telemetry.enabled`)};u(RV,{error:`telemetry must be an object`}).strict().optional(),u(RV,{error:`telemetry must be an object`}).passthrough().optional();var zV={scope:`browser`,access:`editable`,takesEffect:`now`},BV={scope:`browser`,access:`advanced`,takesEffect:`now`},Z={scope:`machine`,access:`editable`,takesEffect:`now`},VV={scope:`machine`,access:`editable`,takesEffect:`new-sessions`},HV={scope:`machine`,access:`readout`,takesEffect:`now`},Q={scope:`machine`,access:`file-only`},UV=1e3,WV=60,GV=60,KV=UV*WV,qV=KV*GV,JV=qV*24,YV={label:`investigations`,storedPerDisplay:1},XV={label:`sessions`,storedPerDisplay:1},ZV={label:`recurrences`,storedPerDisplay:1},QV={label:`actions`,storedPerDisplay:1},$V={label:`seconds`,storedPerDisplay:1},eH={label:`minutes`,storedPerDisplay:1},tH={label:`hours`,storedPerDisplay:1},nH={label:`days`,storedPerDisplay:1},rH={label:`seconds`,storedPerDisplay:UV,storedLabel:`ms`},iH={label:`minutes`,storedPerDisplay:KV,storedLabel:`ms`},aH={label:`minutes`,storedPerDisplay:WV,storedLabel:`seconds`},oH={label:`hours`,storedPerDisplay:qV,storedLabel:`ms`},sH={label:`hours`,storedPerDisplay:GV,storedLabel:`minutes`},cH={label:`days`,storedPerDisplay:JV,storedLabel:`ms`},lH={label:`USD`,storedPerDisplay:1},uH={label:`users`,storedPerDisplay:1},dH={label:`reviews per hour`,storedPerDisplay:1},fH={label:`times`,storedPerDisplay:1},$=`A tuning knob kept out of the Settings view; the default suits almost every install.`,pH=`A diagnostic switch kept out of the Settings view; change it in config.json while investigating.`,mH=`Changes how the server process or its worktrees behave, so it is set in config.json with a restart or new sessions in mind.`,hH=`A structured value with no dashboard control; edit it in config.json.`,gH=`Never editable from the dashboard by rule; edit it in config.json.`;function _H(e){return e.map(e=>({value:e,label:e[0].toUpperCase()+e.slice(1)}))}var vH=Object.freeze({"machine-terminal":{title:`Terminal`,description:`Terminal behavior shared by dashboard clients.`},"machine-detection-sessions":{title:`Detection and sessions`,description:`Config-file-only detection, timing, worktree and process settings.`},"lanes-ingest":{title:`Ingest`,description:`The machine-context sources behind Visions.`}}),yH=Object.freeze([{id:`browser-appearance`,level:`browser`,title:`Appearance`,description:`How this browser draws the dashboard.`,legacyIds:[`browser-flying-animals`,`animals`,`flying-animals`],settings:[{id:`theme`,path:`pref:themeId`,title:`Theme`,description:`Color scheme for the dashboard.`,control:`select`,optionsFrom:`themes`,keywords:[`color`,`palette`],defaultValue:`phyrexian`,...zV},{id:`session-usage-chips`,path:`pref:sessionUsageChips`,title:`Show usage on session cards`,description:`Shows each card's transcript token count and CLI-reported cost when available, otherwise a calculated API list-price estimate.`,control:`toggle`,keywords:[`usage`,`cost`,`tokens`,`card`,`price`],defaultValue:!1,...zV},{id:`phone-arrow-pad`,path:`pref:phoneArrowPad`,title:`Swipe arrow pad on phone (experimental)`,description:`Replace the four arrow keys above the phone keyboard with one pad: swipe on it to send arrow keys, one per short drag.`,control:`toggle`,keywords:[`experimental`,`mobile`,`keys`,`arrows`,`swipe`,`gesture`],defaultValue:!1,...zV},{id:`flying-animals`,path:`pref:flyingAnimalsEnabled`,title:`Flying animals`,description:`Show animated animals flying across the dashboard.`,control:`toggle`,keywords:[`animation`,`motion`,`animals`],defaultValue:!1,...zV},{id:`animals-min-gap`,path:`pref:flyingAnimalsMinGapSeconds`,title:`Time between flights: minimum`,description:`Shortest pause between flights.`,control:`number`,integer:!1,step:.1,range:It,unit:$V,maximumSettingId:`animals-max-gap`,keywords:[`animals`,`frequency`],defaultValue:ct.flyingAnimalsMinGapSeconds,...BV},{id:`animals-max-gap`,path:`pref:flyingAnimalsMaxGapSeconds`,title:`Time between flights: maximum`,description:`Longest pause between flights.`,control:`number`,integer:!1,step:.1,range:It,unit:$V,keywords:[`animals`,`frequency`],defaultValue:ct.flyingAnimalsMaxGapSeconds,...BV},{id:`animals-min-duration`,path:`pref:flyingAnimalsMinDurationSeconds`,title:`Flight duration: minimum`,description:`Shortest flight, for faster animals.`,control:`number`,integer:!1,step:.1,range:qe,unit:$V,maximumSettingId:`animals-max-duration`,keywords:[`animals`,`speed`],defaultValue:ct.flyingAnimalsMinDurationSeconds,...BV},{id:`animals-max-duration`,path:`pref:flyingAnimalsMaxDurationSeconds`,title:`Flight duration: maximum`,description:`Longest flight, for slower animals.`,control:`number`,integer:!1,step:.1,range:qe,unit:$V,keywords:[`animals`,`speed`],defaultValue:ct.flyingAnimalsMaxDurationSeconds,...BV},{id:`animals-scale`,path:`pref:flyingAnimalsScale`,title:`Size multiplier`,description:`Scale applied on top of the viewport size.`,control:`number`,integer:!1,step:.1,range:Gt,unit:fH,keywords:[`animals`,`size`],defaultValue:ct.flyingAnimalsScale,...BV},{id:`animals-on-phone`,path:`pref:flyingAnimalsOnPhone`,title:`Show on phone layout`,description:`Allow flights on the phone layout.`,control:`toggle`,keywords:[`animals`,`mobile`],defaultValue:ct.flyingAnimalsOnPhone,...BV}]},{id:`browser-notifications`,level:`browser`,title:`Notifications`,description:`How this browser, and the Telegram bot shared by every lane, get your attention.`,settings:[{id:`alert-sounds-enabled`,path:`pref:soundEnabled`,title:`Alert sounds`,legacyIds:[{sectionId:`browser-appearance`,settingId:`alert-sounds-enabled`}],description:`Play sounds when a session needs attention and when a merge celebration plays. The same switch as the note button in the desktop header.`,control:`toggle`,keywords:[`audio`,`mute`,`sound`,`notification`],defaultValue:!0,...zV},{id:`alert-sound`,path:`pref:soundId`,title:`Alert sound`,legacyIds:[{sectionId:`browser-appearance`,settingId:`alert-sound`}],description:`Sound played when a session needs attention. Your own .ogg, .mp3, .wav, .m4a or .webm files dropped into the sounds folder of the Glimmervoid home (~/.glimmervoid/sounds/, or $GLIMMERVOID_HOME/sounds/) are listed after the built-in sounds. Glimmervoid never creates that folder, so make it yourself; new files show up the next time Settings opens.`,control:`select`,optionsFrom:`sounds`,keywords:[`audio`,`notification`,`custom`],defaultValue:`chime`,...zV},{id:`desktop-notifications`,path:`pref:notificationsEnabled`,title:`Desktop notifications`,legacyIds:[{sectionId:`browser-appearance`,settingId:`desktop-notifications`}],description:`Raise a browser notification when a session needs attention while this dashboard is in the background.`,control:`toggle`,keywords:[`browser`,`attention`],defaultValue:!0,...zV}]},{id:`machine-telegram`,level:`machine`,parent:`browser-notifications`,title:`Telegram`,description:`One bot shared by session, PR review and PostHog notifications.`,legacyIds:[`telegram`,`notifications`],settings:[{id:`telegram-bot-token`,path:`telegram.botToken`,title:`Bot token`,description:`Credential used by the shared Telegram bot. Create a bot by messaging @BotFather in Telegram and sending /newbot; it replies with this token. When GLIMMERVOID_TELEGRAM_BOT_TOKEN supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`api`],defaultValue:``,...Z},{id:`telegram-chat-id`,path:`telegram.chatId`,title:`Chat id`,description:`Destination chat for enabled Telegram lanes. Send your bot any message, then open https://api.telegram.org/bot<token>/getUpdates in a browser and copy the number under message.chat.id.`,control:`text`,keywords:[`destination`,`channel`],defaultValue:``,...Z},{id:`telegram-session-notifications`,path:`telegramNotifications`,title:`Send session notifications`,description:`Send session completion, input and failure alerts when no dashboard is open. Unacknowledged alerts also escalate after the phone escalation delay while a dashboard remains open.`,control:`toggle`,keywords:[`phone`,`off dashboard`,`test`],defaultValue:!1,status:`telegram-delivery`,...Z}]},{id:`machine-sessions`,level:`machine`,title:`Sessions`,description:`How sessions start, where projects are found, and what the dashboard shows for them.`,legacyIds:[`machine-general`,`general`,`machine-repositories`,`repos`,`repositories`],settings:[{id:`auto-resume`,path:`autoResume`,title:`Auto-resume sessions on startup`,description:`Resume conversations that were live when Glimmervoid last shut down or crashed, and tell sessions that were mid-turn, or had a background agent, monitor or scheduled wakeup in flight, to continue.`,control:`toggle`,keywords:[`startup`,`conversation`],defaultValue:!0,...Z},{id:`conversation-view`,path:`conversationView`,title:`Conversation view (experimental)`,description:`Let each Claude Code and Codex session turn on a Conversation face from its card menu, which renders the transcript as messages, approvals and a composer. Sessions stay on the terminal until you turn it on for them. A Claude Code session started while this is on can answer its permission prompts and questions there. A Codex session connects on its next start, through a local app-server so approvals can be answered from the dashboard; guarded Codex sessions and those that bypass Codex hook trust keep the terminal only.`,control:`toggle`,keywords:[`experimental`,`transcript`,`chat`,`codex`,`claude`],defaultValue:!1,...Z},{id:`zen-view`,path:`zenView`,title:`Zen view (experimental)`,description:`Add a Zen tab that shows no terminal until a session needs you, then shows only that session and what it needs.`,control:`toggle`,keywords:[`experimental`,`calm`,`focus`,`attention`,`needs you`],defaultValue:!1,...Z},{id:`tab-order`,path:`viewTabOrder`,title:`Tab order`,description:`The order of the dashboard tabs in every browser: the header on desktop and the More menu on a phone. You can also drag a tab in the desktop header.`,control:`tab-order`,keywords:[`tabs`,`order`,`rearrange`,`reorder`,`header`,`more`,`menu`],defaultValue:[],...Z},{id:`remote-sessions`,path:`remoteSessions`,title:`Remote Coder sessions (experimental)`,description:`Offer the Coder environments in config.json when adding a session, so the session runs in its own Coder workspace instead of on this machine. Off refuses new remote sessions; ones already running keep working until closed.`,control:`toggle`,keywords:[`experimental`,`coder`,`remote`,`workspace`,`cloud`],defaultValue:!1,...Z},{id:`streamer-mode`,path:`streamerMode`,title:`Streamer mode`,description:`Hide sensitive details in the dashboard while screen sharing or streaming.`,control:`toggle`,keywords:[`streaming`,`screen share`,`privacy`],defaultValue:!1,...Z},{id:`repository-roots`,path:`repoRoots`,title:`Repository roots`,description:`Directories scanned for projects when adding sessions.`,control:`list`,keywords:[`folders`,`project discovery`],defaultValue:[],listPlaceholder:`Repository root path`,listEmptyText:`No repository roots configured.`,...Z},{id:`custom-agents`,path:`status:custom-agents`,title:`Custom agents`,description:`Extra agent CLIs a session can be spawned with, declared under customAgents in config.json.`,control:`readonly`,keywords:[`adapters`,`cli`],status:`custom-agents`,...HV},{id:`agent-logins`,path:`status:agent-logins`,title:`Agent logins`,description:`How Claude Code and Codex sign in inside a Coder workspace. Each uses the login already on this machine; Connect signs one in for Glimmervoid alone when there is none.`,control:`readonly`,keywords:[`claude`,`codex`,`sign in`,`login`,`coder`,`remote`],status:`agent-logins`,...HV},{id:`remote-setup`,path:`status:remote-setup`,title:`Remote host setup`,description:`Start a session that walks you through running Glimmervoid on another Linux machine you reach by ssh, as a service you open from your laptop and phone.`,control:`readonly`,keywords:[`remote`,`ssh`,`server`,`devbox`,`tailscale`,`pair`,`host`],status:`remote-setup`,...HV}]},{id:`machine-guardrails`,level:`machine`,title:`Guardrails and unattended`,description:`What a guarded session may touch, and which unattended actions automated work may take. Claude Code sessions on Linux and macOS write anywhere this account can, except credentials, Glimmervoid's own state and the blocked folders here.`,legacyIds:[`lanes-unattended`,`unattended`],settings:[{id:`skip-permissions-by-default`,path:`skipPermissionsByDefault`,title:`Skip permission prompts by default`,description:`Start sessions whose project sets no permission choice with the agent CLI permission bypass flag.`,control:`toggle`,keywords:[`permissions`,`yolo`,`dangerously`],danger:!0,warning:`Enabling this control lets agents edit files and run shell commands without asking, and restarts running sessions that inherit it.`,defaultValue:!1,...Z},{id:`sane-yolo`,path:`saneYolo`,title:`Sane YOLO`,description:`Block catastrophic commands in sessions that skip permission prompts when the cc-safety-net executable is available and trusted hooks are installed. Missing or untrusted hooks leave a session unprotected.`,control:`toggle`,keywords:[`permissions`,`yolo`,`safety`],defaultValue:!0,...VV},{id:`rtk-compression`,path:`rtk`,title:`rtk output compression`,description:`Compress Bash output with the rtk executable.`,control:`toggle`,keywords:[`bash`,`tokens`],danger:!0,status:`rtk-install`,warning:`Enabling this control permits Glimmervoid to install the pinned rtk executable automatically.`,defaultValue:!1,...VV},{id:`post-turn-checks-mode`,path:`postTurnChecks.mode`,title:`Post-turn checks mode`,description:`Default mode for post-turn checks. Project and individual rule modes override it, so Report can still allow file fixes.`,control:`select`,options:_H(MV),keywords:[`quality`,`fixes`],defaultValue:`report`,...Z},{id:`branch-gc-delete-unmerged`,path:`branchGc.deleteUnmerged`,title:`Delete unmerged branches`,description:`Also delete stale remote branches with no merge proof. Off keeps every unmerged branch.`,control:`toggle`,keywords:[`git`,`cleanup`,`orphan`],danger:!0,warning:`Enabling this control lets branch cleanup delete stale remote branches without merge proof.`,defaultValue:!1,...Z},{id:`guardrails-unguarded-repos`,path:`guardrails.unguardedRepos`,title:`Unguarded repositories`,description:`Folders whose sessions run without guardrails. A session started in one of these folders, or below it, is not guarded.`,control:`list`,keywords:[`guardrails`,`opt out`,`dotfiles`],danger:!0,warning:`A session without guardrails can read credentials and write anywhere this account can.`,defaultValue:[],listPlaceholder:`Folder path`,listEmptyText:`Every repository is guarded.`,...VV},{id:`guardrails-blocked-paths`,path:`guardrails.blockedPaths`,title:`Blocked folders`,description:`Extra folders and files a guarded session cannot write, on top of credentials and Glimmervoid's own state. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`block`,`protect`],defaultValue:[],listPlaceholder:`~/folder`,listEmptyText:`Only the built-in list is blocked.`,...VV},{id:`guardrails-unreadable-paths`,path:`guardrails.unreadablePaths`,title:`Unreadable folders`,description:`Extra folders and files a guarded session cannot read, on top of the built-in credential list. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`secrets`,`credentials`],defaultValue:[],listPlaceholder:`~/folder`,listEmptyText:`Only the built-in credential list is unreadable.`,...VV}]},{id:`machine-updates`,level:`machine`,title:`Updates`,description:`See which Glimmervoid version is running, which one is newest, and update in one step.`,legacyIds:[`updates`],settings:[{id:`update-actions`,path:`status:update-actions`,title:`Status and actions`,legacyIds:[`update-summary`,`update-installed`,`update-latest`,`update-last-checked`].map(e=>({sectionId:`machine-updates`,settingId:e})),description:`Whether this install is up to date, the running and newest versions, the last check, and the update and restart actions.`,control:`readonly`,keywords:[`version`,`available`,`current`,`check`,`restart`,`commit`,`installed`,`release`,`failure`],status:`update-actions`,...HV},{id:`update-channel`,path:`updateChannel`,title:`Channel`,description:`Track tagged releases or the upstream of the checked-out branch.`,control:`select`,options:_H(jV),keywords:[`release`,`branch`],defaultValue:`release`,...Z},{id:`check-updates`,path:`checkForUpdates`,title:`Check for updates automatically`,description:`Check for a newer Glimmervoid at launch, while a dashboard is connected, and when this page opens.`,control:`toggle`,keywords:[`release`,`github`],defaultValue:!0,...Z}]},{id:`machine-usage`,level:`machine`,title:`Usage`,description:`Local transcript accounting and estimated-cost budgets.`,legacyIds:[`usage`],settings:[{id:`usage-enabled`,path:`usage.enabled`,title:`Track token usage`,description:`Read local CLI transcripts and roll them into the Usage view and session chips.`,control:`toggle`,keywords:[`tokens`,`cost`],defaultValue:!0,status:`usage-last-report`,...Z},{id:`usage-retain-days`,path:`usage.retainDays`,title:`Retain transcript detail`,description:`How long live transcript detail stays available. A monthly budget keeps detail from the start of the current month when that is longer.`,control:`number`,range:Pe,unit:nH,keywords:[`history`,`retention`],defaultValue:90,...Z},{id:`usage-daily-budget`,path:`usage.budget.dailyUsd`,title:`Daily budget`,description:`Estimated daily spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:qt,unit:lH,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01,...Z},{id:`usage-monthly-budget`,path:`usage.budget.monthlyUsd`,title:`Monthly budget`,description:`Estimated monthly spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:qt,unit:lH,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01,...Z}]},{id:`lanes-visions`,level:`lanes`,title:`Visions`,description:`Editor-buffer findings, bounded model comments, and the machine-context ingest behind them.`,legacyIds:[`lanes`,`visions`,`lanes-ingest`,`ingest`],settings:[{id:`visions-enabled`,path:`visions.enabled`,title:`Enable Visions`,description:`Set up supported editors detected on this machine, then show their buffer findings in the Visions view.`,control:`toggle`,keywords:[`editor`,`findings`,`lsp`],defaultValue:!1,...Z},{id:`visions-dispatch-enabled`,path:`visions.dispatch.enabled`,title:`Enable model comments`,description:`Start bounded review sessions for local editor buffers.`,control:`toggle`,keywords:[`review`,`dispatch`],defaultValue:!1,...Z},{id:`visions-max-per-hour`,path:`visions.dispatch.maxPerHour`,title:`Max per hour`,description:`Maximum review sessions dispatched per hour. One slot is reserved for edit reviews; activity-driven reviews take the rest, up to the activity cap set by visions.dispatch.activityMaxPerHour.`,control:`number`,range:zt,unit:dH,keywords:[`rate limit`,`reviews`],defaultValue:6,...Z},{id:`visions-model`,path:`visions.dispatch.model`,title:`Model override`,description:`Leave blank to use the opus model alias.`,control:`text`,keywords:[`claude`,`override`],defaultValue:``,...Z},{id:`visions-projects`,path:`visions.projects`,title:`Projects`,description:`Clear every selection, including unavailable projects, to accept buffers from every configured project.`,control:`projects`,keywords:[`repositories`,`filter`],defaultValue:[],...Z},{id:`visions-auto-fix`,path:`visions.autoFix`,title:`Apply tier 1 fixes`,description:`Allow Visions to edit eligible open Markdown buffers, including inactive buffers, without asking.`,control:`toggle`,keywords:[`automatic`,`edits`],danger:!0,warning:`Enabling this control lets Visions edit eligible buffers without a carbon unit present.`,defaultValue:!1,...Z},{id:`ingest-enabled`,path:`ingest.enabled`,title:`Enable machine context ingest`,description:`Enable the local activity feed behind Visions. Turning Visions on enables ingest unless ingest.enabled is explicitly false.`,control:`toggle`,keywords:[`events`,`activity`,`ingest`],defaultValue:!1,...Z}]},{id:`lanes-posthog`,level:`lanes`,title:`PostHog`,description:`Error monitoring, investigations and traffic-spike alerts.`,legacyIds:[`posthog`],settings:[{id:`posthog-enabled`,path:`posthog.enabled`,title:`Enable PostHog monitoring`,description:`Poll PostHog error tracking and investigate issues that move.`,control:`toggle`,keywords:[`errors`,`monitoring`],defaultValue:!1,...Z},{id:`posthog-host`,path:`posthog.host`,title:`Host`,description:`PostHog cloud or self-hosted HTTP URL.`,control:`text`,keywords:[`url`,`server`],defaultValue:`https://us.posthog.com`,...Z},{id:`posthog-api-key`,path:`posthog.apiKey`,title:`Personal API key`,description:`Credential with read access to PostHog projects. When GLIMMERVOID_POSTHOG_API_KEY supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`token`],defaultValue:``,...Z},{id:`posthog-projects`,path:`posthog.projects`,title:`Projects`,description:`PostHog project ids to monitor. config.json holds "all" or an array of ids, and an empty array monitors no project. In Settings that empty array shows as none, and an empty list saves "all".`,control:`list`,keywords:[`project ids`,`filter`],defaultValue:`all`,valueKind:`posthog-projects`,listPlaceholder:`Project id`,listEmptyText:`Every project the key can read.`,...Z},{id:`posthog-interval`,path:`posthog.intervalMinutes`,title:`Poll interval`,description:`Delay between PostHog polling passes.`,control:`number`,integer:!1,step:`any`,range:zt,unit:eH,keywords:[`refresh`,`schedule`],defaultValue:15,...Z},{id:`posthog-max-investigations`,path:`posthog.maxConcurrentInvestigations`,title:`Max concurrent investigations`,description:`Maximum investigation sessions running together.`,control:`number`,range:zt,unit:YV,keywords:[`parallel`,`workers`],defaultValue:2,...Z},{id:`posthog-min-users`,path:`posthog.minUsersToInvestigate`,title:`Min users to investigate`,description:`Minimum affected users for a new issue investigation. Regressions, worsening issues and eligible error spikes bypass this minimum.`,control:`number`,range:zt,unit:uH,keywords:[`threshold`,`affected`],defaultValue:1,...Z},{id:`posthog-traffic-enabled`,path:`posthog.trafficSpikeEnabled`,title:`Traffic spike alerts`,description:`Ping when recent unique users exceed a project baseline.`,control:`toggle`,keywords:[`analytics`,`alert`],defaultValue:!0,...Z},{id:`posthog-auto-fix`,path:`posthog.autoFix`,title:`Attempt fixes for major issues`,description:`Allow an isolated agent to fix an issue, push a branch and open a pull request.`,control:`toggle`,keywords:[`automatic`,`pull request`],danger:!0,warning:`Enabling this control lets PostHog fixes commit, push and open pull requests automatically.`,defaultValue:!1,...Z}]},{id:`lanes-team-review`,level:`lanes`,title:`Team review`,description:`Draft reviews of teammates' pull requests for you to post from the Reviews tab.`,legacyIds:[`team-review`,`reviews`],settings:[{id:`team-review-enabled`,path:`teamReview.enabled`,title:`Enable team review`,description:`Poll open pull requests from the team and draft a review of each one. Nothing is posted until you choose Approve or Comment.`,control:`toggle`,keywords:[`pull requests`,`github`],defaultValue:!1,...Z},{id:`github-teams`,path:`github.teams`,title:`GitHub teams`,description:`Teams to search for review requests and members, one org/slug per entry. Leave empty to fall back to the legacy teamReview.org and teamReview.team keys in config.json.`,control:`list`,keywords:[`github`,`teams`,`review requests`],defaultValue:[],listPlaceholder:`org/team-slug`,listEmptyText:`No GitHub teams configured.`,...Z},{id:`team-review-re-review-after-hours`,path:`teamReview.reReviewAfterHours`,title:`Re-review after`,description:`When a reviewed PR has a new head, review it again after this long since its last review. Re-run review runs it at any time.`,control:`number`,range:zt,unit:tH,keywords:[`review`,`delay`],defaultValue:24,integer:!1,step:.5,...Z},{id:`team-review-skip-idle-after-days`,path:`teamReview.skipIdleAfterDays`,title:`Skip PRs idle for`,description:`Leave pull requests without GitHub activity for this long out of automatic review.`,control:`number`,range:zt,unit:nH,keywords:[`idle`,`activity`],defaultValue:14,integer:!1,step:.5,...Z},{id:`team-review-skill`,path:`teamReview.skill`,title:`Review skill`,description:`Name of a Claude Code skill installed for the review agent, for example your own PR review skill. Leave empty to let the agent review with whatever skills it has.`,control:`text`,keywords:[`skill`,`claude code`,`pr review`],defaultValue:``,...Z},{id:`team-review-auto-rebase-my-prs`,path:`teamReview.autoRebaseMyPrs`,title:`Keep my pull requests rebased`,description:`On each poll, rebase your open, non-draft pull requests that are behind their base branch. A pull request with conflicts or checks still running is left alone, and a failed rebase is not retried until you push again.`,control:`toggle`,keywords:[`rebase`,`update branch`,`behind`,`my prs`],danger:!0,warning:`Enabling this control rewrites your pull request branches on GitHub. Pull before you push from a local checkout of one.`,defaultValue:!1,...Z},{id:`team-review-keep-mergeable-enabled`,path:`teamReview.keepMergeableEnabled`,title:`Keep mergeable`,description:`Offer Keep mergeable on your pull requests: a guarded agent repairs conflicts and failing checks and pushes the repair. Off hides the control and starts no repair; the pull requests you chose stay chosen for when you turn it back on.`,control:`toggle`,keywords:[`repair`,`conflicts`,`my prs`],defaultValue:!0,...Z},{id:`team-review-keep-mergeable-timeout`,path:`teamReview.keepMergeableTimeoutMinutes`,title:`Keep mergeable deadline`,description:`Longest a Keep mergeable repair session may run before it is stopped and nothing is pushed.`,control:`number`,range:Qe,unit:eH,keywords:[`timeout`,`repair`],defaultValue:30,...Z},{id:`team-review-merge-queue-enabled`,path:`teamReview.mergeQueueEnabled`,title:`Merge when ready`,description:`Offer Merge when ready on your pull requests: queued pull requests are rebased when behind and merged once ready, one per repository per poll. Off hides the control and merges nothing; the queue is kept for when you turn it back on.`,control:`toggle`,keywords:[`merge queue`,`auto merge`,`my prs`],defaultValue:!0,...Z}]},{id:`lanes-workflows`,level:`lanes`,title:`Workflows`,description:`Rules that act on pull request events in the repositories you choose.`,legacyIds:[`workflows`],settings:[{id:`workflows-enabled`,path:`workflows.enabled`,title:`Run workflows`,description:`Poll the repositories your enabled rules watch and run their actions. Off stops polling and every action, whatever each rule says.`,control:`toggle`,keywords:[`pull requests`,`automation`,`master switch`],defaultValue:!0,...Z},{id:`workflows-max-concurrent-sessions`,path:`workflows.maxConcurrentSessions`,title:`Concurrent agent sessions`,description:`Most workflow agent sessions running at once. Up to twenty later spawns wait for a free slot; additional spawns are dropped and logged.`,control:`number`,range:ze,unit:XV,keywords:[`parallel`,`spawn`],defaultValue:2,...Z},{id:`workflows-rules`,path:`status:workflow-rules`,title:`Workflow rules`,description:`Each rule watches repositories for one pull request event (opened, checks-failed, review-requested, approved, commented or merged), narrows it by author, labels, base branch, your own pull requests or a review request to your team, and then notifies you, labels or comments on the pull request, or starts a guarded agent session that pushes nothing. Rules start disabled. Turn each rule on or off here; everything else about a rule is set in config.json under workflows.rules.`,control:`readonly`,keywords:[`pull requests`,`automation`,`github`,`rules`],status:`workflows`,...HV}]},{id:`lanes-benchmarks`,level:`lanes`,title:`Benchmarks`,description:`Compare agent setups on frozen cases from the suites in the benchmarks folder of the Glimmervoid home.`,legacyIds:[`benchmarks`],settings:[{id:`benchmarks-enabled`,path:`benchmarks.enabled`,title:`Enable benchmarks`,description:`Show the Bench tab. Nothing runs until you choose Mine or Run there.`,control:`toggle`,keywords:[`eval`,`arms`,`recall`,`compare`],defaultValue:!1,...Z}]},{id:`lanes-coherence`,level:`lanes`,title:`Coherence (experimental)`,description:`Per-session Coherence hook status and decision journal for agent sessions.`,settings:[{id:`coherence-enabled`,path:`coherence.enabled`,title:`Show session Coherence`,description:`Shows each session's Coherence hook status and decision journal when the repository installed @posthog/coherence 1.8 or newer. Off by default.`,control:`toggle`,keywords:[`experimental`,`coherence`,`journal`,`decisions`],defaultValue:!1,...Z}]},{id:`machine-privacy`,level:`machine`,title:`Privacy`,description:`What Glimmervoid sends about itself.`,legacyIds:[`privacy`,`telemetry`],settings:[{id:`telemetry-enabled`,path:`telemetry.enabled`,title:`Send usage data`,description:`Helps us improve Glimmervoid. Sent under a random install id: version, platform, app starts, daily activity, session starts and ends with agent kind, exit kind and duration, errors as their type, error code and scrubbed stack frames, per session token counts, models and estimated costs from the usage scan, and a salted one-way hash of your Claude and Codex account ids so installs of one account count together. Never prompts, project information, error messages, paths, repository or branch names, objectives, terminal output, emails or names. Delete my data asks for everything sent under this install to be erased and starts a new install id. GLIMMERVOID_TELEMETRY=0, DO_NOT_TRACK=1 or CI=true turn it off regardless.`,control:`toggle`,keywords:[`telemetry`,`analytics`,`tracking`,`opt out`],defaultValue:!0,...Z}]},{id:`browser-shortcuts`,level:`browser`,title:`Shortcuts and about`,description:`Keyboard shortcuts, their reference and build information.`,legacyIds:[`shortcuts`],settings:[{id:`next-attention-key`,path:`pref:nextAttentionKeyCode`,title:`Jump to the next session needing you`,description:`The key held with Cmd on a Mac, or Alt elsewhere, that jumps to the next session needing you. Record a new one by pressing the whole shortcut.`,control:`shortcut-key`,keywords:[`shortcut`,`keyboard`,`hotkey`,`jump`,`next`,`attention`],defaultValue:`KeyJ`,...zV}]}]),bH=Object.freeze([{id:`file-debug-mode`,path:`debugMode`,title:`Debug mode`,group:`machine-sessions`,description:`Show session-card diagnostics for state, transitions and detection signals.`,control:`toggle`,keywords:[`diagnostics`,`state`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:pH,...Q},{id:`file-replay-buffer`,path:`replayBufferKB`,title:`Replay buffer`,group:`machine-terminal`,description:`PTY output retained for clients that reconnect or join late.`,control:`number`,range:de,unit:{label:`KB`,storedPerDisplay:1},keywords:[`history`,`backfill`],defaultValue:512,takesEffect:`new-sessions`,fileOnlyReason:$,...Q},{id:`file-session-memory-reserve`,path:`sessionMemoryReserveMB`,title:`Session memory reserve`,group:`machine-sessions`,description:`Free memory an automatic session start waits for; 0 starts sessions without checking.`,control:`number`,range:Ht,unit:{label:`MB`,storedPerDisplay:1},keywords:[`memory`,`headroom`],defaultValue:600,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-cursor-blink`,path:`cursorBlink`,title:`Cursor blink`,group:`machine-terminal`,description:`Blink the cursor in every terminal.`,control:`toggle`,keywords:[`caret`,`terminal`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-detect-background-agents`,path:`detectBackgroundAgents`,title:`Detect background agents`,group:`machine-detection-sessions`,description:`Hold completion while tracked background work is active.`,control:`toggle`,keywords:[`subagents`,`completion`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:pH,...Q},{id:`file-record-signals`,path:`recordSignals`,title:`Record structural signals`,group:`machine-detection-sessions`,description:`Keep forensic status and hook recordings for each session. Full capture (capture.enabled) records these signals even when this is off.`,control:`toggle`,keywords:[`recordings`,`diagnostics`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:pH,...Q},{id:`file-trace-enabled`,path:`trace.enabled`,title:`Capture session traces`,group:`machine-detection-sessions`,description:`Keep normalized Claude transcript traces for session debugging.`,control:`toggle`,keywords:[`transcripts`,`diagnostics`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:pH,...Q},{id:`file-detect-scheduled-wakeups`,path:`detectScheduledWakeups`,title:`Detect scheduled wakeups`,group:`machine-detection-sessions`,description:`Surface advisory wakeup timing for scheduled sessions.`,control:`toggle`,keywords:[`schedule`,`sleep`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:pH,...Q},{id:`file-worktree-auto-rebase`,path:`worktreeAutoRebase`,title:`Worktree auto-rebase`,group:`machine-detection-sessions`,description:`Rebase eligible session worktrees when the integration branch moves.`,control:`toggle`,keywords:[`git`,`branch`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:mH,...Q},{id:`file-worktree-sync-on-start`,path:`worktreeSyncOnStart`,title:`Worktree sync on start`,group:`machine-detection-sessions`,description:`Fetch origin and fast-forward the local integration branch before a session starts its worktree.`,control:`toggle`,keywords:[`git`,`fetch`,`fast-forward`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:mH,...Q},{id:`file-worktree-rerere`,path:`worktreeRerere`,title:`Worktree rerere`,group:`machine-detection-sessions`,description:`Reuse recorded Git conflict resolutions.`,control:`toggle`,keywords:[`git`,`conflicts`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:mH,...Q},{id:`file-integration-branch`,path:`integrationBranch`,title:`Integration branch`,group:`machine-detection-sessions`,description:`Base branch for session worktrees. Empty = each repo's default branch. Existing sessions are never retargeted.`,control:`text`,nullable:!0,keywords:[`git`,`merge`],defaultValue:null,takesEffect:`new-sessions`,fileOnlyReason:mH,...Q},{id:`file-worktree-root`,path:`worktreeRoot`,title:`Worktree root`,group:`machine-detection-sessions`,description:`Directory that contains session worktrees. Existing worktrees are never relocated.`,control:`text`,keywords:[`git`,`directory`],defaultValue:``,takesEffect:`new-sessions`,fileOnlyReason:mH,...Q},{id:`file-worktree-share`,path:`worktreeShare`,title:`Shared worktree paths`,group:`machine-detection-sessions`,description:`Local paths copied or linked during worktree preparation.`,control:`list`,keywords:[`files`,`context`],defaultValue:[`node_modules`,`.env`,`.env.local`,`.claude`],takesEffect:`new-sessions`,fileOnlyReason:gH,...Q},{id:`file-port`,path:`port`,title:`Local port`,group:`machine-detection-sessions`,description:`Port used by the local dashboard listener.`,control:`number`,range:b,unit:{label:`port`,storedPerDisplay:1},keywords:[`server`,`listener`],defaultValue:3e3,takesEffect:`restart`,fileOnlyReason:gH,...Q},{id:`file-notify-debounce-ms`,path:`notifyDebounceMs`,title:`Notification debounce`,group:`machine-detection-sessions`,description:`Delay used to coalesce notification state changes.`,control:`number`,integer:!1,step:`any`,range:zt,unit:rH,keywords:[`timer`,`alerts`],defaultValue:3e3,takesEffect:`new-sessions`,fileOnlyReason:$,...Q},{id:`file-phone-escalation-ms`,path:`phoneEscalationMs`,title:`Phone escalation delay`,group:`machine-detection-sessions`,description:`Delay before off-dashboard escalation.`,control:`number`,integer:!1,step:`any`,range:zt,unit:iH,keywords:[`timer`,`telegram`],defaultValue:3e5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-post-turn-checks`,path:`postTurnChecks`,title:`Post-turn checks`,group:`machine-detection-sessions`,description:`Deterministic checks run after eligible turns. The global mode is a default; project and individual rule modes can select fixes even when the global mode is report.`,control:`json`,keywords:[`quality`,`fixes`],defaultValue:{enabled:!0,mode:`report`,rules:{trailingWs:!0,finalNewline:!0,bom:!0,slop:!1}},takesEffect:`now`,fileOnlyReason:hH,...Q},{id:`file-branch-gc-enabled`,path:`branchGc.enabled`,title:`Branch cleanup`,group:`machine-detection-sessions`,description:`Enable cleanup of eligible session branches.`,control:`toggle`,keywords:[`git`,`cleanup`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:mH,...Q},{id:`file-branch-gc-worktrees`,path:`branchGc.worktrees`,title:`Local worktree cleanup`,group:`machine-detection-sessions`,description:`Enable cleanup of eligible local worktrees.`,control:`toggle`,keywords:[`git`,`worktree`,`cleanup`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:mH,...Q},{id:`file-branch-gc-prefixes`,path:`branchGc.prefixes`,title:`Branch cleanup prefixes`,group:`machine-detection-sessions`,description:`Branch prefixes that filter both remote branch cleanup and local worktree cleanup.`,control:`list`,keywords:[`git`,`branch`],defaultValue:[`glimmervoid/session/`,`worktree-agent-`],takesEffect:`now`,fileOnlyReason:mH,...Q},{id:`file-branch-gc-dry-run`,path:`branchGc.dryRun`,title:`Branch cleanup dry run`,group:`machine-detection-sessions`,description:`Report planned cleanup without deleting remote branches.`,control:`toggle`,keywords:[`git`,`safety`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:mH,...Q},{id:`file-branch-gc-stale-days`,path:`branchGc.staleDays`,title:`Branch stale days`,group:`machine-detection-sessions`,description:`Age threshold for orphan branch cleanup when unmerged deletion is on.`,control:`number`,integer:!1,step:`any`,range:zt,unit:nH,keywords:[`git`,`retention`],defaultValue:14,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-branch-gc-interval-ms`,path:`branchGc.intervalMs`,title:`Branch cleanup interval`,group:`machine-detection-sessions`,description:`Delay between branch cleanup passes.`,control:`number`,integer:!1,step:`any`,range:zt,unit:oH,keywords:[`git`,`schedule`],defaultValue:216e5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-custom-agents`,path:`customAgents`,title:`Custom agents`,group:`machine-detection-sessions`,description:`Extra agent CLIs a session can be spawned with. The Sessions section lists the declared agents and whether each command resolves.`,control:`json`,keywords:[`adapters`,`cli`],defaultValue:[],takesEffect:`new-sessions`,fileOnlyReason:gH,...Q},{id:`file-task-title-refiner-enabled`,path:`taskTitle.refiner.enabled`,title:`Refine task titles`,group:`machine-detection-sessions`,description:`Keep session card titles useful when prompts change topic by asking a model for a short title.`,control:`toggle`,keywords:[`title`,`refiner`,`card`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-task-title-refiner-model`,path:`taskTitle.refiner.model`,title:`Task title model`,group:`machine-detection-sessions`,description:`Claude model alias the title refiner asks.`,control:`text`,keywords:[`title`,`refiner`,`model`],defaultValue:`haiku`,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-task-title-refiner-min-interval`,path:`taskTitle.refiner.minIntervalSeconds`,title:`Task title refresh interval`,group:`machine-detection-sessions`,description:`Shortest pause between two title refinements of one session.`,control:`number`,integer:!1,step:`any`,range:De,unit:$V,keywords:[`title`,`refiner`,`interval`],defaultValue:60,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-task-title-refiner-timeout`,path:`taskTitle.refiner.timeoutSeconds`,title:`Task title timeout`,group:`machine-detection-sessions`,description:`Maximum time allowed for one title refinement.`,control:`number`,integer:!1,step:`any`,range:we,unit:$V,keywords:[`title`,`refiner`,`deadline`],defaultValue:60,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-codex`,path:`usage.vendors.codex`,title:`Track Codex usage`,group:`machine-usage`,description:`Include local Codex CLI transcripts in usage reports.`,control:`toggle`,keywords:[`openai`,`vendor`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-grok`,path:`usage.vendors.grok`,title:`Track Grok usage`,group:`machine-usage`,description:`Include local Grok CLI transcripts in usage reports.`,control:`toggle`,keywords:[`xai`,`vendor`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-fetch-pricing`,path:`usage.fetchPricing`,title:`Fetch current model prices`,group:`machine-usage`,description:`Load public model prices when usage tracking starts, using a cached table for up to one day. Falls back to cached or bundled prices if the fetch fails; no daily refresh runs while tracking continues.`,control:`toggle`,keywords:[`rates`,`models`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:$,...Q},{id:`file-usage-plan-limits`,path:`usage.planLimits`,title:`Show plan limits`,group:`machine-usage`,description:`Read the Claude plan limit the CLI reports and show it beside usage.`,control:`toggle`,keywords:[`plan`,`limits`,`quota`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-rtk-savings`,path:`usage.rtkSavings`,title:`Estimate rtk savings`,group:`machine-usage`,description:`Estimate the tokens rtk output compression saved and show it in the Usage view.`,control:`toggle`,keywords:[`rtk`,`savings`,`tokens`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-scan-interval`,path:`usage.scanIntervalMinutes`,title:`Scan interval`,group:`machine-usage`,description:`Periodic transcript polling interval. Session activity can also trigger scans between timer ticks.`,control:`number`,range:ie,unit:eH,keywords:[`poll`,`refresh`],defaultValue:5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-warehouse-retain-days`,path:`usage.warehouseRetainDays`,title:`Retain usage history`,group:`machine-usage`,description:`How long the daily usage warehouse keeps rolled-up totals after transcript detail expires.`,control:`number`,range:_.warehouseRetainDays,unit:nH,keywords:[`history`,`warehouse`,`retention`],defaultValue:365,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-session-block-hours`,path:`usage.sessionBlockHours`,title:`Session block length`,group:`machine-usage`,description:`Length of the rolling block the Usage view groups activity into.`,control:`number`,range:_.sessionBlockHours,unit:tH,keywords:[`block`,`window`,`hours`],defaultValue:5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-cost-mode`,path:`usage.costMode`,title:`Cost mode`,group:`machine-usage`,description:`Choose whether recorded costs, calculated costs or both can appear.`,control:`select`,options:_H(SV),keywords:[`pricing`,`estimate`],defaultValue:`auto`,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-extra-projects-dirs`,path:`usage.extraProjectsDirs`,title:`Extra transcript folders`,group:`machine-usage`,description:`Absolute paths of additional Claude projects folders the usage scan reads.`,control:`list`,keywords:[`transcripts`,`folders`,`scan`],defaultValue:[],takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-quiet-delay`,path:`visions.dispatch.quietMs`,title:`Quiet delay`,group:`lanes-visions`,description:`Editor quiet time before a scheduled review. Saves and blank-line boundaries can dispatch immediately, subject to the other review limits.`,control:`number`,range:zt,unit:rH,keywords:[`debounce`,`idle`],defaultValue:3e4,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-cooldown`,path:`visions.dispatch.cooldownMs`,title:`Cooldown`,group:`lanes-visions`,description:`Minimum delay between reviews of the same document. Initial orientation reviews bypass this delay.`,control:`number`,range:zt,unit:iH,keywords:[`rate limit`,`delay`],defaultValue:3e5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-activity-max-per-hour`,path:`visions.dispatch.activityMaxPerHour`,title:`Activity max per hour`,group:`lanes-visions`,description:`Maximum activity-driven reviews dispatched per hour, capped at the overall hourly limit minus one to reserve an edit-review slot.`,control:`number`,range:De,unit:dH,keywords:[`rate limit`,`events`],defaultValue:2,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-dispatch-timeout`,path:`visions.dispatch.dispatchTimeoutSeconds`,title:`Dispatch timeout`,group:`lanes-visions`,description:`Maximum time allowed for one review session.`,control:`number`,range:zt,unit:aH,keywords:[`deadline`,`review`],defaultValue:180,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-intent-thread-ttl`,path:`visions.intent.threadTtlMs`,title:`Intent thread lifetime`,group:`lanes-visions`,description:`How long an intent thread nobody advanced stays live before it retires.`,control:`number`,range:zt,unit:cH,keywords:[`intent`,`decay`,`thread`],defaultValue:2592e5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-terminal`,path:`ingest.sources.terminal.enabled`,title:`Terminal output source`,group:`lanes-ingest`,description:`Include terminal output in the ingest feed.`,control:`toggle`,keywords:[`pty`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-agent-logs`,path:`ingest.sources.agentLogs.enabled`,title:`Agent logs source`,group:`lanes-ingest`,description:`Include local agent logs in the ingest feed.`,control:`toggle`,keywords:[`transcript`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-git`,path:`ingest.sources.git.enabled`,title:`Git activity source`,group:`lanes-ingest`,description:`Include local Git activity in the ingest feed.`,control:`toggle`,keywords:[`commits`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-fs`,path:`ingest.sources.fs.enabled`,title:`File changes source`,group:`lanes-ingest`,description:`Include watched file changes in the ingest feed.`,control:`toggle`,keywords:[`filesystem`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-shell-history`,path:`ingest.sources.shellHistory.enabled`,title:`Shell history source`,group:`lanes-ingest`,description:`Include local shell history in the ingest feed.`,control:`toggle`,keywords:[`commands`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-editor`,path:`ingest.sources.editor.enabled`,title:`Editor events source`,group:`lanes-ingest`,description:`Include local editor events in the ingest feed.`,control:`toggle`,keywords:[`buffers`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-investigation-timeout`,path:`posthog.investigationTimeoutSeconds`,title:`Investigation timeout`,group:`lanes-posthog`,description:`Maximum time allowed for one investigation.`,control:`number`,integer:!1,step:`any`,range:zt,unit:aH,keywords:[`deadline`,`session`],defaultValue:900,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-escalation`,path:`posthog.userEscalationThreshold`,title:`Escalation threshold`,group:`lanes-posthog`,description:`Affected-user count that escalates an issue.`,control:`number`,range:zt,unit:uH,keywords:[`threshold`,`severity`],defaultValue:25,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-fix-timeout`,path:`posthog.fixTimeoutSeconds`,title:`Fix timeout`,group:`lanes-posthog`,description:`Maximum time allowed for one fix session.`,control:`number`,integer:!1,step:`any`,range:E,unit:aH,keywords:[`deadline`,`repair`],defaultValue:1800,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-traffic-multiplier`,path:`posthog.trafficSpikeMultiplier`,title:`Spike multiplier`,group:`lanes-posthog`,description:`Baseline multiplier required to classify a traffic spike.`,control:`number`,integer:!1,step:`any`,range:k,unit:fH,keywords:[`baseline`,`ratio`],defaultValue:3,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-traffic-min-users`,path:`posthog.trafficSpikeMinUsers`,title:`Min users to alert`,group:`lanes-posthog`,description:`Minimum recent unique users for an initial traffic-spike alert. Escalation and recovery alerts bypass this minimum.`,control:`number`,range:ye,unit:uH,keywords:[`threshold`,`analytics`],defaultValue:10,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-traffic-cooldown`,path:`posthog.trafficSpikeCooldownMinutes`,title:`Spike cooldown`,group:`lanes-posthog`,description:`Cooldown for new traffic spikes. Escalation and recovery alerts bypass it. Zero removes the time delay; repeated active-spike alerts are still suppressed.`,control:`number`,integer:!1,step:`any`,range:De,unit:sH,keywords:[`silence`,`delay`],defaultValue:360,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-traffic-baseline`,path:`posthog.trafficSpikeBaselineDays`,title:`Baseline window`,group:`lanes-posthog`,description:`Historical window used to calculate normal hourly traffic.`,control:`number`,range:pe,unit:nH,keywords:[`history`,`analytics`],defaultValue:7,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-recurrence-dedupe`,path:`posthog.recurrenceDedupe`,title:`Deduplicate recurring issues`,group:`lanes-posthog`,description:`Treat an issue seen again inside the recurrence window as the same investigation instead of opening a new one.`,control:`toggle`,keywords:[`recurrence`,`dedupe`,`issues`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-recurrence-window-days`,path:`posthog.recurrenceWindowDays`,title:`Recurrence window`,group:`lanes-posthog`,description:`How far back an issue counts as a recurrence of an investigated one.`,control:`number`,integer:!1,step:`any`,range:zt,unit:nH,keywords:[`recurrence`,`window`],defaultValue:7,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-transient-recurrence-limit`,path:`posthog.transientRecurrenceLimit`,title:`Transient recurrence limit`,group:`lanes-posthog`,description:`How many times a transient issue may recur before it is investigated again.`,control:`number`,integer:!1,step:`any`,range:zt,unit:ZV,keywords:[`recurrence`,`transient`,`limit`],defaultValue:3,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-repo-path`,path:`posthog.repoPath`,title:`Repository path`,group:`lanes-posthog`,description:`Absolute path of the local checkout investigations read and fixes branch from, for every project the project map does not name.`,control:`text`,keywords:[`repository`,`checkout`,`path`],defaultValue:``,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-project-map`,path:`posthog.projectMap`,title:`Project map`,group:`lanes-posthog`,description:`PostHog project id to a label: the name shown for that project, and, when it is an absolute path to a checkout, the repository its issues are investigated in.`,control:`json`,keywords:[`projects`,`repositories`,`map`],defaultValue:{},takesEffect:`now`,fileOnlyReason:hH,...Q},{id:`file-team-review-org`,path:`teamReview.org`,title:`GitHub organization (legacy)`,group:`lanes-team-review`,description:`Organization login that owns the team, for example PostHog. Read only when github.teams is empty.`,control:`text`,keywords:[`github`,`owner`,`legacy`],defaultValue:``,takesEffect:`now`,fileOnlyReason:`A legacy key: github.teams names teams as org/slug entries and wins whenever it is set.`,...Q},{id:`file-team-review-team`,path:`teamReview.team`,title:`GitHub team (legacy)`,group:`lanes-team-review`,description:`Team slug whose members and review requests are polled. Read only when github.teams is empty.`,control:`text`,keywords:[`github`,`slug`,`legacy`],defaultValue:``,takesEffect:`now`,fileOnlyReason:`A legacy key: github.teams names teams as org/slug entries and wins whenever it is set.`,...Q},{id:`file-workflows-max-actions-per-poll`,path:`workflows.maxActionsPerPoll`,title:`Actions per poll`,group:`lanes-workflows`,description:`Most actions run in one poll. The rest are dropped and logged.`,control:`number`,range:He,unit:QV,keywords:[`cap`,`rate limit`],defaultValue:20,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-workflows-rules`,path:`workflows.rules`,title:`Workflow rule definitions`,group:`lanes-workflows`,description:`The rules the Workflows section switches on and off: each names its repositories, one pull request event, its filters and its actions.`,control:`json`,keywords:[`pull requests`,`automation`,`rules`],defaultValue:[],takesEffect:`now`,fileOnlyReason:`Rule definitions are written in config.json; the Workflows section only switches each rule on or off.`,...Q}]),xH=Object.freeze({sections:yH,fileOnly:bH}),SH=Object.freeze(Object.fromEntries(yH.flatMap(e=>(e.legacyIds??[]).map(t=>[t,e.id])))),CH=Object.freeze(yH.reduce((e,t)=>{for(let n of t.settings)for(let r of n.legacyIds??[])e[r.sectionId]={...e[r.sectionId],[r.settingId]:t.id};return e},{}));function wH(e){let t=[],n=e=>{if(!e||typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};return t.push([e,n]),n},r=n(e);for(let e=t.pop();e;e=t.pop()){let[t,r]=e;for(let[e,i]of Object.entries(t))Object.defineProperty(r,e,{value:n(i),writable:!0,enumerable:!0,configurable:!0})}return r}function TH(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function EH(e,t){let n=t.split(`.`),r=e;for(let e of n.slice(0,-1)){if(!r||typeof r!=`object`)return;r=r[e]}r&&typeof r==`object`&&delete r[n.at(-1)]}function DH(e,t,n){let r=t.split(`.`),i=e;for(let e of r.slice(0,-1))(!i[e]||typeof i[e]!=`object`||Array.isArray(i[e]))&&(i[e]={}),i=i[e];i[r.at(-1)]=wH(n)}function OH(e){return e.flatMap(e=>e.settings)}function kH(e){return e.access===`file-only`||e.control===`readonly`}function AH(e){let t=String(e??``).trim().toLowerCase();if(!t||t===`all`)return`all`;if(t===`none`)return[];let n=t.split(`,`).map(e=>e.trim());return n.every(e=>/^\d+$/.test(e)&&Number.isSafeInteger(Number(e))&&Number(e)>0)?n.map(Number):null}var jH=6;function MH(e,t){return e.control===`number`&&typeof t==`number`?t/(e.unit?.storedPerDisplay??1):e.valueKind===`posthog-projects`?Array.isArray(t)?t.length===0?[`none`]:t.map(String):[]:wH(t)}function NH(e){return e.control===`number`&&(e.unit?.storedPerDisplay??1)!==1}function PH(e){return String(Number(e.toFixed(jH)))}function FH(e,t){let n=MH(e,t);return e.valueKind===`posthog-projects`&&Array.isArray(n)?n.join(`, `)||`all`:typeof n==`number`&&e.unit?`${PH(n)} ${e.unit.label}`:JSON.stringify(n??null)}function IH(e,t){if(e.control===`number`){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=Number(t);if(e.zeroIsNull&&n<=0)return null;let r=n*(e.unit?.storedPerDisplay??1);return e.integer===!1?r:Math.round(r)}if(e.valueKind===`posthog-projects`)return AH(Array.isArray(t)?t.join(`,`):t);if(e.control===`text`||e.control===`password`){let n=String(t??``).trim();return e.nullable&&!n?null:n}return wH(t)}function LH(e){return String(e||``).toLowerCase().match(/[a-z0-9]+/g)||[]}var RH=3,zH=2,BH=1,VH=3,HH=30,UH=16;function WH(e,t){return e===t?RH:e.startsWith(t)?zH:t.length>=VH&&e.includes(t)?BH:0}function GH(e,t,n){let r=0;for(let n of t){let t=Math.max(0,...e.map(e=>WH(e,n)));if(t===0)return 0;r+=t}return r*n}function KH(e){return e.options?.map(e=>e.label).join(`, `)??``}function qH(e){return tU(e.group??``)?.title??``}function JH(e,t,n){let r=GH(LH(e.title),n,1e3),i=GH(LH(e.keywords.join(` `)),n,100),a=GH(t,n,10),o=GH(LH(e.path),n,10),s=GH(LH(KH(e)),n,10),c=GH(LH(e.description),n,1);return r+i+a+o+s+c}function YH(e){return e.section?.title??``}function XH(e,t){return Number(e.section===null)-Number(t.section===null)}function ZH(e,t,n){return[[`title`,e.title],[`keywords`,e.keywords.join(` `)],[`section`,t?.title??qH(e)],[`description`,e.description],[`path`,e.path],[`options`,KH(e)]].flatMap(([e,t])=>{let r=[];for(let e of t.matchAll(/[a-z0-9]+/gi)){let t=e[0].toLowerCase();for(let i of n){if(WH(t,i)===0)continue;let n=e.index+t.indexOf(i);r.push({start:n,end:n+i.length})}}let i=[];for(let e of r.sort((e,t)=>e.start-t.start||e.end-t.end)){let t=i.at(-1);t&&e.start<=t.end?t.end=Math.max(t.end,e.end):i.push({...e})}return i.length?[{field:e,text:t,spans:i}]:[]})}function QH(e,t,n=[]){let r=LH(t).slice(0,UH);if(r.length===0)return[];let i=[];for(let t of e){let e=LH(t.title);for(let n of t.settings){let a=JH(n,e,r);a!==0&&i.push({section:t,setting:n,score:a,matches:ZH(n,t,r)})}}for(let e of n){let t=JH(e,LH(qH(e)),r);t!==0&&i.push({section:null,setting:e,score:t,matches:ZH(e,null,r)})}return i.sort((e,t)=>t.score-e.score||XH(e,t)||YH(e).localeCompare(YH(t))||e.setting.title.localeCompare(t.setting.title)).slice(0,HH)}function $H(e,t,n={},r={}){let i=/^#settings\/([^/]+)(?:\/([^/]+))?$/.exec(String(e||``));if(!i)return null;let a,o;try{a=decodeURIComponent(i[1]),o=i[2]?decodeURIComponent(i[2]):null}catch{return null}let s=n[a]||a,c=(o?r[s]?.[o]:void 0)||s,l=t.find(e=>e.id===c);if(!l)return null;let u=o?l.settings.find(e=>e.id===o||e.legacyIds?.some(e=>e.settingId===o&&e.sectionId===s)):null;return o&&!u?null:{sectionId:c,settingId:u?.id||null,hash:`#settings/${c}${u?`/${u.id}`:``}`}}function eU(e){let t=new Map,n=new Map;for(let r of[...OH(e.sections),...e.fileOnly])t.set(r.id,r),n.set(r.path,r);return{byId:t,byPath:n}}eU(xH);function tU(e,t=xH){let n=t.sections.find(t=>t.id===e);return n?{title:n.title,description:n.description}:vH[e]??null}function nU({checked:e=[],stored:t=[],rendered:n=[]}={}){let r=new Set(n),i=[...e];for(let e of t)typeof e==`string`&&e.trim()&&(r.has(e)||i.includes(e)||i.push(e));return i}function rU(e,t){let n=new Set(e.map(e=>e.id)),r=[...new Set(t)].filter(e=>!n.has(e));return[...e,...r.map(e=>({id:e,name:`Unavailable project (${e})`}))]}var iU=new WeakMap,aU=`Configured`,oU=`•`.repeat(12),sU=`Each line must be a positive whole-number PostHog project id, or the one word none.`,cU=3,lU=200,uU=new Set([`customAgents`]),dU=1e-9,fU=`Lanes`,pU=Object.freeze({now:`Applies now`,"new-sessions":`New sessions`,restart:`After restart`}),mU=Object.freeze({browser:`This browser`,machine:`This machine`});function hU(e,t){let n=t.secretSources;if(!n||typeof n!=`object`)return null;let r=n[e.path];return typeof r==`string`?r:null}function gU(e){let t=e.rtkInstall;return t?.status===`installing`?`No rtk binary found. Glimmervoid is installing it into ~/.glimmervoid/bin now.`:e.rtkInstallSupported===!1?`No rtk binary found. Automatic installation is unavailable on this server platform; install a compatible binary manually.`:t?.status===`failed`?`No rtk binary found. The last install attempt failed: ${t.reason||`unknown reason`}. A save can retry after the ten-minute failure cooldown; saves during the cooldown skip installation.`:`No rtk binary found. Saving requests installation into ~/.glimmervoid/bin on supported server platforms, subject to installer eligibility.`}function _U(e){return e.control===`password`}function vU(e){return`${e.path}${aU}`}function yU(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>yU(e,t[n]));if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&yU(e[n],t[n]))}function bU(e){return iU.get(e)||null}function xU(e){return Array.isArray(e)?e.map(e=>String(e)):[]}function SU(e){return e.split(`
173
- `).map(e=>e.trim()).filter(e=>e!==``)}function CU(e){let t=e.range;if(!t)return null;let n={min:Number(MH(e,t.min))};return t.max!=null&&(n.max=Number(MH(e,t.max))),t.exclusiveMin&&(n.exclusiveMin=!0),n}function wU(e){let t=`Default ${FH(e,e.defaultValue)}`;return NH(e)?`${t}, stored as ${JSON.stringify(e.defaultValue)} ${e.unit?.storedLabel??``}`.trimEnd():t}function TU(e,t){let n=wU(e),r=uU.has(e.path)?void 0:TH(t,e.path);if(r===void 0)return{currentText:null,defaultText:n,jsonFragment:null};let i={};return DH(i,e.path,r),{currentText:`Current ${FH(e,r)}`,defaultText:n,jsonFragment:JSON.stringify(i,null,2)}}function EU(e,t,n){let r=t??e.find(e=>e.id===n.group);if(!r)return tU(n.group??``)?.title??`config.json`;let i=e.find(e=>e.id===r.parent);return i?`${i.title} / ${r.title}`:r.level===`lanes`?`${fU} / ${r.title}`:r.title}function DU(e){let t=/^#settings(?:\?(.*))?$/.exec(String(e??``));if(!t)return null;let n=new URLSearchParams(t[1]??``).get(`q`)??``;return{query:Array.from(n.trim()).slice(0,lU).join(``).trim()}}function OU(e,t){return e.filter(e=>e.parent===t)}function kU(e,t){let n=e.find(e=>e.id===t);return n?n.parent?e.find(e=>e.id===n.parent)??n:n:null}function AU(e){return e.filter(e=>!e.parent)}function jU(e){let t=e.filter(e=>e.level===`lanes`);return[{heading:null,sections:e.filter(e=>e.level!==`lanes`)},{heading:fU,sections:t}].filter(e=>e.sections.length>0)}function MU(e,t,n,r){return r?`hidden`:n.trim()?`search`:t&&kU(e,t)?`section`:`list`}function NU(e,t={}){let n={};for(let r of OH(e)){if(kH(r))continue;if(r.path.startsWith(`pref:`)){let e=r.path.slice(5),i=t.prefs?.[e]??t[r.path];n[r.path]=MH(r,i??r.defaultValue);continue}if(_U(r)){let e=TH(t,vU(r))===!0;n[r.path]=e?oU:``;continue}let e=TH(t,r.path);n[r.path]=MH(r,e??r.defaultValue)}return iU.set(n,wH(t)),n}function PU(e,t,n){let r=OH(e).filter(e=>kH(e)||e.path.startsWith(`pref:`)||hU(e,bU(t)||{})||_U(e)&&n[e.path]===oU?!1:!yU(t[e.path],n[e.path]));if(r.length===0)return{};let i=bU(t)||{},a=(Array.isArray(i.projectChoices)?i.projectChoices:[]).map(e=>e.id).filter(e=>typeof e==`string`),o={},s=new Set;for(let e of r){let[r]=e.path.split(`.`);if(!e.path.includes(`.`)){o[r]=IH(e,n[e.path]);continue}if(!s.has(r)){let e=i[r];o[r]=e&&typeof e==`object`&&!Array.isArray(e)?wH(e):{},s.add(r)}let c=IH(e,n[e.path]);if(e.control===`projects`){let n=t[e.path];c=nU({checked:Array.isArray(c)?c:[],stored:Array.isArray(n)?n:[],rendered:rU(a.map(e=>({id:e,name:e})),Array.isArray(n)?n:[]).map(e=>e.id)})}DH(o,e.path,c)}for(let t of OH(e))_U(t)&&EH(o,vU(t));return delete o.secretSources,o}function FU(e,t,n,r){return dW(PU(e,t,{...t,[n.path]:r}))}function IU(e){let t=e.unit?.label;return t?` of ${t}`:``}function LU(e){let t=CU(e);if(!t)return`Allowed range is unavailable.`;let n=`${e.integer!==!1&&!NH(e)?`whole number`:`number`}${IU(e)}`;return t.exclusiveMin&&t.min===0?`Must be a positive ${n}.`:t.max==null?`Must be a ${n} ${t.exclusiveMin?`above`:`of at least`} ${PH(t.min)}.`:`Must be a ${n} between ${PH(t.min)} and ${PH(t.max)}.`}function RU(e){return`Must be a multiple of ${FH(e,1)}.`}function zU(e){return Math.abs(e-Math.round(e))<dU&&Number.isSafeInteger(Math.round(e))}function BU(e,t){return Number(IH({...e,integer:!1,nullable:!1,zeroIsNull:!1},t))}function VU(e,t){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=e.range;if(!n)return`Allowed range is unavailable.`;if(t==null||String(t).trim()===``)return LU(e);let r=Number(t);if(!Number.isFinite(r))return LU(e);if(e.zeroIsNull&&r<=0)return null;let i=BU(e,r);if(e.integer!==!1&&!zU(i))return NH(e)?RU(e):LU(e);let a=Number(IH(e,r));return n.exclusiveMin&&a<=n.min||!n.exclusiveMin&&a<n.min||n.max!=null&&a>n.max?LU(e):null}function HU(e,t,n=!1){return n?LU(e):VU(e,t.trim())}function UU(e,t){let n=t.trim();if(e.nullable&&n===``)return null;let r=Number(n);return e.zeroIsNull&&r<=0?null:r}function WU(e){if(e==null||e===``)return``;let t=Number(e);return Number.isFinite(t)?PH(t):String(e)}function GU(e,t){return Array.isArray(t)?e.valueKind===`posthog-projects`&&IH(e,t)===null?sU:null:`Must be a list.`}function KU(e,t){let n={};for(let r of OH(e)){if(kH(r))continue;let e=null;r.control===`number`&&(e=VU(r,t[r.path])),r.control===`list`&&(e=GU(r,t[r.path])),r.control===`select`&&r.options&&!r.options.some(e=>e.value===t[r.path])&&(e=`Choose one of the available options.`),e&&(n[r.id]=e)}return qU(OH(e),t,n),n}function qU(e,t,n){for(let r of e){let i=e.find(e=>e.id===r.maximumSettingId);if(!i||n[r.id]||n[i.id])continue;let a=t[r.path],o=t[i.path];Number(IH(r,a))>Number(IH(i,o))&&(n[r.id]=`Minimum must not exceed the maximum (${WU(o)}).`,n[i.id]=`Maximum must not be below the minimum (${WU(a)}).`)}}function JU(e,t){return OH(e).find(e=>e.id===t.maximumSettingId||e.maximumSettingId===t.id)}function YU(e,t,n){let r=JU(e,t);return KU([{id:`scoped`,level:`machine`,title:``,description:``,settings:r?[t,r]:[t]}],n)[t.id]??null}function XU(e,t){return e.control===`number`?UU(e,t):e.control===`list`?SU(t):t}function ZU(e,t){return IH(e,e.control===`list`?xU(t):t)}function QU(e){return e?.isDirty===!0}function $U(e,t,n,r,i,a=!1){if(!QU(n))return{kind:`unchanged`};let o=t.control===`number`?HU(t,r,a):null;if(o)return{kind:`invalid`,error:o};let s=XU(t,r);if(yU(IH(t,s),ZU(t,n.base)))return{kind:`unchanged`};let c=YU(e,t,{...i,[t.path]:s});return c?{kind:`invalid`,error:c}:{kind:`changed`,value:s}}function eW(e){return _U(e)?``:MH(e,e.defaultValue)}function tW(e,t){return yU(t,eW(e))}function nW(e){return e.presentation?e.presentation:(e.options?.length??0)<=cU?`segmented`:`select`}function rW(e){return Array.isArray(e)?e.length>0:typeof e==`string`?e.trim()!==``:e===!0}function iW(e,t){return e.danger===!0&&!!e.warning&&rW(t)}function aW(e,t){return iW(e,t)}function oW(e){return e.title.charAt(0).toLowerCase()+e.title.slice(1)}function sW(e){return _U(e)?`Reset removes the stored ${oW(e)}. Anything that relies on it stops until a new one is saved.`:aW(e,eW(e))?e.warning??``:null}function cW(e){return[e.repos.join(`, `),e.trigger,e.actions.map(e=>e.type).join(`, `)].join(` `)}function lW(e){if(e==null)return[`No rules. Add workflows.rules to config.json.`];let t=Tt.safeParse(e);return t.success?t.data.rules.length===0?[`No rules. Add workflows.rules to config.json.`]:t.data.rules.map(e=>[e.name,e.enabled?`enabled`:`disabled`,cW(e)].join(` `)):[`The workflows block is invalid, so no rule runs: ${t.error.issues[0]?.message??`unknown problem`}`]}function uW(e){let t=Tt.safeParse(e??{});return t.success?t.data.rules.map(e=>({id:e.id,name:e.name,isEnabled:e.enabled,summary:cW(e)})):[]}function dW(e){let t=e.workflows;return typeof t!=`object`||!t||Array.isArray(t)?e:{...e,workflows:Object.fromEntries(Object.entries(t).filter(([e])=>e!==`rules`))}}var fW=`lanes-features`,pW=Object.freeze({id:fW,level:`lanes`,title:`Features`,description:`Optional tabs, each hidden until its own toggle is on.`,settings:[]}),mW=Object.freeze({sounds:()=>uf(),themes:Mf}),hW={},gW=null,_W=null,vW=mt,yW=null,bW=!1,xW=null,SW=[],CW=null,wW=()=>null,TW=()=>{},EW=new Set,DW=new Set;function OW(e){for(let t of DW)t(e)}function kW(e){if(!e.optionsFrom)return e;let t=mW[e.optionsFrom]?.()??[];return{...e,options:t.map(e=>({value:e.id,label:e.label}))}}function AW(){let e=xH.sections.map(e=>({...e,settings:e.settings.map(kW)})),t=e.findIndex(e=>e.level===`lanes`);return Object.freeze([...e.slice(0,t),pW,...e.slice(t)])}function jW(e){DW.add(e)}function MW(){return hW}function NW(e){return hW={...hW,...e},hW}function PW(){return{status:gW,journal:_W,request:vW,lastAutoCheckAt:yW,isCheckInFlight:bW,checkSendFailure:xW}}function FW(e){let t=O(vW,e);t!==vW&&(vW=t,OW({kind:`update`,frame:`request`}))}function IW(){FW(T({type:`update-apply`})?`request-sent`:`request-unsent`)}function LW(){yW=Date.now();let e=T({type:`update-check`});bW=e,xW=e?null:p,OW({kind:`update`,frame:`request`})}function RW(e){TW=e}function zW(){TW()}function BW(e){SW=[...e]}function VW(){return SW}function HW(e=null,t=null){e===null&&CW?.sectionId||(CW={sectionId:e,settingId:t,hashAtRequest:location.hash},OW({kind:`activate`}))}function UW(){let e=CW;return CW=null,e}function WW(e){let t=DU(e);if(t){let e=Ma(t.query);return{sectionId:e,settingId:null,hash:e}}return $H(e,AW(),SH,CH)}function GW(e){wW=e}function KW(){for(let e of EW)e()}function qW(e){EW.add(e)}function JW(){return Hd()&&wW()===`section`}function YW(){JW()&&OW({kind:`return-to-list`})}function XW(e){e&&(hW=e,Ji(hW.agentLogins),OW({kind:`broadcast`}))}function ZW(){OW({kind:`status`})}function QW(e){ZW()}function $W(e){gW=e,bW=!1,xW=null,vW=O(vW,`status-frame`),OW({kind:`update`,frame:`status`})}function eG(e){_W=e,vW=O(vW,`progress-frame`),OW({kind:`update`,frame:`progress`})}function tG(e){if(e.scope!==`update`)return!1;let t=g(e.message),n=vW.requested;return vW=O(vW,`error-frame`,t),bW=!1,n||(xW=t),OW({kind:`update`,frame:`error`}),!0}function nG(e,t){return typeof t!=`string`||t===``?{knownBuild:e,reload:!1}:e==null?{knownBuild:t,reload:!1}:e===t?{knownBuild:e,reload:!1}:{knownBuild:t,reload:!0}}var rG=null,iG=null,aG=null,oG=null,sG=null,cG=null,lG=-1,uG=null,dG={isRightToLeft:!1,arcProgress:0},fG=1,pG=3;function mG(){if(!rG||uG===null)return;let e=ni({viewportWidthPx:document.documentElement.clientWidth,viewportHeightPx:document.documentElement.clientHeight,verticalProgress:uG,...dG});st(rG,ii(e,fG,window.devicePixelRatio))}function hG(){cG!==null&&(clearTimeout(cG),cG=null)}function gG(e=ir()){return tr({isEnabled:e,hasReducedMotion:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,isPhone:Hd(),options:In()})}function _G(e){e.onanimationend=null,e.style.animation=`none`,oG&&(oG.style.animation=`none`),e.hidden=!0}function vG(e,t){if(!rG||!iG||!aG||!oG||gG())return;let n=In();hG();let r=on(n,lG,Math.random,t);if(_G(rG),!r){cG=setTimeout(()=>vG(!1),1e3);return}uG=r.verticalProgress,dG={isRightToLeft:r.isRightToLeft,arcProgress:r.arcProgress},fG=n.flyingAnimalsScale,mG();let i=sn[r.animalIndex];iG.className=`nyan-sprite ${i.sprite}`,aG.className=`nyan-trail ${i.trail}`,lG=r.animalIndex,sG?.classList.remove(`is-booped`),rG.hidden=!1,rG.offsetWidth,rG.style.animation=`nyan-fly ${r.durationSeconds}s linear`,oG.style.animation=`nyan-trail-hold ${r.durationSeconds}s linear`,e&&(rG.style.animationDelay=`-${r.firstDelaySeconds}s`,oG.style.animationDelay=`-${r.firstDelaySeconds}s`),rG.onanimationend=e=>{rG&&e.target===rG&&(_G(rG),cG=setTimeout(()=>vG(!1),r.gapMs))}}function yG(){sG&&(sG.classList.remove(`is-booped`),sG.offsetWidth,sG.classList.add(`is-booped`))}function bG(e){if(rG&&oG&&e.target===sG)for(let e of[...rG.getAnimations(),...oG.getAnimations()])e.playbackRate=pG}function xG(){if(rG||gG())return;rG=document.createElement(`div`),rG.className=`nyan-flight`,rG.setAttribute(`aria-hidden`,`true`);let e=document.createElement(`div`);e.className=`nyan-trail-window`,oG=document.createElement(`div`),oG.className=`nyan-trail-hold`,aG=document.createElement(`div`),oG.append(aG),e.append(oG),iG=document.createElement(`div`),sG=document.createElement(`div`),sG.className=`nyan-boop`,sG.append(iG),sG.addEventListener(`pointerdown`,yG),sG.addEventListener(`animationend`,bG),rG.append(e,sG),document.body.appendChild(rG),window.addEventListener(`resize`,mG),window.addEventListener(`orientationchange`,mG),vG(!0)}function SG(e){xG(),vG(!1,e)}function CG(){hG(),window.removeEventListener(`resize`,mG),window.removeEventListener(`orientationchange`,mG),rG?.remove(),rG=null,iG=null,aG=null,oG=null,sG=null,lG=-1,uG=null}var wG=!1;function TG(e){let t=document.documentElement;if(wG||(wG=!0,Ud(()=>TG(ir())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>TG(ir()))),e){if(t.dataset.flyingAnimals=`true`,gG(e)){CG();return}xG()}else delete t.dataset.flyingAnimals,CG()}var EG=`•`.repeat(8),DG=`[^/\\\\\\s"'\`<>:]+`,OG=RegExp(`(?<![\\w./\\\\-])(?:/home/${DG}|/Users/${DG}|[A-Za-z]:[\\\\/]Users[\\\\/]${DG}|/root(?![\\w.-]))`,`g`);function kG(e){let t=Vp(e);if(t.length===0)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+EG,r=i.end;return n+e.slice(r)}function AG(e){return e.replace(OG,`~`)}function jG(e){return AG(kG(e))}var MG=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,NG=[`title`,`label`],PG=new WeakMap,FG=new WeakMap,IG=null;function LG(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(MG)!==null}function RG(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function zG(e,t){if(t&&e===t.masked)return t;let n=jG(e);return n===e?null:{original:e,masked:n}}function BG(e){let t=RG(e)?null:zG(e.data,PG.get(e));t?(PG.set(e,t),e.data!==t.masked&&(e.data=t.masked)):PG.delete(e)}function VG(e,t){let n=e.getAttribute(t),r=FG.get(e),i=n===null?null:zG(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),FG.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function HG(e){for(let t of NG)VG(e,t)}function UG(e){return e instanceof Element&&e.matches(MG)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function WG(e){HG(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,UG);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&BG(e),e instanceof Element&&HG(e)}function GG(e){LG(e)||(e instanceof Text&&BG(e),e instanceof Element&&WG(e))}function KG(e){e instanceof Element&&!LG(e)&&HG(e)}function qG(e){let t=new Set,n=new Set;for(let r of e){if(r.type===`childList`)for(let e of r.addedNodes)t.add(e);r.type===`characterData`&&t.add(r.target),r.type===`attributes`&&n.add(r.target)}for(let e of t)e.isConnected&&GG(e);for(let e of n)e.isConnected&&KG(e)}function JG(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);YG(e);for(let e=t.nextNode();e;e=t.nextNode())YG(e)}function YG(e){if(e instanceof Text){let t=PG.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=FG.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function XG(){if(IG)return;let e=new MutationObserver(t=>{qG(t),e.takeRecords()});WG(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:NG}),IG=e}function ZG(){IG&&(IG.disconnect(),IG=null,JG(document.body),PG=new WeakMap,FG=new WeakMap)}function QG(e){e?XG():ZG()}function $G(){QG($o()),ts(QG)}function eK(e){if(typeof e!=`object`||!e||!(`telemetry`in e))return!1;let{telemetry:t}=e;return typeof t!=`object`||!t||!(`enabled`in t)?!1:t.enabled===!0}function tK(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function nK(e,t){return t||tK(e)?!1:eK(e)}var rK=2500;function iK({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}var aK=2e4,oK=null,sK=null,cK={claude:null,codex:null},lK=null,uK=null,dK=null,fK=`all`,pK=!1,mK=null,hK=null,gK=!0,_K=()=>!1,vK=new Set,yK=Oe({getAck:bn,setAck:Jn,signature:()=>OC(oK,cK.claude),isLooking:()=>_K()});function bK(e){for(let t of vK)t(e)}function xK(){lK?.(yK.refresh())}function SK(e){pK=e,bK(`refresh-status`),mK&&=(clearTimeout(mK),null),e&&(mK=setTimeout(()=>{mK=null,pK=!1,hK=`Usage did not answer within ${Math.round(aK/1e3)} s. Refresh to try again.`,bK(`refresh-status`)},aK))}function CK(e){let t=Nx.find(t=>t.value===e);return t?t.days:null}function wK(){return{report:oK,sessions:sK,planLimitsByVendor:cK,rangeValue:fK}}function TK(){let e=!gK||!pK&&hK!==null;return gK?pK?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:hK??``,isPending:!1,hasFailure:e}:{text:oK?`${p} The figures below are from before the connection dropped.`:p,isPending:pK,hasFailure:e}}function EK(e){vK.add(e)}function DK(e){_K=e,xK()}function OK(){yK.acknowledge(),xK()}function kK(e){lK=e,xK()}function AK(e){uK?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function jK(e){uK=e}function MK(e){fK=e}function NK({force:e=!1}={}){if(!uK)return;dK=y(`usage`);let t={type:`request-usage-report`,requestId:dK};e&&(t.force=!0);let n=CK(fK);n!==null&&(t.days=n),hK=null,SK(!0),!uK(t)&&(hK=p,SK(!1))}function PK(e){gK=e,bK(`refresh-status`)}function FK(e){sK=e,bK(`sessions`)}function IK(e){let t=e;cK={...cK,[SC(t)]:t},bK(`plan-limits`),xK()}function LK(e){HC(e,dK)&&(hK=null,SK(!1),oK=e,bK(`report`),xK())}function RK(){let e=oK?.pricing||(sK?{source:sK.pricingSource}:null),t=FC(e?.fetchedAt),n=[PC(e,t!==null&&t>0?$t(t):``)],r=zC(oK);r&&n.push(r);let i=RC(oK?.scan);return i&&n.push(i),n}var zK={teamReview:e=>e?.teamReview?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,visions:e=>e?.visions?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,benchmarks:e=>e?.benchmarks?.enabled===!0,zenView:e=>e?.zenView===!0},BK=[{rule:`teamReview`,sectionId:`lanes-team-review`,settingId:`team-review-enabled`},{rule:`usage`,sectionId:`machine-usage`,settingId:`usage-enabled`},{rule:`posthog`,sectionId:`lanes-posthog`,settingId:`posthog-enabled`},{rule:`visions`,sectionId:`lanes-visions`,settingId:`visions-enabled`},{rule:`benchmarks`,sectionId:`lanes-benchmarks`,settingId:`benchmarks-enabled`},{rule:`zenView`,sectionId:`machine-sessions`,settingId:`zen-view`}],VK=2166136261,HK=16777619;function UK(e){let t=VK;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,HK)>>>0;return t}var WK=18e4,GK=2**32,KK=new Set([z.INITIALIZING,z.STARTING,z.RUNNING,z.WAITING,z.IDLE,z.COMPLETE,z.FAILED]),qK=new Map([[z.INITIALIZING,f.INITIALIZING],[z.STARTING,f.STARTING],[z.RUNNING,f.RUNNING],[z.IDLE,f.IDLE]]),JK=new Map([[z.INITIALIZING,`resting`],[z.STARTING,`resting`],[z.WAITING,`alert`],[z.FAILED,`alert`],[z.COMPLETE,`sitting`],[z.IDLE,`asleep`]]);function YK(e){return KK.has(e)}function XK(e,t){let n=UK(e)/GK,r=ln(t,-1,()=>n);return r===null?null:sn[r]??null}function ZK(e){let t=UK(`${e}#spot`);return{leftPercent:6+t%78,topPercent:12+(t>>>8)%62,ambleDistancePx:24+(t>>>16)%64,ambleSeconds:9+(t>>>24)%9}}function QK({state:e,activity:t,lastOutputAtMs:n,nowMs:r}){return e===z.RUNNING?n!==void 0&&r-n>=WK?`asleep`:t===`quiet`?`resting`:`ambling`:JK.get(e)??`asleep`}function $K({state:e,unseenOutcome:t}){return e===z.WAITING?Wt.WAITING:e===z.FAILED&&t===`failed`?Wt.FAILED:null}function eq(e,t){return qK.get(e)??Cc(e,t)}var tq=new Set([z.RUNNING,z.STARTING,z.INITIALIZING]),nq=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),rq=null,iq=!1,aq=null,oq=null,sq=new Map;function cq(e){let t=L(`div`,`zen-calm`),n=L(`div`,`zen-status-line`);n.setAttribute(`role`,`status`);let r=L(`span`,`zen-working-count`);n.append(L(`h2`,`zen-all-clear`,`ALL CLEAR`),r);let i=L(`div`,`zen-meadow`);i.setAttribute(`aria-label`,`Sessions`),t.append(n,i);let a=L(`div`,`zen-stage`),o=L(`div`,`zen-reason-line`);o.setAttribute(`role`,`status`);let s=L(`span`,`zen-staged-need`),c=L(`span`,`zen-queued-behind`);o.append(s,c);let l=L(`div`,`zen-pet-strip`);l.setAttribute(`aria-label`,`Other sessions`);let u=L(`button`,`btn-dialog`,`Next`);u.type=`button`,u.addEventListener(`click`,pq);let d=L(`div`,`zen-stage-bar`);d.append(o,l,u,Ba());let f=L(`div`,`zen-card-slot`);a.append(d,f),a.hidden=!0,e.append(t,a),rq={calm:t,workingCount:r,meadow:i,stage:a,stagedNeed:s,queuedBehind:c,petStrip:l,cardSlot:f}}function lq(){return iq}function uq(){if(rq){iq=!0;for(let e of sq.values())e.root.remove();sq.clear(),fq()}}function dq(){iq&&=(vq(),oq=null,!1)}function fq(){if(!iq)return;let e=gq();oq!==null&&!hq(oq)&&(oq=null),_q(oq??xc(e,aq),e)}function pq(){if(!iq)return;oq=null;let e=aq,t=e===null?void 0:H.get(e),n=t!==void 0&&Ec({state:t.currentState,unseenOutcome:t.unseenOutcome});e!==null&&n&&TT(e);let r=gq().filter(t=>!n||t!==e);_q(bc(r,e),r)}function mq(e){iq&&hq(e)&&(oq=e,_q(e,gq()))}function hq(e){let t=H.get(e);return t!==void 0&&YK(t.currentState)}function gq(){return Ac(vc(Iu()))}function _q(e,t){if(!rq)return;let n=e===null?void 0:H.get(e);if(e===null||!n){vq(),bq(rq);return}let r=aq!==e;aq=e,rq.calm.hidden=!0,rq.stage.hidden=!1,yq(rq,n,t.filter(t=>t!==e).length),xq(rq.petStrip,e),(Wr()!==e||n.card.parentElement!==rq.cardSlot)&&(Gr(n,e,rq.cardSlot,{className:`zen-staged`}),mg(n,e,!0),r&&Dq(n,e))}function vq(){aq!==null&&Wr()===aq&&Kr(),aq=null}function yq(e,t,n){e.stagedNeed.textContent=eq(t.currentState,t.pendingPromptKind),e.stagedNeed.dataset.state=t.currentState,e.queuedBehind.textContent=`${n} more waiting`,e.queuedBehind.hidden=n===0}function bq(e){e.stage.hidden=!0,e.calm.hidden=!1;let t=Iu().filter(e=>tq.has(e.state)).length;e.workingCount.textContent=`${t} working`,xq(e.meadow,null)}function xq(e,t){let n=vc(Iu()).filter(e=>YK(e.state)&&e.id!==t),r=new Set(n.map(e=>e.id));for(let[e,t]of sq)r.has(e)||(t.root.remove(),H.has(e)||sq.delete(e));for(let t of n){let n=sq.get(t.id)??Sq(t.id);n.root.parentElement!==e&&e.append(n.root),Cq(n,t.ui,t.name)}}function Sq(e){let t=L(`button`,`zen-pet`);t.type=`button`,t.dataset.sessionId=e;let n=ZK(e);t.style.setProperty(`--zen-pet-left`,`${n.leftPercent}%`),t.style.setProperty(`--zen-pet-top`,`${n.topPercent}%`),t.style.setProperty(`--zen-pet-amble-distance`,`${n.ambleDistancePx}px`),t.style.setProperty(`--zen-pet-amble-duration`,`${n.ambleSeconds}s`),t.addEventListener(`click`,()=>mq(e));let r=L(`span`,`zen-pet-walker`),i=L(`span`,`zen-pet-bubble`);i.setAttribute(`aria-hidden`,`true`);let a=L(`span`,`zen-pet-facing`),o=L(`span`,`zen-pet-hopper`),s=XK(e,In().flyingAnimalsExcludedSprites);o.append(s?oi(s,`zen-pet-sprite`):L(`span`,`zen-pet-dot`)),a.append(o);let c=L(`span`,`zen-pet-zzz`,`zzz`);c.setAttribute(`aria-hidden`,`true`);let l=L(`span`,`zen-pet-name`);r.append(i,a,c,l),t.append(r);let u={root:t,hopper:o,bubble:i,name:l};return sq.set(e,u),u}function Cq(e,t,n){Tq(e,t,performance.now()),e.root.dataset.state=t.currentState,e.name.textContent!==n&&(e.name.textContent=n),e.root.setAttribute(`aria-label`,n),e.root.title=`${kT(t.path)}: ${eq(t.currentState,t.pendingPromptKind)}`;let r=$K({state:t.currentState,unseenOutcome:t.unseenOutcome});e.bubble.hidden=r===null,r!==null&&xr(e.bubble,r)}function wq(e){nq?.matches||document.hidden||!e.hopper.animate||e.hopper.animate([{transform:`translateY(0)`},{transform:`translateY(-6px)`,offset:.4},{transform:`translateY(0)`}],{duration:320,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})}function Tq(e,t,n){e.root.dataset.mood=QK({state:t.currentState,activity:t._activity,lastOutputAtMs:t._lastOutputAt,nowMs:n})}function Eq(e,t){if(!iq)return;let n=e.card?.dataset.id,r=n?sq.get(n):void 0;r?.root.isConnected&&(Tq(r,e,performance.now()),t===`beat`&&wq(r))}en(Eq),Zt(()=>{if(!iq)return;let e=performance.now();for(let[t,n]of sq){let r=H.get(t);r&&n.root.isConnected&&Tq(n,r,e)}});function Dq(e,t){requestAnimationFrame(()=>requestAnimationFrame(()=>{iq&&aq===t&&!document.hidden&&document.hasFocus()&&e.term?.focus()}))}function Oq(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function kq(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function Aq(e,t){let n=new Set(e),r=[...new Set((t??[]).filter(e=>n.has(e)))];return[...r,...e.filter(e=>!r.includes(e))]}function jq(e,t,n){let r=e.filter(e=>e!==t);if(r.length===e.length)return[...e];let i=Math.max(0,Math.min(n,r.length));return[...r.slice(0,i),t,...r.slice(i)]}function Mq(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function Nq(e,t,n){t&&e?.refreshOn?.includes(n)&&t.refresh?.(n)}function Pq(e,t,n,r){for(let i of e)Oq(i.view,t)&&Nq(i,r(i.view),n)}function Fq(){let e=new Map,t=new Map;function n(e,n){let r=t.get(e.view);if(r)return r;let i=n().catch(n=>{throw t.delete(e.view),n});return t.set(e.view,i),i}function r(t,n){return e.get(t.view)||(n.mount(t.el),e.set(t.view,n),n)}function i(t){return e.get(t)??null}function a(t){let i=e.get(t.view);return i?Promise.resolve(i):t.module?Promise.resolve(r(t,t.module)):n(t,t.load).then(e=>r(t,e))}function o(e){for(let t of e)t.module&&r(t,t.module)}async function s(t){for(let r of t)r.load&&!e.has(r.view)&&await n(r,r.load)}return{show:a,mountedModuleOf:i,mountEagerViews:o,prefetch:s}}function Iq(e,t,n){let r=Number(e);return!e||!Number.isFinite(r)||t-r>n}var Lq=`glimmervoid:preload-error-reload-at`,Rq=3e4,zq=1e3,Bq=Fq();function Vq(e,t){let n=Bq.mountedModuleOf(e.view);n?t(n):Bq.show(e).then(t).catch(t=>{throw ke(`view`,`${e.view} failed to show: ${Jt(t)}`),t})}function Hq(e){return Bq.mountedModuleOf(e)}function Uq(e){Bq.mountEagerViews(e)}function Wq(e){let t=()=>{Bq.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,zq)}function Gq(e){window.addEventListener(`vite:preloadError`,()=>{let t=e(),n=Date.now();Iq(t.getItem(Lq),n,Rq)&&(t.setItem(Lq,String(n)),location.reload())})}function Kq(e){Az({openTerminal:e.openTerminal,openReviews:e.openReviews}),RW(e.onRestart);let t=[{view:`focus`,label:`Focus`,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,hasReviewSidebar:!0,module:{mount:()=>KE({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:bD,deactivate:CD}},{view:`zen`,label:`Zen`,panelClass:`zen-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,gate:{fromSettings:zK.zenView},module:{mount:cq,activate:uq,deactivate:dq}},{view:`prs`,label:`Reviews`,glyph:`⇅`,panelClass:`pr-view`,gate:{fromSettings:zK.teamReview},load:()=>Rm(()=>import(`./review-queue-panel-BQvU_-xl.js`).then(e=>e.view),__vite__mapDeps([0,1,2,3,4,5,6,7])),attention:{subscribe:Ez,acknowledge:Tz},onConnectionChange:e=>{AR(e),YF(e)}},{view:`issues`,label:`Issues`,glyph:`#`,panelClass:`issues-view`,load:()=>Rm(()=>import(`./issues-panel-Bev1wadi.js`).then(e=>e.view),__vite__mapDeps([8,1,2,3,4,5,6,7])),refreshOn:[`shown`],onConnectionChange:KB},{view:`usage`,label:`Usage`,glyph:`◔`,panelClass:`usage-view`,gate:{fromSettings:zK.usage},load:()=>Rm(()=>import(`./usage-panel-CEJqXYIA.js`).then(e=>e.view),__vite__mapDeps([9,1,2,3])),attention:{subscribe:kK,acknowledge:OK},onConnectionChange:PK,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,glyph:`◎`,panelClass:`radar-view`,gate:{fromSettings:zK.posthog},load:()=>Rm(()=>import(`./radar-panel-Dtp4ZzT3.js`).then(e=>e.view),__vite__mapDeps([10,1,2,3,4,7])),attention:{subscribe:uV,acknowledge:lV}},{view:`visions`,label:`Visions`,glyph:`◇`,panelClass:`visions-view`,gate:{fromSettings:zK.visions},load:()=>Rm(()=>import(`./visions-panel-Dm3iKlhv.js`).then(e=>e.view),__vite__mapDeps([11,1,2,4])),attention:{subscribe:uk,acknowledge:dk},refreshOn:[`shown`],onConnectionChange:mk},{view:`hooks`,label:`Hooks`,glyph:`◈`,panelClass:`hooks-view`,load:()=>Rm(()=>import(`./hooks-panel-Cli8EeBB.js`).then(e=>e.view),__vite__mapDeps([12,1,2,4,7])),refreshOn:[`shown`,`connected`,`hooks-updated`]},{view:`trace`,label:`Trace`,panelClass:`trace-view`,gate:{subscribe:ul},load:()=>Rm(()=>import(`./trace-panel-DFqImX92.js`).then(e=>e.view),__vite__mapDeps([13,1,2,6,4])),refreshOn:[`shown`],onAvailabilityChange:e=>dV(e?wx:null),onConnectionChange:kx},{view:`benchmarks`,label:`Bench`,panelClass:`bench-view`,gate:{fromSettings:zK.benchmarks},load:()=>Rm(()=>import(`./benchmark-panel-Cssmnd3z.js`).then(e=>e.view),__vite__mapDeps([14,1,2])),onConnectionChange:hB},{view:`settings`,label:`Settings`,glyph:`@`,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>Rm(()=>import(`./settings-panel-DegKCsoZ.js`).then(e=>e.view),__vite__mapDeps([15,1,2,3,6,4,7]))}],n=I(document,`#app-main`,`main`),r=t.map(t=>{let r=L(`button`,`header-tab`,t.label);r.id=`tab-${t.view}`,r.type=`button`,r.draggable=!0;let i=`view-${t.view}`;r.setAttribute(`role`,`tab`),r.setAttribute(`aria-controls`,i);let a=t.view===`focus`;r.setAttribute(`aria-selected`,String(a)),r.tabIndex=a?0:-1,t.glyph&&(r.dataset.phoneGlyph=t.glyph);let o=document.getElementById(i)??L(`section`);if(o.classList.add(t.panelClass),o.id=i,o.setAttribute(`role`,`tabpanel`),o.setAttribute(`aria-labelledby`,r.id),o.hidden=!0,o.parentElement||n.append(o),r.hidden=t.gate!==void 0,o.classList.toggle(`view-panel`,t.hasPanelChrome!==!1),t.attention){let n=L(`span`,`tab-activity`);n.id=`tab-${t.view}-activity`,n.setAttribute(`aria-hidden`,`true`),r.append(n),t.attention.subscribe(r=>{let{isActive:i,level:a}=Mq(r);n.classList.toggle(`active`,i),a===null&&n.removeAttribute(`data-attention`),a!==null&&n.setAttribute(`data-attention`,a),e.setPhoneAttention(t.view,r)})}return{...t,tab:r,el:o}});return I(document,`#header-tabs`,`div`).replaceChildren(...r.map(e=>e.tab)),r}Of(Pn()),kf(er()),Af(nr()),TG(ir()),Vd(),lc(document);var qq=I(document,`#connection-status`,`span`),Jq=I(qq,`.connection-label`,`span`),Yq=I(document,`#loading-screen`,`div`),Xq=I(document,`#loading-status`,`div`),Zq=I(document,`#loading-detail`,`div`),Qq=I(document,`#shutdown-screen`,`div`),$q=I(document,`#shutdown-status`,`div`),eJ=!1,tJ=null,nJ=!1;function rJ(){let e=si(),t=Yq.querySelector(`.loading-spinner`);e&&t&&t.replaceWith(oi(e,`loading-animal`))}rJ();function iJ(){eJ||tJ===null||iK({hasSnapshot:nJ,connectingTerminalCount:qh(),msSinceConnected:performance.now()-tJ})===`reveal`&&aJ()}Kh(iJ);function aJ(){if(eJ)return;eJ=!0,Yq.classList.add(`fade-out`),Wq(lY);let e=()=>Yq.remove();Yq.addEventListener(`transitionend`,e,{once:!0}),setTimeout(e,1e3)}function oJ(e,t){qq.dataset.state=`shutdown`,Jq.textContent=e,qq.title=e,QJ.disabled=!0,$q.textContent=t,Qq.classList.add(`active`)}var sJ=new Set([`disconnected`,`connecting`]);function cJ(e,t,n){qq.dataset.state=e,qq.toggleAttribute(`data-reconnected`,n),Jq.textContent=t,qq.title=t}function lJ(e,t){cJ(e,t,e===`connected`&&sJ.has(qq.dataset.state??``))}function uJ(e,t){qq.dataset.state!==`shutdown`&&cJ(e===`verified`?`connected`:e,t,!1)}var dJ=1e4,fJ=`Server`,pJ=`Worktree`,mJ=`Worktree warning`,hJ=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,gJ=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,_J=null,vJ=!1;function yJ(){Xq.textContent=`Reconnecting to server...`,Zq.textContent=gJ,Zq.hidden=!vJ}function bJ(){_J=null,vJ=!0,eJ?_r({source:fJ,message:hJ,hidesInStreamerMode:!1}):yJ()}function xJ(){_J!==null||vJ||(_J=window.setTimeout(bJ,dJ))}function SJ(){_J!==null&&window.clearTimeout(_J),_J=null,vJ=!1,Zq.hidden=!0,gr(fJ)}_e((e,t)=>{if(e===`connecting`||e===`verified`)uJ(e,t);else{lJ(e,t),eT(e===`connected`);for(let t of lY)t.onConnectionChange?.(e===`connected`);if(e===`connected`){if(SJ(),_Y&&vY(_Y),Qq.classList.contains(`active`)){location.reload();return}lo(),document.body.classList.add(`app-ready`),!eJ&&tJ===null&&(tJ=performance.now(),Xq.textContent=`Connecting to sessions...`,setTimeout(aJ,rK)),iJ(),HY(),PJ(`connected`),S(`get-settings`,{}).then(e=>{e.settings&&(wY(e.settings),Ur()===`settings`&&rY(location.hash))}).catch(()=>{})}else e===`disconnected`&&Qq.classList.contains(`active`)?$q.textContent=`Waiting for server...`:(xJ(),eJ||yJ())}});function CJ(){fq(),GB(),DR(),fM()}function wJ(){rD(),CJ()}var TJ=null;function EJ(e){let t=nG(TJ,e);TJ=t.knownBuild,t.reload&&location.reload()}function DJ(e){fk(new Map(e.filter(e=>!e.ephemeral).map(e=>[e.id,e.name]))),QW(e.filter(e=>!e.ephemeral).map(e=>({id:e.id,name:e.name,agent:e.agent,permissionMode:e.dangerouslySkipPermissions?`Skip permissions`:`Default`})));for(let t of e){Hs(t.id,t.coherenceHooks),t.ephemeral||wu(t.path),Yz(t.id,t.linkedPrs);let e=Bw(t.id);e&&DT(t.id,t.state,t.stateSince),e&&Cl(t.id,!!t.saneYolo),e&&iT(t.id,t.isGuarded,t.isGuardrailsReleased),e||Gw(t.id,t.name,t.state,bV(t)),CT(t.id,t.failureReason),zw(t.id,t.taskTitle,t.taskTitleIsCustom),nT(t.id,t.agent),_T(t.id,t.mergeStatus,t.mergeReason),tT(t.id,t.effectiveBase),sT(t.id,t.activeAgents,t.awaitingBackgroundTasks),pT(t.id,t.pendingWakeup),uT(t.id,t.pendingPromptKind,t.isCompacting,t.isWaitingForMemory),dT(t.id,t.unseenOutcome),Mw(t.id,t),Yw(t.id,t.hasPlan),NJ(t.id)}Ww(),Zc(H),rD(),SD(),CJ(),OJ(),oY(location.hash),UY(),nJ=!0,iJ()}function OJ(){Tx([...H].map(([e,t])=>({id:e,name:tn(t)||e})))}function kJ(e,t){Yw(e,t?.hasPlan===!0),dT(e,t?.unseenOutcome),NJ(e)}function AJ(e){if(!Bw(e.id))Gw(e.id,e.session,e.to,bV({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),Zc(H),GB();else if(e.to===z.DORMANT&&e.from!==z.DORMANT){let t=H.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;bT(e.id),Gw(e.id,e.session,z.DORMANT,bV({skipPerms:i,saneYolo:a,worktree:r?.dataset.worktree!==void 0,workspace:r?.dataset.workspace!==void 0,remoteWorkspace:r?.dataset.remoteWorkspace??null,guarded:r?.dataset.guarded!==void 0,guardrailsReleased:r?.dataset.guardrailsReleased!==void 0,ephemeral:r?.dataset.ephemeral!==void 0,path:o,stateSince:e.timestamp,taskTitle:t?.taskTitle,taskTitleIsCustom:t?.taskTitleIsCustom})),nT(e.id,t?.agent),kJ(e.id,t),wJ(),hy(e.id),Zc(H)}else DT(e.id,e.to,e.timestamp,e.event),CT(e.id,e.failureReason),e.saneYolo!==void 0&&Cl(e.id,e.saneYolo),Zc(H),hy(e.id),wJ(),Wl(e.id),e.to===z.INITIALIZING&&(e.from===z.DONE||e.from===z.FAILED)&&ng(e.id)}var jJ=new Map;function MJ(e){let t=new Set;for(let n of e){if(!n?.id)continue;t.add(n.id);let e={tokens:n.tokens,costUSD:n.costUSD,officialCostUSD:n.officialCostUSD};jJ.set(n.id,e),cT(n.id,e)}for(let e of[...jJ.keys()])t.has(e)||(jJ.delete(e),cT(e,null))}function NJ(e){let t=jJ.get(e);t&&cT(e,t)}jK(T),IA(T),Sx(T),WB(T),pB(T),pl(qz),nu(Ks),nu(Gz),hl({isReadable:qs,open:Ys}),_l(vV);function PJ(e){Pq(lY,{isPhoneShellActive:uM(),activeView:Ur(),phoneScreen:W.snapshot().phoneScreen},e,Hq)}ts(()=>PJ(`settings-updated`));var FJ={snapshot:e=>{EJ(e.serverBuild),DJ(e.sessions)},"hooks-report":e=>RA(e),"save-hook-result":()=>zA(),"delete-hook-result":()=>zA(),"state-change":e=>AJ(e),"session-added":e=>{e.ephemeral||wu(e.path),Yz(e.id,e.linkedPrs),Bw(e.id)||(Gw(e.id,e.session,e.state,bV(e)),nT(e.id,e.agent),NJ(e.id)),Zc(H),wJ(),OJ()},"session-removed":e=>{yr(e.id),bT(e.id),Us(e.id),_y(e.id),Xz(e.id),Zc(H),wJ(),OJ()},"session-title":e=>{zw(e.id,e.taskTitle,e.isCustom),wJ()},"session-prs":e=>Yz(e.id,e.linkedPrs),"session-renamed":e=>{yT(e.id,e.newName),wJ(),OJ()},"session-modified":e=>{e.ephemeral||wu(e.path);let t=H.get(String(e.id));Hs(e.id,null),bT(e.id),_y(e.id),Yz(e.id,e.linkedPrs),Gw(e.id,e.session,e.state,bV(e)),nT(e.id,e.agent),kJ(e.id,t),Zc(H),wJ(),OJ()},"session-git":e=>rT(e.id,!!e.worktree),"session-agents":e=>{sT(e.id,e.activeAgents,e.awaitingBackgroundTasks),wJ(),Wl(e.id)},"session-wakeup":e=>pT(e.id,e.pendingWakeup),"session-unseen":e=>{dT(e.id,e.unseenOutcome),Ww(),Zc(H),wJ()},"session-prompt":e=>{uT(e.id,e.pendingPromptKind,e.isCompacting===!0,e.isWaitingForMemory===!0),CJ()},"session-merge-status":e=>{gT(e.id,e.mergeStatus,e.reason),hD(e.id,e.mergeStatus),CJ()},"session-worktree-blocked":e=>{_r({source:pJ,sessionId:e.id,message:`${e.session}: ${e.notice||`The integration branch was not found. Check the integration branch in Settings, then restart the session.`}`})},"session-worktree-warning":e=>{_r({source:mJ,sessionId:e.id,message:`${e.session}: ${e.notice||`The base branch could not be synced. The session keeps working on its current base.`}`})},"session-worktree-ready":e=>{gr(pJ,e.id),tT(e.id,e.base)},"session-diff":e=>{vT(e.id,{committed:e.committed,uncommitted:e.uncommitted,hasCommits:e.hasCommits})},"session-diff-error":e=>{uy(e.id,e.message)},"change-map":e=>dy(e.id,e.map),"branch-sync-status":e=>fy(e.id,e),"session-changed":e=>my(e.id),"post-turn-result":e=>mT(e.id,e),"debug-state-response":e=>Ul(e),"session-trace-response":e=>{Nw(e)||Ex(e)},"session-trace-changed":e=>{Fw(e.id),Dx(e)},"session-conversation":e=>{Mw(e.id,e),CJ()},"session-plan-changed":e=>{Xw(e),CJ()},"session-plan-draft":e=>{Zw(e)},"session-plan-response":e=>{Qw(e)},"session-docs-changed":e=>Ts(e),"session-docs-snapshot":e=>Es(e),"session-coherence-hooks":e=>{Hs(e.id,e.coherenceHooks),wJ()},"session-coherence":e=>{Ws(e),wJ()},"session-coherence-snapshot":e=>{Gs(e),wJ()},"session-coherence-journal-response":e=>Xs(e),"session-setup-response":e=>yV(e),notify:e=>{ka(e),Wl(e.session)},"update-status":e=>{HJ(e),$W(e)},"update-progress":e=>eG(e.journal),"post-turn-leftovers":e=>WJ(e),error:e=>{let t=tG(e),n=Ox(e);Pw(e);let r=$w(e);t||n||r||(e.id?ST(e.id,e.message):_r({source:fJ,message:e.message}))},"session-error":e=>{sy(e.id),!$w(e)&&ST(e.id,e.message)},"settings-updated":e=>{e.settings&&wY(e.settings),lo()},"agent-logins":e=>Ji(e.logins),"health-snapshot":e=>{e.stats&&Yg(e.stats)},"radar-status":e=>fV(e),"radar-investigation-activity":e=>pV(e),"radar-investigation-finished":e=>mV(e),"team-review-status":e=>KF(e),"github-prs":e=>Ar(e),"my-prs-status":OR,"benchmark-status":e=>gB(e),"benchmark-action-result":e=>_B(e),"my-pr-merge-result":e=>kR(e),"team-review-action-result":e=>qF(e),"open-team-review-session-result":e=>JF(e),"issues-status":e=>qB(e),"issue-detail-result":e=>JB(e),"open-issue-session-result":e=>YB(e),"usage-sessions":e=>{MJ(e.sessions),FK(e)},"usage-report":e=>{LK(e),ZW()},"plan-limits":e=>IK(e),"usage-budget-alert":e=>ka({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0}),"visions-findings":e=>gk(e),"visions-comments":e=>_k(e),"visions-hand":e=>vk(e),"visions-intent":e=>yk(e),"visions-fix":e=>hk(e),"visions-snapshot":e=>Sk(e),"ingest-activity":e=>bk(e),"ingest-snapshot":e=>xk(e),"client-trust":e=>IY(e.trust),"shutting-down":()=>oJ(`Shutting down...`,`Shutting down sessions...`),restarting:()=>oJ(`Restarting...`,`Restarting server...`)};function IJ(e){let t=FJ[e.type];t&&t(e)}Rt(e=>{IJ(e),PJ(e.type)});var LJ,RJ=null;function zJ(e,t,n){e.onclick=()=>{let e=Ft(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var BJ=Na(je,re,`Update`).href;function VJ(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function HJ(e){let t=I(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=Ce(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=VJ(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===RJ||!a&&LJ!==void 0&&s===LJ||!a&&s&&Hn()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);I(document,`#update-banner-text`,`span`).textContent=i,I(document,`#update-banner-cmd`,`code`).textContent=c;let l=I(document,`#update-banner-update`,`a`);l.href=BJ,l.hidden=n!==`link`;let u=I(document,`#update-banner-restart`,`button`);u.hidden=n!==`restart`,u.onclick=FY;let d=I(document,`#update-banner-cmd`,`code`);d.hidden=n!==`command`;let f=I(document,`#update-banner-copy`,`button`);f.hidden=n!==`command`;let p=I(document,`#update-banner-copy-status`,`span`);p.hidden=n!==`command`,p.textContent=``;let m=I(document,`#update-banner-link`,`a`);m.hidden=!e.releaseUrl,m.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,zJ(f,p,c),I(document,`#update-banner-dismiss`,`button`).onclick=()=>{t.hidden=!0,a?RJ=i:(LJ=s,Rn(s))}}var UJ=!1;function WJ({repositories:e,command:t}){let n=I(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(UJ)return;let r=I(document,`#post-turn-leftovers-copy-status`,`span`);I(document,`#post-turn-leftovers-text`,`span`).textContent=Rr(e.length),I(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,zJ(I(document,`#post-turn-leftovers-copy`,`button`),r,t),I(document,`#post-turn-leftovers-dismiss`,`button`).onclick=()=>{UJ=!0,n.hidden=!0}}var GJ=I(document,`#telemetry-banner`,`div`);function KJ(){An(!0),GJ.hidden=!0}function qJ(e){GJ.hidden=!nK(e,cn())}var JJ=I(document,`#telemetry-banner-settings`,`a`);JJ.href=Na(`privacy`,`telemetry-enabled`,`What's collected`).href,JJ.addEventListener(`click`,KJ),I(document,`#telemetry-banner-dismiss`,`button`).addEventListener(`click`,KJ),I(document,`#btn-add-session-header`,`button`).addEventListener(`click`,ra);var YJ=I(document,`#btn-mute`,`button`);nB(YJ);var XJ=I(document,`#btn-streamer`,`button`);os(XJ),$G();var ZJ=I(document,`#power-menu`,`div`),QJ=I(document,`#btn-power`,`button`);function $J(){QJ.setAttribute(`aria-expanded`,ZJ.classList.contains(`open`)?`true`:`false`)}QJ.addEventListener(`click`,e=>{e.stopPropagation(),ZJ.classList.toggle(`open`),$J()}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(ZJ.contains(e.target)||(ZJ.classList.remove(`open`),$J()))}),nt(document.querySelector(`.header`));function eY(e){e&&HW(e),!mM(`settings`)&&bY(`settings`,{section:e})}function tY(){ja(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}function nY(e){return e?(HW(e.sectionId,e.settingId),mM(`settings`)||bY(`settings`,{section:e.sectionId,setting:e.settingId,persist:!1}),!0):!1}function rY(e){return nY(WW(e))}var iY=`No plan is stored for this session yet. It appears here once the agent writes one.`,aY=`Plan`;function oY(e){let t=ma(e);return t?!Bw(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),uM()?(lM(t)||_r({source:aY,sessionId:t,message:iY}),!0):(bY(`focus`,{persist:!1}),_D(t)||_r({source:aY,sessionId:t,message:iY}),!0)):!1}function sY(e){return oY(e)?!0:rY(e)}function cY(e){e.newURL===location.href&&sY(location.hash)}document.addEventListener(`click`,e=>{if(!uM()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&sY(t.hash)&&e.preventDefault()}),dR(I(document,`#celebration-tray`,`div`),I(document,`#btn-celebrations`,`button`),I(document,`#celebration-tray-count`,`span`)),I(document,`#btn-help`,`button`).addEventListener(`click`,()=>{eY(`browser-shortcuts`)});var lY=Kq({onRestart:FY,openTerminal:e=>{pM(e)||(bY(`focus`),gD(e))},openPlan:e=>{bY(`focus`),_D(e)},openReviews:()=>pY(`prs`)?(mM(`prs`)||bY(`prs`),!0):!1,setPhoneAttention:gM});function uY(){return lY.map(e=>e.view)}var dY=uY();BW(lY),ny({panel:document.getElementById(`review-sidebar`)}),Uq(lY);function fY(e){return lY.find(t=>t.view===e)}function pY(e){return lY.some(t=>t.view===e&&!t.tab.hidden)}var mY=!0,hY=null;function gY(e){fY(e)?.attention?.acknowledge()}var _Y=null;function vY(e){_Y=T({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function yY(e){let t=fY(e);t&&(Vq(t,e=>Nq(t,e,`shown`)),vY(e))}function bY(e,{section:t,setting:n,persist:r=!0}={}){let i=fY(e);if(!i||!pY(e))return;let a=Ur();W.dispatch(`setActiveView`,e),mY=r,r&&(hY=null),document.body.dataset.activeView=e,document.body.dataset.reviewSidebarHidden=String(i.hasReviewSidebar!==!0),r&&fn(e);for(let t of lY){let n=t.view===e;t.el&&(t.el.hidden=!n),t.tab.setAttribute(`aria-selected`,String(n)),t.tab.tabIndex=n?0:-1}a!==e&&Hq(a)?.deactivate?.(),Vq(i,r=>{Ur()===e&&(r.activate?.(),Nq(i,r,`shown`),e===`settings`&&t&&HW(t,n??null))}),vY(e),a===`settings`&&e!==`settings`&&tY(),gY(e)}function xY(e,t){let{view:n}=e;e.tab.hidden=!t,hM(n,t),e.onAvailabilityChange?.(t),!uM()&&(!t&&Ur()===n&&bY(`focus`),t&&hY===n&&bY(n))}function SY(e){for(let{view:t,isAvailable:n}of kq(lY,e))xY(t,n)}function CY(e){let t=Aq(dY,e);lY.every((e,n)=>e.view===t[n])||(lY.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),I(document,`#header-tabs`,`div`).append(...lY.map(e=>e.tab)),aM(t))}function wY(e){Hw(e),XW(e),pk(e),SY(e),qJ(e),CY(e.viewTabOrder),es(e.streamerMode===!0),Aw(e.conversationView===!0)}for(let e of lY)e.gate&&(xY(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>xY(e,t)));Cx(()=>{pY(`trace`)&&(mM(`trace`)||bY(`trace`))});function TY(e,t){let n=lY.filter(e=>!e.tab.hidden),r=n[(n.findIndex(t=>t.view===e)+t+n.length)%n.length];return bY(r.view),r.tab}function EY(e){lY.some(e=>e.tab===document.activeElement)&&e.focus()}var DY=null;function OY(e){let t=uY();CY(e),S(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&CY(t)}).catch(()=>CY(t))}function kY(e){let t=DY;if(DY=null,!t||t===e)return;let n=uY();OY(jq(n,t,n.indexOf(e)))}for(let e=0;e<lY.length;e++){let{view:t,tab:n}=lY[e];n.addEventListener(`click`,()=>bY(t)),n.addEventListener(`dragstart`,e=>{DY=t,e.dataTransfer?.setData(`text/plain`,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`)}),n.addEventListener(`dragover`,e=>{DY&&DY!==t&&(e.preventDefault(),n.dataset.dropTarget=`true`)}),n.addEventListener(`dragleave`,()=>delete n.dataset.dropTarget),n.addEventListener(`drop`,e=>{e.preventDefault(),delete n.dataset.dropTarget,kY(t)}),n.addEventListener(`dragend`,()=>{DY=null}),n.addEventListener(`keydown`,e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),TY(Ur(),e.key===`ArrowRight`?1:-1).focus()))})}var AY=Xn(),jY=WW(location.hash),MY=ma(location.hash);if(jY&&bY(`settings`,{section:jY.sectionId,setting:jY.settingId,persist:!1}),MY&&bY(`focus`,{persist:!1}),!jY&&!MY){let e=pY(AY);e||(hY=AY),bY(e?AY:`focus`,{persist:e})}oM({panels:BA(lY),onScreenShown:e=>{yY(e),e!==`settings`&&tY(),e===`settings`&&!ja(location.hash)&&HW(),gY(e)},canGoBack:e=>e===`settings`&&JW()||e===`prs`&&Fz(),onBack:e=>{e===`settings`&&YW(),e===`prs`&&Iz()},headerControls:[I(document,`.header-title`,`h1`),I(document,`#status-indicator`,`div`),I(document,`#celebration-tray`,`div`),I(document,`#btn-add-session-header`,`button`),I(document,`#btn-help`,`button`),YJ,XJ,ZJ]}),qW(Zj),Pz(Zj);function NY(e){if(e===`phone`){let e=GE();for(let e of lY)Hq(e.view)?.deactivate?.();let t=WW(location.hash);sM({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}),t&&HW(t.sectionId,t.settingId);return}let t=dM();cM();let n=Ur();bY(pY(n)?n:`focus`,{persist:mY}),t&&gD(t)}Hd()&&NY(`phone`),Ud(NY),window.addEventListener(`hashchange`,cY);function PY({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){ZJ.classList.remove(`open`),$J();let o=Vw(),s=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;wr({title:t,message:s,confirmLabel:n,danger:r||o>0,onConfirm:()=>T({type:e})})}function FY(){PY({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}I(document,`#btn-restart`,`button`).addEventListener(`click`,FY);function IY(e){let t=Pr(`shutdown`,e);I(document,`#btn-shutdown`,`button`).hidden=!t,I(document,`#menu-divider-shutdown`,`div`).hidden=!t}I(document,`#btn-shutdown`,`button`).addEventListener(`click`,()=>{PY({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})});var LY=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`]);function RY(e,t){return e.value!==``&&LY.has(t.key)}function zY(e){let t=document.activeElement;return t instanceof HTMLElement?t.isContentEditable?!0:t instanceof HTMLTextAreaElement&&t.dataset.dashboardShortcuts===`allowed`?RY(t,e):(t.tagName===`INPUT`||t.tagName===`TEXTAREA`)&&!t.classList.contains(`xterm-helper-textarea`):!1}function BY({action:e,step:t}){switch(e){case`merge`:return vy(),!0;case`resolve-or-resync`:return by()||Cy(),!0;case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`next-attention`:return Hd()?!1:lq()?(pq(),!0):WE()?(sD(),!0):(Ur()===`prs`&&Lz()||xD(()=>bY(`focus`)),!0);case`rail-step`:return WE()?(yD(t),!0):!1;case`view-step`:return!Hd()&&(EY(TY(Ur(),t)),!0);case`session-nth`:return WE()?(vD(t),!0):!1;case`streamer-mode`:return as(),!0}}document.addEventListener(`keydown`,e=>{if(e.repeat||zY(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1,n=Dn(e,Pa,{isTerminalFocused:t},La());n&&BY(n)&&e.preventDefault()});var VY=Lr({mode:`trailing`,delayMs:150,run:()=>{T({type:`focus-change`,focused:document.hasFocus()})}});function HY(){VY.schedule()}function UY(){let e=dM();e&&B(e)?._isActiveViewer?.()===!0&&TT(e)}function WY(){HY(),fg(B(Wr())),UY()}window.addEventListener(`focus`,WY),window.addEventListener(`blur`,WY),document.addEventListener(`visibilitychange`,WY);var GY=!1;async function KY(){if(!GY){GY=!0,eg();try{if(await Vt()===`ok`)return;for(let e of H.keys())ng(e)}finally{tg(),GY=!1}}}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&(Xm(),KY())}),window.addEventListener(`online`,KY);var qY=Te(T);window.addEventListener(`error`,e=>{qY(e.error),ke(`uncaught`,Jt(e.error??e.message))}),window.addEventListener(`unhandledrejection`,e=>{qY(e.reason),ke(`unhandled-rejection`,Jt(e.reason))}),Gq(()=>window.sessionStorage),window.addEventListener(`pageshow`,e=>{e.persisted&&(Xm(),KY())}),Jg(I(document,`#health-footer-mount`,`div`)),$d(Uw),xJ(),Ee();export{EU as $,YS as $a,tC as $i,uF as $n,cu as $o,eA as $r,UF as $t,UW as A,SS as Aa,OO as Ai,hF as An,hx as Ao,zk as Ar,Iz as At,tW as B,VC as Ba,VD as Bi,EF as Bn,Hb as Bo,Lk as Br,nz as Bt,zW as C,dS as Ca,xA as Ci,IP as Cn,mC as Co,HM as Cr,ta as Cs,eB as Ct,MW as D,Ux as Da,lk as Di,aF as Dn,bx as Do,LA as Dr,Lz as Dt,VW as E,$x as Ea,mA as Ei,eP as En,yx as Eo,PA as Er,Mr as Es,Oz as Et,CU as F,AS as Fa,IO as Fi,qP as Fn,Wb as Fo,Mk as Fr,Mz as Ft,DU as G,IC as Ga,JD as Gi,NF as Gn,Sf as Go,qk as Gr,$R as Gt,aW as H,gS as Ha,SO as Hi,$N as Hn,kf as Ho,wk as Hr,iz as Ht,$U as I,iC as Ia,VO as Ii,YP as In,Vb as Io,Uk as Ir,jR as It,eW as J,ZC as Ja,nE as Ji,ZP as Jn,Ud as Jo,Ak as Jr,UR as Jt,MU as K,KC as Ka,YD as Ki,IF as Kn,df as Ko,Vk as Kr,WR as Kt,TU as L,rC as La,jO as Li,pF as Ln,Ub as Lo,Hk as Lr,YR as Lt,mU as M,vS as Ma,yO as Mi,tP as Mn,fb as Mo,Kk as Mr,Dz as Mt,OU as N,hC as Na,MO as Ni,VP as Nn,wb as No,Pk as Nr,Nz as Nt,PW as O,Hx as Oa,ck as Oi,CF as On,vx as Oo,FA as Or,kz as Ot,nW as P,wC as Pa,BO as Pi,FF as Pn,Rb as Po,Nk as Pr,Sz as Pt,jU as Q,ZS as Qa,$C as Qi,kP as Qn,ou as Qo,vA as Qr,CR as Qt,QU as R,QS as Ra,WD as Ri,cP as Rn,Gb as Ro,kk as Rr,JR as Rt,LW as S,_C as Sa,hA as Si,PF as Sn,BC as So,VM as Sr,ea as Ss,dB as St,GW as T,Jx as Ta,iA as Ti,SP as Tn,xx as To,zM as Tr,jr as Ts,Cz as Tt,WU as U,DS as Ua,CO as Ui,lP as Un,Of as Uo,Tk as Ur,HR as Ut,xU as V,hS as Va,xO as Vi,QP as Vn,Af as Vo,Ek as Vr,GR as Vt,kU as W,oS as Wa,LD as Wi,aP as Wn,ff as Wo,Jk as Wr,ZR as Wt,hU as X,CS as Xa,tw as Xi,LP as Xn,xu as Xo,Dk as Xr,TR as Xt,gU as Y,wS as Ya,rE as Yi,tF as Yn,Pu as Yo,Fk as Yr,QR as Yt,FU as Z,Kx as Za,ew as Zi,yF as Zn,bu as Zo,Bk as Zr,wR as Zt,XW as _,IS as _a,lA as _i,AF as _n,aw as _o,cN as _r,Yi as _s,VB as _t,AK as a,Nx as aa,tA as ai,kF as an,ES as ao,ON as ar,Pa as as,QH as at,KW as b,tS as ba,pA as bi,DP as bn,iS as bo,yN as br,oa as bs,fB as bt,MK as c,sC as ca,cA as ci,TP as cn,EC as co,KM as cr,Ba as cs,aV as ct,wK as d,DC as da,TA as di,xF as dn,jS as do,LN as dr,Na as ds,RB as dt,pS as ea,DA as ei,WF as en,jC as eo,RP as er,Kl as es,iW as et,RK as f,cw as fa,Xk as fi,wF as fn,iw as fo,XM as fr,Aa as fs,BB as ft,fW as g,LS as ga,gA as gi,BP as gn,ow as go,wN as gr,ga as gs,UB as gt,SG as h,RS as ha,yA as hi,vF as hn,Gx as ho,EN as hr,va as hs,zB as ht,BK as i,yC as ia,_A as ii,nF as in,kC as io,rP as ir,ns as is,rU as it,pU as j,lC as ja,TD as ji,HP as jn,gx as jo,Rk as jr,jz as jt,jW as k,Vx as ka,sk as ki,mF as kn,_x as ko,Wk as kr,wz as kt,EK as l,cC as la,Zk as li,gF as ln,Xx as lo,GM as lr,za as ls,sV as lt,gG as m,rS as ma,nA as mi,cF as mn,Wx as mo,kN as mr,xa as ms,HB as mt,Aq as n,zS as na,uA as ni,fP as nn,CC as no,MP as nr,$o as ns,lW as nt,NK as o,Ax as oa,oA as oi,MF as on,lS as oo,qM as or,Ra as os,xH as ot,TG as p,eS as pa,fA as pi,sF as pn,GC as po,zN as pr,Ma as ps,FB as pt,sW as q,pC as qa,_O as qi,XP as qn,Hd as qo,jk as qr,rz as qt,zK as r,xC as ra,bA as ri,pP as rn,bC as ro,NP as rr,ts as rs,uW as rt,DK as s,jx as sa,CA as si,jF as sn,nS as so,JM as sr,Va as ss,cV as st,jq as t,mS as ta,SA as ti,rF as tn,NC as to,fF as tr,el as ts,AU as tt,TK as u,QC as ua,$k as ui,SF as un,AC as uo,RN as ur,La as us,oV as ut,AW as v,PS as va,sA as vi,LF as vn,nw as vo,oN as vr,Qi as vs,LB as vt,YW as w,sw as wa,EA as wi,FP as wn,rw as wo,BM as wr,oi as ws,tB as wt,IW as x,MS as xa,wA as xi,lF as xn,zC as xo,UM as xr,Xi as xs,mB as xt,NW as y,FS as ya,aA as yi,eF as yn,cS as yo,sN as yr,sa as ys,IB as yt,NU as z,WC as za,uO as zi,DF as zn,ub as zo,Ok as zr,XR as zt};
172
+ `)),n.comments)}function EF(e){let t=e.comments.length+e.generalFindings.length;return[e.note.trim()?`your note`:``,t?`${t} ${t===1?`finding`:`findings`}`:``].filter(Boolean).join(` and `)}function DF(e,t){let n=EF(t);return n?`Posts ${n}, labeled as an automated review, at ${At(e.reviewedHead)}.`:`Nothing ticked: Approve posts a bare approval, Comment needs a finding or a note.`}function OF(e,t){let n=EF(t);return e===`approve`&&n?`Approved on GitHub with ${n}`:e===`comment`&&n?`Commented on GitHub with ${n}`:NF(e)}var kF=Object.freeze({approve:`Approve`,"approve-only":`Approve`,comment:`Comment`,discard:`Not mine`,requeue:`Re-run review`,"resolve-thread":`Resolve`});function AF(e){return kF[e]}function jF(e){return e.status===`ready`?{primary:[`approve`,`comment`],secondary:[`requeue`,`discard`]}:ft(e)?{primary:[`approve-only`],secondary:[`requeue`]}:e.status===`error`||e.status===`stale`?{primary:[`requeue`],secondary:[`discard`]}:oF(e.status)?{primary:[`requeue`],secondary:[]}:{primary:[],secondary:[]}}function MF(e){return SP[e]}function NF(e){return xP[e]}function PF(e){return e===0?`Picked for review. It starts on the next poll.`:`Waiting for a free review slot. It starts as soon as ${e===1?`the review`:`one of the ${e} reviews`} in progress finishes.`}function FF(e){return e?e.configured?e.error?`Review drafts will show here once GitHub answers.`:`No review drafts yet. New teammate pull requests show up here after the next poll.`:e.reason?`Team review is not running: ${e.reason}.`:`Team review is off.`:`Waiting for the team review lane.`}function IF(e){return e?.configured&&e.reason||null}function LF(e){return`${e.key}@${e.reviewedHead}:${e.status}:${e.summary}:${LP(e).map(e=>e.text).join(`, `)}`}function RF(e){return`reviewedHead`in e?JSON.stringify([e.prCreatedAt,e.reviewedAt,e.postedAt,e.githubReviews,e.liveHead,e.priorReviewedHead,e.viewerThreads]):JSON.stringify([e.prCreatedAt,e.priorReviewedHead])}var zF=null,BF=null,VF=new Set;function HF(e){for(let t of VF)t(e)}function UF(){BF=VN(zF,jr),HF({kind:`status`})}function WF(e){VF.add(e)}function GF(){return BF}function KF(){return CP(BF)}function qF(e){let t=Dt.safeParse(e);t.success?(zF=t.data,UF()):ke(`reviews`,`dropped team-review-status: ${v(t.error.issues)}`)}function JF(e){HF({kind:`action-result`,message:e})}function YF(e){HF({kind:`open-session-result`,message:e})}function XF(e){HF({kind:`connection`,isConnected:e})}Mr(UF);var ZF=1.2,QF=1.55,$F=.12,eI=523.25,tI=2,nI=8,Y=(e,t,n)=>({semitone:e,startBeat:t,beats:n}),rI={melody:[Y(7,4,.5),Y(11,4.5,.5),Y(12,5,3)],bass:[Y(-5,4,1),Y(-12,5,3)]},iI=[{melody:[Y(0,0,1),Y(4,1,1),Y(7,2,1),Y(9,3,1)],bass:[Y(-12,0,2),Y(-8,2,2)]},{melody:[Y(7,0,.67),Y(7,.67,.67),Y(7,1.33,.67),Y(9,2,1),Y(5,3,1)],bass:[Y(-12,0,2),Y(-7,2,2)]},{melody:[Y(5,0,1),Y(9,1,1),Y(7,2,1),Y(4,3,1)],bass:[Y(-7,0,2),Y(-12,2,2)]},{melody:[Y(12,0,.5),Y(7,.5,.5),Y(12,1,.5),Y(16,1.5,.5),Y(16,2,1),Y(14,3,1)],bass:[Y(-12,0,2),Y(-3,2,2)]},{melody:[Y(4,0,1),Y(7,1,1),Y(4,2,.5),Y(5,2.5,.5),Y(7,3,.5),Y(4,3.5,.5)],bass:[Y(-8,0,2),Y(-12,2,2)]}].map(e=>({melody:[...e.melody,...rI.melody],bass:[...e.bass,...rI.bass]}));function aI(e,t){return eI*2**((e+t)/12)}function oI(e,t){let n=(e,n,r)=>e.map(e=>({frequency:aI(e.semitone,t),startSeconds:QF+e.startBeat*$F,durationSeconds:e.beats*$F,waveform:n,gain:r}));return[...n(e.melody,`square`,.2),...n(e.melody,`triangle`,.5),...n(e.bass,`triangle`,.6)]}var sI=[{frequency:220,endFrequency:880,startSeconds:0,durationSeconds:.32,waveform:`triangle`,gain:.25},{frequency:160,endFrequency:45,startSeconds:ZF,durationSeconds:.28,waveform:`sine`,gain:1},{frequency:1400,endFrequency:380,startSeconds:ZF,durationSeconds:.06,waveform:`square`,gain:.12}];function cI(e){let t=iI[e%iI.length],n=Math.min(e*tI,nI);return{peakGain:.1,tones:[...sI,...oI(t,n)]}}function lI(e){return Math.round(Math.sqrt(2*e/780)*1e3)}function uI(e,t,n=Math.random){return Math.round(e+n()*(t-e))}function dI(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var fI=.6,pI=.25,mI=1.6;function hI(e){return Math.min(fI+e*pI,mI)}var gI=[`var(--accent)`,`var(--state-running)`,`var(--state-idle)`,`var(--state-waiting)`,`var(--state-failed)`];function _I(e,t=Math.random){let n=uI(320,520,t),r=uI(1800,2800,t);return[[`--confetti-start-x`,`${uI(4,96,t)}%`],[`--confetti-x`,`${uI(-140,140,t)}px`],[`--confetti-rise`,`${-uI(20,55,t)}px`],[`--confetti-fall`,`${uI(45,70,t)}vh`],[`--confetti-rise-ms`,`${n}ms`],[`--confetti-fall-ms`,`${r}ms`],[`--confetti-flight-ms`,`${n+r}ms`],[`--confetti-tilt`,`${uI(0,180,t)}deg`],[`--confetti-spin`,`${uI(-360,360,t)}deg`],[`--confetti-flutter-ms`,`${uI(160,340,t)}ms`],[`--confetti-delay`,`${uI(0,160,t)}ms`],[`--confetti-color`,gI[e%gI.length]]]}var vI=`<svg viewBox="0 0 36 36" aria-hidden="true"><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="17"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="13"/><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="9"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="5"/></svg>`,yI=`<svg viewBox="0 0 26 8" aria-hidden="true"><path class="merge-bullseye-dart-flight" d="M0 0L7 3V5L0 8L2 4Z"/><rect class="merge-bullseye-dart-shaft" x="6" y="3.3" width="8" height="1.4"/><rect class="merge-bullseye-dart-barrel" x="13" y="2.5" width="7" height="3" rx="1"/><path class="merge-bullseye-dart-tip" d="M20 3L26 4L20 5Z"/></svg>`;function bI(){let e=Ot(`div`,`merge-bullseye-target`,vI);return e.append(L(`span`,`merge-bullseye-ripple`)),e}function xI(){let e=L(`div`,`merge-bullseye-dart-drift`),t=L(`div`,`merge-bullseye-dart-arc`),n=L(`div`,`merge-bullseye-dart-aim`);return n.append(Ot(`div`,`merge-bullseye-dart`,yI)),t.append(n),e.append(t),e}function SI(){let e=L(`div`,`merge-bullseye-range`),t=L(`div`,`merge-bullseye-track`);return t.append(xI()),e.append(bI(),t),e}var CI={title:`BULLSEYE!`,buildScene:SI},wI=6,TI=30,EI=-14,DI=16;function OI(e=Math.random){return[[`--crosshair-start-left`,`${uI(wI,TI,e)}%`],[`--crosshair-start-offset-y`,`${uI(EI,DI,e)}px`]]}var kI=`<svg viewBox="0 0 26 40" aria-hidden="true"><path class="merge-headshot-target-body" d="M9 13H17L18 16Q25 18 25 24V40H1V24Q1 18 8 16Z"/><circle class="merge-headshot-target-head" cx="13" cy="7" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="7" r="3"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="2.5"/></svg>`,AI=`<svg viewBox="0 0 22 22" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M11 0V5M11 17V22M0 11H5M17 11H22"/><circle class="merge-headshot-crosshair-dot" cx="11" cy="11" r="1"/></svg>`,jI=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3L8 8M21 3L16 8M3 21L8 16M21 21L16 16"/></svg>`;function MI(){let e=L(`div`,`merge-headshot-sweep`);st(e,OI());let t=L(`div`,`merge-headshot-aim`);t.append(Ot(`div`,`merge-headshot-crosshair`,AI));let n=L(`div`,`merge-headshot-bob`);return n.append(t,Ot(`div`,`merge-headshot-hitmarker`,jI)),e.append(n),e}function NI(){let e=L(`div`,`merge-headshot-range`),t=L(`div`,`merge-headshot-track`);return t.append(MI()),e.append(Ot(`div`,`merge-headshot-target`,kI),t),e}var PI={title:`HEADSHOT!`,buildScene:NI},FI=[`10`,`J`,`Q`,`K`,`A`],II=160,LI=19,RI=5,zI=9,BI=780,VI=70,HI=70,UI=35;function WI(e){let t=FI.length-1,n=e-t/2;return{offsetPx:n*LI,titleSpreadFraction:n/t,tiltDegrees:n*RI,bottomPx:zI-n**2,dealLeadMs:BI-e*VI,flipLeadMs:II+(t-e)*HI,waveDelayMs:e*UI}}function GI(e){return[[`--card-offset`,`${e.offsetPx}px`],[`--card-title-spread`,String(e.titleSpreadFraction)],[`--card-tilt`,`${e.tiltDegrees}deg`],[`--card-bottom`,`${e.bottomPx}px`],[`--card-deal-lead-ms`,`${e.dealLeadMs}ms`],[`--card-flip-lead-ms`,`${e.flipLeadMs}ms`],[`--card-wave-delay-ms`,`${e.waveDelayMs}ms`]]}function KI(){return[[`--card-flip-ms`,`${II}ms`]]}var qI=`<svg viewBox="0 0 10 9" aria-hidden="true"><path d="M5 8.5C5 8.5 0 5.3 0 2.6C0 1.1 1.2 0 2.6 0C3.6 0 4.5 .6 5 1.4C5.5 .6 6.4 0 7.4 0C8.8 0 10 1.1 10 2.6C10 5.3 5 8.5 5 8.5Z"/></svg>`;function JI(e,t){let n=L(`div`,`merge-flush-deal`);st(n,GI(WI(t)));let r=L(`div`,`merge-flush-hop`),i=L(`div`,`merge-flush-card`),a=L(`div`,`merge-flush-face`);return a.append(L(`span`,`merge-flush-rank`,e)),a.insertAdjacentHTML(`beforeend`,qI),i.append(L(`div`,`merge-flush-back`),a),r.append(i),n.append(r),n}function YI(){let e=L(`div`,`merge-flush-table`);return st(e,KI()),e.append(...FI.map(JI)),e}var XI={title:`ROYAL FLUSH!`,buildScene:YI},ZI=[1,2,3,4],QI=14,$I=3,eL=3,tL=10,nL=20,rL=2,iL=28,aL=18,oL=.01,sL=1.5,cL=2200,lL=1,uL=120,dL=.35,fL=15,pL=105,mL=4,hL=65,gL=145;function _L(e){return Math.round(e/(Math.PI*aL)*360)}function vL(e){return nL-e*rL}function yL(e){return e.rowIndex*QI+e.depthIndex*$I}function bL(e,t,n){return Array.from({length:n},(r,i)=>e+(t-e)*i/(n-1))}function xL(){return ZI.flatMap((e,t)=>Array.from({length:e},(n,r)=>({rowIndex:t,depthIndex:e-1-r})))}function SL(e,t){let n=dI(bL(fL,pL,e),t),r=dI(bL(hL,gL,e),t);return n.map((e,n)=>({angleDegrees:e+uI(-4,mL,t),depthScalePercent:Math.round(r[n])}))}function CL(e,t,n){let r=uI(240,380,n),i=t.angleDegrees*Math.PI/180,a=r*Math.cos(i),o=(r*Math.sin(i))**2/1560,s=uI(15,45,n),c=lI(o),l=lI(o+s),u=c+l,d=uI(540,1080,n),f=a>=0?1:-1,p=yL(e);return{depthIndex:e.depthIndex,launchAngleDegrees:t.angleDegrees,distanceFromHeadPinPx:p,layer:vL(e.depthIndex),flyXPx:Math.round(a*u/1e3),peakRisePx:Math.round(o),landingDropPx:s,riseMs:c,fallMs:l,flightMs:u,spinDegrees:Math.round(f*d*u/1e3),glintMs:Math.round(180/d*1e3),depthScalePercent:t.depthScalePercent,delayMs:Math.round(p/dL)}}function wL(e=Math.random){let t=xL(),n=SL(t.length,e);return t.map((t,r)=>CL(t,n[r],e))}function TL(e){return[[`--pin-left`,`${e.distanceFromHeadPinPx}px`],[`--pin-raise`,`${e.depthIndex*eL}px`],[`--pin-shade`,`${100-e.depthIndex*12}%`],[`--pin-fly-x`,`${e.flyXPx}px`],[`--pin-peak-y`,`${-e.peakRisePx}px`],[`--pin-land-y`,`${e.landingDropPx}px`],[`--pin-rise-ms`,`${e.riseMs}ms`],[`--pin-fall-ms`,`${e.fallMs}ms`],[`--pin-flight-ms`,`${e.flightMs}ms`],[`--pin-spin`,`${e.spinDegrees}deg`],[`--pin-glint-ms`,`${e.glintMs}ms`],[`--pin-depth-scale`,`${e.depthScalePercent}%`],[`--pin-depth-shade`,`${e.depthScalePercent-10}%`],[`--pin-delay`,`${e.delayMs}ms`],[`--pin-layer`,String(e.layer)]]}function EL(){return vL(sL)}function DL(){return Math.max(...xL().map(yL))+tL}function OL(){let e=DL(),t=iL+e+aL-lL;return[[`--ball-follow-px`,`${uL}px`],[`--ball-follow-ms`,`${Math.round(uL/dL)}ms`],[`--ball-follow-spin`,`${_L(uL)}deg`],[`--ball-size`,`${aL}px`],[`--ball-approach-spin`,`${cL}deg`],[`--ball-impact-inset`,`${t}px`],[`--ball-layer`,String(EL())],[`--rack-right`,`${iL}px`],[`--rack-width`,`${e}px`],[`--pin-width`,`${tL}px`]]}function kL(e=Math.random){return e()>=oL?null:sn[Math.floor(e()*sn.length)].sprite}var AL=`<svg viewBox="0 0 10 24" aria-hidden="true"><path class="merge-strike-pin-body" d="M5 0C7 0 7.6 2 7.2 4C6.9 5.6 6.3 6.6 6.4 8C6.6 10 9.6 12 9.6 16C9.6 19.5 8.4 22 7.6 24H2.4C1.6 22 .4 19.5 .4 16C.4 12 3.4 10 3.6 8C3.7 6.6 3.1 5.6 2.8 4C2.4 2 3 0 5 0Z"/><path class="merge-strike-pin-stripe" d="M3.1 5.2H6.9V6.2H3.1ZM3.4 7H6.6V8H3.4Z"/></svg>`;function jL(e){let t=L(`span`,`merge-strike-pin`);return t.append(Ot(`span`,`merge-strike-pin-arc`,AL)),st(t,TL(e)),t}function ML(){let e=kL();if(!e)return L(`span`,`merge-strike-ball`);let t=L(`span`,`merge-strike-ball is-animal`);return t.append(L(`span`,`nyan-sprite ${e}`)),t}function NL(){let e=L(`div`,`merge-strike-lane`);st(e,OL());let t=L(`div`,`merge-strike-rack`);t.append(...wL().map(jL));let n=L(`div`,`merge-strike-track`);return n.append(ML()),e.append(t,n),e}var PL={title:`STRIKE!`,buildScene:NL},FL=20,IL=92,LL=23,RL=7,zL=-40;function BL(){let e=lI(72),t=lI(69),n=780*t/1e3;return{launchHeightPx:FL,peakHeightPx:IL,heightThroughRimPx:LL,heightLeavingNetPx:RL,heightOutOfCardPx:zL,riseMs:e,fallToRimMs:t,speedThroughRimPxPerSecond:n,netCatchMs:Math.round(32/n*1e3),dropMs:lI(47)}}function VL(e=BL()){return[[`--ball-launch-y`,`${-e.launchHeightPx}px`],[`--ball-peak-y`,`${-e.peakHeightPx}px`],[`--ball-rim-y`,`${-e.heightThroughRimPx}px`],[`--ball-net-exit-y`,`${-e.heightLeavingNetPx}px`],[`--ball-drop-out-y`,`${-e.heightOutOfCardPx}px`],[`--ball-rise-ms`,`${e.riseMs}ms`],[`--ball-fall-to-rim-ms`,`${e.fallToRimMs}ms`],[`--ball-to-rim-ms`,`${e.riseMs+e.fallToRimMs}ms`],[`--ball-net-catch-ms`,`${e.netCatchMs}ms`],[`--ball-drop-ms`,`${e.dropMs}ms`]]}var HL=`<svg viewBox="0 0 40 48" aria-hidden="true"><rect class="merge-swish-pole" x="36" y="28" width="2" height="20"/><rect class="merge-swish-backboard" x="35" y="2" width="3" height="26" rx="1"/><path class="merge-swish-rim" d="M31 18H35M7 18A12 2.5 0 0 1 31 18"/></svg>`,UL=`<svg viewBox="0 0 40 48" aria-hidden="true"><g class="merge-swish-net"><path d="M8 18L12 32M13.5 18L15.5 32M19 18V32M24.5 18L22.5 32M30 18L26 32M9.5 23Q19 25 28.5 23M11 28Q19 29.5 27 28"/></g><path class="merge-swish-rim" d="M7 18A12 2.5 0 0 0 31 18"/></svg>`;function WL(){let e=L(`div`,`merge-swish-ball-drift`),t=L(`div`,`merge-swish-ball-arc`);return t.append(L(`span`,`merge-swish-ball`)),e.append(t),e}function GL(){let e=L(`div`,`merge-swish-court`);st(e,VL());let t=L(`div`,`merge-swish-track`);return t.append(WL()),e.append(Ot(`div`,`merge-swish-hoop-back`,HL),t,Ot(`div`,`merge-swish-hoop-front`,UL)),e}var KL=[PL,{title:`SWISH!`,buildScene:GL},CI,PI,XI],qL=48,JL=5600,YL=20,XL=null,ZL=[],QL=null,$L=!1,eR=0;function tR(e){let t=L(`span`,`merge-confetti-piece`),n=L(`span`,`merge-confetti-arc`);return n.append(L(`span`,`merge-confetti-paper`)),t.append(n),st(t,_I(e)),t}function nR(e){let t=L(`p`,`merge-celebration-title`);return t.setAttribute(`aria-hidden`,`true`),Array.from(e).forEach((e,n)=>{let r=L(`span`,`merge-celebration-letter`,e);r.style.setProperty(`--letter-delay`,`${n*45}ms`),t.append(r)}),t}function rR(e,t,n){let r=t.firstElementChild,i=t.lastElementChild;r instanceof HTMLElement&&i instanceof HTMLElement&&(e.style.setProperty(`--celebration-title-width`,`${i.offsetLeft+i.offsetWidth-r.offsetLeft}px`),e.style.setProperty(`--celebration-title-center-y`,`${t.offsetTop+t.offsetHeight/2-n.offsetTop}px`))}function iR(e){let t=L(`div`,`merge-celebration-scene`);return t.setAttribute(`aria-hidden`,`true`),t.append(e.buildScene()),t}function aR(){return KL[Math.floor(Math.random()*KL.length)]}function oR(e){if(gn())try{_f(cI(e))}catch{}}function sR(e){let t=L(`ul`,`merge-celebration-details`);for(let n of e)t.append(L(`li`,`merge-celebration-detail`,n));return t}function cR(e,t,n){XL?.remove(),oR(n);let r=L(`div`,`merge-celebration`);r.setAttribute(`role`,`status`);let i=L(`div`,`merge-celebration-card`),a=L(`div`,`merge-celebration-stage`),o=nR(t.title),s=iR(t);a.append(o,L(`p`,`merge-celebration-message`,e.message),sR(e.detailLines),s);let c=L(`div`,`merge-confetti`);c.style.setProperty(`--confetti-scale`,String(hI(n)));for(let e=0;e<qL;e+=1)c.append(tR(e));i.append(c,a),r.append(i),document.body.append(r),rR(a,o,s),XL=r,window.setTimeout(()=>{r.remove(),XL===r&&(XL=null)},JL)}function lR(e){return $L?`playing`:e?`queued`:`empty`}function uR(){if(!QL)return;let e=ZL.length>0;QL.tray.dataset.state=lR(e),QL.count.textContent=e?String(ZL.length):``,QL.button.disabled=$L||!e}function dR(){let e=ZL.shift();$L=e!==void 0,uR(),e&&(cR(e.text,e.scene,eR),eR+=1,window.setTimeout(dR,JL))}function fR(e,t,n){QL={tray:e,button:t,count:n},t.addEventListener(`click`,()=>{eR=0,dR()}),uR()}function pR(e,t=aR()){ZL.push({text:e,scene:t}),ZL.length>YL&&ZL.shift(),uR()}var mR=null,hR=null,gR=new Set,_R=new Map,vR=!1,yR=new Set;function bR(e){for(let t of yR)t(e)}function xR(){return[..._R].flatMap(([e,t])=>{let n=H.get(e);return!n||t.length===0?[]:[{id:e,title:tn(n)||e,links:t}]})}function SR(){let e=jN(mR?.prs??[],jr),t=NN(hR,e);hR=e,ER(t),bR({kind:`prs`})}function CR(){vR||(vR=!0,queueMicrotask(()=>{vR=!1,SR()}))}function wR(e){yR.add(e)}function TR(){return{prs:jN(mR?.prs??[],jr),status:mR,sessionsByPrKey:MN(xR())}}function ER(e){let t=e.filter(e=>!gR.has(e.key));if(t.length!==0){for(let e of t)gR.add(e.key);pR(FN(t))}}function DR(e){_R=e,CR()}function OR(){bR({kind:`session-state`})}function kR(e){let t=d.safeParse(e);t.success?(mR=t.data,SR()):ke(`reviews`,`dropped my-prs-status: ${v(t.error.issues)}`)}function AR(e){bR({kind:`merge-result`,message:e})}function jR(e){bR({kind:`connection`,isConnected:e})}Mr(CR);var MR=[{id:`all`,label:`All`},{id:`reviewing`,label:`Reviewing`},{id:`mine`,label:`Mine`}],NR={turn:`Your turn`,working:`Agent working`,waiting:`Waiting on others`,aside:`Set aside`},PR=[`turn`,`working`,`waiting`,`aside`],FR={conflicts:`turn`,behind:`turn`,"checks-failing":`turn`,"changes-requested":`turn`,"unresolved-threads":`turn`,ready:`turn`,"checks-pending":`waiting`,"needs-approval":`waiting`,unknown:`waiting`,draft:`aside`,merged:`aside`},IR={directAsk:0,followUp:1,mineNeedsYou:2,teamReady:3,mineReady:4,failedReview:5,staleReview:6,fork:7};function LR(e,t){return{source:`team`,key:`team:${e.key}`,prKey:ot(e),kind:t,review:e}}function RR(e){return e.status===`ready`?UN(e).band===`blocking-others`?IR.directAsk:IR.teamReady:IR.followUp}function zR(e){return[...e.ready.map(e=>({item:LR(e,`ready`),group:`turn`,turnRank:RR(e)})),...e.attention.map(e=>({item:LR(e,`attention`),group:`turn`,turnRank:e.status===`error`?IR.failedReview:IR.staleReview})),...e.handReview.map(e=>({item:LR(e,`handReview`),group:`turn`,turnRank:IR.fork})),...e.inReview.map(e=>({item:LR(e,`inReview`),group:`working`,turnRank:0})),...e.queued.map(e=>({item:LR(e,`queued`),group:`working`,turnRank:0})),...e.noReviewNeeded.map(e=>({item:LR(e,`settled`),group:`waiting`,turnRank:0})),...e.posted.map(e=>({item:LR(e,`posted`),group:`waiting`,turnRank:0})),...e.discarded.map(e=>({item:LR(e,`discarded`),group:`aside`,turnRank:0}))]}function BR(e,t){let n=FR[e.stage];return n===`turn`&&e.stage!==`ready`&&t.has(ot(e))?`working`:n}function VR(e,t){return oN(e).flatMap(e=>e.rows).map(({pr:e,parentKey:n})=>({item:{source:`mine`,key:`mine:${e.key}`,prKey:ot(e),pr:e,stackedOn:n},group:BR(e,t),turnRank:e.stage===`ready`?IR.mineReady:IR.mineNeedsYou}))}function HR(e,t,n){let r=[...zR(e),...VR(t,n)];return PR.map(e=>{let t=r.filter(t=>t.group===e),n=e===`turn`?t.toSorted((e,t)=>e.turnRank-t.turnRank):t;return{id:e,title:NR[e],items:n.map(e=>e.item)}})}function UR(e,t){if(t===`all`)return[...e];let n=t===`reviewing`?`team`:`mine`;return e.map(e=>({...e,items:e.items.filter(e=>e.source===n)}))}function WR(e){return e.find(e=>e.id===`turn`)?.items??[]}function GR(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function KR(e,t){return GR(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function qR(e){return e.source===`mine`?$P(e.pr.repo,e.pr.number):$P(e.review.repo,e.review.number)}function JR(e){return e.source===`team`?e.kind===`attention`&&`status`in e.review&&e.review.status===`error`?`failed`:`waiting`:e.pr.stage===`ready`?`finished`:e.pr.stage===`checks-failing`||e.pr.stage===`conflicts`?`failed`:`waiting`}function YR(e){return WR(e).map(e=>({id:e.key,kind:JR(e),name:qR(e)}))}function XR(e){return{waitingCount:e.filter(e=>e.kind===`waiting`).length,finishedCount:e.filter(e=>e.kind===`finished`).length,failedCount:e.filter(e=>e.kind===`failed`).length}}function ZR(e,t){return YR(e).filter(e=>e.id!==t)}function QR({capturedOrder:e,actedKey:t,groups:n}){let r=WR(n).map(e=>e.key).filter(e=>e!==t),i=new Set(r);return e.slice(e.indexOf(t)+1).find(e=>i.has(e))??e.find(e=>i.has(e))??r[0]??null}function $R(e,t){let n=WR(e).map(e=>e.key),r=t?n.indexOf(t):-1;return r===-1?``:`${r+1} of ${n.length} in Your turn`}function ez(e){return e.source===`mine`?`${e.key}@${e.pr.stage}`:`reviewedHead`in e.review?`${e.review.key}@${e.review.reviewedHead}`:`${e.review.key}@${e.kind}`}function tz(e){return WR(e).map(ez)}function nz({turnEntries:e,acknowledged:t,unseen:n,isLooking:r}){let i=new Set(e),a=new Set(t.split(`|`).filter(e=>i.has(e))),o=new Set(n.split(`|`).filter(e=>i.has(e))),s=[...i].filter(e=>!a.has(e));if(r)return{isShown:!1,acknowledged:Ut([...i]),unseen:Ut([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:Ut([...a]),unseen:Ut([...o])}}function rz(e){let t=e.find(e=>e.id===`working`)?.items.length??0;return t===0?`Nothing needs you right now.`:`Nothing needs you right now. ${t} ${t===1?`pull request is`:`pull requests are`} with an agent.`}function iz(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function az(e){let t=e.filter(e=>e?.configured===!0);if(t.length===0)return e.find(e=>e!==null)??null;let n=t.toSorted((e,t)=>(e.lastRefreshedAt??e.lastSyncAt??0)-(t.lastRefreshedAt??t.lastSyncAt??0));return{...t.find(e=>e.error)??n[0],isRefreshing:t.some(e=>e.isRefreshing)}}var oz=[],sz=null,cz=null,lz=null,uz=!1,dz=null,fz=En(),pz=Zn(),mz=new Set(pz.split(`|`).filter(Boolean)),hz=new Set,gz=new Set;function _z(e){for(let t of gz)t(e)}function vz(e){e!==fz&&(fz=e,_n(e))}function yz(e){e!==pz&&(pz=e,mz=new Set(e.split(`|`).filter(Boolean)),dn(e))}function bz(){return GF()!==null&&TR().status!==null}function xz(){if(!bz())return;let e=nz({turnEntries:tz(oz),acknowledged:fz,unseen:pz,isLooking:cz?.isLooking()??!1});vz(e.acknowledged),yz(e.unseen),dz?.(e.isShown)}function Sz(e){lz=e,_z({kind:`reveal`})}function Cz(e){gz.add(e)}function wz(e){cz=e,xz()}function Tz(){let{prs:e,sessionsByPrKey:t}=TR();return oz=HR(KF(),e,new Set(t.keys())),xz(),oz}function Ez(){bz()&&(vz(Ut(tz(oz))),xz())}function Dz(e){dz=e,xz()}function Oz(){return pz}function kz(e){return mz.has(e)}function Az(e){return mz.has(e)?(yz(Ut([...mz].filter(t=>t!==e))),!0):!1}function jz(e){sz=e}function Mz(){return sz}function Nz(){let e=lz;return lz=null,e}function Pz(e){if(e!==uz){uz=e;for(let e of hz)e()}}function Fz(e){hz.add(e)}function Iz(){return document.documentElement.dataset.layout===`phone`&&uz}function Lz(){Iz()&&_z({kind:`return-to-queue`})}function Rz(){let e=ZR(oz,cz?.selectedKey()??null)[0]?.id??null;return e?(Sz(e),!0):!1}function zz(e){let t=oz.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!sz?.openReviews()?!1:(Sz(t.key),Ez(),!0)}WF(e=>{e.kind===`status`&&Tz()}),wR(e=>{e.kind===`prs`&&Tz()});var Bz={OPEN:0,MERGED:1,CLOSED:2};function Vz(e){return e?Bz[e.state]:Bz.OPEN}function Hz(e,t){let n=`${e.repo}#${e.number}`,r=`#${e.number}`;if(!t)return{key:n,text:r,url:e.url,hoverText:e.repo,look:null,tier:Ms(void 0)};let i=cN(t.stage);return{key:n,text:r,url:t.url,hoverText:`${e.repo}: ${t.title} (${sN(t.stage)})`,look:{icon:lN(t.stage),tone:i},tier:Ms(i)}}function Uz(e,t){let n=e.map(e=>{let n=t(ot(e));return{link:e,pr:n?wM(n):void 0}});return n.sort((e,t)=>Vz(e.pr)-Vz(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>Hz(e,t))}var Wz=new Map;function Gz(e){return document.querySelectorAll(`[data-pr-chips-for="${CSS.escape(e)}"]`)}function Kz(e){return Uz(Wz.get(e)??[],jr).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,hoverText:`${e.hoverText}. Show in Reviews; Cmd/Ctrl-click opens GitHub`,onActivate:()=>{zz(e.key)||sc(e.url)}}))}function qz(e,t){let n=ql(e,e),r=L(`button`,`session-pr-chip-unlink`);r.append(sr(ur)),r.type=`button`,r.title=`Unlink ${e.key} from this session`,r.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),r.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),wr({title:`Unlink pull request`,message:`Unlink ${e.key} from this session? Its checks and reviews stop showing here until you link it again.`,confirmLabel:`Unlink`,danger:!0,onConfirm:()=>{Lu(t,{type:`unlink-session-pr`,id:t,key:e.key})}})});let i=L(`span`,`session-pr-chip-item`);return i.append(n,r),i}function Jz(e,t){e.dataset.prChipsFor=t,Ql(e,Kz(t),e=>qz(e,t))}function Yz(e){for(let t of e){let e=t.dataset.prChipsFor;e&&Jz(t,e)}au()}function Xz(e,t){let n=at.shape.links.safeParse(t??[]);Wz.set(e,n.success?n.data:[]),Yz(Gz(e)),DR(Wz)}function Zz(e){Wz.delete(e),DR(Wz)}Mr(()=>Yz(document.querySelectorAll(`[data-pr-chips-for]`)));var Qz=null,$z=new Set;function eB(){Qz?.setAttribute(`aria-pressed`,String(!gn()))}function tB(e){pn(e),eB();for(let t of $z)t(e)}function nB(e){$z.add(e)}function rB(e){Qz=e,eB(),e.addEventListener(`click`,()=>tB(!gn()))}var iB={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},aB=null,oB=null,sB=!0,cB=new Map,lB=new Map,uB=new Set;function dB(){for(let e of uB)e()}function fB(e){uB.add(e)}function pB(){return{status:aB,isServerConnected:sB,pendingActionBySuite:cB,outcomeBySuite:lB}}function mB(e){oB=e}function hB(e,t){oB?.({type:`benchmark-action`,requestId:y(`benchmark`),suiteId:e,action:t})===!0?(cB.set(e,t),lB.set(e,iB[t]),dB()):(lB.set(e,p),dB())}function gB(e){if(sB=e,!e){for(let e of cB.keys())lB.delete(e);cB.clear()}dB()}function _B(e){aB=e,dB()}function vB(e){cB.delete(e.suiteId);let t=aB?.suites.find(t=>t.id===e.suiteId)?.candidateCount??0,n={mine:`Mining finished. ${t} candidate${t===1?``:`s`} awaiting approval in the candidates folder.`,run:`Run ${e.runId??``} started.`,cancel:`Run cancelled.`};lB.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),dB()}var yB=45e3,bB=`The server did not answer within ${yB/1e3} s.`,xB=`Select the issue to load its description.`,SB=null,CB=null,wB=new Map,TB=null,EB=new Map,DB=new Map,OB=new Map,kB=new Map,AB=new Map,jB=new Set;function MB(e){for(let t of jB)t(e)}function NB(e){return`${e.key}:${e.updatedAt}`}function PB(e){let t=EB.get(e);t&&(EB.delete(e),DB.set(t.issueKey,{text:bB,tone:`error`}),MB(`detail`))}function FB(e){let t=EB.get(e);return t?(clearTimeout(t.timeoutHandle),EB.delete(e),t):null}function IB(){return{latestStatus:CB,issueByKey:wB,selectedKey:SB}}function LB(e){jB.add(e)}function RB(e){SB=e}function zB(e){return[...EB.values()].some(t=>t.issueKey===e.key)}function BB(e){return DB.get(e.key)}function VB(e){let t=NB(e),n=kB.get(t);return n===``?`No description.`:n??AB.get(t)??`Loading description.`}function HB(e){let t=NB(e);if(kB.has(t)||[...OB.values()].some(e=>e.cacheKey===t))return;let n=y(`issue-detail`);AB.delete(t),TB?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?OB.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{OB.delete(n),AB.set(t,`${bB} ${xB}`),MB(`detail`)},yB)}):AB.set(t,`${p} ${xB}`)}function UB(e){let t=e.projectId;if(!t||zB(e))return;let n=y(`open-issue-session`);TB?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(EB.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>PB(n),yB)}),DB.set(e.key,{text:`Opening session.`,tone:`busy`}),MB(`detail`)):(DB.set(e.key,{text:p,tone:`error`}),MB(`detail`))}function WB(e){TB?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function GB(e){TB=e}function KB(){MB(`session-state`)}function qB(e){if(!e){for(let e of EB.values())clearTimeout(e.timeoutHandle),DB.set(e.issueKey,{text:p,tone:`error`});EB.clear();for(let e of OB.values())clearTimeout(e.timeoutHandle),AB.set(e.cacheKey,`${p} ${xB}`);OB.clear(),MB(`status`)}}function JB(e){let t=CB?.issues.find(e=>e.key===SB);CB=e,wB=new Map(e.issues.map(e=>[e.key,e]));let n=e.issues.find(e=>e.key===SB);n&&n.updatedAt!==t?.updatedAt&&HB(n),MB(`status`)}function YB(e){let t=OB.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),OB.delete(e.requestId),e.ok&&e.body!==null&&kB.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&AB.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),MB(`detail`))}function XB(e){if(typeof e.requestId!=`string`)return;let t=FB(e.requestId);if(!t)return;let n=t.issueKey;if(e.ok===!0){let r=typeof e.sessionName==`string`?e.sessionName:`issue #${t.issueNumber}`,i=e.pending===!0?` Prompt queued.`:``,a=e.existing===!0?`already open`:`created`;DB.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=CB?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),MB(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;DB.set(n,{text:r,tone:`error`}),MB(`detail`)}var ZB=null,QB=null,$B=null,eV=()=>!1,tV=new Set,nV=new Set,rV=Oe({getAck:On,setAck:qn,signature:()=>wt({posthog:ZB}),isLooking:()=>eV()});function iV(e){for(let t of nV)t(e)}function aV(){QB?.(rV.refresh())}function oV(){return{latest:ZB,archivedLocally:tV,traceOpener:$B}}function sV(e){nV.add(e)}function cV(e){eV=e,aV()}function lV(e){tV.add(e)}function uV(){rV.acknowledge(),aV()}function dV(e){QB=e,aV()}function fV(e){$B=e}function pV(e){ZB=e,Pt(ZB,tV),iV({kind:`status`}),aV()}function mV(e){let t=ce(ZB,e.projectId,e.issueId)?.inFlight===!0;Ie(ZB,e)&&iV({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function hV(e){let t=ee(ZB,e);iV({kind:`investigation-finished`,frame:e,isPatched:t}),t&&aV()}var gV=Os({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function _V(e){let t=L(`ul`,`session-setup-list`);return t.append(...e.map(e=>L(`li`,null,e))),t}function vV(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=bt(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[L(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=L(`div`,`session-setup-plugin`);return t.append(L(`h3`,null,e.name)),e.skills.length>0&&t.append(L(`p`,`session-setup-label`,`Skills`),_V(e.skills)),e.agents.length>0&&t.append(L(`p`,`session-setup-label`,`Agents`),_V(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[_V(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=L(`p`,`session-setup-hook`);return t.append(L(`span`,null,e.event),L(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>L(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[_V(t.skills)]:[]),n(`Agents`,t.agents.length>0?[_V(t.agents)]:[])}function yV(e){let t=L(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=L(`div`,`session-setup-sections`);gV.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function bV(e){let t=gV.settleResponse(e);if(!t)return;if(!e.ok||!e.setup){t.status.textContent=e.error||`Could not read session setup`;return}let n=t.parts.sections;vV(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function xV(e){return{skipPerms:e.skipPerms??e.dangerouslySkipPermissions??!1,saneYolo:e.saneYolo===!0,worktree:e.worktree??e.isWorktree??!1,workspace:e.workspace??e.isWorkspace??!1,remoteWorkspace:e.remoteWorkspace??null,guarded:e.guarded??e.isGuarded??!1,guardrailsReleased:e.guardrailsReleased??e.isGuardrailsReleased??!1,ephemeral:e.ephemeral===!0,ownerId:e.ownerId??null,path:e.path,stateSince:e.stateSince,taskTitle:typeof e.taskTitle==`string`?e.taskTitle:null,taskTitleIsCustom:e.taskTitleIsCustom===!0}}var SV={maxConcurrentInvestigations:Math.ceil,minUsersToInvestigate:Math.ceil,userEscalationThreshold:Math.ceil,trafficSpikeMinUsers:Math.ceil,trafficSpikeBaselineDays:Math.floor};[...Object.entries(SV).map(([e,t])=>({path:[`posthog`,e],min:1,round:t}))];var CV=Object.freeze([`auto`,`calculate`,`display`]),wV=Object.freeze([`codex`,`grok`]),TV=Object.freeze([`dailyUsd`,`monthlyUsd`]),X=e=>t({error:`${e} must be a boolean`}).optional(),EV=(e,t=!1)=>{let n=a({error:`${e} must be a string`});return(t?n.transform(e=>e.trim()):n).optional()},DV=e=>e.label?e.label:e.max==null?e.exclusiveMin?`greater than ${e.min}`:`at least ${e.min}`:`between ${e.min} and ${e.max}`,OV=(e,t=zt)=>i({error:`${e} must be ${DV(t)}`}).finite().refine(e=>!t.exclusiveMin||e>t.min,{message:`${e} must be ${DV(t)}`}).refine(e=>t.exclusiveMin||e>=t.min,{message:`${e} must be ${DV(t)}`}).refine(e=>t.max==null||e<=t.max,{message:`${e} must be ${DV(t)}`}).optional(),kV=(e,t)=>OV(e,t).unwrap().int({error:`${e} must be a whole number ${DV(t)}`}).optional(),AV=(e,t)=>i({error:`${e} must be an integer between ${t.min} and ${t.max}`}).int({error:`${e} must be an integer between ${t.min} and ${t.max}`}).min(t.min,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).max(t.max,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).optional(),jV=(e,t)=>u(t,{error:`${e} must be an object`}).nullable().optional(),MV=Object.freeze([`release`,`main`]),NV=Object.freeze([`report`,`fix`]);u({refiner:u({enabled:X(`taskTitle.refiner.enabled`),model:EV(`taskTitle.refiner.model`,!0),minIntervalSeconds:OV(`taskTitle.refiner.minIntervalSeconds`,{min:0}),timeoutSeconds:OV(`taskTitle.refiner.timeoutSeconds`,we)},{error:`taskTitle.refiner must be an object`}).nullable().optional()},{error:`taskTitle must be an object`}).nullable().optional();var PV={enabled:X(`branchGc.enabled`),worktrees:X(`branchGc.worktrees`),prefixes:c(a({error:`branchGc.prefixes must be an array of strings`}).min(1,{error:`branchGc.prefixes entries must be non-empty strings`}),{error:`branchGc.prefixes must be an array of strings`}).optional(),dryRun:X(`branchGc.dryRun`),staleDays:OV(`branchGc.staleDays`,ut),deleteUnmerged:X(`branchGc.deleteUnmerged`),intervalMs:OV(`branchGc.intervalMs`,yt)},FV=u(PV,{error:`branchGc must be an object`});jV(`branchGc`,PV),FV.omit({prefixes:!0,dryRun:!0,worktrees:!0}).nullable().optional(),Object.freeze([`enabled`,`deleteUnmerged`]),Object.freeze([`staleDays`,`intervalMs`]),jV(`postTurnChecks`,{mode:o(NV,{error:`postTurnChecks.mode must be one of report, fix`}).optional()}),jV(`visions`,{enabled:X(`visions.enabled`),autoFix:X(`visions.autoFix`),projects:c(a({error:`visions.projects must be an array of strings`}),{error:`visions.projects must be an array of strings`}).optional(),dispatch:jV(`visions.dispatch`,{enabled:X(`visions.dispatch.enabled`),model:EV(`visions.dispatch.model`,!0),quietMs:kV(`visions.dispatch.quietMs`,oe),cooldownMs:kV(`visions.dispatch.cooldownMs`,Le),maxPerHour:kV(`visions.dispatch.maxPerHour`,Et),activityMaxPerHour:kV(`visions.dispatch.activityMaxPerHour`,Me),dispatchTimeoutSeconds:kV(`visions.dispatch.dispatchTimeoutSeconds`,te)}),intent:jV(`visions.intent`,{threadTtlMs:kV(`visions.intent.threadTtlMs`,le)})}),u({teams:c(a({error:`github.teams must be an array of org/slug strings`}).refine(e=>tt(e)!==null,{message:`github.teams entries must be org/slug with valid GitHub segments`}),{error:`github.teams must be an array of org/slug strings`}).optional()},{error:`github must be an object`}).nullable().optional(),jV(`teamReview`,{enabled:X(`teamReview.enabled`),autoRebaseMyPrs:X(`teamReview.autoRebaseMyPrs`),keepMergeableEnabled:X(`teamReview.keepMergeableEnabled`),mergeQueueEnabled:X(`teamReview.mergeQueueEnabled`),keepMergeableTimeoutMinutes:AV(`teamReview.keepMergeableTimeoutMinutes`,Qe),org:EV(`teamReview.org`,!0),team:EV(`teamReview.team`,!0),skill:EV(`teamReview.skill`,!0),reReviewAfterHours:OV(`teamReview.reReviewAfterHours`),skipIdleAfterDays:OV(`teamReview.skipIdleAfterDays`)}),jV(`benchmarks`,{enabled:X(`benchmarks.enabled`)}),jV(`coherence`,{enabled:X(`coherence.enabled`)});var IV={intervalMinutes:C,maxConcurrentInvestigations:ht,investigationTimeoutSeconds:ve,fixTimeoutSeconds:E,minUsersToInvestigate:m,userEscalationThreshold:Ae,recurrenceWindowDays:pt,transientRecurrenceLimit:ae,trafficSpikeMultiplier:k,trafficSpikeMinUsers:ye,trafficSpikeCooldownMinutes:he,trafficSpikeBaselineDays:pe};jV(`posthog`,{enabled:X(`posthog.enabled`),recurrenceDedupe:X(`posthog.recurrenceDedupe`),trafficSpikeEnabled:X(`posthog.trafficSpikeEnabled`),autoFix:X(`posthog.autoFix`),host:EV(`posthog.host`,!0).refine(e=>e==null||!e||/^https?:\/\//i.test(e),{message:`posthog.host must be an http(s) URL`}),apiKey:EV(`posthog.apiKey`,!0),repoPath:EV(`posthog.repoPath`,!0),projects:r([l(`all`),c(i({error:`posthog.projects must be "all" or an array of positive integer project ids`}).int({error:`posthog.projects must be "all" or an array of positive integer project ids`}).positive({error:`posthog.projects must be "all" or an array of positive integer project ids`}),{error:`posthog.projects must be "all" or an array of positive integer project ids`})],{error:`posthog.projects must be "all" or an array of positive integer project ids`}).optional(),projectMap:n(a(),e(),{error:`posthog.projectMap must be an object`}).optional(),...Object.fromEntries(Object.entries(IV).map(([e,t])=>[e,Object.hasOwn(SV,e)?kV(`posthog.${e}`,t):OV(`posthog.${e}`,t)]))}),`${CV.join(`, `)}`,Object.fromEntries(wV.map(e=>[e,X(`usage.vendors.${e}`)])),Object.fromEntries(TV.map(e=>[e,i({error:`usage.budget.${e} must be a positive number or null`}).positive({error:`usage.budget.${e} must be a positive number or null`}).nullable().optional()])),jV(`telegram`,{botToken:EV(`telegram.botToken`,!0),chatId:EV(`telegram.chatId`,!0)}),u({enabled:X(`ingest.enabled`)},{error:`ingest must be an object`}).passthrough().optional(),u({enabled:X(`trace.enabled`)},{error:`trace must be an object`}).optional(),u({enabled:X(`planReview.enabled`)},{error:`planReview must be an object`}).optional();var LV=e=>c(a({error:`${e} must be an array of paths`}).trim().min(1,{error:`${e} must be an array of paths`}),{error:`${e} must be an array of paths`}).optional(),RV={unguardedRepos:LV(`guardrails.unguardedRepos`),blockedPaths:LV(`guardrails.blockedPaths`),unreadablePaths:LV(`guardrails.unreadablePaths`)};u(RV,{error:`guardrails must be an object`}).passthrough().optional();var zV={enabled:X(`telemetry.enabled`)};u(zV,{error:`telemetry must be an object`}).strict().optional(),u(zV,{error:`telemetry must be an object`}).passthrough().optional();var BV={scope:`browser`,access:`editable`,takesEffect:`now`},VV={scope:`browser`,access:`advanced`,takesEffect:`now`},Z={scope:`machine`,access:`editable`,takesEffect:`now`},HV={scope:`machine`,access:`editable`,takesEffect:`new-sessions`},UV={scope:`machine`,access:`readout`,takesEffect:`now`},Q={scope:`machine`,access:`file-only`},WV=1e3,GV=60,KV=60,qV=WV*GV,JV=qV*KV,YV=JV*24,XV={label:`investigations`,storedPerDisplay:1},ZV={label:`sessions`,storedPerDisplay:1},QV={label:`recurrences`,storedPerDisplay:1},$V={label:`actions`,storedPerDisplay:1},eH={label:`seconds`,storedPerDisplay:1},tH={label:`minutes`,storedPerDisplay:1},nH={label:`hours`,storedPerDisplay:1},rH={label:`days`,storedPerDisplay:1},iH={label:`seconds`,storedPerDisplay:WV,storedLabel:`ms`},aH={label:`minutes`,storedPerDisplay:qV,storedLabel:`ms`},oH={label:`minutes`,storedPerDisplay:GV,storedLabel:`seconds`},sH={label:`hours`,storedPerDisplay:JV,storedLabel:`ms`},cH={label:`hours`,storedPerDisplay:KV,storedLabel:`minutes`},lH={label:`days`,storedPerDisplay:YV,storedLabel:`ms`},uH={label:`USD`,storedPerDisplay:1},dH={label:`users`,storedPerDisplay:1},fH={label:`reviews per hour`,storedPerDisplay:1},pH={label:`times`,storedPerDisplay:1},$=`A tuning knob kept out of the Settings view; the default suits almost every install.`,mH=`A diagnostic switch kept out of the Settings view; change it in config.json while investigating.`,hH=`Changes how the server process or its worktrees behave, so it is set in config.json with a restart or new sessions in mind.`,gH=`A structured value with no dashboard control; edit it in config.json.`,_H=`Never editable from the dashboard by rule; edit it in config.json.`;function vH(e){return e.map(e=>({value:e,label:e[0].toUpperCase()+e.slice(1)}))}var yH=Object.freeze({"machine-terminal":{title:`Terminal`,description:`Terminal behavior shared by dashboard clients.`},"machine-detection-sessions":{title:`Detection and sessions`,description:`Config-file-only detection, timing, worktree and process settings.`},"lanes-ingest":{title:`Ingest`,description:`The machine-context sources behind Visions.`}}),bH=Object.freeze([{id:`browser-appearance`,level:`browser`,title:`Appearance`,description:`How this browser draws the dashboard.`,legacyIds:[`browser-flying-animals`,`animals`,`flying-animals`],settings:[{id:`theme`,path:`pref:themeId`,title:`Theme`,description:`Color scheme for the dashboard.`,control:`select`,optionsFrom:`themes`,keywords:[`color`,`palette`],defaultValue:`phyrexian`,...BV},{id:`session-usage-chips`,path:`pref:sessionUsageChips`,title:`Show usage on session cards`,description:`Shows each card's transcript token count and CLI-reported cost when available, otherwise a calculated API list-price estimate.`,control:`toggle`,keywords:[`usage`,`cost`,`tokens`,`card`,`price`],defaultValue:!1,...BV},{id:`phone-arrow-pad`,path:`pref:phoneArrowPad`,title:`Swipe arrow pad on phone (experimental)`,description:`Replace the four arrow keys above the phone keyboard with one pad: swipe on it to send arrow keys, one per short drag.`,control:`toggle`,keywords:[`experimental`,`mobile`,`keys`,`arrows`,`swipe`,`gesture`],defaultValue:!1,...BV},{id:`flying-animals`,path:`pref:flyingAnimalsEnabled`,title:`Flying animals`,description:`Show animated animals flying across the dashboard.`,control:`toggle`,keywords:[`animation`,`motion`,`animals`],defaultValue:!1,...BV},{id:`animals-min-gap`,path:`pref:flyingAnimalsMinGapSeconds`,title:`Time between flights: minimum`,description:`Shortest pause between flights.`,control:`number`,integer:!1,step:.1,range:It,unit:eH,maximumSettingId:`animals-max-gap`,keywords:[`animals`,`frequency`],defaultValue:ct.flyingAnimalsMinGapSeconds,...VV},{id:`animals-max-gap`,path:`pref:flyingAnimalsMaxGapSeconds`,title:`Time between flights: maximum`,description:`Longest pause between flights.`,control:`number`,integer:!1,step:.1,range:It,unit:eH,keywords:[`animals`,`frequency`],defaultValue:ct.flyingAnimalsMaxGapSeconds,...VV},{id:`animals-min-duration`,path:`pref:flyingAnimalsMinDurationSeconds`,title:`Flight duration: minimum`,description:`Shortest flight, for faster animals.`,control:`number`,integer:!1,step:.1,range:qe,unit:eH,maximumSettingId:`animals-max-duration`,keywords:[`animals`,`speed`],defaultValue:ct.flyingAnimalsMinDurationSeconds,...VV},{id:`animals-max-duration`,path:`pref:flyingAnimalsMaxDurationSeconds`,title:`Flight duration: maximum`,description:`Longest flight, for slower animals.`,control:`number`,integer:!1,step:.1,range:qe,unit:eH,keywords:[`animals`,`speed`],defaultValue:ct.flyingAnimalsMaxDurationSeconds,...VV},{id:`animals-scale`,path:`pref:flyingAnimalsScale`,title:`Size multiplier`,description:`Scale applied on top of the viewport size.`,control:`number`,integer:!1,step:.1,range:Gt,unit:pH,keywords:[`animals`,`size`],defaultValue:ct.flyingAnimalsScale,...VV},{id:`animals-on-phone`,path:`pref:flyingAnimalsOnPhone`,title:`Show on phone layout`,description:`Allow flights on the phone layout.`,control:`toggle`,keywords:[`animals`,`mobile`],defaultValue:ct.flyingAnimalsOnPhone,...VV}]},{id:`browser-notifications`,level:`browser`,title:`Notifications`,description:`How this browser, and the Telegram bot shared by every lane, get your attention.`,settings:[{id:`alert-sounds-enabled`,path:`pref:soundEnabled`,title:`Alert sounds`,legacyIds:[{sectionId:`browser-appearance`,settingId:`alert-sounds-enabled`}],description:`Play sounds when a session needs attention and when a merge celebration plays. The same switch as the note button in the desktop header.`,control:`toggle`,keywords:[`audio`,`mute`,`sound`,`notification`],defaultValue:!0,...BV},{id:`alert-sound`,path:`pref:soundId`,title:`Alert sound`,legacyIds:[{sectionId:`browser-appearance`,settingId:`alert-sound`}],description:`Sound played when a session needs attention. Your own .ogg, .mp3, .wav, .m4a or .webm files dropped into the sounds folder of the Glimmervoid home (~/.glimmervoid/sounds/, or $GLIMMERVOID_HOME/sounds/) are listed after the built-in sounds. Glimmervoid never creates that folder, so make it yourself; new files show up the next time Settings opens.`,control:`select`,optionsFrom:`sounds`,keywords:[`audio`,`notification`,`custom`],defaultValue:`chime`,...BV},{id:`desktop-notifications`,path:`pref:notificationsEnabled`,title:`Desktop notifications`,legacyIds:[{sectionId:`browser-appearance`,settingId:`desktop-notifications`}],description:`Raise a browser notification when a session needs attention while this dashboard is in the background.`,control:`toggle`,keywords:[`browser`,`attention`],defaultValue:!0,...BV}]},{id:`machine-telegram`,level:`machine`,parent:`browser-notifications`,title:`Telegram`,description:`One bot shared by session, PR review and PostHog notifications.`,legacyIds:[`telegram`,`notifications`],settings:[{id:`telegram-bot-token`,path:`telegram.botToken`,title:`Bot token`,description:`Credential used by the shared Telegram bot. Create a bot by messaging @BotFather in Telegram and sending /newbot; it replies with this token. When GLIMMERVOID_TELEGRAM_BOT_TOKEN supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`api`],defaultValue:``,...Z},{id:`telegram-chat-id`,path:`telegram.chatId`,title:`Chat id`,description:`Destination chat for enabled Telegram lanes. Send your bot any message, then open https://api.telegram.org/bot<token>/getUpdates in a browser and copy the number under message.chat.id.`,control:`text`,keywords:[`destination`,`channel`],defaultValue:``,...Z},{id:`telegram-session-notifications`,path:`telegramNotifications`,title:`Send session notifications`,description:`Send session completion, input and failure alerts when no dashboard is open. Unacknowledged alerts also escalate after the phone escalation delay while a dashboard remains open.`,control:`toggle`,keywords:[`phone`,`off dashboard`,`test`],defaultValue:!1,status:`telegram-delivery`,...Z}]},{id:`machine-sessions`,level:`machine`,title:`Sessions`,description:`How sessions start, where projects are found, and what the dashboard shows for them.`,legacyIds:[`machine-general`,`general`,`machine-repositories`,`repos`,`repositories`],settings:[{id:`auto-resume`,path:`autoResume`,title:`Auto-resume sessions on startup`,description:`Resume conversations that were live when Glimmervoid last shut down or crashed, and tell sessions that were mid-turn, or had a background agent, monitor or scheduled wakeup in flight, to continue.`,control:`toggle`,keywords:[`startup`,`conversation`],defaultValue:!0,...Z},{id:`conversation-view`,path:`conversationView`,title:`Conversation view (experimental)`,description:`Let each Claude Code and Codex session turn on a Conversation face from its card menu, which renders the transcript as messages, approvals and a composer. Sessions stay on the terminal until you turn it on for them. A Claude Code session started while this is on can answer its permission prompts and questions there. A Codex session connects on its next start, through a local app-server so approvals can be answered from the dashboard; guarded Codex sessions and those that bypass Codex hook trust keep the terminal only.`,control:`toggle`,keywords:[`experimental`,`transcript`,`chat`,`codex`,`claude`],defaultValue:!1,...Z},{id:`zen-view`,path:`zenView`,title:`Zen view (experimental)`,description:`Add a Zen tab that shows no terminal until a session needs you, then shows only that session and what it needs.`,control:`toggle`,keywords:[`experimental`,`calm`,`focus`,`attention`,`needs you`],defaultValue:!1,...Z},{id:`tab-order`,path:`viewTabOrder`,title:`Tab order`,description:`The order of the dashboard tabs in every browser: the header on desktop and the More menu on a phone. You can also drag a tab in the desktop header.`,control:`tab-order`,keywords:[`tabs`,`order`,`rearrange`,`reorder`,`header`,`more`,`menu`],defaultValue:[],...Z},{id:`remote-sessions`,path:`remoteSessions`,title:`Remote Coder sessions (experimental)`,description:`Offer the Coder environments in config.json when adding a session, so the session runs in its own Coder workspace instead of on this machine. Off refuses new remote sessions; ones already running keep working until closed.`,control:`toggle`,keywords:[`experimental`,`coder`,`remote`,`workspace`,`cloud`],defaultValue:!1,...Z},{id:`streamer-mode`,path:`streamerMode`,title:`Streamer mode`,description:`Hide sensitive details in the dashboard while screen sharing or streaming.`,control:`toggle`,keywords:[`streaming`,`screen share`,`privacy`],defaultValue:!1,...Z},{id:`repository-roots`,path:`repoRoots`,title:`Repository roots`,description:`Directories scanned for projects when adding sessions.`,control:`list`,keywords:[`folders`,`project discovery`],defaultValue:[],listPlaceholder:`Repository root path`,listEmptyText:`No repository roots configured.`,...Z},{id:`custom-agents`,path:`status:custom-agents`,title:`Custom agents`,description:`Extra agent CLIs a session can be spawned with, declared under customAgents in config.json.`,control:`readonly`,keywords:[`adapters`,`cli`],status:`custom-agents`,...UV},{id:`agent-logins`,path:`status:agent-logins`,title:`Agent logins`,description:`How Claude Code and Codex sign in inside a Coder workspace. Each uses the login already on this machine; Connect signs one in for Glimmervoid alone when there is none.`,control:`readonly`,keywords:[`claude`,`codex`,`sign in`,`login`,`coder`,`remote`],status:`agent-logins`,...UV},{id:`remote-setup`,path:`status:remote-setup`,title:`Remote host setup`,description:`Start a session that walks you through running Glimmervoid on another Linux machine you reach by ssh, as a service you open from your laptop and phone.`,control:`readonly`,keywords:[`remote`,`ssh`,`server`,`devbox`,`tailscale`,`pair`,`host`],status:`remote-setup`,...UV}]},{id:`machine-guardrails`,level:`machine`,title:`Guardrails and unattended`,description:`What a guarded session may touch, and which unattended actions automated work may take. Claude Code sessions on Linux and macOS write anywhere this account can, except credentials, Glimmervoid's own state and the blocked folders here.`,legacyIds:[`lanes-unattended`,`unattended`],settings:[{id:`skip-permissions-by-default`,path:`skipPermissionsByDefault`,title:`Skip permission prompts by default`,description:`Start sessions whose project sets no permission choice with the agent CLI permission bypass flag.`,control:`toggle`,keywords:[`permissions`,`yolo`,`dangerously`],danger:!0,warning:`Enabling this control lets agents edit files and run shell commands without asking, and restarts running sessions that inherit it.`,defaultValue:!1,...Z},{id:`sane-yolo`,path:`saneYolo`,title:`Sane YOLO`,description:`Block catastrophic commands in sessions that skip permission prompts when the cc-safety-net executable is available and trusted hooks are installed. Missing or untrusted hooks leave a session unprotected.`,control:`toggle`,keywords:[`permissions`,`yolo`,`safety`],defaultValue:!0,...HV},{id:`rtk-compression`,path:`rtk`,title:`rtk output compression`,description:`Compress Bash output with the rtk executable.`,control:`toggle`,keywords:[`bash`,`tokens`],danger:!0,status:`rtk-install`,warning:`Enabling this control permits Glimmervoid to install the pinned rtk executable automatically.`,defaultValue:!1,...HV},{id:`post-turn-checks-mode`,path:`postTurnChecks.mode`,title:`Post-turn checks mode`,description:`Default mode for post-turn checks. Project and individual rule modes override it, so Report can still allow file fixes.`,control:`select`,options:vH(NV),keywords:[`quality`,`fixes`],defaultValue:`report`,...Z},{id:`branch-gc-delete-unmerged`,path:`branchGc.deleteUnmerged`,title:`Delete unmerged branches`,description:`Also delete stale remote branches with no merge proof. Off keeps every unmerged branch.`,control:`toggle`,keywords:[`git`,`cleanup`,`orphan`],danger:!0,warning:`Enabling this control lets branch cleanup delete stale remote branches without merge proof.`,defaultValue:!1,...Z},{id:`guardrails-unguarded-repos`,path:`guardrails.unguardedRepos`,title:`Unguarded repositories`,description:`Folders whose sessions run without guardrails. A session started in one of these folders, or below it, is not guarded.`,control:`list`,keywords:[`guardrails`,`opt out`,`dotfiles`],danger:!0,warning:`A session without guardrails can read credentials and write anywhere this account can.`,defaultValue:[],listPlaceholder:`Folder path`,listEmptyText:`Every repository is guarded.`,...HV},{id:`guardrails-blocked-paths`,path:`guardrails.blockedPaths`,title:`Blocked folders`,description:`Extra folders and files a guarded session cannot write, on top of credentials and Glimmervoid's own state. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`block`,`protect`],defaultValue:[],listPlaceholder:`~/folder`,listEmptyText:`Only the built-in list is blocked.`,...HV},{id:`guardrails-unreadable-paths`,path:`guardrails.unreadablePaths`,title:`Unreadable folders`,description:`Extra folders and files a guarded session cannot read, on top of the built-in credential list. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`secrets`,`credentials`],defaultValue:[],listPlaceholder:`~/folder`,listEmptyText:`Only the built-in credential list is unreadable.`,...HV}]},{id:`machine-updates`,level:`machine`,title:`Updates`,description:`See which Glimmervoid version is running, which one is newest, and update in one step.`,legacyIds:[`updates`],settings:[{id:`update-actions`,path:`status:update-actions`,title:`Status and actions`,legacyIds:[`update-summary`,`update-installed`,`update-latest`,`update-last-checked`].map(e=>({sectionId:`machine-updates`,settingId:e})),description:`Whether this install is up to date, the running and newest versions, the last check, and the update and restart actions.`,control:`readonly`,keywords:[`version`,`available`,`current`,`check`,`restart`,`commit`,`installed`,`release`,`failure`],status:`update-actions`,...UV},{id:`update-channel`,path:`updateChannel`,title:`Channel`,description:`Track tagged releases or the upstream of the checked-out branch.`,control:`select`,options:vH(MV),keywords:[`release`,`branch`],defaultValue:`release`,...Z},{id:`check-updates`,path:`checkForUpdates`,title:`Check for updates automatically`,description:`Check for a newer Glimmervoid at launch, while a dashboard is connected, and when this page opens.`,control:`toggle`,keywords:[`release`,`github`],defaultValue:!0,...Z}]},{id:`machine-usage`,level:`machine`,title:`Usage`,description:`Local transcript accounting and estimated-cost budgets.`,legacyIds:[`usage`],settings:[{id:`usage-enabled`,path:`usage.enabled`,title:`Track token usage`,description:`Read local CLI transcripts and roll them into the Usage view and session chips.`,control:`toggle`,keywords:[`tokens`,`cost`],defaultValue:!0,status:`usage-last-report`,...Z},{id:`usage-retain-days`,path:`usage.retainDays`,title:`Retain transcript detail`,description:`How long live transcript detail stays available. A monthly budget keeps detail from the start of the current month when that is longer.`,control:`number`,range:Pe,unit:rH,keywords:[`history`,`retention`],defaultValue:90,...Z},{id:`usage-daily-budget`,path:`usage.budget.dailyUsd`,title:`Daily budget`,description:`Estimated daily spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:qt,unit:uH,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01,...Z},{id:`usage-monthly-budget`,path:`usage.budget.monthlyUsd`,title:`Monthly budget`,description:`Estimated monthly spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:qt,unit:uH,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01,...Z}]},{id:`lanes-visions`,level:`lanes`,title:`Visions`,description:`Editor-buffer findings, bounded model comments, and the machine-context ingest behind them.`,legacyIds:[`lanes`,`visions`,`lanes-ingest`,`ingest`],settings:[{id:`visions-enabled`,path:`visions.enabled`,title:`Enable Visions`,description:`Set up supported editors detected on this machine, then show their buffer findings in the Visions view.`,control:`toggle`,keywords:[`editor`,`findings`,`lsp`],defaultValue:!1,...Z},{id:`visions-dispatch-enabled`,path:`visions.dispatch.enabled`,title:`Enable model comments`,description:`Start bounded review sessions for local editor buffers.`,control:`toggle`,keywords:[`review`,`dispatch`],defaultValue:!1,...Z},{id:`visions-max-per-hour`,path:`visions.dispatch.maxPerHour`,title:`Max per hour`,description:`Maximum review sessions dispatched per hour. One slot is reserved for edit reviews; activity-driven reviews take the rest, up to the activity cap set by visions.dispatch.activityMaxPerHour.`,control:`number`,range:zt,unit:fH,keywords:[`rate limit`,`reviews`],defaultValue:6,...Z},{id:`visions-model`,path:`visions.dispatch.model`,title:`Model override`,description:`Leave blank to use the opus model alias.`,control:`text`,keywords:[`claude`,`override`],defaultValue:``,...Z},{id:`visions-projects`,path:`visions.projects`,title:`Projects`,description:`Clear every selection, including unavailable projects, to accept buffers from every configured project.`,control:`projects`,keywords:[`repositories`,`filter`],defaultValue:[],...Z},{id:`visions-auto-fix`,path:`visions.autoFix`,title:`Apply tier 1 fixes`,description:`Allow Visions to edit eligible open Markdown buffers, including inactive buffers, without asking.`,control:`toggle`,keywords:[`automatic`,`edits`],danger:!0,warning:`Enabling this control lets Visions edit eligible buffers without a carbon unit present.`,defaultValue:!1,...Z},{id:`ingest-enabled`,path:`ingest.enabled`,title:`Enable machine context ingest`,description:`Enable the local activity feed behind Visions. Turning Visions on enables ingest unless ingest.enabled is explicitly false.`,control:`toggle`,keywords:[`events`,`activity`,`ingest`],defaultValue:!1,...Z}]},{id:`lanes-posthog`,level:`lanes`,title:`PostHog`,description:`Error monitoring, investigations and traffic-spike alerts.`,legacyIds:[`posthog`],settings:[{id:`posthog-enabled`,path:`posthog.enabled`,title:`Enable PostHog monitoring`,description:`Poll PostHog error tracking and investigate issues that move.`,control:`toggle`,keywords:[`errors`,`monitoring`],defaultValue:!1,...Z},{id:`posthog-host`,path:`posthog.host`,title:`Host`,description:`PostHog cloud or self-hosted HTTP URL.`,control:`text`,keywords:[`url`,`server`],defaultValue:`https://us.posthog.com`,...Z},{id:`posthog-api-key`,path:`posthog.apiKey`,title:`Personal API key`,description:`Credential with read access to PostHog projects. When GLIMMERVOID_POSTHOG_API_KEY supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`token`],defaultValue:``,...Z},{id:`posthog-projects`,path:`posthog.projects`,title:`Projects`,description:`PostHog project ids to monitor. config.json holds "all" or an array of ids, and an empty array monitors no project. In Settings that empty array shows as none, and an empty list saves "all".`,control:`list`,keywords:[`project ids`,`filter`],defaultValue:`all`,valueKind:`posthog-projects`,listPlaceholder:`Project id`,listEmptyText:`Every project the key can read.`,...Z},{id:`posthog-interval`,path:`posthog.intervalMinutes`,title:`Poll interval`,description:`Delay between PostHog polling passes.`,control:`number`,integer:!1,step:`any`,range:zt,unit:tH,keywords:[`refresh`,`schedule`],defaultValue:15,...Z},{id:`posthog-max-investigations`,path:`posthog.maxConcurrentInvestigations`,title:`Max concurrent investigations`,description:`Maximum investigation sessions running together.`,control:`number`,range:zt,unit:XV,keywords:[`parallel`,`workers`],defaultValue:2,...Z},{id:`posthog-min-users`,path:`posthog.minUsersToInvestigate`,title:`Min users to investigate`,description:`Minimum affected users for a new issue investigation. Regressions, worsening issues and eligible error spikes bypass this minimum.`,control:`number`,range:zt,unit:dH,keywords:[`threshold`,`affected`],defaultValue:1,...Z},{id:`posthog-traffic-enabled`,path:`posthog.trafficSpikeEnabled`,title:`Traffic spike alerts`,description:`Ping when recent unique users exceed a project baseline.`,control:`toggle`,keywords:[`analytics`,`alert`],defaultValue:!0,...Z},{id:`posthog-auto-fix`,path:`posthog.autoFix`,title:`Attempt fixes for major issues`,description:`Allow an isolated agent to fix an issue, push a branch and open a pull request.`,control:`toggle`,keywords:[`automatic`,`pull request`],danger:!0,warning:`Enabling this control lets PostHog fixes commit, push and open pull requests automatically.`,defaultValue:!1,...Z}]},{id:`lanes-team-review`,level:`lanes`,title:`Team review`,description:`Draft reviews of teammates' pull requests for you to post from the Reviews tab.`,legacyIds:[`team-review`,`reviews`],settings:[{id:`team-review-enabled`,path:`teamReview.enabled`,title:`Enable team review`,description:`Poll open pull requests from the team and draft a review of each one. Nothing is posted until you choose Approve or Comment.`,control:`toggle`,keywords:[`pull requests`,`github`],defaultValue:!1,...Z},{id:`github-teams`,path:`github.teams`,title:`GitHub teams`,description:`Teams to search for review requests and members, one org/slug per entry. Leave empty to fall back to the legacy teamReview.org and teamReview.team keys in config.json.`,control:`list`,keywords:[`github`,`teams`,`review requests`],defaultValue:[],listPlaceholder:`org/team-slug`,listEmptyText:`No GitHub teams configured.`,...Z},{id:`team-review-re-review-after-hours`,path:`teamReview.reReviewAfterHours`,title:`Re-review after`,description:`When a reviewed PR has a new head, review it again after this long since its last review. Re-run review runs it at any time.`,control:`number`,range:zt,unit:nH,keywords:[`review`,`delay`],defaultValue:24,integer:!1,step:.5,...Z},{id:`team-review-skip-idle-after-days`,path:`teamReview.skipIdleAfterDays`,title:`Skip PRs idle for`,description:`Leave pull requests without GitHub activity for this long out of automatic review.`,control:`number`,range:zt,unit:rH,keywords:[`idle`,`activity`],defaultValue:14,integer:!1,step:.5,...Z},{id:`team-review-skill`,path:`teamReview.skill`,title:`Review skill`,description:`Name of a Claude Code skill installed for the review agent, for example your own PR review skill. Leave empty to let the agent review with whatever skills it has.`,control:`text`,keywords:[`skill`,`claude code`,`pr review`],defaultValue:``,...Z},{id:`team-review-auto-rebase-my-prs`,path:`teamReview.autoRebaseMyPrs`,title:`Keep my pull requests rebased`,description:`On each poll, rebase your open, non-draft pull requests that are behind their base branch. A pull request with conflicts or checks still running is left alone, and a failed rebase is not retried until you push again.`,control:`toggle`,keywords:[`rebase`,`update branch`,`behind`,`my prs`],danger:!0,warning:`Enabling this control rewrites your pull request branches on GitHub. Pull before you push from a local checkout of one.`,defaultValue:!1,...Z},{id:`team-review-keep-mergeable-enabled`,path:`teamReview.keepMergeableEnabled`,title:`Keep mergeable`,description:`Offer Keep mergeable on your pull requests: a guarded agent repairs conflicts and failing checks and pushes the repair. Off hides the control and starts no repair; the pull requests you chose stay chosen for when you turn it back on.`,control:`toggle`,keywords:[`repair`,`conflicts`,`my prs`],defaultValue:!0,...Z},{id:`team-review-keep-mergeable-timeout`,path:`teamReview.keepMergeableTimeoutMinutes`,title:`Keep mergeable deadline`,description:`Longest a Keep mergeable repair session may run before it is stopped and nothing is pushed.`,control:`number`,range:Qe,unit:tH,keywords:[`timeout`,`repair`],defaultValue:30,...Z},{id:`team-review-merge-queue-enabled`,path:`teamReview.mergeQueueEnabled`,title:`Merge when ready`,description:`Offer Merge when ready on your pull requests: queued pull requests are rebased when behind and merged once ready, one per repository per poll. Off hides the control and merges nothing; the queue is kept for when you turn it back on.`,control:`toggle`,keywords:[`merge queue`,`auto merge`,`my prs`],defaultValue:!0,...Z}]},{id:`lanes-workflows`,level:`lanes`,title:`Workflows`,description:`Rules that act on pull request events in the repositories you choose.`,legacyIds:[`workflows`],settings:[{id:`workflows-enabled`,path:`workflows.enabled`,title:`Run workflows`,description:`Poll the repositories your enabled rules watch and run their actions. Off stops polling and every action, whatever each rule says.`,control:`toggle`,keywords:[`pull requests`,`automation`,`master switch`],defaultValue:!0,...Z},{id:`workflows-max-concurrent-sessions`,path:`workflows.maxConcurrentSessions`,title:`Concurrent agent sessions`,description:`Most workflow agent sessions running at once. Up to twenty later spawns wait for a free slot; additional spawns are dropped and logged.`,control:`number`,range:ze,unit:ZV,keywords:[`parallel`,`spawn`],defaultValue:2,...Z},{id:`workflows-rules`,path:`status:workflow-rules`,title:`Workflow rules`,description:`Each rule watches repositories for one pull request event (opened, checks-failed, review-requested, approved, commented or merged), narrows it by author, labels, base branch, your own pull requests or a review request to your team, and then notifies you, labels or comments on the pull request, or starts a guarded agent session that pushes nothing. Rules start disabled. Turn each rule on or off here; everything else about a rule is set in config.json under workflows.rules.`,control:`readonly`,keywords:[`pull requests`,`automation`,`github`,`rules`],status:`workflows`,...UV}]},{id:`lanes-benchmarks`,level:`lanes`,title:`Benchmarks`,description:`Compare agent setups on frozen cases from the suites in the benchmarks folder of the Glimmervoid home.`,legacyIds:[`benchmarks`],settings:[{id:`benchmarks-enabled`,path:`benchmarks.enabled`,title:`Enable benchmarks`,description:`Show the Bench tab. Nothing runs until you choose Mine or Run there.`,control:`toggle`,keywords:[`eval`,`arms`,`recall`,`compare`],defaultValue:!1,...Z}]},{id:`lanes-coherence`,level:`lanes`,title:`Coherence (experimental)`,description:`Per-session Coherence hook status and decision journal for agent sessions.`,settings:[{id:`coherence-enabled`,path:`coherence.enabled`,title:`Show session Coherence`,description:`Shows each session's Coherence hook status and decision journal when the repository installed @posthog/coherence 1.8 or newer. Off by default.`,control:`toggle`,keywords:[`experimental`,`coherence`,`journal`,`decisions`],defaultValue:!1,...Z}]},{id:`machine-privacy`,level:`machine`,title:`Privacy`,description:`What Glimmervoid sends about itself.`,legacyIds:[`privacy`,`telemetry`],settings:[{id:`telemetry-enabled`,path:`telemetry.enabled`,title:`Send usage data`,description:`Helps us improve Glimmervoid. Sent under a random install id: version, platform, app starts, daily activity, session starts and ends with agent kind, exit kind and duration, errors as their type, error code and scrubbed stack frames, per session token counts, models and estimated costs from the usage scan, and a salted one-way hash of your Claude and Codex account ids so installs of one account count together. Never prompts, project information, error messages, paths, repository or branch names, objectives, terminal output, emails or names. Delete my data asks for everything sent under this install to be erased and starts a new install id. GLIMMERVOID_TELEMETRY=0, DO_NOT_TRACK=1 or CI=true turn it off regardless.`,control:`toggle`,keywords:[`telemetry`,`analytics`,`tracking`,`opt out`],defaultValue:!0,...Z}]},{id:`browser-shortcuts`,level:`browser`,title:`Shortcuts and about`,description:`Keyboard shortcuts, their reference and build information.`,legacyIds:[`shortcuts`],settings:[{id:`next-attention-key`,path:`pref:nextAttentionKeyCode`,title:`Jump to the next session needing you`,description:`The key held with Cmd on a Mac, or Alt elsewhere, that jumps to the next session needing you. Record a new one by pressing the whole shortcut.`,control:`shortcut-key`,keywords:[`shortcut`,`keyboard`,`hotkey`,`jump`,`next`,`attention`],defaultValue:`KeyJ`,...BV}]}]),xH=Object.freeze([{id:`file-debug-mode`,path:`debugMode`,title:`Debug mode`,group:`machine-sessions`,description:`Show session-card diagnostics for state, transitions and detection signals.`,control:`toggle`,keywords:[`diagnostics`,`state`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:mH,...Q},{id:`file-replay-buffer`,path:`replayBufferKB`,title:`Replay buffer`,group:`machine-terminal`,description:`PTY output retained for clients that reconnect or join late.`,control:`number`,range:de,unit:{label:`KB`,storedPerDisplay:1},keywords:[`history`,`backfill`],defaultValue:512,takesEffect:`new-sessions`,fileOnlyReason:$,...Q},{id:`file-session-memory-reserve`,path:`sessionMemoryReserveMB`,title:`Session memory reserve`,group:`machine-sessions`,description:`Free memory an automatic session start waits for; 0 starts sessions without checking.`,control:`number`,range:Ht,unit:{label:`MB`,storedPerDisplay:1},keywords:[`memory`,`headroom`],defaultValue:600,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-cursor-blink`,path:`cursorBlink`,title:`Cursor blink`,group:`machine-terminal`,description:`Blink the cursor in every terminal.`,control:`toggle`,keywords:[`caret`,`terminal`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-detect-background-agents`,path:`detectBackgroundAgents`,title:`Detect background agents`,group:`machine-detection-sessions`,description:`Hold completion while tracked background work is active.`,control:`toggle`,keywords:[`subagents`,`completion`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:mH,...Q},{id:`file-record-signals`,path:`recordSignals`,title:`Record structural signals`,group:`machine-detection-sessions`,description:`Keep forensic status and hook recordings for each session. Full capture (capture.enabled) records these signals even when this is off.`,control:`toggle`,keywords:[`recordings`,`diagnostics`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:mH,...Q},{id:`file-trace-enabled`,path:`trace.enabled`,title:`Capture session traces`,group:`machine-detection-sessions`,description:`Keep normalized Claude transcript traces for session debugging.`,control:`toggle`,keywords:[`transcripts`,`diagnostics`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:mH,...Q},{id:`file-detect-scheduled-wakeups`,path:`detectScheduledWakeups`,title:`Detect scheduled wakeups`,group:`machine-detection-sessions`,description:`Surface advisory wakeup timing for scheduled sessions.`,control:`toggle`,keywords:[`schedule`,`sleep`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:mH,...Q},{id:`file-worktree-auto-rebase`,path:`worktreeAutoRebase`,title:`Worktree auto-rebase`,group:`machine-detection-sessions`,description:`Rebase eligible session worktrees when the integration branch moves.`,control:`toggle`,keywords:[`git`,`branch`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:hH,...Q},{id:`file-worktree-sync-on-start`,path:`worktreeSyncOnStart`,title:`Worktree sync on start`,group:`machine-detection-sessions`,description:`Fetch origin and fast-forward the local integration branch before a session starts its worktree.`,control:`toggle`,keywords:[`git`,`fetch`,`fast-forward`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:hH,...Q},{id:`file-worktree-rerere`,path:`worktreeRerere`,title:`Worktree rerere`,group:`machine-detection-sessions`,description:`Reuse recorded Git conflict resolutions.`,control:`toggle`,keywords:[`git`,`conflicts`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:hH,...Q},{id:`file-integration-branch`,path:`integrationBranch`,title:`Integration branch`,group:`machine-detection-sessions`,description:`Base branch for session worktrees. Empty = each repo's default branch. Existing sessions are never retargeted.`,control:`text`,nullable:!0,keywords:[`git`,`merge`],defaultValue:null,takesEffect:`new-sessions`,fileOnlyReason:hH,...Q},{id:`file-worktree-root`,path:`worktreeRoot`,title:`Worktree root`,group:`machine-detection-sessions`,description:`Directory that contains session worktrees. Existing worktrees are never relocated.`,control:`text`,keywords:[`git`,`directory`],defaultValue:``,takesEffect:`new-sessions`,fileOnlyReason:hH,...Q},{id:`file-worktree-share`,path:`worktreeShare`,title:`Shared worktree paths`,group:`machine-detection-sessions`,description:`Local paths copied or linked during worktree preparation.`,control:`list`,keywords:[`files`,`context`],defaultValue:[`node_modules`,`.env`,`.env.local`,`.claude`],takesEffect:`new-sessions`,fileOnlyReason:_H,...Q},{id:`file-port`,path:`port`,title:`Local port`,group:`machine-detection-sessions`,description:`Port used by the local dashboard listener.`,control:`number`,range:b,unit:{label:`port`,storedPerDisplay:1},keywords:[`server`,`listener`],defaultValue:3e3,takesEffect:`restart`,fileOnlyReason:_H,...Q},{id:`file-notify-debounce-ms`,path:`notifyDebounceMs`,title:`Notification debounce`,group:`machine-detection-sessions`,description:`Delay used to coalesce notification state changes.`,control:`number`,integer:!1,step:`any`,range:zt,unit:iH,keywords:[`timer`,`alerts`],defaultValue:3e3,takesEffect:`new-sessions`,fileOnlyReason:$,...Q},{id:`file-phone-escalation-ms`,path:`phoneEscalationMs`,title:`Phone escalation delay`,group:`machine-detection-sessions`,description:`Delay before off-dashboard escalation.`,control:`number`,integer:!1,step:`any`,range:zt,unit:aH,keywords:[`timer`,`telegram`],defaultValue:3e5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-post-turn-checks`,path:`postTurnChecks`,title:`Post-turn checks`,group:`machine-detection-sessions`,description:`Deterministic checks run after eligible turns. The global mode is a default; project and individual rule modes can select fixes even when the global mode is report.`,control:`json`,keywords:[`quality`,`fixes`],defaultValue:{enabled:!0,mode:`report`,rules:{trailingWs:!0,finalNewline:!0,bom:!0,slop:!1}},takesEffect:`now`,fileOnlyReason:gH,...Q},{id:`file-branch-gc-enabled`,path:`branchGc.enabled`,title:`Branch cleanup`,group:`machine-detection-sessions`,description:`Enable cleanup of eligible session branches.`,control:`toggle`,keywords:[`git`,`cleanup`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:hH,...Q},{id:`file-branch-gc-worktrees`,path:`branchGc.worktrees`,title:`Local worktree cleanup`,group:`machine-detection-sessions`,description:`Enable cleanup of eligible local worktrees.`,control:`toggle`,keywords:[`git`,`worktree`,`cleanup`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:hH,...Q},{id:`file-branch-gc-prefixes`,path:`branchGc.prefixes`,title:`Branch cleanup prefixes`,group:`machine-detection-sessions`,description:`Branch prefixes that filter both remote branch cleanup and local worktree cleanup.`,control:`list`,keywords:[`git`,`branch`],defaultValue:[`glimmervoid/session/`,`worktree-agent-`],takesEffect:`now`,fileOnlyReason:hH,...Q},{id:`file-branch-gc-dry-run`,path:`branchGc.dryRun`,title:`Branch cleanup dry run`,group:`machine-detection-sessions`,description:`Report planned cleanup without deleting remote branches.`,control:`toggle`,keywords:[`git`,`safety`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:hH,...Q},{id:`file-branch-gc-stale-days`,path:`branchGc.staleDays`,title:`Branch stale days`,group:`machine-detection-sessions`,description:`Age threshold for orphan branch cleanup when unmerged deletion is on.`,control:`number`,integer:!1,step:`any`,range:zt,unit:rH,keywords:[`git`,`retention`],defaultValue:14,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-branch-gc-interval-ms`,path:`branchGc.intervalMs`,title:`Branch cleanup interval`,group:`machine-detection-sessions`,description:`Delay between branch cleanup passes.`,control:`number`,integer:!1,step:`any`,range:zt,unit:sH,keywords:[`git`,`schedule`],defaultValue:216e5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-custom-agents`,path:`customAgents`,title:`Custom agents`,group:`machine-detection-sessions`,description:`Extra agent CLIs a session can be spawned with. The Sessions section lists the declared agents and whether each command resolves.`,control:`json`,keywords:[`adapters`,`cli`],defaultValue:[],takesEffect:`new-sessions`,fileOnlyReason:_H,...Q},{id:`file-task-title-refiner-enabled`,path:`taskTitle.refiner.enabled`,title:`Refine task titles`,group:`machine-detection-sessions`,description:`Keep session card titles useful when prompts change topic by asking a model for a short title.`,control:`toggle`,keywords:[`title`,`refiner`,`card`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-task-title-refiner-model`,path:`taskTitle.refiner.model`,title:`Task title model`,group:`machine-detection-sessions`,description:`Claude model alias the title refiner asks.`,control:`text`,keywords:[`title`,`refiner`,`model`],defaultValue:`haiku`,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-task-title-refiner-min-interval`,path:`taskTitle.refiner.minIntervalSeconds`,title:`Task title refresh interval`,group:`machine-detection-sessions`,description:`Shortest pause between two title refinements of one session.`,control:`number`,integer:!1,step:`any`,range:De,unit:eH,keywords:[`title`,`refiner`,`interval`],defaultValue:60,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-task-title-refiner-timeout`,path:`taskTitle.refiner.timeoutSeconds`,title:`Task title timeout`,group:`machine-detection-sessions`,description:`Maximum time allowed for one title refinement.`,control:`number`,integer:!1,step:`any`,range:we,unit:eH,keywords:[`title`,`refiner`,`deadline`],defaultValue:60,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-codex`,path:`usage.vendors.codex`,title:`Track Codex usage`,group:`machine-usage`,description:`Include local Codex CLI transcripts in usage reports.`,control:`toggle`,keywords:[`openai`,`vendor`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-grok`,path:`usage.vendors.grok`,title:`Track Grok usage`,group:`machine-usage`,description:`Include local Grok CLI transcripts in usage reports.`,control:`toggle`,keywords:[`xai`,`vendor`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-fetch-pricing`,path:`usage.fetchPricing`,title:`Fetch current model prices`,group:`machine-usage`,description:`Load public model prices when usage tracking starts, using a cached table for up to one day. Falls back to cached or bundled prices if the fetch fails; no daily refresh runs while tracking continues.`,control:`toggle`,keywords:[`rates`,`models`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:$,...Q},{id:`file-usage-plan-limits`,path:`usage.planLimits`,title:`Show plan limits`,group:`machine-usage`,description:`Read the Claude plan limit the CLI reports and show it beside usage.`,control:`toggle`,keywords:[`plan`,`limits`,`quota`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-rtk-savings`,path:`usage.rtkSavings`,title:`Estimate rtk savings`,group:`machine-usage`,description:`Estimate the tokens rtk output compression saved and show it in the Usage view.`,control:`toggle`,keywords:[`rtk`,`savings`,`tokens`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-scan-interval`,path:`usage.scanIntervalMinutes`,title:`Scan interval`,group:`machine-usage`,description:`Periodic transcript polling interval. Session activity can also trigger scans between timer ticks.`,control:`number`,range:ie,unit:tH,keywords:[`poll`,`refresh`],defaultValue:5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-warehouse-retain-days`,path:`usage.warehouseRetainDays`,title:`Retain usage history`,group:`machine-usage`,description:`How long the daily usage warehouse keeps rolled-up totals after transcript detail expires.`,control:`number`,range:_.warehouseRetainDays,unit:rH,keywords:[`history`,`warehouse`,`retention`],defaultValue:365,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-session-block-hours`,path:`usage.sessionBlockHours`,title:`Session block length`,group:`machine-usage`,description:`Length of the rolling block the Usage view groups activity into.`,control:`number`,range:_.sessionBlockHours,unit:nH,keywords:[`block`,`window`,`hours`],defaultValue:5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-cost-mode`,path:`usage.costMode`,title:`Cost mode`,group:`machine-usage`,description:`Choose whether recorded costs, calculated costs or both can appear.`,control:`select`,options:vH(CV),keywords:[`pricing`,`estimate`],defaultValue:`auto`,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-usage-extra-projects-dirs`,path:`usage.extraProjectsDirs`,title:`Extra transcript folders`,group:`machine-usage`,description:`Absolute paths of additional Claude projects folders the usage scan reads.`,control:`list`,keywords:[`transcripts`,`folders`,`scan`],defaultValue:[],takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-quiet-delay`,path:`visions.dispatch.quietMs`,title:`Quiet delay`,group:`lanes-visions`,description:`Editor quiet time before a scheduled review. Saves and blank-line boundaries can dispatch immediately, subject to the other review limits.`,control:`number`,range:zt,unit:iH,keywords:[`debounce`,`idle`],defaultValue:3e4,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-cooldown`,path:`visions.dispatch.cooldownMs`,title:`Cooldown`,group:`lanes-visions`,description:`Minimum delay between reviews of the same document. Initial orientation reviews bypass this delay.`,control:`number`,range:zt,unit:aH,keywords:[`rate limit`,`delay`],defaultValue:3e5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-activity-max-per-hour`,path:`visions.dispatch.activityMaxPerHour`,title:`Activity max per hour`,group:`lanes-visions`,description:`Maximum activity-driven reviews dispatched per hour, capped at the overall hourly limit minus one to reserve an edit-review slot.`,control:`number`,range:De,unit:fH,keywords:[`rate limit`,`events`],defaultValue:2,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-dispatch-timeout`,path:`visions.dispatch.dispatchTimeoutSeconds`,title:`Dispatch timeout`,group:`lanes-visions`,description:`Maximum time allowed for one review session.`,control:`number`,range:zt,unit:oH,keywords:[`deadline`,`review`],defaultValue:180,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-visions-intent-thread-ttl`,path:`visions.intent.threadTtlMs`,title:`Intent thread lifetime`,group:`lanes-visions`,description:`How long an intent thread nobody advanced stays live before it retires.`,control:`number`,range:zt,unit:lH,keywords:[`intent`,`decay`,`thread`],defaultValue:2592e5,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-terminal`,path:`ingest.sources.terminal.enabled`,title:`Terminal output source`,group:`lanes-ingest`,description:`Include terminal output in the ingest feed.`,control:`toggle`,keywords:[`pty`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-agent-logs`,path:`ingest.sources.agentLogs.enabled`,title:`Agent logs source`,group:`lanes-ingest`,description:`Include local agent logs in the ingest feed.`,control:`toggle`,keywords:[`transcript`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-git`,path:`ingest.sources.git.enabled`,title:`Git activity source`,group:`lanes-ingest`,description:`Include local Git activity in the ingest feed.`,control:`toggle`,keywords:[`commits`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-fs`,path:`ingest.sources.fs.enabled`,title:`File changes source`,group:`lanes-ingest`,description:`Include watched file changes in the ingest feed.`,control:`toggle`,keywords:[`filesystem`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-shell-history`,path:`ingest.sources.shellHistory.enabled`,title:`Shell history source`,group:`lanes-ingest`,description:`Include local shell history in the ingest feed.`,control:`toggle`,keywords:[`commands`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-ingest-editor`,path:`ingest.sources.editor.enabled`,title:`Editor events source`,group:`lanes-ingest`,description:`Include local editor events in the ingest feed.`,control:`toggle`,keywords:[`buffers`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-investigation-timeout`,path:`posthog.investigationTimeoutSeconds`,title:`Investigation timeout`,group:`lanes-posthog`,description:`Maximum time allowed for one investigation.`,control:`number`,integer:!1,step:`any`,range:zt,unit:oH,keywords:[`deadline`,`session`],defaultValue:900,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-escalation`,path:`posthog.userEscalationThreshold`,title:`Escalation threshold`,group:`lanes-posthog`,description:`Affected-user count that escalates an issue.`,control:`number`,range:zt,unit:dH,keywords:[`threshold`,`severity`],defaultValue:25,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-fix-timeout`,path:`posthog.fixTimeoutSeconds`,title:`Fix timeout`,group:`lanes-posthog`,description:`Maximum time allowed for one fix session.`,control:`number`,integer:!1,step:`any`,range:E,unit:oH,keywords:[`deadline`,`repair`],defaultValue:1800,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-traffic-multiplier`,path:`posthog.trafficSpikeMultiplier`,title:`Spike multiplier`,group:`lanes-posthog`,description:`Baseline multiplier required to classify a traffic spike.`,control:`number`,integer:!1,step:`any`,range:k,unit:pH,keywords:[`baseline`,`ratio`],defaultValue:3,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-traffic-min-users`,path:`posthog.trafficSpikeMinUsers`,title:`Min users to alert`,group:`lanes-posthog`,description:`Minimum recent unique users for an initial traffic-spike alert. Escalation and recovery alerts bypass this minimum.`,control:`number`,range:ye,unit:dH,keywords:[`threshold`,`analytics`],defaultValue:10,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-traffic-cooldown`,path:`posthog.trafficSpikeCooldownMinutes`,title:`Spike cooldown`,group:`lanes-posthog`,description:`Cooldown for new traffic spikes. Escalation and recovery alerts bypass it. Zero removes the time delay; repeated active-spike alerts are still suppressed.`,control:`number`,integer:!1,step:`any`,range:De,unit:cH,keywords:[`silence`,`delay`],defaultValue:360,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-traffic-baseline`,path:`posthog.trafficSpikeBaselineDays`,title:`Baseline window`,group:`lanes-posthog`,description:`Historical window used to calculate normal hourly traffic.`,control:`number`,range:pe,unit:rH,keywords:[`history`,`analytics`],defaultValue:7,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-recurrence-dedupe`,path:`posthog.recurrenceDedupe`,title:`Deduplicate recurring issues`,group:`lanes-posthog`,description:`Treat an issue seen again inside the recurrence window as the same investigation instead of opening a new one.`,control:`toggle`,keywords:[`recurrence`,`dedupe`,`issues`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-recurrence-window-days`,path:`posthog.recurrenceWindowDays`,title:`Recurrence window`,group:`lanes-posthog`,description:`How far back an issue counts as a recurrence of an investigated one.`,control:`number`,integer:!1,step:`any`,range:zt,unit:rH,keywords:[`recurrence`,`window`],defaultValue:7,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-transient-recurrence-limit`,path:`posthog.transientRecurrenceLimit`,title:`Transient recurrence limit`,group:`lanes-posthog`,description:`How many times a transient issue may recur before it is investigated again.`,control:`number`,integer:!1,step:`any`,range:zt,unit:QV,keywords:[`recurrence`,`transient`,`limit`],defaultValue:3,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-repo-path`,path:`posthog.repoPath`,title:`Repository path`,group:`lanes-posthog`,description:`Absolute path of the local checkout investigations read and fixes branch from, for every project the project map does not name.`,control:`text`,keywords:[`repository`,`checkout`,`path`],defaultValue:``,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-posthog-project-map`,path:`posthog.projectMap`,title:`Project map`,group:`lanes-posthog`,description:`PostHog project id to a label: the name shown for that project, and, when it is an absolute path to a checkout, the repository its issues are investigated in.`,control:`json`,keywords:[`projects`,`repositories`,`map`],defaultValue:{},takesEffect:`now`,fileOnlyReason:gH,...Q},{id:`file-team-review-org`,path:`teamReview.org`,title:`GitHub organization (legacy)`,group:`lanes-team-review`,description:`Organization login that owns the team, for example PostHog. Read only when github.teams is empty.`,control:`text`,keywords:[`github`,`owner`,`legacy`],defaultValue:``,takesEffect:`now`,fileOnlyReason:`A legacy key: github.teams names teams as org/slug entries and wins whenever it is set.`,...Q},{id:`file-team-review-team`,path:`teamReview.team`,title:`GitHub team (legacy)`,group:`lanes-team-review`,description:`Team slug whose members and review requests are polled. Read only when github.teams is empty.`,control:`text`,keywords:[`github`,`slug`,`legacy`],defaultValue:``,takesEffect:`now`,fileOnlyReason:`A legacy key: github.teams names teams as org/slug entries and wins whenever it is set.`,...Q},{id:`file-workflows-max-actions-per-poll`,path:`workflows.maxActionsPerPoll`,title:`Actions per poll`,group:`lanes-workflows`,description:`Most actions run in one poll. The rest are dropped and logged.`,control:`number`,range:He,unit:$V,keywords:[`cap`,`rate limit`],defaultValue:20,takesEffect:`now`,fileOnlyReason:$,...Q},{id:`file-workflows-rules`,path:`workflows.rules`,title:`Workflow rule definitions`,group:`lanes-workflows`,description:`The rules the Workflows section switches on and off: each names its repositories, one pull request event, its filters and its actions.`,control:`json`,keywords:[`pull requests`,`automation`,`rules`],defaultValue:[],takesEffect:`now`,fileOnlyReason:`Rule definitions are written in config.json; the Workflows section only switches each rule on or off.`,...Q}]),SH=Object.freeze({sections:bH,fileOnly:xH}),CH=Object.freeze(Object.fromEntries(bH.flatMap(e=>(e.legacyIds??[]).map(t=>[t,e.id])))),wH=Object.freeze(bH.reduce((e,t)=>{for(let n of t.settings)for(let r of n.legacyIds??[])e[r.sectionId]={...e[r.sectionId],[r.settingId]:t.id};return e},{}));function TH(e){let t=[],n=e=>{if(!e||typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};return t.push([e,n]),n},r=n(e);for(let e=t.pop();e;e=t.pop()){let[t,r]=e;for(let[e,i]of Object.entries(t))Object.defineProperty(r,e,{value:n(i),writable:!0,enumerable:!0,configurable:!0})}return r}function EH(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function DH(e,t){let n=t.split(`.`),r=e;for(let e of n.slice(0,-1)){if(!r||typeof r!=`object`)return;r=r[e]}r&&typeof r==`object`&&delete r[n.at(-1)]}function OH(e,t,n){let r=t.split(`.`),i=e;for(let e of r.slice(0,-1))(!i[e]||typeof i[e]!=`object`||Array.isArray(i[e]))&&(i[e]={}),i=i[e];i[r.at(-1)]=TH(n)}function kH(e){return e.flatMap(e=>e.settings)}function AH(e){return e.access===`file-only`||e.control===`readonly`}function jH(e){let t=String(e??``).trim().toLowerCase();if(!t||t===`all`)return`all`;if(t===`none`)return[];let n=t.split(`,`).map(e=>e.trim());return n.every(e=>/^\d+$/.test(e)&&Number.isSafeInteger(Number(e))&&Number(e)>0)?n.map(Number):null}var MH=6;function NH(e,t){return e.control===`number`&&typeof t==`number`?t/(e.unit?.storedPerDisplay??1):e.valueKind===`posthog-projects`?Array.isArray(t)?t.length===0?[`none`]:t.map(String):[]:TH(t)}function PH(e){return e.control===`number`&&(e.unit?.storedPerDisplay??1)!==1}function FH(e){return String(Number(e.toFixed(MH)))}function IH(e,t){let n=NH(e,t);return e.valueKind===`posthog-projects`&&Array.isArray(n)?n.join(`, `)||`all`:typeof n==`number`&&e.unit?`${FH(n)} ${e.unit.label}`:JSON.stringify(n??null)}function LH(e,t){if(e.control===`number`){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=Number(t);if(e.zeroIsNull&&n<=0)return null;let r=n*(e.unit?.storedPerDisplay??1);return e.integer===!1?r:Math.round(r)}if(e.valueKind===`posthog-projects`)return jH(Array.isArray(t)?t.join(`,`):t);if(e.control===`text`||e.control===`password`){let n=String(t??``).trim();return e.nullable&&!n?null:n}return TH(t)}function RH(e){return String(e||``).toLowerCase().match(/[a-z0-9]+/g)||[]}var zH=3,BH=2,VH=1,HH=3,UH=30,WH=16;function GH(e,t){return e===t?zH:e.startsWith(t)?BH:t.length>=HH&&e.includes(t)?VH:0}function KH(e,t,n){let r=0;for(let n of t){let t=Math.max(0,...e.map(e=>GH(e,n)));if(t===0)return 0;r+=t}return r*n}function qH(e){return e.options?.map(e=>e.label).join(`, `)??``}function JH(e){return nU(e.group??``)?.title??``}function YH(e,t,n){let r=KH(RH(e.title),n,1e3),i=KH(RH(e.keywords.join(` `)),n,100),a=KH(t,n,10),o=KH(RH(e.path),n,10),s=KH(RH(qH(e)),n,10),c=KH(RH(e.description),n,1);return r+i+a+o+s+c}function XH(e){return e.section?.title??``}function ZH(e,t){return Number(e.section===null)-Number(t.section===null)}function QH(e,t,n){return[[`title`,e.title],[`keywords`,e.keywords.join(` `)],[`section`,t?.title??JH(e)],[`description`,e.description],[`path`,e.path],[`options`,qH(e)]].flatMap(([e,t])=>{let r=[];for(let e of t.matchAll(/[a-z0-9]+/gi)){let t=e[0].toLowerCase();for(let i of n){if(GH(t,i)===0)continue;let n=e.index+t.indexOf(i);r.push({start:n,end:n+i.length})}}let i=[];for(let e of r.sort((e,t)=>e.start-t.start||e.end-t.end)){let t=i.at(-1);t&&e.start<=t.end?t.end=Math.max(t.end,e.end):i.push({...e})}return i.length?[{field:e,text:t,spans:i}]:[]})}function $H(e,t,n=[]){let r=RH(t).slice(0,WH);if(r.length===0)return[];let i=[];for(let t of e){let e=RH(t.title);for(let n of t.settings){let a=YH(n,e,r);a!==0&&i.push({section:t,setting:n,score:a,matches:QH(n,t,r)})}}for(let e of n){let t=YH(e,RH(JH(e)),r);t!==0&&i.push({section:null,setting:e,score:t,matches:QH(e,null,r)})}return i.sort((e,t)=>t.score-e.score||ZH(e,t)||XH(e).localeCompare(XH(t))||e.setting.title.localeCompare(t.setting.title)).slice(0,UH)}function eU(e,t,n={},r={}){let i=/^#settings\/([^/]+)(?:\/([^/]+))?$/.exec(String(e||``));if(!i)return null;let a,o;try{a=decodeURIComponent(i[1]),o=i[2]?decodeURIComponent(i[2]):null}catch{return null}let s=n[a]||a,c=(o?r[s]?.[o]:void 0)||s,l=t.find(e=>e.id===c);if(!l)return null;let u=o?l.settings.find(e=>e.id===o||e.legacyIds?.some(e=>e.settingId===o&&e.sectionId===s)):null;return o&&!u?null:{sectionId:c,settingId:u?.id||null,hash:`#settings/${c}${u?`/${u.id}`:``}`}}function tU(e){let t=new Map,n=new Map;for(let r of[...kH(e.sections),...e.fileOnly])t.set(r.id,r),n.set(r.path,r);return{byId:t,byPath:n}}tU(SH);function nU(e,t=SH){let n=t.sections.find(t=>t.id===e);return n?{title:n.title,description:n.description}:yH[e]??null}function rU({checked:e=[],stored:t=[],rendered:n=[]}={}){let r=new Set(n),i=[...e];for(let e of t)typeof e==`string`&&e.trim()&&(r.has(e)||i.includes(e)||i.push(e));return i}function iU(e,t){let n=new Set(e.map(e=>e.id)),r=[...new Set(t)].filter(e=>!n.has(e));return[...e,...r.map(e=>({id:e,name:`Unavailable project (${e})`}))]}var aU=new WeakMap,oU=`Configured`,sU=`•`.repeat(12),cU=`Each line must be a positive whole-number PostHog project id, or the one word none.`,lU=3,uU=200,dU=new Set([`customAgents`]),fU=1e-9,pU=`Lanes`,mU=Object.freeze({now:`Applies now`,"new-sessions":`New sessions`,restart:`After restart`}),hU=Object.freeze({browser:`This browser`,machine:`This machine`});function gU(e,t){let n=t.secretSources;if(!n||typeof n!=`object`)return null;let r=n[e.path];return typeof r==`string`?r:null}function _U(e){let t=e.rtkInstall;return t?.status===`installing`?`No rtk binary found. Glimmervoid is installing it into ~/.glimmervoid/bin now.`:e.rtkInstallSupported===!1?`No rtk binary found. Automatic installation is unavailable on this server platform; install a compatible binary manually.`:t?.status===`failed`?`No rtk binary found. The last install attempt failed: ${t.reason||`unknown reason`}. A save can retry after the ten-minute failure cooldown; saves during the cooldown skip installation.`:`No rtk binary found. Saving requests installation into ~/.glimmervoid/bin on supported server platforms, subject to installer eligibility.`}function vU(e){return e.control===`password`}function yU(e){return`${e.path}${oU}`}function bU(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>bU(e,t[n]));if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&bU(e[n],t[n]))}function xU(e){return aU.get(e)||null}function SU(e){return Array.isArray(e)?e.map(e=>String(e)):[]}function CU(e){return e.split(`
173
+ `).map(e=>e.trim()).filter(e=>e!==``)}function wU(e){let t=e.range;if(!t)return null;let n={min:Number(NH(e,t.min))};return t.max!=null&&(n.max=Number(NH(e,t.max))),t.exclusiveMin&&(n.exclusiveMin=!0),n}function TU(e){let t=`Default ${IH(e,e.defaultValue)}`;return PH(e)?`${t}, stored as ${JSON.stringify(e.defaultValue)} ${e.unit?.storedLabel??``}`.trimEnd():t}function EU(e,t){let n=TU(e),r=dU.has(e.path)?void 0:EH(t,e.path);if(r===void 0)return{currentText:null,defaultText:n,jsonFragment:null};let i={};return OH(i,e.path,r),{currentText:`Current ${IH(e,r)}`,defaultText:n,jsonFragment:JSON.stringify(i,null,2)}}function DU(e,t,n){let r=t??e.find(e=>e.id===n.group);if(!r)return nU(n.group??``)?.title??`config.json`;let i=e.find(e=>e.id===r.parent);return i?`${i.title} / ${r.title}`:r.level===`lanes`?`${pU} / ${r.title}`:r.title}function OU(e){let t=/^#settings(?:\?(.*))?$/.exec(String(e??``));if(!t)return null;let n=new URLSearchParams(t[1]??``).get(`q`)??``;return{query:Array.from(n.trim()).slice(0,uU).join(``).trim()}}function kU(e,t){return e.filter(e=>e.parent===t)}function AU(e,t){let n=e.find(e=>e.id===t);return n?n.parent?e.find(e=>e.id===n.parent)??n:n:null}function jU(e){return e.filter(e=>!e.parent)}function MU(e){let t=e.filter(e=>e.level===`lanes`);return[{heading:null,sections:e.filter(e=>e.level!==`lanes`)},{heading:pU,sections:t}].filter(e=>e.sections.length>0)}function NU(e,t,n,r){return r?`hidden`:n.trim()?`search`:t&&AU(e,t)?`section`:`list`}function PU(e,t={}){let n={};for(let r of kH(e)){if(AH(r))continue;if(r.path.startsWith(`pref:`)){let e=r.path.slice(5),i=t.prefs?.[e]??t[r.path];n[r.path]=NH(r,i??r.defaultValue);continue}if(vU(r)){let e=EH(t,yU(r))===!0;n[r.path]=e?sU:``;continue}let e=EH(t,r.path);n[r.path]=NH(r,e??r.defaultValue)}return aU.set(n,TH(t)),n}function FU(e,t,n){let r=kH(e).filter(e=>AH(e)||e.path.startsWith(`pref:`)||gU(e,xU(t)||{})||vU(e)&&n[e.path]===sU?!1:!bU(t[e.path],n[e.path]));if(r.length===0)return{};let i=xU(t)||{},a=(Array.isArray(i.projectChoices)?i.projectChoices:[]).map(e=>e.id).filter(e=>typeof e==`string`),o={},s=new Set;for(let e of r){let[r]=e.path.split(`.`);if(!e.path.includes(`.`)){o[r]=LH(e,n[e.path]);continue}if(!s.has(r)){let e=i[r];o[r]=e&&typeof e==`object`&&!Array.isArray(e)?TH(e):{},s.add(r)}let c=LH(e,n[e.path]);if(e.control===`projects`){let n=t[e.path];c=rU({checked:Array.isArray(c)?c:[],stored:Array.isArray(n)?n:[],rendered:iU(a.map(e=>({id:e,name:e})),Array.isArray(n)?n:[]).map(e=>e.id)})}OH(o,e.path,c)}for(let t of kH(e))vU(t)&&DH(o,yU(t));return delete o.secretSources,o}function IU(e,t,n,r){return fW(FU(e,t,{...t,[n.path]:r}))}function LU(e){let t=e.unit?.label;return t?` of ${t}`:``}function RU(e){let t=wU(e);if(!t)return`Allowed range is unavailable.`;let n=`${e.integer!==!1&&!PH(e)?`whole number`:`number`}${LU(e)}`;return t.exclusiveMin&&t.min===0?`Must be a positive ${n}.`:t.max==null?`Must be a ${n} ${t.exclusiveMin?`above`:`of at least`} ${FH(t.min)}.`:`Must be a ${n} between ${FH(t.min)} and ${FH(t.max)}.`}function zU(e){return`Must be a multiple of ${IH(e,1)}.`}function BU(e){return Math.abs(e-Math.round(e))<fU&&Number.isSafeInteger(Math.round(e))}function VU(e,t){return Number(LH({...e,integer:!1,nullable:!1,zeroIsNull:!1},t))}function HU(e,t){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=e.range;if(!n)return`Allowed range is unavailable.`;if(t==null||String(t).trim()===``)return RU(e);let r=Number(t);if(!Number.isFinite(r))return RU(e);if(e.zeroIsNull&&r<=0)return null;let i=VU(e,r);if(e.integer!==!1&&!BU(i))return PH(e)?zU(e):RU(e);let a=Number(LH(e,r));return n.exclusiveMin&&a<=n.min||!n.exclusiveMin&&a<n.min||n.max!=null&&a>n.max?RU(e):null}function UU(e,t,n=!1){return n?RU(e):HU(e,t.trim())}function WU(e,t){let n=t.trim();if(e.nullable&&n===``)return null;let r=Number(n);return e.zeroIsNull&&r<=0?null:r}function GU(e){if(e==null||e===``)return``;let t=Number(e);return Number.isFinite(t)?FH(t):String(e)}function KU(e,t){return Array.isArray(t)?e.valueKind===`posthog-projects`&&LH(e,t)===null?cU:null:`Must be a list.`}function qU(e,t){let n={};for(let r of kH(e)){if(AH(r))continue;let e=null;r.control===`number`&&(e=HU(r,t[r.path])),r.control===`list`&&(e=KU(r,t[r.path])),r.control===`select`&&r.options&&!r.options.some(e=>e.value===t[r.path])&&(e=`Choose one of the available options.`),e&&(n[r.id]=e)}return JU(kH(e),t,n),n}function JU(e,t,n){for(let r of e){let i=e.find(e=>e.id===r.maximumSettingId);if(!i||n[r.id]||n[i.id])continue;let a=t[r.path],o=t[i.path];Number(LH(r,a))>Number(LH(i,o))&&(n[r.id]=`Minimum must not exceed the maximum (${GU(o)}).`,n[i.id]=`Maximum must not be below the minimum (${GU(a)}).`)}}function YU(e,t){return kH(e).find(e=>e.id===t.maximumSettingId||e.maximumSettingId===t.id)}function XU(e,t,n){let r=YU(e,t);return qU([{id:`scoped`,level:`machine`,title:``,description:``,settings:r?[t,r]:[t]}],n)[t.id]??null}function ZU(e,t){return e.control===`number`?WU(e,t):e.control===`list`?CU(t):t}function QU(e,t){return LH(e,e.control===`list`?SU(t):t)}function $U(e){return e?.isDirty===!0}function eW(e,t,n,r,i,a=!1){if(!$U(n))return{kind:`unchanged`};let o=t.control===`number`?UU(t,r,a):null;if(o)return{kind:`invalid`,error:o};let s=ZU(t,r);if(bU(LH(t,s),QU(t,n.base)))return{kind:`unchanged`};let c=XU(e,t,{...i,[t.path]:s});return c?{kind:`invalid`,error:c}:{kind:`changed`,value:s}}function tW(e){return vU(e)?``:NH(e,e.defaultValue)}function nW(e,t){return bU(t,tW(e))}function rW(e){return e.presentation?e.presentation:(e.options?.length??0)<=lU?`segmented`:`select`}function iW(e){return Array.isArray(e)?e.length>0:typeof e==`string`?e.trim()!==``:e===!0}function aW(e,t){return e.danger===!0&&!!e.warning&&iW(t)}function oW(e,t){return aW(e,t)}function sW(e){return e.title.charAt(0).toLowerCase()+e.title.slice(1)}function cW(e){return vU(e)?`Reset removes the stored ${sW(e)}. Anything that relies on it stops until a new one is saved.`:oW(e,tW(e))?e.warning??``:null}function lW(e){return[e.repos.join(`, `),e.trigger,e.actions.map(e=>e.type).join(`, `)].join(` `)}function uW(e){if(e==null)return[`No rules. Add workflows.rules to config.json.`];let t=Tt.safeParse(e);return t.success?t.data.rules.length===0?[`No rules. Add workflows.rules to config.json.`]:t.data.rules.map(e=>[e.name,e.enabled?`enabled`:`disabled`,lW(e)].join(` `)):[`The workflows block is invalid, so no rule runs: ${t.error.issues[0]?.message??`unknown problem`}`]}function dW(e){let t=Tt.safeParse(e??{});return t.success?t.data.rules.map(e=>({id:e.id,name:e.name,isEnabled:e.enabled,summary:lW(e)})):[]}function fW(e){let t=e.workflows;return typeof t!=`object`||!t||Array.isArray(t)?e:{...e,workflows:Object.fromEntries(Object.entries(t).filter(([e])=>e!==`rules`))}}var pW=`lanes-features`,mW=Object.freeze({id:pW,level:`lanes`,title:`Features`,description:`Optional tabs, each hidden until its own toggle is on.`,settings:[]}),hW=Object.freeze({sounds:()=>df(),themes:Nf}),gW={},_W=null,vW=null,yW=mt,bW=null,xW=!1,SW=null,CW=[],wW=null,TW=()=>null,EW=()=>{},DW=new Set,OW=new Set;function kW(e){for(let t of OW)t(e)}function AW(e){if(!e.optionsFrom)return e;let t=hW[e.optionsFrom]?.()??[];return{...e,options:t.map(e=>({value:e.id,label:e.label}))}}function jW(){let e=SH.sections.map(e=>({...e,settings:e.settings.map(AW)})),t=e.findIndex(e=>e.level===`lanes`);return Object.freeze([...e.slice(0,t),mW,...e.slice(t)])}function MW(e){OW.add(e)}function NW(){return gW}function PW(e){return gW={...gW,...e},gW}function FW(){return{status:_W,journal:vW,request:yW,lastAutoCheckAt:bW,isCheckInFlight:xW,checkSendFailure:SW}}function IW(e){let t=O(yW,e);t!==yW&&(yW=t,kW({kind:`update`,frame:`request`}))}function LW(){IW(T({type:`update-apply`})?`request-sent`:`request-unsent`)}function RW(){bW=Date.now();let e=T({type:`update-check`});xW=e,SW=e?null:p,kW({kind:`update`,frame:`request`})}function zW(e){EW=e}function BW(){EW()}function VW(e){CW=[...e]}function HW(){return CW}function UW(e=null,t=null){e===null&&wW?.sectionId||(wW={sectionId:e,settingId:t,hashAtRequest:location.hash},kW({kind:`activate`}))}function WW(){let e=wW;return wW=null,e}function GW(e){let t=OU(e);if(t){let e=Ma(t.query);return{sectionId:e,settingId:null,hash:e}}return eU(e,jW(),CH,wH)}function KW(e){TW=e}function qW(){for(let e of DW)e()}function JW(e){DW.add(e)}function YW(){return Ud()&&TW()===`section`}function XW(){YW()&&kW({kind:`return-to-list`})}function ZW(e){e&&(gW=e,Ji(gW.agentLogins),kW({kind:`broadcast`}))}function QW(){kW({kind:`status`})}function $W(e){QW()}function eG(e){_W=e,xW=!1,SW=null,yW=O(yW,`status-frame`),kW({kind:`update`,frame:`status`})}function tG(e){vW=e,yW=O(yW,`progress-frame`),kW({kind:`update`,frame:`progress`})}function nG(e){if(e.scope!==`update`)return!1;let t=g(e.message),n=yW.requested;return yW=O(yW,`error-frame`,t),xW=!1,n||(SW=t),kW({kind:`update`,frame:`error`}),!0}function rG(e,t){return typeof t!=`string`||t===``?{knownBuild:e,reload:!1}:e==null?{knownBuild:t,reload:!1}:e===t?{knownBuild:e,reload:!1}:{knownBuild:t,reload:!0}}var iG=null,aG=null,oG=null,sG=null,cG=null,lG=null,uG=-1,dG=null,fG={isRightToLeft:!1,arcProgress:0},pG=1,mG=3;function hG(){if(!iG||dG===null)return;let e=ni({viewportWidthPx:document.documentElement.clientWidth,viewportHeightPx:document.documentElement.clientHeight,verticalProgress:dG,...fG});st(iG,ii(e,pG,window.devicePixelRatio))}function gG(){lG!==null&&(clearTimeout(lG),lG=null)}function _G(e=ir()){return tr({isEnabled:e,hasReducedMotion:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,isPhone:Ud(),options:In()})}function vG(e){e.onanimationend=null,e.style.animation=`none`,sG&&(sG.style.animation=`none`),e.hidden=!0}function yG(e,t){if(!iG||!aG||!oG||!sG||_G())return;let n=In();gG();let r=on(n,uG,Math.random,t);if(vG(iG),!r){lG=setTimeout(()=>yG(!1),1e3);return}dG=r.verticalProgress,fG={isRightToLeft:r.isRightToLeft,arcProgress:r.arcProgress},pG=n.flyingAnimalsScale,hG();let i=sn[r.animalIndex];aG.className=`nyan-sprite ${i.sprite}`,oG.className=`nyan-trail ${i.trail}`,uG=r.animalIndex,cG?.classList.remove(`is-booped`),iG.hidden=!1,iG.offsetWidth,iG.style.animation=`nyan-fly ${r.durationSeconds}s linear`,sG.style.animation=`nyan-trail-hold ${r.durationSeconds}s linear`,e&&(iG.style.animationDelay=`-${r.firstDelaySeconds}s`,sG.style.animationDelay=`-${r.firstDelaySeconds}s`),iG.onanimationend=e=>{iG&&e.target===iG&&(vG(iG),lG=setTimeout(()=>yG(!1),r.gapMs))}}function bG(){cG&&(cG.classList.remove(`is-booped`),cG.offsetWidth,cG.classList.add(`is-booped`))}function xG(e){if(iG&&sG&&e.target===cG)for(let e of[...iG.getAnimations(),...sG.getAnimations()])e.playbackRate=mG}function SG(){if(iG||_G())return;iG=document.createElement(`div`),iG.className=`nyan-flight`,iG.setAttribute(`aria-hidden`,`true`);let e=document.createElement(`div`);e.className=`nyan-trail-window`,sG=document.createElement(`div`),sG.className=`nyan-trail-hold`,oG=document.createElement(`div`),sG.append(oG),e.append(sG),aG=document.createElement(`div`),cG=document.createElement(`div`),cG.className=`nyan-boop`,cG.append(aG),cG.addEventListener(`pointerdown`,bG),cG.addEventListener(`animationend`,xG),iG.append(e,cG),document.body.appendChild(iG),window.addEventListener(`resize`,hG),window.addEventListener(`orientationchange`,hG),yG(!0)}function CG(e){SG(),yG(!1,e)}function wG(){gG(),window.removeEventListener(`resize`,hG),window.removeEventListener(`orientationchange`,hG),iG?.remove(),iG=null,aG=null,oG=null,sG=null,cG=null,uG=-1,dG=null}var TG=!1;function EG(e){let t=document.documentElement;if(TG||(TG=!0,Wd(()=>EG(ir())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>EG(ir()))),e){if(t.dataset.flyingAnimals=`true`,_G(e)){wG();return}SG()}else delete t.dataset.flyingAnimals,wG()}var DG=`•`.repeat(8),OG=`[^/\\\\\\s"'\`<>:]+`,kG=RegExp(`(?<![\\w./\\\\-])(?:/home/${OG}|/Users/${OG}|[A-Za-z]:[\\\\/]Users[\\\\/]${OG}|/root(?![\\w.-]))`,`g`);function AG(e){let t=Hp(e);if(t.length===0)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+DG,r=i.end;return n+e.slice(r)}function jG(e){return e.replace(kG,`~`)}function MG(e){return jG(AG(e))}var NG=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,PG=[`title`,`label`],FG=new WeakMap,IG=new WeakMap,LG=null;function RG(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(NG)!==null}function zG(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function BG(e,t){if(t&&e===t.masked)return t;let n=MG(e);return n===e?null:{original:e,masked:n}}function VG(e){let t=zG(e)?null:BG(e.data,FG.get(e));t?(FG.set(e,t),e.data!==t.masked&&(e.data=t.masked)):FG.delete(e)}function HG(e,t){let n=e.getAttribute(t),r=IG.get(e),i=n===null?null:BG(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),IG.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function UG(e){for(let t of PG)HG(e,t)}function WG(e){return e instanceof Element&&e.matches(NG)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function GG(e){UG(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,WG);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&VG(e),e instanceof Element&&UG(e)}function KG(e){RG(e)||(e instanceof Text&&VG(e),e instanceof Element&&GG(e))}function qG(e){e instanceof Element&&!RG(e)&&UG(e)}function JG(e){let t=new Set,n=new Set;for(let r of e){if(r.type===`childList`)for(let e of r.addedNodes)t.add(e);r.type===`characterData`&&t.add(r.target),r.type===`attributes`&&n.add(r.target)}for(let e of t)e.isConnected&&KG(e);for(let e of n)e.isConnected&&qG(e)}function YG(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);XG(e);for(let e=t.nextNode();e;e=t.nextNode())XG(e)}function XG(e){if(e instanceof Text){let t=FG.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=IG.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function ZG(){if(LG)return;let e=new MutationObserver(t=>{JG(t),e.takeRecords()});GG(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:PG}),LG=e}function QG(){LG&&(LG.disconnect(),LG=null,YG(document.body),FG=new WeakMap,IG=new WeakMap)}function $G(e){e?ZG():QG()}function eK(){$G($o()),ts($G)}function tK(e){if(typeof e!=`object`||!e||!(`telemetry`in e))return!1;let{telemetry:t}=e;return typeof t!=`object`||!t||!(`enabled`in t)?!1:t.enabled===!0}function nK(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function rK(e,t){return t||nK(e)?!1:tK(e)}var iK=2500;function aK({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}var oK=2e4,sK=null,cK=null,lK={claude:null,codex:null},uK=null,dK=null,fK=null,pK=`all`,mK=!1,hK=null,gK=null,_K=!0,vK=()=>!1,yK=new Set,bK=Oe({getAck:bn,setAck:Jn,signature:()=>kC(sK,lK.claude),isLooking:()=>vK()});function xK(e){for(let t of yK)t(e)}function SK(){uK?.(bK.refresh())}function CK(e){mK=e,xK(`refresh-status`),hK&&=(clearTimeout(hK),null),e&&(hK=setTimeout(()=>{hK=null,mK=!1,gK=`Usage did not answer within ${Math.round(oK/1e3)} s. Refresh to try again.`,xK(`refresh-status`)},oK))}function wK(e){let t=Px.find(t=>t.value===e);return t?t.days:null}function TK(){return{report:sK,sessions:cK,planLimitsByVendor:lK,rangeValue:pK}}function EK(){let e=!_K||!mK&&gK!==null;return _K?mK?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:gK??``,isPending:!1,hasFailure:e}:{text:sK?`${p} The figures below are from before the connection dropped.`:p,isPending:mK,hasFailure:e}}function DK(e){yK.add(e)}function OK(e){vK=e,SK()}function kK(){bK.acknowledge(),SK()}function AK(e){uK=e,SK()}function jK(e){dK?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function MK(e){dK=e}function NK(e){pK=e}function PK({force:e=!1}={}){if(!dK)return;fK=y(`usage`);let t={type:`request-usage-report`,requestId:fK};e&&(t.force=!0);let n=wK(pK);n!==null&&(t.days=n),gK=null,CK(!0),!dK(t)&&(gK=p,CK(!1))}function FK(e){_K=e,xK(`refresh-status`)}function IK(e){cK=e,xK(`sessions`)}function LK(e){let t=e;lK={...lK,[CC(t)]:t},xK(`plan-limits`),SK()}function RK(e){UC(e,fK)&&(gK=null,CK(!1),sK=e,xK(`report`),SK())}function zK(){let e=sK?.pricing||(cK?{source:cK.pricingSource}:null),t=IC(e?.fetchedAt),n=[FC(e,t!==null&&t>0?$t(t):``)],r=BC(sK);r&&n.push(r);let i=zC(sK?.scan);return i&&n.push(i),n}var BK={teamReview:e=>e?.teamReview?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,visions:e=>e?.visions?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,benchmarks:e=>e?.benchmarks?.enabled===!0,zenView:e=>e?.zenView===!0},VK=[{rule:`teamReview`,sectionId:`lanes-team-review`,settingId:`team-review-enabled`},{rule:`usage`,sectionId:`machine-usage`,settingId:`usage-enabled`},{rule:`posthog`,sectionId:`lanes-posthog`,settingId:`posthog-enabled`},{rule:`visions`,sectionId:`lanes-visions`,settingId:`visions-enabled`},{rule:`benchmarks`,sectionId:`lanes-benchmarks`,settingId:`benchmarks-enabled`},{rule:`zenView`,sectionId:`machine-sessions`,settingId:`zen-view`}],HK=2166136261,UK=16777619;function WK(e){let t=HK;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,UK)>>>0;return t}var GK=18e4,KK=2**32,qK=new Set([z.INITIALIZING,z.STARTING,z.RUNNING,z.WAITING,z.IDLE,z.COMPLETE,z.FAILED]),JK=new Map([[z.INITIALIZING,f.INITIALIZING],[z.STARTING,f.STARTING],[z.RUNNING,f.RUNNING],[z.IDLE,f.IDLE]]),YK=new Map([[z.INITIALIZING,`resting`],[z.STARTING,`resting`],[z.WAITING,`alert`],[z.FAILED,`alert`],[z.COMPLETE,`sitting`],[z.IDLE,`asleep`]]);function XK(e){return qK.has(e)}function ZK(e,t){let n=WK(e)/KK,r=ln(t,-1,()=>n);return r===null?null:sn[r]??null}function QK(e){let t=WK(`${e}#spot`);return{leftPercent:6+t%78,topPercent:12+(t>>>8)%62,ambleDistancePx:24+(t>>>16)%64,ambleSeconds:9+(t>>>24)%9}}function $K({state:e,activity:t,lastOutputAtMs:n,nowMs:r}){return e===z.RUNNING?n!==void 0&&r-n>=GK?`asleep`:t===`quiet`?`resting`:`ambling`:YK.get(e)??`asleep`}function eq({state:e,unseenOutcome:t}){return e===z.WAITING?Wt.WAITING:e===z.FAILED&&t===`failed`?Wt.FAILED:null}function tq(e,t){return JK.get(e)??Cc(e,t)}var nq=new Set([z.RUNNING,z.STARTING,z.INITIALIZING]),rq=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),iq=null,aq=!1,oq=null,sq=null,cq=new Map;function lq(e){let t=L(`div`,`zen-calm`),n=L(`div`,`zen-status-line`);n.setAttribute(`role`,`status`);let r=L(`span`,`zen-working-count`);n.append(L(`h2`,`zen-all-clear`,`ALL CLEAR`),r);let i=L(`div`,`zen-meadow`);i.setAttribute(`aria-label`,`Sessions`),t.append(n,i);let a=L(`div`,`zen-stage`),o=L(`div`,`zen-reason-line`);o.setAttribute(`role`,`status`);let s=L(`span`,`zen-staged-need`),c=L(`span`,`zen-queued-behind`);o.append(s,c);let l=L(`div`,`zen-pet-strip`);l.setAttribute(`aria-label`,`Other sessions`);let u=L(`button`,`btn-dialog`,`Next`);u.type=`button`,u.addEventListener(`click`,mq);let d=L(`div`,`zen-stage-bar`);d.append(o,l,u,Ba());let f=L(`div`,`zen-card-slot`);a.append(d,f),a.hidden=!0,e.append(t,a),iq={calm:t,workingCount:r,meadow:i,stage:a,stagedNeed:s,queuedBehind:c,petStrip:l,cardSlot:f}}function uq(){return aq}function dq(){if(iq){aq=!0;for(let e of cq.values())e.root.remove();cq.clear(),pq()}}function fq(){aq&&=(yq(),sq=null,!1)}function pq(){if(!aq)return;let e=_q();sq!==null&&!gq(sq)&&(sq=null),vq(sq??xc(e,oq),e)}function mq(){if(!aq)return;sq=null;let e=oq,t=e===null?void 0:H.get(e),n=t!==void 0&&Ec({state:t.currentState,unseenOutcome:t.unseenOutcome});e!==null&&n&&ET(e);let r=_q().filter(t=>!n||t!==e);vq(bc(r,e),r)}function hq(e){aq&&gq(e)&&(sq=e,vq(e,_q()))}function gq(e){let t=H.get(e);return t!==void 0&&XK(t.currentState)}function _q(){return Ac(vc(Iu()))}function vq(e,t){if(!iq)return;let n=e===null?void 0:H.get(e);if(e===null||!n){yq(),xq(iq);return}let r=oq!==e;oq=e,iq.calm.hidden=!0,iq.stage.hidden=!1,bq(iq,n,t.filter(t=>t!==e).length),Sq(iq.petStrip,e),(Wr()!==e||n.card.parentElement!==iq.cardSlot)&&(Gr(n,e,iq.cardSlot,{className:`zen-staged`}),hg(n,e,!0),r&&Oq(n,e))}function yq(){oq!==null&&Wr()===oq&&Kr(),oq=null}function bq(e,t,n){e.stagedNeed.textContent=tq(t.currentState,t.pendingPromptKind),e.stagedNeed.dataset.state=t.currentState,e.queuedBehind.textContent=`${n} more waiting`,e.queuedBehind.hidden=n===0}function xq(e){e.stage.hidden=!0,e.calm.hidden=!1;let t=Iu().filter(e=>nq.has(e.state)).length;e.workingCount.textContent=`${t} working`,Sq(e.meadow,null)}function Sq(e,t){let n=vc(Iu()).filter(e=>XK(e.state)&&e.id!==t),r=new Set(n.map(e=>e.id));for(let[e,t]of cq)r.has(e)||(t.root.remove(),H.has(e)||cq.delete(e));for(let t of n){let n=cq.get(t.id)??Cq(t.id);n.root.parentElement!==e&&e.append(n.root),wq(n,t.ui,t.name)}}function Cq(e){let t=L(`button`,`zen-pet`);t.type=`button`,t.dataset.sessionId=e;let n=QK(e);t.style.setProperty(`--zen-pet-left`,`${n.leftPercent}%`),t.style.setProperty(`--zen-pet-top`,`${n.topPercent}%`),t.style.setProperty(`--zen-pet-amble-distance`,`${n.ambleDistancePx}px`),t.style.setProperty(`--zen-pet-amble-duration`,`${n.ambleSeconds}s`),t.addEventListener(`click`,()=>hq(e));let r=L(`span`,`zen-pet-walker`),i=L(`span`,`zen-pet-bubble`);i.setAttribute(`aria-hidden`,`true`);let a=L(`span`,`zen-pet-facing`),o=L(`span`,`zen-pet-hopper`),s=ZK(e,In().flyingAnimalsExcludedSprites);o.append(s?oi(s,`zen-pet-sprite`):L(`span`,`zen-pet-dot`)),a.append(o);let c=L(`span`,`zen-pet-zzz`,`zzz`);c.setAttribute(`aria-hidden`,`true`);let l=L(`span`,`zen-pet-name`);r.append(i,a,c,l),t.append(r);let u={root:t,hopper:o,bubble:i,name:l};return cq.set(e,u),u}function wq(e,t,n){Eq(e,t,performance.now()),e.root.dataset.state=t.currentState,e.name.textContent!==n&&(e.name.textContent=n),e.root.setAttribute(`aria-label`,n),e.root.title=`${AT(t.path)}: ${tq(t.currentState,t.pendingPromptKind)}`;let r=eq({state:t.currentState,unseenOutcome:t.unseenOutcome});e.bubble.hidden=r===null,r!==null&&xr(e.bubble,r)}function Tq(e){rq?.matches||document.hidden||!e.hopper.animate||e.hopper.animate([{transform:`translateY(0)`},{transform:`translateY(-6px)`,offset:.4},{transform:`translateY(0)`}],{duration:320,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})}function Eq(e,t,n){e.root.dataset.mood=$K({state:t.currentState,activity:t._activity,lastOutputAtMs:t._lastOutputAt,nowMs:n})}function Dq(e,t){if(!aq)return;let n=e.card?.dataset.id,r=n?cq.get(n):void 0;r?.root.isConnected&&(Eq(r,e,performance.now()),t===`beat`&&Tq(r))}en(Dq),Zt(()=>{if(!aq)return;let e=performance.now();for(let[t,n]of cq){let r=H.get(t);r&&n.root.isConnected&&Eq(n,r,e)}});function Oq(e,t){requestAnimationFrame(()=>requestAnimationFrame(()=>{aq&&oq===t&&!document.hidden&&document.hasFocus()&&e.term?.focus()}))}function kq(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function Aq(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function jq(e,t){let n=new Set(e),r=[...new Set((t??[]).filter(e=>n.has(e)))];return[...r,...e.filter(e=>!r.includes(e))]}function Mq(e,t,n){let r=e.filter(e=>e!==t);if(r.length===e.length)return[...e];let i=Math.max(0,Math.min(n,r.length));return[...r.slice(0,i),t,...r.slice(i)]}function Nq(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function Pq(e,t,n){t&&e?.refreshOn?.includes(n)&&t.refresh?.(n)}function Fq(e,t,n,r){for(let i of e)kq(i.view,t)&&Pq(i,r(i.view),n)}function Iq(){let e=new Map,t=new Map;function n(e,n){let r=t.get(e.view);if(r)return r;let i=n().catch(n=>{throw t.delete(e.view),n});return t.set(e.view,i),i}function r(t,n){return e.get(t.view)||(n.mount(t.el),e.set(t.view,n),n)}function i(t){return e.get(t)??null}function a(t){let i=e.get(t.view);return i?Promise.resolve(i):t.module?Promise.resolve(r(t,t.module)):n(t,t.load).then(e=>r(t,e))}function o(e){for(let t of e)t.module&&r(t,t.module)}async function s(t){for(let r of t)r.load&&!e.has(r.view)&&await n(r,r.load)}return{show:a,mountedModuleOf:i,mountEagerViews:o,prefetch:s}}function Lq(e,t,n){let r=Number(e);return!e||!Number.isFinite(r)||t-r>n}var Rq=`glimmervoid:preload-error-reload-at`,zq=3e4,Bq=1e3,Vq=Iq();function Hq(e,t){let n=Vq.mountedModuleOf(e.view);n?t(n):Vq.show(e).then(t).catch(t=>{throw ke(`view`,`${e.view} failed to show: ${Jt(t)}`),t})}function Uq(e){return Vq.mountedModuleOf(e)}function Wq(e){Vq.mountEagerViews(e)}function Gq(e){let t=()=>{Vq.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,Bq)}function Kq(e){window.addEventListener(`vite:preloadError`,()=>{let t=e(),n=Date.now();Lq(t.getItem(Rq),n,zq)&&(t.setItem(Rq,String(n)),location.reload())})}function qq(e){jz({openTerminal:e.openTerminal,openReviews:e.openReviews}),zW(e.onRestart);let t=[{view:`focus`,label:`Focus`,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,hasReviewSidebar:!0,module:{mount:()=>qE({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:xD,deactivate:wD}},{view:`zen`,label:`Zen`,panelClass:`zen-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,gate:{fromSettings:BK.zenView},module:{mount:lq,activate:dq,deactivate:fq}},{view:`prs`,label:`Reviews`,glyph:`⇅`,panelClass:`pr-view`,gate:{fromSettings:BK.teamReview},load:()=>zm(()=>import(`./review-queue-panel-CVujzadC.js`).then(e=>e.view),__vite__mapDeps([0,1,2,3,4,5,6,7])),attention:{subscribe:Dz,acknowledge:Ez},onConnectionChange:e=>{jR(e),XF(e)}},{view:`issues`,label:`Issues`,glyph:`#`,panelClass:`issues-view`,load:()=>zm(()=>import(`./issues-panel-CyB4oq9Z.js`).then(e=>e.view),__vite__mapDeps([8,1,2,3,4,5,6,7])),refreshOn:[`shown`],onConnectionChange:qB},{view:`usage`,label:`Usage`,glyph:`◔`,panelClass:`usage-view`,gate:{fromSettings:BK.usage},load:()=>zm(()=>import(`./usage-panel-D2RX3LtG.js`).then(e=>e.view),__vite__mapDeps([9,1,2,3])),attention:{subscribe:AK,acknowledge:kK},onConnectionChange:FK,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,glyph:`◎`,panelClass:`radar-view`,gate:{fromSettings:BK.posthog},load:()=>zm(()=>import(`./radar-panel-Cl3yPWed.js`).then(e=>e.view),__vite__mapDeps([10,1,2,3,4,7])),attention:{subscribe:dV,acknowledge:uV}},{view:`visions`,label:`Visions`,glyph:`◇`,panelClass:`visions-view`,gate:{fromSettings:BK.visions},load:()=>zm(()=>import(`./visions-panel-BV9EKCBw.js`).then(e=>e.view),__vite__mapDeps([11,1,2,4])),attention:{subscribe:dk,acknowledge:fk},refreshOn:[`shown`],onConnectionChange:hk},{view:`hooks`,label:`Hooks`,glyph:`◈`,panelClass:`hooks-view`,load:()=>zm(()=>import(`./hooks-panel-R-L7DuIz.js`).then(e=>e.view),__vite__mapDeps([12,1,2,4,7])),refreshOn:[`shown`,`connected`,`hooks-updated`]},{view:`trace`,label:`Trace`,panelClass:`trace-view`,gate:{subscribe:ul},load:()=>zm(()=>import(`./trace-panel-B6TiM5pb.js`).then(e=>e.view),__vite__mapDeps([13,1,2,6,4])),refreshOn:[`shown`],onAvailabilityChange:e=>fV(e?Tx:null),onConnectionChange:Ax},{view:`benchmarks`,label:`Bench`,panelClass:`bench-view`,gate:{fromSettings:BK.benchmarks},load:()=>zm(()=>import(`./benchmark-panel-D09qvrAY.js`).then(e=>e.view),__vite__mapDeps([14,1,2])),onConnectionChange:gB},{view:`settings`,label:`Settings`,glyph:`@`,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>zm(()=>import(`./settings-panel-DW5An8lQ.js`).then(e=>e.view),__vite__mapDeps([15,1,2,3,6,4,7]))}],n=I(document,`#app-main`,`main`),r=t.map(t=>{let r=L(`button`,`header-tab`,t.label);r.id=`tab-${t.view}`,r.type=`button`,r.draggable=!0;let i=`view-${t.view}`;r.setAttribute(`role`,`tab`),r.setAttribute(`aria-controls`,i);let a=t.view===`focus`;r.setAttribute(`aria-selected`,String(a)),r.tabIndex=a?0:-1,t.glyph&&(r.dataset.phoneGlyph=t.glyph);let o=document.getElementById(i)??L(`section`);if(o.classList.add(t.panelClass),o.id=i,o.setAttribute(`role`,`tabpanel`),o.setAttribute(`aria-labelledby`,r.id),o.hidden=!0,o.parentElement||n.append(o),r.hidden=t.gate!==void 0,o.classList.toggle(`view-panel`,t.hasPanelChrome!==!1),t.attention){let n=L(`span`,`tab-activity`);n.id=`tab-${t.view}-activity`,n.setAttribute(`aria-hidden`,`true`),r.append(n),t.attention.subscribe(r=>{let{isActive:i,level:a}=Nq(r);n.classList.toggle(`active`,i),a===null&&n.removeAttribute(`data-attention`),a!==null&&n.setAttribute(`data-attention`,a),e.setPhoneAttention(t.view,r)})}return{...t,tab:r,el:o}});return I(document,`#header-tabs`,`div`).replaceChildren(...r.map(e=>e.tab)),r}kf(Pn()),Af(er()),jf(nr()),EG(ir()),Hd(),lc(document);var Jq=I(document,`#connection-status`,`span`),Yq=I(Jq,`.connection-label`,`span`),Xq=I(document,`#loading-screen`,`div`),Zq=I(document,`#loading-status`,`div`),Qq=I(document,`#loading-detail`,`div`),$q=I(document,`#shutdown-screen`,`div`),eJ=I(document,`#shutdown-status`,`div`),tJ=!1,nJ=null,rJ=!1;function iJ(){let e=si(),t=Xq.querySelector(`.loading-spinner`);e&&t&&t.replaceWith(oi(e,`loading-animal`))}iJ();function aJ(){tJ||nJ===null||aK({hasSnapshot:rJ,connectingTerminalCount:Jh(),msSinceConnected:performance.now()-nJ})===`reveal`&&oJ()}qh(aJ);function oJ(){if(tJ)return;tJ=!0,Xq.classList.add(`fade-out`),Gq(uY);let e=()=>Xq.remove();Xq.addEventListener(`transitionend`,e,{once:!0}),setTimeout(e,1e3)}function sJ(e,t){Jq.dataset.state=`shutdown`,Yq.textContent=e,Jq.title=e,$J.disabled=!0,eJ.textContent=t,$q.classList.add(`active`)}var cJ=new Set([`disconnected`,`connecting`]);function lJ(e,t,n){Jq.dataset.state=e,Jq.toggleAttribute(`data-reconnected`,n),Yq.textContent=t,Jq.title=t}function uJ(e,t){lJ(e,t,e===`connected`&&cJ.has(Jq.dataset.state??``))}function dJ(e,t){Jq.dataset.state!==`shutdown`&&lJ(e===`verified`?`connected`:e,t,!1)}var fJ=1e4,pJ=`Server`,mJ=`Worktree`,hJ=`Worktree warning`,gJ=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,_J=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,vJ=null,yJ=!1;function bJ(){Zq.textContent=`Reconnecting to server...`,Qq.textContent=_J,Qq.hidden=!yJ}function xJ(){vJ=null,yJ=!0,tJ?_r({source:pJ,message:gJ,hidesInStreamerMode:!1}):bJ()}function SJ(){vJ!==null||yJ||(vJ=window.setTimeout(xJ,fJ))}function CJ(){vJ!==null&&window.clearTimeout(vJ),vJ=null,yJ=!1,Qq.hidden=!0,gr(pJ)}_e((e,t)=>{if(e===`connecting`||e===`verified`)dJ(e,t);else{uJ(e,t),tT(e===`connected`);for(let t of uY)t.onConnectionChange?.(e===`connected`);if(e===`connected`){if(CJ(),vY&&yY(vY),$q.classList.contains(`active`)){location.reload();return}lo(),document.body.classList.add(`app-ready`),!tJ&&nJ===null&&(nJ=performance.now(),Zq.textContent=`Connecting to sessions...`,setTimeout(oJ,iK)),aJ(),KY(),FJ(`connected`),S(`get-settings`,{}).then(e=>{e.settings&&(TY(e.settings),Ur()===`settings`&&iY(location.hash))}).catch(()=>{})}else e===`disconnected`&&$q.classList.contains(`active`)?eJ.textContent=`Waiting for server...`:(SJ(),tJ||bJ())}});function wJ(){pq(),KB(),OR(),pM()}function TJ(){iD(),wJ()}var EJ=null;function DJ(e){let t=rG(EJ,e);EJ=t.knownBuild,t.reload&&location.reload()}function OJ(e){pk(new Map(e.filter(e=>!e.ephemeral).map(e=>[e.id,e.name]))),$W(e.filter(e=>!e.ephemeral).map(e=>({id:e.id,name:e.name,agent:e.agent,permissionMode:e.dangerouslySkipPermissions?`Skip permissions`:`Default`})));for(let t of e){Hs(t.id,t.coherenceHooks),t.ephemeral||wu(t.path),Xz(t.id,t.linkedPrs);let e=Vw(t.id);e&&OT(t.id,t.state,t.stateSince),e&&Cl(t.id,!!t.saneYolo),e&&aT(t.id,t.isGuarded,t.isGuardrailsReleased),e||Kw(t.id,t.name,t.state,xV(t)),wT(t.id,t.failureReason),Bw(t.id,t.taskTitle,t.taskTitleIsCustom),rT(t.id,t.agent),vT(t.id,t.mergeStatus,t.mergeReason),nT(t.id,t.effectiveBase),cT(t.id,t.activeAgents,t.awaitingBackgroundTasks),mT(t.id,t.pendingWakeup),dT(t.id,t.pendingPromptKind,t.isCompacting,t.isWaitingForMemory),fT(t.id,t.unseenOutcome),Nw(t.id,t),Xw(t.id,t.hasPlan),PJ(t.id)}Gw(),Zc(H),iD(),CD(),wJ(),kJ(),sY(location.hash),qY(),rJ=!0,aJ()}function kJ(){Ex([...H].map(([e,t])=>({id:e,name:tn(t)||e})))}function AJ(e,t){Xw(e,t?.hasPlan===!0),fT(e,t?.unseenOutcome),PJ(e)}function jJ(e){if(!Vw(e.id))Kw(e.id,e.session,e.to,xV({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),Zc(H),KB();else if(e.to===z.DORMANT&&e.from!==z.DORMANT){let t=H.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;xT(e.id),Kw(e.id,e.session,z.DORMANT,xV({skipPerms:i,saneYolo:a,worktree:r?.dataset.worktree!==void 0,workspace:r?.dataset.workspace!==void 0,remoteWorkspace:r?.dataset.remoteWorkspace??null,guarded:r?.dataset.guarded!==void 0,guardrailsReleased:r?.dataset.guardrailsReleased!==void 0,ephemeral:r?.dataset.ephemeral!==void 0,path:o,stateSince:e.timestamp,taskTitle:t?.taskTitle,taskTitleIsCustom:t?.taskTitleIsCustom})),rT(e.id,t?.agent),AJ(e.id,t),TJ(),gy(e.id),Zc(H)}else OT(e.id,e.to,e.timestamp,e.event),wT(e.id,e.failureReason),e.saneYolo!==void 0&&Cl(e.id,e.saneYolo),Zc(H),gy(e.id),TJ(),Wl(e.id),e.to===z.INITIALIZING&&(e.from===z.DONE||e.from===z.FAILED)&&rg(e.id)}var MJ=new Map;function NJ(e){let t=new Set;for(let n of e){if(!n?.id)continue;t.add(n.id);let e={tokens:n.tokens,costUSD:n.costUSD,officialCostUSD:n.officialCostUSD};MJ.set(n.id,e),lT(n.id,e)}for(let e of[...MJ.keys()])t.has(e)||(MJ.delete(e),lT(e,null))}function PJ(e){let t=MJ.get(e);t&&lT(e,t)}MK(T),LA(T),Cx(T),GB(T),mB(T),pl(Jz),nu(Ks),nu(Kz),hl({isReadable:qs,open:Ys}),_l(yV);function FJ(e){Fq(uY,{isPhoneShellActive:dM(),activeView:Ur(),phoneScreen:W.snapshot().phoneScreen},e,Uq)}ts(()=>FJ(`settings-updated`));var IJ={snapshot:e=>{DJ(e.serverBuild),OJ(e.sessions)},"hooks-report":e=>zA(e),"save-hook-result":()=>BA(),"delete-hook-result":()=>BA(),"state-change":e=>jJ(e),"session-added":e=>{e.ephemeral||wu(e.path),Xz(e.id,e.linkedPrs),Vw(e.id)||(Kw(e.id,e.session,e.state,xV(e)),rT(e.id,e.agent),PJ(e.id)),Zc(H),TJ(),kJ()},"session-close-confirm":e=>{Ku(e.id)},"session-removed":e=>{yr(e.id),xT(e.id),Us(e.id),vy(e.id),Zz(e.id),Zc(H),TJ(),kJ()},"session-title":e=>{Bw(e.id,e.taskTitle,e.isCustom),TJ()},"session-prs":e=>Xz(e.id,e.linkedPrs),"session-renamed":e=>{bT(e.id,e.newName),TJ(),kJ()},"session-modified":e=>{e.ephemeral||wu(e.path);let t=H.get(String(e.id));Hs(e.id,null),xT(e.id),vy(e.id),Xz(e.id,e.linkedPrs),Kw(e.id,e.session,e.state,xV(e)),rT(e.id,e.agent),AJ(e.id,t),Zc(H),TJ(),kJ()},"session-git":e=>iT(e.id,!!e.worktree),"session-agents":e=>{cT(e.id,e.activeAgents,e.awaitingBackgroundTasks),TJ(),Wl(e.id)},"session-wakeup":e=>mT(e.id,e.pendingWakeup),"session-unseen":e=>{fT(e.id,e.unseenOutcome),Gw(),Zc(H),TJ()},"session-prompt":e=>{dT(e.id,e.pendingPromptKind,e.isCompacting===!0,e.isWaitingForMemory===!0),wJ()},"session-merge-status":e=>{_T(e.id,e.mergeStatus,e.reason),gD(e.id,e.mergeStatus),wJ()},"session-worktree-blocked":e=>{_r({source:mJ,sessionId:e.id,message:`${e.session}: ${e.notice||`The integration branch was not found. Check the integration branch in Settings, then restart the session.`}`})},"session-worktree-warning":e=>{_r({source:hJ,sessionId:e.id,message:`${e.session}: ${e.notice||`The base branch could not be synced. The session keeps working on its current base.`}`})},"session-worktree-ready":e=>{gr(mJ,e.id),nT(e.id,e.base)},"session-diff":e=>{yT(e.id,{committed:e.committed,uncommitted:e.uncommitted,hasCommits:e.hasCommits})},"session-diff-error":e=>{dy(e.id,e.message)},"change-map":e=>fy(e.id,e.map),"branch-sync-status":e=>py(e.id,e),"session-changed":e=>hy(e.id),"post-turn-result":e=>hT(e.id,e),"debug-state-response":e=>Ul(e),"session-trace-response":e=>{Pw(e)||Dx(e)},"session-trace-changed":e=>{Iw(e.id),Ox(e)},"session-conversation":e=>{Nw(e.id,e),wJ()},"session-plan-changed":e=>{Zw(e),wJ()},"session-plan-draft":e=>{Qw(e)},"session-plan-response":e=>{$w(e)},"session-docs-changed":e=>Ts(e),"session-docs-snapshot":e=>Es(e),"session-coherence-hooks":e=>{Hs(e.id,e.coherenceHooks),TJ()},"session-coherence":e=>{Ws(e),TJ()},"session-coherence-snapshot":e=>{Gs(e),TJ()},"session-coherence-journal-response":e=>Xs(e),"session-setup-response":e=>bV(e),notify:e=>{ka(e),Wl(e.session)},"update-status":e=>{UJ(e),eG(e)},"update-progress":e=>tG(e.journal),"post-turn-leftovers":e=>GJ(e),error:e=>{let t=nG(e),n=kx(e);Fw(e);let r=eT(e);t||n||r||(e.id?CT(e.id,e.message):_r({source:pJ,message:e.message}))},"session-error":e=>{cy(e.id),!eT(e)&&CT(e.id,e.message)},"settings-updated":e=>{e.settings&&TY(e.settings),lo()},"agent-logins":e=>Ji(e.logins),"health-snapshot":e=>{e.stats&&Xg(e.stats)},"radar-status":e=>pV(e),"radar-investigation-activity":e=>mV(e),"radar-investigation-finished":e=>hV(e),"team-review-status":e=>qF(e),"github-prs":e=>Ar(e),"my-prs-status":kR,"benchmark-status":e=>_B(e),"benchmark-action-result":e=>vB(e),"my-pr-merge-result":e=>AR(e),"team-review-action-result":e=>JF(e),"open-team-review-session-result":e=>YF(e),"issues-status":e=>JB(e),"issue-detail-result":e=>YB(e),"open-issue-session-result":e=>XB(e),"usage-sessions":e=>{NJ(e.sessions),IK(e)},"usage-report":e=>{RK(e),QW()},"plan-limits":e=>LK(e),"usage-budget-alert":e=>ka({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0}),"visions-findings":e=>_k(e),"visions-comments":e=>vk(e),"visions-hand":e=>yk(e),"visions-intent":e=>bk(e),"visions-fix":e=>gk(e),"visions-snapshot":e=>Ck(e),"ingest-activity":e=>xk(e),"ingest-snapshot":e=>Sk(e),"client-trust":e=>LY(e.trust),"shutting-down":()=>sJ(`Shutting down...`,`Shutting down sessions...`),restarting:()=>sJ(`Restarting...`,`Restarting server...`)};function LJ(e){let t=IJ[e.type];t&&t(e)}Rt(e=>{LJ(e),FJ(e.type)});var RJ,zJ=null;function BJ(e,t,n){e.onclick=()=>{let e=Ft(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var VJ=Na(je,re,`Update`).href;function HJ(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function UJ(e){let t=I(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=Ce(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=HJ(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===zJ||!a&&RJ!==void 0&&s===RJ||!a&&s&&Hn()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);I(document,`#update-banner-text`,`span`).textContent=i,I(document,`#update-banner-cmd`,`code`).textContent=c;let l=I(document,`#update-banner-update`,`a`);l.href=VJ,l.hidden=n!==`link`;let u=I(document,`#update-banner-restart`,`button`);u.hidden=n!==`restart`,u.onclick=IY;let d=I(document,`#update-banner-cmd`,`code`);d.hidden=n!==`command`;let f=I(document,`#update-banner-copy`,`button`);f.hidden=n!==`command`;let p=I(document,`#update-banner-copy-status`,`span`);p.hidden=n!==`command`,p.textContent=``;let m=I(document,`#update-banner-link`,`a`);m.hidden=!e.releaseUrl,m.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,BJ(f,p,c),I(document,`#update-banner-dismiss`,`button`).onclick=()=>{t.hidden=!0,a?zJ=i:(RJ=s,Rn(s))}}var WJ=!1;function GJ({repositories:e,command:t}){let n=I(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(WJ)return;let r=I(document,`#post-turn-leftovers-copy-status`,`span`);I(document,`#post-turn-leftovers-text`,`span`).textContent=Rr(e.length),I(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,BJ(I(document,`#post-turn-leftovers-copy`,`button`),r,t),I(document,`#post-turn-leftovers-dismiss`,`button`).onclick=()=>{WJ=!0,n.hidden=!0}}var KJ=I(document,`#telemetry-banner`,`div`);function qJ(){An(!0),KJ.hidden=!0}function JJ(e){KJ.hidden=!rK(e,cn())}var YJ=I(document,`#telemetry-banner-settings`,`a`);YJ.href=Na(`privacy`,`telemetry-enabled`,`What's collected`).href,YJ.addEventListener(`click`,qJ),I(document,`#telemetry-banner-dismiss`,`button`).addEventListener(`click`,qJ),I(document,`#btn-add-session-header`,`button`).addEventListener(`click`,ra);var XJ=I(document,`#btn-mute`,`button`);rB(XJ);var ZJ=I(document,`#btn-streamer`,`button`);os(ZJ),eK();var QJ=I(document,`#power-menu`,`div`),$J=I(document,`#btn-power`,`button`);function eY(){$J.setAttribute(`aria-expanded`,QJ.classList.contains(`open`)?`true`:`false`)}$J.addEventListener(`click`,e=>{e.stopPropagation(),QJ.classList.toggle(`open`),eY()}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(QJ.contains(e.target)||(QJ.classList.remove(`open`),eY()))}),nt(document.querySelector(`.header`));function tY(e){e&&UW(e),!hM(`settings`)&&xY(`settings`,{section:e})}function nY(){ja(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}function rY(e){return e?(UW(e.sectionId,e.settingId),hM(`settings`)||xY(`settings`,{section:e.sectionId,setting:e.settingId,persist:!1}),!0):!1}function iY(e){return rY(GW(e))}var aY=`No plan is stored for this session yet. It appears here once the agent writes one.`,oY=`Plan`;function sY(e){let t=ma(e);return t?!Vw(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),dM()?(uM(t)||_r({source:oY,sessionId:t,message:aY}),!0):(xY(`focus`,{persist:!1}),vD(t)||_r({source:oY,sessionId:t,message:aY}),!0)):!1}function cY(e){return sY(e)?!0:iY(e)}function lY(e){e.newURL===location.href&&cY(location.hash)}document.addEventListener(`click`,e=>{if(!dM()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&cY(t.hash)&&e.preventDefault()}),fR(I(document,`#celebration-tray`,`div`),I(document,`#btn-celebrations`,`button`),I(document,`#celebration-tray-count`,`span`)),I(document,`#btn-help`,`button`).addEventListener(`click`,()=>{tY(`browser-shortcuts`)});var uY=qq({onRestart:IY,openTerminal:e=>{mM(e)||(xY(`focus`),_D(e))},openPlan:e=>{xY(`focus`),vD(e)},openReviews:()=>mY(`prs`)?(hM(`prs`)||xY(`prs`),!0):!1,setPhoneAttention:_M});function dY(){return uY.map(e=>e.view)}var fY=dY();VW(uY),ry({panel:document.getElementById(`review-sidebar`)}),Wq(uY);function pY(e){return uY.find(t=>t.view===e)}function mY(e){return uY.some(t=>t.view===e&&!t.tab.hidden)}var hY=!0,gY=null;function _Y(e){pY(e)?.attention?.acknowledge()}var vY=null;function yY(e){vY=T({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function bY(e){let t=pY(e);t&&(Hq(t,e=>Pq(t,e,`shown`)),yY(e))}function xY(e,{section:t,setting:n,persist:r=!0}={}){let i=pY(e);if(!i||!mY(e))return;let a=Ur();W.dispatch(`setActiveView`,e),hY=r,r&&(gY=null),document.body.dataset.activeView=e,document.body.dataset.reviewSidebarHidden=String(i.hasReviewSidebar!==!0),r&&fn(e);for(let t of uY){let n=t.view===e;t.el&&(t.el.hidden=!n),t.tab.setAttribute(`aria-selected`,String(n)),t.tab.tabIndex=n?0:-1}a!==e&&Uq(a)?.deactivate?.(),Hq(i,r=>{Ur()===e&&(r.activate?.(),Pq(i,r,`shown`),e===`settings`&&t&&UW(t,n??null))}),yY(e),a===`settings`&&e!==`settings`&&nY(),_Y(e)}function SY(e,t){let{view:n}=e;e.tab.hidden=!t,gM(n,t),e.onAvailabilityChange?.(t),!dM()&&(!t&&Ur()===n&&xY(`focus`),t&&gY===n&&xY(n))}function CY(e){for(let{view:t,isAvailable:n}of Aq(uY,e))SY(t,n)}function wY(e){let t=jq(fY,e);uY.every((e,n)=>e.view===t[n])||(uY.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),I(document,`#header-tabs`,`div`).append(...uY.map(e=>e.tab)),oM(t))}function TY(e){Uw(e),ZW(e),mk(e),CY(e),JJ(e),wY(e.viewTabOrder),es(e.streamerMode===!0),jw(e.conversationView===!0)}for(let e of uY)e.gate&&(SY(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>SY(e,t)));wx(()=>{mY(`trace`)&&(hM(`trace`)||xY(`trace`))});function EY(e,t){let n=uY.filter(e=>!e.tab.hidden),r=n[(n.findIndex(t=>t.view===e)+t+n.length)%n.length];return xY(r.view),r.tab}function DY(e){uY.some(e=>e.tab===document.activeElement)&&e.focus()}var OY=null;function kY(e){let t=dY();wY(e),S(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&wY(t)}).catch(()=>wY(t))}function AY(e){let t=OY;if(OY=null,!t||t===e)return;let n=dY();kY(Mq(n,t,n.indexOf(e)))}for(let e=0;e<uY.length;e++){let{view:t,tab:n}=uY[e];n.addEventListener(`click`,()=>xY(t)),n.addEventListener(`dragstart`,e=>{OY=t,e.dataTransfer?.setData(`text/plain`,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`)}),n.addEventListener(`dragover`,e=>{OY&&OY!==t&&(e.preventDefault(),n.dataset.dropTarget=`true`)}),n.addEventListener(`dragleave`,()=>delete n.dataset.dropTarget),n.addEventListener(`drop`,e=>{e.preventDefault(),delete n.dataset.dropTarget,AY(t)}),n.addEventListener(`dragend`,()=>{OY=null}),n.addEventListener(`keydown`,e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),EY(Ur(),e.key===`ArrowRight`?1:-1).focus()))})}var jY=Xn(),MY=GW(location.hash),NY=ma(location.hash);if(MY&&xY(`settings`,{section:MY.sectionId,setting:MY.settingId,persist:!1}),NY&&xY(`focus`,{persist:!1}),!MY&&!NY){let e=mY(jY);e||(gY=jY),xY(e?jY:`focus`,{persist:e})}sM({panels:VA(uY),onScreenShown:e=>{bY(e),e!==`settings`&&nY(),e===`settings`&&!ja(location.hash)&&UW(),_Y(e)},canGoBack:e=>e===`settings`&&YW()||e===`prs`&&Iz(),onBack:e=>{e===`settings`&&XW(),e===`prs`&&Lz()},headerControls:[I(document,`.header-title`,`h1`),I(document,`#status-indicator`,`div`),I(document,`#celebration-tray`,`div`),I(document,`#btn-add-session-header`,`button`),I(document,`#btn-help`,`button`),XJ,ZJ,QJ]}),JW(Qj),Fz(Qj);function PY(e){if(e===`phone`){let e=KE();for(let e of uY)Uq(e.view)?.deactivate?.();let t=GW(location.hash);cM({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}),t&&UW(t.sectionId,t.settingId);return}let t=fM();lM();let n=Ur();xY(mY(n)?n:`focus`,{persist:hY}),t&&_D(t)}Ud()&&PY(`phone`),Wd(PY),window.addEventListener(`hashchange`,lY);function FY({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){QJ.classList.remove(`open`),eY();let o=Hw(),s=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;wr({title:t,message:s,confirmLabel:n,danger:r||o>0,onConfirm:()=>T({type:e})})}function IY(){FY({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}I(document,`#btn-restart`,`button`).addEventListener(`click`,IY);function LY(e){let t=Pr(`shutdown`,e);I(document,`#btn-shutdown`,`button`).hidden=!t,I(document,`#menu-divider-shutdown`,`div`).hidden=!t}I(document,`#btn-shutdown`,`button`).addEventListener(`click`,()=>{FY({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})});var RY=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`]);function zY(e,t){return e.value!==``&&RY.has(t.key)}function BY(e){let t=document.activeElement;return t instanceof HTMLElement?t.isContentEditable?!0:t instanceof HTMLTextAreaElement&&t.dataset.dashboardShortcuts===`allowed`?zY(t,e):(t.tagName===`INPUT`||t.tagName===`TEXTAREA`)&&!t.classList.contains(`xterm-helper-textarea`):!1}function VY(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function HY(e){_D(e),Pu(e),requestAnimationFrame(()=>requestAnimationFrame(()=>H.get(e)?.term?.focus()))}function UY(){let e=VY()??Au();e?Vu(e,HY):document.getElementById(`btn-add-session-header`)?.click()}function WY({action:e,step:t}){switch(e){case`merge`:return yy(),!0;case`close-session`:{let e=Au();return e?(Ku(e),!0):!1}case`resolve-or-resync`:return xy()||wy(),!0;case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return UY(),!0;case`next-attention`:return Ud()?!1:uq()?(mq(),!0):GE()?(cD(),!0):(Ur()===`prs`&&Rz()||SD(()=>xY(`focus`)),!0);case`rail-step`:return GE()?(bD(t),!0):!1;case`view-step`:return!Ud()&&(DY(EY(Ur(),t)),!0);case`session-nth`:return GE()?(yD(t),!0):!1;case`streamer-mode`:return as(),!0}}document.addEventListener(`keydown`,e=>{if(e.repeat||BY(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1,n=Dn(e,Pa,{isTerminalFocused:t},La());n&&WY(n)&&e.preventDefault()});var GY=Lr({mode:`trailing`,delayMs:150,run:()=>{T({type:`focus-change`,focused:document.hasFocus()})}});function KY(){GY.schedule()}function qY(){let e=fM();e&&B(e)?._isActiveViewer?.()===!0&&ET(e)}function JY(){KY(),pg(B(Wr())),qY()}window.addEventListener(`focus`,JY),window.addEventListener(`blur`,JY),document.addEventListener(`visibilitychange`,JY);var YY=!1;async function XY(){if(!YY){YY=!0,tg();try{if(await Vt()===`ok`)return;for(let e of H.keys())rg(e)}finally{ng(),YY=!1}}}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&(Zm(),XY())}),window.addEventListener(`online`,XY);var ZY=Te(T);window.addEventListener(`error`,e=>{ZY(e.error),ke(`uncaught`,Jt(e.error??e.message))}),window.addEventListener(`unhandledrejection`,e=>{ZY(e.reason),ke(`unhandled-rejection`,Jt(e.reason))}),Kq(()=>window.sessionStorage),window.addEventListener(`pageshow`,e=>{e.persisted&&(Zm(),XY())}),Yg(I(document,`#health-footer-mount`,`div`)),ef(Ww),SJ(),Ee();export{DU as $,XS as $a,nC as $i,dF as $n,cu as $o,tA as $r,WF as $t,WW as A,CS as Aa,kO as Ai,gF as An,gx as Ao,Bk as Ar,Lz as At,nW as B,HC as Ba,HD as Bi,DF as Bn,Ub as Bo,Rk as Br,rz as Bt,BW as C,fS as Ca,SA as Ci,LP as Cn,hC as Co,UM as Cr,ta as Cs,tB as Ct,NW as D,Wx as Da,uk as Di,oF as Dn,xx as Do,RA as Dr,Rz as Dt,HW as E,eS as Ea,hA as Ei,tP as En,bx as Eo,FA as Er,Mr as Es,kz as Et,wU as F,jS as Fa,LO as Fi,JP as Fn,Gb as Fo,Nk as Fr,Nz as Ft,OU as G,LC as Ga,YD as Gi,PF as Gn,Cf as Go,Jk as Gr,ez as Gt,oW as H,_S as Ha,CO as Hi,eP as Hn,Af as Ho,Tk as Hr,az as Ht,eW as I,aC as Ia,HO as Ii,XP as In,Hb as Io,Wk as Ir,MR as It,tW as J,QC as Ja,rE as Ji,QP as Jn,Wd as Jo,jk as Jr,WR as Jt,NU as K,qC as Ka,XD as Ki,LF as Kn,ff as Ko,Hk as Kr,GR as Kt,EU as L,iC as La,MO as Li,mF as Ln,Wb as Lo,Uk as Lr,XR as Lt,hU as M,yS as Ma,bO as Mi,nP as Mn,pb as Mo,qk as Mr,Oz as Mt,kU as N,gC as Na,NO as Ni,HP as Nn,Tb as No,Fk as Nr,Pz as Nt,FW as O,Ux as Oa,lk as Oi,wF as On,yx as Oo,IA as Or,Az as Ot,rW as P,TC as Pa,VO as Pi,IF as Pn,zb as Po,Pk as Pr,Cz as Pt,MU as Q,QS as Qa,ew as Qi,AP as Qn,ou as Qo,yA as Qr,wR as Qt,$U as R,$S as Ra,GD as Ri,lP as Rn,Kb as Ro,Ak as Rr,YR as Rt,RW as S,vC as Sa,gA as Si,FF as Sn,VC as So,HM as Sr,ea as Ss,fB as St,KW as T,Yx as Ta,aA as Ti,CP as Tn,Sx as To,BM as Tr,jr as Ts,wz as Tt,GU as U,OS as Ua,wO as Ui,uP as Un,kf as Uo,Ek as Ur,UR as Ut,SU as V,gS as Va,SO as Vi,$P as Vn,jf as Vo,Dk as Vr,KR as Vt,AU as W,sS as Wa,RD as Wi,oP as Wn,pf as Wo,Yk as Wr,QR as Wt,gU as X,wS as Xa,nw as Xi,RP as Xn,xu as Xo,Ok as Xr,ER as Xt,_U as Y,TS as Ya,iE as Yi,nF as Yn,Pu as Yo,Ik as Yr,$R as Yt,IU as Z,qx as Za,tw as Zi,bF as Zn,bu as Zo,Vk as Zr,TR as Zt,ZW as _,LS as _a,uA as _i,jF as _n,ow as _o,lN as _r,Yi as _s,HB as _t,jK as a,Px as aa,nA as ai,AF as an,DS as ao,kN as ar,Pa as as,$H as at,qW as b,nS as ba,mA as bi,OP as bn,aS as bo,bN as br,oa as bs,pB as bt,NK as c,cC as ca,lA as ci,EP as cn,DC as co,qM as cr,Ba as cs,oV as ct,TK as d,OC as da,EA as di,SF as dn,MS as do,RN as dr,Na as ds,zB as dt,mS as ea,OA as ei,GF as en,MC as eo,zP as er,Kl as es,aW as et,zK as f,lw as fa,Zk as fi,TF as fn,aw as fo,ZM as fr,Aa as fs,VB as ft,pW as g,RS as ga,_A as gi,VP as gn,sw as go,TN as gr,ga as gs,WB as gt,CG as h,zS as ha,bA as hi,yF as hn,Kx as ho,DN as hr,va as hs,BB as ht,VK as i,bC as ia,vA as ii,rF as in,AC as io,iP as ir,ns as is,iU as it,mU as j,uC as ja,ED as ji,UP as jn,_x as jo,zk as jr,Mz as jt,MW as k,Hx as ka,ck as ki,hF as kn,vx as ko,Gk as kr,Tz as kt,DK as l,lC as la,Qk as li,_F as ln,Zx as lo,KM as lr,za as ls,cV as lt,_G as m,iS as ma,rA as mi,lF as mn,Gx as mo,AN as mr,xa as ms,UB as mt,jq as n,BS as na,dA as ni,pP as nn,wC as no,NP as nr,$o as ns,uW as nt,PK as o,jx as oa,sA as oi,NF as on,uS as oo,JM as or,Ra as os,SH as ot,EG as p,tS as pa,pA as pi,cF as pn,KC as po,BN as pr,Ma as ps,IB as pt,cW as q,mC as qa,vO as qi,ZP as qn,Ud as qo,Mk as qr,iz as qt,BK as r,SC as ra,xA as ri,mP as rn,xC as ro,PP as rr,ts as rs,dW as rt,OK as s,Mx as sa,wA as si,MF as sn,rS as so,YM as sr,Va as ss,lV as st,Mq as t,hS as ta,CA as ti,iF as tn,PC as to,pF as tr,el as ts,jU as tt,EK as u,$C as ua,eA as ui,CF as un,jC as uo,zN as ur,La as us,sV as ut,jW as v,FS as va,cA as vi,RF as vn,rw as vo,sN as vr,Qi as vs,RB as vt,XW as w,cw as wa,DA as wi,IP as wn,iw as wo,VM as wr,oi as ws,nB as wt,LW as x,NS as xa,TA as xi,uF as xn,BC as xo,WM as xr,Xi as xs,hB as xt,PW as y,IS as ya,oA as yi,tF as yn,lS as yo,cN as yr,sa as ys,LB as yt,PU as z,GC as za,dO as zi,OF as zn,db as zo,kk as zr,ZR as zt};