glimmervoid 0.52.3-next.749 → 0.52.3-next.751
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/glimmervoid.js +7 -7
- package/dist/chunks/agent-api-cli-D5LpKt3J.js +1 -0
- package/dist/chunks/{agent-api-cli-PgRkZU4P.js → agent-api-cli-DvnXm4kI.js} +1 -1
- package/dist/chunks/{main-Buf2PV_P.js → main-BWbKEWLs.js} +16 -2
- package/dist/chunks/{packs-cli-s61MOWh7.js → packs-cli-BY5iV3hA.js} +1 -1
- package/dist/chunks/{pr-flows-cli-D6M6kXRm.js → pr-flows-cli-DMrno1BY.js} +2 -2
- package/dist/chunks/{settings-cli-CYaiaFRJ.js → settings-cli-D6vMWRbr.js} +1 -1
- package/dist/chunks/{ssh-sign-cli-BAlpaJTq.js → ssh-sign-cli-CYoKi2i6.js} +1 -1
- package/dist/chunks/whiteboard-svg-core-Cidy3DqV.js +3844 -0
- package/dist/client/assets/{agent-mark-CvEqiBo4.js → agent-mark-CPPMGmer.js} +1 -1
- package/dist/client/assets/agent-mark-CPPMGmer.js.br +0 -0
- package/dist/client/assets/{arena-panel-ISlMnhdr.js → arena-panel-Dgw6ZGdZ.js} +2 -2
- package/dist/client/assets/arena-panel-Dgw6ZGdZ.js.br +0 -0
- package/dist/client/assets/{benchmark-panel-CbNeD1Aa.js → benchmark-panel-DR6aAOVJ.js} +1 -1
- package/dist/client/assets/benchmark-panel-DR6aAOVJ.js.br +0 -0
- package/dist/client/assets/boards-view-BzjY5fys.js +1 -0
- package/dist/client/assets/boards-view-BzjY5fys.js.br +0 -0
- package/dist/client/assets/{community-panel-DFjyCuQn.js → community-panel-BMBam6Rk.js} +1 -1
- package/dist/client/assets/community-panel-BMBam6Rk.js.br +0 -0
- package/dist/client/assets/{dialogs-3m6N2GQi.js → dialogs-HOpRh5gr.js} +1 -1
- package/dist/client/assets/dialogs-HOpRh5gr.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-CrshwKCN.js → doc-editor-ui-BQW70vY2.js} +1 -1
- package/dist/client/assets/doc-editor-ui-BQW70vY2.js.br +0 -0
- package/dist/client/assets/{feature-hint-DOqkkS_S.js → feature-hint-CqdX9ZAW.js} +1 -1
- package/dist/client/assets/feature-hint-CqdX9ZAW.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-DLbuF9fv.js → first-run-checklist-BlZGURU2.js} +1 -1
- package/dist/client/assets/first-run-checklist-BlZGURU2.js.br +0 -0
- package/dist/client/assets/{hooks-panel-Cy_NwPQM.js → hooks-panel-ByIwabVS.js} +1 -1
- package/dist/client/assets/hooks-panel-ByIwabVS.js.br +0 -0
- package/dist/client/assets/index-B12zcEVW.js +75 -0
- package/dist/client/assets/index-B12zcEVW.js.br +0 -0
- package/dist/client/assets/{issues-panel-DA-TyQpb.js → issues-panel-Sus7muya.js} +1 -1
- package/dist/client/assets/issues-panel-Sus7muya.js.br +0 -0
- package/dist/client/assets/{lane-read-token-step-B2qvZxxP.js → lane-read-token-step-7jOMda7j.js} +1 -1
- package/dist/client/assets/lane-read-token-step-7jOMda7j.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-BbATOOLT.js → my-prs-panel-ChhHuCoo.js} +1 -1
- package/dist/client/assets/my-prs-panel-ChhHuCoo.js.br +0 -0
- package/dist/client/assets/{nyan-cat-FdK_g6uh.js → nyan-cat-CVhgfmIv.js} +1 -1
- package/dist/client/assets/nyan-cat-CVhgfmIv.js.br +0 -0
- package/dist/client/assets/{phone-shell-9b-bf4Dm.js → phone-shell-QCuH5boT.js} +1 -1
- package/dist/client/assets/phone-shell-QCuH5boT.js.br +0 -0
- package/dist/client/assets/{plan-face-B9S4yUcj.js → plan-face-DUhdCaFO.js} +1 -1
- package/dist/client/assets/plan-face-DUhdCaFO.js.br +0 -0
- package/dist/client/assets/{plan-render-d5VbtGtB.js → plan-render-DLBH8WcZ.js} +1 -1
- package/dist/client/assets/plan-render-DLBH8WcZ.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-MoAluWAc.js → pr-queue-columns-CBvxTcrj.js} +1 -1
- package/dist/client/assets/pr-queue-columns-CBvxTcrj.js.br +0 -0
- package/dist/client/assets/{radar-panel-DxnKC0O3.js → radar-panel-BVMuKUyT.js} +1 -1
- package/dist/client/assets/radar-panel-BVMuKUyT.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-D-YdrTBd.js → repo-roots-adder-wqJpeF0h.js} +1 -1
- package/dist/client/assets/repo-roots-adder-wqJpeF0h.js.br +0 -0
- package/dist/client/assets/{resume-dialog-CuNFDUKu.js → resume-dialog-CiIZCDh7.js} +1 -1
- package/dist/client/assets/resume-dialog-CiIZCDh7.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-CREnMu2I.js → review-queue-panel-DcpL1Oa_.js} +1 -1
- package/dist/client/assets/review-queue-panel-DcpL1Oa_.js.br +0 -0
- package/dist/client/assets/{session-actions-BGzOI9VS.js → session-actions-9ZhnsG51.js} +2 -2
- package/dist/client/assets/session-actions-9ZhnsG51.js.br +0 -0
- package/dist/client/assets/{session-row-B9VNB7jC.js → session-row-DGItX9OU.js} +1 -1
- package/dist/client/assets/session-row-DGItX9OU.js.br +0 -0
- package/dist/client/assets/{settings-panel-C8mHUg30.js → settings-panel-DbON5896.js} +2 -2
- package/dist/client/assets/settings-panel-DbON5896.js.br +0 -0
- package/dist/client/assets/{trace-panel-Bsr2Easc.js → trace-panel-BBnR2Rin.js} +1 -1
- package/dist/client/assets/trace-panel-BBnR2Rin.js.br +0 -0
- package/dist/client/assets/{usage-panel-DWVbDiG1.js → usage-panel-Cj4D9QUu.js} +1 -1
- package/dist/client/assets/usage-panel-Cj4D9QUu.js.br +0 -0
- package/dist/client/assets/{your-day-tip-DGI6fbHA.js → your-day-tip-Ckl6WABy.js} +1 -1
- package/dist/client/assets/your-day-tip-Ckl6WABy.js.br +0 -0
- package/dist/client/index.html +4 -4
- package/dist/client/index.html.br +0 -0
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/agent-api-cli-Hv7ZSe1j.js +0 -1
- package/dist/chunks/whiteboard-svg-core-bnP72KuQ.js +0 -2476
- package/dist/client/assets/agent-mark-CvEqiBo4.js.br +0 -0
- package/dist/client/assets/arena-panel-ISlMnhdr.js.br +0 -0
- package/dist/client/assets/benchmark-panel-CbNeD1Aa.js.br +0 -0
- package/dist/client/assets/boards-view-DQTSAGYw.js +0 -1
- package/dist/client/assets/boards-view-DQTSAGYw.js.br +0 -0
- package/dist/client/assets/community-panel-DFjyCuQn.js.br +0 -0
- package/dist/client/assets/dialogs-3m6N2GQi.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-CrshwKCN.js.br +0 -0
- package/dist/client/assets/feature-hint-DOqkkS_S.js.br +0 -0
- package/dist/client/assets/first-run-checklist-DLbuF9fv.js.br +0 -0
- package/dist/client/assets/hooks-panel-Cy_NwPQM.js.br +0 -0
- package/dist/client/assets/index-CrpXpbdb.js +0 -75
- package/dist/client/assets/index-CrpXpbdb.js.br +0 -0
- package/dist/client/assets/issues-panel-DA-TyQpb.js.br +0 -0
- package/dist/client/assets/lane-read-token-step-B2qvZxxP.js.br +0 -0
- package/dist/client/assets/my-prs-panel-BbATOOLT.js.br +0 -0
- package/dist/client/assets/nyan-cat-FdK_g6uh.js.br +0 -0
- package/dist/client/assets/phone-shell-9b-bf4Dm.js.br +0 -0
- package/dist/client/assets/plan-face-B9S4yUcj.js.br +0 -0
- package/dist/client/assets/plan-render-d5VbtGtB.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-MoAluWAc.js.br +0 -0
- package/dist/client/assets/radar-panel-DxnKC0O3.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-D-YdrTBd.js.br +0 -0
- package/dist/client/assets/resume-dialog-CuNFDUKu.js.br +0 -0
- package/dist/client/assets/review-queue-panel-CREnMu2I.js.br +0 -0
- package/dist/client/assets/session-actions-BGzOI9VS.js.br +0 -0
- package/dist/client/assets/session-row-B9VNB7jC.js.br +0 -0
- package/dist/client/assets/settings-panel-C8mHUg30.js.br +0 -0
- package/dist/client/assets/trace-panel-Bsr2Easc.js.br +0 -0
- package/dist/client/assets/usage-panel-DWVbDiG1.js.br +0 -0
- package/dist/client/assets/your-day-tip-DGI6fbHA.js.br +0 -0
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xterm-CdMfg81L.js","assets/rolldown-runtime-DK3Fl9T5.js","assets/nyan-cat-FdK_g6uh.js","assets/dom-helpers-BFFApPgS.js","assets/ui-prefs-DDS1bMmm.js","assets/zod-_N0uRWDY.js","assets/local-store-CVQ5ByvB.js","assets/alert-sound-core-CmJhj4qI.js","assets/nyan-geometry-core-C8RryYMH.js","assets/celebration-player-BX0kw6fZ.js","assets/alert-sound-Da6VQFBS.js","assets/doc-editor-ui-CrshwKCN.js","assets/control-ws-CPMlFaao.js","assets/button-mkFeAYAx.js","assets/modal-Dhk9uL5H.js","assets/action-status-DVzULV_M.js","assets/plan-render-d5VbtGtB.js","assets/doc-editor-ui-5jSk9zTx.css","assets/resume-dialog-CuNFDUKu.js","assets/card-registry-Ce-vcsp1.js","assets/card-actions-bxVtjG6L.js","assets/plan-face-B9S4yUcj.js","assets/ui-state-core-Nssh-6QJ.js","assets/roving-keys-core-BDobx2It.js","assets/plan-face-CNqLL3OW.css","assets/phone-shell-9b-bf4Dm.js","assets/session-row-B9VNB7jC.js","assets/session-tick-y2mRLUu_.js","assets/session-actions-BGzOI9VS.js","assets/preload-helper-BLdHbfdN.js","assets/menu-vE2Jgaj4.js","assets/pr-status-icon-BMKwTDHk.js","assets/agent-mark-CvEqiBo4.js","assets/first-run-checklist-DLbuF9fv.js","assets/setup-step-BG8YW-jb.js","assets/repo-roots-adder-D-YdrTBd.js","assets/boards-view-DQTSAGYw.js","assets/boards-view-yHwL2BwM.css","assets/review-queue-panel-CREnMu2I.js","assets/lane-read-token-step-B2qvZxxP.js","assets/lane-read-token-step-GYpu4zXr.css","assets/pr-queue-columns-MoAluWAc.js","assets/my-prs-panel-BbATOOLT.js","assets/team-review-settings-core-BHv0yl1m.js","assets/issues-panel-DA-TyQpb.js","assets/issues-panel-1vb6hHuv.css","assets/usage-panel-DWVbDiG1.js","assets/chart-readout-RMfue8Zi.js","assets/usage-panel-DV0ckKqY.css","assets/radar-panel-DxnKC0O3.js","assets/dialogs-3m6N2GQi.js","assets/radar-panel-LHOTTm1M.css","assets/community-panel-DFjyCuQn.js","assets/community-panel-DR_-RgSK.css","assets/hooks-panel-Cy_NwPQM.js","assets/hooks-panel-BUBv4dvX.css","assets/trace-panel-Bsr2Easc.js","assets/trace-panel-D-AIzBSZ.css","assets/arena-panel-ISlMnhdr.js","assets/arena-panel-CW50kbc8.css","assets/settings-panel-C8mHUg30.js","assets/flying-animal-preview-BcM0Sll8.js","assets/settings-panel-gVM13RdM.css","assets/feature-hint-DOqkkS_S.js","assets/feature-hint-Dm-eD9Sz.css","assets/your-day-tip-DGI6fbHA.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{C as e,S as t,_ as n,a as r,b as i,d as a,f as o,g as s,h as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,t as _,u as v,v as y,x as ee,y as te}from"./control-ws-CPMlFaao.js";import{a as ne,c as b,d as x,g as S,h as re,m as ie,n as ae,o as oe,r as se,u as ce,y as le}from"./zod-_N0uRWDY.js";import{$t as ue,A as de,Bn as fe,Bt as pe,C as me,Cn as he,Ct as ge,D as _e,Dt as C,E as ve,Et as ye,Ft as be,G as xe,Gn as Se,Hn as Ce,It as we,J as Te,Jt as Ee,K as De,Kn as Oe,Ln as ke,Lt as Ae,M as je,Mt as Me,Nn as Ne,Nt as Pe,O as w,Ot as Fe,Pn as Ie,Pt as Le,Qt as Re,R as ze,Rn as Be,S as Ve,St as He,T as Ue,Tt as We,U as Ge,Un as Ke,V as qe,Vn as Je,Wn as Ye,Yt as Xe,Z as Ze,_ as Qe,_n as $e,_t as et,a as tt,an as nt,b as rt,bt as it,c as at,dn as ot,en as st,f as ct,g as lt,h as ut,hn as dt,i as ft,in as pt,j as mt,jt as ht,kn as gt,kt as _t,l as vt,p as yt,q as bt,qn as xt,qt as St,rn as Ct,s as wt,st as Tt,t as T,tn as Et,u as Dt,ut as Ot,vn as kt,vt as At,wn as jt,wt as Mt,x as Nt,xn as Pt,y as Ft,yn as It,zn as Lt,zt as Rt}from"./button-mkFeAYAx.js";import{J as zt,S as Bt,X as Vt,Y as Ht,Z as E,_ as Ut,b as Wt,f as Gt,g as D,h as Kt,n as qt,p as Jt,q as Yt,s as O,t as Xt,u as Zt}from"./dom-helpers-BFFApPgS.js";import{a as Qt,i as $t,n as en,r as tn,t as nn}from"./modal-Dhk9uL5H.js";import{C as rn,S as an,_ as on,a as sn,b as cn,c as ln,d as un,f as dn,g as fn,h as pn,i as mn,l as hn,m as gn,n as _n,o as vn,p as yn,r as bn,s as xn,t as Sn,u as Cn,v as wn,x as Tn,y as En}from"./session-row-B9VNB7jC.js";import{S as Dn,_ as On,a as kn,b as An,c as jn,f as Mn,g as Nn,h as Pn,i as k,m as Fn,n as In,o as A,r as j,s as Ln,t as M,u as Rn,x as zn,y as Bn}from"./card-registry-Ce-vcsp1.js";import{n as N,t as Vn}from"./ui-state-core-Nssh-6QJ.js";import{t as P}from"./preload-helper-BLdHbfdN.js";import{i as Hn,n as Un,o as Wn,r as Gn,s as Kn,t as qn,u as Jn}from"./action-status-DVzULV_M.js";import{a as Yn,c as Xn,i as Zn,n as Qn,o as $n,r as er,s as tr,t as nr}from"./session-tick-y2mRLUu_.js";import{n as rr,t as ir}from"./local-store-CVQ5ByvB.js";import{$ as ar,A as or,C as sr,D as cr,J as lr,K as ur,O as dr,S as fr,T as pr,W as mr,X as hr,Y as gr,Z as _r,_t as vr,at as yr,b as br,c as xr,ct as Sr,f as Cr,g as wr,h as Tr,ht as Er,i as Dr,it as Or,k as kr,l as Ar,m as jr,mt as Mr,n as Nr,nt as Pr,ot as Fr,p as Ir,q as Lr,r as Rr,rt as zr,s as Br,st as Vr,t as Hr,u as Ur,v as Wr,w as Gr,x as Kr,xt as qr,y as Jr,yt as Yr,z as Xr}from"./ui-prefs-DDS1bMmm.js";import{C as Zr,D as Qr,E as $r,I as ei,O as ti,S as ni,T as ri,_ as ii,a as ai,b as oi,c as si,d as ci,f as li,g as ui,h as di,i as fi,k as pi,l as mi,m as hi,o as gi,u as _i,v as vi,w as yi,x as bi,y as xi}from"./session-actions-BGzOI9VS.js";import{n as Si}from"./card-actions-bxVtjG6L.js";import{n as Ci,t as wi}from"./roving-keys-core-BDobx2It.js";import{n as Ti}from"./menu-vE2Jgaj4.js";import{t as Ei}from"./pr-status-icon-BMKwTDHk.js";import{t as Di}from"./agent-mark-CvEqiBo4.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 Oi={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},ki=null,Ai=null,ji=!0,Mi=new Map,Ni=new Map,Pi=new Set;function Fi(){for(let e of Pi)e()}function Ii(e){Pi.add(e)}function Li(){return{status:ki,isServerConnected:ji,pendingActionBySuite:Mi,outcomeBySuite:Ni}}function Ri(e){Ai=e}function zi(e,t){Ai?.({type:`benchmark-action`,requestId:h(`benchmark`),suiteId:e,action:t})===!0?(Mi.set(e,t),Ni.set(e,Oi[t]),Fi()):(Ni.set(e,je),Fi())}function Bi(e){if(ji=e,!e){for(let e of Mi.keys())Ni.delete(e);Mi.clear()}Fi()}function Vi(e){ki=e,Fi()}function Hi(e){Mi.delete(e.suiteId);let t=ki?.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.`};Ni.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),Fi()}function Ui({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=tn({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=O(`div`,`coherence-journal-header`),s=O(`h3`,`dialog-title`,t);s.id=n;let c=T({variant:`secondary`,label:`Close`,action:`close-coherence-panel`,onClick:i});return o.append(s,c),a.dialog.append(o,...r),nn(a.dialog,s.id),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function Wi({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=h(e),m=Ui({dialogClass:t,titleText:n,titleId:`${p}-title`,body:l,onCloseRequest:()=>g.close()}),g={sessionId:s,status:c,parts:u,requestId:p,timer:null,close:()=>{o(g),a===g&&(a=null),m.close()}};a=g,d?.(),m.focusClose(),v(f(p))?g.timer=setTimeout(()=>{g.requestId=null,g.timer=null,c.textContent=`${r}: request timed out`},i):(g.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 Gi={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 Ki(e){return e?.active!==!1||e.reason===ot.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,detailText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:an.broken}]}function qi(e){let t=Re.safeParse(e.kind);return{heading:`${t.success?Gi[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function Ji(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 Yi=new Map,Xi=new Map,Zi=Wi({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function Qi(e,t){Xi.delete(e),t&&Xi.set(e,t),ia(e)}function $i(e){Yi.delete(e),Xi.delete(e);let t=Zi.currentPanel();t?.sessionId===e&&t.close()}function ea(e){let t=Yi.get(e.id);t&&t.updatedAt>e.updatedAt||(Yi.set(e.id,e),ia(e.id))}function ta(e){Yi.clear();for(let[t,n]of Object.entries(e.sessions))Yi.set(t,n);let t=Zi.currentPanel();t&&ia(t.sessionId)}function na(e){return Ki(Xi.get(e)??null).map(t=>({...t,onActivate:()=>aa(e)}))}function ra(e){return Yi.get(e)?.journal.ok===!0}function ia(e){let t=Zi.currentPanel();if(!t||t.sessionId!==e)return;let n=Ji(Xi.get(e)??null,Yi.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>O(`p`,null,e)))}function aa(e){let t=O(`div`,`coherence-journal-reading`),n=O(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=O(`div`,`coherence-journal-entries`);Zi.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>ia(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function oa(e){let t=Zi.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=qi(e),n=O(`article`,`coherence-journal-entry`);return n.append(O(`h4`,null,t.heading),O(`p`,null,t.text)),t.detail&&n.append(O(`p`,null,t.detail)),t.supersedes&&n.append(O(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var sa=new Set([`waiting`,`monitoring`]);function ca(e){return Object.fromEntries(Rt.flatMap(t=>{let n=sa.has(t)?8:6;return[[`--state-${t}`,e[t]],[`--state-${t}-bg`,`color-mix(in oklab, var(--state-${t}) ${n}%, transparent)`]]}))}function la(e){return{...Object.fromEntries(Object.entries(e.chrome).map(([e,t])=>[`--${e}`,t])),...ca(e.states)}}var ua={dark:{red:`#ef4444`,brightRed:`#f87171`,green:`#22c55e`,brightGreen:`#4ade80`,yellow:`#eab308`,brightYellow:`#facc15`,blue:`#3b82f6`,brightBlue:`#60a5fa`,magenta:`#a855f7`,brightMagenta:`#c084fc`,cyan:`#06b6d4`,brightCyan:`#22d3ee`},light:{red:`#b91c1c`,brightRed:`#dc2626`,green:`#15803d`,brightGreen:`#16a34a`,yellow:`#92400e`,brightYellow:`#a16207`,blue:`#1d4ed8`,brightBlue:`#2563eb`,magenta:`#6d28d9`,brightMagenta:`#7c3aed`,cyan:`#0e7490`,brightCyan:`#0891b2`}},da={dark:{black:`--border`,brightBlack:`--text-muted`,white:`--text`,brightWhite:`--text-head`},light:{black:`--text-head`,brightBlack:`--text-dim`,white:`--text-dim`,brightWhite:`--text`}},fa=.35;function pa(e,t){return`#${[1,3,5].map(t=>Number.parseInt(e.slice(t,t+2),16)).map(e=>Math.round(e+(255-e)*t)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function ma(e){if(e.accentAnsiSlot===`none`)return{};let t=`bright${e.accentAnsiSlot[0].toUpperCase()}${e.accentAnsiSlot.slice(1)}`;return{[e.accentAnsiSlot]:`--accent`,[t]:pa(e.chrome.accent,fa)}}function ha(e){return{label:e.label,colors:la(e),terminal:{background:`--bg-card`,foreground:`--text`,cursor:`--accent`,cursorAccent:`--bg-card`,...da[e.mode],...ua[e.mode],...ma(e)}}}var ga={golgari:ha({label:`Golgari (Dark)`,mode:`dark`,accentAnsiSlot:`blue`,chrome:{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`},states:{running:`#22c55e`,waiting:`#f59e0b`,failed:`#ef4444`,monitoring:`#22d3ee`,done:`#94a3b8`,initializing:`#6b7280`,idle:`#eab308`,starting:`#a78bfa`,complete:`#34d399`}}),midnight:ha({label:`Midnight (Dark)`,mode:`dark`,accentAnsiSlot:`blue`,chrome:{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:`#5674f7`,"accent-dim":`#3a54c0`},states:{running:`#22c55e`,waiting:`#f59e0b`,failed:`#ef4444`,monitoring:`#22d3ee`,done:`#94a3b8`,initializing:`#6b7280`,idle:`#eab308`,starting:`#a855f7`,complete:`#60a5fa`}}),phyrexian:ha({label:`Phyrexian (Dark)`,mode:`dark`,accentAnsiSlot:`magenta`,chrome:{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`},states:{running:`#22c55e`,waiting:`#f59e0b`,failed:`#ef4444`,monitoring:`#60a5fa`,done:`#67e8f9`,initializing:`#6b7280`,idle:`#eab308`,starting:`#f472b6`,complete:`#34d399`}}),compleated:ha({label:`Compleated (Light)`,mode:`light`,accentAnsiSlot:`none`,chrome:{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`},states:{running:`#157838`,waiting:`#a94e08`,failed:`#cd2323`,monitoring:`#0e728d`,done:`#5a697e`,initializing:`#6b7280`,idle:`#995d07`,starting:`#7c3aed`,complete:`#047a55`}}),unicorn:ha({label:`Rainbow Unicorns (Dark)`,mode:`dark`,accentAnsiSlot:`magenta`,chrome:{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`},states:{running:`#42d780`,waiting:`#f79f3b`,failed:`#f15e4d`,monitoring:`#2dd4bf`,done:`#f153a8`,initializing:`#8f87a6`,idle:`#bcb02f`,starting:`#a17ef1`,complete:`#34baf4`}}),"posthog-light":ha({label:`PostHog (Light)`,mode:`light`,accentAnsiSlot:`none`,chrome:{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":`#66685f`,accent:`#c03300`,"accent-dim":`#8e2600`},states:{running:`#237a36`,waiting:`#936412`,failed:`#8c0d3b`,monitoring:`#0e7490`,done:`#3e6b9e`,initializing:`#73756b`,idle:`#835c19`,starting:`#a621c8`,complete:`#34796f`}}),"posthog-dark":ha({label:`PostHog (Dark)`,mode:`dark`,accentAnsiSlot:`none`,chrome:{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`},states:{running:`#36c46f`,waiting:`#f7a501`,failed:`#f46767`,monitoring:`#22d3ee`,done:`#589df8`,initializing:`#8f8f8c`,idle:`#ffce5c`,starting:`#9a81ff`,complete:`#29dbbb`}})},_a=`phyrexian`,va=null,ya=null,ba=null,xa={};function Sa(e){return Object.hasOwn(ga,e)?ga[e]:xa[e]}function Ca(e){xa=Object.fromEntries(e.map(({id:e,palette:t})=>[e,ha(t)]));let t=ba??_a,n=Sa(t)?t:_a;return n===ya&&!Object.hasOwn(xa,n)?!1:(Ta(n),!0)}function wa(e){ba=e,Sa(e)&&Ta(e)}function Ta(e){let t=Sa(e);if(!t)return;let n=ya;ya=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`&&va?.()}function Ea(e){va=e}function Da(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function Oa(){let e=Sa(ya||_a);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 ka(){return{id:ya,colors:{...Sa(ya??_a)?.colors}}}function Aa(){return Object.entries({...ga,...xa}).map(([e,t])=>({id:e,label:t.label}))}function ja(){let e=Oa();e.background&&e.foreground&&v({type:`terminal-colors`,background:e.background,foreground:e.foreground})}var Ma=3e4,Na=24,Pa=null,Fa=[`Android`,`iPhone`,`iPad`,`Windows`,`Mac OS X`,`Linux`],Ia=[/Firefox\/\d+/,/Edg\/\d+/,/Chrome\/\d+/,/Version\/\d+/];function La(){let e=navigator.userAgent,t=Fa.find(t=>e.includes(t))??`unknown platform`;return`${Ia.map(t=>t.exec(e)?.[0]).find(e=>e!==void 0)?.replace(`Version`,`Safari`)??`unknown browser`} on ${t}`}function Ra(){let e=Reflect.get(navigator,`connection`);if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`type`),n=Reflect.get(e,`rtt`);return[typeof t==`string`?t:``,typeof n==`number`?`${n}ms`:``].filter(e=>e!==``)}function za(){return[navigator.onLine?`online`:`offline`,...Ra()].join(` `)}function Ba(e,t){let n=[],r=0;for(let i of e){let e=i.length+1;if(r+e>t)break;n.push(i),r+=e}return{takenMarks:n,usedChars:r}}function Va(e,t){let n=e.join(` `);if(n.length<=t)return n;let r=t-Na,i=Ba(e,r/2),a=Ba(e.slice(i.takenMarks.length).reverse(),r-i.usedChars),o=e.length-i.takenMarks.length-a.takenMarks.length;return[...i.takenMarks,`(${o} marks dropped)`,...a.takenMarks.reverse()].join(` `)}function Ha(e){return e.marks.some(e=>e.startsWith(`terminal-bytes`))}function Ua(e){let t=Ha(e)&&!e.isCapped?`terminal live`:`terminal not live after ${Ma/1e3} s`,n=`hidden ${Math.round(e.hiddenForMs/1e3)} s, ${t}, ${La()}, ${e.networkAtWake}: `,r=n+Va(e.marks,Ct-n.length);return v({type:`client-log`,scope:`wake`,text:r.slice(0,Ct)})}function Wa(){let e=Pa;e&&(e.isCapped||Ha(e))&&Ua(e)&&(Pa=null,clearTimeout(e.capTimer))}function Ga(){Pa&&(Pa.isCapped=!0,Wa())}function Ka(e,t){e.marks.push(`${t}+${Math.round(performance.now()-e.startedAtMs)}`)}function qa(e){Pa&&(e===`terminal-bytes`&&Ha(Pa)||(Ka(Pa,e),(e===`terminal-bytes`||e===`control-opened`)&&Wa()))}function Ja(e){Pa&&Ka(Pa,e===`link`?[`link`,...Ra()].join(`-`):e)}function Ya(e,t){Pa||={startedAtMs:performance.now(),hiddenForMs:t,networkAtWake:za(),marks:[],isCapped:!1,capTimer:setTimeout(Ga,Ma)},qa(e)}function Xa(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function Za(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 Qa=null,$a=null;function eo(){return Qa}function to(){return Qa?Promise.resolve(Qa):($a??=Promise.all([P(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.t),__vite__mapDeps([0,1])),P(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.r),__vite__mapDeps([0,1])),P(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.n),__vite__mapDeps([0,1]))]).then(([e,t,n])=>(Qa={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},Qa)).catch(e=>{throw $a=null,e}),$a)}var no=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,ro=new Map;function io(e){return e.clientWidth>0&&e.clientHeight>0}function ao(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 oo(e){ro.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,ao(e)}function so(e){let t=[e],n=N.snapshot().borrowedCardId,r=n?A.get(n):void 0;r&&t.push(r);for(let e of Za([...ro.keys()],no,t))oo(e),e.needsWebGLReload=!0}function co(e){e?.term&&Xa({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:io(e.termWrap)})&&mo(e,{isForced:!0})}function lo(){for(let e of ro.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{oo(e),e.needsWebGLReload=!0}}}var uo=!1;function fo(){uo||(uo=!0,requestAnimationFrame(()=>{uo=!1,lo()}))}function po(e){e?.addEventListener(`contextrestored`,fo)}function mo(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){ro.delete(e),ro.set(e,!0);return}e.webglAddon&&(ao(e),ro.delete(e));let n=eo();if(!n)return;so(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,ro.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(po),r.onAddTextureAtlasCanvas(po),po(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!io(e.termWrap),ro.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,ro.delete(e)}}var ho=`(max-width: 768px)`,go=`(pointer: coarse)`;function _o({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var vo=window.matchMedia?.(go),yo=window.matchMedia?.(ho);function bo(){return _o({coarse:!!vo?.matches,narrowWidth:!!yo?.matches})}function xo(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function So(){N.subscribe((e,t)=>{t.includes(`layout`)&&xo(e.layout)});let e=bo();xo(e),N.dispatch(`setLayout`,e);let t=()=>N.dispatch(`setLayout`,bo());return vo?.addEventListener?.(`change`,t),yo?.addEventListener?.(`change`,t),e}function Co(){return N.snapshot().layout===`phone`}function wo(e){return N.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var To=``,Eo=`\x1B`,Do=`\r`,Oo=new Map([[`deleteContentBackward`,To],[`deleteByComposition`,To],[`deleteCompositionText`,To],[`deleteWordBackward`,Eo],[`deleteSoftLineBackward`,Eo],[`deleteHardLineBackward`,Eo]]);function ko(e){return Oo.get(e)??``}var Ao=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function jo(e){return typeof e!=`string`||e===``||!Ao.has(e)}function Mo(e){return e?e.keyCode===229||e.key===`Process`:!1}function No(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 To.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,Do)}var Po=`Upload`;async function Fo(e,t){return Un(Po,e),Lo(e,t)}async function Io(e,t){Un(Po,e);for(let n of t)await Lo(e,n)}async function Lo(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:(Wn({source:Po,sessionId:e,message:await Ro(r,t.name)}),!1)}catch{return Wn({source:Po,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 Ro(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 zo=new WeakMap,Bo=5e3,Vo=15e3,Ho=`The agent copied text. The browser needs a click before it can reach your clipboard.`,Uo=`The clipboard is unavailable in this browser.`;function Wo(e,t,n,r){let i=zo.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(()=>Go(e,t),n===`ok`?Bo:Vo)))}function Go(e,t){let n=zo.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function Ko(e){let t=e.buffer.active;return t.viewportY<t.baseY}function qo(e,t,{hasNewOutput:n=!1}={}){let r=zo.get(e)?.jumpToLatest;if(!r)return;let i=Ko(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function Jo(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 Yo(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),Wo(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function Xo(e,t,n,r){let i=Wt(t);i?i.then(()=>{r&&Wo(e,`clipboard`,`ok`,r)}).catch(t=>Yo(e,n,t)):Wo(e,`clipboard`,`error`,Uo)}function Zo(e,t){let n=zo.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function Qo(e){let t=zo.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,Xo(e,n,`osc52 write`,`Copied to the clipboard.`))}function $o(e,t,n){let r=Hn(`terminal-notice`),i=O(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=T({variant:`primary`,label:`Copy to clipboard`,onClick:()=>Qo(t)});i.append(O(`span`,`terminal-clipboard-prompt-text`,Ho),a);let o=O(`div`,`terminal-notices`);o.append(i,r.element);let s=O(`div`,`terminal-jump-latest`);s.hidden=!0,s.append(T({variant:`secondary`,label:`Jump to latest`,onClick:()=>{n.scrollToBottom(),n.focus()}}),O(`span`,`terminal-jump-latest-new-output`));let c=O(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(O(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),zo.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatest:s})}var es=1024,ts=`Keys you type now are held and sent once the terminal reconnects.`,ns=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,rs=!1;function is(e){let t=e._inputQueue,n=e.dataWs;if(!rs&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,Go(e,`keys`)}}function as(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!rs&&!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>=es?(Wo(e,`keys`,`error`,ns),!1):(e._inputQueue.push(t),r&&Wo(e,`keys`,`busy`,ts),!0)}function os(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,Co()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=No(i,r.value);return i=r.value,e!==``&&(as(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{Co()?n(e):a()},!0)};c(`keydown`,e=>{Mo(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(!jo(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=ko(e.inputType);r!==``&&(as(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function ss(e){return!!e&&Array.from(e.types).includes(`Files`)}function cs(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),Io(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{ss(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,ss(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),Io(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function ls(e){rs=e}var us=6,ds=262144,fs=16384,ps=()=>{};function ms(e,t){if(t.length<=fs)e.push(t);else for(let n=0;n<t.length;n+=fs)e.push(t.slice(n,n+fs))}function hs({budget:e=us,maxChunkBytes:t=ds,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)ms(l,e),m+=e.length,a.readIdx++;else{m===0&&(ms(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,ps);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 gs=hs(),_s=ce().int().min(1).max(500),vs=ce().int().min(1).max(200);oe(`type`,[x({type:b(`input`),data:S()}),x({type:b(`claim`),cols:_s,rows:vs}),x({type:b(`unview`)}),x({type:b(`pause-output`)}),x({type:b(`resume-output`)})]);var ys=x({type:b(`pty-size`),cols:_s,rows:vs,seq:ce().int().nonnegative()}),bs=x({type:b(`output-beat`)}),xs=oe(`type`,[ys,bs]),Ss=`history`,Cs=`output`,ws=`paused`;ae([`screen`,`deep`]);function Ts(e){try{return JSON.parse(e)}catch{return null}}function Es(e){let t=xs.safeParse(Ts(e));return t.success?t.data:null}var Ds=new Set([1,5,25,100]);function Os(e){return e.isOutputPaused?`${e.history} paused`:e.history}function ks(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function As(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function js(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function Ms({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&ks(e,n))}function Ns({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function Ps({isBorrowedCard:e,isTerminalFaceShown:t}){return!e||!t}function Fs({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function Is(e,t,n){let r=new URLSearchParams;t&&r.set(Ss,`deep`),n&&r.set(Cs,ws);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function Ls({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:Ms({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function Rs({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function zs({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!ks(e,t),s=As(n)?js(n):null,c=r&&!!s&&!ks(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:Ms({authoritative:e,isActiveViewer:r,lastClaim:a})}}function Bs(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function Vs(e){let t=Bs(e);return t===null?null:Es(t)}function Hs(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=Vs(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 Us=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,Ws=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,F=`[^\\S\\r\\n]`,Gs=`${Us}${F}*(?:=>|[:=])${F}*`,Ks=`[?&][A-Za-z0-9_.-]*`,qs=`[^\\r\\n;&|]{0,200}?`,Js=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,Ys=RegExp(`(${Gs})${Ws}`,`gi`),Xs=RegExp(`(\\bBearer${F}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),Zs=[/\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],Qs=[RegExp(`((?:^|\\s)--?${Us}${F}+)${Ws}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${F}*=?${F}*)${Ws}`,`g`),RegExp(`(-AsPlainText${F}+)${Ws}`,`gi`),RegExp(`((?:^|\\s)setx${F}+[^\\s\\r\\n]*${Us}[^\\s\\r\\n]*${F}+)${Ws}`,`gi`)],$s=[RegExp(`(\\bauthorization${F}*:${F}*Basic${F}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${F}+login\\b${qs}${F}-p(?:${F}+|=))${Ws}`,`gi`),RegExp(`(\\bcurl\\b${qs}${F}(?:--user|-u)(?:${F}+|=)[^\\s:\\r\\n]+:)${Ws}`,`gi`),RegExp(`(\\b${Js}\\b${qs}${F}-p)${Ws}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi],ec=[/-----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],tc=RegExp(`(${Ks}(?:${Us}|_key)=)[^&#\\s]+`,`gi`),nc=[Ys,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${Ws}`,`g`)],rc=[Xs,...Qs,...$s,...Zs,...ec];function ic(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function ac(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 oc(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 sc(e){let t=ic(e,tc);return oc([...t,...nc.flatMap(n=>ac(ic(e,n),t)),...rc.flatMap(t=>ic(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var cc=`glimmervoid-streamer-mode`,lc=new Set,uc=ir(cc,!1)===!0;function dc(e){document.documentElement.toggleAttribute(`data-streamer`,e)}dc(uc);function fc(){return uc}function pc(e){if(rr(cc,e),e!==fc()){uc=e,dc(e);for(let t of lc)t(e)}}function mc(e){return lc.add(e),()=>lc.delete(e)}async function hc(e){try{let t=await a(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:qn});return t.type===`settings-error`?String(t.message):(pc(e),``)}catch(e){return Kn(e,qn)}}var gc=`Streamer mode`;async function _c(){let e=!fc();e&&pc(!0);let t=await hc(e);t?Wn({source:gc,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}):Un(gc)}function vc(){_c()}var yc=`#808080`,bc=new WeakMap;function xc(e,t,n){return`${e}:${t}:${n}`}function Sc(e){return xc(e.marker.line,e.x,e.width)}function Cc(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function wc(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function Tc(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function Ec(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 Dc(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 Oc(e,t,n,r){let i=[];if(sc(Tc(e,t,n)).length===0)return i;let{text:a,cellAt:o}=Ec(e,t,n,r);for(let e of sc(a))Dc(i,o.slice(e.start,e.end));return i}function kc(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=wc(e,i);r.push(...Oc(e,i,t,n)),i=t+1}return r}function Ac(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function jc(e){e.decoration.dispose(),e.marker.dispose()}function Mc(e){for(let t of e.masks)jc(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function Nc(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function Pc(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 Fc(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(Sc(r),r),r=e.masks.at(-1);return Pc(e),n}function Ic(e,t){let n={normal:Ac(),alternate:Ac()},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??yc,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(!fc())return;let t=e.buffer.active,r=n[t.type],i=Cc(t,Nc(r,t)),a=Fc(r,i);for(let e of kc(t,i)){let n=xc(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())jc(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){Mc(n.normal),Mc(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=>{Mc(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=mc(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),bc.delete(e)},{once:!0}),bc.set(e,d)}function Lc(e){bc.get(e)?.()}function Rc({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var zc=`-4 -4 108 108`,Bc=Object.freeze([{side:`top`,d:`M33 29L50 12L67 29`},{side:`right`,d:`M71 33L88 50L71 67`},{side:`bottom`,d:`M67 71L50 88L33 71`},{side:`left`,d:`M29 67L12 50L29 33`}]),Vc=`M50 39L61 50L50 61L39 50Z`,Hc=11,Uc=`#e8e0ff`,Wc=`#c084fc`;function Gc({frame:e,light:t,strokeWidth:n=Hc}){return`<path d="${Bc.map(({d:e})=>e).join(``)}" fill="none" stroke="${e}" stroke-width="${n}" stroke-linejoin="miter" stroke-linecap="butt"/><path d="${Vc}" fill="${t}"/>`}function Kc(e,t){return Ps({isBorrowedCard:N.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var qc=new WeakMap,Jc=new WeakMap,Yc=new WeakSet,Xc=new WeakSet,Zc=new WeakSet;function Qc(e,t){if(qc.has(e)||!Ko(t))return;let n=t.buffer.active,r=n.length-n.viewportY;Yc.has(e)?qc.set(e,r):Jc.set(e,r)}function $c(e,t,n){let r=e.term;r&&Fs({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:Yc.has(e)})&&(Yc.add(e),Xc.add(e),qc.set(e,r.buffer.active.length-n),Dl(t))}var el=new WeakMap;function tl(e,t){return document.visibilityState===`visible`&&!Kc(e,t)}function nl(e,t){if(e&&_l(e,t))return;let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=tl(e,t);el.get(n)!==r&&(el.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function rl(){for(let[e,t]of A)nl(t,e)}document.addEventListener(`visibilitychange`,rl),N.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&rl()});function il(e,t){return A.get(e)===t&&!t.dataWs}function al(e){return e.querySelector(`:scope > .terminal-connecting`)}function ol(){let e=de(`svg`,{class:`loading-mark`,viewBox:zc,"aria-hidden":`true`});for(let{side:t,d:n}of Bc)e.append(de(`path`,{class:`loading-mark-bracket`,"data-side":t,d:n}));return e}function sl(e){if(al(e))return;let t=O(`div`,`terminal-connecting`);t.append(ol(),O(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}var cl=new Set,ll=new WeakSet;function ul(e){return cl.add(e),()=>cl.delete(e)}function dl(){let e=0;for(let[t,n]of A)n.card.dataset.link===`connecting`&&tl(n,t)&&e++;return e}function fl(e){let t=Rc({hasTerminal:e.term!==null||ll.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:rs}),n=t===`connecting`&&!rs&&Xc.has(e)?`live`:t;n===`none`?(delete e.card.dataset.link,pl()):(e.card.dataset.link=n,pl())}function pl(){for(let e of cl)e()}function ml(e,t,n){Qc(t,n),gs.unregister(e),t.dataWs=null,fl(t),t._resetGridClaim?.()}var hl=new WeakMap;function gl(e,t,r,i){ml(e,t,r),clearTimeout(hl.get(t)),hl.delete(t),i===0&&y()?El(e,t,r):hl.set(t,setTimeout(()=>{hl.delete(t),il(e,t)&&n().catch(()=>{}).then(()=>{il(e,t)&&El(e,t,r)})},i))}function _l(e,t){let n=Zc.has(e),r=!e.dataWs&&A.get(t)===e;return!(n||r)||!e.term||!tl(e,t)?!1:(Zc.delete(e),e._dataWsRetryAttempt=0,gl(t,e,e.term,0),!0)}function vl(e,t,n){ml(e,t,n),Zc.add(t)}var yl=15e3,bl=new Map;function xl(e){if(!y()||bl.has(e)||A.get(e)?.dataWs)return;let n=Is(e,!1,!1),r=new WebSocket(t(location,te(n)));r.binaryType=`arraybuffer`;let a=[],o=e=>a.push(e),s=()=>Sl(e,r),c=()=>{r.readyState===WebSocket.CONNECTING&&s()};r.addEventListener(`message`,o),r.addEventListener(`close`,s);let l=setTimeout(c,i),u=setTimeout(s,yl);bl.set(e,{socket:r,attachPath:n,bufferedMessages:a,release:()=>{r.removeEventListener(`message`,o),r.removeEventListener(`close`,s),clearTimeout(l),clearTimeout(u)}})}function Sl(e,t){let n=bl.get(e);n?.socket===t&&(bl.delete(e),n.release(),t.close())}function Cl(e,t){let n=bl.get(e);if(!n)return null;let r=n.socket.readyState===WebSocket.CONNECTING||n.socket.readyState===WebSocket.OPEN;return n.attachPath!==t||!r?(Sl(e,n.socket),null):(bl.delete(e),n.release(),n)}var wl=new WeakMap;function Tl(e,t,n){if(t.openedAtMs===null)return;let r=Math.round(performance.now()-t.openedAtMs);if(r>=1e3){wl.delete(e);return}let i=(wl.get(e)??0)+1;if(wl.set(e,i),!Ds.has(i))return;let a=n.wasClean?`clean`:`unclean`,o=t.hasReceivedBytes?`yes`:`no`;u(`terminal`,`fast close ${i}x, session ${t.sessionId}, code ${n.code}, reason '${n.reason}', ${a}, open ${r} ms, bytes ${o}, attach ${t.attachDescription}`)}function El(n,r,a){Zc.delete(r);let o=qc.get(r);qc.delete(r);let c=Jc.get(r);Jc.delete(r);let l=o!==void 0,u=o??c,d=!1,f=tl(r,n),p=Is(n,l,!f),m=Cl(n,p),h=m?.socket??new WebSocket(t(location,te(p)));el.set(h,f),h.binaryType=`arraybuffer`,r.dataWs=h,f&&qa(`terminal-connecting`),fl(r);let g=!1,_=!1,v={sessionId:n,attachDescription:Os({history:l?`deep`:`screen`,isOutputPaused:!f}),openedAtMs:null,hasReceivedBytes:!1},y={hasSeenSize:!1,lastSeq:0},ee=setTimeout(()=>{h.readyState===WebSocket.CONNECTING&&(_=!0,f&&qa(`terminal-abandoned`),h.close())},i);gs.register(n,(e,t)=>a.write(e,t));let ne=e=>{if(r.dataWs!==h)return;let t=Hs(e.data,y);if(t.kind===`bytes`){v.hasReceivedBytes=!0,$n(r),el.get(h)&&qa(`terminal-bytes`);let e=d;if(d=!1,gs.enqueue(n,t.data),!e)return;let i=u??0;gs.enqueueAction(n,()=>{a.scrollToLine(Math.max(0,a.buffer.active.length-i))});return}if(t.kind===`beat`){$n(r);return}if(t.kind===`attach-size`){d=u!==void 0,l||Yc.delete(r),y.hasSeenSize=!0,y.lastSeq=t.seq,a.reset(),Lc(a),r.ptySize={cols:t.cols,rows:t.rows},r._syncGrid?.();return}if(t.kind!==`size`)return;y.lastSeq=t.seq;let i={cols:t.cols,rows:t.rows};gs.enqueueAction(n,()=>{r.ptySize=i,r._syncGrid?.()})};h.addEventListener(`message`,ne),h.addEventListener(`close`,t=>{if(clearTimeout(ee),r.dataWs!==h)return;if(Tl(r,v,t),f&&!_&&qa(`terminal-closed`),Xc.delete(r),!g&&!_&&s(),!tl(r,n)){vl(n,r,a);return}if(_){gl(n,r,a,0);return}let i=e(r._dataWsRetryAttempt||0);r._dataWsRetryAttempt=(r._dataWsRetryAttempt||0)+1,gl(n,r,a,i)});let b=()=>{clearTimeout(ee),g=!0,v.openedAtMs=performance.now(),f&&qa(`terminal-opened`),r._dataWsRetryAttempt=0,Xc.delete(r),fl(r),nl(r,n),r._syncGrid?.({isActivationEdge:!0}),r._retryOwedGridClaim?.(),r._inputQueue?.length&&setTimeout(()=>{r.dataWs===h&&is(r)},50)};h.addEventListener(`open`,b),h.readyState===WebSocket.OPEN&&b();for(let e of m?.bufferedMessages??[])ne(e)}function Dl(e){let t=j(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,gl(e,t,t.term,0),n?.close()}function Ol(){for(let[e,t]of A)t.term&&(tl(t,e)?Dl(e):kl(e,t,t.term))}function kl(e,t,n){let r=t.dataWs;r&&(vl(e,t,n),r.close())}function Al(){for(let[e,t]of A)t.term&&kl(e,t,t.term)}function jl(e,t){let n=e.dataWs;e.dataWs=null,gs.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}var Ml=`CommitMono`,Nl=[400,700].map(e=>`${e} 14px ${Ml}`),Pl=`monospace`;function Fl(e){return e.trim().replace(/^['"]|['"]$/g,``)}function Il(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>Fl(e)!==Ml);return r.length>0?r.join(`, `):Pl}function Ll(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function Rl(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function zl(){return document.fonts?Nl.every(e=>document.fonts.check(e)):!1}function Bl(){return Il(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),zl())}function Vl(e){document.fonts&&Ll(document.fonts,Nl,e)}var Hl=qr(navigator.userAgent),Ul=`next-attention-keys`,Wl=Ar();function Gl(){return Wl}function Kl(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(O(`span`,`shortcut-sep`,`+`)),e.appendChild(O(`kbd`,`kbd`,t))})}function ql(e){let t=O(`span`,`shortcut-keys`);return Kl(t,e),t}function Jl(){let e=ql(Yr(`next-attention`,Hl,Wl));return e.classList.add(Ul),e}function Yl(e){Wl=e;let t=Yr(`next-attention`,Hl,e);for(let e of document.querySelectorAll(`.${Ul}`))e.replaceChildren(),Kl(e,t)}var Xl=x({title:S().optional(),iconDataUrl:S().startsWith(`data:image/`).optional()}),Zl=new Set([`http:`,`https:`]);function Ql(e){let t;try{t=new URL(e)}catch{return null}return Zl.has(t.protocol)?t.href:null}var $l=/\bElectron\/\d/,eu=new Set([`localhost`,`127.0.0.1`]);function tu(e){return $l.test(e)}function nu({userAgent:e,pageHostname:t}){return tu(e)&&eu.has(t)}function ru(e){return Ql(e)!==null}var iu=new Set([0,1]);function au({button:e,opensInNewTab:t}){return t&&iu.has(e)}function ou(){return nu({userAgent:navigator.userAgent,pageHostname:location.hostname})}function su(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function cu(e){try{let t=await n();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}}var lu=500,uu=new Map;async function du(e){try{let t=await n(),r=await fetch(`/link-preview`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})});if(!r.ok)return{};let i=Xl.safeParse(await r.json());return i.success?i.data:{}}catch{return{}}}function fu(e){return e.title!==void 0||e.iconDataUrl!==void 0}function pu(e){let t=uu.get(e);if(t)return t;let n=du(e).then(t=>(!fu(t)&&uu.get(e)===n&&uu.delete(e),t));if(uu.set(e,n),uu.size>lu){let e=uu.keys().next().value;e!==void 0&&uu.delete(e)}return n}function mu(e){!ou()||!ru(e)?su(e):cu(e).then(t=>{t||su(e)})}function hu(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&au({button:e.button,opensInNewTab:t.target===`_blank`})&&ru(t.href)&&(e.preventDefault(),mu(t.href))}function gu(e){ou()&&(e.addEventListener(`click`,hu,!0),e.addEventListener(`auxclick`,hu,!0))}var _u={phase:`hidden`,isPointerOnLink:!1,isPointerOnPopup:!1},vu=`*`,yu=/^[("'<[{]+|[)"'>\]}.,;:!?]+$/g,bu=new Set(`md.ts.tsx.js.jsx.mjs.cjs.json.py.rs.go.sh.txt.yml.yaml.toml.lock.html.css.rb.java.kt.swift.cs.php.sql.log.env.cfg.ini.xml.svg.png.jpg.gif.pdf.zip`.split(`.`)),xu=/^[a-z][a-z0-9+.-]*:\/\//i,Su=/\s/,Cu=/\.[a-z]{2,63}$/i,wu=/^www\./;function Tu(e){return!e.isPointerOnLink&&!e.isPointerOnPopup}function Eu(e){let t={...e,isPointerOnLink:!0};return e.phase===`shown`?{state:t,effects:[`cancel-hide`,`schedule-dwell`,`render`]}:e.phase===`pending`?{state:t,effects:[`schedule-dwell`]}:{state:{...t,phase:`pending`},effects:[`schedule-show`,`schedule-dwell`]}}function Du(e){let t={...e,isPointerOnLink:!1};return e.phase===`shown`&&Tu(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function Ou(e){let t={...e,isPointerOnPopup:!1};return e.phase===`shown`&&Tu(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function ku(e,t){switch(t){case`enter-link`:return Eu(e);case`leave-link`:return Du(e);case`enter-popup`:return{state:{...e,isPointerOnPopup:!0},effects:e.phase===`shown`?[`cancel-hide`]:[]};case`leave-popup`:return Ou(e);case`escape`:return e.phase===`hidden`?{state:e,effects:[]}:{state:{...e,phase:`hidden`,isPointerOnPopup:!1},effects:[`cancel-show`,`cancel-hide`,`cancel-dwell`,`remove`]};case`show-timer`:return e.phase===`pending`?e.isPointerOnLink?{state:{...e,phase:`shown`},effects:[`render`]}:{state:{...e,phase:`hidden`},effects:[]}:{state:e,effects:[]};case`hide-timer`:return e.phase!==`shown`||!Tu(e)?{state:e,effects:[]}:{state:{...e,phase:`hidden`},effects:[`remove`]};case`dwell-timer`:return e.phase!==`shown`||!e.isPointerOnLink?{state:e,effects:[]}:{state:e,effects:[`fetch-preview`]}}}function Au(e){let{linkRange:t,rows:n,cellWidthPx:r,cellHeightPx:i,popupHeightPx:a,popupWidthPx:o,screenWidthPx:s}=e,c=(t.endRow+1)*i,l=t.startRow*i-a,u=n*i-c,d=t.startRow*i,f=Math.max(0,s-o),p=Math.min(Math.max(0,t.startCol*r),f);return!(u>=a)&&(d>=a||d>u)?{side:`above`,leftPx:p,topPx:Math.max(0,l)}:{side:`below`,leftPx:p,topPx:c}}function ju(e){try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?null:t}catch{return null}}function Mu(e,t){let n=e.split(``);for(let e of t)n.fill(vu,e.start,e.end);return n.join(``)}function Nu(e,t){let n=ju(e);if(!n)return null;let r=n.username?`${n.username}${n.password?`:${n.password}`:``}@`:``,i=`${n.protocol}//${r}`,a=`${n.pathname===`/`&&!n.search&&!n.hash?``:n.pathname}${n.search}${n.hash}`;if(!t)return{scheme:i,host:n.host,rest:a};let o=Mu(`${i}${n.host}${a}`,sc(`${i}${n.host}${a}`)),s=i.length+n.host.length;return{scheme:o.slice(0,i.length),host:o.slice(i.length,s),rest:o.slice(s)}}function Pu(e){let t=e.trim().replace(yu,``);if(t.length===0||Su.test(t))return null;let n=ju(xu.test(t)?t:`https://${t}`);if(!n)return null;let r=n.hostname.replace(/\.$/,``);return!Cu.test(r)||!xu.test(t)&&bu.has(r.slice(r.lastIndexOf(`.`)+1).toLowerCase())?null:r}function Fu(e,t){let n=e.replace(wu,``),r=t.replace(wu,``);return n===r||n.endsWith(`.${r}`)||r.endsWith(`.${n}`)}function Iu(e,t){let n=ju(t);if(!n)return null;let r=Pu(e);if(!r)return null;let i=n.hostname.replace(/\.$/,``);return Fu(r,i)?null:{textHost:r,targetHost:i}}var Lu=100,Ru=150,zu=600,Bu=16,Vu=[`mousedown`,`mouseup`,`mousemove`,`click`,`dblclick`,`contextmenu`,`wheel`],Hu=!1;function Uu(e){Hu=e}function Wu(e){let t=O(`div`,`terminal-link-popup-url`),n=Nu(e,fc());return n?(t.append(O(`span`,`terminal-link-popup-url-dim`,n.scheme),O(`strong`,`terminal-link-popup-host`,n.host),O(`span`,`terminal-link-popup-url-dim`,n.rest)),t):(t.textContent=e,t)}function Gu(e){if(e.linkText===null)return null;let t=Iu(e.linkText,e.url);if(!t)return null;let n=O(`div`,`terminal-link-popup-mismatch`);return n.append(`Text says `,O(`strong`,null,t.textHost),`, goes to `,O(`strong`,null,t.targetHost)),n}function Ku(e,t){if(!e||e.url!==t)return null;let{title:n,iconDataUrl:r}=e.preview;if(!n&&!r)return null;let i=O(`div`,`terminal-link-popup-preview`);if(r){let e=O(`img`,`terminal-link-popup-icon`);e.src=r,e.alt=``,e.width=Bu,e.height=Bu,i.append(e)}return n&&i.append(O(`span`,`terminal-link-popup-title`,n)),i}function qu(e,t){let n=e.element,r=n?.querySelector(`.xterm-screen`);if(!n||!r)return{enterLink(){},leaveLink(){}};let i=n,a=r,o=t.abortController.signal,s=O(`div`,`xterm-hover terminal-link-popup`);s.hidden=!0,i.append(s);let c=_u,l=null,u=null,d=null,f=null,p=null,m=0;function h(){u!==null&&(clearTimeout(u),u=null)}function g(){d!==null&&(clearTimeout(d),d=null)}function _(){f!==null&&(clearTimeout(f),f=null)}function v(){let e=l?.url;Hu&&e&&pu(e).then(t=>{Hu&&(p={url:e,preview:t},c.phase===`shown`&&l?.url===e&&te())})}function y(e){e.key===`Escape`&&x(`escape`)}function ee(t){let n=a.getBoundingClientRect(),r=i.getBoundingClientRect(),o=e.buffer.active.viewportY;m=o;let c=Au({linkRange:{startRow:t.range.start.y-1-o,startCol:t.range.start.x-1,endRow:t.range.end.y-1-o},rows:e.rows,cellWidthPx:n.width/e.cols,cellHeightPx:n.height/e.rows,popupHeightPx:s.offsetHeight,popupWidthPx:s.offsetWidth,screenWidthPx:n.width});s.dataset.side=c.side,s.style.left=`${n.left-r.left+c.leftPx}px`,s.style.top=`${n.top-r.top+c.topPx}px`}function te(){let e=l;if(!e)return;let n=O(`div`,`terminal-link-popup-footer`);n.append(O(`span`,`terminal-link-popup-hint`,`Click to open`),T({variant:`secondary`,size:`small`,label:`Copy link`,onClick:()=>Xo(t,e.url,`link copy`,`Copied the link.`)}));let r=Gu(e);s.replaceChildren(...[Wu(e.url),r,Ku(Hu?p:null,e.url),n].filter(e=>e!==null)),s.hidden=!1,ee(e),document.addEventListener(`keydown`,y,{capture:!0,signal:o})}function ne(){s.hidden=!0,s.replaceChildren(),document.removeEventListener(`keydown`,y,{capture:!0})}let b={"schedule-show":()=>{h(),u=setTimeout(()=>{u=null,x(`show-timer`)},Lu)},"cancel-show":h,"schedule-hide":()=>{g(),d=setTimeout(()=>{d=null,x(`hide-timer`)},Ru)},"cancel-hide":g,"schedule-dwell":()=>{_(),f=setTimeout(()=>{f=null,x(`dwell-timer`)},zu)},"cancel-dwell":_,"fetch-preview":v,render:te,remove:ne};function x(e){let t=ku(c,e);c=t.state;for(let e of t.effects)b[e]()}for(let e of Vu)s.addEventListener(e,e=>e.stopPropagation(),{signal:o});s.addEventListener(`mouseenter`,()=>x(`enter-popup`),{signal:o}),s.addEventListener(`mouseleave`,()=>x(`leave-popup`),{signal:o});let S=e.onScroll(()=>{e.buffer.active.viewportY!==m&&x(`escape`)}),re=e.onResize(()=>x(`escape`));return o.addEventListener(`abort`,()=>{h(),g(),_(),S.dispose(),re.dispose(),s.remove()},{once:!0}),{enterLink(e){Co()||(l=e,x(`enter-link`))},leaveLink(){x(`leave-link`)}}}var Ju=/https?:\/\/[^\s<>"']+/g,Yu=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),Xu={")":`(`,"]":`[`,"}":`{`};function Zu(e,t){let n=0;for(let r of e)r===t&&n++;return n}function Qu(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(Yu.has(t)){e=e.slice(0,-1);continue}let n=Xu[t];if(n&&Zu(e,n)<Zu(e,t))e=e.slice(0,-1);else return e}}function $u(e){let t=[];for(let n of e.matchAll(Ju)){let e=Qu(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var ed=50;function td(e,t){return t.start.y===t.end.y?e.buffer.active.getLine(t.start.y-1)?.translateToString(!0,t.start.x-1,t.end.x)??null:null}function nd(e,t){return{activate(e,t){mu(t)},hover(n,r,i){t.enterLink({url:r,linkText:td(e,i),range:i})},leave(){t.leaveLink()},allowNonHttpProtocols:!1}}function rd(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<ed;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<ed;)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 id(e,t){let n=e.registerLinkProvider({provideLinks(n,r){let i=e.buffer?.active;if(!i)return r(void 0);let{text:a,cellAt:o}=rd(i,n),s=[];for(let{start:e,end:n,url:r}of $u(a)){let i=o[e],a=o[n-1];if(!i||!a)continue;let c={start:i,end:a};s.push({range:c,text:r,activate(e,t){mu(t)},hover(){t.enterLink({url:r,linkText:null,range:c})},leave(){t.leaveLink()}})}r(s.length?s:void 0)}}),r=ad(e);return{dispose(){r.dispose(),n.dispose()}}}function ad(e){let t=e.element?.querySelector(`.xterm-screen`);if(!t)return{dispose(){}};let n=null,r=e=>{e.isTrusted&&(n={clientX:e.clientX,clientY:e.clientY})},i=()=>{n=null},a=(e,n)=>{t.dispatchEvent(new MouseEvent(`mousemove`,{clientX:e,clientY:n,bubbles:!1}))};t.addEventListener(`mousemove`,r),t.addEventListener(`mouseleave`,i);let o=e.onRender(({start:r,end:i})=>{if(!n||t.classList.contains(`xterm-cursor-pointer`))return;let o=t.getBoundingClientRect(),s=o.height/e.rows;if(!(s>0))return;let c=Math.floor((n.clientY-o.top)/s);if(c<r||c>i)return;let l=c===0?s:-s;a(n.clientX,n.clientY+l),a(n.clientX,n.clientY)});return{dispose(){o.dispose(),t.removeEventListener(`mousemove`,r),t.removeEventListener(`mouseleave`,i)}}}var od=10,sd=1.2,cd=.005,ld=4,ud=.08,dd=5;function fd(e,t){let n=Math.abs(t);return n<od?!1:n>Math.abs(e)*sd}function pd(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 md(e,t,n){let r=e.length>=ld?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function hd(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>=ud))return 0;let o=Math.min(a,dd);return i<0?-o:o}function gd({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function _d(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)-cd*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=pd(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function vd(e,t){return e===`alternate`||!!t&&t!==`none`}function yd(e,t){return!(e>0)||!(t>0)?0:e/t}var bd=1;function xd(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function Sd(e,t){for(let n of e)if(n.identifier===t)return n;return null}function Cd(e,t){if(xd(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=()=>vd(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return yd(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:bd,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}=_d(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=gd({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=Sd(e.touches,r);if(!u)return;if(!s){if(!fd(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=md([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=md(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=pd(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=md(l,o,e.timeStamp);let t=hd(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function wd(e){let t=vr(e,Hl,{isTerminalFocused:!0},Gl());return t?Mr(t,document.body.dataset.activeView):!1}var Td=250,Ed=`(max-width: 768px)`,Dd=12,Od=14,kd=5e4,Ad=!1;function jd(e){Ad=e}var Md=!1;window.addEventListener(`blur`,()=>{Md=!0}),window.addEventListener(`focus`,()=>{Md=!1});function Nd(e){let t=document.activeElement;return Ns({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:Md,isPhoneLayout:Co()})}function Pd(e,t,n){let r=window.matchMedia?.(Ed).matches?Dd:Od,i=new n.Terminal({cursorBlink:Ad,fontSize:r,fontFamily:Bl(),theme:Oa(),scrollback:kd,allowProposedApi:!0}),a=new n.FitAddon;i.loadAddon(a),sl(e),i.open(e),$o(e,t,i);let o=qu(i,t);i.options.linkHandler=nd(i,o),id(i,o),Ic(i,t.abortController.signal),t.term=i,t.fitAddon=a,oo(t);let s=null,c=null,l=!1,u=null,d=null;function f(){c!==null&&(clearTimeout(c),c=null)}function p(){if(!l)return null;let e=t.fitAddon;if(!e)return null;let n=e.proposeDimensions();return n?{cols:n.cols,rows:n.rows}:null}function m(e){if(!l||!Nd(t.card)||t.dataWs?.readyState!==WebSocket.OPEN)return!1;t.dataWs.send(JSON.stringify({type:`claim`,cols:e.cols,rows:e.rows})),u=e,d=null;let n=Ms({authoritative:t.ptySize??null,isActiveViewer:l,lastClaim:u});return t.card.dataset.grid=n?`following`:`exact`,!0}function h(e){f(),d=e,c=setTimeout(()=>{c=null,m(e)},Td)}function g(){d&&c===null&&m(d)}function _({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=zs({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:p(),isActiveViewer:l,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:u});r.resizeTo&&n.resize(r.resizeTo.cols,r.resizeTo.rows),t.card.dataset.grid=r.isFollowing?`following`:`exact`,r.keepsPendingSettle||(f(),d=null),r.sendUnview?(u=null,t.dataWs?.send(JSON.stringify({type:`unview`}))):r.owedClaim&&(e&&m(r.owedClaim)||h(r.owedClaim))}function v(){let e=Ls({authoritative:t.ptySize??null,isActiveViewer:l,isDocumentEngaged:Nd(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:u});e!==`none`&&(f(),e===`rebid`&&(u=null),_({isActivationEdge:!0}))}let y=new ResizeObserver(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,_()}))});y.observe(e),t.resizeObserver=y,t._syncGrid=_,t._resetGridClaim=()=>{f(),d=Rs({isActiveViewer:l,lastClaim:u,owedClaim:d}),u=null},t._retryOwedGridClaim=g,t._syncGridOnEngagementEdge=v,t._isActiveViewer=()=>l,t._setActiveViewer=e=>{l!==e&&(l=e,f(),d=null,e&&co(t),_({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{Md=!1,v()},{signal:t.abortController.signal}),mo(t);let ee=null;i.onScroll(()=>{ee===null&&(ee=requestAnimationFrame(()=>{ee=null,t.term&&(t.term.refresh(0,t.term.rows-1),qo(t,t.term))}))}),i.onWriteParsed(()=>qo(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=Jo(r)}catch(e){return Yo(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(Xo(t,i,`osc52 write`),!0):(Zo(t,i),!0)});for(let e of[10,11])i.parser.registerOscHandler(e,e=>e.split(`;`).includes(`?`));i.attachCustomKeyEventHandler(e=>{if(e.shiftKey&&e.key===`Enter`)return e.type===`keydown`&&as(t,`\x1B\r`),!1;if(e.type!==`keydown`)return!0;if(wd(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),Xo(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(as(t,`\x1B`),!1):!0}),os(e,i,t),Cd(e,i)}function Fd(){ls(!0);for(let e of A.values())fl(e)}function Id(){ls(!1);for(let e of A.values())fl(e),is(e)}function Ld(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{as(e,n),e.unseenOutcome&&v({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{$c(e,t,n)}),cs(e.termWrap,t,e.abortController.signal),fl(e),queueMicrotask(()=>{il(t,e)&&El(t,e,n)}))}function Rd(e,t){if(e.term||ll.has(e))return;let n=eo();if(n){zd(e,t,n);return}ll.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},sl(e.termWrap),fl(e),to().then(n=>{ll.delete(e),!(e.term||e.abortController.signal.aborted||A.get(t)!==e)&&(zd(e,t,n),e._setActiveViewer?.(r))},()=>{ll.delete(e),fl(e)})}function zd(e,t,n){Pd(e.termWrap,e,n),Ld(e,t)}function Bd(e){e?._syncGridOnEngagementEdge?.()}function Vd(e,t){if(!e)return;Rd(e,t),nl(e,t),co(e);let n=e.term;n&&(n.refresh(0,n.rows-1),Bd(e))}function Hd(e,t,n){e&&(n&&Rd(e,t),e._setActiveViewer?.(n))}var Ud={isVisible:document.visibilityState===`visible`,isFrozen:!1,isProbing:!1,isReplacing:!1},Wd=document.visibilityState===`visible`?null:Date.now(),Gd=null,Kd=null;function qd(){Gd!==null&&window.clearTimeout(Gd),Gd=null}function Jd(e){qd();let t=Date.now()+e;Gd=window.setTimeout(()=>{Gd=null,Zd({kind:`heartbeat-due`,lateByMs:Date.now()-t})},e)}function Yd(){Kd!==null&&window.clearTimeout(Kd),Kd=null}function Xd(e){switch(e.kind){case`probe-control`:p(e.deadlineMs,e.isAnnounced).then(e=>{Zd({kind:e?`pong`:`pong-missed`})});return;case`replace-control`:g();return;case`close-sockets`:Yd(),_(),Al();return;case`reconnect-shown-terminals`:Ol();return;case`hold-input`:Fd();return;case`release-input`:Id();return;case`schedule-heartbeat`:Jd(e.inMs);return;case`cancel-heartbeat`:qd();return}}function Zd(e){let t=ee(Ud,e);Ud=t.state;for(let e of t.actions)Xd(e)}function Qd(){if(document.visibilityState!==`visible`){Wd=Date.now(),Zd({kind:`hidden`});return}let e=Wd===null?0:Date.now()-Wd;Wd=null,Ya(`shown`,e),Zd({kind:`shown`,hiddenForMs:e})}function $d(e){Yd(),qa(`control-${e}`),e===`connecting`?Kd=window.setTimeout(()=>{Kd=null,Zd({kind:`handshake-overdue`})},i):(e===`opened`&&ja(),Zd({kind:e===`opened`?`control-opened`:`control-closed`}))}function ef(){Ya(`resumed`,Wd===null?0:Date.now()-Wd),Zd({kind:`resumed`})}function tf(){let e=Reflect.get(navigator,`connection`);e instanceof EventTarget&&e.addEventListener(`change`,()=>{Ja(`link`),Zd({kind:`network-changed`})})}function nf(){r($d),document.addEventListener(`visibilitychange`,Qd),document.addEventListener(`freeze`,()=>Zd({kind:`frozen`})),document.addEventListener(`resume`,ef),window.addEventListener(`pagehide`,e=>{e.persisted&&Zd({kind:`frozen`})}),window.addEventListener(`pageshow`,e=>{e.persisted&&ef()}),window.addEventListener(`online`,()=>{Ja(`online`),Zd({kind:`network-changed`})}),window.addEventListener(`offline`,()=>Ja(`offline`)),tf()}var rf=!1,af=!1,of=!1,sf=null,cf=null;function lf(){return cf??=P(()=>import(`./nyan-cat-FdK_g6uh.js`).then(e=>e.r).then(e=>(sf=e,e),e=>(cf=null,u(`flying-animals`,`nyan cat failed to load: ${d(e)}`),null)),__vite__mapDeps([2,1,3,4,5,6,7,8])),cf}function uf(e){!of||e.currentFlightBlockReason(!0)?e.stopNyanCat():e.startNyanCat()}function df(){af=!0,ff(Jr())}function ff(e){let t=document.documentElement;rf||(rf=!0,wo(()=>ff(Jr())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>ff(Jr()))),of=e,e?(t.dataset.flyingAnimals=`true`,sf?uf(sf):af&&lf().then(e=>{e&&uf(e)})):(delete t.dataset.flyingAnimals,sf?.stopNyanCat())}var pf=45e3,mf=`The server did not answer within ${pf/1e3} s.`,hf=`Select the issue to load its description.`,gf=null,_f=null,vf=new Map,yf=null,bf=new Map,xf=new Map,Sf=null,I=new Map,Cf=new Map,wf=new Map,Tf=new Map,Ef=new Set;function L(e){for(let t of Ef)t(e)}function Df(e){return`${e.key}:${e.updatedAt}`}function Of(e){let t=bf.get(e);t&&(bf.delete(e),I.set(t.issueKey,{text:mf,tone:`error`}),L(`detail`))}function kf(e){let t=bf.get(e);return t?(clearTimeout(t.timeoutHandle),bf.delete(e),t):null}function Af(){return{latestStatus:_f,issueByKey:vf,selectedKey:gf}}function jf(e){Ef.add(e)}function Mf(e){gf=e,Sf&&Sf.issue.key!==e&&(Sf=null)}function Nf(){if(gf)return vf.get(gf)??(Sf?.issue.key===gf?Sf.issue:void 0)}function Pf(e){return Sf?.issue.key===e.key&&Sf.isClosed}function Ff(e){return[...xf.values()].some(t=>t.issue.key===e.key)}function If(e,t){if(Ff(e))return;let n=h(`set-issue-state`);yf?.({type:`set-issue-state`,requestId:n,repo:e.repo,issueNumber:e.number,state:t})?(xf.set(n,{issue:e,state:t,timeoutHandle:setTimeout(()=>{xf.delete(n),I.set(e.key,{text:mf,tone:`error`}),L(`detail`)},pf)}),I.set(e.key,{text:t===`closed`?`Closing issue.`:`Reopening issue.`,tone:`busy`}),L(`detail`)):(I.set(e.key,{text:je,tone:`error`}),L(`detail`))}function Lf(e){let t=xf.get(e.requestId);if(!t)return;clearTimeout(t.timeoutHandle),xf.delete(e.requestId);let{issue:n,state:r}=t;e.ok?(Sf={issue:n,isClosed:r===`closed`},I.set(n.key,{text:r===`closed`?`Closed as completed.`:`Reopened.`,tone:`ok`}),L(`detail`)):(I.set(n.key,{text:e.error||`Could not ${r===`closed`?`close`:`reopen`} the issue.`,tone:`error`}),L(`detail`))}function Rf(e){return[...bf.values()].some(t=>t.issueKey===e.key)}function zf(e){return I.get(e.key)}function Bf(e){let t=Df(e),n=wf.get(t);return n===``?`No description.`:n??Tf.get(t)??`Loading description.`}function Vf(e){let t=Df(e);if(wf.has(t)||[...Cf.values()].some(e=>e.cacheKey===t))return;let n=h(`issue-detail`);Tf.delete(t),yf?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?Cf.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{Cf.delete(n),Tf.set(t,`${mf} ${hf}`),L(`detail`)},pf)}):Tf.set(t,`${je} ${hf}`)}function Hf(e){let t=e.projectId;if(!t||Rf(e))return;let n=h(`open-issue-session`);yf?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(bf.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>Of(n),pf)}),I.set(e.key,{text:`Opening session.`,tone:`busy`}),L(`detail`)):(I.set(e.key,{text:je,tone:`error`}),L(`detail`))}function Uf(e){yf?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function Wf(e){yf=e}function Gf(){L(`session-state`)}function Kf(e){if(!e){for(let e of bf.values())clearTimeout(e.timeoutHandle),I.set(e.issueKey,{text:je,tone:`error`});bf.clear();for(let e of xf.values())clearTimeout(e.timeoutHandle),I.set(e.issue.key,{text:je,tone:`error`});xf.clear();for(let e of Cf.values())clearTimeout(e.timeoutHandle),Tf.set(e.cacheKey,`${je} ${hf}`);Cf.clear(),L(`status`)}}function qf(e){let t=_f?.issues.find(e=>e.key===gf);_f=e,vf=new Map(e.issues.map(e=>[e.key,e])),Sf&&!Sf.isClosed&&vf.has(Sf.issue.key)&&(Sf=null);let n=e.issues.find(e=>e.key===gf);n&&n.updatedAt!==t?.updatedAt&&Vf(n),L(`status`)}function Jf(e){let t=Cf.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),Cf.delete(e.requestId),e.ok&&e.body!==null&&wf.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&Tf.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),L(`detail`))}function Yf(e){if(typeof e.requestId!=`string`)return;let t=kf(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`;I.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=_f?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),L(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;I.set(n,{text:r,tone:`error`}),L(`detail`)}var Xf=new Map,Zf=new Set;function Qf(e){let t=Ee.safeParse(e);if(!t.success)u(`reviews`,`dropped github-prs: ${c(t.error.issues)}`);else{Xf=new Map(Object.entries(t.data.prs));for(let e of Zf)e()}}function $f(e){return Xf.get(e.toLowerCase())}function ep(e){Zf.add(e)}var tp=20,np=[],rp=null,ip=!1,ap=0,op=null;function sp(){return op??=P(()=>import(`./celebration-player-BX0kw6fZ.js`),__vite__mapDeps([9,3,4,5,6,7,10])).catch(e=>(op=null,u(`merge-celebration`,`celebration player failed to load: ${d(e)}`),null)),op}function cp(e){return ip?`playing`:e?`queued`:`empty`}function lp(){if(!rp)return;let e=np.length>0,t=cp(e);rp.tray.dataset.state=t,rp.count.textContent=e?String(np.length):``,rp.toggle.element.disabled=t!==`queued`,rp.toggle.setState(t===`queued`?`attention`:`idle`)}function up(){let e=np.shift();if(ip=e!==void 0,lp(),!e)return;let t=ap;ap+=1,sp().then(n=>{n?(n.playCelebration(e,t),window.setTimeout(up,n.CELEBRATION_DURATION_MS)):(np.unshift(e),ip=!1,lp())})}function dp(e,t,n){rp={tray:e,toggle:t,count:n},t.element.addEventListener(`click`,()=>{ap=0,up()}),lp()}function fp(e){np.push(e),np.length>tp&&np.shift(),lp()}var pp={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},mp=new Set([`FAILURE`,`ERROR`]);function hp(e){return pp[e]}function gp(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&&mp.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function _p(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 vp(e){let t=dt.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:_p(t)}}var yp=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],bp=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],xp={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`},Sp={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`},Cp={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`},wp={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 Tp(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})}let i=Math.max(...e.map(e=>e.depth+1));a.push({root:t,rows:e.map(t=>({...t,stackSize:e.length,stackHeight:i}))})}return a}function Ep(e){return yp[e.rows.reduce((e,{pr:t})=>Math.min(e,yp.indexOf(xp[t.stage])),yp.length-1)]}function Dp(e){let t=new Map(yp.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of Tp(e)){let e=t.get(Ep(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return bp.flatMap(e=>t.get(e)??[])}function Op(e,t){return Tp(e).find(e=>e.rows.some(e=>e.pr.key===t))?.rows??[]}function kp(e){return e.stackSize<2?null:`Stack ${e.depth+1}/${e.stackHeight}`}function Ap(e){return Sp[e]}function jp(e){return Cp[e]}function Mp(e){return wp[e]}function Np(e){return e?.isKeepMergeableEnabled!==!1}function Pp(e,t){if(!t||!e.keepMergeable||e.isKeepMergeableFixInFlight)return!1;let n=e.keepMergeableAttempt?.outcome;return n!==void 0&&n!==`pushed`&&n!==`stopped`}function Fp(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...vp({...n,repo:r}),...e}]})}function Ip(e){let t=new Map;for(let n of e)for(let e of n.links){let r=Xe(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 Lp(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 Rp=3;function zp(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,Rp).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}}function Bp(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:he(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,isAuthorOrgMember:n.isAuthorOrgMember,liveHead:n.headRefOid,prStage:vp(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n)}}var Vp=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`];function Hp(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`}}function Up(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function Wp(e){return e.status===`posted`&&Gp(e)}function Gp(e){if(!Up(e)||jt(e))return!1;let t=Xp(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 Kp(e){return Zp(e).length>0||Wp(e)}function qp(e){return Kp(e)?`actionable`:Hp(e).band}function Jp(e){let t={ready:[],noReviewNeeded:[],inReview:[],queued:[],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=new Set(e.inFlight.map(e=>e.key));t.inReview.push(...e.inFlight);for(let t of e.queued)i.has(t.key)||r[Hp(t).band].push(t);for(let e of Vp)t.queued.push(...r[e]);let a=new Set(t.queued.map(e=>e.key));for(let r of e.drafts){if(i.has(r.key)||a.has(r.key))continue;if(Kp(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!Qp(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[qp(r)].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 Vp)t.ready.push(...n[e]);return t}function Yp(e,t){return e.commit===t?e.isViewer||It.has(e.state):!1}function Xp(e){return e.liveHead??e.reviewedHead}function Zp(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function Qp(e){return Zp(e).length>0?!0:jt(e)?!1:Gp(e)?!0:!(e.githubReviews??[]).some(t=>Yp(t,Xp(e)))}function $p(e,t){return`${e}#${t}`}var em=null,tm={},nm=[],rm=[],im={},am={},om=[],sm={},cm={},lm={},um=null,dm=new Set,fm=new Map,pm=!1,mm=new Set;function hm(e){for(let t of mm)t(e)}function gm(){return[...fm].flatMap(([e,t])=>{let n=A.get(e);return!n||t.length===0?[]:[{id:e,title:kn(n)||e,links:t}]})}function _m(){let e=Fp(em?.prs??[],$f),t=Lp(um,e);um=e,xm(t),hm({kind:`prs`})}function vm(){pm||(pm=!0,queueMicrotask(()=>{pm=!1,_m()}))}function ym(e){mm.add(e)}function bm(){return{prs:Fp(em?.prs??[],$f).map(e=>({...e,reviewItems:am[e.key]??e.reviewItems})),status:em,sessionsByPrKey:Ip(gm()),handledByPr:tm,prFlowWarnings:nm,prFlowApprovals:rm,sourceRunsByPr:im,prFlowActions:om,actionRunsByPr:sm,prActionsByPr:cm,prActionRunsByPr:lm}}function xm(e){let t=e.filter(e=>!dm.has(e.key));if(t.length!==0){for(let e of t)dm.add(e.key);fp(zp(t))}}function Sm(e){fm=e,vm()}function Cm(){hm({kind:`session-state`})}function wm(e){let t=$e.safeParse(e);t.success?(em=t.data,_m()):u(`reviews`,`dropped my-prs-status: ${c(t.error.issues)}`)}function Tm(e){let t=gt.safeParse(e);t.success?(tm=t.data.handledByPr,nm=t.data.warnings,rm=t.data.pendingApprovals,im=t.data.sourceRunsByPr,am=t.data.reviewItemsByPr,om=t.data.actions,sm=t.data.actionRunsByPr,cm=t.data.prActionsByPr,lm=t.data.prActionRunsByPr,hm({kind:`prs`})):u(`reviews`,`dropped pr-flows-status: ${c(t.error.issues)}`)}function Em(e){hm({kind:`merge-result`,message:e})}function Dm(e){hm({kind:`connection`,isConnected:e})}ep(vm);var Om=new Map([{state:`mine-repair-failed`,group:`turn`,kind:`failed`,action:`fix`},{state:`review-failed`,group:`turn`,kind:`failed`,action:`fix`},{state:`review-direct-ask`,group:`turn`,kind:`waiting`,action:`review`},{state:`review-ready`,group:`turn`,kind:`waiting`,action:`review`},{state:`review-stale`,group:`turn`,kind:`waiting`,action:`review`},{state:`review-follow-up`,group:`turn`,kind:`waiting`,action:`reply`},{state:`mine-changes-requested`,group:`turn`,kind:`waiting`,action:`reply`},{state:`mine-unresolved-threads`,group:`turn`,kind:`waiting`,action:`reply`},{state:`mine-behind`,group:`turn`,kind:`waiting`,action:`update`},{state:`mine-checks-failing`,group:`turn`,kind:`waiting`,action:`update`},{state:`mine-conflicts`,group:`turn`,kind:`waiting`,action:`update`},{state:`mine-ready`,group:`turn`,kind:`finished`,action:`merge`},{state:`mine-repairing`,group:`working`,kind:null,action:null},{state:`mine-agent-fixing`,group:`working`,kind:null,action:null},{state:`review-in-flight`,group:`working`,kind:null,action:null},{state:`review-queued`,group:`working`,kind:null,action:null},{state:`review-settled`,group:`waiting`,kind:null,action:null},{state:`review-posted`,group:`waiting`,kind:null,action:null},{state:`mine-checks-pending`,group:`waiting`,kind:null,action:null},{state:`mine-needs-approval`,group:`waiting`,kind:null,action:null},{state:`mine-unknown`,group:`waiting`,kind:null,action:null},{state:`review-discarded`,group:`aside`,kind:null,action:null},{state:`mine-draft`,group:`aside`,kind:null,action:null},{state:`mine-merged`,group:`aside`,kind:null,action:null}].map((e,t)=>[e.state,{...e,rank:t}])),km={turn:`Your turn`,working:`Agent working`,waiting:`Waiting on others`,aside:`Set aside`},Am=[`turn`,`working`,`waiting`,`aside`],jm={conflicts:`mine-conflicts`,behind:`mine-behind`,"checks-failing":`mine-checks-failing`,"changes-requested":`mine-changes-requested`,"unresolved-threads":`mine-unresolved-threads`,ready:`mine-ready`,"checks-pending":`mine-checks-pending`,"needs-approval":`mine-needs-approval`,unknown:`mine-unknown`,draft:`mine-draft`,merged:`mine-merged`},Mm={settled:`review-settled`,inReview:`review-in-flight`,queued:`review-queued`,posted:`review-posted`,discarded:`review-discarded`},Nm=Vp.indexOf(`waiting-on-author`);function Pm(e){return e.status===`ready`?Hp(e).band===`blocking-others`?`review-direct-ask`:`review-ready`:`review-follow-up`}function Fm(e,t){return t===`ready`?Pm(e):t===`attention`?`status`in e&&e.status===`error`?`review-failed`:`review-stale`:Mm[t]}function Im(e,t,n){let r=e.state===`OPEN`;if(r&&Pp(e,n))return`mine-repair-failed`;if(r&&n&&e.keepMergeable&&e.isKeepMergeableFixInFlight)return`mine-repairing`;let i=jm[e.stage];return Om.get(i)?.group===`turn`&&e.stage!==`ready`&&t.has(Xe(e))?`mine-agent-fixing`:i}function Lm(e,t){return t===`ready`||t===`attention`?Vp.indexOf(qp(e)):t===`queued`?Vp.indexOf(Hp(e).band):0}function Rm(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function zm(e){let t=Zp(e).flatMap(e=>Rm(e.lastReplyAt)??[]);return t.length>0?Math.max(...t):null}function Bm(e,t){if(t===`inReview`)return Rm(e.startedAt)??1/0;if(t===`queued`)return Rm(e.prCreatedAt)??1/0;let n=e;return zm(n)??Rm(n.reviewedAt)??Rm(n.prCreatedAt)??1/0}function Vm(e){return Rm(e.mergedAt??e.stageSinceMs??e.updatedAt)??1/0}function Hm(e,t,n,r){let i=Om.get(e);return i?[{item:r(i),row:i,priorityBandRank:t,waitStartMs:n}]:[]}function Um(e){return[[`ready`,e.ready],[`attention`,e.attention],[`inReview`,e.inReview],[`queued`,e.queued],[`settled`,e.noReviewNeeded],[`posted`,e.posted],[`discarded`,e.discarded]].flatMap(([e,t])=>t.flatMap(t=>Hm(Fm(t,e),Lm(t,e),Bm(t,e),({action:n,kind:r})=>({source:`team`,key:`team:${t.key}`,prKey:Xe(t),kind:e,review:t,action:n,attention:r}))))}function Wm(e,t,n){return Dp(e).flatMap(e=>e.rows).flatMap(e=>Hm(Im(e.pr,t,n),0,Vm(e.pr),({action:t,kind:n})=>({source:`mine`,key:`mine:${e.pr.key}`,prKey:Xe(e.pr),pr:e.pr,stackRow:e,action:t,attention:n})))}function Gm(e){return e.row.kind===`failed`?0:e.row.state===`review-direct-ask`?1:e.priorityBandRank>=Nm?3:2}function Km(e,t){let n=e.waitStartMs-t.waitStartMs;return e.row.group===`turn`?Gm(e)-Gm(t)||n||e.item.key.localeCompare(t.item.key):e.row.rank-t.row.rank||e.priorityBandRank-t.priorityBandRank||n}function qm(e,t,n,r){let i=new Map(Am.map(e=>[e,[]]));for(let a of[...Um(e),...Wm(t,n,r)])i.get(a.row.group)?.push(a);return Am.map(e=>({id:e,title:km[e],items:(i.get(e)??[]).toSorted(Km).map(e=>e.item)}))}var Jm=[`turn`,`working`,`aside`],Ym=new Map([{state:`error`,group:`turn`,kind:`failed`},{state:`ready-HIGH`,group:`turn`,kind:`finished`},{state:`ready-MEDIUM`,group:`turn`,kind:`finished`},{state:`ready-LOW`,group:`turn`,kind:`finished`},{state:`ready`,group:`turn`,kind:`finished`},{state:`running`,group:`working`,kind:null},{state:`queued`,group:`working`,kind:null},{state:`aside`,group:`aside`,kind:null}].map((e,t)=>[e.state,{...e,rank:t}]));function Xm(e){return e.status===`ready`&&e.verdict?`ready-${e.verdict}`:e.status}function Zm(e){let t=Date.parse(e.item.createdAt);return Number.isNaN(t)?1/0:t}function Qm(e){let t=e.flatMap(e=>{let t=Ym.get(Xm(e));return t?[{row:t,askedAtMs:Zm(e),item:{source:`community`,key:e.item.key,entry:e,attention:t.kind}}]:[]}).toSorted((e,t)=>e.row.rank-t.row.rank||e.askedAtMs-t.askedAtMs);return Jm.map(e=>({id:e,title:km[e],items:t.filter(t=>t.row.group===e).map(e=>e.item)}))}function $m(e){return`${e.key}@${e.entry.status}:${e.entry.finishedAt??``}`}function eh(e){return e.find(e=>e.id===`turn`)?.items??[]}function th(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function nh(e,t){return th(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function rh(e){return e.source===`mine`?$p(e.pr.repo,e.pr.number):$p(e.review.repo,e.review.number)}function ih(e,t){return eh(e).map(e=>({id:e.key,kind:e.attention??`waiting`,name:t(e)}))}function ah(e){return ih(e,rh)}function oh(e,t){return ah(e).filter(e=>e.id!==t)}function sh({capturedOrder:e,actedKey:t,groups:n}){let r=eh(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 ch(e,t){let n=eh(e).map(e=>e.key),r=t?n.indexOf(t):-1;return r===-1?``:`${r+1} of ${n.length} in Your turn`}function lh(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 uh(e){return eh(e).map(lh)}function dh({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:et([...i]),unseen:et([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:et([...a]),unseen:et([...o])}}function fh(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 ph(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function mh(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 hh=new Map([[`j`,`next-row`],[`k`,`previous-row`],[`n`,`next-finding`],[`p`,`previous-finding`],[`x`,`toggle-finding`],[`o`,`open-session`],[`a`,`pick-approve`],[`r`,`pick-request-changes`],[`c`,`pick-comment`]]);function gh(e){return e.key===`Enter`&&e.metaKey!==e.ctrlKey&&!e.altKey&&!e.shiftKey?`post`:e.metaKey||e.ctrlKey||e.altKey||e.shiftKey?null:e.key===`Escape`?`cancel`:hh.get(e.key)??null}function _h(e,t,n){if(e.length===0)return null;let r=t===null?-1:e.indexOf(t);return r===-1?n===1?e[0]:e[e.length-1]:e[Math.min(e.length-1,Math.max(0,r+n))]}var vh=null,yh=null,bh=new Set;function xh(e){for(let t of bh)t(e)}function Sh(){yh=Bp(vh,$f),xh({kind:`status`})}function Ch(e){bh.add(e)}function wh(){return yh}function Th(){return Jp(yh)}function Eh(e){let t=Pt.safeParse(e);t.success?(vh=t.data,Sh()):u(`reviews`,`dropped team-review-status: ${c(t.error.issues)}`)}function Dh(e){xh({kind:`action-result`,message:e})}function Oh(e){xh({kind:`open-session-result`,message:e})}function kh(e){xh({kind:`connection`,isConnected:e})}ep(Sh);var Ah=[],jh=null,Mh=null,Nh=null,Ph=!1,Fh=null,Ih=Ur(),Lh=Cr(),Rh=new Set(Lh.split(`|`).filter(Boolean)),zh=new Set,Bh=new Set;function Vh(e){for(let t of Bh)t(e)}function Hh(e){e!==Ih&&(Ih=e,mr(e))}function Uh(e){e!==Lh&&(Lh=e,Rh=new Set(e.split(`|`).filter(Boolean)),ur(e))}function Wh(){return wh()!==null&&bm().status!==null}function Gh(){if(!Wh())return;let e=dh({turnEntries:uh(Ah),acknowledged:Ih,unseen:Lh,isLooking:Mh?.isLooking()??!1});Hh(e.acknowledged),Uh(e.unseen),Fh?.(e.isShown)}function Kh(e){Nh=e,Vh({kind:`reveal`})}function qh(e){Bh.add(e)}function Jh(e){Mh=e,Gh()}function Yh(){let{prs:e,sessionsByPrKey:t,status:n}=bm();return Ah=qm(Th(),e,new Set(t.keys()),Np(n)),Gh(),Ah}function Xh(){Wh()&&(Hh(et(uh(Ah))),Gh())}function Zh(e){Fh=e,Gh()}function Qh(){return Lh}function $h(e){return Rh.has(e)}function eg(e){return Rh.has(e)?(Uh(et([...Rh].filter(t=>t!==e))),!0):!1}function tg(e){jh=e}function ng(){return jh}function rg(){let e=Nh;return Nh=null,e}function ig(e){if(e!==Ph){Ph=e;for(let e of zh)e()}}function ag(e){zh.add(e)}function og(){return document.documentElement.dataset.layout===`phone`&&Ph}function sg(){og()&&Vh({kind:`return-to-queue`})}function cg(){let e=oh(Ah,Mh?.selectedKey()??null)[0]?.id??null;return e?(Kh(e),!0):!1}function lg(e){let t=Ah.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!jh?.openReviews()?!1:(Kh(t.key),Xh(),!0)}Ch(e=>{e.kind===`status`&&Yh()}),ym(e=>{e.kind===`prs`&&Yh()});function ug(){return{groups:Ah}}var dg={OPEN:0,MERGED:1,CLOSED:2};function fg(e){return e?dg[e.state]:dg.OPEN}function pg(e,t){let n=`${e.repo}#${e.number}`,r=`#${e.number}`;if(!t)return{key:n,text:r,detailText:r,stateText:``,url:e.url,prTitle:``,look:null,tier:rn(void 0)};let i=jp(t.stage);return{key:n,text:r,detailText:`${r} ${t.title}`,stateText:Ap(t.stage),url:t.url,prTitle:t.title,look:{icon:Mp(t.stage),tone:i},tier:rn(i)}}function mg(e,t){let n=e.map(e=>{let n=t(Xe(e));return{link:e,pr:n?vp(n):void 0}});return n.sort((e,t)=>fg(e.pr)-fg(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>pg(e,t))}var hg=new Map;function gg(e){return document.querySelectorAll(`[data-pr-rows-for="${CSS.escape(e)}"]`)}function _g(e){return mg(hg.get(e)??[],$f).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,onActivate:()=>{lg(e.key)||mu(e.url)}}))}function vg(e,t){let n=tt(`session-pr-chip-unlink`);return n.append(w(Dt)),n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),Qt({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:()=>{di(t,{type:`unlink-session-pr`,id:t,key:e.key})}})}),n}function yg(e,t){let n=hn({...e,text:e.key},{...e,className:`linked-pr-row-link`});e.prTitle&&n.append(O(`span`,`linked-pr-row-title`,e.prTitle)),e.stateText&&n.append(O(`span`,`linked-pr-row-stage`,e.stateText));let r=O(`li`,`linked-pr-row`);return r.append(n,vg(e,t)),r}function bg(e,t){e.dataset.prRowsFor=t;let n=_g(t);Cn(e,n,e=>yg(e,t),{visibleCount:n.length})}function xg(e){for(let t of e){let e=t.dataset.prRowsFor;e&&bg(t,e)}}function Sg(e,t){let n=kt.shape.links.safeParse(t??[]);hg.set(e,n.success?n.data:[]),xg(gg(e)),xn(e),Sm(hg)}function Cg(e){hg.delete(e),Sm(hg)}ep(()=>{xg(document.querySelectorAll(`[data-pr-rows-for]`)),vn()});function R(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function wg(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function Tg(e,t){return e||wg(t)>0}var Eg={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},Dg=null,Og=!1,kg=!1,Ag=null,jg=null,Mg=null,Ng=`—`;function Pg(e){return e==null?Ng:it(e,`GB`)}function Fg(e){return e==null?Ng:ye(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function Ig(e){return e==null?Ng:`${Fg(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function Lg(){let e=O(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=O(`div`,`health-summary`),n=tt(`health-toggle`);n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=O(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,O(`span`,`health-toggle-label`,`Health`));let i=O(`div`,`health-stats`);t.append(n,i);let a=O(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{kg=!kg,e.dataset.expanded=String(kg),n.setAttribute(`aria-expanded`,String(kg)),a.hidden=!kg,kg&&(v({type:`request-health-snapshot`}),zg())}),e.append(t,a),Ag=e,jg=i,Mg=a,e}function Rg(){if(!jg||!Dg)return;let e=Dg,t=wg(e.anomalies);jg.innerHTML=`
|
|
3
|
-
<span class="health-stat"><span class="health-stat-label">Heap</span> ${Pg(e.process.heapUsed)}</span>
|
|
4
|
-
<span class="health-stat"><span class="health-stat-label">Memory</span> ${Pg(e.process.rss)}</span>
|
|
5
|
-
<span class="health-stat"><span class="health-stat-label">Buffers</span> ${Pg(e.process.external)}</span>
|
|
6
|
-
<span class="health-stat"><span class="health-stat-label">Handles</span> ${e.process.activeResources}</span>
|
|
7
|
-
<span class="health-stat"><span class="health-stat-label">Headroom</span> ${Pg(e.memoryGate?.headroomBytes)} / ${e.memoryGate?.heldStartCount??0} held</span>
|
|
8
|
-
<span class="health-stat"><span class="health-stat-label">Sessions</span> ${e.sessions.alivePty}/${e.sessions.total}</span>
|
|
9
|
-
<span class="health-stat"><span class="health-stat-label">Sockets</span> ${e.websockets.control}+${e.websockets.data}</span>
|
|
10
|
-
<span class="health-stat"><span class="health-stat-label">Uptime</span> ${Fg(e.uptimeSeconds)}</span>
|
|
11
|
-
${t>0?`<span class="health-anomaly">${t} ${t===1?`anomaly`:`anomalies`}</span>`:``}
|
|
12
|
-
`}function zg(){if(!Mg||!Dg)return;let e=Dg,t=e.process,n=e.websockets,r=e.sessions,i=e.anomalies,a=``;if(wg(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=`
|
|
13
|
-
<div class="health-section health-section-warn">
|
|
14
|
-
<div class="health-section-title">⚠ Anomalies</div>
|
|
15
|
-
${e.map(e=>`<div class="health-row">${e}</div>`).join(``)}
|
|
16
|
-
</div>
|
|
17
|
-
`}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`
|
|
18
|
-
<tr>
|
|
19
|
-
<td>${R(e.name)}</td>
|
|
20
|
-
<td class="health-mono">${Eg[e.state]||e.state}</td>
|
|
21
|
-
<td class="health-mono">${e.hasPty?e.ptyPid:Ng}</td>
|
|
22
|
-
<td class="health-mono">${Pg(e.outputBufferBytes)}</td>
|
|
23
|
-
<td class="health-mono">${e.outputBufferEntries}</td>
|
|
24
|
-
<td class="health-mono">${e.dataListenerCount}</td>
|
|
25
|
-
<td class="health-mono health-dim">${n}</td>
|
|
26
|
-
<td class="health-mono health-dim">${t.join(` `)||``}</td>
|
|
27
|
-
</tr>
|
|
28
|
-
`}).join(``);Mg.innerHTML=`
|
|
29
|
-
${a}
|
|
30
|
-
<div class="health-section">
|
|
31
|
-
<div class="health-section-title">Process</div>
|
|
32
|
-
<div class="health-grid">
|
|
33
|
-
<div class="health-row"><span class="health-label">Heap used</span><span class="health-mono">${Pg(t.heapUsed)}</span></div>
|
|
34
|
-
<div class="health-row"><span class="health-label">Heap total</span><span class="health-mono">${Pg(t.heapTotal)}</span></div>
|
|
35
|
-
<div class="health-row"><span class="health-label">RSS</span><span class="health-mono">${Pg(t.rss)}</span></div>
|
|
36
|
-
<div class="health-row"><span class="health-label">External</span><span class="health-mono">${Pg(t.external)}</span></div>
|
|
37
|
-
<div class="health-row"><span class="health-label">Array buffers</span><span class="health-mono">${Pg(t.arrayBuffers)}</span></div>
|
|
38
|
-
<div class="health-row"><span class="health-label">Active resources</span><span class="health-mono">${t.activeResources}</span></div>
|
|
39
|
-
<div class="health-row"><span class="health-label">Uptime</span><span class="health-mono">${Fg(e.uptimeSeconds)}</span></div>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
|
|
43
|
-
<div class="health-section">
|
|
44
|
-
<div class="health-section-title">Memory gate</div>
|
|
45
|
-
<div class="health-grid">
|
|
46
|
-
<div class="health-row"><span class="health-label">Headroom</span><span class="health-mono">${Pg(e.memoryGate?.headroomBytes)}</span></div>
|
|
47
|
-
<div class="health-row"><span class="health-label">Read</span><span class="health-mono">${Ig(e.memoryGate?.headroomReadAtMs)}</span></div>
|
|
48
|
-
<div class="health-row"><span class="health-label">Starts held</span><span class="health-mono">${e.memoryGate?.heldStartCount??0}</span></div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
<div class="health-section">
|
|
53
|
-
<div class="health-section-title">WebSockets</div>
|
|
54
|
-
<div class="health-grid">
|
|
55
|
-
<div class="health-row"><span class="health-label">Control clients</span><span class="health-mono">${n.control}</span></div>
|
|
56
|
-
<div class="health-row"><span class="health-label">Data clients</span><span class="health-mono">${n.data}</span></div>
|
|
57
|
-
<div class="health-row"><span class="health-label">Tracked per session</span><span class="health-mono">${n.dataPerSessionTotal}</span></div>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<div class="health-section">
|
|
62
|
-
<div class="health-section-title">Sessions (${r.total} total · ${r.alivePty} alive PTY)</div>
|
|
63
|
-
<div class="health-row health-dim">Listeners ${r.totalDataListeners} · Output buffer ${Pg(r.totalOutputBufferBytes)}</div>
|
|
64
|
-
<table class="health-table">
|
|
65
|
-
<thead>
|
|
66
|
-
<tr>
|
|
67
|
-
<th>Name</th><th>State</th><th>PID</th><th>Buffer</th><th>Entries</th><th>Listeners</th><th>Timers</th><th>Flags</th>
|
|
68
|
-
</tr>
|
|
69
|
-
</thead>
|
|
70
|
-
<tbody>${o||`<tr><td colspan="8" class="health-dim">No sessions</td></tr>`}</tbody>
|
|
71
|
-
</table>
|
|
72
|
-
</div>
|
|
73
|
-
`}function Bg(){if(!Ag)return;let e=Tg(Og,Dg?.anomalies),t=Ag.hidden;Ag.hidden=!e,e&&t&&Dg&&(Rg(),kg&&zg())}function Vg(e){Og=e,Bg()}function Hg(e){if(Ag)return Ag;let t=Lg();return e.appendChild(t),Bg(),t}function Ug(e){Dg=e,Bg(),Ag&&!Ag.hidden&&(Rg(),kg&&zg())}var Wg=null,Gg=null,Kg=!1,qg=null,Jg=new Set;function Yg(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function Xg(){for(let e of Jg)e()}function Zg(){return{report:Wg,hasReportSendFailed:Kg}}function Qg(e){Jg.add(e)}function $g(e){Gg=e}function e_(){if(!Gg)return;qg=h(`hooks-report`);let e=Gg({type:`request-hooks-report`,requestId:qg});e!==!Kg&&(Kg=!e,Xg())}function t_(e){Yg(e,qg)&&(Wg=e,Kg=!1,Xg())}function n_(){e_()}var r_=new Map;function i_(e){return r_.get(e)??[]}function a_(e){return i_(e).length>0}function o_(e){let t=j(e)?.btnDocs;t&&(t.hidden=!a_(e))}var s_=null,c_=null;function l_(){return c_??=P(()=>import(`./doc-editor-ui-CrshwKCN.js`).then(e=>(s_=e,e),e=>(c_=null,u(`doc-editor`,`doc editor failed to load: ${d(e)}`),null)),__vite__mapDeps([11,12,13,5,3,14,15,16,17])),c_}function u_(e){l_().then(t=>t?.openDocEditor(e))}function d_(e){s_?.applyDocsToOpenEditor(e)}function f_(e){r_.set(e.id,e.docs),e.docs.length===0&&r_.delete(e.id),o_(e.id),d_(e.id)}function p_(e){let t=[...r_.keys()];r_.clear();for(let[t,n]of Object.entries(e.sessions))r_.set(t,n);for(let e of new Set([...t,...r_.keys()]))o_(e),d_(e)}var m_=10,h_={low:0,medium:1,high:2};function g_(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 __(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.`);let p=`link:${i.providerRepo}:${i.packageName}:${e.name}`;n.push({dedupeKey:p,groupKey:p,kind:`link`,severity:6,path:s,openPath:`${c.sessionPathPrefix}${s}`,heading:`${e.name} imports ${i.packageName} from ${i.providerRepo} in ${i.importerCount} ${l}`,detail:f,conflictRisk:null})}for(let t of e.collisions)n.push({dedupeKey:`collision:${e.sessionPathPrefix}${t.path}:${t.otherSessionId}`,groupKey:`collision:${t.otherSessionId}`,kind:`collision`,severity:5,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,heading:`Also being changed in "${t.otherSessionName}"`,detail:t.conflictEvidence,conflictRisk:t.conflictRisk});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}`,groupKey:`co-change:${e.sessionPathPrefix}${t.partner}`,kind:`co-change`,severity:4,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,heading:`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}.`,conflictRisk:null})}return n}function v_(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function y_(e,t){for(let n of e.hotspots)v_(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`});for(let n of e.blastRadius)n.transitiveDependentCount<m_||v_(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`})}function b_(e,t){return e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function x_(e){return e.conflictRisk===null?-1:h_[e.conflictRisk]}function S_(e,t){return t.severity-e.severity||x_(t)-x_(e)||e.heading.localeCompare(t.heading)||e.groupKey.localeCompare(t.groupKey)}function C_(e,t){return e===null||t===null?e??t:h_[t]>h_[e]?t:e}function w_(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?(e.lines.push(n),e.conflictRisk=C_(e.conflictRisk,n.conflictRisk)):t.set(n.groupKey,{groupKey:n.groupKey,kind:n.kind,severity:n.severity,heading:n.heading,conflictRisk:n.conflictRisk,lines:[n]})}let n=[...t.values()];for(let e of n)e.lines.sort(b_);return n.sort(S_)}function T_(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:g_(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of __(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);y_(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:w_(r.values()),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function E_(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}function D_(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 O_(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=D_(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 k_(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function A_(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 j_({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=N_(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 M_({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?j_({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 N_(e){return e||`base`}function P_(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function F_(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function I_({status:e,hasCommits:t,live:n,state:r}){return e===`merging`||!t?null:!n&&(e===`parked`||e===`merged`)?`Session ended.`:!n||e===`parked`?null:r===`INITIALIZING`||r===`STARTING`?`Starting up. Mergeable once the session is live.`:null}function L_({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function R_(e){if(!e)return[];let t=new Map;for(let n of[...O_(e.committed?.diff),...O_(e.uncommitted?.diff)]){let e=t.get(n.path);e?(e.added+=n.added,e.removed+=n.removed,e.binary=e.binary||n.binary,e.hunks.push(...n.hunks)):t.set(n.path,{path:n.path,oldPath:n.oldPath,added:n.added,removed:n.removed,binary:n.binary,hunks:[...n.hunks]})}return[...t.values()]}function z_(e,t){return t===null?null:e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)??null}function B_(e,t,n){let r=e.findIndex(e=>e.path===t),i=n===1?0:e.length-1;return e[r===-1?i:Math.min(e.length-1,Math.max(0,r+n))]?.path??null}function V_(e){return e!==E.DORMANT&&e!==E.DONE&&e!==E.FAILED}function H_(e,t){return(Ht.includes(e)||e===E.RUNNING)&&t}function U_(e){let{status:t,reason:n,isFetched:r,hasCommits:i,isWorkspace:a,state:o,effectiveBase:s}=e,c=A_(e.files),l=V_(o),u=F_(t,n,H_(o,i)),d=L_({fetched:r,changedFileCount:c.files,hasCommits:i}),f=M_({status:t,mergeReason:n,fetched:r,hasDiffError:e.hasDiffError,hasChanges:c.files>0||i,hasCommits:i,canMerge:!a&&u.isEnabled,isWorkspace:a,live:l,effectiveBase:s,changedFileCount:c.files}),p=!a&&u.isRendered&&(d||t===`parked`||t===`merging`),m=I_({status:t,hasCommits:i,live:l,state:o});return{sentence:t===`parked`?`${f.text}. ${P_(n)}`:f.text,isEmpty:f.isEmpty===!0,totals:c,isMergeShown:p,isMergeEnabled:p&&u.isEnabled&&!e.isMergeInFlight,mergeRefusal:m,isDiscardShown:!a&&!l&&(t===`pending-review`||t===`parked`)}}var W_=5e3,G_=new Map,K_=new Map,q_=new Map,J_=new Map,Y_=new Map,X_=new Map,Z_=new WeakMap,Q_=new WeakMap,$_=new Set,ev=new Set,tv=null,nv=null,rv=null,iv=null,av=null;function ov(e){return $_.add(e),()=>$_.delete(e)}function sv(e){for(let t of $_)t(e)}function cv(e){if(!e)return[];let t=Z_.get(e);if(t)return t;let n=R_(e);return Z_.set(e,n),n}function lv(e){if(!e)return null;let t=Q_.get(e);if(t)return t;let n=T_(e);return Q_.set(e,n),n}function uv(e){return A.get(e)?.card.dataset.workspace!==void 0}function dv(e){let t=A.get(e);if(!t)return null;let n=q_.get(e)??null,r=cv(n),i=J_.get(e)??null;return{...U_({status:G_.get(e)||`none`,reason:K_.get(e)??null,isFetched:q_.has(e),hasCommits:n?.hasCommits===!0,hasDiffError:i!==null,isWorkspace:uv(e),state:t.currentState,effectiveBase:t.effectiveBase,isMergeInFlight:X_.has(e),files:r}),sessionId:e,sessionName:t.card.dataset.session||e,files:r,diffError:i,changeMapView:lv(Y_.get(e)),notice:tv?.sessionId===e?tv.text:null,isWorkspace:uv(e)}}function fv(e,t){tv={sessionId:e,text:t},nv&&clearTimeout(nv),nv=setTimeout(()=>{tv=null,sv(e)},W_),sv(e)}function pv(e){Y_.has(e)||Y_.set(e,null),v({type:`request-change-map`,id:e})}function mv(e){v({type:`request-session-diff`,id:e}),pv(e)}function hv(e,t){let n=G_.get(e);G_.set(e,t),k_(n,t)&&(q_.delete(e),J_.delete(e),Y_.delete(e),e===Qr()&&mv(e)),sv(e)}function gv(e,t,n=null){let r=t||`none`;K_.set(e,n);let i=X_.get(e);i!==void 0&&i!==r&&X_.delete(e),hv(e,r)}function _v(e,t,n=null){K_.set(e,n),X_.delete(e),hv(e,t||`none`)}function vv(e,t){let n=k(e);n&&(q_.set(n,t),J_.delete(n),sv(n))}function yv(e,t){let n=k(e);n&&(J_.set(n,t),sv(n))}function bv(e,t){let n=k(e);if(!n)return;let r=ue.safeParse(t);r.success&&r.data.sessionId===n&&(Y_.set(n,r.data),sv(n))}function xv(e){let t=k(e);t&&t===Qr()&&mv(t)}function Sv(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function Cv(e){let t=k(e);if(!t||t!==Qr())return;let n=!q_.has(t)||J_.has(t),r=!Y_.has(t)||Sv(Y_.get(t));n&&mv(t),r&&!n&&pv(t),sv(t)}function wv(e){let t=k(e);t&&X_.delete(t)&&sv(t)}function Tv(e){let t=k(e);G_.delete(t),K_.delete(t),q_.delete(t),J_.delete(t),Y_.delete(t),X_.delete(t),t===Qr()?pi(null):sv(t)}function Ev(e,t){X_.has(e)||(v(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(X_.set(e,G_.get(e)||`none`),sv(e)):fv(e,`Not connected. The merge was not sent.`))}function Dv(e){let t=dv(e);return t?X_.has(e)?(fv(e,`Merge is already on its way for "${t.sessionName}".`),!1):t.isMergeEnabled?A.get(e)?.currentState===E.RUNNING?(Qt({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:()=>Ev(e,!0)}),!0):(Ev(e,!1),!0):(fv(e,t.mergeRefusal??`Nothing to merge in "${t.sessionName}" right now.`),!1):!1}function Ov(e){let t=dv(e);t?.isDiscardShown&&Qt({title:`Discard worktree`,message:`Throw away the worktree changes for "${t.sessionName}"? This cannot be undone.`,confirmLabel:`Discard`,danger:!0,onConfirm:()=>v({type:`discard-session-worktree`,id:e})})}function kv(){return[...ev].some(e=>!e.hasAttribute(`data-slot-held`))}function Av(){let e=kv()&&document.visibilityState===`visible`?Qr():null;e!==rv&&(iv&&clearInterval(iv),iv=null,rv=e,v({type:`watch-session-changes`,id:e}),e&&(iv=setInterval(()=>v({type:`watch-session-changes`,id:e}),Et)))}function jv(e){av??=Mv(),av.observe(e)}function Mv(){return document.addEventListener(`visibilitychange`,Av),ti(e=>{e&&mv(e),Av()}),new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&ev.add(t.target),t.isIntersecting||ev.delete(t.target);Av()})}var Nv=!1,Pv=new Set;function Fv(e){Nv=!!e,Kv();for(let e of Pv)e(Nv)}function Iv(e){return Pv.add(e),()=>Pv.delete(e)}function Lv(){return Nv}function Rv(){let e=O(`div`,`debug-close`);return e.append(T({variant:`icon`,size:`small`,label:`Close debug overlay`,icon:w(Dt)})),e}function zv(e){return e?ge(new Date(e)):`-`}function Bv(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function Vv(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Bv(e.quietMs)})`:``}function Hv(e){let t=`<span class="debug-dim">${zv(e.ts)}</span>`;if(e.kind===`signal`){let n=R([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${R(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=Vv(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${R(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=R(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${R(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${R(e.category||`?`)}: <span class="debug-dim">${R(e.from||`?`)} → ${R(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${R(e.kind||`decision`)}</span>`}function Uv(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">${R(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">${R(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${zv(e.timestamp)}</span> ${R(e.from)} → ${R(e.to)} <span class="debug-label">${R(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?`${R(a.signal)} (${R(a.source||`?`)}${a.confidence?`/${R(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">${R(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 ${Bv(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">${R(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">${Hv(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(Rv())}function Wv(e,t){if(e.debugOpen){Gv(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(Rv()),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`)&&Gv(e)}),v({type:`debug-state`,id:t})}function Gv(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function Kv(){for(let[,e]of A)e.btnDebug.classList.toggle(`visible`,Nv),e.btnTrace.classList.toggle(`visible`,Nv),!Nv&&e.debugOpen&&Gv(e)}function qv(e){let t=typeof e.id==`string`?A.get(e.id):void 0;t?.debugOpen&&Uv(t,e.payload)}function Jv(e){j(e)?.debugOpen&&v({type:`debug-state`,id:e})}var Yv=100,Xv=100,Zv=`answered`,Qv=`questionManager.rules entries must be a plain-language rule or an object with name, question and pick`,$v=x({name:S({error:`questionManager.rules[].name must be a string`}).trim().min(1).max(80),question:S({error:`questionManager.rules[].question must be a string`}).trim().min(1).max(500),pick:se(S().trim().min(1).max(200),{error:`questionManager.rules[].pick must list option labels`}).min(1).max(8)},{error:Qv}),ey=S().trim().min(1).max(1e3),ty=le([ey,$v],{error:Qv});x({enabled:ne({error:`questionManager.enabled must be a boolean`}).optional(),repos:se(S({error:`questionManager.repos must list repository paths or owner/name slugs`}).trim().min(1),{error:`questionManager.repos must list repository paths or owner/name slugs`}).max(Xv).optional(),rules:se(ty,{error:`questionManager.rules must be an array`}).max(Yv).optional(),model:S({error:`questionManager.model must be a model name`}).trim().min(1).max(100).optional()},{error:`questionManager must be an object`}),oe(`kind`,[x({kind:b(`answer`),answers:ie(S(),S()),ruleName:S().min(1),by:ae([`rule`,`manager`])}),x({kind:b(`escalate`),reason:S().min(1)})]),le([re({rule:ce().int().min(1),answers:se(re({question:S().min(1),labels:se(S().min(1)).min(1).max(8)})).min(1).max(8)}),re({escalate:S().min(1)})]);function ny(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:t===Zv}}function ry(e,t,n){let r=!t.isStart&&e!==null&&e.groupId===t.id?e.lines:[];return{groupId:t.id,lines:[...r,n||`Session needs attention`]}}function iy(e,t){return{body:t.join(`
|
|
74
|
-
`),tag:`glimmervoid-alert-${e.id}`,renotify:e.isStart}}var ay=4e3;function oy(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function sy(e,t,n,r=ay){try{let i=e.getItem(t);if(i){let e=Number(i);if(Number.isFinite(e)&&n-e<r)return!1}return e.setItem(t,String(n)),!0}catch{return!0}}var cy=`#plan/`;function ly(e){return`${cy}${encodeURIComponent(e)}`}function uy(e){if(!e.startsWith(cy))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var dy=null;function fy(){return dy??=P(()=>import(`./alert-sound-Da6VQFBS.js`),__vite__mapDeps([10,7])).catch(e=>(dy=null,u(`alert-sound`,`alert sound failed to load: ${d(e)}`),null)),dy}function py(){let e=Tr();fy().then(t=>t?.playAlertSound(e))}function my(){return typeof Notification>`u`?null:Notification}function hy(){return my()!==null}function gy(){let e=my();return e?e.permission:`unavailable`}async function _y(){let e=my();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function vy(){return!hy()&&!window.isSecureContext?`Browsers allow desktop notifications only over HTTPS or on localhost, and this page is plain HTTP on another address. Open the dashboard on localhost, or use Telegram.`:hy()?gy()===`denied`&&br()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function yy(){return br()&&gy()==="default"}function by(e=()=>{}){let t=O(`div`,`notification-permission`),n=()=>{let r=vy();if(t.replaceChildren(),t.hidden=!r&&!yy(),r){t.append(O(`p`,`notification-permission-hint text-meta text-text-muted`,r));return}let i=T({variant:`secondary`,label:`Enable desktop notifications`});i.addEventListener(`click`,()=>{i.disabled=!0,_y().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var xy=`Notifications`,Sy=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,Cy=new Map,wy=!1;function Ty(){wy||(wy=!0,Wn({source:xy,message:Sy,hidesInStreamerMode:!1}))}function Ey(e,t){let n=Cy.get(e)??new Set;n.add(t),Cy.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function Dy(e){let t=Cy.get(e);if(t){Cy.delete(e);for(let e of t)e.close()}}function Oy(e){return!hy()||!br()||document.documentElement.hasAttribute(`data-streamer`)?!1:e||!document.hasFocus()}function ky(){return Oy(!1)&&gy()===`granted`}var Ay=null;function jy(e,t){let n=my();if(!n||(Ay=ry(Ay,t,e.message),Un(xy),!sy(window.localStorage,oy(`group-${t.id}`,`${e.session}-${e.category}`),Date.now())))return;let r=t.sessionIds.length===1?A.get(e.session):void 0,i=t.sessionIds.length>1?`${t.sessionIds.length} sessions`:r?kn(r):`Glimmervoid`;try{let r=new n(i,iy(t,Ay.lines));r.onclick=()=>{window.focus(),e.kind===`plan`&&(window.location.hash=ly(e.session)),r.close()};for(let e of t.sessionIds)A.has(e)&&Ey(e,r)}catch{}}var My=null;function Ny(e){return!e||e.id!==My&&(My=e.id,!0)}function Py(e){A.get(e.session)?._isActiveViewer?.()===!0?v({type:`alert-seen`,id:e.session}):Ny(e.group)&&Gr()&&py()}function Fy(e,t){t?jy(e,t):zy(e)}function Iy(){let e=Reflect.get(navigator,`userAgentData`);return typeof e!=`object`||!e?!1:Reflect.get(e,`platform`)===`macOS`}function Ly(e){!document.hasFocus()&&ky()&&zy(e)}function Ry(e){if(e.category===`answered`){Ly(e);return}if(document.hasFocus()){Py(e);return}let t=e.group;ky()&&(Fy(e,t),!Iy())||(Oy(!1)&&gy()===`denied`&&Ty(),t?.isStart!==!1&&Ny(t)&&Gr()&&py())}function zy({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=my();if(!a||!Oy(!!i)||(a.permission===`denied`&&Ty(),a.permission!==`granted`)||(Un(xy),!sy(window.localStorage,oy(e,t),Date.now())))return;let o=typeof e==`string`?e:``,s=A.get(o),c=s?kn(s):``;try{let i=new a(c||`Glimmervoid`,ny(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=ly(o)),i.close()},s&&Ey(o,i)}catch{}}var By=null;function Vy(){return By??=P(()=>import(`./resume-dialog-CuNFDUKu.js`),__vite__mapDeps([18,12,13,5,3,14,19,15,20])).catch(e=>(By=null,u(`resume-dialog`,`restart dialog failed to load: ${d(e)}`),null)),By}var Hy=null,Uy=null;function Wy(){return Uy??=P(()=>import(`./plan-face-B9S4yUcj.js`).then(e=>(Hy=e,e),()=>(Uy=null,null)),__vite__mapDeps([21,13,5,3,14,22,23,16,24])),Uy}function Gy(e){let t=O(`section`,`plan-face`);t.hidden=!0;let n=null,r=!1,i=null,a={},o=new Map;function s(s){if(r=!1,e.signal?.aborted)return;if(!s){e.reportProblem(`The plan view did not load. Open the plan again to retry.`),i!==null&&e.showTerminal(),i=null;return}let c=s.createPlanFace(e);t.replaceWith(c.el),c.update(a);for(let e of o.values())c.update({draft:e});o.clear(),n=c,i!==null&&c.show(i)}return{get el(){return n?.el??t},show(e){n?n.show(e):(i=e,!r&&(r=!0,Wy().then(s)))},hide(){i=null,n?.hide()},update(e){n?n.update(e):(e.state&&(a.state=e.state),typeof e.isConnected==`boolean`&&(a.isConnected=e.isConnected),e.draft&&o.set(e.draft.agentId,e.draft))}}}function Ky(e,t){let n=j(e);n?Si(n).show(`error`,t):Wn({source:`Session`,sessionId:typeof e==`string`?e:void 0,message:t})}function qy(e,t){let n=j(e);if(!n)return;let r=n.card.querySelector(`:scope > .session-failure-reason`);if(!(n.currentState===E.FAILED&&t)){r?.remove();return}let i=r??O(`p`,`session-failure-reason`);i.setAttribute(`role`,`status`),i.textContent=t,r||n.termWrap.before(i)}var Jy=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function Yy(e){return e===`approve`||e===`approve-accept-edits`}function Xy(e){return(e.state===`decided`||e.state===`closed`)&&Yy(e.lastDecision)}function Zy(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&Xy(n)}function Qy(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function $y(e){let t=Qy(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 eb(e,t){return Qy(e,t)?.openRevision?.revision??null}function tb(e,t,n){if(n===null)return null;let r=Qy(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function nb(e,t){let n=t-e;return Number.isFinite(n)?He(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function rb(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 ib(e,t,n){let r=rb(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return Jy.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function ab(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 ob(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function sb(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+pt}function cb(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 ${Ne} characters, so nothing was sent`:ob(e)>1e4?`the feedback composes more than the ${Ie} characters the hook reply carries, so nothing was sent`:sb(e)>nt?`the decision is larger than one control frame carries, so nothing was sent`:null}function lb(e){return e?`, ${e}`:``}function ub(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=ab(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 db(e,t,n){let r=ub(e,t,n);return r?`${r}${lb(e.problem)}`:e.problem??``}function fb(e){let t=Qy(e.state,e.selectedAgentId),n=$y(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:tb(e.state,t?.agentId??null,n),status:db(e,t,n),actions:ib(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:tb(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:rb(e,t,n)}]}}function pb(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 mb({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}function hb({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var gb=e=>zt.includes(e),_b=e=>Vt.includes(e);function vb(e){let t=e.currentState;e.btnRestart.classList.toggle(`visible`,gb(t)||_b(t)||t===E.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,Lv()),e.btnPlan.hidden=hb(e)===`hidden`}function yb(e){let t=j(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(k(e)),vb(t),nl(t,k(e)),!0)}function bb(e,t){let n=j(e);n&&(n.hasPlan=t===!0,vb(n))}function xb(e){let t=j(e.id);t&&(t.planReviewState=pb(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),vb(t))}function Sb(e){let t=j(e.id);t&&t.planFace.update({draft:e})}function Cb(e){let t=j(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),vb(t))}function wb(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=j(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function Tb(e){for(let[,t]of A)t.planFace.update({isConnected:e})}var Eb=160,Db=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 Ob(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=Eb?t:`${t.slice(0,157)}...`}function kb(e,t){let n=Db[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?Ob(r):``}var Ab=5e3;function jb(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function Mb(e,t){if(!e.toolUseId)return jb(e.text)??`context`;let n=t.get(e.toolUseId);return n?kb(n.name,n.input)||n.name:`expansion`}function Nb(e){return e.kind!==`expansion`||e.toolUseId?!1:jb(e.text)!==null}function Pb(e){return e.kind===`prompt`||e.kind===`session`||Nb(e)}function Fb(e){return new TextEncoder().encode(e).byteLength}var Ib={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`};function Lb(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:Ob(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:Ob(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:Ob(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:Ob(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:Ob(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:Mb(e,t)};if(e.kind===`tool_call`){let t=kb(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:`${Fb(e.content)} bytes`}}function Rb(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function zb(e,t){let n=Lb(e,t),r=Rb(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:Ib[e.kind],text:`${r}${i}`,tone:o,badges:a}}function Bb(e,t){return{record:e,...zb(e,t)}}function Vb(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function Hb(e,t){let n=Vb(e);return!n||t.has(n)?null:n}function Ub(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function Wb(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function Gb(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]=Bb(i.record,e.toolCallByUseId))}}function Kb(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function qb(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function Jb(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=Fb(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function Yb(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=Hb(i,e.toolCallByUseId);t&&Ub(e.unresolvedToolUseCounts,t);let a=Bb(i,e.toolCallByUseId);if(Pb(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:qb()},Jb(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:qb()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),Jb(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 Xb(e,t){let n=Kb();Yb(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)||Ub(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],Gb(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function Zb(e){return e.rows.length+ +!!e.head}function Qb(e){let t=0;for(let n of e.turns)t+=Zb(n);return t}function $b(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&&Wb(e.unresolvedToolUseCounts,t)}}function ex(e,t){$b(e,t.head?[t.head,...t.rows]:t.rows)}function tx(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);$b(e,i);for(let e of i)Jb(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function nx(e,t=Ab){let n=Qb(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=Zb(t),ex(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:tx(e,n-t)}}function rx(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 ix(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 ax(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 ox(e,t=Ab){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function sx(e,t=Ab){return!ox(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function cx(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`}var lx=1e4,ux=null,dx=null,fx=[],px=null,mx=null,z=null,hx=null,gx=!1,_x=null,vx=()=>!1,yx=new Set;function bx(e){for(let t of yx)t(e)}function xx(){hx&&=(clearTimeout(hx.timeoutHandle),null)}function Sx(){hx=null,_x=`The trace did not load within ${Math.round(lx/1e3)} s.`,bx({kind:`rebuild`})}function Cx(e){xx(),gx=!1,_x=null,px=e,z=e?{sessionId:e,grouping:Kb(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,bx({kind:`selection-reset`})}function wx(e){let t=ix(fx,mx,px,e);return mx&&t===mx&&(mx=null),t!==px&&(Cx(t),!0)}function Tx(e){if(!ux)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};ux(t)?hx={request:e,timeoutHandle:setTimeout(Sx,lx)}:(_x=je,bx({kind:`header`}))}function Ex(e=!1){if(!ux)return;let t=ax({selectedSessionId:px,isPanelVisible:e||vx(),hasPendingRequest:!!hx,hasLoadedOnce:z?.hasLoadedOnce??!1,nextOffset:z?.nextOffset??0});t&&Tx(t)}function Dx(){gx&&!hx&&(gx=!1,Ex())}function Ox(){if(!z)return;let e=nx(z.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!z.hasDroppedEarliestRows;t&&(z.hasDroppedEarliestRows=!0),bx({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function kx(e){z&&(bx({kind:`records-appended`,appends:Yb(z.grouping,e)}),Ox())}function Ax(e){z&&(bx({kind:`records-prepended`,prepend:Xb(z.grouping,e)}),Ox())}function jx(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 Mx(){return{selectedSessionId:px,hasPendingRequest:!!hx,hasLoadedOnce:z?.hasLoadedOnce??!1,hasDroppedEarliestRows:z?.hasDroppedEarliestRows??!1,firstOffset:z?.firstOffset??0,residentRowCount:z?Qb(z.grouping):0}}function Nx(){return{sessionOptions:fx,selectedSessionId:px,selectedTrace:z,pendingSessionId:hx?.request.id??null,traceFailureText:_x}}function Px(e){yx.add(e)}function Fx(e){vx=e}function Ix(){if(!ux)return;let e=sx(Mx());e&&Tx(e)}function Lx(e){fx.some(t=>t.id===e)&&e!==px&&(mx=null,Cx(e),Ex(),bx({kind:`rebuild`}))}function Rx(){let e=wx(!0);return Ex(!0),e}function zx(e){ux=e}function Bx(e){dx=e}function Vx(e){mx=e,dx?.()}function Hx(e){fx=rx(e);let t=wx(vx());t&&Ex(),bx({kind:`sessions`,hasSelectionChanged:t})}function Ux(e){let t=jx(e);if(!t)return;let n=cx({pendingRequest:hx?.request??null,resident:z?{sessionId:z.sessionId,firstOffset:z.firstOffset,nextOffset:z.nextOffset,hasLoadedOnce:z.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?Dx():(xx(),_x&&(_x=null,bx({kind:`header`})),n===`stale`?Dx():n===`reset`?(Cx(t.id),z&&(z.filePath=t.path),Ex(),bx({kind:`rebuild`}),Dx()):z&&(z.filePath=t.path,n===`prepend`?(z.firstOffset=t.start,Ax(t.records),Dx()):(n===`seed`&&(z.hasLoadedOnce=!0,z.firstOffset=t.start),z.nextOffset=t.next,kx(t.records),Dx())))}function Wx(e){let t=e?.id;typeof t==`string`&&t===px&&vx()&&(hx?gx=!0:Ex())}function Gx(e){let t=e?.id;if(typeof t!=`string`||hx?.request.id!==t)return!1;xx(),gx=!1;let n=e?.message;return _x=typeof n==`string`&&n?n:`The trace could not be read.`,bx({kind:`rebuild`}),!0}function Kx(e){xx(),gx=!1,_x=e?null:je,e?(bx({kind:`header`}),Ex()):bx({kind:`rebuild`})}function qx(e){return e instanceof Error?e.message:String(e)}function Jx(e,t,n=!1){let r=O(`label`,`dialog-checkbox-label`),i=O(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,O(`span`,null,e)),r}function Yx(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function Xx(e){let[t,n]=await Promise.all([a(`get-workspace-repos`,{id:e}),a(`scan-repo-roots`,{}).catch(()=>null)]);if(t.type!==`workspace-repos`)throw Error(`Unexpected reply`);if(!t.ok)throw Error(t.error||`Could not read the workspace`);let r=t.repos.map(e=>({name:Yx(e),path:e,isMember:!0})),i=new Set(t.repos),o=n?.type===`repo-roots-scanned`?n.directories:[];for(let e of o.flatMap(e=>e.projects))i.has(e.path)||(i.add(e.path),r.push({name:e.name,path:e.path,isMember:!1}));return r}function Zx(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:o}=en({title:`Workspace repositories`}),s=O(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),c=O(`fieldset`,`dialog-workspace-list`);c.setAttribute(`aria-label`,`Workspace repositories`),c.append(O(`div`,`dialog-hint`,`Loading repositories...`));let l=O(`div`,`dialog-hint`);l.setAttribute(`role`,`status`);let u=O(`div`,`dialog-error`),d=T({variant:`primary`,label:`Save`,disabled:!0});i.append(d),n.append(s,c,l,u,i),o.addEventListener(`click`,r),requestAnimationFrame(()=>o.focus()),Xx(e).then(e=>{if(t.isConnected){c.textContent=``;for(let t of e)c.append(Jx(t.name,t.path,t.isMember));d.disabled=!1}}).catch(e=>{t.isConnected&&(c.textContent=``,u.textContent=`Could not load repositories: ${qx(e)}`)}),d.addEventListener(`click`,()=>{let n=[...c.querySelectorAll(`input:checked`)].map(e=>e.value);n.length<2?u.textContent=`Select at least two repositories.`:(u.textContent=``,d.disabled=!0,l.textContent=`Saving`,a(`set-workspace-repos`,{id:e,repos:n}).then(e=>{if(!t.isConnected)return;if(e.type===`set-workspace-repos-result`&&e.ok){r();return}let n=e.type===`set-workspace-repos-result`?e.error:null;u.textContent=n||`Could not update the workspace.`}).catch(e=>{t.isConnected&&(u.textContent=`Could not update the workspace: ${qx(e)}`)}).finally(()=>{l.textContent=``,d.disabled=!1}))})}function Qx(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function $x(e,t){wn(e.taskTitleEl,()=>Tn(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),cn(e,t)}),e.nameEl.addEventListener(`click`,()=>{on(e.nameEl)||pi(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),cn(e,t))}),e.btnRename.addEventListener(`click`,()=>{Qx(e),cn(e,t,{returnsFocusToTerminal:!e.renameTargetEl?.isConnected})}),e.btnRestart.addEventListener(`click`,()=>{Qx(e),Vy().then(n=>n?.openRestartDialog(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0}))}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{Qx(e),Zx(t)}),e.btnTrace.addEventListener(`click`,()=>{Qx(e),Vx(t)}),e.btnDocs.addEventListener(`click`,()=>{Qx(e),u_(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=hb(e);n!==`hidden`&&(n===`face`?yb(t):location.hash=ly(t))}),e.btnRemove.addEventListener(`click`,()=>{Qx(e),ci(t)});function n(){for(let[,t]of A)t!==e&&Qx(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`)}e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation(),e.sessionMenu.classList.contains(`open`)?Qx(e):n()}),Ti({trigger:e.btnSessionMenu,menu:e.sessionMenu,menuItems:()=>[...e.sessionMenu.querySelectorAll(`.popup-menu-item.visible`)].filter(e=>e.checkVisibility()),isOpen:()=>e.sessionMenu.classList.contains(`open`),open:n,close:()=>Qx(e),signal:e.abortController.signal}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;!e.sessionMenu.contains(n)&&n!==e.btnSessionMenu&&Qx(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),Qx(e),Wv(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&Gv(e)},{signal:e.abortController.signal})}var eS=1500,tS=new WeakMap;function nS(e){clearTimeout(tS.get(e)),tS.delete(e)}function rS(e,t){let n=setTimeout(()=>{tS.delete(e),v({type:`dismiss`,id:t,expectedState:E.COMPLETE})},eS);tS.set(e,n)}function iS(e,t,n){let r=document.activeElement;return ei({previousState:t,nextState:n,isPhoneLayout:Co(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}var aS=e=>e==null?``:String(e);function oS(e,t,n){let r=j(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&En(e,r.taskTitle)}}function sS(e){return typeof e==`string`&&A.has(e)}function cS(){return A.size}function lS(e){let t=e||{};t.linkPreviews!=null&&Uu(t.linkPreviews),t.cursorBlink!=null&&jd(t.cursorBlink),t.debugMode!=null&&(Fv(t.debugMode),Vg(t.debugMode));for(let[,e]of A)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function uS(){Rl(A.values(),Bl())}function dS(e){return{state:e.currentState,unseenOutcome:e.unseenOutcome,ownerId:e.ownerId}}function fS(){let e=Dn(M.counts),t=e>0?`(${e}) Glimmervoid`:`Glimmervoid`;document.title!==t&&(document.title=t)}function pS(e,t,n,r={}){if(!In)return;let i=k(e),a=aS(n)||E.DORMANT,o=un(i,aS(t),a,r),s=a===E.DORMANT;In.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),vb(c),Vd(c,i)}let u=new AbortController,d=Gy({signal:u.signal,requestPlan:(e,t,n)=>v({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>v({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:l,sendDecision:(e,t)=>v({type:`plan-decision`,id:e,...t}),reportProblem:e=>Ky(i,e)});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:aS(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,btnRename:o.btnRename,btnRestart:o.btnRestart,btnSessionMenu:o.btnSessionMenu,btnWorkspaceRepos:o.btnWorkspaceRepos,tags:o.tags,btnTrace:o.btnTrace,btnPlan:o.btnPlan,btnDocs:o.btnDocs,btnRemove:o.btnRemove,debugOverlay:null,debugOpen:!1,abortController:u,currentState:a,face:`terminal`,isBorrowed:!1,hasPlan:!1,pendingPromptKind:null,planReviewState:{reviews:[]},planFace:d},c._ensureTerminalReady=()=>Vd(c,i),c._showTerminalFace=l,c._showPreferredFace=l,c._setBorrowed=e=>{c.isBorrowed=e,o.card.toggleAttribute(`data-borrowed`,e),vb(c)},o.card.append(d.el);let f=A.get(i);return f&&zn(M,dS(f)),A.set(i,c),An(M,dS(c)),Zn(i,c),$x(c,i),vb(c),c.btnDocs.hidden=!a_(i),a===E.RUNNING&&Xn(c,!0),s||Rd(c,i),fS(),c}function mS(e,t){let n=j(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function hS(e,t){let n=j(e);if(!n)return;n.agent=typeof t==`string`?t:null;let r=n.card.querySelector(`.session-agent-mark`);r&&Di(r,n.agent),vb(n)}function gS(e,t){let n=j(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function _S(e,t,n=!1){let r=j(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=Zt(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function vS(e,t){let n=j(e);n&&(n.pendingPromptKind=typeof t==`string`?t:null)}function yS(e,t){let n=j(e);n&&(zn(M,dS(n)),n.unseenOutcome=t??null,An(M,dS(n)))}function bS(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function xS(e,t,n=null){let r=j(e),i=aS(t)||`none`;r&&bS(r.card,i),gv(k(e),i,aS(n)||null)}function SS(e,t,n=null){let r=j(e),i=aS(t)||`none`;r&&bS(r.card,i),_v(k(e),i,aS(n)||null)}function CS(e,t){let n=j(e);if(!n)return;let r=aS(t);n.card.dataset.session=r,n.nameEl.textContent=r}function wS(e){let t=j(e);t&&(Gv(t),zn(M,dS(t)),A.delete(k(e)),Zn(k(e),void 0),Hy?.dropPlanBodyCache(k(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),jl(t,k(e)),oo(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),fS())}function TS(e,t,n){if(!t||!e.term)return;let r=n===E.DONE?`Session complete`:`Session failed`,i=n===E.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 ES(e,t){e.term&&(t===E.DONE||t===E.FAILED)&&(e.term.clear(),e.term.reset())}function DS(e){let t=A.get(e);t&&Fn({state:t.currentState,unseenOutcome:t.unseenOutcome})&&document.visibilityState===`visible`&&(Co()||document.hasFocus())&&v({type:`dismiss`,id:e,expectedState:t.currentState})}function OS(e,t,n){let r=j(e);if(!r)return;let i=aS(t),a=r.currentState;zn(M,dS(r)),r.currentState=i,An(M,dS(r)),Zn(k(e),r),i!==E.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(nS(r),r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),Xn(r,i===E.RUNNING)),a===E.DORMANT&&i!==E.DORMANT&&Rd(r,k(e)),Bn({state:i})===`resting`&&Dy(k(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,Zt(i,r.awaitingBackgroundTasks)),vb(r),iS(r,a,i)&&rS(r,k(e));let o=i===E.DONE||i===E.FAILED,s=a!==E.DONE&&a!==E.FAILED&&a!==E.INITIALIZING;o&&s&&(r.card.classList.remove(`completion-flash`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.card.classList.add(`completion-flash`),r.card.addEventListener(`animationend`,()=>r.card.classList.remove(`completion-flash`),{once:!0})})})),(i===E.DONE||i===E.FAILED)&&TS(r,s,i),i===E.INITIALIZING&&ES(r,a),fS()}var kS=Wi({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function AS(e){let t=O(`ul`,`session-setup-list`);return t.append(...e.map(e=>O(`li`,null,e))),t}function jS(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=qt(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[O(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=O(`div`,`session-setup-plugin`);return t.append(O(`h3`,null,e.name)),e.skills.length>0&&t.append(O(`p`,`session-setup-label`,`Skills`),AS(e.skills)),e.agents.length>0&&t.append(O(`p`,`session-setup-label`,`Agents`),AS(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[AS(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=O(`p`,`session-setup-hook`);return t.append(O(`span`,null,e.event),O(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>O(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[AS(t.skills)]:[]),n(`Agents`,t.agents.length>0?[AS(t.agents)]:[])}function MS(e){let t=O(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=O(`div`,`session-setup-sections`);kS.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function NS(e){let t=kS.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;jS(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function PS(e){return He(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function FS(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${PS(Date.now()-e)} ago`}var IS=e=>`polled ${FS(e)}`;function LS(e){let t=[],n=[],r=null,i=e=>{let t=e.format(e.ts);e.el.textContent!==t&&(e.el.textContent=t)},a=()=>{let r=e();if(r&&!r.closest(`[hidden]`)){for(let e of t)i(e);for(let e of n)e()}};return{track(e,n,r=IS){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=Qn(a)}}}var RS=80,zS=Object.freeze([{value:`day`,label:`Today`,days:1},{value:`week`,label:`Last 7 days`,days:7},{value:`month`,label:`Last 30 days`,days:30}]),BS=`week`;function VS(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function HS(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function US(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${VS(String(Math.abs(t)))}`}function WS(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}$${VS(r)}.${i}`}function GS(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}${HS((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${HS((n/1e6).toFixed(2))}M`:`${t}${HS((n/1e9).toFixed(2))}B`}function KS(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=RS?`warn`:`ok`}var qS=90;function JS(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&C(e.budgetUsd,null)!==null):[]}function YS(e){let t=C(e?.pct,null);return t===null?0:t}function XS(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=C(n.pct,null),i=C(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}function ZS(e){return e?.vendor===`codex`||e?.vendor===`kimi`?e.vendor:`claude`}function QS(e,t=null){let n=[],r=KS(XS(t,`fiveHour`)?.pct);r!==`ok`&&n.push(`block:${r}`),e?.anomaly?.daily&&n.push(`anomaly:daily`),e?.anomaly?.burn&&n.push(`anomaly:burn`);for(let t of JS(e)){let e=YS(t);if(e<qS)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return et(n)}function $S(e,t=``){let n=e?.source;if(n===`fetched`){let e=Fe(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=Fe(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 eC(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 tC(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function nC(e){if(!e||typeof e!=`object`)return``;let t=[],n=tC(e.dirs);if(n!==null&&t.push(`${US(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${US(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${US(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${US(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 rC(e){return Fe(e?.error,``)}function iC(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}var aC=`Estimated list prices, not a bill.`,oC=`Enable in Settings.`,sC=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],cC=/^(\d{4})-(\d{2})-(\d{2})$/,lC=new Set([`day`,`model`,`label`]),uC=new Set([`model`,`label`]);function dC(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${HS(e.toFixed(1))}%`}var fC=`tokens`,pC=Object.freeze([{value:`tokens`,label:`Tokens`},{value:`cost`,label:`Cost`}]);function mC(e){return e===`cost`?`cost`:fC}function hC(e,t){return t===`cost`?WS(e):GS(e)}function gC(e,t){if(t===`tokens`)return`tokens`;let n=Number(e?.costUSD);return Number.isFinite(n)&&n>0?`costUSD`:`tokens`}function _C(e){return e===`costUSD`?`share of cost`:`share of tokens`}function vC(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function yC(e){let t=cC.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=sC[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function bC(e){let t=xC(e);return t.length===0?``:t.length===1?yC(t[0]):`${yC(t[0])} to ${yC(t[t.length-1])}`}function xC(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>cC.test(e)).sort()}function SC(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:CC(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function CC(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=wC(e,n);return cC.test(r)?r:wC(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function wC(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function TC(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:ye(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function EC(e,t){let n=Mt(t-864e5),[,r,i]=e.yesterday.day.split(`-`).map(Number),a=e.yesterday.day===n?`yesterday`:`${sC[r-1]} ${i}`,o=e.yesterday.sessionCount===1?`session`:`sessions`;return`${a}: ${e.yesterday.sessionCount} ${o}, ${TC(e.yesterday.activeMs/6e4)}`}function DC(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=sC[n.getMonth()];return r?`${r} ${n.getDate()} ${We(n)}`:`-`}var OC=Object.freeze({interactive:`Interactive`,"pr-review":`PR review`,"team-review":`PR reviews`,posthog:`PostHog`,"my-prs":`Keep mergeable`,workflows:`Workflows`,"change-map":`Change map`,benchmark:`Benchmarks`,"agent-spawn":`Agent API`,"task-title":`Task titles`,other:`Other`}),kC=`Sessions spawned by Glimmervoid; terminal sessions count as other`,AC=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function jC(e){let t=Fe(e,``);return t?OC[t]||t:OC.other}function MC(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function NC(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function PC(e){return MC(e).some(e=>NC(e.lane))}var FC=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function IC(e,t,n){let r=XS(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function LC(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+C(t.costUSD,0),0),o=i.reduce((e,t)=>e+C(t.tokens,0),0),s=i.filter(e=>NC(e.lane)).map(e=>({lane:String(e.lane),label:jC(e.lane),tokens:C(e.tokens,0),costUSD:C(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?vC(c,a):vC(l,o),d=IC(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:FC[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function RC(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:Ow.map(e=>LC(e.key,r[e.key],t,n)).filter(e=>e!==null)}function zC(e){return e.planPct===null?``:`about ${dC(e.planPct)} of plan`}function BC(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?WS(e.costUSD):GS(e.tokens)}`).join(`, `)}var VC=`team-review`;function HC(e){if(!Array.isArray(e?.byLane))return``;let t=MC(e).find(e=>e.lane===VC),n=C(t?.costUSD,0);if(n<=0)return``;let r=vC(n,e?.totals?.costUSD),i=r===null?``:`, ${dC(r)} of this period`;return`PR reviews cost ${WS(n)}${i}.`}function UC(e){let t=C(e,null);return t===null||t<=0?``:`${US(t)} ${t===1?`session`:`sessions`}`}function WC(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function GC(e){let t=WC(e);if(!t)return``;let n=C(t.savedUSD,0);if(n<=0)return``;let r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e).length,i=r===0?``:`, at least, since ${r} ${r===1?`model has`:`models have`} no price`;return`Prompt caching saved ${WS(n)}${i}, across ${GS(C(t.cacheReadTokens,0))} cache read tokens.`}function KC(e){return e===`monthly`?`this month`:`today`}function qC(e){return`${WS(C(e?.spentUsd,0))} of ${WS(C(e?.budgetUsd,0))}`}function JC(e){return`${KC(e?.scope)} spend against budget`}var YC=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function XC(e){let t=cC.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function ZC(e){let t=XC(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Mt(t)}function QC(e){let t=cC.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function $C(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 ew(e,t){e.tokens+=C(t?.tokens,0),e.costUSD+=C(t?.costUSD,0),e.input+=C(t?.input,0),e.output+=C(t?.output,0),e.cacheCreate+=C(t?.cacheCreate,0),e.cacheRead+=C(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=zw(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+=C(t?.tokens,0),r.costUSD+=C(t?.costUSD,0),r.input+=C(t?.input,0),r.output+=C(t?.output,0),r.cacheCreate+=C(t?.cacheCreate,0),r.cacheRead+=C(t?.cacheRead,0),e.modelByName.set(n,r)}}function tw(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 nw(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)||$C(r);ew(i,e),n.set(r,i)}return Array.from(n.values()).map(tw)}function rw(e){return nw(e,ZC)}function iw(e){return nw(e,QC)}function aw(e,t){return t===`week`?rw(e):t===`month`?iw(e):Array.isArray(e)?[...e]:[]}var ow=/^(\d{4})-(\d{2})$/;function sw(e,t){if(t===`month`){let t=ow.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=sC[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=yC(e);return t===`-`?t:`week of ${t}`}return yC(e)}function cw(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var lw=16,uw=Object.freeze([.05,.25,.5,.75]),dw=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function fw(e,t){let n=C(e,0),r=C(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<uw.length;e+=1)i>=uw[e]&&(a=e+1);return a}function pw(e,{weeks:t=lw,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>cC.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`&&cC.test(n)?n:Mt(o),c=XC(ZC(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Mt(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,C(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=Mt(n),a=i.get(r)||null,o=r>s,c=p!==null&&r<p;d.push({day:r,week:e,weekday:t,tokens:C(a?.tokens,0),costUSD:C(a?.costUSD,0),source:a?.source===`history`?`history`:a?`live`:null,noData:o||c||!a&&p===null,tone:fw(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function mw(e){let t=yC(e?.day);if(e?.noData)return`${t}: no data`;let n=C(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${GS(n)} tokens, ${WS(C(e?.costUSD,0))}`}function hw(e){if(!e)return``;let t=C(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${yw(e.ratio)} the ${n} average: ${WS(e.todayUsd)} against ${WS(e.baselineUsd)}.`}function gw(e){return e?`This block is burning ${yw(e.ratio)} the usual rate: ${GS(e.current)} tokens per minute against ${GS(e.baseline)}.`:``}function _w(e){return[hw(e?.daily),gw(e?.burn)].filter(Boolean).join(` `)}function vw(e){return!!(e?.daily||e?.burn)}function yw(e){let t=C(e,null);return t===null?`-`:`${HS(t.toFixed(1))}x`}var bw=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`,kimi:`Kimi`});function xw(e){let t=Fe(e,``);return t?bw[t]||t:bw.claude}function Sw(e,t){return ww(t)?xw(e?.vendor):``}function Cw(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>C(t[n]?.tokens,0)-C(t[e]?.tokens,0)).map(e=>({vendor:e,label:xw(e),tokens:C(t[e]?.tokens,0),costUSD:C(t[e]?.costUSD,0)}))}function ww(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 Tw=`Claude only`;function Ew(e){return ww(e)?Tw:``}var Dw=36e5,Ow=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]),kw=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`},{vendor:`kimi`,label:`Kimi Code`}]);function Aw(e,t=Date.now()){let n=C(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function jw(e,t=Date.now()){let n=C(e,null);return n===null||n<=0||t-n>Dw}function Mw(e,t=Date.now()){if(!jw(e,t))return``;let n=Aw(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function Nw(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 Pw(e){let t=Fe(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function Fw(e){return rC(e)!==``}function Iw(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 Lw(e){return typeof e?.id==`string`&&e.id!==``}function Rw(e){let t=Fe(e?.label,``);return Lw(e)&&t?t:Iw(e?.project)||t||`unknown project`}function zw(e){let t=typeof e==`string`?e:e?.model;return Fe(t,`unknown model`)}function Bw(e){return String(e?.day??``)}function Vw(e,t,n){if(!lC.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?Bw(e):n(e)}function Hw(e,t,n,r=Rw){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=Vw(e,t,r),o=Vw(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 Uw(e){return uC.has(e)?`asc`:`desc`}function Ww(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:Uw(t)}}function Gw(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var Kw=Object.freeze({key:`lastTs`,dir:`desc`}),qw=Object.freeze({key:`tokens`,dir:`desc`}),Jw=Object.freeze({key:`day`,dir:`desc`});function Yw(e,t=Kw){return Hw(e,t.key,t.dir,Rw)}function Xw(e,t,n=10){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 Zw(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${US(t)} hidden`}function Qw(e,t=qw){return Hw(e,t.key,t.dir,zw)}function $w(e,t=Jw){return Hw(e,t.key,t.dir,Bw)}function eT(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function tT(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}))}var nT=36e5,rT=24*nT,iT=Object.freeze({fiveHour:{lengthMs:5*nT,label:`5-hour`},sevenDay:{lengthMs:7*rT,label:`weekly`}}),aT=10,oT=80,sT=100,cT=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function lT(e,t){return e>=sT?`fail`:e>=oT||t!==null&&t>=oT?`warn`:`ok`}function uT(e,t,n){if(t===null||t<=0)return null;let r=t-e;return Math.min(Math.max((n-r)/e*100,0),100)}function dT(e,t,n,r){let i=XS(n,t);if(!i||i.pct===null||i.resetsAtMs!==null&&i.resetsAtMs<=r)return null;let a=iT[t],o=uT(a.lengthMs,i.resetsAtMs,r),s=o!==null&&o>=aT&&i.pct<sT?i.pct/(o/100):null;return{vendor:e,vendorLabel:kw.find(t=>t.vendor===e)?.label||e,key:t,windowLabel:a.label,usedPct:i.pct,elapsedPct:o,projectedPct:s,resetsAtMs:i.resetsAtMs,tone:lT(i.pct,s)}}function fT(e,t){return kw.flatMap(({vendor:n})=>Ow.map(({key:r})=>dT(n,r,e[n],t)).filter(e=>e!==null))}function pT(e,t){let n=C(e,null);if(n===null||n<=0)return``;let r=new Date(n),i=We(r);return Mt(n)===Mt(t)?i:n-t<7*rT&&r.getDay()!==new Date(t).getDay()?`${cT[r.getDay()]} ${i}`:`${sC[r.getMonth()]} ${r.getDate()} ${i}`}function mT(e){return`${Math.round(e)}%`}function hT(e){return Math.max(e.usedPct,e.projectedPct??0)}function gT(e){let t=new Map;for(let n of e){let e=t.get(n.vendor);(!e||n.usedPct>e.usedPct)&&t.set(n.vendor,n)}return[...t.values()]}function _T(e,t){let n=gT(e).filter(e=>e.vendor!==t&&e.tone!==`fail`);if(n.length===0)return``;let r=[...n].sort((e,t)=>e.usedPct-t.usedPct)[0];return`${r.vendorLabel} has ${mT(100-r.usedPct)} of its ${r.windowLabel} window left.`}function vT(e,t){let n=pT(e,t);return!n||e===null?`until the window resets`:`until ${n}, in ${TC((e-t)/6e4)}`}function yT(e,t,n){let r=[`${e.vendorLabel} sessions stop answering ${vT(e.resetsAtMs,n)}. Their worktrees and conversations stay intact.`,_T(t,e.vendor)];return{tone:`fail`,headline:`${e.vendorLabel} ${e.windowLabel} limit reached.`,detail:r.filter(Boolean).join(` `)}}function bT(e,t){let n=pT(e.resetsAtMs,t),r=n?`, resets ${n}`:``;if(e.usedPct>=oT)return{tone:`warn`,headline:`${e.vendorLabel} ${e.windowLabel} limit is at ${mT(e.usedPct)}.`,detail:`Little room left before it resets${r}.`};let i=n?` by ${n}`:``;return{tone:`warn`,headline:`${e.vendorLabel} will be tight${i}.`,detail:`At this pace its ${e.windowLabel} window ends at ${mT(e.projectedPct??e.usedPct)}.`}}function xT(e){return{tone:`warn`,headline:`Over your ${KC(e.scope)===`today`?`daily`:`monthly`} budget.`,detail:`${qC(e)} spent ${KC(e.scope)}.`}}function ST(e,t,n,r){let i=e.find(e=>e.tone===`fail`);if(i)return yT(i,e,r);let a=e.filter(e=>e.tone===`warn`).sort((e,t)=>hT(t)-hT(e))[0];if(a)return bT(a,r);let o=t.find(e=>C(e.pct,0)>=100);if(o)return xT(o);if(e.length===0)return{tone:`ok`,headline:n===null?`Nothing spent yet today.`:`${WS(n)} spent today.`,detail:`No agent has reported a current plan limit, so this tab tracks estimated spend only.`};let s=[...e].sort((e,t)=>hT(t)-hT(e))[0],c=pT(s.resetsAtMs,r);return{tone:`ok`,headline:`Every limit has room.`,detail:`Closest is ${s.vendorLabel} ${s.windowLabel} at ${mT(s.usedPct)}${c?`, resets ${c}`:``}.`}}function CT(e){return e.tone===`fail`?`limit reached`:e.projectedPct===null?e.elapsedPct===null?``:`too early to project`:`about ${mT(e.projectedPct)} at reset`}var wT=`report`;function TT(e){return zS.find(t=>t.value===e)?.label||``}function ET(e,t){return{key:gC(e,t),dir:`desc`}}function DT(e,t){let n=Qw(e?.models,ET(e?.totals,t))[0];if(!n)return null;let r=gC(e?.totals,t);return{label:zw(n),sharePct:vC(n[r],e?.totals?.[r])}}function OT(e,t){let n=Yw(e?.sessions,ET(e?.totals,t)),r=n[0];return{count:n.length,topLabel:r?Rw(r):``}}function kT(e){let t=MC(e).filter(e=>NC(e.lane));return t.length===0?null:t.reduce((e,t)=>e+C(t.costUSD,0),0)}function AT(e){let t=e.filter(e=>C(e.pct,0)>=100).length,n=e.length-t;return t===0?{value:`${n} of ${e.length}`,detail:e.length===1?`under its ceiling`:`all under their ceilings`}:{value:`${n} of ${e.length}`,detail:t===1?`1 over its ceiling`:`${t} over their ceilings`}}function jT(e){return xC(e).length}function MT(e,t){let n=XC(e);return!n||t<=0?[]:Array.from({length:t},(e,r)=>{let i=new Date(n);return i.setDate(n.getDate()-(t-1-r)),Mt(i)})}function NT(e){return zS.find(t=>t.value===e)?.days??7}function PT(e){return e.reduce((e,t)=>t.resetsAtMs===null?e:e===null?t.resetsAtMs:Math.min(e,t.resetsAtMs),null)}function FT(e,t){let n=XC(e);return n?(n.setDate(n.getDate()+t),Mt(n)):``}function IT(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=String(e?.day??``);cC.test(n)&&r.set(n,(r.get(n)??0)+C(e?.[t],0))}return r}function LT(e,t){let n=XC(e);return n?t<=7?cT[n.getDay()]:String(n.getDate()):e}function RT(e,t,n,r){let i=IT(e,r===`cost`?`costUSD`:`tokens`),a=MT(n,t).map(e=>({day:e,label:LT(e,t),value:i.get(e)??0,isToday:e===n})),o=a.reduce((e,t)=>e+t.value,0),s=MT(FT(n,-t),t),c=s.reduce((e,t)=>e+(i.get(t)??0),0);return{metric:r,total:o,deltaPct:s.some(e=>i.has(e))&&c>0?(o-c)/c*100:null,average:a.length>0?o/a.length:0,peak:a.reduce((e,t)=>Math.max(e,t.value),0),bars:a}}function zT(e,t){if(e.deltaPct===null)return``;let n=t===1?`yesterday`:`the ${t} days before`,r=Math.round(Math.abs(e.deltaPct));return r===0?`About the same as ${n}`:`${r}% ${e.deltaPct<0?`less`:`more`} than ${n}`}function BT(e){return`${hC(e.average,e.metric)} a day on average`}function VT(e){return ww(e)?Cw(e).map(e=>`${e.label} ${WS(e.costUSD)}`).join(`, `):``}function HT(e){return ww(e)?Cw(e).map(t=>({...t,sharePct:vC(t.tokens,e?.tokens)})):[]}function UT(e){let t=e?.totals,n=[{label:`Processed tokens`,value:GS(C(t?.tokens,0))},{label:`Cached input`,value:GS(C(t?.cacheRead,0))},{label:`Uncached input`,value:GS(C(t?.input,0))},{label:`Output`,value:GS(C(t?.output,0))}],r=C(WC(e?.savings)?.savedUSD,0);return r>0&&n.push({label:`Cache savings`,value:WS(r)}),n}function WT(e){let t=(e?.yourDay?.insights??[]).map(e=>({text:e.text,tone:`ok`})),n=e?.anomaly;vw(n)&&t.push({text:_w(n),tone:`warn`});for(let n of[GC(e?.savings),HC(e)])n&&t.push({text:n,tone:`ok`});return t}function GT(e,t,n,r){let i=gC(t,n),a=e.reduce((e,t)=>Math.max(e,C(t[i],0)),0);return e.map(e=>({row:e,label:r(e),tokens:C(e.tokens,0),costUSD:C(e.costUSD,0),sharePct:vC(e[i],t?.[i]),barPct:vC(e[i],a)??0}))}function KT(e,t){return GT(Qw(e?.models,ET(e?.totals,t)),e?.totals,t,zw)}function qT(e,t){return GT(Yw(e?.sessions,ET(e?.totals,t)),e?.totals,t,Rw)}function JT(e){return[{label:`Input`,tokens:C(e.input,0)},{label:`Output`,tokens:C(e.output,0)},{label:`Cache write`,tokens:C(e.cacheCreate,0)},{label:`Cache read`,tokens:C(e.cacheRead,0)}]}var YT=2e4,XT=`glimmervoid-usage-metric`,ZT=null,QT=null,$T={claude:null,codex:null,kimi:null},eE=null,tE=null,nE=null,rE=BS,iE=mC(ir(XT,null)),aE=!1,oE=null,sE=null,cE=!0,lE=()=>!1,uE=new Set,dE=At({getAck:Wr,setAck:Pr,signature:()=>QS(ZT,$T.claude),isLooking:()=>lE()});function fE(e){for(let t of uE)t(e)}function pE(){eE?.(dE.refresh())}function mE(e){aE=e,fE(`refresh-status`),oE&&=(clearTimeout(oE),null),e&&(oE=setTimeout(()=>{oE=null,aE=!1,sE=`Usage did not answer within ${Math.round(YT/1e3)} s. Refresh to try again.`,fE(`refresh-status`)},YT))}function hE(e){let t=zS.find(t=>t.value===e);return t?t.days:null}function gE(){return{report:ZT,sessions:QT,planLimitsByVendor:$T,rangeValue:rE,metric:iE}}function _E(){let e=!cE||!aE&&sE!==null;return cE?aE?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:sE??``,isPending:!1,hasFailure:e}:{text:ZT?`${je} The figures below are from before the connection dropped.`:je,isPending:aE,hasFailure:e}}function vE(e){uE.add(e)}function yE(e){lE=e,pE()}function bE(){dE.acknowledge(),pE()}function xE(e){eE=e,pE()}function SE(e){tE?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function CE(e){tE=e}function wE(e){rE=e}function TE(e){iE=e,rr(XT,e)}function EE({force:e=!1}={}){if(!tE)return;nE=h(`usage`);let t={type:`request-usage-report`,requestId:nE};e&&(t.force=!0);let n=hE(rE);n!==null&&(t.days=n),sE=null,mE(!0),!tE(t)&&(sE=je,mE(!1))}function DE(e){cE=e,fE(`refresh-status`)}function OE(e){QT=e,fE(`sessions`)}function kE(e){let t=e;$T={...$T,[ZS(t)]:t},fE(`plan-limits`),pE()}function AE(e){iC(e,nE)&&(sE=null,mE(!1),ZT=e,fE(`report`),pE())}function jE(){let e=ZT?.pricing||(QT?{source:QT.pricingSource}:null),t=eC(e?.fetchedAt),n=[$S(e,t!==null&&t>0?FS(t):``)],r=rC(ZT);r&&n.push(r);let i=nC(ZT?.scan);return i&&n.push(i),n}var ME=26,NE=97;function PE(e){return Object.values(e.elements).filter(e=>e.kind===`unit`)}function FE(e){let t=String.fromCharCode(NE+e%ME),n=Math.floor(e/ME);return n===0?t:`${t}${n+1}`}function IE(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map,r=new Set;function i(e){let a=n.get(e);if(a!==void 0)return a;let o=t.get(e);if(!o||r.has(e))return 0;r.add(e);let s=1+Math.max(0,...o.after.map(i));return r.delete(e),n.set(e,s),s}for(let t of e)i(t.id);return n}function LE(e){let t=PE(e),n=IE(t),r=new Map;for(let e of t){let t=n.get(e.id)??1;r.set(t,[...r.get(t)??[],e])}let i=new Map,a=[];for(let e of[...r.keys()].sort((e,t)=>e-t)){let t=(r.get(e)??[]).sort((e,t)=>e.title.localeCompare(t.title)||e.id.localeCompare(t.id));for(let[n,r]of t.entries())i.set(r.id,t.length===1?String(e):`${e}${FE(n)}`),a.push(r)}return a.map(e=>({unitId:e.id,title:e.title,status:e.status,level:n.get(e.id)??1,label:i.get(e.id)??``,afterLabels:e.after.flatMap(e=>i.get(e)??[]),linkedBoardId:e.linkedBoardId}))}var RE=14,zE=30,BE=40,VE=120,HE=300,UE=400,WE=4e4,GE=2e4,KE=4e5,qE=6,JE=12,YE=3e3,XE=14,ZE=8,QE=100,$E=6.6,eD=5,tD=10,nD=2,rD=[.5,.35,.65,.2,.8],iD=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}],aD={right:0,left:1,bottom:2,top:3},oD={left:0,right:1,top:2,bottom:3},sD=[1,0,3,2];function cD(e){return e===`left`||e===`right`}function lD(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function uD(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function dD(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);return{x:t,y:n,width:r-t,height:i-n}}function fD(e,t){let n=[...e].sort((e,t)=>e.rect.x-t.rect.x),r=[];for(let e of n){r=r.filter(t=>t.rect.x+t.rect.width>=e.rect.x);for(let n of r)pD(n.rect,e.rect)&&t(n,e);r.push(e)}}function pD(e,t){return e.x<=t.x+t.width&&t.x<=e.x+e.width&&e.y<=t.y+t.height&&t.y<=e.y+e.height}function mD(e,t){return e[0]-t[0]||e[1]-t[1]}function hD(e){let t=[];return fD(e.map((e,t)=>({group:0,index:t,rect:e})),(e,n)=>{t.push(e.index<n.index?[e.index,n.index]:[n.index,e.index])}),t.sort(mD)}function gD(e,t){let n=[];return fD([...e.map((e,t)=>({group:0,index:t,rect:e})),...t.map((e,t)=>({group:1,index:t,rect:e}))],(e,t)=>{e.group!==t.group&&n.push(e.group===0?[e.index,t.index]:[t.index,e.index])}),n.sort(mD)}function _D(e){return dD(e.map(e=>({...e,width:0,height:0})))??{x:0,y:0,width:0,height:0}}function vD(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);i?i.push(r):n.set(e,[r])}return n}function yD(e){return e.from.y===e.to.y}function bD(e,t){let n=t.x+t.width,r=t.y+t.height;if(yD(e)){let i=e.from.y;return t.y<i&&i<r&&Math.min(e.from.x,e.to.x)<n&&Math.max(e.from.x,e.to.x)>t.x}let i=e.from.x;return t.x<i&&i<n&&Math.min(e.from.y,e.to.y)<r&&Math.max(e.from.y,e.to.y)>t.y}function xD(e,t){return e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height}function SD(e){let t=e.filter((t,n)=>{let r=e[n-1];return!r||r.x!==t.x||r.y!==t.y});return t.filter((e,n)=>{let r=t[n-1],i=t[n+1];return!r||!i||!(r.x===e.x&&e.x===i.x||r.y===e.y&&e.y===i.y)})}function CD(e){return e.slice(1).flatMap((t,n)=>{let r=e[n];return r?[{from:r,to:t}]:[]})}function wD(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function TD(e){if(e.length<=Oe.layoutWarnings)return[...e];let t=e.slice(0,Oe.layoutWarnings-1);return[...t,`and ${e.length-t.length} more`]}function ED(e,t){return t.x>=e.x+e.width||t.x+t.width<=e.x}function DD(e,t,n){if(e.id===t.id)return{exitSide:`right`,entrySide:`top`};if(n)return{exitSide:`bottom`,entrySide:`bottom`};let r=lD(e),i=lD(t);return ED(e,t)?i.x>r.x?{exitSide:`right`,entrySide:`left`}:{exitSide:`left`,entrySide:`right`}:i.y>r.y?{exitSide:`bottom`,entrySide:`top`}:{exitSide:`top`,entrySide:`bottom`}}var OD=[`right`,`left`,`bottom`,`top`];function kD(e,t){let{wire:n,from:r,to:i}=e;if(n.back||r.id===i.id)return[t];let a=e.outputPort||n.fromSide?[e.exitSide]:[t.exitSide,...OD.filter(e=>e!==t.exitSide)],o=n.toSide?[n.toSide]:[t.entrySide,...OD.filter(e=>e!==t.entrySide)];return a.flatMap(e=>o.map(t=>({exitSide:e,entrySide:t})))}function AD(e,t){let n=e.outputPort??LD(e.from,t.exitSide,1)[0]??lD(e.from),r=LD(e.to,t.entrySide,1)[0]??lD(e.to);if(!HD(t.exitSide,t.entrySide))return{...e,...t,start:n,end:r};let i=UD(r,t.entrySide,e.to,n),a=i===r&&!e.outputPort?UD(n,t.exitSide,e.from,r):n;return{...e,...t,start:a,end:i}}function jD(e,t){return e.turnsAndCrossings<t.turnsAndCrossings||e.turnsAndCrossings===t.turnsAndCrossings&&e.cost<t.cost}function MD(e,t,n){let r=aO(e,t,{usageByEdge:new Map,usageByNodeAndAxis:new Map},null,n,{remainingExpansions:YE}),i=r?.at(-1),a=i===void 0?1/0:n.bestCost[i]??1/0;if(rO(n),!r||a===1/0)return null;let o=SD(r.map(t=>{let n=t>>2,r=n%e.xs.length;return{x:e.xs[r]??0,y:e.ys[(n-r)/e.xs.length]??0}}));return{segments:CD(o),bounds:_D(o),bends:Math.max(o.length-2,0),cost:a}}function ND(e,t){let n=t.filter(t=>pD(e.bounds,t.bounds)&&t.segments.some(t=>e.segments.some(e=>wO(e,t)))).length;return{turnsAndCrossings:e.bends+n,cost:e.cost}}function PD(e,t,n){let r=new Map(e.map(e=>[e,kD(e,t.get(e)??{exitSide:e.exitSide,entrySide:e.entrySide})]));if(![...r.values()].some(e=>e.length>1))return;let i=XD([...r].flatMap(([e,t])=>t.map(t=>AD(e,t))),[...n.boxesById.values(),...n.panels],n.softObstacles,n.contentTop);if(!i)return;let a=nO(i),o=new Map(e.flatMap(e=>{let[t]=r.get(e)??[],n=t?MD(i,AD(e,t),a):null;return n?[[e,n]]:[]}));for(let[e,t]of r){let n=o.get(e);if(t.length<2||!n)continue;let r=[...o].flatMap(([t,n])=>t===e?[]:[n]),s={pair:t[0],score:ND(n,r)};for(let n of t.slice(1)){let t=MD(i,AD(e,n),a),o=t?ND(t,r):null;o&&jD(o,s.score)&&(s={pair:n,score:o})}s.pair&&(e.exitSide=s.pair.exitSide,e.entrySide=s.pair.entrySide)}}function FD(e,t){let n=e=>e.entrySide===t.get(e)?.entrySide;for(let r=!0;r;){r=!1;for(let i of e){let a=t.get(i);!a||n(i)||i.wire.toSide||e.some(e=>e!==i&&e.to.id===i.to.id&&e.styleKey===i.styleKey&&e.entrySide===a.entrySide&&n(e))&&(i.exitSide=i.outputPort||i.wire.fromSide?i.exitSide:a.exitSide,i.entrySide=a.entrySide,r=!0)}}}function ID(e){let t=new Map,n=e.wires.flatMap(n=>{let r=e.boxesById.get(n.from),i=e.boxesById.get(n.to);if(!r||!i)return[];let a=DD(r,i,n.back),o=r.outputs.find(e=>e.id===n.fromOutput),s=n.tone===`lane`?r.lane?.hex??null:null,c={wire:n,from:r,to:i,strokeHex:s,styleKey:`${n.dashed||n.back}|${n.tone}|${s}`,exitSide:o?`right`:n.fromSide??a.exitSide,entrySide:n.toSide??a.entrySide,busKey:null,exitKey:``,outputPort:o?.port??null,start:o?.port??lD(r),end:lD(i)};return t.set(c,a),[c]});PD(n,t,e),FD(n,t);for(let e of n){let t=e.wire.fromOutput;e.exitKey=e.outputPort&&t?`${e.from.id}|output ${t}|${e.styleKey}`:`${e.from.id}|${e.exitSide}|${e.styleKey}`}let r=e=>`${e.to.id}|${e.entrySide}|${e.styleKey}`,i=new Map;for(let e of n)i.set(r(e),(i.get(r(e))??0)+1);for(let e of n)(i.get(r(e))??0)>1&&(e.busKey=r(e));return n}function LD(e,t,n){let r=Array.from({length:n},(e,t)=>t);if(cD(t)){let i=Math.round(t===`left`?e.x:e.x+e.width),a=Math.min(XE,(e.height-16)/Math.max(n-1,1)),o=e.y+Math.min(e.height/2,40)-(n-1)*a/2,s=Math.max(e.y+ZE,Math.min(o,e.y+e.height-ZE-(n-1)*a));return r.map(e=>({x:i,y:Math.round(s+e*a)}))}let i=Math.round(t===`top`?e.y:e.y+e.height),a=e.x+e.width/2-(n-1)*XE/2;return r.map(e=>({x:Math.round(a+e*XE),y:i}))}function RD(e,t){let n=cD(t)?e.height:e.width;return Math.max(1,Math.floor((n-16)/XE)+1)}function zD(e){return vD(e.flatMap(e=>[...e.outputPort?[]:[{box:e.from,side:e.exitSide,groupKey:`exit|${e.styleKey}`,wireId:e.wire.id,farPoint:lD(e.to),assign:t=>{e.start=t}}],{box:e.to,side:e.entrySide,groupKey:e.busKey?`bus|${e.busKey}`:`entry|${e.wire.id}`,wireId:e.wire.id,farPoint:e.outputPort??lD(e.from),assign:t=>{e.end=t}}]),e=>`${e.box.id}|${e.side}`)}function BD(e){return new Map([...e.entries()].map(([e,t])=>[e,[...vD(t,e=>e.groupKey).entries()].map(([e,t])=>({groupKey:e,firstWireId:t.map(e=>e.wireId).sort()[0]??e,farCoordinate:t.reduce((e,t)=>e+(cD(t.side)?t.farPoint.y:t.farPoint.x),0)/t.length})).sort((e,t)=>e.farCoordinate-t.farCoordinate||e.firstWireId.localeCompare(t.firstWireId)||e.groupKey.localeCompare(t.groupKey)).map(e=>e.groupKey)]))}function VD(e,t){for(let[n,r]of e){let e=r[0],i=t.get(n)??[];if(!e)continue;let a=LD(e.box,e.side,i.length);for(let e of r){let t=a[i.indexOf(e.groupKey)];t&&e.assign(t)}}}function HD(e,t){return e===`right`&&t===`left`||e===`left`&&t===`right`||e===`bottom`&&t===`top`||e===`top`&&t===`bottom`}function UD(e,t,n,r){return cD(t)?r.y>=n.y+ZE&&r.y<=n.y+n.height-ZE?{x:e.x,y:r.y}:e:r.x>=n.x+ZE&&r.x<=n.x+n.width-ZE?{x:r.x,y:e.y}:e}function WD(e,t){let n=(e,n)=>(t.get(`${e.id}|${n}`)?.length??0)===1,r=new Map([...vD(e,e=>e.exitKey)].map(([e,t])=>[e,t.length]));for(let t of e){if(t.from.id===t.to.id||!HD(t.exitSide,t.entrySide))continue;let e=t.busKey===null&&n(t.to,t.entrySide)?UD(t.end,t.entrySide,t.to,t.start):t.end;e===t.end?t.outputPort===null&&n(t.from,t.exitSide)&&r.get(t.exitKey)===1&&(t.start=UD(t.start,t.exitSide,t.from,t.end)):t.end=e}}function GD(e,t){return[...e.entries()].flatMap(([e,n])=>{let r=n[0],i=t.get(e)?.length??0;return!r||i<=RD(r.box,r.side)?[]:[`box ${r.box.id} has ${i} wires on its ${r.side} side, more than fit`]})}function KD(e){let t=[...e];for(let[n,r]of e.entries()){let i=e[n+1];i!==void 0&&i-r>42&&t.push(Math.round((r+i)/2))}return[...new Set(t)].sort((e,t)=>e-t)}function qD(e,t,n){let r=0,i=e.length;for(;r<i;){let a=r+i>>1,o=e[a]??1/0,s=n?o<t:o<=t;s&&(r=a+1),s||(i=a)}return r}function JD(e,t,n){return{first:qD(e,t,!1),last:qD(e,n,!0)-1}}function YD(e,t,n){return{first:Math.max(0,qD(e,t,!1)-1),last:Math.min(qD(e,n,!0)-1,e.length-2)}}function XD(e,t,n,r){let i=[...t,...n],a=dD([...i,...e.flatMap(e=>[{...e.start,width:0,height:0},{...e.end,width:0,height:0}])]);if(!a)return null;let o=e.flatMap(e=>[e.start.x,e.end.x]),s=e.flatMap(e=>[e.start.y,e.end.y]),c=r+4,l=[...i.flatMap(e=>[e.x-RE,e.x+e.width+RE]),a.x-42,a.x+a.width+42].map(Math.round),u=[...i.flatMap(e=>[e.y-RE,e.y+e.height+RE]),a.y-42,a.y+a.height+42].map(Math.round).filter(e=>e>=c),d=KD([...new Set([...l,...o])].sort((e,t)=>e-t)),f=KD([...new Set([...u,...s])].sort((e,t)=>e-t));if(d.length*f.length>WE)return null;let p=t.map(e=>uD(e,1)),m=(e,t)=>{let n=new Uint8Array(d.length*f.length);for(let r of t){let t=e===0?YD(d,r.x,r.x+r.width):JD(d,r.x,r.x+r.width),i=e===0?JD(f,r.y,r.y+r.height):YD(f,r.y,r.y+r.height);for(let e=i.first;e<=i.last;e+=1)n.fill(1,e*d.length+t.first,e*d.length+t.last+1)}return n};return{xs:d,ys:f,xIndexByValue:new Map(d.map((e,t)=>[e,t])),yIndexByValue:new Map(f.map((e,t)=>[e,t])),isBlocked:[m(0,p),m(1,p)],isSoft:[m(0,n),m(1,n)]}}function ZD(){let e=[],t=[],n=(n,r)=>{[e[n],e[r]]=[e[r]??0,e[n]??0],[t[n],t[r]]=[t[r]??0,t[n]??0]};return{push(r,i){e.push(r),t.push(i);let a=e.length-1;for(;a>0;){let e=a-1>>1;if((t[e]??0)<=(t[a]??0))break;n(e,a),a=e}},pop(){let r=e[0],i=e.pop(),a=t.pop();if(e.length===0||i===void 0||a===void 0)return r;e[0]=i,t[0]=a;let o=0;for(;;){let i=o*2+1,a=i+1,s=o;if(i<e.length&&(t[i]??0)<(t[s]??0)&&(s=i),a<e.length&&(t[a]??0)<(t[s]??0)&&(s=a),s===o)return r;n(s,o),o=s}}}}function QD(e,t,n,r){return r===0?{axis:0,index:n*e.xs.length+t}:r===1?{axis:0,index:n*e.xs.length+t-1}:r===2?{axis:1,index:n*e.xs.length+t}:{axis:1,index:(n-1)*e.xs.length+t}}function $D(e,t){return`${e}\n${t}`}function eO(e,t){let n=e.countByExitKey.get(t.exitKey)??0;if(t.busKey===null)return n;let r=e.countByBusKey.get(t.busKey)??0,i=e.countByBusAndExitKey.get($D(t.busKey,t.exitKey))??0;return n+r-i}function tO(e,t,n,r,i){let a=e.usageByEdge.get(n.axis*1e6+n.index),o=e.usageByNodeAndAxis.get((1-n.axis)*1e6+r),s=a?eO(a,t):0,c=s>0,l=a!==void 0&&a.total>s,u=o!==void 0&&o.total>eO(o,t);return(c?-i*.5:0)+(l?VE:0)+(u?BE:0)}function nO(e){let t=e.xs.length*e.ys.length*4;return{bestCost:new Float64Array(t).fill(1/0),cameFrom:new Int32Array(t).fill(-1),touchedStates:[]}}function rO(e){for(let t of e.touchedStates)e.bestCost[t]=1/0,e.cameFrom[t]=-1;e.touchedStates.length=0}function iO(e,t,n,r,i,a){let o=aO(e,t,n,r,i,a);return rO(i),o}function aO(e,t,n,r,i,a){let o=e.xs.length,s=e.xIndexByValue.get(t.start.x),c=e.yIndexByValue.get(t.start.y),l=e.xIndexByValue.get(t.end.x),u=e.yIndexByValue.get(t.end.y);if(s===void 0||c===void 0||l===void 0||u===void 0)return null;let d=c*o+s,f=u*o+l,p=aD[t.exitSide],m=oD[t.entrySide],{bestCost:h,cameFrom:g,touchedStates:_}=i,v=ZD(),y=d*4+p,ee=(n,r)=>Math.abs((e.xs[n]??0)-t.end.x)+Math.abs((e.ys[r]??0)-t.end.y);h[y]=0,_.push(y),v.push(y,ee(s,c));for(let i=0;i<GE&&a.remainingExpansions>0;i+=1){--a.remainingExpansions;let i=v.pop();if(i===void 0)return null;let s=i>>2,c=i&3;if(s===f&&c===m)return oO(g,i);let l=s%o,u=(s-l)/o,y=h[i]??1/0;for(let[a,te]of iD.entries()){if(s===d&&a!==p||a===sD[c])continue;let ne=l+te.x,b=u+te.y;if(ne<0||b<0||ne>=o||b>=e.ys.length)continue;let x=b*o+ne;if(x===f&&a!==m)continue;let S=QD(e,l,u,a);if(s!==d&&x!==f&&e.isBlocked[S.axis]?.[S.index]===1)continue;let re={x:e.xs[l]??0,y:e.ys[u]??0},ie={x:e.xs[ne]??0,y:e.ys[b]??0},ae=Math.abs(ie.x-re.x)+Math.abs(ie.y-re.y),oe=r!==null&&bD({from:re,to:ie},r),se=ae+(a===c?0:zE)+(e.isSoft[S.axis]?.[S.index]===1?HE:0)+(oe?UE:0)+tO(n,t,S,x,ae),ce=x*4+a,le=y+Math.max(se,1);le>=(h[ce]??1/0)||(h[ce]=le,g[ce]=i,_.push(ce),v.push(ce,le+ee(ne,b)))}}return null}function oO(e,t){let n=[];for(let r=t;r!==-1;r=e[r]??-1)n.push(r);return n.reverse()}function sO(e,t,n,r,i){let a=e.xs.length,o=(e,t)=>e.set(t,(e.get(t)??0)+i),s=(e,t)=>{let r=e.get(t)??{total:0,countByExitKey:new Map,countByBusKey:new Map,countByBusAndExitKey:new Map};e.set(t,r),r.total+=i,o(r.countByExitKey,n.exitKey),n.busKey!==null&&(o(r.countByBusKey,n.busKey),o(r.countByBusAndExitKey,$D(n.busKey,n.exitKey)))};for(let[n,i]of r.entries()){let o=r[n-1];if(o===void 0)continue;let c=o>>2,l=i&3,u=c%a,d=QD(e,u,(c-u)/a,l);s(t.usageByEdge,d.axis*1e6+d.index),s(t.usageByNodeAndAxis,d.axis*1e6+c),s(t.usageByNodeAndAxis,d.axis*1e6+(i>>2))}}function cO(e,t){let n=iD[aD[t]]??{x:0,y:0};return{x:e.x+n.x*RE,y:e.y+n.y*RE}}function lO(e){let t=cO(e.start,e.exitSide),n=cO(e.end,e.entrySide);return SD([e.start,t,{x:n.x,y:t.y},n,e.end])}function uO(e,t){if(!e.wire.back)return null;let n=dD([e.from,e.to]);return n?t.find(e=>e.x<=n.x&&e.y<=n.y&&e.x+e.width>=n.x+n.width&&e.y+e.height>=n.y+n.height)??n:null}function dO(e,t){let n=e=>Math.abs(e.start.x-e.end.x)+Math.abs(e.start.y-e.end.y);return[...e].sort((e,r)=>n(t(r))-n(t(e))||t(e).wire.id.localeCompare(t(r).wire.id))}function fO(e,t,n){let r=e&&n?SD(n.map(t=>{let n=t>>2,r=n%e.xs.length;return{x:e.xs[r]??0,y:e.ys[(n-r)/e.xs.length]??0}})):lO(t);return{plan:t,points:r,segments:CD(r),states:n}}function pO(e,t,n){let r=XD(e,[...t.boxesById.values(),...t.panels],t.softObstacles,t.contentTop),i=r?nO(r):null,a={usageByEdge:new Map,usageByNodeAndAxis:new Map},o=new Map;for(let s of dO(e,e=>e)){let e=r&&i?iO(r,s,a,uO(s,t.loopFrames),i,n):null;r&&e&&sO(r,a,s,e,1),o.set(s.wire.id,fO(r,s,e))}return{drawn:e.flatMap(e=>o.get(e.wire.id)??[]),grid:r,usage:a}}function mO(e){return Math.max(0,e.points.length-2)}function hO(e,t,n){let r=_D(e.points),i=t.filter(t=>pD(r,_D(t.points))&&DO(e,t)!==null).length;return kO(n).filter(t=>{let n=uD(t,-2);return pD(r,n)&&AO(e,t,n)}).length*QE+i}function gO(e,t){let{grid:n,usage:r}=e;if(!n)return e.drawn;let i=nO(n),a={remainingExpansions:KE},o=new Map(e.drawn.map(e=>[e.plan.wire.id,e]));for(let s of dO(e.drawn,e=>e.plan)){if(!s.states||a.remainingExpansions<=0)continue;let e=[...o.values()].filter(e=>e.plan!==s.plan),c=hO(s,e,t);if(c===0)continue;sO(n,r,s.plan,s.states,-1);let l=fO(n,s.plan,iO(n,s.plan,r,uO(s.plan,t.loopFrames),i,a)),u=mO(l)<=Math.max(mO(s),qE),d=l.states&&u&&hO(l,e,t)<c?l:s;sO(n,r,d.plan,d.states??s.states,1),o.set(d.plan.wire.id,d)}return e.drawn.map(e=>o.get(e.plan.wire.id)??e)}function _O(e){return Math.ceil(e.length*$E)}function vO(e,t){return{x:e.x-t/2,y:e.y-tD,width:t,height:13}}function yO(e){return Math.abs(e.from.x-e.to.x)+Math.abs(e.from.y-e.to.y)}function bO(e,t){if(!yD(e))return[];let n=e.from.y;return[Math.min(e.from.x,e.to.x)+eD+t/2,Math.max(e.from.x,e.to.x)-eD-t/2].flatMap(e=>[{x:e,y:n-eD},{x:e,y:n+eD+tD}])}function xO(e,t){let n=[...e].sort((e,t)=>yO(t)-yO(e));return[...e.slice(0,1),...n].flatMap(e=>[...rD.flatMap(n=>{let r=e.from.x+(e.to.x-e.from.x)*n,i=e.from.y+(e.to.y-e.from.y)*n;return yD(e)?[{x:r,y:i-eD},{x:r,y:i+eD+tD}]:[{x:r+eD+t/2,y:i+tD/2},{x:r-eD-t/2,y:i+tD/2}]}),...bO(e,t)])}function SO(e,t,n){let r=new Map,i=e.flatMap(e=>e.segments),a=[...t.boxesById.values(),...t.softObstacles];for(let o of e){let e=o.plan.wire.label;if(!e)continue;let s=_O(e),c=xO(o.segments,s),l=c.find(e=>{let n=vO(e,s);if(n.y<t.contentTop)return!1;let o=uD(n,nD);return i.some(e=>bD(e,o))||a.some(e=>xD(n,e))?!1:![...r.values()].some(e=>xD(n,e.bounds))}),u=l??c[0]??lD(o.plan.from);l||n.push(`wire ${o.plan.wire.id} label "${e}" has no clear spot`),r.set(o.plan.wire.id,{at:{x:Math.round(u.x),y:Math.round(u.y)},bounds:vO(u,s)})}return r}function CO(e,t,n){return e>Math.min(t,n)+.5&&e<Math.max(t,n)-.5}function wO(e,t){if(yD(e)===yD(t))return!1;let n=yD(e)?e:t,r=n===e?t:e;return CO(r.from.x,n.from.x,n.to.x)&&CO(n.from.y,r.from.y,r.to.y)}function TO(e,t){if(yD(e)!==yD(t))return!1;let n=yD(e),r=e=>n?e.from.y:e.from.x,i=e=>Math.min(n?e.from.x:e.from.y,n?e.to.x:e.to.y),a=e=>Math.max(n?e.from.x:e.from.y,n?e.to.x:e.to.y);return r(e)===r(t)&&Math.min(a(e),a(t))-Math.max(i(e),i(t))>1}function EO(e,t){return e.plan.busKey!==null&&e.plan.busKey===t.plan.busKey||e.plan.exitKey===t.plan.exitKey}function DO(e,t){if(EO(e,t))return null;let n=e.segments.flatMap(e=>t.segments.map(t=>[e,t]));return n.some(([e,t])=>wO(e,t))?`wire ${e.plan.wire.id} crosses wire ${t.plan.wire.id}`:n.some(([e,t])=>TO(e,t))?`wire ${e.plan.wire.id} overlaps wire ${t.plan.wire.id}`:null}function OO(e){return hD(e.map(e=>_D(e.points))).flatMap(([t,n])=>{let r=e[t],i=e[n];return r&&i?DO(r,i)??[]:[]})}function kO(e){return[...e.boxesById.values(),...e.panels]}function AO(e,t,n){return t.id===e.plan.from.id||t.id===e.plan.to.id?!1:e.segments.some(e=>bD(e,n))}function jO(e,t){let n=kO(t),r=n.map(e=>uD(e,-2));return gD(e.map(e=>_D(e.points)),r).flatMap(([t,i])=>{let a=e[t],o=n[i],s=r[i];return!a||!o||!s?[]:AO(a,o,s)?[`wire ${a.plan.wire.id} runs through ${o.kind} ${o.id}`]:[]})}function MO(e){return e.flatMap(e=>{if(!e.states)return[`wire ${e.plan.wire.id} found no clear route, so it is drawn as a straight dog-leg`];let t=mO(e);return t>qE?[`wire ${e.plan.wire.id} bends ${t} times`]:[]})}function NO(e,t){return yD(t)?e.y===t.from.y&&e.x>=Math.min(t.from.x,t.to.x)&&e.x<=Math.max(t.from.x,t.to.x):e.x===t.from.x&&e.y>=Math.min(t.from.y,t.to.y)&&e.y<=Math.max(t.from.y,t.to.y)}function PO(e,t){if(!t||t===e)return null;let n=e.points.find(e=>t.segments.some(t=>NO(e,t)));return!n||n.x===e.plan.end.x&&n.y===e.plan.end.y?null:n}function FO(e,t){let n=e[t],r=e[t+1];n!==void 0&&r!==void 0&&(e[t]=r,e[t+1]=n)}function IO(e,t,n,r,i){VD(n,r),WD(e,r);let a=pO(e,t,i);return{routed:a,crossingCost:jO(a.drawn,t).length*QE+OO(a.drawn).length}}function LO(e,t,n,r,i){let a=IO(e,t,n,r,i);if(e.length>JE)return gO(a.routed,t);for(let o of r.values())for(let s=0;a.crossingCost>0&&s+1<o.length;s+=1){FO(o,s);let c=IO(e,t,n,r,i);c.crossingCost<a.crossingCost?a=c:FO(o,s)}return gO(IO(e,t,n,r,i).routed,t)}function RO(e){let t=ID(e),n=zD(t),r=BD(n),i={remainingExpansions:KE},a=LO(t,e,n,r,i),o=i.remainingExpansions>0?[]:[`the board has more wires than fit in one routing pass, so some are drawn as straight dog-legs`],s=[],c=SO(a,e,s),l=new Map;for(let e of[...a].sort((e,t)=>e.plan.wire.id.localeCompare(t.plan.wire.id)))e.plan.busKey&&!l.has(e.plan.busKey)&&l.set(e.plan.busKey,e);let u=a.map(e=>{let{plan:t,points:n}=e,r=t.busKey?l.get(t.busKey):void 0;return{kind:`wire`,id:t.wire.id,path:wD(n),start:t.start,end:t.end,label:t.wire.label,labelAt:c.get(t.wire.id)?.at??lD(t.from),isDashed:t.wire.dashed||t.wire.back,isBack:t.wire.back,strokeHex:t.strokeHex,tone:t.wire.tone,hasArrowhead:r===void 0||r===e,joinAt:PO(e,r)}}),d=[...c.values()].map(e=>e.bounds),f=a.flatMap(e=>e.points).map(e=>({x:e.x,y:e.y,width:0,height:0}));return{wires:u,segments:a.flatMap(e=>e.segments),warnings:[...o,...jO(a,e),...OO(a),...MO(a),...GD(n,r),...s],extent:dD([...f,...d])}}var B=40,zO=44,BO=220,VO=90,HO=30,UO=12,WO=20,GO=18,KO=28,qO=12,JO=2,YO=20,XO=26,ZO=18,QO=26,$O=170,ek=21,tk=17,nk=10,rk=22,ik=24,ak=16,ok=16,sk=26,ck=24,lk=8,uk=10,dk=14,fk=4,pk=40,mk=26,hk=24,gk=8,_k=320,vk=Object.freeze({blue:`#60a5fa`,green:`#4ade80`,orange:`#fb923c`,pink:`#f472b6`,cyan:`#22d3ee`,yellow:`#facc15`});function yk(e,t){let n=e.split(/\s+/).filter(Boolean),r=[],i=``;for(let e of n){let n=e.match(RegExp(`.{1,${t}}`,`g`))??[e];for(let e of n){let n=i?`${i} ${e}`:e;n.length<=t?i=n:(r.push(i),i=e)}}return i&&r.push(i),r.length>0?r:[``]}function bk(e,t,n){let r=e.muted?2:0,i=e.style===`numbered`?`${t}.`:e.style===`kv`?e.key:null,a=(t,n,r,i)=>({text:t,muted:e.muted,style:e.style,marker:n===0?i:null,indentChars:r,isFirstRow:n===0});if(i&&i.length+1>qO){let t=yk(e.text,n-r-JO).map(e=>a(e,1,JO,null));return[a(``,0,0,i),...t]}let o=e.style===`item`?JO:i?i.length+1:0;return yk(e.text,n-r-o-+(e.style===`code`)).map((e,t)=>a(e,t,o,i))}function xk(e,t=XO){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,bk(e,n,t)))}function Sk(e,t){let n=e.lanes.find(e=>e.id===t.lane);return n?{label:n.label||n.id,hex:vk[n.color]}:null}function Ck(e){return e.column!==null&&e.at===null&&e.near===null}function wk(e){return e.width??BO}function Tk(e,t){return Math.floor(e*(t-24)/196)}function Ek(e){if(!e.media)return null;let t=wk(e),n=t-24,r=Math.round(_k*t/BO);return{width:n,height:Math.min(r,Math.max(1,Math.round(n*e.media.height/e.media.width)))}}function Dk(e,t,n,r){return!e.media||!r?null:{kind:e.media.kind,asset:e.media.asset,mime:e.media.mime,hasPreview:e.media.hasPreview,alt:e.media.alt,x:t.x+UO,y:t.y+n,width:r.width,height:r.height}}function Ok(e,t){let n=wk(t),r=Tk(YO,n),i=yk(t.title,r),a=t.change===`relabeled`&&t.was?yk(t.was,r):[],o=xk(t.lines,Tk(XO,n)),s=Sk(e,t),c=s!==null&&!Ck(t),l=UO+(a.length+i.length)*WO+o.length*GO,u=Ek(t),d=u?u.height+gk:0,f=l+UO+d+(c?26:0),p=t.shape===`decision`?t.outputs:[];return{titleLines:i,wasLines:a,bodyLines:o,lane:s,showsLanePill:c,headerHeight:f,outputs:p,mediaTop:l+gk,mediaSize:u,height:f+p.length*KO}}function V(e,t){return Object.values(e.elements).filter(e=>e.kind===t)}function kk(e){let t=yk(e.text,ek);return{lines:t,height:24+(t.length+1)*tk}}function Ak(e){let t=new Map;for(let n of V(e,`note`)){let e=t.get(n.on),r=kk(n).height;t.set(n.on,e===void 0?r:e+nk+r)}return t}function jk(e){return e.columns.map(e=>e.title?yk(e.title,ik):[])}function Mk(e){return(Math.max(1,...e.map(e=>e.length))-1)*ak}function Nk(e,t){let n=V(e,`box`).filter(Ck),r=new Set(n.filter(e=>t.has(e.id)).map(e=>e.column)),i=new Set(V(e,`frame`).flatMap(e=>e.contains)),a=new Set(n.filter(e=>i.has(e.id)).map(e=>e.column)),o=e=>uk+(e!==void 0&&a.has(e)?ZO:0);return e.columns.map((t,n)=>{let i=r.has(t.id);return{left:i?156:o(t.id),right:o(e.columns[n+1]?.id),minimumWidth:i?Math.max(VO,186):VO}})}function Pk(e,t,n){return e.map((e,r)=>{let i=t[r]??0,a=n[r]??0,o=i>0?e.left+e.right+(i+1)*dk:0,s=a>0?e.left+e.right+a+20:0;return Math.max(e.minimumWidth,o,s)})}function Fk(e){let t=new Map(e.columns.map((e,t)=>[e.id,t])),n=e.columns.map(()=>BO);for(let r of V(e,`box`).filter(Ck)){let e=t.get(r.column)??0;n[e]=Math.max(n[e]??BO,wk(r))}return n}function Ik(e,t){let n=[],r=B;for(let[i,a]of e.entries())n.push(r),r+=a+(t[i]??VO);return n}function Lk(e,t){return(e.at(-1)??B)+(t.at(-1)??BO)}function Rk(e){let t=new Map;for(let n of V(e,`frame`))for(let e of n.contains)t.has(e)||t.set(e,n.id);return t}function zk(e,t){return e===t?0:(e?ZO:0)+(t?44:0)}function Bk(e,t){return e.lanes.some(e=>e.id===t.lane)?t.lane??``:``}function Vk(e,t){let n=new Set(t.map(t=>Bk(e,t)));return[``,...e.lanes.map(e=>e.id)].filter(e=>n.has(e))}function Hk(e,t,n){let r=Ok(e,t),i=wk(t);return{kind:`box`,id:t.id,x:n.x,y:n.y,width:i,height:r.height,titleLines:r.titleLines,bodyLines:r.bodyLines,lane:r.lane,showsLanePill:r.showsLanePill,change:t.change,wasLines:r.wasLines,shape:t.shape,headerHeight:r.headerHeight,media:Dk(t,n,r.mediaTop,r.mediaSize),outputs:r.outputs.map((e,t)=>({id:e.id,label:e.label,port:{x:n.x+i,y:n.y+r.headerHeight+t*KO+KO/2}}))}}function Uk(e,t,n,r,i,a){let o=Rk(e),s=V(e,`box`).filter(Ck).map((e,t)=>({box:e,index:t})).sort((e,t)=>e.box.order-t.box.order||e.index-t.index).map(({box:e})=>e),c=Vk(e,s),l=c.some(e=>e!==``),u=Lk(t,n),d=[],f=r;for(let n of c){let r=e.lanes.find(e=>e.id===n),c=f+(l?mk:0),p=new Map,m=new Map;for(let r of s){if(Bk(e,r)!==n)continue;let s=Math.max(0,e.columns.findIndex(e=>e.id===r.column)),l=o.get(r.id)??null,u=(p.get(r.column)??c)+zk(m.get(r.column)??null,l),d=Hk(e,r,{x:t[s]??B,y:u}),f=(i.get(r.id)??0)-lk;p.set(r.column,u+Math.max(d.height,f)+HO),m.set(r.column,l),a.set(r.id,d)}let h=Math.max(c,...p.values())-HO;l&&d.push({id:n,label:r?r.label||r.id:``,hex:r?vk[r.color]:``,x:B,y:f,width:u-B,height:h-f}),f=h+hk+HO}return d}function Wk(e,t,n){let r=e.y+e.height/2-n.height/2,i=e.x+e.width/2-n.width/2;switch(t.side){case`right`:return{x:e.x+e.width+t.gap,y:r};case`left`:return{x:e.x-n.width-t.gap,y:r};case`bottom`:return{x:i,y:e.y+e.height+t.gap};case`top`:return{x:i,y:e.y-n.height-t.gap}}}function Gk(e,t){let n=[...e.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0);return{x:e.size>0?n+VO:B,y:t}}function Kk(e,t,n,r){let i=V(e,`box`).filter(e=>e.at===null&&e.near!==null),a=new Set(i.map(e=>e.id)),o=(i,s)=>{let c=n.get(i.id);if(c||!i.near)return c;let l=e.elements[i.near.of],u=l?.kind===`box`&&!s.has(l.id)&&(n.has(l.id)||a.has(l.id))?o(l,new Set([...s,i.id])):void 0;u||r.push(`box ${i.id} sits near ${i.near.of}, which is not placed on the board`);let d={width:wk(i),height:Ok(e,i).height},f=u?Wk(u,i.near,d):Gk(n,t),p=Hk(e,i,{x:Math.round(f.x),y:Math.round(f.y)});return n.set(i.id,p),p};for(let e of i)o(e,new Set)}function qk(e,t,n,r,i){let a=Lk(n,r),o=Math.max(a,...t.map(e=>e.x+e.width))+VO,s=V(e,`panel`).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id)),c=i;return s.map(e=>{let t=yk(e.title,YO),n=xk(e.lines),r=24+t.length*WO+n.length*GO,i={kind:`panel`,id:e.id,x:Math.round(o),y:c,width:BO,height:r,titleLines:t,bodyLines:n};return c+=r+HO,i})}function Jk(e,t,n,r,i){let a=new Map,o=[],s=Uk(e,t,n,r,i,a);for(let t of V(e,`box`))t.at&&a.set(t.id,Hk(e,t,t.at));Kk(e,r,a,o);for(let t of V(e,`box`))a.has(t.id)||a.set(t.id,Hk(e,t,Gk(a,r)));return{boxesById:a,bands:s,warnings:o}}function Yk(e,t){return V(e,`frame`).flatMap(e=>{let n=dD(e.contains.flatMap(e=>t.get(e)??[]));return n?[{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,x:n.x-ZO,y:n.y-ZO-QO,width:n.width+36,height:n.height+36+QO}]:[]})}function Xk(e){return e.resolvedBy?`resolved by ${e.resolvedBy}`:e.author?`from ${e.author}`:``}function Zk(e,t){let n=new Map;return V(e,`note`).flatMap(e=>{let r=t.get(e.on);if(!r)return[];let{lines:i,height:a}=kk(e),o=n.get(e.on)??r.y-lk;return n.set(e.on,o+a+nk),[{kind:`note`,id:e.id,x:r.x+r.width-ck,y:o,width:$O,height:a,lines:i,byline:Xk(e),isResolved:e.resolvedBy!==null}]})}function Qk(e,t,n,r){let i=dD([...e.flatMap(e=>e.kind===`wire`?[]:[e]),...t?[t]:[],{x:0,y:0,width:n,height:r}]);return i?{x:Math.min(0,i.x-B),y:Math.min(0,i.y-B),width:i.width+80,height:i.height+80}:{x:0,y:0,width:n+B,height:80}}function $k(e,t){return e.slice(0,-1).map((n,r)=>{let i=n+(t[r]??BO);return{left:i,right:e[r+1]??i}})}function eA(e,t,n){let r=e.segments.filter(e=>e.from.x===e.to.x).map(e=>e.from.x);return $k(t,n).map(e=>new Set(r.filter(t=>t>e.left&&t<e.right)).size)}function tA(e,t,n){return $k(t,n).map(t=>e.wires.reduce((e,n)=>n.label&&n.labelAt.x>t.left&&n.labelAt.x<t.right?Math.max(e,_O(n.label)):e,0))}function nA(e,t,n,r){let i=[...e.values()],a=[...i,...t],o=hD(a).flatMap(([e,t])=>{let n=a[e],r=a[t];return n&&r&&xD(n,r)?[`${n.kind} ${n.id} overlaps ${r.kind} ${r.id}`]:[]}),s=new Map(V(r,`frame`).map(e=>[e.id,new Set(e.contains)])),c=n.flatMap(e=>i.flatMap(t=>{let n={x:e.x,y:e.y,width:e.width,height:QO};return!s.get(e.id)?.has(t.id)&&xD(t,n)?[`box ${t.id} covers the title of frame ${e.id}`]:[]}));return[...o,...c]}function rA(e,t){let n=Fk(e),r=Ik(n,t.gapWidths),{boxesById:i,bands:a,warnings:o}=Jk(e,r,n,t.boxesTop,t.stackHeightByBoxId),s=Yk(e,i),c=Zk(e,i),l=qk(e,[...i.values(),...c],r,n,t.boxesTop),u=RO({wires:V(e,`wire`),boxesById:i,panels:l,softObstacles:[...c,...s.map(e=>({x:e.x,y:e.y,width:e.width,height:QO}))],loopFrames:s.filter(e=>e.isLoop),contentTop:t.contentTop});return{columnLeftEdges:r,columnWidths:n,boxesById:i,bands:a,frames:s,notes:c,panels:l,routing:u,placementWarnings:[...o,...nA(i,l,s,e)],tracksByGap:eA(u,r,n),labelWidthByGap:tA(u,r,n)}}function iA(e,t){return Array.from({length:Math.max(e.length,t.length)},(n,r)=>Math.max(e[r]??0,t[r]??0))}function aA(e,t){let n=[],r=[];for(let i=1;;i+=1){let a=rA(e,{gapWidths:Pk(t.reserves,n,r),boxesTop:t.boxesTop,contentTop:t.contentTop,stackHeightByBoxId:t.stackHeightByBoxId}),o=a.tracksByGap.some((e,t)=>e>(n[t]??0)),s=a.labelWidthByGap.some((e,t)=>e>(r[t]??0));if(i>=fk||!o&&!s)return a;n=iA(n,a.tracksByGap),r=iA(r,a.labelWidthByGap)}}function oA(e){let t=yk(e.title,YO),n=xk(e.lines),r=+!!e.linkedBoardId;return{titleLines:t,bodyLines:n,height:42+t.length*WO+(n.length+r)*GO}}function sA(e){let t=new Map,n=new Map;for(let r of LE(e)){let i=e.elements[r.unitId];if(i?.kind!==`unit`)continue;let a=oA(i),o=n.get(r.level)??70;n.set(r.level,o+a.height+HO),t.set(i.id,{kind:`unit`,id:i.id,x:B+(r.level-1)*310,y:o,width:BO,height:a.height,label:r.label,status:i.status,titleLines:a.titleLines,bodyLines:a.bodyLines,linkedBoardId:i.linkedBoardId})}return t}function cA(e,t){let n={x:e.x+e.width,y:e.y+Math.round(e.height/2)},r={x:t.x,y:t.y+Math.round(t.height/2)},i=t.x-Math.round(VO/2);return wD(SD([n,{x:i,y:n.y},{x:i,y:r.y},r]))}function lA(e,t){return V(e,`unit`).flatMap(e=>{let n=t.get(e.id);return n?e.after.flatMap(e=>{let r=t.get(e);return r?[cA(r,n)]:[]}):[]})}function uA(e){return e.size===0?B:Math.max(...[...e.values()].map(e=>e.y+e.height))+pk}function dA(e,t){if(t===0)return e;let n=Object.fromEntries(Object.entries(e.elements).map(([e,n])=>n.kind!==`box`||!n.at?[e,n]:[e,{...n,at:{x:n.at.x,y:n.at.y+t}}]));return{...e,elements:n}}var fA={plain:null,fail:`failure path`,join:`joins`,lane:null};function pA(e,t,n){return`${e}|${t}|${n}`}function mA(e,t,n){let r=[fA[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var hA={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function gA(e){let t=new Set(V(e,`box`).map(e=>e.change));return ke.flatMap(e=>e===`none`||!t.has(e)?[]:[{label:hA[e],swatch:{kind:`change`,change:e}}])}function _A(e){return e.size===0?[]:Ke.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}}))}function vA(e,t){let n=e.lanes.map(e=>({label:e.label||e.id,swatch:{kind:`lane`,hex:vk[e.color]}})),r=new Map(e.legend.map(e=>[pA(e.tone,e.dashed||e.back,e.back),e.label])),i=new Set,a=V(e,`wire`).flatMap(e=>{let t=e.dashed||e.back,n=pA(e.tone,t,e.back),a=r.get(n)??mA(e.tone,t,e.back);return i.has(n)||a===null?[]:(i.add(n),[{key:n,label:a,swatch:{kind:`wire`,tone:e.tone,isDashed:t,isBack:e.back}}])}).sort((e,t)=>e.key.localeCompare(t.key)),o=e.legend.filter(e=>!i.has(pA(e.tone,e.dashed||e.back,e.back))).map(e=>({label:e.label,swatch:{kind:`wire`,tone:e.tone,isDashed:e.dashed||e.back,isBack:e.back}}));return[...n,...a.map(({label:e,swatch:t})=>({label:e,swatch:t})),...o,...gA(e),..._A(t)]}function yA(e){let t=sA(e),n=uA(t),r=n-B,i=dA(e,r),a=Ak(i),o=jk(i),s=Mk(o),c=n+sk+s,l=n+zO+s,u=aA(i,{reserves:Nk(i,a),boxesTop:l,contentTop:c,stackHeightByBoxId:a}),{columnLeftEdges:d,columnWidths:f}=u,p=[...u.frames,...u.routing.wires,...u.boxesById.values(),...u.notes,...u.panels,...t.values()],m=Qk(p,u.routing.extent,Lk(d,f),l),h=m.y+m.height,g=vA(i,t).map((e,t)=>({...e,x:B,y:h+t*rk})),_=h+g.length*rk+(g.length>0?12:0),v=i.caption?{text:i.caption,x:B,y:_}:null,y=g.length*rk+(v?30:0)+(g.length>0?12:0);return{columns:i.columns.map((e,t)=>({id:e.id,titleLines:o[t]??[],titleBaselineY:n+ok,ruleY:c,x:d[t]??B,width:f[t]??BO})),bands:u.bands,elements:p,legend:g,caption:v,pinnedOffsetY:r,plan:t.size>0?{titleAt:{x:B,y:56},arrowPaths:lA(i,t)}:null,bounds:{...m,height:m.height+y},warnings:TD([...u.placementWarnings,...u.routing.warnings])}}function bA(e){return JSON.stringify(e)}var xA=Object.freeze({box:Lt,frame:fe,wire:xt,note:Je,unit:Ye,panel:Ce});Object.freeze({id:`operator`,name:`operator`});function SA(e,t,n){if(n[0]===`put`)return n[1].id===t?n[1]:null;if(n[0]===`remove`||!e)return null;let r=xA[e.kind].safeParse({...e,...n[1]});return r.success&&r.data.id===t?r.data:null}function CA(e,t,n,r){let i={...e.elements};for(let[e,n]of Object.entries(t.elements)){let t=i[e];if(n[0]===`remove`){if(!t)return null;delete i[e];continue}let r=SA(t,e,n);if(!r)return null;n[0]===`put`&&delete i[e],i[e]=r}return Object.keys(i).length>Oe.elements?null:{...e,...t.fields,elements:i,version:n,updatedAt:r}}var wA=new Map,TA=new Map,EA=[],DA=[],OA=[],kA=new Map;function AA(){for(let e of[...EA])e()}function jA(e){for(let t of DA)t(e)}function MA(e){return e.type===`whiteboard-result`}async function NA(e,t){try{let n=await a(e,t,{timeoutMs:qn});return MA(n)?n.ok?{ok:!0,reply:n}:{ok:!1,error:n.error??`The server refused the change.`}:{ok:!1,error:`The server answered with something other than a whiteboard reply.`}}catch(e){return{ok:!1,error:Kn(e,qn)}}}function PA(e){let t=TA.get(e);if(t)return t;let n=NA(`whiteboard-get`,{boardId:e}).then(t=>{TA.delete(e),t.ok&&t.reply.board&&(wA.set(e,t.reply.board),jA(e))});return TA.set(e,n),n}function FA(){return OA}function IA(e){return wA.get(e)??null}function LA(e){return wA.has(e)?Promise.resolve():PA(e)}function RA(e){return EA.push(e),()=>{let t=EA.indexOf(e);t>=0&&EA.splice(t,1)}}function zA(e){DA.push(e)}function BA(){let e=new Map;for(let t of OA)for(let n of t.connectedSessionIds){let r=e.get(n);r?r.push(t):e.set(n,[t])}kA=e}function VA(e){OA=[...e.boards].sort((e,t)=>t.updatedAt-e.updatedAt),BA();let t=new Map(OA.map(e=>[e.id,e.version]));for(let[e,n]of[...wA]){let r=t.get(e);r!==n.version&&(wA.delete(e),r===void 0?jA(e):PA(e))}AA()}function HA(e){let t=wA.get(e.boardId);if(!t||t.version>=e.toVersion)return;if(t.version!==e.fromVersion){wA.delete(e.boardId),PA(e.boardId);return}let n=CA(t,e.diff,e.toVersion,e.updatedAt);n?(wA.set(e.boardId,n),jA(e.boardId)):(wA.delete(e.boardId),PA(e.boardId))}function UA(e){wA.delete(e.boardId),OA=OA.filter(t=>t.id!==e.boardId),BA(),jA(e.boardId),AA()}async function WA(e){let t=await NA(`whiteboard-create`,{title:e});if(!t.ok)return t;let n=t.reply.summary?.id;return n?{ok:!0,boardId:n}:{ok:!1,error:`The server created no board.`}}async function GA(e,t){let n=await NA(`whiteboard-op`,{boardId:e,ops:t});return n.ok?{ok:!0,diff:n.reply.patch?.diff??null}:n}async function KA(e){let t={"x-glimmervoid-upload-name":encodeURIComponent(e.name)};e.type&&(t[`content-type`]=e.type);let n=await fetch(Se,{method:`POST`,body:e,headers:t}).catch(()=>null);if(!n)return{ok:!1,error:`${e.name} was not added because the server did not answer`};let r=await n.json().catch(()=>null),i=Be.safeParse(r);return i.success?{ok:!0,media:i.data.media}:{ok:!1,error:r&&typeof r==`object`&&`error`in r&&typeof r.error==`string`?r.error:`${e.name} was not added (HTTP ${n.status})`}}async function qA(e){let t=await NA(`whiteboard-delete`,{boardId:e});return t.ok?{ok:!0}:t}async function JA(e,t){let n=await NA(`whiteboard-connect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function YA(e,t){let n=await NA(`whiteboard-disconnect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function XA(e,t){let n=await NA(`whiteboard-nudge`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function ZA(e){let t=await NA(`whiteboard-review`,{boardId:e});return t.ok?t.reply.review?{ok:!0,review:t.reply.review}:{ok:!1,error:`Glimmervoid did not return the board review.`}:t}var QA=null;function $A(e){QA=e}function ej(e,t){QA?.(e,t)}function tj(e){return kA.get(e)??[]}var nj=null;function rj(e,t){nj={boardId:e,sessionId:t}}function ij(){let e=nj;return nj=null,e}var aj=()=>{};function oj(e){aj=e}function sj(e,t){rj(e,t),aj()}function cj(e,t){let n=e.queuedBySessionId[t]??0;return n===0?``:`${n} queued`}function lj(e,t,n){let r=cj(e,t),i=r?`wait`:`muted`;return{key:`board:${e.id}`,text:n,detailText:e.title,stateText:r,look:{icon:`board`,tone:i},tier:rn(i),className:`session-pr-chip session-board-chip`,ariaLabel:`Open board ${e.title}`,onActivate:()=>sj(e.id,t)}}function uj(e,t){let n=cj(e,t);return lj(e,t,n?`${e.title}, ${n}`:e.title)}function dj(e){return tj(e).map(t=>lj(t,e,t.title))}function fj(e,t,n){let r=uj(e,t),i=tt(`session-pr-chip-unlink`);i.append(w(Dt)),i.setAttribute(`aria-label`,`Disconnect board ${e.title}`),i.addEventListener(`click`,r=>{r.stopPropagation(),r.preventDefault(),Qt({title:`Disconnect board`,message:`Disconnect ${e.title} from this session? It stops getting summaries of changes to the board until it connects again.`,confirmLabel:`Disconnect`,danger:!0,onConfirm:()=>{YA(e.id,t).then(e=>n(e.ok?null:e.error))}})});let a=O(`span`,`session-pr-chip-item`);return a.append(hn(r,r),i),a}function pj(e){let{dialog:t,close:n,actions:r,btnCancel:i}=en({title:`Connect board`}),a=O(`div`,`session-pr-chips dialog-linked-prs`),o=O(`p`,`dialog-message`,`A connected session is told what others changed on the board with its next whiteboard get or prompt.`),s=O(`select`,`dialog-input`);s.setAttribute(`aria-label`,`Board to connect`);let c=Hn(`action-status`),l=T({variant:`primary`,label:`Connect`});r.append(l),t.append(a,o,s,c.element,r);function u(e){e&&c.show(`error`,e)}function d(){let t=tj(e);Cn(a,t.map(t=>uj(t,e)),n=>{let r=t.find(e=>`board:${e.id}`===n.key);return r?fj(r,e,u):hn(n,n)});let n=FA().filter(t=>!t.connectedSessionIds.includes(e));s.replaceChildren(...n.map(e=>{let t=O(`option`,null,e.title);return t.value=e.id,t})),n.length===0&&s.append(O(`option`,null,`No other boards to connect`)),s.disabled=n.length===0,l.disabled=n.length===0}l.addEventListener(`click`,()=>{let t=s.value;t&&(l.disabled=!0,JA(t,e).then(e=>{e.ok?n():(c.show(`error`,e.error),d())}))}),i.addEventListener(`click`,n);let f=RA(()=>{t.isConnected?d():f()});d()}RA(vn);function mj(){return N.snapshot().borrowedCardId}var hj=null;function gj(e,t,n,{className:r,onRelease:i}={}){if(!e?.card||!n)return;let a=mj();a&&a!==t&&_j();let o=e.card;o._cardHostClass&&o._cardHostClass!==r&&o.classList.remove(o._cardHostClass),o._cardHostClass=r||``,r&&o.classList.add(r),Xt(o,n),hj=i??null,N.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function _j(){let e=mj(),t=hj;if(hj=null,t?.(),N.dispatch(`borrowCard`,null),!e)return null;let n=A.get(e);n?._showTerminalFace?.(),n?._setBorrowed?.(!1),n?._setActiveViewer?.(!1);let r=n?.card;return r&&(r._cardHostClass&&r.classList.remove(r._cardHostClass),delete r._cardHostClass,Ut(r,In)),e}var vj=null,yj=null,bj={},xj=null,Sj=null,Cj=null,wj=new Map,Tj=new Map;function Ej(){return yj??=P(()=>import(`./phone-shell-9b-bf4Dm.js`).then(e=>{e.mountPhoneShell(bj),Cj&&e.orderPhonePanels(Cj);for(let[t,n]of wj)e.setPhoneScreenAvailable(t,n);for(let[t,n]of Tj)e.setPhoneScreenAttention(t,n);return vj=e,e},e=>(yj=null,u(`phone-shell`,`phone shell failed to load: ${d(e)}`),null)),__vite__mapDeps([25,13,5,3,26,12,14,19,15,27,28,22,29,4,6,7,20,30,23,31,32])),yj}function Dj(e){bj=e}async function Oj(e){let t={options:e};xj=t;let n=await Ej();if(xj!==t)return!1;if(!n)return xj=null,Sj=null,!1;xj=null,n.activatePhoneShell(t.options);let r=Sj;return Sj=null,r?.(n),!0}function kj(){xj=null,Sj=null,vj?.deactivatePhoneShell()}function Aj(){return xj!==null||(vj?.isPhoneShellActive()??!1)}function jj(){return xj?xj.options?.sessionId??null:vj?.getPhoneSessionId()??null}function Mj(e){Cj=e,vj?.orderPhonePanels(e)}function Nj(e,t){wj.set(e,t),vj?.setPhoneScreenAvailable(e,t)}function Pj(e,t){Tj.set(e,t),vj?.setPhoneScreenAttention(e,t)}function Fj(){vj?.refreshPhoneBoard()}function Ij(){vj?.syncPhoneHistory()}function Lj(e){return xj?(Sj=t=>{e(t)},!0):vj?e(vj):!1}function Rj(e){return Lj(t=>t.showPhonePlan(e))}function zj(e){return Lj(t=>t.showPhoneSession(e))}function Bj(e){return Lj(t=>t.showPhoneScreen(e))}function Vj(){let e=jj();e&&j(e)?._isActiveViewer?.()===!0&&DS(e)}function Hj(){Bd(j(mj())),Vj()}function Uj(){window.addEventListener(`focus`,Hj),window.addEventListener(`blur`,Hj),document.addEventListener(`visibilitychange`,Hj),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&lo()}),window.addEventListener(`pageshow`,e=>{e.persisted&&lo()})}function Wj(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function Gj(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function Kj({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=Wj(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=Gj(e.key,a);if(n===null)return;e.preventDefault();let r=u(t.getBoundingClientRect().width+l*n);r!==null&&s(r)})}var qj={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.`},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.`},board:{label:`Board`,meaning:`A whiteboard this session is connected to; hover for edits it has not read yet.`}},Jj=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:Yt[e],meaning:t}),Yj=Object.freeze([Jj(E.DORMANT,`Not started yet.`),Jj(E.STARTING,`Setting up the worktree and booting the agent.`),Jj(E.RUNNING,`The agent is mid-turn.`),Jj(E.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),Jj(E.WAITING,`Waiting on a permission prompt or your answer.`),Jj(E.COMPLETE,`Finished a turn you have not looked at yet.`),Jj(E.IDLE,`Ready for the next prompt.`),Jj(E.DONE,`The agent process ended.`),Jj(E.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 Xj(e,t){let n=O(`section`,`status-legend`),r=O(`dl`,`status-legend-rows`);return r.append(...t),n.append(O(`h2`,`status-legend-title`,e),r),n}function Zj(e,t){let n=O(`div`,`status-legend-row`);return n.append(e,O(`dd`,`status-legend-meaning`,t)),n}function Qj(){return Xj(`Status colors`,Yj.map(e=>{let t=O(`dt`,`status-legend-badge`),n=O(`span`,`status-legend-glyph`),r=O(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=Zj(t,e.meaning);return sn(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function $j(){return Xj(`Pull request icons`,Object.keys(qj).map(e=>{let t=qj[e],n=O(`dt`,`status-legend-badge`);return n.append(Ei(e),O(`span`,`status-legend-name`,t.label)),Zj(n,t.meaning)}))}var eM=null,tM=null,nM=!1,rM=null;function iM(){return tM??=P(()=>import(`./first-run-checklist-DLbuF9fv.js`).then(e=>(eM=e,e),e=>(tM=null,u(`first-run`,`first-run checklist failed to load: ${d(e)}`),null)),__vite__mapDeps([33,12,13,5,3,15,28,14,19,22,29,4,6,7,20,34,35])),tM}function aM(e,t){rM={host:e,isShown:t},eM?eM.showFirstRunChecklist(e,t):t&&nM&&iM().then(e=>{e&&rM&&e.showFirstRunChecklist(rM.host,rM.isShown)})}function oM(){eM?.refreshFirstRunChecklist()}function sM(){nM=!0,rM&&aM(rM.host,rM.isShown)}var cM=`(no path)`;function lM(e){if(!e)return cM;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||cM}function uM(e,t,n=()=>null){let r=Array.isArray(e)?e:[],i=new Map;for(let e of r){let r=n(e),a=t(e),o=r?.key??(a?String(a):cM),s=i.get(o);s||(s=r?{...r,projectPath:null,rows:[]}:{key:o,label:o===cM?cM:lM(o),title:o,projectPath:o===cM?null:o,rows:[]},i.set(o,s)),s.rows.push(e)}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 dM(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 fM(e,t){return e.filter(e=>!e.connectedSessionIds.some(t)).sort((e,t)=>e.title.localeCompare(t.title,void 0,{numeric:!0,sensitivity:`base`})||e.id.localeCompare(t.id))}var pM=`removed`,mM=new Set([E.COMPLETE,E.DONE,E.FAILED,pM]);function hM(e){return mM.has(e)}function gM(e,t){let n=e.filter(e=>hM(t(e))).length;return{settled:n,total:e.length,isAllSettled:e.length>0&&n===e.length}}var _M=[],vM=new Set;function yM(e){vM.add(e)}function bM(){return _M}function xM(e){_M=e.races;for(let e of vM)e()}function SM(e){let t=CM(e.id);if(!t)return null;let n=gM(Object.values(t.sessionIdByContestant),e=>A.get(e)?.currentState??`removed`);return{key:`race:${t.id}`,label:`${t.spec.title} ${n.settled}/${n.total}`,title:`Race: ${t.spec.title}, ${n.settled} of ${n.total} settled`}}function CM(e){return _M.find(t=>Object.values(t.sessionIdByContestant).includes(e))??null}var wM=()=>{};function TM(e){wM=e.openTerminal}function EM(e){wM(e)}function DM({onAdd:e}){let t=O(`div`,`session-group-header`),n=O(`span`,`session-group-label`),r=O(`span`,`session-group-count`),i=O(`span`,`session-group-rule`);i.setAttribute(`aria-hidden`,`true`);let a=T({variant:`icon`,size:`small`,label:`Add session to this project`,icon:w(rt),action:`add-group-session`,onClick:()=>e(t.dataset.path,t.dataset.label)});return t.append(n,r,i,a),{header:t,label:n,count:r,addButton:a}}function OM(e,t){let{header:n,label:r,count:i,addButton:a}=e;yi(n,`path`,t.projectPath??``),yi(n,`label`,t.label),$r(r,t.label),$r(i,String(t.rows.length)),ri(a,t.projectPath===null)}var kM={waitingCount:0,finishedCount:0,failedCount:0},AM={failed:Bt[E.FAILED],waiting:Bt[E.WAITING],finished:Bt[E.COMPLETE]},jM={failed:`failed`,waiting:`needs you`,finished:`finished`},MM=[`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`],NM=2500,PM=`cubic-bezier(0.16, 1, 0.3, 1)`,FM=`cubic-bezier(0.5, 0, 0.2, 1)`,IM=260,LM=200,RM=200,zM=300,BM=28,VM=360,HM=420,UM=200,WM=3,GM=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),KM=new WeakMap;function qM(e){let t=KM.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function JM(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function YM(){return GM?.matches??!1}function XM(e){return e.map(e=>({easing:PM,...e}))}function ZM(e,t){let n=O(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${Ln.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${Ln.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${Ln.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${Ln.overflowSlot}px`);let r=O(`span`,`attention-banner-chips`),i=O(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=O(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=O(`span`,`attention-banner-status`);o.append(r,O(`span`,`attention-banner-count`),a);let s=tt(`attention-banner-jump-row`);return s.append(o),t&&(t.classList.add(`attention-banner-jump`),s.append(t)),n.addEventListener(`click`,()=>e.onJump()),n.append(s),KM.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(()=>$M(n)).observe(r),QM(n,kM,[]),n}function QM(e,t,n){let r=qM(e);r.tiles=n,$r(Kt(e,`.attention-banner-count`),jn(t));let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&hN(e,r),$M(e)}function $M(e){let t=qM(e),n=Kt(e,`.attention-banner-chips`),r=Kt(n,`.attention-tile-overflow`),i=JM(e),a=t.tiles.slice(0,Mn(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():rN(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??tN(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),nN(s,i,a===0),(s.parentElement!==n||eN(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;ri(r,p===0),$r(r,`+${p}`),Zr(r,`aria-label`,`${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)&&sN(e,null),i){for(let e of d)iN(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?oN(r,a):a!==0&&aN(r,a,n)})}}function eN(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function tN(e,t){let n=O(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=O(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>sN(e,t)),n.addEventListener(`pointerleave`,()=>sN(e,null)),n}function nN(e,{kind:t,name:n},r){e.dataset.kind=t,e.toggleAttribute(`data-head`,r);let i=`${n}, ${jM[t]}`;e.setAttribute(`aria-label`,i),Jn(Kt(e,`.attention-tile-icon`),AM[t])}function rN(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=YM()?[{opacity:1},{opacity:0}]:XM([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:RM,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function iN(e){let t=YM()?[{opacity:0},{opacity:1}]:XM([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:LM})}function aN(e,t,n){YM()||e.animate(XM([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:zM,delay:n*BM,fill:`backwards`})}function oN(e,t){YM()?e.animate([{opacity:.35},{opacity:1}],{duration:VM,easing:PM}):e.animate(XM([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:VM})}function sN(e,t){let n=qM(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 cN(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function lN(e,t,n){let r=qM(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!JM(e)){n();return}sN(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=cN(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(uN(o,s),dN(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function uN(e,t){return!t||YM()?[{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 dN(e){return!e||YM()?{duration:UM,fill:`forwards`}:{duration:HM,easing:FM,fill:`forwards`}}function fN(e){let t=qM(e);e.hasAttribute(`data-empty`)&&mN(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!JM(e))return;let n={duration:IM};if(t.pressAnimations.push(e.animate(XM([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!YM()){t.pressAnimations.push(e.animate(XM([{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(XM([{transform:`none`},{transform:`translateY(${WM}px)`,offset:.3},{transform:`none`}]),n),r.animate(XM([{transform:`none`},{transform:`translateY(-${WM}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function pN(e){let t=MM.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??MM[0]}function mN(e,t){let n=pN(t.lastAllClearLine);t.lastAllClearLine=n,Kt(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>hN(e,t),NM)}function hN(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var gN={terminal:`Terminal`,board:`Board`},_N=[`terminal`,`board`],vN=.05,yN=`application/x-glimmervoid-pane-tab`;function bN(){let e=Br(),t=new Set([`terminal`]),n=Sr(e,t),r=null,i=O(`div`,`pane-layout`),a=O(`div`,`pane-trail`),o=O(`div`,`pane-divider`);o.setAttribute(`role`,`separator`),o.setAttribute(`aria-label`,`Resize panes`),o.tabIndex=0;let s={terminal:f(`terminal`),board:f(`board`)},c={terminal:m(`terminal`),board:m(`board`)},l={terminal:p(`terminal`),board:p(`board`)},u=new Map,d=[h(0),h(1)];function f(e){let t=O(`div`,`pane-body`);return t.id=`focus-pane-${e}`,t.dataset.pane=e,t.setAttribute(`role`,`tabpanel`),t}function p(e){let t=O(`div`,`pane-title`);return t.dataset.tab=e,t}function m(t){let n=tt(`pane-tab`);return n.append(O(`span`,`sr-only`,gN[t])),n.draggable=!0,n.dataset.tab=t,n.setAttribute(`role`,`tab`),n.setAttribute(`aria-controls`,`focus-pane-${t}`),n.addEventListener(`click`,()=>v(zr(e,t))),n.addEventListener(`dragstart`,e=>{r=t,e.dataTransfer?.setData(yN,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`),i.dataset.dragging=``}),n.addEventListener(`dragend`,_),n}function h(t){let i=O(`section`,`pane-group`),a=O(`div`,`pane-strip pane-header`),o=O(`div`,`pane-tabs`);o.setAttribute(`role`,`tablist`),a.append(o);let s=O(`div`,`pane-group-body`);return i.append(a,s),i.addEventListener(`dragover`,e=>{r&&(e.preventDefault(),i.dataset.dropZone=g(i,a,e))}),i.addEventListener(`dragleave`,e=>{e.relatedTarget instanceof Node&&i.contains(e.relatedTarget)||delete i.dataset.dropZone}),i.addEventListener(`drop`,o=>{if(!r)return;o.preventDefault();let s=g(i,a,o),c=n.groupIndexes[t],l=r;_(),c!==void 0&&v(yr(e,l,c,s))}),{group:i,strip:a,tabList:o,body:s}}function g(e,t,n){if(n.target instanceof Node&&t.contains(n.target))return`join`;let r=e.getBoundingClientRect();return Or(n.clientX-r.left,n.clientY-r.top,r)}function _(){r=null,delete i.dataset.dragging;for(let{group:e}of d)delete e.dataset.dropZone}function v(t){t!==e&&(e=t,Xr(e),b())}function y(e,t){t.parentElement!==e&&e.append(t)}function ee(e,t){e.children.length===t.length&&t.every((t,n)=>e.children[n]===t)||e.replaceChildren(...t)}function te(e,t){t?(e.strip.parentElement!==t.parent||t.before!==null&&e.strip.nextElementSibling!==t.before)&&t.parent.insertBefore(e.strip,t.before):e.group.firstElementChild!==e.strip&&e.group.prepend(e.strip)}function ne(e,t,n){let r=l[t];r.hidden=!n,e.tabList.nextElementSibling!==r&&e.tabList.after(r)}function b(){n=Sr(e,t);for(let e of _N)l[e].hidden=!0,t.has(e)||(s[e].hidden=!0);let r=Vr(n.groups);i.dataset.direction=n.direction??`single`;let f=n.groups.map((e,t)=>({group:e,parts:d[t]}));for(let{group:e,parts:t}of f){if(!t)continue;ee(t.tabList,e.tabs.map(e=>c[e]));for(let n of e.tabs){let r=n===e.activeTab;c[n].setAttribute(`aria-selected`,String(r)),c[n].tabIndex=r?0:-1,y(t.body,s[n]),s[n].hidden=!r}let n=u.get(e.activeTab);te(t,n),ne(t,e.activeTab,n===void 0)}let[p,m]=d;if(!p||!m)return;y((d[r]??p).strip,a);let h=n.groups.length===2?[p.group,o,m.group]:[p.group];ee(i,h),p.group.style.flex=`${n.firstShare} 1 0`,m.group.style.flex=`${1-n.firstShare} 1 0`,o.setAttribute(`aria-orientation`,n.direction===`row`?`vertical`:`horizontal`),o.setAttribute(`aria-valuenow`,String(Math.round(n.firstShare*100)))}function x(e){let t=i.getBoundingClientRect();return n.direction===`row`?(e.clientX-t.left)/t.width:(e.clientY-t.top)/t.height}o.addEventListener(`pointerdown`,e=>{e.button===0&&(o.setPointerCapture(e.pointerId),o.dataset.dragging=`true`,e.preventDefault())}),o.addEventListener(`pointermove`,t=>{o.hasPointerCapture(t.pointerId)&&(e=Fr(e,x(t)),b())});let S=t=>{o.hasPointerCapture(t.pointerId)&&(o.releasePointerCapture(t.pointerId),delete o.dataset.dragging,Xr(e))};return o.addEventListener(`pointerup`,S),o.addEventListener(`pointercancel`,S),o.addEventListener(`keydown`,t=>{let n={ArrowLeft:-.05,ArrowUp:-.05,ArrowRight:vN,ArrowDown:vN}[t.key];n!==void 0&&e.kind===`split`&&(t.preventDefault(),v(Fr(e,e.firstShare+n)))}),b(),{element:i,trailSlot:a,bodyOf:e=>s[e],titleSlotOf:e=>l[e],setStripHost:(e,t)=>{t&&u.set(e,t),t||u.delete(e),b()},showTabs:e=>{t=e,b()},showTab:t=>v(zr(e,t))}}var xN=[],SN=new Set,CN=new WeakSet,wN=null,TN=null;function EN(e){xN.some(t=>t.id===e.id)||(xN.push(e),ON(e.id,null))}function DN(){return xN}function ON(e,t){for(let n of SN)n(e,t)}function kN(e){return SN.add(e),()=>SN.delete(e)}function AN(e){e!==wN&&(PN(),wN=e)}function jN(e){wN===e&&(PN(),wN=null)}function MN(e,t){return TN?.page.id===e&&TN.sessionId===t}function NN(e,t,n=null){let r=xN.find(t=>t.id===e);if(!r||!wN||wN.sessionId()!==t||!r.isAvailableFor(t)||MN(e,t)&&n===null)return;PN();let i=wN,a=i.elementFor(r);LN(a),TN={page:r,sessionId:t},r.mount(a,t,{placement:i.placement,target:n}),i.didShow(r),ON(r.id,t)}function PN(){if(!TN)return;let{page:e,sessionId:t}=TN;TN=null,e.unmount(),wN?.didHide(e),ON(e.id,t)}function FN(){return TN?.page.canStepBack()??!1}function IN(){return TN?TN.page.canStepBack()?(TN.page.stepBack(),!0):(PN(),!0):!1}function LN(e){CN.has(e)||(CN.add(e),e.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Gt(e)||IN()&&e.preventDefault()}))}function RN({style:e}){let t=O(`div`,`session-page-bar session-page-bar-${e}`),n=new Map,r=null;function i(n){let i=e===`header`,a=T({variant:`quiet`,size:i?`small`:`default`,label:n.label,icon:w(n.iconPath),action:`${i?`open`:`show`}-${n.id}`});a.addEventListener(`click`,()=>{r&&NN(n.id,r)});let o=O(`span`,`session-page-dot`);o.setAttribute(`aria-hidden`,`true`);let s=O(`span`,`session-page-button`);return s.dataset.page=n.id,s.append(a,o),t.append(s),n.attachButton?.(s,e),{wrap:s,control:a,dot:o}}function a(e){let t=n.get(e.id)??i(e);n.set(e.id,t);let a=r!==null&&e.isAvailableFor(r);t.wrap.toggleAttribute(`data-slot-held`,!a),t.dot.hidden=!a||!r||!e.hasUnreadFor(r)}function o(){for(let e of xN)a(e)}return kN((e,t)=>{if(t!==null&&t!==r)return;let n=xN.find(t=>t.id===e);n&&a(n)}),o(),{element:t,showSession(e){r=e,o()}}}var zN=5,BN={high:`High`,medium:`Medium`,low:`Low`};function VN(e,t){let n=tt(`review-look-line`,e.path);return n.append(O(`span`,`review-look-detail`,e.detail)),n.addEventListener(`click`,()=>t(e.openPath)),n}function HN(e,t){let n=O(`div`,`review-look-group`);n.dataset.kind=e.kind;let r=O(`p`,`review-look-text`,e.heading);if(e.conflictRisk){let t=O(`span`,`review-look-risk`,`Conflict risk: ${BN[e.conflictRisk]}`);t.dataset.risk=e.conflictRisk,r.append(` `,t)}n.append(r);for(let r of e.lines)n.append(VN(r,t));return n}function UN(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=O(`section`,`review-look`);if(i.append(O(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=O(`p`,`review-look-error`,`Could not check this change for anything worth a look.`);t.append(` `,e.errors.join(` `)),i.append(t)}let a=t?e.worthALook:e.worthALook.slice(0,zN);if(a.length>0){let e=O(`div`,`review-look-list`);for(let t of a)e.append(HN(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=O(`div`,`review-look-more`),c=T({variant:`quiet`,size:`small`,label:`Show all`,action:`show-all-worth-a-look`,onClick:n});return s.append(O(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function WN(e){return(e??[]).map(e=>O(`span`,`review-file-hint`,e.text))}var GN=`changes`,KN={add:`+`,del:`-`,meta:`\\`},H=null,qN=null,U=null,W=null,JN=null,YN=!1;function XN(){let e=O(`section`,`review-reader`);e.setAttribute(`aria-label`,`Changes`),e.tabIndex=-1,e.hidden=!0;let t=O(`div`,`review-reader-bar`),n=O(`p`,`review-reader-status`);n.setAttribute(`role`,`status`);let r=O(`p`,`review-reader-notice`);r.setAttribute(`role`,`status`);let i=O(`div`,`review-reader-actions`),a=T({variant:`primary`,label:`Merge`,action:`merge-session`,onClick:()=>{U&&Dv(U)}}),o=T({variant:`danger`,label:`Discard`,action:`discard-session`,onClick:()=>{U&&Ov(U)}}),s=T({variant:`secondary`,label:`Close`,action:`close-reader`,onClick:PN});i.append(a,o,s),t.append(n,r,i);let c=O(`div`,`review-reader-body`),l=O(`div`,`review-reader-files`),u=O(`div`,`review-reader-diff`);return c.append(l,u),e.append(t,c),e.addEventListener(`keydown`,QN),ov(e=>{e===U&&nP()}),ti(()=>{W=null,YN=!1,nP(),$N()}),jv(e),{root:e,status:n,notice:r,mergeButton:a,discardButton:o,closeButton:s,fileColumn:l,diff:u}}function ZN(){return H??=XN(),H}function QN(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Gt(e))return;let t=e.key===`j`?1:e.key===`k`?-1:0;if(t===0||!U)return;e.preventDefault();let n=B_(dv(U)?.files??[],W,t);n&&eP(n)}function $N(){U&&ON(GN,U)}function eP(e){W=e,nP(),H?.fileColumn.querySelector(`.review-reader-file[aria-current="true"]`)?.scrollIntoView({block:`nearest`}),$N()}function tP(e){let t=z_(e,JN);t&&(W=t.path,JN=null),!z_(e,W)&&(W=qN===`overlay`?e[0]?.path??null:null)}function nP(){if(!H||qN===null)return;U=Qr();let e=U?dv(U):null;if(H.closeButton.hidden=qN!==`overlay`,!e){rP(H);return}let t=W!==null;tP(e.files),H.status.textContent=e.sentence;let n=e.notice??(e.isMergeShown&&!e.isMergeEnabled?e.mergeRefusal:null);H.notice.textContent=n??``,H.notice.hidden=n===null,H.mergeButton.hidden=!e.isMergeShown,H.mergeButton.disabled=!e.isMergeEnabled,H.discardButton.hidden=!e.isDiscardShown,H.root.dataset.level=qN===`screen`&&W!==null?`diff`:`list`,iP(H.fileColumn,e),cP(H.diff,z_(e.files,W)),t!==(W!==null)&&$N()}function rP(e){e.status.textContent=`No session selected`,e.notice.hidden=!0,e.mergeButton.hidden=!0,e.discardButton.hidden=!0,e.root.dataset.level=`list`,e.fileColumn.replaceChildren(),e.diff.replaceChildren()}function iP(e,t){let n=e.scrollTop;if(e.replaceChildren(),t.diffError){e.append(O(`p`,`review-diff-error`,t.diffError));return}if(t.isEmpty){e.append(O(`p`,`review-empty-title`,t.sentence));return}t.totals.files>0&&e.append(aP(t.totals));let r=O(`div`,`review-reader-file-list`);r.setAttribute(`role`,`list`);let i=t.changeMapView&&t.changeMapView.repos.length>1?t.changeMapView.repos:[],a=null;for(let e of t.files){let n=i.length>0?E_(i,e.path):null;n&&n!==a&&r.append(O(`div`,`review-repo-label`,n)),a=n,r.append(oP(e,t))}e.append(r);let o=t.changeMapView?UN(t.changeMapView,{isShowingAll:YN,onShowAll:lP,onOpenFile:uP}):null;o&&e.append(o),e.scrollTop=n}function aP(e){let t=O(`p`,`review-reader-totals`);return t.append(O(`span`,`review-stat-files`,`${e.files} file${e.files===1?``:`s`}`),O(`span`,`review-add`,`+${e.added}`),O(`span`,`review-del`,`-${e.removed}`)),t}function oP(e,t){let n=tt(`review-reader-file`);n.dataset.path=e.path,n.setAttribute(`role`,`listitem`),n.setAttribute(`aria-current`,String(e.path===W));let r=O(`span`,`review-file-name`);r.append(O(`span`,`review-file-path`,e.path));let i=WN(t.changeMapView?.hintsByOpenPath.get(e.path));if(i.length>0){let e=O(`span`,`review-file-hints`);e.append(...i),r.append(e)}return n.append(r,sP(e)),n.addEventListener(`click`,()=>eP(e.path)),n}function sP(e){let t=O(`span`,`review-file-counts`);return e.binary?(t.append(O(`span`,`review-bin`,`bin`)),t):(t.append(O(`span`,`review-add`,`+${e.added}`),O(`span`,`review-del`,`-${e.removed}`)),t)}function cP(e,t){let n=e.dataset.path===t?.path?e.scrollTop:0;if(e.replaceChildren(),!t){delete e.dataset.path;return}e.dataset.path=t.path;let r=O(`div`,`review-reader-diff-head`);if(r.append(O(`span`,`review-file-path`,t.path),sP(t)),e.append(r),t.binary){e.append(O(`div`,`review-file-binary`,`Binary file not shown`));return}let i=O(`div`,`review-file-body`);for(let e of t.hunks){i.append(O(`div`,`review-hunk-head`,e.header));for(let t of e.lines){let e=O(`div`,`review-line review-line-${t.type}`);e.append(O(`span`,`review-line-gutter`,KN[t.type]??` `),O(`span`,`review-line-text`,t.text)),i.append(e)}}e.append(i),e.scrollTop=n}function lP(){YN=!0,nP()}function uP(e){let t=z_(U?dv(U)?.files??[]:[],e);t&&eP(t.path)}function dP(e,t){let{root:n}=ZN();n.parentElement!==e&&e.append(n),qN=t,n.dataset.placement=t,n.hidden=!1}function fP(){H&&(H.root.hidden=!0,H.root.remove(),qN=null)}function pP(){W!==null&&(W=null,nP(),$N())}function mP(e,t){t===`header`&&(jv(e),new MutationObserver(Av).observe(e,{attributes:!0,attributeFilter:[`data-slot-held`]}))}ov(e=>ON(GN,e));var hP={id:GN,label:`Changes`,iconPath:vt,isAvailableFor:e=>dv(e)!==null,hasUnreadFor:()=>!1,mount(e,t,{placement:n,target:r}){dP(e,n),JN=r,nP(),n===`overlay`&&ZN().root.focus({preventScroll:!0})},unmount:fP,canStepBack:()=>qN===`screen`&&W!==null,stepBack:pP,attachButton:mP};function gP(){EN(hP)}var _P=new Set([`terminal`]),vP=new Set([`terminal`,`board`]),yP=new Set([`board`]),bP=e=>e.ui.path,xP=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),SP=null,G=null,CP=null,wP=null,K=null,TP=null,EP=null,DP=null,OP=null,kP=null,AP=null,q=null,jP=null,MP=new Map,NP=null,PP=null,FP=null,J=!1,IP=!1,LP=null,RP=new Map,Y=new Map,zP=new Map,BP=new Map,X=null,VP=``,HP=[],UP=new Set;function WP(){return dM(KP(nF()),UP)}function GP(e){let t=X;if(X=e||null,t&&t!==X){let e=Y.get(t);e&&(e.tabIndex=-1,e.setAttribute(`aria-selected`,`false`))}if(X){let e=Y.get(X);e&&(e.tabIndex=0,e.setAttribute(`aria-selected`,`true`))}}function KP(e){return uM(e,bP,SM)}function qP(e){let t=BP.get(e.key),n=zP.get(e.key);return(!t||!n)&&(t=DM({onAdd:si}),n=O(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),BP.set(e.key,t),zP.set(e.key,n)),OM(t,e),Zr(n,`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function JP(){return J}function Z(){return N.snapshot().focusedSessionId}function YP(){return J&&q!==null}function XP({rail:e,center:t,resizer:n}){if(SP=e,CP=t,!SP||!CP)return;let r=SP,i=CP;$P(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,Er(Hl)),G=ZM({onJump:xF,rowFor:e=>Y.get(e)},Jl());let a=O(`details`,`rail-section rail-status-key`);a.append(O(`summary`,`rail-section-summary`,`Status key`),Qj()),fF(a,sr(),gr),r.append(G,a),NP=O(`div`,`focus-empty`),NP.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,PP=NP.querySelector(`.focus-empty-title`),FP=NP.querySelector(`.focus-empty-desc`),K=bN(),K.element.addEventListener(`click`,DF),wP=K.bodyOf(`terminal`),jP=pF(),gP(),TP=RN({style:`header`}),K.trailSlot.append(TP.element),i.append(NP,K.element),yM(()=>{J&&dF()}),RA(()=>{if(!J)return;let e=q!==null;dF(),e&&q===null&&JF()}),r.addEventListener(`keydown`,eF)}var ZP={minPx:180,maxPx:480},QP=16;function $P(e){e&&SP&&Kj({resizer:e,column:SP,widthHost:SP,widthProperty:`--rail-width`,bounds:ZP,keyStepPx:QP,getStoredWidth:jr,setStoredWidth:hr})}function eF(e){if(e.key===`Delete`||e.key===`Backspace`){let t=e.target instanceof HTMLElement?e.target:null,n=t?.dataset.id;if(!n||Y.get(n)!==t)return;e.preventDefault(),ci(n);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=tF(),n=t.find(t=>t===e.target)??(X?Y.get(X):null),r=n?t.indexOf(n):-1,i=On(t.map((e,t)=>String(t)),r===-1?null:String(r),e.key===`ArrowDown`?1:-1),a=i==null?null:t[Number(i)];a&&(e.preventDefault(),a.dataset.id&&GP(a.dataset.id),a.focus())}function tF(){return SP?[...SP.querySelectorAll(`button.session-row[data-id], button.session-row[data-board-id]`)].filter(e=>!e.closest(`details:not([open])`)):[]}function nF(){return Nn(mi(rF))}function rF(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function iF(e){let{row:t,refs:n}=_n();t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,()=>aF(e)),t.addEventListener(`pointerenter`,()=>{G&&sN(G,e)}),t.addEventListener(`pointerleave`,()=>{G&&sN(G,null)});let{item:r,removeButton:i}=ln(t,()=>ci(e),()=>xi(e));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,Object.assign(t,{_refs:n,_row:r})}function aF(e){let t=_i(e);t&&sF(t,e)}function oF(e){let t=_i(e);t&&sF(t,e)}function sF(e,t){LF(t),CF(e,t)}function cF(e,{id:t,ui:n,state:r,name:i},a){let o=RP.get(t)||`none`;e.classList.toggle(`focused`,t===Z()),mn(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a});let s=t===X;Zr(e,`aria-selected`,String(s)),Zr(e,`tabindex`,s?`0`:`-1`)}function lF(e,t){if(!J)return;let n=e?.card?.dataset.id,r=n?Y.get(n):null;r&&(t===`flag`?r.dataset.activity=e._activity||``:tr(r._refs?.glyph))}Yn(lF),nr((e,t)=>{if(!J)return;let n=Y.get(e);n&&$r(n._refs.elapsed,er(t))});var uF=new Map;function dF(e){if(!J)return;let t=SP;if(!t)return;let n=nF(),r=KP(n),i=new Set,a=Pn(n,Z()),o=new Map(a.map(({id:e},t)=>[e,t+1])),s=(t,n)=>{let r=t.map(e=>e.id).join(`,`),a=n._lastOrderKey===r&&n.childElementCount===t.length;for(let n of t){let{id:t}=n;i.add(t);let r=Y.get(t),a=!r;r||(r=iF(t),Y.set(t,r));let s=o.get(t)??null;(!e||a||e.has(t)||uF.get(t)!==s)&&cF(r,n,s),uF.set(t,s)}a||bi(n,t.flatMap(({id:e})=>Y.get(e)?._row??[])),n._lastOrderKey=r},c=new Set(r.order),l=r.groups.map(e=>e.key).join(`
|
|
75
|
-
`),u=l===VP;VP=l;for(let e of r.groups){let{header:n,list:r}=qP(e);u||t.append(n,r),s(e.rows,r)}jP&&(!u||jP.section.parentElement!==t)&&t.append(jP.section),jP&&hF(jP);for(let[e,t]of[...BP])c.has(e)||(t.header.remove(),zP.get(e)?.remove(),BP.delete(e),zP.delete(e));for(let[e,t]of Y)i.has(e)||(t._row.remove(),Y.delete(e),uF.delete(e),e===X&&(X=null));for(let e of[...RP.keys()])A.has(e)||RP.delete(e);let d=HP;HP=dM(r,UP);let f=Z();if(f&&!ai(f)){PN(),N.dispatch(`focusSession`,null),X=null;let e=vF(d,f);if(e){let t=!document.activeElement||document.activeElement===document.body;LF(e),t&&CF(A.get(e),e);return}}RF();let p=Z();if(p){let e=A.get(p);e&&e.card.parentElement!==wP&&TF(e,p)}TP?.showSession(q?null:p),MF(),bF(n,a)}function fF(e,t,n){e.open=t,e.addEventListener(`toggle`,()=>n(e.open))}function pF(){let e=O(`div`,`rail-section rail-boards`),t=O(`details`,`rail-boards-details`),n=O(`span`,`session-group-count`),r=O(`summary`,`rail-section-summary`);r.append(`Boards `,n);let i=O(`div`,`focus-rail-list focus-board-list`);i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,`Boards with no session`),t.append(r,i),fF(t,fr(),lr);let a=T({variant:`icon`,size:`small`,label:`New board`,icon:w(rt),action:`new-board`,onClick:_F});return a.classList.add(`rail-section-action`),e.append(t,a),{section:e,count:n,list:i}}function mF(e){let{row:t,refs:n}=_n();t.dataset.boardId=e,t.addEventListener(`click`,()=>gF(e));let r=O(`div`,`session-row-item`);return r.append(t),Object.assign(t,{_refs:n,_row:r})}function hF(e){let t=FA();q&&!t.some(e=>e.id===q)&&(q=null);let n=fM(t,e=>A.has(e)),r=new Set(n.map(e=>e.id));for(let[e,t]of MP)r.has(e)||(t._row.remove(),MP.delete(e));for(let e of n){let t=MP.get(e.id);t||(t=mF(e.id),MP.set(e.id,t)),bn(t,t._refs,e.title),t.classList.toggle(`focused`,e.id===q)}bi(e.list,n.flatMap(e=>MP.get(e.id)?._row??[])),$r(e.count,String(n.length)),Zr(e.count,`aria-label`,`${n.length} ${n.length===1?`board`:`boards`} with no session`)}function gF(e){J&&(IF(),q=e,kP=null,GP(null),dF())}function _F(){OF().then(e=>e.createBoardFromDialog(gF),kF)}function vF(e,t){let n=e.filter(e=>e===t||ai(e));if(n.length<2)return HP.find(e=>ai(e))??null;let r=n.indexOf(t)===n.length-1;return On(n,t,r?-1:1)}function yF(){return Pn(nF(),Z())}function bF(e,t){G&&QM(G,Rn(e),t)}function xF(){if(!J)return;G&&fN(G);let e=yF()[0]?.id;e&&SF(e)}function SF(e){J&&(_i(e),Y.get(e)?.scrollIntoView({block:`nearest`}),G&&lN(G,e,()=>wF(e)),LF(e),CF(A.get(e),e))}function CF(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{J&&Z()===t&&e.term?.focus()}))}function wF(e){if(xP?.matches||document.hidden)return;let t=Y.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=A.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function TF(e,t){if(!wP)return;let n=e.card.querySelector(`:scope > .session-card-header`);gj(e,t,wP,{className:`focus-centered`,onRelease:()=>{n?.classList.remove(`pane-header`),K?.setStripHost(`terminal`,null)}}),n?.classList.add(`pane-header`),n&&EF(n),Hd(e,t,!0)}function EF(e){let t=e.querySelector(`:scope > .session-name`);K?.setStripHost(`terminal`,{parent:e,before:t})}function DF(e){if(!(e.target instanceof Element)||!e.target.closest(`.pane-tab[data-tab="terminal"]`))return;let t=Z(),n=t?A.get(t):null;n&&n.face!==`terminal`&&n._showTerminalFace?.()}function OF(){return EP??=P(()=>import(`./boards-view-DQTSAGYw.js`).then(e=>(DP=e,e)),__vite__mapDeps([36,13,5,3,14,19,15,12,30,23,37])),EP}function kF(e){EP=null,u(`focus`,`the board pane failed to load: ${d(e)}`)}function AF(e){K&&AP!==e&&(AP=e,K.showTabs(e))}function jF(e){AF(yP);let t=OP!==null||kP!==e;OP=null,kP=e,OF().then(n=>NF(n,null,t?e:null),kF)}function MF(e=null){if(q){jF(q);return}let t=Z(),n=t?tj(t):[],[r]=n;if(AF(r?vP:_P),!t||!r){OP=null,kP=null;return}let i=n.some(e=>e.id===kP),a=OP!==t||e!==null||!i;OP=t;let o=a?e??r.id:null;o&&(kP=o),OF().then(e=>NF(e,t,o),kF)}function NF(e,t,n){if(!K||Z()!==t)return;let r=K.bodyOf(`board`),i=e.mountBoardHost();i.parentElement!==r&&r.replaceChildren(i),e.placeBoardTitle(K.titleSlotOf(`board`)),n&&e.showBoardBeside(n,t)}function PF(){J&&(OP||q)&&DP?.reopenSelectedBoard()}function FF(){let e=ij();J&&e?.sessionId&&A.has(e.sessionId)&&(LF(e.sessionId),MF(e.boardId),K?.showTab(`board`))}function IF(){PN();let e=Z();e&&(mj()===e&&_j(),N.dispatch(`focusSession`,null))}function LF(e){J&&A.has(e)&&(DS(e),hi(e),e!==Z()&&(IF(),q=null,N.dispatch(`focusSession`,e),X=e,dF()))}function RF(){if(!NP||!PP||!FP)return;let e=Z(),t=!!q||!!(e&&A.has(e)),n=A.size>0;ri(NP,t),K&&ri(K.element,!t),aM(NP,!n),ri(PP,!n),ri(FP,!n),!t&&n&&($r(PP,`No session selected`),$r(FP,`Select a session from the rail on the left to focus it here.`))}function zF(e,t){RP.set(k(e),typeof t==`string`&&t?t:`none`),J&&dF()}var BF={placement:`overlay`,sessionId:()=>J&&CP&&!q?Z():null,elementFor:()=>{if(!CP)throw Error(`Focus view is not mounted`);return CP},didShow:()=>{},didHide:()=>{let e=Z();e&&CF(A.get(e),e)}};function VF(e=null){let t=Z();t&&NN(`changes`,t,e)}function HF(e){J&&A.has(e)&&LF(e)}function UF(e){return!J||!A.has(e)?!1:(LF(e),yb(e))}function WF(e){if(!J)return;let t=WP()[e-1];t&&ai(t)&&aF(t)}function GF(e){if(!J)return;let t=WP().filter(e=>e===X||ai(e)),n=On(t,X,e);n!=null&&ai(n)&&(oF(n),Y.get(n)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=Z();J&&e&&DS(e)});function KF(){SP&&(J=!0,AN(BF),IF(),X=null,dF(),IP&&LP?SF(LP):IP&&yF().length>0?xF():(IP&&G&&fN(G),JF()))}function qF(e,t=null){IP=!0,LP=t;try{e()}finally{IP=!1,LP=null}}function JF(){if(!J||Z()||q)return;let e=fi();e&&LF(e)}function YF(){J&&=(IF(),jN(BF),X=null,!1)}var XF=[],ZF=new Set;function QF(e){let t=st.safeParse(e);if(t.success){XF=t.data;for(let e of ZF)e()}}function $F(e){return XF.find(t=>t.agent===e)??null}function eI(e){return ZF.add(e),()=>{ZF.delete(e)}}var tI=2e3,nI={},rI=null,iI=null,aI=mt,oI=null,sI=!1,cI=null,lI=[],uI=null,dI=()=>null,fI=()=>{},pI=!1,mI=new Set,hI=new Set;function gI(e){for(let t of hI)t(e)}function _I(e){hI.add(e)}function vI(){return nI}function yI(e){return nI={...nI,...e},nI}function bI(){return{status:rI,journal:iI,request:aI,lastAutoCheckAt:oI,isCheckInFlight:sI,checkSendFailure:cI}}function xI(e){let t=ze(aI,e);t!==aI&&(aI=t,gI({kind:`update`,frame:`request`}))}function SI(){xI(v({type:`update-apply`})?`request-sent`:`request-unsent`)}function CI(){oI=Date.now();let e=v({type:`update-check`});sI=e,cI=e?null:je,gI({kind:`update`,frame:`request`})}function wI(e){fI=e}function TI(){fI()}function EI(e){lI=[...e]}function DI(){return lI}function OI(e=null,t=null,n=null){let r=uI!==null&&(uI.sectionId!==null||uI.isLink);e===null&&n===null&&r||(uI={sectionId:e,settingId:t,hashAtRequest:n??location.hash,isLink:n!==null},gI({kind:`activate`}))}function kI(){let e=uI;return uI=null,e}function AI(e){dI=e}function jI(){for(let e of mI)e()}function MI(e){mI.add(e)}function NI(){return Co()&&dI()===`section`}function PI(){NI()&&gI({kind:`return-to-list`})}function FI(e){e&&(nI=e,QF(nI.agentLogins),gI({kind:`broadcast`}))}function II(){pI||(pI=!0,window.setTimeout(()=>{a(`get-settings`,{}).then(e=>{e.settings&&FI(e.settings)}).catch(()=>{pI=!1})},tI))}function LI(){gI({kind:`status`})}function RI(e){LI()}function zI(e){rI=e,sI=!1,cI=null,aI=ze(aI,`status-frame`),gI({kind:`update`,frame:`status`})}function BI(e){iI=e,aI=ze(aI,`progress-frame`),gI({kind:`update`,frame:`progress`})}function VI(e){if(e.scope!==`update`)return!1;let t=Ge(e.message),n=aI.requested;return aI=ze(aI,`error-frame`,t),sI=!1,n||(cI=t),gI({kind:`update`,frame:`error`}),!0}var HI=200;function UI(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function WI(e){return/^#settings(?:[/?]|$)/.test(e)}function GI(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function KI(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,HI).join(``).trim()}}function qI(e,t,n){let r=O(`a`,`settings-link`,n);return r.href=UI(e,t),r}var JI={teamReview:e=>e?.teamReview?.enabled!==!1,issues:e=>e?.issues?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,community:e=>e?.community?.enabled===!0},YI=[{rule:`teamReview`,sectionId:`lanes-team-review`,settingId:`team-review-enabled`},{rule:`issues`,sectionId:`lanes-issues`,settingId:`issues-enabled`},{rule:`usage`,sectionId:`machine-usage`,settingId:`usage-enabled`},{rule:`posthog`,sectionId:`lanes-posthog`,settingId:`posthog-enabled`},{rule:`community`,sectionId:`lanes-community`,settingId:`community-enabled`}],XI=null,ZI=null,QI=null,$I=()=>!1,eL=new Set,tL=new Set,nL=At({getAck:Ir,setAck:Lr,signature:()=>Tt({posthog:XI}),isLooking:()=>$I()});function rL(e){for(let t of tL)t(e)}function iL(){ZI?.(nL.refresh())}function aL(){return{latest:XI,archivedLocally:eL,traceOpener:QI}}function oL(e){tL.add(e)}function sL(e){$I=e,iL()}function cL(e){eL.add(e)}function lL(){nL.acknowledge(),iL()}function uL(e){ZI=e,iL()}function dL(e){QI=e}function fL(e){XI=e,Ot(XI,eL),rL({kind:`status`}),iL()}function pL(e){let t=Ze(XI,e.projectId,e.issueId)?.inFlight===!0;bt(XI,e)&&rL({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function mL(e){let t=Te(XI,e);rL({kind:`investigation-finished`,frame:e,isPatched:t}),t&&iL()}var hL=null,gL=[],_L=()=>!1,vL=null,yL=Nr(),bL=Rr(),xL=new Set(bL.split(`|`).filter(Boolean)),SL=new Set;function CL(e){for(let t of SL)t(e)}function wL(){return eh(gL).map($m)}function TL(e){e!==yL&&(yL=e,dr(e))}function EL(e){e!==bL&&(bL=e,xL=new Set(e.split(`|`).filter(Boolean)),kr(e))}function DL(){if(!hL)return;let e=dh({turnEntries:wL(),acknowledged:yL,unseen:bL,isLooking:_L()});TL(e.acknowledged),EL(e.unseen),vL?.(e.isShown)}function OL(e){SL.add(e)}function kL(){return hL}function AL(){return gL}function jL(e){_L=e,DL()}function ML(e){vL=e,DL()}function NL(){hL&&(TL(et(wL())),DL())}function PL(){return bL}function FL(e){return xL.has(e)}function IL(e){return xL.has(e)?(EL(et([...xL].filter(t=>t!==e))),!0):!1}function LL(e){let t=St.safeParse(e);t.success?(hL=t.data,gL=Qm(t.data.entries),DL(),CL({kind:`status`})):u(`community`,`dropped community-status: ${c(t.error.issues)}`)}function RL(e){CL({kind:`connection`,isConnected:e})}function zL({source:e,className:t,title:n,allowsScripts:r}){let i=O(`iframe`,t);return i.setAttribute(`sandbox`,r?`allow-scripts allow-forms`:``),i.setAttribute(`allow`,``),i.referrerPolicy=`no-referrer`,i.title=n,e.kind===`srcdoc`&&(i.srcdoc=e.html),e.kind===`url`&&(i.src=e.url),i}var BL=`panel-action`,VL=524288,HL=[`key`,`prKey`,`repo`,`number`,`action`,`actionId`,`itemKey`,`fingerprint`],UL=900;function WL(e){let t=_t.options.find(t=>t.shape.type.value===e);return new Set(Object.keys(t?.shape??{}).filter(e=>e!==`type`&&e!==`requestId`))}function GL(e){return e.map(e=>`${e.path.map(String).join(`.`)||`request`}: ${e.message}`).join(`; `)}function KL(e,t){let n=Le.safeParse(t);if(!n.success)return{ok:!1,error:`not sent: ${GL(n.error.issues)}`};if(!e.includes(`reviews`))return{ok:!1,error:`${n.data.type} not sent: this panel does not list reviews under acts in pack.json`};let r=_t.safeParse({...n.data,requestId:BL});if(!r.success)return{ok:!1,error:`${n.data.type} not sent: ${GL(r.error.issues)}`};let i=WL(r.data.type),a=Object.fromEntries(Object.entries(r.data).filter(([e])=>i.has(e))),o=new TextEncoder().encode(JSON.stringify(a)).length;return o>524288?{ok:!1,error:`${r.data.type} not sent: the request is ${o} bytes, over the ${VL} byte limit`}:{ok:!0,type:r.data.type,payload:a}}function qL(e,t,n){return`${e} sent ${t} ${HL.flatMap(e=>{let t=n[e];return typeof t==`string`||typeof t==`number`?[`${e}=${t}`]:[]}).join(` `)}`.trim().slice(0,UL)}var JL=`•`.repeat(8),YL=`[^/\\\\\\s"'\`<>:]+`,XL=RegExp(`(?<![\\w./\\\\-])(?:/home/${YL}|/Users/${YL}|[A-Za-z]:[\\\\/]Users[\\\\/]${YL}|/root(?![\\w.-]))`,`g`);function ZL(e){let t=sc(e);if(t.length===0)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+JL,r=i.end;return n+e.slice(r)}function QL(e){return e.replace(XL,`~`)}function $L(e){return QL(ZL(e))}var eR=1e3,tR=12e4,nR=new Map,rR=null;function iR(e){return fc()?$L(e):e}var aR={sessions:()=>({sessions:[...A].map(([e,t])=>({id:e,name:iR(kn(t)),agent:t.agent??null,state:t.currentState,stateSinceMs:t.stateSince,taskTitle:t.taskTitle===null?null:iR(t.taskTitle)}))}),focus:()=>({sessionId:N.snapshot().focusedSessionId,view:N.snapshot().activeView,isStreamerMode:fc()}),theme:()=>ka(),usage:()=>({planLimits:Object.entries(gE().planLimitsByVendor).flatMap(([e,t])=>t===null||e!==`claude`&&e!==`codex`&&e!==`kimi`?[]:[{vendor:e,fiveHour:XS(t,`fiveHour`),sevenDay:XS(t,`sevenDay`)}])}),attention:()=>{let e=Rn([...A.values()].map(e=>({state:e.currentState,unseenOutcome:e.unseenOutcome??null})));return{waiting:e.waitingCount,finished:e.finishedCount,failed:e.failedCount}},reviews:()=>ug()};function oR(e,t){e.frame.contentWindow?.postMessage(t,`*`)}function sR(e,t){let n=t.get(e);if(n)return n;let r=aR[e](),i={data:r,dataJson:JSON.stringify(r)};return t.set(e,i),i}function cR(e,t,n=new Map){let{data:r,dataJson:i}=sR(t,n);e.lastSentJsonByTopic.get(t)!==i&&(e.lastSentJsonByTopic.set(t,i),oR(e,Me.parse({v:1,kind:`topic`,topic:t,data:r})))}function lR(){let e=!1,t=new Map;for(let n of nR.values()){for(let e of n.subscribedTopics)cR(n,e,t);e||=n.subscribedTopics.size>0}e||rR===null||(clearInterval(rR),rR=null)}var uR=new Map;async function dR(e,t){let n=await a(e,t).catch(e=>qx(e));return typeof n==`string`?{ok:!1,error:n}:n.type===`pack-data-result`?n.ok&&n.data?{ok:!0,data:n.data}:{ok:!1,error:n.error??`the pack store did not answer`}:{ok:!1,error:`unexpected ${n.type} reply`}}function fR(e,t){oR(e,{v:1,kind:`store`,data:uR.get(e.packName)??{},error:t})}async function pR(e){let t=await dR(`pack-data-get`,{pack:e.packName});t.ok&&uR.set(e.packName,t.data),fR(e,t.ok?null:t.error)}async function mR(e,t,n){let r=Ae(e.packName,we(uR.get(e.packName)??{},t,n));if(r!==null){fR(e,r);return}let i=await dR(`pack-data-set`,{pack:e.packName,key:t,value:n});if(!i.ok)fR(e,i.error);else{uR.set(e.packName,i.data);for(let t of nR.values())t.packName===e.packName&&fR(t,null)}}function hR(e,t){e.subscribedTopics=new Set(t.filter(t=>e.grantedTopics.has(t))),e.lastSentJsonByTopic.clear(),oR(e,{v:1,kind:`hello`,granted:[...e.subscribedTopics]}),pR(e);for(let t of e.subscribedTopics)cR(e,t);rR??=setInterval(lR,eR)}function gR(e,t,n,r,i=!1){oR(e,{v:1,kind:`action-result`,id:t,ok:r===null,timedOut:i,result:n,error:r})}function _R(e,t){return t.ok===!1?typeof t.error==`string`&&t.error!==``?t.error:`${e} was refused`:null}async function vR(e,t,n){let r=KL(e.acts,n);if(!r.ok){gR(e,t,null,r.error);return}v({type:`client-log`,scope:`packs`,text:qL(e.viewId,r.type,r.payload)});let i=await a(r.type,r.payload,{timeoutMs:tR}).catch(e=>qx(e));if(i===`Request timed out`){gR(e,t,null,`${r.type} got no answer within ${tR/1e3} s; it may still run, so check before sending it again`,!0);return}if(typeof i==`string`){gR(e,t,null,`${r.type} failed: ${i}`);return}let o={...i};gR(e,t,o,_R(r.type,o))}function yR(e){let t=[...nR.values()].find(t=>t.frame.contentWindow!==null&&t.frame.contentWindow===e.source);if(!t)return;let n=Pe.safeParse(e.data);if(n.success){vR(t,n.data.id,n.data.request);return}let r=be.safeParse(e.data);r.success&&(r.data.kind===`store-set`?mR(t,r.data.key,r.data.value):r.data.kind===`subscribe`&&hR(t,r.data.topics))}function bR(e,t,n){nR.size===0&&window.addEventListener(`message`,yR),nR.set(e,{viewId:e,frame:t,packName:n.pack,acts:n.acts,grantedTopics:new Set(n.reads),subscribedTopics:new Set,lastSentJsonByTopic:new Map})}var xR=null,SR=new Set;function CR(){return xR}function wR(e){return SR.add(e),()=>SR.delete(e)}function TR(e){let t=ht.safeParse(e);if(!t.success)u(`settings`,`dropped packs-status: ${c(t.error.issues)}`);else{xR=t.data,Ca(t.data.themes)&&ja();for(let e of SR)e()}}var ER=`about:blank`,DR={pack:``,reads:[],acts:[]},OR=new Map,kR=new Map;function AR(e){let t=O(`img`,`pack-tab-icon`);return t.src=e,t.alt=``,t.decoding=`async`,t.referrerPolicy=`no-referrer`,t}function jR(e){return kR.set(e.viewId,e),{mount(t){let n=kR.get(e.viewId);t.replaceChildren(MR(e.viewId,n?.entryUrl??ER,e.label,n??DR))}}}function MR(e,t,n,r){let i=zL({source:{kind:`url`,url:t},className:`pack-panel-frame`,title:n,allowsScripts:!0});return OR.set(e,i),bR(e,i,r),i}function NR(e,t,n,r){let i=OR.get(e);i&&i.getAttribute(`src`)!==t&&i.replaceWith(MR(e,t,n,r))}function PR(e){kR.set(e.viewId,e),NR(e.viewId,e.entryUrl,e.label,e)}function FR(e){kR.delete(e),NR(e,ER,OR.get(e)?.title??``,DR)}function IR(e){let t=()=>e(CR()?.panels??[]);wR(t),t()}function LR(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function RR(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function zR(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 BR(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 VR(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function HR(e,t,n){t&&e?.refreshOn?.includes(n)&&t.refresh?.(n)}function UR(e,t,n,r){for(let i of e)LR(i.view,t)&&HR(i,r(i.view),n)}function WR(){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 GR(e,t,n){let r=Number(e);return!e||!Number.isFinite(r)||t-r>n}var KR=`glimmervoid:preload-error-reload-at`,qR=3e4,JR=1e3,YR=WR();function XR(e,t){let n=YR.mountedModuleOf(e.view);n?t(n):YR.show(e).then(t).catch(t=>{throw u(`view`,`${e.view} failed to show: ${d(t)}`),t})}function ZR(e){return YR.mountedModuleOf(e)}function QR(e){YR.mountEagerViews(e)}function $R(e){let t=()=>{YR.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,JR)}function ez(e){let t=Date.now();GR(e.getItem(KR),t,qR)&&(e.setItem(KR,String(t)),location.reload())}function tz(e){window.addEventListener(`vite:preloadError`,()=>ez(e()))}function nz(e,t){fetch(e,{method:`HEAD`,cache:`no-store`}).then(e=>{e.status===404&&ez(t())}).catch(()=>{})}function rz(e,t,n){let r=D(document,`#app-main`,`main`),i=tt(`header-tab`,e.label);i.prepend(t),i.id=`tab-${e.view}`,i.draggable=!0;let a=`view-${e.view}`;i.setAttribute(`role`,`tab`),i.setAttribute(`aria-controls`,a);let o=e.view===`focus`;i.setAttribute(`aria-selected`,String(o)),i.tabIndex=o?0:-1;let s=document.getElementById(a)??O(`section`);if(s.classList.add(e.panelClass),s.id=a,s.setAttribute(`role`,`tabpanel`),s.setAttribute(`aria-labelledby`,i.id),s.hidden=!0,s.parentElement||r.append(s),i.hidden=e.gate!==void 0||e.isPhoneOnly===!0,s.classList.toggle(`view-panel`,e.hasPanelChrome!==!1),e.attention){let t=O(`span`,`tab-activity`);t.id=`tab-${e.view}-activity`,t.setAttribute(`aria-hidden`,`true`),i.append(t),e.attention.subscribe(r=>{let{isActive:i,level:a}=VR(r);t.classList.toggle(`active`,i),a===null&&t.removeAttribute(`data-attention`),a!==null&&t.setAttribute(`data-attention`,a),n(e.view,r)})}return{...e,tab:i,el:s}}function iz(e){return e.iconUrl?AR(e.iconUrl):w(at)}function az(e){return rz({view:e.viewId,label:e.label,iconPath:``,panelClass:`pack-panel-view`,hasPanelChrome:!1,module:jR(e)},iz(e),()=>{})}function oz(e,t){e.tab.replaceChildren(iz(t),t.label)}function sz(e){tg({openTerminal:e.openTerminal,openReviews:e.openReviews}),TM({openTerminal:e.openTerminal}),wI(e.onRestart),$A(e.openReviewFile);let t=[{view:`focus`,label:`Focus`,iconPath:yt,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,refreshOn:[`connected`],module:{mount:()=>XP({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:KF,deactivate:YF,refresh:PF}},{view:`prs`,label:`Reviews`,iconPath:Ve,panelClass:`pr-view`,gate:{fromSettings:JI.teamReview},load:()=>P(()=>import(`./review-queue-panel-CREnMu2I.js`).then(e=>e.view),__vite__mapDeps([38,12,13,5,3,14,15,4,6,7,39,31,40,41,34,42,26,19,27,28,22,29,20,30,23,32,43])),refreshOn:[`shown`],attention:{subscribe:Zh,acknowledge:Xh},onConnectionChange:e=>{Dm(e),kh(e)}},{view:`issues`,label:`Issues`,iconPath:Qe,panelClass:`issues-view`,gate:{fromSettings:JI.issues},load:()=>P(()=>import(`./issues-panel-DA-TyQpb.js`).then(e=>e.view),__vite__mapDeps([44,13,5,3,14,19,15,12,28,22,29,4,6,7,20,31,41,16,42,26,27,30,23,32,45])),refreshOn:[`shown`],onConnectionChange:Kf},{view:`usage`,label:`Usage`,iconPath:_e,panelClass:`usage-view`,gate:{fromSettings:JI.usage},load:()=>P(()=>import(`./usage-panel-DWVbDiG1.js`).then(e=>e.view),__vite__mapDeps([46,13,5,3,47,48])),attention:{subscribe:xE,acknowledge:bE},onConnectionChange:DE,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,iconPath:Nt,panelClass:`radar-view`,gate:{fromSettings:JI.posthog},load:()=>P(()=>import(`./radar-panel-DxnKC0O3.js`).then(e=>e.view),__vite__mapDeps([49,12,13,5,3,14,19,15,50,27,28,22,29,4,6,7,20,32,35,47,51])),attention:{subscribe:uL,acknowledge:lL}},{view:`community`,label:`Community`,iconPath:ct,panelClass:`community-view`,gate:{fromSettings:JI.community},load:()=>P(()=>import(`./community-panel-DFjyCuQn.js`).then(e=>e.view),__vite__mapDeps([52,12,13,5,3,14,19,15,39,31,40,41,4,6,7,34,53])),refreshOn:[`shown`],attention:{subscribe:ML,acknowledge:NL},onConnectionChange:RL},{view:`boards`,label:`Boards`,iconPath:at,isPhoneNavScreen:!0,isPhoneOnly:!0,panelClass:`boards-screen`,hasPanelChrome:!1,load:()=>P(()=>import(`./boards-view-DQTSAGYw.js`).then(e=>e.view),__vite__mapDeps([36,13,5,3,14,19,15,12,30,23,37])),refreshOn:[`shown`,`connected`]},{view:`hooks`,label:`Hooks`,iconPath:lt,panelClass:`hooks-view`,load:()=>P(()=>import(`./hooks-panel-Cy_NwPQM.js`).then(e=>e.view),__vite__mapDeps([54,12,13,5,3,14,15,55])),refreshOn:[`shown`,`connected`,`hooks-updated`]},{view:`trace`,label:`Trace`,iconPath:Ue,panelClass:`trace-view`,gate:{subscribe:Iv},load:()=>P(()=>import(`./trace-panel-Bsr2Easc.js`).then(e=>e.view),__vite__mapDeps([56,13,5,3,15,12,4,6,7,57])),refreshOn:[`shown`],onAvailabilityChange:e=>dL(e?Vx:null),onConnectionChange:Kx},{view:`benchmarks`,label:`Arena`,iconPath:wt,panelClass:`bench-view`,load:()=>P(()=>import(`./arena-panel-ISlMnhdr.js`).then(e=>e.view),__vite__mapDeps([58,12,13,5,3,14,19,29,27,59])),onConnectionChange:Bi},{view:`settings`,label:`Settings`,iconPath:me,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>P(()=>import(`./settings-panel-C8mHUg30.js`).then(e=>e.view),__vite__mapDeps([60,12,13,5,3,14,15,4,6,7,28,19,22,29,20,32,10,50,27,35,61,8,42,26,30,23,31,43,2,1,62]))}].map(t=>rz(t,w(t.iconPath),e.setPhoneAttention));return D(document,`#header-tabs`,`div`).replaceChildren(...t.map(e=>e.tab)),t}function cz(e){return e===`remote`?`remote`:`local`}function lz(e,t){return cz(t)===`local`||e!==`shutdown`}var uz=!1,dz=new Set;function fz({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){let o=cS(),s=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;Qt({title:t,message:s,confirmLabel:n,danger:r||o>0,onConfirm:()=>v({type:e})})}function pz(){fz({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function mz(){fz({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})}function hz(e){uz=lz(`shutdown`,e);for(let e of dz)e.isConnected?e.hidden=!uz:dz.delete(e)}function gz(e){e.hidden=!uz,dz.add(e)}function _z(e){e&&OI(e),!Bj(`settings`)&&$(`settings`,{section:e})}function vz(e){Bj(e)||$(e)}function yz(){Bj(`boards`)||($(`focus`),FF())}function bz(){WI(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}var Q=sz({onRestart:pz,openTerminal:e=>{zj(e)||($(`focus`),HF(e))},openPlan:e=>{$(`focus`),UF(e)},openReviewFile:(e,t)=>{sS(e)&&(zj(e)||($(`focus`),HF(e),VF(t)))},openReviews:()=>wz(`prs`)?(Bj(`prs`)||$(`prs`),!0):!1,setPhoneAttention:Pj});function xz(){return Q.map(e=>e.view)}var Sz=xz();function Cz(e){return Q.find(t=>t.view===e)}function wz(e){return Q.some(t=>t.view===e&&!t.tab.hidden)}var Tz=!0,Ez=null;function Dz(e){Cz(e)?.attention?.acknowledge()}var Oz=null;function kz(e){Oz=v({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function Az(){Oz&&kz(Oz)}function jz(e){let t=Cz(e);t&&(XR(t,e=>HR(t,e,`shown`)),kz(e))}function Mz(e){UR(Q,{isPhoneShellActive:Aj(),activeView:Vn(),phoneScreen:N.snapshot().phoneScreen},e,ZR)}function $(e,{section:t,setting:n,persist:r=!0}={}){let i=Cz(e);if(!i||!wz(e))return;let a=Vn();N.dispatch(`setActiveView`,e),Tz=r,r&&(Ez=null),document.body.dataset.activeView=e,r&&cr(e);for(let t of Q){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&&ZR(a)?.deactivate?.(),XR(i,r=>{Vn()===e&&(r.activate?.(),HR(i,r,`shown`),e===`settings`&&t&&OI(t,n??null))}),kz(e),a===`settings`&&e!==`settings`&&bz(),Dz(e)}function Nz(e,t){let{view:n}=e;e.tab.hidden=!t,Nj(n,t),e.onAvailabilityChange?.(t),!Aj()&&(!t&&Vn()===n&&$(`focus`),t&&Ez===n&&$(n))}function Pz(e){for(let{view:t,isAvailable:n}of RR(Q,e))Nz(t,n)}var Fz;function Iz(e){Fz=e;let t=zR(Sz,e);Q.every((e,n)=>e.view===t[n])||(Q.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),D(document,`#header-tabs`,`div`).append(...Q.map(e=>e.tab)),Mj(t))}function Lz(){return Q.filter(e=>!e.tab.hidden)}function Rz(e,t){let n=e[t];return $(n.view),n.tab}function zz(e,t){let n=Lz(),r=n.findIndex(t=>t.view===e);return Rz(n,Ci(r,t,n.length))}function Bz(e){Q.some(e=>e.tab===document.activeElement)&&e.focus()}var Vz=null;function Hz(e){let t=xz();Iz(e),a(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&Iz(t)}).catch(()=>Iz(t))}function Uz(e){let t=Vz;if(Vz=null,!t||t===e)return;let n=xz();Hz(BR(n,t,n.indexOf(e)))}function Wz({view:e,tab:t}){t.addEventListener(`click`,()=>$(e)),t.addEventListener(`dragstart`,t=>{Vz=e,t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),t.addEventListener(`dragover`,n=>{Vz&&Vz!==e&&(n.preventDefault(),t.dataset.dropTarget=`true`)}),t.addEventListener(`dragleave`,()=>delete t.dataset.dropTarget),t.addEventListener(`drop`,n=>{n.preventDefault(),delete t.dataset.dropTarget,Uz(e)}),t.addEventListener(`dragend`,()=>{Vz=null}),t.addEventListener(`keydown`,e=>{if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=Lz(),n=t.findIndex(e=>e.view===Vn()),r=wi(e.key,n,t.length,`horizontal`);r!==null&&(e.preventDefault(),Rz(t,r).focus())})}var Gz=`pack:`,Kz=new Map;function qz(e){let t=az(e);return Q.push(t),Sz.push(t.view),D(document,`#header-tabs`,`div`).append(t.tab),Wz(t),t}function Jz(e){let t=new Set(e.map(e=>e.viewId));for(let e of Q)e.view.startsWith(Gz)&&!t.has(e.view)&&(FR(e.view),Nz(e,!1));for(let t of e){let e=Cz(t.viewId)??qz(t),n=Kz.get(t.viewId);n&&(n.label!==t.label||n.iconUrl!==t.iconUrl)&&oz(e,t),Kz.set(t.viewId,t),PR(t),Nz(e,!0)}Iz(Fz)}function Yz(){let e=Hr(),t=WI(location.hash),n=uy(location.hash);if(t&&(OI(null,null,location.hash),$(`settings`,{persist:!1})),n&&$(`focus`,{persist:!1}),t||n)return;let r=wz(e);r||(Ez=e),$(r?e:`focus`,{persist:r})}function Xz(){let e=Vn();$(wz(e)?e:`focus`,{persist:Tz})}function Zz(){EI(Q),QR(Q);for(let e of Q)e.gate&&(Nz(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>Nz(e,t)));Bx(()=>{wz(`trace`)&&(Bj(`trace`)||$(`trace`))});for(let e of Q)Wz(e);Yz(),IR(Jz)}function Qz(e){return WI(e)?(OI(null,null,e),Bj(`settings`)||$(`settings`,{persist:!1}),!0):!1}var $z=`No plan is stored for this session yet. It appears here once the agent writes one.`,eB=`Plan`;function tB(e){let t=uy(e);return t?!sS(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),Aj()?(Rj(t)||Wn({source:eB,sessionId:t,message:$z}),!0):($(`focus`,{persist:!1}),UF(t)||Wn({source:eB,sessionId:t,message:$z}),!0)):!1}function nB(e){return tB(e)?!0:Qz(e)}function rB(e){e.newURL===location.href&&nB(location.hash)}function iB(){document.addEventListener(`click`,e=>{if(!Aj()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&nB(t.hash)&&e.preventDefault()}),window.addEventListener(`hashchange`,rB)}var aB=null,oB=new Set;function sB(){aB?.setState(Gr()?`idle`:`off`)}function cB(e){_r(e),sB();for(let t of oB)t(e)}function lB(e){oB.add(e)}function uB(e){aB=e,sB(),e.element.addEventListener(`click`,()=>cB(!Gr()))}var dB=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,fB=[`title`,`label`],pB=new WeakMap,mB=new WeakMap,hB=null;function gB(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(dB)!==null}function _B(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function vB(e,t){if(t&&e===t.masked)return t;let n=$L(e);return n===e?null:{original:e,masked:n}}function yB(e){let t=_B(e)?null:vB(e.data,pB.get(e));t?(pB.set(e,t),e.data!==t.masked&&(e.data=t.masked)):pB.delete(e)}function bB(e,t){let n=e.getAttribute(t),r=mB.get(e),i=n===null?null:vB(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),mB.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function xB(e){for(let t of fB)bB(e,t)}function SB(e){return e instanceof Element&&e.matches(dB)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function CB(e){xB(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,SB);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&yB(e),e instanceof Element&&xB(e)}function wB(e){gB(e)||(e instanceof Text&&yB(e),e instanceof Element&&CB(e))}function TB(e){e instanceof Element&&!gB(e)&&xB(e)}function EB(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&&wB(e);for(let e of n)e.isConnected&&TB(e)}function DB(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);OB(e);for(let e=t.nextNode();e;e=t.nextNode())OB(e)}function OB(e){if(e instanceof Text){let t=pB.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=mB.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function kB(){if(hB)return;let e=new MutationObserver(t=>{EB(t),e.takeRecords()});CB(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:fB}),hB=e}function AB(){hB&&(hB.disconnect(),hB=null,DB(document.body),pB=new WeakMap,mB=new WeakMap)}function jB(e){e?kB():AB()}function MB(){jB(fc()),mc(jB)}var NB=ft({label:`Play queued merge celebrations`,icon:w(ve,`1.6`),action:`play-celebrations`,states:[`idle`,`attention`]}),PB=T({variant:`primary`,label:`Session`,icon:w(rt),action:`add-session`,onClick:gi});PB.id=`btn-add-session-header`;var FB=ft({label:`Keyboard shortcuts and version`,icon:w(ut,`1.6`),action:`open-shortcuts-help`,onClick:()=>_z(`browser-shortcuts`),states:[`idle`]}).element,IB=ft({label:`Mute alerts`,icon:w(Ft,`1.6`),action:`toggle-mute`,states:[`idle`,`off`]}),LB=IB.element,RB=T({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-header-status`});RB.id=`header-status-dismiss`;var zB=D(document,`#celebration-tray`,`div`);zB.prepend(NB.element),D(document,`.header-right`,`div`).append(PB,FB,LB),D(document,`#header-status`,`p`).append(RB);function BB(){uB(IB),MB(),Jt(document.querySelector(`.header`))}function VB(){dp(zB,NB,D(document,`#celebration-tray-count`,`span`))}function HB(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:`}function UB(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 WB(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function GB(e,t){return t||WB(e)?!1:UB(e)}var KB=T({variant:`primary`,size:`small`,label:`Restart`,action:`restart-to-update`,hidden:!0}),qB=T({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-update-command`}),JB=T({variant:`icon`,size:`small`,label:`Dismiss update notice`,icon:w(Dt),action:`dismiss-update-banner`});D(document,`#update-banner-cmd`,`code`).before(KB),D(document,`#update-banner-copy-status`,`span`).before(qB),D(document,`#update-banner`,`div`).append(JB);var YB=T({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-leftovers-command`}),XB=T({variant:`icon`,size:`small`,label:`Dismiss old report notice`,icon:w(Dt),action:`dismiss-leftovers-banner`});D(document,`#post-turn-leftovers-copy-status`,`span`).before(YB),D(document,`#post-turn-leftovers-banner`,`div`).append(XB);var ZB,QB=null;function $B(e,t,n){e.onclick=()=>{let e=Wt(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var eV=qI(De,xe,`Update`).href;function tV(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function nV(e){let t=D(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=qe(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=tV(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===QB||!a&&ZB!==void 0&&s===ZB||!a&&s&&Dr()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);D(document,`#update-banner-text`,`span`).textContent=i,D(document,`#update-banner-cmd`,`code`).textContent=c;let l=D(document,`#update-banner-update`,`a`);l.href=eV,l.hidden=n!==`link`,KB.hidden=n!==`restart`,KB.onclick=pz;let u=D(document,`#update-banner-cmd`,`code`);u.hidden=n!==`command`,qB.hidden=n!==`command`;let d=D(document,`#update-banner-copy-status`,`span`);d.hidden=n!==`command`,d.textContent=``;let f=D(document,`#update-banner-link`,`a`);f.hidden=!e.releaseUrl,f.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,$B(qB,d,c),JB.onclick=()=>{t.hidden=!0,a?QB=i:(ZB=s,or(s))}}var rV=!1;function iV({repositories:e,command:t}){let n=D(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(rV)return;let r=D(document,`#post-turn-leftovers-copy-status`,`span`);D(document,`#post-turn-leftovers-text`,`span`).textContent=HB(e.length),D(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,$B(YB,r,t),XB.onclick=()=>{rV=!0,n.hidden=!0}}var aV=D(document,`#telemetry-banner`,`div`),oV=T({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-telemetry-banner`});aV.append(oV);function sV(){ar(!0),aV.hidden=!0}function cV(e){aV.hidden=!GB(e,pr())}function lV(){let e=D(document,`#telemetry-banner-settings`,`a`);e.href=qI(`privacy`,`telemetry-enabled`,`What's collected`).href,e.addEventListener(`click`,sV),oV.addEventListener(`click`,sV)}function uV(e){P(()=>import(`./feature-hint-DOqkkS_S.js`).then(t=>t.showFeatureHint(e,{isFeatureEnabled:e=>wz(pe[e]),openView:vz,openSetting:(e,t)=>Qz(UI(e,t))}),e=>u(`feature-hint`,`hint card failed to load: ${d(e)}`)),__vite__mapDeps([63,12,13,5,3,4,6,7,61,8,64]))}function dV(){P(()=>import(`./feature-hint-DOqkkS_S.js`).then(e=>e.showStarHint(),e=>u(`star-hint`,`star card failed to load: ${d(e)}`)),__vite__mapDeps([63,12,13,5,3,4,6,7,61,8,64]))}var fV=2500;function pV({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}function mV(e){Da(e.isExperimentalBuild===!0&&Kr()),lS(e),FI(e),Pz(e),cV(e),Iz(e.viewTabOrder),pc(e.streamerMode===!0)}var hV=Object.freeze({top:[0,1],right:[-1,0],bottom:[0,-1],left:[1,0]}),gV=160,_V=950,vV=900,yV=980,bV=450,xV=720,SV=260,CV=`cubic-bezier(0.22, 1, 0.36, 1)`,wV=`cubic-bezier(0.2, 0.8, 0.3, 1)`,TV=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),EV=e=>new Promise(t=>{setTimeout(t,e)});function DV(e){return e!==void 0&&Object.hasOwn(hV,e)}function OV(e){return[...e.querySelectorAll(`.loading-mark-bracket`)].flatMap(e=>{let t=e instanceof SVGElement?e.dataset.side:void 0;if(!(e instanceof SVGElement)||!DV(t))return[];let[n,r]=hV[t];return[{bracket:e,dx:n,dy:r}]})}function kV(e){for(let{bracket:t}of e){let e=getComputedStyle(t),n={transform:e.transform===`none`?`none`:e.transform,stroke:e.stroke};t.animate([n,{transform:`none`,stroke:Uc}],{duration:gV,easing:`ease-out`})}}function AV(e){e.animate([{transform:`rotate(0deg)`,easing:`cubic-bezier(0.5, 0, 0.15, 1)`},{transform:`rotate(360deg)`,offset:.86,easing:wV},{transform:`rotate(354deg)`,offset:.93,easing:wV},{transform:`rotate(360deg)`}],{duration:_V})}function jV(e){for(let{bracket:t,dx:n,dy:r}of e){let e=`translate(${n*7}px, ${r*7}px)`;t.animate([{transform:`none`},{transform:e,offset:.22},{transform:e,offset:.4},{transform:`none`}],{duration:520,delay:vV,easing:`cubic-bezier(0.2, 0.9, 0.3, 1)`})}}function MV(e,t){e.animate([{transform:`scale(0)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:yV,easing:CV,fill:`forwards`}),t.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`})}function NV(e,t,n){for(let{bracket:t,dx:n,dy:r}of e)t.animate([{transform:`none`,opacity:1},{transform:`translate(${n*4}px, ${r*4}px)`,opacity:1,offset:.18},{transform:`translate(${-n*46}px, ${-r*46}px)`,opacity:0}],{duration:xV,easing:`cubic-bezier(0.6, 0, 0.2, 1)`,fill:`forwards`});t.animate([{transform:`scale(1)`,opacity:1},{transform:`scale(0.7)`,opacity:1,offset:.18},{transform:`scale(5)`,opacity:.5,offset:.45},{transform:`scale(9)`,opacity:0}],{duration:xV,easing:`cubic-bezier(0.5, 0, 0.2, 1)`,fill:`forwards`}),n.animate([{transform:`scale(1)`,opacity:0},{transform:`scale(1)`,opacity:1,offset:.2},{transform:`scale(12)`,opacity:0}],{duration:900,easing:`ease-out`})}async function PV(e){let t=e.querySelector(`.loading-mark`),n=e.querySelector(`.loading-mark-dial`),r=e.querySelector(`.loading-mark-light`),i=e.querySelector(`.loading-mark-halo`);if(TV?.matches||document.hidden||!(t instanceof SVGElement)||!n||!r||!i)return;let a=OV(t);kV(a),e.dataset.unlock=`spin`,await EV(gV),AV(n),jV(a),MV(r,i),await EV(yV),e.dataset.unlock=`lit`,await EV(bV),e.dataset.unlock=`burst`,NV(a,r,i),await EV(SV)}var FV=D(document,`#connection-status`,`span`),IV=D(FV,`.connection-label`,`span`),LV=D(document,`#loading-screen`,`div`),RV=D(document,`#loading-status`,`div`),zV=D(document,`#loading-detail`,`div`),BV=D(document,`#shutdown-screen`,`div`),VV=D(document,`#shutdown-status`,`div`),HV=!1,UV=null,WV=!1;function GV(){HV||UV===null||pV({hasSnapshot:WV,connectingTerminalCount:dl(),msSinceConnected:performance.now()-UV})===`reveal`&&qV()}function KV(){WV=!0,GV()}function qV(){HV||(HV=!0,$R(Q),df(),sM(),PV(LV).then(JV,JV))}function JV(){LV.classList.add(`fade-out`);let e=()=>LV.remove();LV.addEventListener(`transitionend`,t=>{t.target===LV&&e()}),setTimeout(e,1e3)}function YV(e,t){FV.dataset.state=`shutdown`,IV.textContent=e,VV.textContent=t,BV.classList.add(`active`)}var XV=new Set([`disconnected`,`connecting`]);function ZV(e,t,n){FV.dataset.state=e,FV.toggleAttribute(`data-reconnected`,n),IV.textContent=t}function QV(e,t){ZV(e,t,e===`connected`&&XV.has(FV.dataset.state??``))}function $V(e,t){FV.dataset.state!==`shutdown`&&ZV(e===`verified`?`connected`:e,t,!1)}var eH=1e4,tH=`Server`,nH=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,rH=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,iH=null,aH=!1;function oH(){RV.textContent=`Reconnecting to server...`,zV.textContent=rH,zV.hidden=!aH}function sH(){iH=null,aH=!0,HV?Wn({source:tH,message:nH,hidesInStreamerMode:!1}):oH()}function cH(){iH!==null||aH||(iH=window.setTimeout(sH,eH))}function lH(){iH!==null&&window.clearTimeout(iH),iH=null,aH=!1,zV.hidden=!0,Un(tH)}function uH(){lH(),nz(import.meta.url,()=>window.sessionStorage),Az(),BV.classList.contains(`active`)?location.reload():(oM(),document.body.classList.add(`app-ready`),!HV&&UV===null&&(UV=performance.now(),RV.textContent=`Connecting to sessions...`,setTimeout(qV,fV)),GV(),Mz(`connected`),a(`get-settings`,{}).then(e=>{e.settings&&(mV(e.settings),Vn()===`settings`&&Qz(location.hash))}).catch(()=>{}))}function dH(e,t){if(e===`connecting`||e===`verified`)$V(e,t);else{QV(e,t),Tb(e===`connected`);for(let t of Q)t.onConnectionChange?.(e===`connected`);e===`connected`?uH():e===`disconnected`&&BV.classList.contains(`active`)?VV.textContent=`Waiting for server...`:(cH(),HV||oH())}}function fH(){ul(GV),o(dH)}var pH=14,mH=Object.freeze({idle:Wc,failed:`#ef4444`,waiting:`#f59e0b`});function hH({waitingCount:e,failedCount:t}){return e>0?`waiting`:t>0?`failed`:`idle`}function gH(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><title>Glimmervoid</title><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"/><g transform="translate(2.4 2.4) scale(0.272)">${Gc({frame:Uc,light:mH[e],strokeWidth:pH})}</g></svg>`}function _H(){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 vH=_H(),yH=`idle`;function bH(e){let t=hH(e);t!==yH&&(yH=t,vH.href=`data:image/svg+xml,${encodeURIComponent(gH(t))}`)}function xH(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}}function SH(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,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}}function CH(){Gf(),Cm(),Fj()}function wH(){dF(),CH()}function TH(){ni(e=>{dF(e),CH()})}var EH=null;function DH(e){let t=xH(EH,e);EH=t.knownBuild,t.reload&&location.reload()}function OH(e){Gn(e),wS(e),$i(e),Tv(e),Cg(e)}function kH(e){let t=new Set(e.map(e=>e.id));for(let e of[...A.keys()])t.has(e)||OH(e)}function AH(e){kH(e),RI(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){Qi(t.id,t.coherenceHooks),Sg(t.id,t.linkedPrs);let e=sS(t.id);e&&OS(t.id,t.state,t.stateSince),e&&fn(t.id,!!t.saneYolo),e||pS(t.id,t.name,t.state,SH(t)),qy(t.id,t.failureReason),oS(t.id,t.taskTitle,t.taskTitleIsCustom),hS(t.id,t.agent),SS(t.id,t.mergeStatus,t.mergeReason),mS(t.id,t.effectiveBase),_S(t.id,t.activeAgents,t.awaitingBackgroundTasks),vS(t.id,t.pendingPromptKind),yS(t.id,t.unseenOutcome),bb(t.id,t.hasPlan)}fS(),bH(M.counts),dF(),JF(),CH(),jH(),tB(location.hash),Vj(),KV()}function jH(){Hx([...A].map(([e,t])=>({id:e,name:kn(t)||e})))}function MH(e,t){bb(e,t?.hasPlan===!0),yS(e,t?.unseenOutcome)}var NH=new Set([E.DONE,E.FAILED]);function PH(e,t){return e!==void 0&&NH.has(e)&&!NH.has(t)&&t!==E.DORMANT}function FH(e){let t=A.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;wS(e.id),pS(e.id,e.session,E.DORMANT,SH({skipPerms:i,saneYolo:a,worktree:r?.dataset.worktree!==void 0,workspace:r?.dataset.workspace!==void 0,remoteWorkspace:r?.dataset.remoteWorkspace??null,ephemeral:r?.dataset.ephemeral!==void 0,path:o,stateSince:e.timestamp,taskTitle:t?.taskTitle,taskTitleIsCustom:t?.taskTitleIsCustom})),hS(e.id,t?.agent),MH(e.id,t)}function IH(e,t){let n=A.get(String(e.id))?.currentState;t.to===E.DORMANT&&n!==E.DORMANT?(FH(e),Cv(e.id)):(OS(e.id,t.to,e.timestamp),qy(e.id,e.failureReason),e.saneYolo!==void 0&&fn(e.id,e.saneYolo),Cv(e.id),PH(n,t.to)&&Dl(e.id))}function LH(e){if(sS(e.id))e.transition&&IH(e,e.transition),e.activeAgents!==void 0&&_S(e.id,e.activeAgents,e.awaitingBackgroundTasks),e.unseenOutcome!==void 0&&yS(e.id,e.unseenOutcome),e.pendingPromptKind!==void 0&&vS(e.id,e.pendingPromptKind),e.unseenOutcome!==void 0&&fS(),bH(M.counts),oi(e.id),Jv(e.id);else{if(!e.transition)return;pS(e.id,e.session,e.transition.to,SH({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),bH(M.counts),Gf()}}function RH(e){let t={};for(let n of e){for(let e of Object.keys(n))if(Object.hasOwn(t,e))throw Error(`dashboard message type ${e} is claimed by two handler groups`);Object.assign(t,n)}return t}var zH={"session-trace-response":e=>Ux(e),"session-trace-changed":e=>Wx(e),"session-plan-changed":e=>{xb(e),CH()},"session-plan-draft":e=>{Sb(e)},"session-plan-response":e=>{Cb(e)},"session-docs-changed":e=>f_(e),"session-docs-snapshot":e=>p_(e),"session-coherence-hooks":e=>{Qi(e.id,e.coherenceHooks),wH()},"session-coherence":e=>{ea(e),wH()},"session-coherence-snapshot":e=>{ta(e),wH()},"session-coherence-journal-response":e=>oa(e)},BH={"team-review-status":e=>Eh(e),"github-prs":e=>Qf(e),"my-prs-status":wm,"pr-flows-status":Tm,"packs-status":TR,"my-pr-merge-result":e=>Em(e),"team-review-action-result":e=>Dh(e),"open-team-review-session-result":e=>Oh(e),"issues-status":e=>qf(e),"issue-detail-result":e=>Jf(e),"open-issue-session-result":e=>Yf(e),"set-issue-state-result":e=>Lf(e)},VH={"radar-status":e=>fL(e),"radar-investigation-activity":e=>pL(e),"radar-investigation-finished":e=>mL(e),"community-status":e=>LL(e),"benchmark-status":e=>Vi(e),"benchmark-action-result":e=>Hi(e),"race-status":e=>xM(e),"usage-sessions":e=>OE(e),"usage-report":e=>{AE(e),LI()},"plan-limits":e=>kE(e),"usage-budget-alert":e=>zy({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0})},HH={snapshot:e=>{DH(e.serverBuild),AH(e.sessions)},"hooks-report":e=>t_(e),"save-hook-result":()=>n_(),"delete-hook-result":()=>n_(),"update-status":e=>{nV(e),zI(e)},"update-progress":e=>BI(e.journal),"post-turn-leftovers":e=>iV(e),"feature-hint":e=>uV(e.hint),"star-hint":()=>dV(),error:e=>{let t=VI(e),n=Gx(e),r=wb(e);t||n||r||(e.id?Ky(e.id,e.message):Wn({source:tH,message:e.message}))},"settings-updated":e=>{e.settings&&mV(e.settings),oM()},"agent-logins":e=>QF(e.logins),"health-snapshot":e=>{e.stats&&Ug(e.stats)},"client-trust":e=>hz(e.trust),"shutting-down":()=>YV(`Shutting down...`,`Shutting down sessions...`),restarting:()=>YV(`Restarting...`,`Restarting server...`)},UH={"session-status":e=>LH(e),"session-added":e=>{Sg(e.id,e.linkedPrs),sS(e.id)||(pS(e.id,e.session,e.state,SH(e)),hS(e.id,e.agent)),bH(M.counts),wH(),jH()},"session-close-confirm":e=>{li(e.id)},"session-removed":e=>{OH(e.id),bH(M.counts),wH(),jH()},"session-title":e=>{oS(e.id,e.taskTitle,e.isCustom),wH()},"session-prs":e=>Sg(e.id,e.linkedPrs),"session-renamed":e=>{CS(e.id,e.newName),wH(),jH()},"session-modified":e=>{let t=A.get(String(e.id)),n=Qr()===String(e.id);Qi(e.id,null),wS(e.id),Tv(e.id),Sg(e.id,e.linkedPrs),pS(e.id,e.session,e.state,SH(e)),n&&pi(String(e.id)),hS(e.id,e.agent),MH(e.id,t),bH(M.counts),wH(),jH()},"session-git":e=>gS(e.id,!!e.worktree),"session-merge-status":e=>{xS(e.id,e.mergeStatus,e.reason),zF(e.id,e.mergeStatus),CH()},"debug-state-response":e=>qv(e),"session-setup-response":e=>NS(e),notify:e=>{Ry(e),Jv(e.session)},"session-error":e=>{wv(e.id),!wb(e)&&Ky(e.id,e.message)}},WH={"whiteboards-snapshot":e=>VA(e),"whiteboard-patch":e=>HA(e),"whiteboard-removed":e=>UA(e)},GH=`Worktree`,KH=`Worktree warning`,qH=RH([HH,UH,{"session-worktree-blocked":e=>{Wn({source:GH,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=>{Wn({source:KH,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=>{Un(GH,e.id),mS(e.id,e.base)},"session-diff":e=>{vv(e.id,e)},"session-diff-error":e=>{yv(e.id,e.message)},"change-map":e=>bv(e.id,e.map),"session-changed":e=>xv(e.id)},zH,WH,BH,VH]);function JH(e){let t=qH[e.type];t&&t(e)}function YH(){l(e=>{JH(e),Mz(e.type)})}function XH(e){return e.filter(e=>!e.hasOwnPhoneScreen).map(e=>({id:e.view,label:e.label.trim(),iconPath:e.iconPath,isNavScreen:e.isPhoneNavScreen===!0,el:e.el}))}function ZH(){Dj({panels:XH(Q),onScreenShown:e=>{jz(e),e!==`settings`&&bz(),e===`settings`&&!WI(location.hash)&&OI(),Dz(e)},canGoBack:e=>e===`settings`&&NI()||e===`prs`&&og(),onBack:e=>{e===`settings`&&PI(),e===`prs`&&sg()},headerControls:[D(document,`.header-title`,`h1`),D(document,`#status-indicator`,`div`),D(document,`#celebration-tray`,`div`),PB,FB,LB]}),MI(Ij),ag(Ij)}function QH(e){if(e===`phone`){let e=Z();for(let e of Q)ZR(e.view)?.deactivate?.();let t=WI(location.hash);Oj({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}).then(e=>{e&&t&&OI(null,null,location.hash),!e&&Co()&&!Aj()&&Xz()});return}let t=jj();kj(),Xz(),t&&HF(t)}function $H(){ZH(),Co()&&QH(`phone`),wo(QH)}function eU(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function tU(e){HF(e),hi(e),requestAnimationFrame(()=>requestAnimationFrame(()=>A.get(e)?.term?.focus()))}function nU(){let e=eU()??Qr();e?ii(e):document.getElementById(`btn-add-session-header`)?.click()}function rU({action:e,step:t}){switch(e){case`merge`:{let e=Qr();return!e||YP()?!1:(Dv(e),!0)}case`close-session`:{let e=Qr();return e?(ci(e),!0):!1}case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return nU(),!0;case`next-attention`:return Co()?!1:JP()?(xF(),!0):(Vn()===`prs`&&cg()||qF(()=>$(`focus`)),!0);case`rail-step`:return JP()?(GF(t),!0):!1;case`view-step`:return!Co()&&(Bz(zz(Vn(),t)),!0);case`session-nth`:return JP()?(WF(t),!0):!1;case`streamer-mode`:return vc(),!0}}function iU(e){return e.code!==`KeyZ`||e.altKey||e.shiftKey?!1:Hl===`mac`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function aU(){ui(tU),document.addEventListener(`keydown`,e=>{if(e.repeat||Gt(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1;if(!t&&iU(e)&&!$t()&&vi()){e.preventDefault(),e.stopImmediatePropagation();return}let n=vr(e,Hl,{isTerminalFocused:t},Gl());n&&($t()||rU(n)&&e.preventDefault())})}function oU(){let e=m(v);window.addEventListener(`error`,t=>{e(t.error),u(`uncaught`,d(t.error??t.message))}),window.addEventListener(`unhandledrejection`,t=>{e(t.reason),u(`unhandled-rejection`,d(t.reason))}),tz(()=>window.sessionStorage)}wa(wr()),Ea(()=>{P(()=>import(`./alert-sound-Da6VQFBS.js`).then(e=>e.playNyanJingle(),e=>u(`alert-sound`,`nyan jingle failed to load: ${d(e)}`)),__vite__mapDeps([10,7]))}),ff(Jr()),So(),gu(document),fH(),TH(),CE(v),P(()=>import(`./your-day-tip-DGI6fbHA.js`).then(e=>e.startYourDayTips({openUsage:()=>vz(`usage`)}),e=>u(`your-day-tip`,`your day tips failed to load: ${d(e)}`)),__vite__mapDeps([65,13,5,3,19,63,12,4,6,7,61,8,64])),$g(v),zx(v),Wf(v),Ri(v),pn(bg),Sn(na),Sn(_g,`links`),Sn(dj,`links`),yn(pj),oj(yz),dn({isReadable:ra,open:aa}),gn(MS),mc(()=>Mz(`settings-updated`)),YH(),lV(),BB(),iB(),VB(),Zz(),$H(),aU(),Uj(),oU(),Hg(D(document,`#health-footer-mount`,`div`)),Vl(uS),cH(),nf(),f();var sU=xr();sU&&n().then(()=>xl(sU));export{DN as $,Bf as $i,SC as $n,R as $r,AC as $t,jI as A,Aa,Zp as Ai,zw as An,Px as Ar,IA as At,_I as B,$p as Bi,vC as Bn,eb as Br,EE as Bt,YI as C,as as Ca,Bm as Ci,cw as Cn,PS as Cr,FA as Ct,GI as D,ja as Da,xm as Di,MC as Dn,Ix as Dr,zA as Dt,UI as E,wo as Ea,Rm as Ei,jC as En,Rx as Er,XA as Et,PI as F,Pp as Fi,BC as Fn,fb as Fr,KA as Ft,gP as G,hp as Gi,aw as Gn,hy as Gr,_E as Gt,$F as H,Mp as Hi,MT as Hn,tb as Hr,TE as Ht,AI as I,Gp as Ii,zC as In,mb as Ir,CA as It,RN as J,ep as Ji,Mw as Jn,ty as Jr,Jw as Jt,FN as K,gp as Ki,RT as Kn,oy as Kr,gE as Kt,DI as L,Np as Li,CT as Ln,nb as Lr,bA as Lt,SI as M,zi as Ma,Xp as Mi,JT as Mn,Nx as Mr,ZA as Mt,CI as N,Ii as Na,Jp as Ni,PT as Nn,ox as Nr,GA as Nt,FI as O,Da as Oa,bm as Oi,UC as On,Lx as Or,RA as Ot,TI as P,Up as Pi,Ww as Pn,yb as Pr,ij as Pt,jN as Q,Rf as Qi,qT as Qn,Qg as Qr,pC as Qt,vI as R,Wp as Ri,ST as Rn,Zy as Rr,yA as Rt,JI as S,hc as Sa,_h as Si,jT as Sn,FS as Sr,_j as St,KI as T,Co as Ta,ch as Ti,Fw as Tn,Jx as Tr,qA as Tt,QF as U,Ap as Ui,zT as Un,by as Ur,wE as Ut,kI as V,kp as Vi,BT as Vn,cb as Vr,yE as Vt,eI as W,jp as Wi,sw as Wn,_y as Wr,vE as Wt,kN as X,Ff as Xi,TT as Xn,Zg as Xr,dw as Xt,MN as Y,zf as Yi,NT as Yn,i_ as Yr,wT as Yt,NN as Z,Pf as Zi,KT as Zn,e_ as Zr,kC as Zt,OL as _,Jl as _a,sh as _i,kT as _n,JS as _r,$j as _t,gz as a,Nf as aa,ng as ai,Gw as an,_C as ar,lN as at,sL as b,fc as ba,gh as bi,mw as bn,rC as br,gj as bt,CR as c,ff as ca,lg as ci,JC as cn,UT as cr,EM as ct,jL as d,mu as da,Ch as di,AT as dn,VT as dr,yM as dt,Af as ea,Jh as ei,YC as en,WT as er,AN as et,AL as f,ru as fa,wh as fi,Ew as fn,HT as fr,pM as ft,IL as g,Yl as ga,$m as gi,dC as gn,YS as gr,aM as gt,FL as h,Kl as ha,mh as hi,hC as hn,zS as hr,dM as ht,mz as i,Mf as ia,sg as ii,oC as in,gC as ir,fN as it,II as j,Li as ja,Hp as ji,Sw as jn,Mx as jr,ej as jt,yI as k,wa as ka,ym as ki,Nw as kn,Fx as kr,LA as kt,wR as l,Hd as la,qh as li,qC as ln,DT as lr,SM as lt,PL as m,Hl as ma,nh as mi,bC as mn,EC as mr,uM as mt,lB as n,Uf as na,eg as ni,Ow as nn,Zw as nr,ZM as nt,BR as o,If as oa,Qh as oi,tT as on,$w as or,DM as ot,kL as p,Ql as pa,fh as pi,eT as pn,Xw as pr,gM as pt,PN as q,$f as qi,Aw as qn,sy as qr,jE as qt,pz as r,Vf as ra,Yh as ri,aC as rn,OT as rr,QM as rt,zR as s,jf as sa,ig as si,DC as sn,Qw as sr,OM as st,cB as t,Hf as ta,$h as ti,kw as tn,pT as tr,IN as tt,zL as u,$u as ua,rg as ui,KC as un,Pw as ur,bM as ut,cL as v,ql as va,lh as vi,RC as vn,GS as vr,Qj as vt,qI as w,Fo as wa,eh as wi,Lw as wn,DS as wr,WA as wt,oL as x,mc as xa,ph as xi,pw as xn,LS as xr,mj as xt,aL as y,Gl as ya,th as yi,PC as yn,WS as yr,Kj as yt,bI as z,Op as zi,fT as zn,Yy as zr,SE as zt};
|