glimmervoid 0.52.2-next.728 → 0.52.2
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 +16 -16
- package/dist/chunks/{adapters-Co1vMNfP.js → adapters-Bs6qlGty.js} +1 -1
- package/dist/chunks/{adapters-E2pke5ID.js → adapters-CKKGMClb.js} +7 -7
- package/dist/chunks/{agent-api-cli-OeDlv0E8.js → agent-api-cli-C7ZovzLq.js} +3 -3
- package/dist/chunks/agent-api-cli-_OEb76Qx.js +1 -0
- package/dist/chunks/{agent-api-core-Cdmq2Whf.js → agent-api-core-CnEak_b4.js} +3 -3
- package/dist/chunks/{agent-setup-cli-mWP1iRw5.js → agent-setup-cli-CbLOoe_E.js} +1 -1
- package/dist/chunks/{config-Blcskz0X.js → config-R2MbY4J9.js} +2 -2
- package/dist/chunks/config-store-C2cOcCN_.js +1 -0
- package/dist/chunks/{config-store-D0dL0RdA.js → config-store-Cy6V7Mxw.js} +6 -5
- package/dist/chunks/{control-messages-B2N9tvWM.js → control-messages-BWxeCAv3.js} +3 -2
- package/dist/chunks/{grok-DyzNBiS8.js → grok-IEmzTYtq.js} +1 -1
- package/dist/chunks/{kimi-BkRxECxq.js → kimi-BtzO0Axk.js} +2 -2
- package/dist/chunks/kimi-CfP0q6Ma.js +1 -0
- package/dist/chunks/{main-DO8JAU_h.js → main-9iCwfTGw.js} +54 -16
- package/dist/chunks/{pack-agent-Cc974wg9.js → pack-agent-opmQ_npt.js} +4 -4
- package/dist/chunks/{pack-bridge-0mgiD3j4.js → pack-bridge-BZS1dggT.js} +1 -1
- package/dist/chunks/{pack-files-DSmmobPa.js → pack-files-CIhq5W2a.js} +3 -3
- package/dist/chunks/{packs-cli-DM0DAkEk.js → packs-cli-C5N1xXCp.js} +5 -5
- package/dist/chunks/{pair-cli-CWot54Ep.js → pair-cli-vKiOsQSN.js} +2 -2
- package/dist/chunks/{pr-flows-cli-Xw7HEaZm.js → pr-flows-cli-D42AXqB0.js} +5 -5
- package/dist/chunks/{pr-flows-external-mOPFsyFC.js → pr-flows-external-BFi7dW3U.js} +3 -3
- package/dist/chunks/{remote-config-D8D0aL8f.js → remote-config-BCkDqH9b.js} +1 -1
- package/dist/chunks/{session-BbdhZ6qO.js → session-DmS8GGwK.js} +1 -0
- package/dist/chunks/{settings-cli-BliqPh5j.js → settings-cli-onCe461z.js} +5 -5
- package/dist/chunks/{settings-readout-core-DfyiCIXt.js → settings-readout-core-Dj8ckj2I.js} +2 -2
- package/dist/chunks/{spawn-env-CX9P7nKQ.js → spawn-env-BDrKa7hy.js} +1 -1
- package/dist/chunks/{ssh-sign-cli-xOkNeF2q.js → ssh-sign-cli-GZ92YUP3.js} +2 -2
- package/dist/chunks/{whiteboard-svg-core-DYDXouiI.js → whiteboard-svg-core-Bbcg7VIG.js} +1 -1
- package/dist/client/assets/{action-status-BmENjDEU.js → action-status-ChqLWNwE.js} +1 -1
- package/dist/client/assets/action-status-ChqLWNwE.js.br +0 -0
- package/dist/client/assets/{arena-panel-BysN3T5_.js → arena-panel-DbKIlSCb.js} +2 -2
- package/dist/client/assets/arena-panel-DbKIlSCb.js.br +0 -0
- package/dist/client/assets/{benchmark-panel-9N3wd4Km.js → benchmark-panel-DsVK240W.js} +1 -1
- package/dist/client/assets/benchmark-panel-DsVK240W.js.br +0 -0
- package/dist/client/assets/{boards-view-CV4wmZLl.js → boards-view-Dib7ZZVH.js} +1 -1
- package/dist/client/assets/boards-view-Dib7ZZVH.js.br +0 -0
- package/dist/client/assets/button-gPjGDYEC.js +1 -0
- package/dist/client/assets/button-gPjGDYEC.js.br +0 -0
- package/dist/client/assets/{card-actions-Dl7d8jSN.js → card-actions-DoLdHG81.js} +1 -1
- package/dist/client/assets/{card-registry-B2wcHmdo.js → card-registry-DooQcht6.js} +1 -1
- package/dist/client/assets/card-registry-DooQcht6.js.br +0 -0
- package/dist/client/assets/{community-panel-BGBC6NFJ.js → community-panel-BiOV5-sV.js} +1 -1
- package/dist/client/assets/community-panel-BiOV5-sV.js.br +0 -0
- package/dist/client/assets/{control-ws-BpJvBDOa.js → control-ws-CCnwczmH.js} +1 -1
- package/dist/client/assets/control-ws-CCnwczmH.js.br +0 -0
- package/dist/client/assets/{dialogs-BD-V1Bk4.js → dialogs-Glf5Smuh.js} +1 -1
- package/dist/client/assets/dialogs-Glf5Smuh.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-rP-g8eGO.js → doc-editor-ui-DmSq6oxC.js} +1 -1
- package/dist/client/assets/doc-editor-ui-DmSq6oxC.js.br +0 -0
- package/dist/client/assets/{feature-hint-C53CYgsG.js → feature-hint-DnrqJolm.js} +1 -1
- package/dist/client/assets/feature-hint-DnrqJolm.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-Ct-fQ9SZ.js → first-run-checklist-2LJwKdE8.js} +1 -1
- package/dist/client/assets/first-run-checklist-2LJwKdE8.js.br +0 -0
- package/dist/client/assets/{hooks-panel-B1MBTFrw.js → hooks-panel-D-3mY4mZ.js} +1 -1
- package/dist/client/assets/hooks-panel-D-3mY4mZ.js.br +0 -0
- package/dist/client/assets/{index-DlRitmGM.js → index-DwjJfCx_.js} +5 -5
- package/dist/client/assets/index-DwjJfCx_.js.br +0 -0
- package/dist/client/assets/{issues-panel-DKsEpAx-.js → issues-panel-cmaZg8pa.js} +1 -1
- package/dist/client/assets/issues-panel-cmaZg8pa.js.br +0 -0
- package/dist/client/assets/{lane-read-token-step-CdBczXZa.js → lane-read-token-step-D99lZR3U.js} +4 -4
- package/dist/client/assets/lane-read-token-step-D99lZR3U.js.br +0 -0
- package/dist/client/assets/{menu-DxXzJF1c.js → menu-70wrT0oQ.js} +1 -1
- package/dist/client/assets/menu-70wrT0oQ.js.br +0 -0
- package/dist/client/assets/{modal-M7jE7EEY.js → modal-BzU16bX3.js} +1 -1
- package/dist/client/assets/modal-BzU16bX3.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-BkX951JG.js → my-prs-panel-CyAEX_SQ.js} +1 -1
- package/dist/client/assets/my-prs-panel-CyAEX_SQ.js.br +0 -0
- package/dist/client/assets/{nyan-cat-BUzAN_bt.js → nyan-cat-DQg7Jylj.js} +1 -1
- package/dist/client/assets/nyan-cat-DQg7Jylj.js.br +0 -0
- package/dist/client/assets/{phone-shell-D522Pzmm.js → phone-shell-BGIx4-6z.js} +1 -1
- package/dist/client/assets/phone-shell-BGIx4-6z.js.br +0 -0
- package/dist/client/assets/{plan-face-oyJASo0C.js → plan-face-DjGyIJPj.js} +1 -1
- package/dist/client/assets/plan-face-DjGyIJPj.js.br +0 -0
- package/dist/client/assets/{plan-render-CDDFaPPS.js → plan-render-Dw6NRG4-.js} +1 -1
- package/dist/client/assets/plan-render-Dw6NRG4-.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-BxKxvW8p.js → pr-queue-columns-a3LtXpny.js} +1 -1
- package/dist/client/assets/pr-queue-columns-a3LtXpny.js.br +0 -0
- package/dist/client/assets/{pr-status-icon-1uf6dcZb.js → pr-status-icon-CV0_Wkzx.js} +1 -1
- package/dist/client/assets/pr-status-icon-CV0_Wkzx.js.br +0 -0
- package/dist/client/assets/{radar-panel-2TxF0hbk.js → radar-panel-9SuG7CHS.js} +1 -1
- package/dist/client/assets/radar-panel-9SuG7CHS.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-C7NNtWv6.js → repo-roots-adder-BhBDc31V.js} +1 -1
- package/dist/client/assets/repo-roots-adder-BhBDc31V.js.br +0 -0
- package/dist/client/assets/{resume-dialog-B-yl3qdF.js → resume-dialog-j14Lv2au.js} +1 -1
- package/dist/client/assets/resume-dialog-j14Lv2au.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-CyOulPXz.js → review-queue-panel-8u_I7_Hn.js} +1 -1
- package/dist/client/assets/review-queue-panel-8u_I7_Hn.js.br +0 -0
- package/dist/client/assets/{session-actions-DpaQVIp-.js → session-actions-Cc3TXNNI.js} +2 -2
- package/dist/client/assets/session-actions-Cc3TXNNI.js.br +0 -0
- package/dist/client/assets/{session-row-CmktIW3Z.js → session-row-V7L-vvPv.js} +1 -1
- package/dist/client/assets/session-row-V7L-vvPv.js.br +0 -0
- package/dist/client/assets/{session-tick-D4e4VC8-.js → session-tick-BgbD-Hwq.js} +1 -1
- package/dist/client/assets/session-tick-BgbD-Hwq.js.br +0 -0
- package/dist/client/assets/{settings-panel-Dk9IgiNx.js → settings-panel-Djq38v9c.js} +2 -2
- package/dist/client/assets/settings-panel-Djq38v9c.js.br +0 -0
- package/dist/client/assets/{setup-step-D1KD1z1S.js → setup-step-U8tZBuCu.js} +1 -1
- package/dist/client/assets/setup-step-U8tZBuCu.js.br +0 -0
- package/dist/client/assets/{trace-panel-BA5q4ttn.js → trace-panel-B1xwTFQF.js} +1 -1
- package/dist/client/assets/trace-panel-B1xwTFQF.js.br +0 -0
- package/dist/client/assets/{usage-panel-j6iTPjbO.js → usage-panel-DFauLty3.js} +1 -1
- package/dist/client/assets/usage-panel-DFauLty3.js.br +0 -0
- package/dist/client/assets/{your-day-tip-z4FxKfuQ.js → your-day-tip-126RabsR.js} +1 -1
- package/dist/client/assets/your-day-tip-126RabsR.js.br +0 -0
- package/dist/client/index.html +12 -12
- package/dist/client/index.html.br +0 -0
- package/dist/server/index.js +1 -1
- package/package.json +4 -1
- package/dist/chunks/agent-api-cli-8joosEV5.js +0 -1
- package/dist/chunks/config-store-crG-vluw.js +0 -1
- package/dist/chunks/kimi-DofPcrvH.js +0 -1
- package/dist/client/assets/action-status-BmENjDEU.js.br +0 -0
- package/dist/client/assets/arena-panel-BysN3T5_.js.br +0 -0
- package/dist/client/assets/benchmark-panel-9N3wd4Km.js.br +0 -0
- package/dist/client/assets/boards-view-CV4wmZLl.js.br +0 -0
- package/dist/client/assets/button-CvVQMDpG.js +0 -1
- package/dist/client/assets/button-CvVQMDpG.js.br +0 -0
- package/dist/client/assets/card-registry-B2wcHmdo.js.br +0 -0
- package/dist/client/assets/community-panel-BGBC6NFJ.js.br +0 -0
- package/dist/client/assets/control-ws-BpJvBDOa.js.br +0 -0
- package/dist/client/assets/dialogs-BD-V1Bk4.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-rP-g8eGO.js.br +0 -0
- package/dist/client/assets/feature-hint-C53CYgsG.js.br +0 -0
- package/dist/client/assets/first-run-checklist-Ct-fQ9SZ.js.br +0 -0
- package/dist/client/assets/hooks-panel-B1MBTFrw.js.br +0 -0
- package/dist/client/assets/index-DlRitmGM.js.br +0 -0
- package/dist/client/assets/issues-panel-DKsEpAx-.js.br +0 -0
- package/dist/client/assets/lane-read-token-step-CdBczXZa.js.br +0 -0
- package/dist/client/assets/menu-DxXzJF1c.js.br +0 -0
- package/dist/client/assets/modal-M7jE7EEY.js.br +0 -0
- package/dist/client/assets/my-prs-panel-BkX951JG.js.br +0 -0
- package/dist/client/assets/nyan-cat-BUzAN_bt.js.br +0 -0
- package/dist/client/assets/phone-shell-D522Pzmm.js.br +0 -0
- package/dist/client/assets/plan-face-oyJASo0C.js.br +0 -0
- package/dist/client/assets/plan-render-CDDFaPPS.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-BxKxvW8p.js.br +0 -0
- package/dist/client/assets/pr-status-icon-1uf6dcZb.js.br +0 -0
- package/dist/client/assets/radar-panel-2TxF0hbk.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-C7NNtWv6.js.br +0 -0
- package/dist/client/assets/resume-dialog-B-yl3qdF.js.br +0 -0
- package/dist/client/assets/review-queue-panel-CyOulPXz.js.br +0 -0
- package/dist/client/assets/session-actions-DpaQVIp-.js.br +0 -0
- package/dist/client/assets/session-row-CmktIW3Z.js.br +0 -0
- package/dist/client/assets/session-tick-D4e4VC8-.js.br +0 -0
- package/dist/client/assets/settings-panel-Dk9IgiNx.js.br +0 -0
- package/dist/client/assets/setup-step-D1KD1z1S.js.br +0 -0
- package/dist/client/assets/trace-panel-BA5q4ttn.js.br +0 -0
- package/dist/client/assets/usage-panel-j6iTPjbO.js.br +0 -0
- package/dist/client/assets/your-day-tip-z4FxKfuQ.js.br +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-BpJvBDOa.js";import{c as b,d as x,g as ne,n as re,o as ie,u as ae}from"./zod-_N0uRWDY.js";import{$t as oe,A as se,Bn as ce,Bt as le,C as ue,Cn as de,Ct as fe,D as pe,Dt as S,E as me,Et as he,Ft as ge,G as _e,Gn as ve,Hn as ye,It as be,J as xe,Jt as Se,K as Ce,Kn as we,Ln as Te,Lt as Ee,M as De,Mt as Oe,Nn as ke,Nt as Ae,O as C,Ot as je,Pn as Me,Pt as Ne,Qt as Pe,R as Fe,Rn as Ie,S as Le,St as Re,T as ze,Tt as Be,U as Ve,Un as He,V as Ue,Vn as We,Wn as Ge,Yt as Ke,Z as qe,_ as Je,_n as Ye,_t as Xe,a as Ze,an as Qe,b as $e,bt as et,c as tt,dn as nt,en as rt,f as it,g as at,h as ot,hn as st,i as ct,in as lt,j as ut,jt as dt,kn as ft,kt as pt,l as mt,p as ht,q as gt,qn as _t,qt as vt,rn as yt,s as bt,st as xt,t as w,tn as St,u as Ct,ut as wt,vn as Tt,vt as Et,wn as Dt,wt as Ot,x as kt,xn as At,y as jt,yn as Mt,zn as Nt,zt as Pt}from"./button-CvVQMDpG.js";import{J as Ft,K as It,X as T,Y as Lt,_ as Rt,b as zt,f as Bt,g as E,h as Vt,n as Ht,p as Ut,q as Wt,s as D,t as Gt,u as Kt,x as qt}from"./dom-helpers-Bs-xZEnd.js";import{a as Jt,i as Yt,n as Xt,r as Zt,t as Qt}from"./modal-M7jE7EEY.js";import{C as $t,S as en,_ as tn,a as nn,b as rn,c as an,d as on,f as sn,g as cn,h as ln,i as un,l as dn,m as fn,n as pn,o as mn,p as hn,r as gn,s as _n,t as vn,u as yn,v as bn,x as xn,y as Sn}from"./session-row-CmktIW3Z.js";import{S as Cn,_ as wn,a as Tn,b as En,c as Dn,f as On,g as kn,h as An,i as O,m as jn,n as Mn,o as k,r as A,s as Nn,t as j,u as Pn,x as Fn,y as In}from"./card-registry-B2wcHmdo.js";import{n as M,t as Ln}from"./ui-state-core-Nssh-6QJ.js";import{t as N}from"./preload-helper-BLdHbfdN.js";import{i as Rn,n as zn,o as Bn,r as Vn,s as Hn,t as Un,u as Wn}from"./action-status-BmENjDEU.js";import{a as Gn,c as Kn,i as qn,n as Jn,o as Yn,r as Xn,s as Zn,t as Qn}from"./session-tick-D4e4VC8-.js";import{n as $n,t as er}from"./local-store-CVQ5ByvB.js";import{$ as tr,A as nr,C as rr,D as ir,J as ar,K as or,O as sr,S as cr,T as lr,W as ur,X as dr,Y as fr,Z as pr,_t as mr,at as hr,b as gr,c as _r,ct as vr,f as yr,g as br,h as xr,ht as Sr,i as Cr,it as wr,k as Tr,l as Er,m as Dr,mt as Or,n as kr,nt as Ar,ot as jr,p as Mr,q as Nr,r as Pr,rt as Fr,s as Ir,st as Lr,t as Rr,u as zr,v as Br,w as Vr,x as Hr,xt as Ur,y as Wr,yt as Gr,z as Kr}from"./ui-prefs-Dyka19fU.js";import{t as qr}from"./http-url-B85DM2Ri.js";import{C as Jr,D as Yr,E as Xr,I as Zr,O as Qr,S as $r,T as ei,_ as ti,a as ni,b as ri,c as ii,d as ai,f as oi,g as si,h as ci,i as li,k as ui,l as di,m as fi,o as pi,u as mi,v as hi,w as gi,x as _i,y as vi}from"./session-actions-DpaQVIp-.js";import{n as yi}from"./card-actions-Dl7d8jSN.js";import{n as bi,t as xi}from"./roving-keys-core-BDobx2It.js";import{n as Si}from"./menu-DxXzJF1c.js";import{t as Ci}from"./pr-status-icon-1uf6dcZb.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 wi={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},Ti=null,Ei=null,Di=!0,Oi=new Map,ki=new Map,Ai=new Set;function ji(){for(let e of Ai)e()}function Mi(e){Ai.add(e)}function Ni(){return{status:Ti,isServerConnected:Di,pendingActionBySuite:Oi,outcomeBySuite:ki}}function Pi(e){Ei=e}function Fi(e,t){Ei?.({type:`benchmark-action`,requestId:h(`benchmark`),suiteId:e,action:t})===!0?(Oi.set(e,t),ki.set(e,wi[t]),ji()):(ki.set(e,De),ji())}function Ii(e){if(Di=e,!e){for(let e of Oi.keys())ki.delete(e);Oi.clear()}ji()}function Li(e){Ti=e,ji()}function Ri(e){Oi.delete(e.suiteId);let t=Ti?.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.`};ki.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),ji()}function zi({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=Zt({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=D(`div`,`coherence-journal-header`),s=D(`h3`,`dialog-title`,t);s.id=n;let c=w({variant:`secondary`,label:`Close`,action:`close-coherence-panel`,onClick:i});return o.append(s,c),a.dialog.append(o,...r),Qt(a.dialog,s.id),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function Bi({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=zi({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 Vi={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 Hi(e){return e?.active!==!1||e.reason===nt.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,detailText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:en.broken}]}function Ui(e){let t=Pe.safeParse(e.kind);return{heading:`${t.success?Vi[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function Wi(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 Gi=new Map,Ki=new Map,qi=Bi({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function Ji(e,t){Ki.delete(e),t&&Ki.set(e,t),ea(e)}function Yi(e){Gi.delete(e),Ki.delete(e);let t=qi.currentPanel();t?.sessionId===e&&t.close()}function Xi(e){let t=Gi.get(e.id);t&&t.updatedAt>e.updatedAt||(Gi.set(e.id,e),ea(e.id))}function Zi(e){Gi.clear();for(let[t,n]of Object.entries(e.sessions))Gi.set(t,n);let t=qi.currentPanel();t&&ea(t.sessionId)}function Qi(e){return Hi(Ki.get(e)??null).map(t=>({...t,onActivate:()=>ta(e)}))}function $i(e){return Gi.get(e)?.journal.ok===!0}function ea(e){let t=qi.currentPanel();if(!t||t.sessionId!==e)return;let n=Wi(Ki.get(e)??null,Gi.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>D(`p`,null,e)))}function ta(e){let t=D(`div`,`coherence-journal-reading`),n=D(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=D(`div`,`coherence-journal-entries`);qi.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>ea(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function na(e){let t=qi.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=Ui(e),n=D(`article`,`coherence-journal-entry`);return n.append(D(`h4`,null,t.heading),D(`p`,null,t.text)),t.detail&&n.append(D(`p`,null,t.detail)),t.supersedes&&n.append(D(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var ra=new Set([`waiting`,`monitoring`]);function ia(e){return Object.fromEntries(Pt.flatMap(t=>{let n=ra.has(t)?8:6;return[[`--state-${t}`,e[t]],[`--state-${t}-bg`,`color-mix(in oklab, var(--state-${t}) ${n}%, transparent)`]]}))}function aa(e){return{...Object.fromEntries(Object.entries(e.chrome).map(([e,t])=>[`--${e}`,t])),...ia(e.states)}}var oa={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`}},sa={dark:{black:`--border`,brightBlack:`--text-muted`,white:`--text`,brightWhite:`--text-head`},light:{black:`--text-head`,brightBlack:`--text-dim`,white:`--text-dim`,brightWhite:`--text`}},ca=.35;function la(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 ua(e){if(e.accentAnsiSlot===`none`)return{};let t=`bright${e.accentAnsiSlot[0].toUpperCase()}${e.accentAnsiSlot.slice(1)}`;return{[e.accentAnsiSlot]:`--accent`,[t]:la(e.chrome.accent,ca)}}function da(e){return{label:e.label,colors:aa(e),terminal:{background:`--bg-card`,foreground:`--text`,cursor:`--accent`,cursorAccent:`--bg-card`,...sa[e.mode],...oa[e.mode],...ua(e)}}}var fa={golgari:da({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:da({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:da({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:da({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:da({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":da({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":da({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`}})},pa=`phyrexian`,ma=null,ha=null,ga=null,_a={};function va(e){return Object.hasOwn(fa,e)?fa[e]:_a[e]}function ya(e){_a=Object.fromEntries(e.map(({id:e,palette:t})=>[e,da(t)]));let t=ga??pa,n=va(t)?t:pa;return n===ha&&!Object.hasOwn(_a,n)?!1:(xa(n),!0)}function ba(e){ga=e,va(e)&&xa(e)}function xa(e){let t=va(e);if(!t)return;let n=ha;ha=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`&&ma?.()}function Sa(e){ma=e}function Ca(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function wa(){let e=va(ha||pa);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 Ta(){return{id:ha,colors:{...va(ha??pa)?.colors}}}function Ea(){return Object.entries({...fa,..._a}).map(([e,t])=>({id:e,label:t.label}))}function Da(){let e=wa();e.background&&e.foreground&&v({type:`terminal-colors`,background:e.background,foreground:e.foreground})}var Oa=3e4,ka=24,Aa=null,ja=[`Android`,`iPhone`,`iPad`,`Windows`,`Mac OS X`,`Linux`],Ma=[/Firefox\/\d+/,/Edg\/\d+/,/Chrome\/\d+/,/Version\/\d+/];function Na(){let e=navigator.userAgent,t=ja.find(t=>e.includes(t))??`unknown platform`;return`${Ma.map(t=>t.exec(e)?.[0]).find(e=>e!==void 0)?.replace(`Version`,`Safari`)??`unknown browser`} on ${t}`}function Pa(){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 Fa(){return[navigator.onLine?`online`:`offline`,...Pa()].join(` `)}function Ia(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 La(e,t){let n=e.join(` `);if(n.length<=t)return n;let r=t-ka,i=Ia(e,r/2),a=Ia(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 Ra(e){return e.marks.some(e=>e.startsWith(`terminal-bytes`))}function za(e){let t=Ra(e)&&!e.isCapped?`terminal live`:`terminal not live after ${Oa/1e3} s`,n=`hidden ${Math.round(e.hiddenForMs/1e3)} s, ${t}, ${Na()}, ${e.networkAtWake}: `,r=n+La(e.marks,yt-n.length);return v({type:`client-log`,scope:`wake`,text:r.slice(0,yt)})}function Ba(){let e=Aa;e&&(e.isCapped||Ra(e))&&za(e)&&(Aa=null,clearTimeout(e.capTimer))}function Va(){Aa&&(Aa.isCapped=!0,Ba())}function Ha(e,t){e.marks.push(`${t}+${Math.round(performance.now()-e.startedAtMs)}`)}function Ua(e){Aa&&(e===`terminal-bytes`&&Ra(Aa)||(Ha(Aa,e),(e===`terminal-bytes`||e===`control-opened`)&&Ba()))}function Wa(e){Aa&&Ha(Aa,e===`link`?[`link`,...Pa()].join(`-`):e)}function Ga(e,t){Aa||={startedAtMs:performance.now(),hiddenForMs:t,networkAtWake:Fa(),marks:[],isCapped:!1,capTimer:setTimeout(Va,Oa)},Ua(e)}function Ka(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function qa(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 Ja=null,Ya=null;function Xa(){return Ja}function Za(){return Ja?Promise.resolve(Ja):(Ya??=Promise.all([N(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.t),__vite__mapDeps([0,1])),N(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.r),__vite__mapDeps([0,1])),N(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.n),__vite__mapDeps([0,1]))]).then(([e,t,n])=>(Ja={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},Ja)).catch(e=>{throw Ya=null,e}),Ya)}var Qa=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,$a=new Map;function eo(e){return e.clientWidth>0&&e.clientHeight>0}function to(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 no(e){$a.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,to(e)}function ro(e){let t=[e],n=M.snapshot().borrowedCardId,r=n?k.get(n):void 0;r&&t.push(r);for(let e of qa([...$a.keys()],Qa,t))no(e),e.needsWebGLReload=!0}function io(e){e?.term&&Ka({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:eo(e.termWrap)})&&lo(e,{isForced:!0})}function ao(){for(let e of $a.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{no(e),e.needsWebGLReload=!0}}}var oo=!1;function so(){oo||(oo=!0,requestAnimationFrame(()=>{oo=!1,ao()}))}function co(e){e?.addEventListener(`contextrestored`,so)}function lo(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){$a.delete(e),$a.set(e,!0);return}e.webglAddon&&(to(e),$a.delete(e));let n=Xa();if(!n)return;ro(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,$a.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(co),r.onAddTextureAtlasCanvas(co),co(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!eo(e.termWrap),$a.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,$a.delete(e)}}var uo=`(max-width: 768px)`,fo=`(pointer: coarse)`;function po({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var mo=window.matchMedia?.(fo),ho=window.matchMedia?.(uo);function go(){return po({coarse:!!mo?.matches,narrowWidth:!!ho?.matches})}function _o(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function vo(){M.subscribe((e,t)=>{t.includes(`layout`)&&_o(e.layout)});let e=go();_o(e),M.dispatch(`setLayout`,e);let t=()=>M.dispatch(`setLayout`,go());return mo?.addEventListener?.(`change`,t),ho?.addEventListener?.(`change`,t),e}function yo(){return M.snapshot().layout===`phone`}function bo(e){return M.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var xo=``,So=`\x1B`,Co=`\r`,wo=new Map([[`deleteContentBackward`,xo],[`deleteByComposition`,xo],[`deleteCompositionText`,xo],[`deleteWordBackward`,So],[`deleteSoftLineBackward`,So],[`deleteHardLineBackward`,So]]);function To(e){return wo.get(e)??``}var Eo=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function Do(e){return typeof e!=`string`||e===``||!Eo.has(e)}function Oo(e){return e?e.keyCode===229||e.key===`Process`:!1}function ko(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 xo.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,Co)}var Ao=`Upload`;async function jo(e,t){return zn(Ao,e),No(e,t)}async function Mo(e,t){zn(Ao,e);for(let n of t)await No(e,n)}async function No(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:(Bn({source:Ao,sessionId:e,message:await Po(r,t.name)}),!1)}catch{return Bn({source:Ao,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 Po(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 Fo=new WeakMap,Io=5e3,Lo=15e3,Ro=`The agent copied text. The browser needs a click before it can reach your clipboard.`,zo=`The clipboard is unavailable in this browser.`;function Bo(e,t,n,r){let i=Fo.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(()=>Vo(e,t),n===`ok`?Io:Lo)))}function Vo(e,t){let n=Fo.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function Ho(e){let t=e.buffer.active;return t.viewportY<t.baseY}function Uo(e,t,{hasNewOutput:n=!1}={}){let r=Fo.get(e)?.jumpToLatest;if(!r)return;let i=Ho(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function Wo(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 Go(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),Bo(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function Ko(e,t,n,r){let i=zt(t);i?i.then(()=>{r&&Bo(e,`clipboard`,`ok`,r)}).catch(t=>Go(e,n,t)):Bo(e,`clipboard`,`error`,zo)}function qo(e,t){let n=Fo.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function Jo(e){let t=Fo.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,Ko(e,n,`osc52 write`,`Copied to the clipboard.`))}function Yo(e,t,n){let r=Rn(`terminal-notice`),i=D(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=w({variant:`primary`,label:`Copy to clipboard`,onClick:()=>Jo(t)});i.append(D(`span`,`terminal-clipboard-prompt-text`,Ro),a);let o=D(`div`,`terminal-notices`);o.append(i,r.element);let s=D(`div`,`terminal-jump-latest`);s.hidden=!0,s.append(w({variant:`secondary`,label:`Jump to latest`,onClick:()=>{n.scrollToBottom(),n.focus()}}),D(`span`,`terminal-jump-latest-new-output`));let c=D(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(D(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),Fo.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatest:s})}var Xo=1024,Zo=`Keys you type now are held and sent once the terminal reconnects.`,Qo=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,$o=!1;function es(e){let t=e._inputQueue,n=e.dataWs;if(!$o&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,Vo(e,`keys`)}}function ts(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!$o&&!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>=Xo?(Bo(e,`keys`,`error`,Qo),!1):(e._inputQueue.push(t),r&&Bo(e,`keys`,`busy`,Zo),!0)}function ns(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,yo()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=ko(i,r.value);return i=r.value,e!==``&&(ts(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{yo()?n(e):a()},!0)};c(`keydown`,e=>{Oo(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(!Do(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=To(e.inputType);r!==``&&(ts(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function rs(e){return!!e&&Array.from(e.types).includes(`Files`)}function is(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),Mo(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{rs(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,rs(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),Mo(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function as(e){$o=e}var os=6,ss=262144,cs=16384,ls=()=>{};function us(e,t){if(t.length<=cs)e.push(t);else for(let n=0;n<t.length;n+=cs)e.push(t.slice(n,n+cs))}function ds({budget:e=os,maxChunkBytes:t=ss,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)us(l,e),m+=e.length,a.readIdx++;else{m===0&&(us(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,ls);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 fs=ds(),ps=ae().int().min(1).max(500),ms=ae().int().min(1).max(200);ie(`type`,[x({type:b(`input`),data:ne()}),x({type:b(`claim`),cols:ps,rows:ms}),x({type:b(`unview`)}),x({type:b(`pause-output`)}),x({type:b(`resume-output`)})]);var hs=x({type:b(`pty-size`),cols:ps,rows:ms,seq:ae().int().nonnegative()}),gs=x({type:b(`output-beat`)}),_s=ie(`type`,[hs,gs]),vs=`history`,ys=`output`,bs=`paused`;re([`screen`,`deep`]);function xs(e){try{return JSON.parse(e)}catch{return null}}function Ss(e){let t=_s.safeParse(xs(e));return t.success?t.data:null}var Cs=new Set([1,5,25,100]);function ws(e){return e.isOutputPaused?`${e.history} paused`:e.history}function Ts(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function Es(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function Ds(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function Os({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&Ts(e,n))}function ks({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function As({isBorrowedCard:e,isTerminalFaceShown:t}){return!e||!t}function js({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function Ms(e,t,n){let r=new URLSearchParams;t&&r.set(vs,`deep`),n&&r.set(ys,bs);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function Ns({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:Os({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function Ps({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function Fs({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!Ts(e,t),s=Es(n)?Ds(n):null,c=r&&!!s&&!Ts(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:Os({authoritative:e,isActiveViewer:r,lastClaim:a})}}function Is(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function Ls(e){let t=Is(e);return t===null?null:Ss(t)}function Rs(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=Ls(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 zs=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,Bs=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,P=`[^\\S\\r\\n]`,Vs=`${zs}${P}*(?:=>|[:=])${P}*`,Hs=`[?&][A-Za-z0-9_.-]*`,Us=`[^\\r\\n;&|]{0,200}?`,Ws=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,Gs=RegExp(`(${Vs})${Bs}`,`gi`),Ks=RegExp(`(\\bBearer${P}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),qs=[/\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],Js=[RegExp(`((?:^|\\s)--?${zs}${P}+)${Bs}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${P}*=?${P}*)${Bs}`,`g`),RegExp(`(-AsPlainText${P}+)${Bs}`,`gi`),RegExp(`((?:^|\\s)setx${P}+[^\\s\\r\\n]*${zs}[^\\s\\r\\n]*${P}+)${Bs}`,`gi`)],Ys=[RegExp(`(\\bauthorization${P}*:${P}*Basic${P}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${P}+login\\b${Us}${P}-p(?:${P}+|=))${Bs}`,`gi`),RegExp(`(\\bcurl\\b${Us}${P}(?:--user|-u)(?:${P}+|=)[^\\s:\\r\\n]+:)${Bs}`,`gi`),RegExp(`(\\b${Ws}\\b${Us}${P}-p)${Bs}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi],Xs=[/-----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],Zs=RegExp(`(${Hs}(?:${zs}|_key)=)[^&#\\s]+`,`gi`),Qs=[Gs,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${Bs}`,`g`)],$s=[Ks,...Js,...Ys,...qs,...Xs];function ec(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function tc(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 nc(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 rc(e){let t=ec(e,Zs);return nc([...t,...Qs.flatMap(n=>tc(ec(e,n),t)),...$s.flatMap(t=>ec(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var ic=`glimmervoid-streamer-mode`,ac=new Set,oc=er(ic,!1)===!0;function sc(e){document.documentElement.toggleAttribute(`data-streamer`,e)}sc(oc);function cc(){return oc}function lc(e){if($n(ic,e),e!==cc()){oc=e,sc(e);for(let t of ac)t(e)}}function uc(e){return ac.add(e),()=>ac.delete(e)}async function dc(e){try{let t=await a(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:Un});return t.type===`settings-error`?String(t.message):(lc(e),``)}catch(e){return Hn(e,Un)}}var fc=`Streamer mode`;async function pc(){let e=!cc();e&&lc(!0);let t=await dc(e);t?Bn({source:fc,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}):zn(fc)}function mc(){pc()}var hc=`#808080`,gc=new WeakMap;function _c(e,t,n){return`${e}:${t}:${n}`}function vc(e){return _c(e.marker.line,e.x,e.width)}function yc(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function bc(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function xc(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function Sc(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 Cc(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 wc(e,t,n,r){let i=[];if(rc(xc(e,t,n)).length===0)return i;let{text:a,cellAt:o}=Sc(e,t,n,r);for(let e of rc(a))Cc(i,o.slice(e.start,e.end));return i}function Tc(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=bc(e,i);r.push(...wc(e,i,t,n)),i=t+1}return r}function Ec(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function Dc(e){e.decoration.dispose(),e.marker.dispose()}function Oc(e){for(let t of e.masks)Dc(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function kc(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function Ac(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 jc(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(vc(r),r),r=e.masks.at(-1);return Ac(e),n}function Mc(e,t){let n={normal:Ec(),alternate:Ec()},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??hc,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(!cc())return;let t=e.buffer.active,r=n[t.type],i=yc(t,kc(r,t)),a=jc(r,i);for(let e of Tc(t,i)){let n=_c(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())Dc(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){Oc(n.normal),Oc(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=>{Oc(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=uc(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),gc.delete(e)},{once:!0}),gc.set(e,d)}function Nc(e){gc.get(e)?.()}function Pc({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var Fc=`-4 -4 108 108`,Ic=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`}]),Lc=`M50 39L61 50L50 61L39 50Z`,Rc=11,zc=`#e8e0ff`,Bc=`#c084fc`;function Vc({frame:e,light:t,strokeWidth:n=Rc}){return`<path d="${Ic.map(({d:e})=>e).join(``)}" fill="none" stroke="${e}" stroke-width="${n}" stroke-linejoin="miter" stroke-linecap="butt"/><path d="${Lc}" fill="${t}"/>`}function Hc(e,t){return As({isBorrowedCard:M.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var Uc=new WeakMap,Wc=new WeakMap,Gc=new WeakSet,Kc=new WeakSet,qc=new WeakSet;function Jc(e,t){if(Uc.has(e)||!Ho(t))return;let n=t.buffer.active,r=n.length-n.viewportY;Gc.has(e)?Uc.set(e,r):Wc.set(e,r)}function Yc(e,t,n){let r=e.term;r&&js({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:Gc.has(e)})&&(Gc.add(e),Kc.add(e),Uc.set(e,r.buffer.active.length-n),Cl(t))}var Xc=new WeakMap;function Zc(e,t){return document.visibilityState===`visible`&&!Hc(e,t)}function Qc(e,t){if(e&&pl(e,t))return;let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=Zc(e,t);Xc.get(n)!==r&&(Xc.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function $c(){for(let[e,t]of k)Qc(t,e)}document.addEventListener(`visibilitychange`,$c),M.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&$c()});function el(e,t){return k.get(e)===t&&!t.dataWs}function tl(e){return e.querySelector(`:scope > .terminal-connecting`)}function nl(){let e=se(`svg`,{class:`loading-mark`,viewBox:Fc,"aria-hidden":`true`});for(let{side:t,d:n}of Ic)e.append(se(`path`,{class:`loading-mark-bracket`,"data-side":t,d:n}));return e}function rl(e){if(tl(e))return;let t=D(`div`,`terminal-connecting`);t.append(nl(),D(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}var il=new Set,al=new WeakSet;function ol(e){return il.add(e),()=>il.delete(e)}function sl(){let e=0;for(let[t,n]of k)n.card.dataset.link===`connecting`&&Zc(n,t)&&e++;return e}function cl(e){let t=Pc({hasTerminal:e.term!==null||al.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:$o}),n=t===`connecting`&&!$o&&Kc.has(e)?`live`:t;n===`none`?(delete e.card.dataset.link,ll()):(e.card.dataset.link=n,ll())}function ll(){for(let e of il)e()}function ul(e,t,n){Jc(t,n),fs.unregister(e),t.dataWs=null,cl(t),t._resetGridClaim?.()}var dl=new WeakMap;function fl(e,t,r,i){ul(e,t,r),clearTimeout(dl.get(t)),dl.delete(t),i===0&&y()?Sl(e,t,r):dl.set(t,setTimeout(()=>{dl.delete(t),el(e,t)&&n().catch(()=>{}).then(()=>{el(e,t)&&Sl(e,t,r)})},i))}function pl(e,t){let n=qc.has(e),r=!e.dataWs&&k.get(t)===e;return!(n||r)||!e.term||!Zc(e,t)?!1:(qc.delete(e),e._dataWsRetryAttempt=0,fl(t,e,e.term,0),!0)}function ml(e,t,n){ul(e,t,n),qc.add(t)}var hl=15e3,gl=new Map;function _l(e){if(!y()||gl.has(e)||k.get(e)?.dataWs)return;let n=Ms(e,!1,!1),r=new WebSocket(t(location,te(n)));r.binaryType=`arraybuffer`;let a=[],o=e=>a.push(e),s=()=>vl(e,r),c=()=>{r.readyState===WebSocket.CONNECTING&&s()};r.addEventListener(`message`,o),r.addEventListener(`close`,s);let l=setTimeout(c,i),u=setTimeout(s,hl);gl.set(e,{socket:r,attachPath:n,bufferedMessages:a,release:()=>{r.removeEventListener(`message`,o),r.removeEventListener(`close`,s),clearTimeout(l),clearTimeout(u)}})}function vl(e,t){let n=gl.get(e);n?.socket===t&&(gl.delete(e),n.release(),t.close())}function yl(e,t){let n=gl.get(e);if(!n)return null;let r=n.socket.readyState===WebSocket.CONNECTING||n.socket.readyState===WebSocket.OPEN;return n.attachPath!==t||!r?(vl(e,n.socket),null):(gl.delete(e),n.release(),n)}var bl=new WeakMap;function xl(e,t,n){if(t.openedAtMs===null)return;let r=Math.round(performance.now()-t.openedAtMs);if(r>=1e3){bl.delete(e);return}let i=(bl.get(e)??0)+1;if(bl.set(e,i),!Cs.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 Sl(n,r,a){qc.delete(r);let o=Uc.get(r);Uc.delete(r);let c=Wc.get(r);Wc.delete(r);let l=o!==void 0,u=o??c,d=!1,f=Zc(r,n),p=Ms(n,l,!f),m=yl(n,p),h=m?.socket??new WebSocket(t(location,te(p)));Xc.set(h,f),h.binaryType=`arraybuffer`,r.dataWs=h,f&&Ua(`terminal-connecting`),cl(r);let g=!1,_=!1,v={sessionId:n,attachDescription:ws({history:l?`deep`:`screen`,isOutputPaused:!f}),openedAtMs:null,hasReceivedBytes:!1},y={hasSeenSize:!1,lastSeq:0},ee=setTimeout(()=>{h.readyState===WebSocket.CONNECTING&&(_=!0,f&&Ua(`terminal-abandoned`),h.close())},i);fs.register(n,(e,t)=>a.write(e,t));let b=e=>{if(r.dataWs!==h)return;let t=Rs(e.data,y);if(t.kind===`bytes`){v.hasReceivedBytes=!0,Yn(r),Xc.get(h)&&Ua(`terminal-bytes`);let e=d;if(d=!1,fs.enqueue(n,t.data),!e)return;let i=u??0;fs.enqueueAction(n,()=>{a.scrollToLine(Math.max(0,a.buffer.active.length-i))});return}if(t.kind===`beat`){Yn(r);return}if(t.kind===`attach-size`){d=u!==void 0,l||Gc.delete(r),y.hasSeenSize=!0,y.lastSeq=t.seq,a.reset(),Nc(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};fs.enqueueAction(n,()=>{r.ptySize=i,r._syncGrid?.()})};h.addEventListener(`message`,b),h.addEventListener(`close`,t=>{if(clearTimeout(ee),r.dataWs!==h)return;if(xl(r,v,t),f&&!_&&Ua(`terminal-closed`),Kc.delete(r),!g&&!_&&s(),!Zc(r,n)){ml(n,r,a);return}if(_){fl(n,r,a,0);return}let i=e(r._dataWsRetryAttempt||0);r._dataWsRetryAttempt=(r._dataWsRetryAttempt||0)+1,fl(n,r,a,i)});let x=()=>{clearTimeout(ee),g=!0,v.openedAtMs=performance.now(),f&&Ua(`terminal-opened`),r._dataWsRetryAttempt=0,Kc.delete(r),cl(r),Qc(r,n),r._syncGrid?.({isActivationEdge:!0}),r._retryOwedGridClaim?.(),r._inputQueue?.length&&setTimeout(()=>{r.dataWs===h&&es(r)},50)};h.addEventListener(`open`,x),h.readyState===WebSocket.OPEN&&x();for(let e of m?.bufferedMessages??[])b(e)}function Cl(e){let t=A(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,fl(e,t,t.term,0),n?.close()}function wl(){for(let[e,t]of k)t.term&&(Zc(t,e)?Cl(e):Tl(e,t,t.term))}function Tl(e,t,n){let r=t.dataWs;r&&(ml(e,t,n),r.close())}function El(){for(let[e,t]of k)t.term&&Tl(e,t,t.term)}function Dl(e,t){let n=e.dataWs;e.dataWs=null,fs.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}var Ol=`CommitMono`,kl=[400,700].map(e=>`${e} 14px ${Ol}`),Al=`monospace`;function jl(e){return e.trim().replace(/^['"]|['"]$/g,``)}function Ml(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>jl(e)!==Ol);return r.length>0?r.join(`, `):Al}function Nl(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function Pl(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function Fl(){return document.fonts?kl.every(e=>document.fonts.check(e)):!1}function Il(){return Ml(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),Fl())}function Ll(e){document.fonts&&Nl(document.fonts,kl,e)}var Rl=Ur(navigator.userAgent),zl=`next-attention-keys`,Bl=Er();function Vl(){return Bl}function Hl(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(D(`span`,`shortcut-sep`,`+`)),e.appendChild(D(`kbd`,`kbd`,t))})}function Ul(e){let t=D(`span`,`shortcut-keys`);return Hl(t,e),t}function Wl(){let e=Ul(Gr(`next-attention`,Rl,Bl));return e.classList.add(zl),e}function Gl(e){Bl=e;let t=Gr(`next-attention`,Rl,e);for(let e of document.querySelectorAll(`.${zl}`))e.replaceChildren(),Hl(e,t)}var Kl=/\bElectron\/\d/,ql=new Set([`localhost`,`127.0.0.1`]);function Jl(e){return Kl.test(e)}function Yl({userAgent:e,pageHostname:t}){return Jl(e)&&ql.has(t)}function Xl(e){return qr(e)!==null}var Zl=new Set([0,1]);function Ql({button:e,opensInNewTab:t}){return t&&Zl.has(e)}function $l(){return Yl({userAgent:navigator.userAgent,pageHostname:location.hostname})}function eu(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function tu(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}}function nu(e){!$l()||!Xl(e)?eu(e):tu(e).then(t=>{t||eu(e)})}function ru(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&Ql({button:e.button,opensInNewTab:t.target===`_blank`})&&Xl(t.href)&&(e.preventDefault(),nu(t.href))}function iu(e){$l()&&(e.addEventListener(`click`,ru,!0),e.addEventListener(`auxclick`,ru,!0))}var au=/https?:\/\/[^\s<>"']+/g,ou=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),su={")":`(`,"]":`[`,"}":`{`};function cu(e,t){let n=0;for(let r of e)r===t&&n++;return n}function lu(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(ou.has(t)){e=e.slice(0,-1);continue}let n=su[t];if(n&&cu(e,n)<cu(e,t))e=e.slice(0,-1);else return e}}function uu(e){let t=[];for(let n of e.matchAll(au)){let e=lu(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var du=50;function fu(){return{activate(e,t){nu(t)},allowNonHttpProtocols:!1}}function pu(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<du;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<du;)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 mu(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=pu(r,t),o=[];for(let{start:e,end:t,url:n}of uu(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){nu(t)}})}n(o.length?o:void 0)}})}var hu=10,gu=1.2,_u=.005,vu=4,yu=.08,bu=5;function xu(e,t){let n=Math.abs(t);return n<hu?!1:n>Math.abs(e)*gu}function Su(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 Cu(e,t,n){let r=e.length>=vu?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function wu(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>=yu))return 0;let o=Math.min(a,bu);return i<0?-o:o}function Tu({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function Eu(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)-_u*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=Su(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function Du(e,t){return e===`alternate`||!!t&&t!==`none`}function Ou(e,t){return!(e>0)||!(t>0)?0:e/t}var ku=1;function Au(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function ju(e,t){for(let n of e)if(n.identifier===t)return n;return null}function Mu(e,t){if(Au(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=()=>Du(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return Ou(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:ku,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}=Eu(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=Tu({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=ju(e.touches,r);if(!u)return;if(!s){if(!xu(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=Cu([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=Cu(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=Su(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=Cu(l,o,e.timeStamp);let t=wu(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function Nu(e){let t=mr(e,Rl,{isTerminalFocused:!0},Vl());return t?Or(t,document.body.dataset.activeView):!1}var Pu=250,Fu=`(max-width: 768px)`,Iu=12,Lu=14,Ru=5e4,zu=!1;function Bu(e){zu=e}var Vu=!1;window.addEventListener(`blur`,()=>{Vu=!0}),window.addEventListener(`focus`,()=>{Vu=!1});function Hu(e){let t=document.activeElement;return ks({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:Vu,isPhoneLayout:yo()})}function Uu(e,t,n){let r=window.matchMedia?.(Fu).matches?Iu:Lu,i=new n.Terminal({cursorBlink:zu,fontSize:r,fontFamily:Il(),theme:wa(),scrollback:Ru,allowProposedApi:!0,linkHandler:fu()}),a=new n.FitAddon;i.loadAddon(a),rl(e),i.open(e),Yo(e,t,i),mu(i),Mc(i,t.abortController.signal),t.term=i,t.fitAddon=a,no(t);let o=null,s=null,c=!1,l=null,u=null;function d(){s!==null&&(clearTimeout(s),s=null)}function f(){if(!c)return null;let e=t.fitAddon;if(!e)return null;let n=e.proposeDimensions();return n?{cols:n.cols,rows:n.rows}:null}function p(e){if(!c||!Hu(t.card)||t.dataWs?.readyState!==WebSocket.OPEN)return!1;t.dataWs.send(JSON.stringify({type:`claim`,cols:e.cols,rows:e.rows})),l=e,u=null;let n=Os({authoritative:t.ptySize??null,isActiveViewer:c,lastClaim:l});return t.card.dataset.grid=n?`following`:`exact`,!0}function m(e){d(),u=e,s=setTimeout(()=>{s=null,p(e)},Pu)}function h(){u&&s===null&&p(u)}function g({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=Fs({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:f(),isActiveViewer:c,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});r.resizeTo&&n.resize(r.resizeTo.cols,r.resizeTo.rows),t.card.dataset.grid=r.isFollowing?`following`:`exact`,r.keepsPendingSettle||(d(),u=null),r.sendUnview?(l=null,t.dataWs?.send(JSON.stringify({type:`unview`}))):r.owedClaim&&(e&&p(r.owedClaim)||m(r.owedClaim))}function _(){let e=Ns({authoritative:t.ptySize??null,isActiveViewer:c,isDocumentEngaged:Hu(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});e!==`none`&&(d(),e===`rebid`&&(l=null),g({isActivationEdge:!0}))}let v=new ResizeObserver(()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,g()}))});v.observe(e),t.resizeObserver=v,t._syncGrid=g,t._resetGridClaim=()=>{d(),u=Ps({isActiveViewer:c,lastClaim:l,owedClaim:u}),l=null},t._retryOwedGridClaim=h,t._syncGridOnEngagementEdge=_,t._isActiveViewer=()=>c,t._setActiveViewer=e=>{c!==e&&(c=e,d(),u=null,e&&io(t),g({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{Vu=!1,_()},{signal:t.abortController.signal}),lo(t);let y=null;i.onScroll(()=>{y===null&&(y=requestAnimationFrame(()=>{y=null,t.term&&(t.term.refresh(0,t.term.rows-1),Uo(t,t.term))}))}),i.onWriteParsed(()=>Uo(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=Wo(r)}catch(e){return Go(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(Ko(t,i,`osc52 write`),!0):(qo(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`&&ts(t,`\x1B\r`),!1;if(e.type!==`keydown`)return!0;if(Nu(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),Ko(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(ts(t,`\x1B`),!1):!0}),ns(e,i,t),Mu(e,i)}function Wu(){as(!0);for(let e of k.values())cl(e)}function Gu(){as(!1);for(let e of k.values())cl(e),es(e)}function Ku(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{ts(e,n),e.unseenOutcome&&v({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{Yc(e,t,n)}),is(e.termWrap,t,e.abortController.signal),cl(e),queueMicrotask(()=>{el(t,e)&&Sl(t,e,n)}))}function qu(e,t){if(e.term||al.has(e))return;let n=Xa();if(n){Ju(e,t,n);return}al.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},rl(e.termWrap),cl(e),Za().then(n=>{al.delete(e),!(e.term||e.abortController.signal.aborted||k.get(t)!==e)&&(Ju(e,t,n),e._setActiveViewer?.(r))},()=>{al.delete(e),cl(e)})}function Ju(e,t,n){Uu(e.termWrap,e,n),Ku(e,t)}function Yu(e){e?._syncGridOnEngagementEdge?.()}function Xu(e,t){if(!e)return;qu(e,t),Qc(e,t),io(e);let n=e.term;n&&(n.refresh(0,n.rows-1),Yu(e))}function Zu(e,t,n){e&&(n&&qu(e,t),e._setActiveViewer?.(n))}var Qu={isVisible:document.visibilityState===`visible`,isFrozen:!1,isProbing:!1,isReplacing:!1},$u=document.visibilityState===`visible`?null:Date.now(),ed=null,td=null;function nd(){ed!==null&&window.clearTimeout(ed),ed=null}function rd(e){nd();let t=Date.now()+e;ed=window.setTimeout(()=>{ed=null,od({kind:`heartbeat-due`,lateByMs:Date.now()-t})},e)}function id(){td!==null&&window.clearTimeout(td),td=null}function ad(e){switch(e.kind){case`probe-control`:p(e.deadlineMs,e.isAnnounced).then(e=>{od({kind:e?`pong`:`pong-missed`})});return;case`replace-control`:g();return;case`close-sockets`:id(),_(),El();return;case`reconnect-shown-terminals`:wl();return;case`hold-input`:Wu();return;case`release-input`:Gu();return;case`schedule-heartbeat`:rd(e.inMs);return;case`cancel-heartbeat`:nd();return}}function od(e){let t=ee(Qu,e);Qu=t.state;for(let e of t.actions)ad(e)}function sd(){if(document.visibilityState!==`visible`){$u=Date.now(),od({kind:`hidden`});return}let e=$u===null?0:Date.now()-$u;$u=null,Ga(`shown`,e),od({kind:`shown`,hiddenForMs:e})}function cd(e){id(),Ua(`control-${e}`),e===`connecting`?td=window.setTimeout(()=>{td=null,od({kind:`handshake-overdue`})},i):(e===`opened`&&Da(),od({kind:e===`opened`?`control-opened`:`control-closed`}))}function ld(){Ga(`resumed`,$u===null?0:Date.now()-$u),od({kind:`resumed`})}function ud(){let e=Reflect.get(navigator,`connection`);e instanceof EventTarget&&e.addEventListener(`change`,()=>{Wa(`link`),od({kind:`network-changed`})})}function dd(){r(cd),document.addEventListener(`visibilitychange`,sd),document.addEventListener(`freeze`,()=>od({kind:`frozen`})),document.addEventListener(`resume`,ld),window.addEventListener(`pagehide`,e=>{e.persisted&&od({kind:`frozen`})}),window.addEventListener(`pageshow`,e=>{e.persisted&&ld()}),window.addEventListener(`online`,()=>{Wa(`online`),od({kind:`network-changed`})}),window.addEventListener(`offline`,()=>Wa(`offline`)),ud()}var fd=!1,pd=!1,md=!1,hd=null,gd=null;function _d(){return gd??=N(()=>import(`./nyan-cat-BUzAN_bt.js`).then(e=>e.r).then(e=>(hd=e,e),e=>(gd=null,u(`flying-animals`,`nyan cat failed to load: ${d(e)}`),null)),__vite__mapDeps([2,1,3,4,5,6,7,8])),gd}function vd(e){!md||e.currentFlightBlockReason(!0)?e.stopNyanCat():e.startNyanCat()}function yd(){pd=!0,bd(Wr())}function bd(e){let t=document.documentElement;fd||(fd=!0,bo(()=>bd(Wr())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>bd(Wr()))),md=e,e?(t.dataset.flyingAnimals=`true`,hd?vd(hd):pd&&_d().then(e=>{e&&vd(e)})):(delete t.dataset.flyingAnimals,hd?.stopNyanCat())}var xd=45e3,Sd=`The server did not answer within ${xd/1e3} s.`,Cd=`Select the issue to load its description.`,wd=null,Td=null,Ed=new Map,Dd=null,Od=new Map,kd=new Map,Ad=null,F=new Map,jd=new Map,Md=new Map,Nd=new Map,Pd=new Set;function I(e){for(let t of Pd)t(e)}function Fd(e){return`${e.key}:${e.updatedAt}`}function Id(e){let t=Od.get(e);t&&(Od.delete(e),F.set(t.issueKey,{text:Sd,tone:`error`}),I(`detail`))}function Ld(e){let t=Od.get(e);return t?(clearTimeout(t.timeoutHandle),Od.delete(e),t):null}function Rd(){return{latestStatus:Td,issueByKey:Ed,selectedKey:wd}}function zd(e){Pd.add(e)}function Bd(e){wd=e,Ad&&Ad.issue.key!==e&&(Ad=null)}function Vd(){if(wd)return Ed.get(wd)??(Ad?.issue.key===wd?Ad.issue:void 0)}function Hd(e){return Ad?.issue.key===e.key&&Ad.isClosed}function Ud(e){return[...kd.values()].some(t=>t.issue.key===e.key)}function Wd(e,t){if(Ud(e))return;let n=h(`set-issue-state`);Dd?.({type:`set-issue-state`,requestId:n,repo:e.repo,issueNumber:e.number,state:t})?(kd.set(n,{issue:e,state:t,timeoutHandle:setTimeout(()=>{kd.delete(n),F.set(e.key,{text:Sd,tone:`error`}),I(`detail`)},xd)}),F.set(e.key,{text:t===`closed`?`Closing issue.`:`Reopening issue.`,tone:`busy`}),I(`detail`)):(F.set(e.key,{text:De,tone:`error`}),I(`detail`))}function Gd(e){let t=kd.get(e.requestId);if(!t)return;clearTimeout(t.timeoutHandle),kd.delete(e.requestId);let{issue:n,state:r}=t;e.ok?(Ad={issue:n,isClosed:r===`closed`},F.set(n.key,{text:r===`closed`?`Closed as completed.`:`Reopened.`,tone:`ok`}),I(`detail`)):(F.set(n.key,{text:e.error||`Could not ${r===`closed`?`close`:`reopen`} the issue.`,tone:`error`}),I(`detail`))}function Kd(e){return[...Od.values()].some(t=>t.issueKey===e.key)}function qd(e){return F.get(e.key)}function Jd(e){let t=Fd(e),n=Md.get(t);return n===``?`No description.`:n??Nd.get(t)??`Loading description.`}function Yd(e){let t=Fd(e);if(Md.has(t)||[...jd.values()].some(e=>e.cacheKey===t))return;let n=h(`issue-detail`);Nd.delete(t),Dd?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?jd.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{jd.delete(n),Nd.set(t,`${Sd} ${Cd}`),I(`detail`)},xd)}):Nd.set(t,`${De} ${Cd}`)}function Xd(e){let t=e.projectId;if(!t||Kd(e))return;let n=h(`open-issue-session`);Dd?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(Od.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>Id(n),xd)}),F.set(e.key,{text:`Opening session.`,tone:`busy`}),I(`detail`)):(F.set(e.key,{text:De,tone:`error`}),I(`detail`))}function Zd(e){Dd?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function Qd(e){Dd=e}function $d(){I(`session-state`)}function ef(e){if(!e){for(let e of Od.values())clearTimeout(e.timeoutHandle),F.set(e.issueKey,{text:De,tone:`error`});Od.clear();for(let e of kd.values())clearTimeout(e.timeoutHandle),F.set(e.issue.key,{text:De,tone:`error`});kd.clear();for(let e of jd.values())clearTimeout(e.timeoutHandle),Nd.set(e.cacheKey,`${De} ${Cd}`);jd.clear(),I(`status`)}}function tf(e){let t=Td?.issues.find(e=>e.key===wd);Td=e,Ed=new Map(e.issues.map(e=>[e.key,e])),Ad&&!Ad.isClosed&&Ed.has(Ad.issue.key)&&(Ad=null);let n=e.issues.find(e=>e.key===wd);n&&n.updatedAt!==t?.updatedAt&&Yd(n),I(`status`)}function nf(e){let t=jd.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),jd.delete(e.requestId),e.ok&&e.body!==null&&Md.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&Nd.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),I(`detail`))}function rf(e){if(typeof e.requestId!=`string`)return;let t=Ld(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`;F.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=Td?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),I(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;F.set(n,{text:r,tone:`error`}),I(`detail`)}var af=new Map,of=new Set;function sf(e){let t=Se.safeParse(e);if(!t.success)u(`reviews`,`dropped github-prs: ${c(t.error.issues)}`);else{af=new Map(Object.entries(t.data.prs));for(let e of of)e()}}function cf(e){return af.get(e.toLowerCase())}function lf(e){of.add(e)}var uf=20,df=[],ff=null,pf=!1,mf=0,hf=null;function gf(){return hf??=N(()=>import(`./celebration-player-B6pp3XJS.js`),__vite__mapDeps([9,3,4,5,6,7,10])).catch(e=>(hf=null,u(`merge-celebration`,`celebration player failed to load: ${d(e)}`),null)),hf}function _f(e){return pf?`playing`:e?`queued`:`empty`}function vf(){if(!ff)return;let e=df.length>0,t=_f(e);ff.tray.dataset.state=t,ff.count.textContent=e?String(df.length):``,ff.toggle.element.disabled=t!==`queued`,ff.toggle.setState(t===`queued`?`attention`:`idle`)}function yf(){let e=df.shift();if(pf=e!==void 0,vf(),!e)return;let t=mf;mf+=1,gf().then(n=>{n?(n.playCelebration(e,t),window.setTimeout(yf,n.CELEBRATION_DURATION_MS)):(df.unshift(e),pf=!1,vf())})}function bf(e,t,n){ff={tray:e,toggle:t,count:n},t.element.addEventListener(`click`,()=>{mf=0,yf()}),vf()}function xf(e){df.push(e),df.length>uf&&df.shift(),vf()}var Sf={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},Cf=new Set([`FAILURE`,`ERROR`]);function wf(e){return Sf[e]}function Tf(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&&Cf.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function Ef(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 Df(e){let t=st.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:Ef(t)}}var Of=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],kf=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],Af={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`},jf={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`},Mf={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`},Nf={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 Pf(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 Ff(e){return Of[e.rows.reduce((e,{pr:t})=>Math.min(e,Of.indexOf(Af[t.stage])),Of.length-1)]}function If(e){let t=new Map(Of.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of Pf(e)){let e=t.get(Ff(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return kf.flatMap(e=>t.get(e)??[])}function Lf(e,t){return Pf(e).find(e=>e.rows.some(e=>e.pr.key===t))?.rows??[]}function Rf(e){return e.stackSize<2?null:`Stack ${e.depth+1}/${e.stackHeight}`}function zf(e){return jf[e]}function Bf(e){return Mf[e]}function Vf(e){return Nf[e]}function Hf(e){return e?.isKeepMergeableEnabled!==!1}function Uf(e,t){if(!t||!e.keepMergeable||e.isKeepMergeableFixInFlight)return!1;let n=e.keepMergeableAttempt?.outcome;return n!==void 0&&n!==`pushed`&&n!==`stopped`}function Wf(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...Df({...n,repo:r}),...e}]})}function Gf(e){let t=new Map;for(let n of e)for(let e of n.links){let r=Ke(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 Kf(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 qf=3;function Jf(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,qf).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 Yf(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:de(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,isAuthorOrgMember:n.isAuthorOrgMember,liveHead:n.headRefOid,prStage:Df(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n)}}var Xf=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`];function Zf(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 Qf(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function $f(e){return e.status===`posted`&&ep(e)}function ep(e){if(!Qf(e)||Dt(e))return!1;let t=ap(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 tp(e){return op(e).length>0||$f(e)}function np(e){return tp(e)?`actionable`:Zf(e).band}function rp(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[Zf(t).band].push(t);for(let e of Xf)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(tp(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!sp(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[np(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 Xf)t.ready.push(...n[e]);return t}function ip(e,t){return e.commit===t?e.isViewer||Mt.has(e.state):!1}function ap(e){return e.liveHead??e.reviewedHead}function op(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function sp(e){return op(e).length>0?!0:Dt(e)?!1:ep(e)?!0:!(e.githubReviews??[]).some(t=>ip(t,ap(e)))}function cp(e,t){return`${e}#${t}`}var lp=null,up={},dp=[],fp=[],pp={},mp={},hp=[],gp={},_p={},vp={},yp=null,bp=new Set,xp=new Map,Sp=!1,Cp=new Set;function wp(e){for(let t of Cp)t(e)}function Tp(){return[...xp].flatMap(([e,t])=>{let n=k.get(e);return!n||t.length===0?[]:[{id:e,title:Tn(n)||e,links:t}]})}function Ep(){let e=Wf(lp?.prs??[],cf),t=Kf(yp,e);yp=e,Ap(t),wp({kind:`prs`})}function Dp(){Sp||(Sp=!0,queueMicrotask(()=>{Sp=!1,Ep()}))}function Op(e){Cp.add(e)}function kp(){return{prs:Wf(lp?.prs??[],cf).map(e=>({...e,reviewItems:mp[e.key]??e.reviewItems})),status:lp,sessionsByPrKey:Gf(Tp()),handledByPr:up,prFlowWarnings:dp,prFlowApprovals:fp,sourceRunsByPr:pp,prFlowActions:hp,actionRunsByPr:gp,prActionsByPr:_p,prActionRunsByPr:vp}}function Ap(e){let t=e.filter(e=>!bp.has(e.key));if(t.length!==0){for(let e of t)bp.add(e.key);xf(Jf(t))}}function jp(e){xp=e,Dp()}function Mp(){wp({kind:`session-state`})}function Np(e){let t=Ye.safeParse(e);t.success?(lp=t.data,Ep()):u(`reviews`,`dropped my-prs-status: ${c(t.error.issues)}`)}function Pp(e){let t=ft.safeParse(e);t.success?(up=t.data.handledByPr,dp=t.data.warnings,fp=t.data.pendingApprovals,pp=t.data.sourceRunsByPr,mp=t.data.reviewItemsByPr,hp=t.data.actions,gp=t.data.actionRunsByPr,_p=t.data.prActionsByPr,vp=t.data.prActionRunsByPr,wp({kind:`prs`})):u(`reviews`,`dropped pr-flows-status: ${c(t.error.issues)}`)}function Fp(e){wp({kind:`merge-result`,message:e})}function Ip(e){wp({kind:`connection`,isConnected:e})}lf(Dp);var Lp=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}])),Rp={turn:`Your turn`,working:`Agent working`,waiting:`Waiting on others`,aside:`Set aside`},zp=[`turn`,`working`,`waiting`,`aside`],Bp={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`},Vp={settled:`review-settled`,inReview:`review-in-flight`,queued:`review-queued`,posted:`review-posted`,discarded:`review-discarded`},Hp=Xf.indexOf(`waiting-on-author`);function Up(e){return e.status===`ready`?Zf(e).band===`blocking-others`?`review-direct-ask`:`review-ready`:`review-follow-up`}function Wp(e,t){return t===`ready`?Up(e):t===`attention`?`status`in e&&e.status===`error`?`review-failed`:`review-stale`:Vp[t]}function Gp(e,t,n){let r=e.state===`OPEN`;if(r&&Uf(e,n))return`mine-repair-failed`;if(r&&n&&e.keepMergeable&&e.isKeepMergeableFixInFlight)return`mine-repairing`;let i=Bp[e.stage];return Lp.get(i)?.group===`turn`&&e.stage!==`ready`&&t.has(Ke(e))?`mine-agent-fixing`:i}function Kp(e,t){return t===`ready`||t===`attention`?Xf.indexOf(np(e)):t===`queued`?Xf.indexOf(Zf(e).band):0}function qp(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function Jp(e){let t=op(e).flatMap(e=>qp(e.lastReplyAt)??[]);return t.length>0?Math.max(...t):null}function Yp(e,t){if(t===`inReview`)return qp(e.startedAt)??1/0;if(t===`queued`)return qp(e.prCreatedAt)??1/0;let n=e;return Jp(n)??qp(n.reviewedAt)??qp(n.prCreatedAt)??1/0}function Xp(e){return qp(e.mergedAt??e.stageSinceMs??e.updatedAt)??1/0}function Zp(e,t,n,r){let i=Lp.get(e);return i?[{item:r(i),row:i,priorityBandRank:t,waitStartMs:n}]:[]}function Qp(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=>Zp(Wp(t,e),Kp(t,e),Yp(t,e),({action:n,kind:r})=>({source:`team`,key:`team:${t.key}`,prKey:Ke(t),kind:e,review:t,action:n,attention:r}))))}function $p(e,t,n){return If(e).flatMap(e=>e.rows).flatMap(e=>Zp(Gp(e.pr,t,n),0,Xp(e.pr),({action:t,kind:n})=>({source:`mine`,key:`mine:${e.pr.key}`,prKey:Ke(e.pr),pr:e.pr,stackRow:e,action:t,attention:n})))}function em(e){return e.row.kind===`failed`?0:e.row.state===`review-direct-ask`?1:e.priorityBandRank>=Hp?3:2}function tm(e,t){let n=e.waitStartMs-t.waitStartMs;return e.row.group===`turn`?em(e)-em(t)||n||e.item.key.localeCompare(t.item.key):e.row.rank-t.row.rank||e.priorityBandRank-t.priorityBandRank||n}function nm(e,t,n,r){let i=new Map(zp.map(e=>[e,[]]));for(let a of[...Qp(e),...$p(t,n,r)])i.get(a.row.group)?.push(a);return zp.map(e=>({id:e,title:Rp[e],items:(i.get(e)??[]).toSorted(tm).map(e=>e.item)}))}var rm=[`turn`,`working`,`aside`],im=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 am(e){return e.status===`ready`&&e.verdict?`ready-${e.verdict}`:e.status}function om(e){let t=Date.parse(e.item.createdAt);return Number.isNaN(t)?1/0:t}function sm(e){let t=e.flatMap(e=>{let t=im.get(am(e));return t?[{row:t,askedAtMs:om(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 rm.map(e=>({id:e,title:Rp[e],items:t.filter(t=>t.row.group===e).map(e=>e.item)}))}function cm(e){return`${e.key}@${e.entry.status}:${e.entry.finishedAt??``}`}function lm(e){return e.find(e=>e.id===`turn`)?.items??[]}function um(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function dm(e,t){return um(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function fm(e){return e.source===`mine`?cp(e.pr.repo,e.pr.number):cp(e.review.repo,e.review.number)}function pm(e,t){return lm(e).map(e=>({id:e.key,kind:e.attention??`waiting`,name:t(e)}))}function mm(e){return pm(e,fm)}function hm(e,t){return mm(e).filter(e=>e.id!==t)}function gm({capturedOrder:e,actedKey:t,groups:n}){let r=lm(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 _m(e,t){let n=lm(e).map(e=>e.key),r=t?n.indexOf(t):-1;return r===-1?``:`${r+1} of ${n.length} in Your turn`}function vm(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 ym(e){return lm(e).map(vm)}function bm({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:Xe([...i]),unseen:Xe([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:Xe([...a]),unseen:Xe([...o])}}function xm(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 Sm(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function Cm(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 wm=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 Tm(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`:wm.get(e.key)??null}function Em(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 Dm=null,Om=null,km=new Set;function Am(e){for(let t of km)t(e)}function jm(){Om=Yf(Dm,cf),Am({kind:`status`})}function Mm(e){km.add(e)}function Nm(){return Om}function Pm(){return rp(Om)}function Fm(e){let t=At.safeParse(e);t.success?(Dm=t.data,jm()):u(`reviews`,`dropped team-review-status: ${c(t.error.issues)}`)}function Im(e){Am({kind:`action-result`,message:e})}function Lm(e){Am({kind:`open-session-result`,message:e})}function Rm(e){Am({kind:`connection`,isConnected:e})}lf(jm);var zm=[],Bm=null,Vm=null,Hm=null,Um=!1,Wm=null,Gm=zr(),Km=yr(),qm=new Set(Km.split(`|`).filter(Boolean)),Jm=new Set,Ym=new Set;function Xm(e){for(let t of Ym)t(e)}function Zm(e){e!==Gm&&(Gm=e,ur(e))}function Qm(e){e!==Km&&(Km=e,qm=new Set(e.split(`|`).filter(Boolean)),or(e))}function $m(){return Nm()!==null&&kp().status!==null}function eh(){if(!$m())return;let e=bm({turnEntries:ym(zm),acknowledged:Gm,unseen:Km,isLooking:Vm?.isLooking()??!1});Zm(e.acknowledged),Qm(e.unseen),Wm?.(e.isShown)}function th(e){Hm=e,Xm({kind:`reveal`})}function nh(e){Ym.add(e)}function rh(e){Vm=e,eh()}function ih(){let{prs:e,sessionsByPrKey:t,status:n}=kp();return zm=nm(Pm(),e,new Set(t.keys()),Hf(n)),eh(),zm}function ah(){$m()&&(Zm(Xe(ym(zm))),eh())}function oh(e){Wm=e,eh()}function sh(){return Km}function ch(e){return qm.has(e)}function lh(e){return qm.has(e)?(Qm(Xe([...qm].filter(t=>t!==e))),!0):!1}function uh(e){Bm=e}function dh(){return Bm}function fh(){let e=Hm;return Hm=null,e}function ph(e){if(e!==Um){Um=e;for(let e of Jm)e()}}function mh(e){Jm.add(e)}function hh(){return document.documentElement.dataset.layout===`phone`&&Um}function gh(){hh()&&Xm({kind:`return-to-queue`})}function _h(){let e=hm(zm,Vm?.selectedKey()??null)[0]?.id??null;return e?(th(e),!0):!1}function vh(e){let t=zm.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!Bm?.openReviews()?!1:(th(t.key),ah(),!0)}Mm(e=>{e.kind===`status`&&ih()}),Op(e=>{e.kind===`prs`&&ih()});function yh(){return{groups:zm}}var bh={OPEN:0,MERGED:1,CLOSED:2};function xh(e){return e?bh[e.state]:bh.OPEN}function Sh(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:$t(void 0)};let i=Bf(t.stage);return{key:n,text:r,detailText:`${r} ${t.title}`,stateText:zf(t.stage),url:t.url,prTitle:t.title,look:{icon:Vf(t.stage),tone:i},tier:$t(i)}}function Ch(e,t){let n=e.map(e=>{let n=t(Ke(e));return{link:e,pr:n?Df(n):void 0}});return n.sort((e,t)=>xh(e.pr)-xh(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>Sh(e,t))}var wh=new Map;function Th(e){return document.querySelectorAll(`[data-pr-rows-for="${CSS.escape(e)}"]`)}function Eh(e){return Ch(wh.get(e)??[],cf).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,onActivate:()=>{vh(e.key)||nu(e.url)}}))}function Dh(e,t){let n=Ze(`session-pr-chip-unlink`);return n.append(C(Ct)),n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),Jt({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:()=>{ci(t,{type:`unlink-session-pr`,id:t,key:e.key})}})}),n}function Oh(e,t){let n=dn({...e,text:e.key},{...e,className:`linked-pr-row-link`});e.prTitle&&n.append(D(`span`,`linked-pr-row-title`,e.prTitle)),e.stateText&&n.append(D(`span`,`linked-pr-row-stage`,e.stateText));let r=D(`li`,`linked-pr-row`);return r.append(n,Dh(e,t)),r}function kh(e,t){e.dataset.prRowsFor=t;let n=Eh(t);yn(e,n,e=>Oh(e,t),{visibleCount:n.length})}function Ah(e){for(let t of e){let e=t.dataset.prRowsFor;e&&kh(t,e)}}function jh(e,t){let n=Tt.shape.links.safeParse(t??[]);wh.set(e,n.success?n.data:[]),Ah(Th(e)),_n(e),jp(wh)}function Mh(e){wh.delete(e),jp(wh)}lf(()=>{Ah(document.querySelectorAll(`[data-pr-rows-for]`)),mn()});function L(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Nh(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function Ph(e,t){return e||Nh(t)>0}var Fh={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},Ih=null,Lh=!1,Rh=!1,zh=null,Bh=null,Vh=null,Hh=`—`;function Uh(e){return e==null?Hh:et(e,`GB`)}function Wh(e){return e==null?Hh:he(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function Gh(e){return e==null?Hh:`${Wh(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function Kh(){let e=D(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=D(`div`,`health-summary`),n=Ze(`health-toggle`);n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=D(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,D(`span`,`health-toggle-label`,`Health`));let i=D(`div`,`health-stats`);t.append(n,i);let a=D(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{Rh=!Rh,e.dataset.expanded=String(Rh),n.setAttribute(`aria-expanded`,String(Rh)),a.hidden=!Rh,Rh&&(v({type:`request-health-snapshot`}),Jh())}),e.append(t,a),zh=e,Bh=i,Vh=a,e}function qh(){if(!Bh||!Ih)return;let e=Ih,t=Nh(e.anomalies);Bh.innerHTML=`
|
|
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-DQg7Jylj.js","assets/dom-helpers-Bs-xZEnd.js","assets/ui-prefs-Dyka19fU.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-B6pp3XJS.js","assets/alert-sound-Da6VQFBS.js","assets/doc-editor-ui-DmSq6oxC.js","assets/control-ws-CCnwczmH.js","assets/button-gPjGDYEC.js","assets/modal-BzU16bX3.js","assets/action-status-ChqLWNwE.js","assets/plan-render-Dw6NRG4-.js","assets/http-url-B85DM2Ri.js","assets/doc-editor-ui-5jSk9zTx.css","assets/resume-dialog-j14Lv2au.js","assets/card-registry-DooQcht6.js","assets/card-actions-DoLdHG81.js","assets/plan-face-DjGyIJPj.js","assets/ui-state-core-Nssh-6QJ.js","assets/roving-keys-core-BDobx2It.js","assets/plan-face-CNqLL3OW.css","assets/phone-shell-BGIx4-6z.js","assets/session-row-V7L-vvPv.js","assets/session-tick-BgbD-Hwq.js","assets/session-actions-Cc3TXNNI.js","assets/preload-helper-BLdHbfdN.js","assets/menu-70wrT0oQ.js","assets/pr-status-icon-CV0_Wkzx.js","assets/first-run-checklist-2LJwKdE8.js","assets/setup-step-U8tZBuCu.js","assets/repo-roots-adder-BhBDc31V.js","assets/boards-view-Dib7ZZVH.js","assets/boards-view-B6r6A9lG.css","assets/review-queue-panel-8u_I7_Hn.js","assets/lane-read-token-step-D99lZR3U.js","assets/lane-read-token-step-GYpu4zXr.css","assets/pr-queue-columns-a3LtXpny.js","assets/my-prs-panel-CyAEX_SQ.js","assets/team-review-settings-core-BHv0yl1m.js","assets/issues-panel-cmaZg8pa.js","assets/issues-panel-1vb6hHuv.css","assets/usage-panel-DFauLty3.js","assets/chart-readout-CFE3tWIs.js","assets/usage-panel-DV0ckKqY.css","assets/radar-panel-9SuG7CHS.js","assets/dialogs-Glf5Smuh.js","assets/radar-panel-LHOTTm1M.css","assets/community-panel-BiOV5-sV.js","assets/community-panel-DR_-RgSK.css","assets/hooks-panel-D-3mY4mZ.js","assets/hooks-panel-BUBv4dvX.css","assets/trace-panel-B1xwTFQF.js","assets/trace-panel-D-AIzBSZ.css","assets/arena-panel-DbKIlSCb.js","assets/arena-panel-CW50kbc8.css","assets/settings-panel-Djq38v9c.js","assets/flying-animal-preview-CstA5sSm.js","assets/settings-panel-gVM13RdM.css","assets/feature-hint-DnrqJolm.js","assets/feature-hint-Dm-eD9Sz.css","assets/your-day-tip-126RabsR.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-CCnwczmH.js";import{c as b,d as x,g as ne,n as re,o as ie,u as ae}from"./zod-_N0uRWDY.js";import{$t as oe,A as se,Bn as ce,Bt as le,C as ue,Cn as de,Ct as fe,D as pe,Dt as S,E as me,Et as he,Ft as ge,G as _e,Gn as ve,Hn as ye,It as be,J as xe,Jt as Se,K as Ce,Kn as we,Ln as Te,Lt as Ee,M as De,Mt as Oe,Nn as ke,Nt as Ae,O as C,Ot as je,Pn as Me,Pt as Ne,Qt as Pe,R as Fe,Rn as Ie,S as Le,St as Re,T as ze,Tt as Be,U as Ve,Un as He,V as Ue,Vn as We,Wn as Ge,Yt as Ke,Z as qe,_ as Je,_n as Ye,_t as Xe,a as Ze,an as Qe,b as $e,bt as et,c as tt,dn as nt,en as rt,f as it,g as at,h as ot,hn as st,i as ct,in as lt,j as ut,jt as dt,kn as ft,kt as pt,l as mt,p as ht,q as gt,qn as _t,qt as vt,rn as yt,s as bt,st as xt,t as w,tn as St,u as Ct,ut as wt,vn as Tt,vt as Et,wn as Dt,wt as Ot,x as kt,xn as At,y as jt,yn as Mt,zn as Nt,zt as Pt}from"./button-gPjGDYEC.js";import{J as Ft,K as It,X as T,Y as Lt,_ as Rt,b as zt,f as Bt,g as E,h as Vt,n as Ht,p as Ut,q as Wt,s as D,t as Gt,u as Kt,x as qt}from"./dom-helpers-Bs-xZEnd.js";import{a as Jt,i as Yt,n as Xt,r as Zt,t as Qt}from"./modal-BzU16bX3.js";import{C as $t,S as en,_ as tn,a as nn,b as rn,c as an,d as on,f as sn,g as cn,h as ln,i as un,l as dn,m as fn,n as pn,o as mn,p as hn,r as gn,s as _n,t as vn,u as yn,v as bn,x as xn,y as Sn}from"./session-row-V7L-vvPv.js";import{S as Cn,_ as wn,a as Tn,b as En,c as Dn,f as On,g as kn,h as An,i as O,m as jn,n as Mn,o as k,r as A,s as Nn,t as j,u as Pn,x as Fn,y as In}from"./card-registry-DooQcht6.js";import{n as M,t as Ln}from"./ui-state-core-Nssh-6QJ.js";import{t as N}from"./preload-helper-BLdHbfdN.js";import{i as Rn,n as zn,o as Bn,r as Vn,s as Hn,t as Un,u as Wn}from"./action-status-ChqLWNwE.js";import{a as Gn,c as Kn,i as qn,n as Jn,o as Yn,r as Xn,s as Zn,t as Qn}from"./session-tick-BgbD-Hwq.js";import{n as $n,t as er}from"./local-store-CVQ5ByvB.js";import{$ as tr,A as nr,C as rr,D as ir,J as ar,K as or,O as sr,S as cr,T as lr,W as ur,X as dr,Y as fr,Z as pr,_t as mr,at as hr,b as gr,c as _r,ct as vr,f as yr,g as br,h as xr,ht as Sr,i as Cr,it as wr,k as Tr,l as Er,m as Dr,mt as Or,n as kr,nt as Ar,ot as jr,p as Mr,q as Nr,r as Pr,rt as Fr,s as Ir,st as Lr,t as Rr,u as zr,v as Br,w as Vr,x as Hr,xt as Ur,y as Wr,yt as Gr,z as Kr}from"./ui-prefs-Dyka19fU.js";import{t as qr}from"./http-url-B85DM2Ri.js";import{C as Jr,D as Yr,E as Xr,I as Zr,O as Qr,S as $r,T as ei,_ as ti,a as ni,b as ri,c as ii,d as ai,f as oi,g as si,h as ci,i as li,k as ui,l as di,m as fi,o as pi,u as mi,v as hi,w as gi,x as _i,y as vi}from"./session-actions-Cc3TXNNI.js";import{n as yi}from"./card-actions-DoLdHG81.js";import{n as bi,t as xi}from"./roving-keys-core-BDobx2It.js";import{n as Si}from"./menu-70wrT0oQ.js";import{t as Ci}from"./pr-status-icon-CV0_Wkzx.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 wi={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},Ti=null,Ei=null,Di=!0,Oi=new Map,ki=new Map,Ai=new Set;function ji(){for(let e of Ai)e()}function Mi(e){Ai.add(e)}function Ni(){return{status:Ti,isServerConnected:Di,pendingActionBySuite:Oi,outcomeBySuite:ki}}function Pi(e){Ei=e}function Fi(e,t){Ei?.({type:`benchmark-action`,requestId:h(`benchmark`),suiteId:e,action:t})===!0?(Oi.set(e,t),ki.set(e,wi[t]),ji()):(ki.set(e,De),ji())}function Ii(e){if(Di=e,!e){for(let e of Oi.keys())ki.delete(e);Oi.clear()}ji()}function Li(e){Ti=e,ji()}function Ri(e){Oi.delete(e.suiteId);let t=Ti?.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.`};ki.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),ji()}function zi({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=Zt({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=D(`div`,`coherence-journal-header`),s=D(`h3`,`dialog-title`,t);s.id=n;let c=w({variant:`secondary`,label:`Close`,action:`close-coherence-panel`,onClick:i});return o.append(s,c),a.dialog.append(o,...r),Qt(a.dialog,s.id),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function Bi({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=zi({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 Vi={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 Hi(e){return e?.active!==!1||e.reason===nt.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,detailText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:en.broken}]}function Ui(e){let t=Pe.safeParse(e.kind);return{heading:`${t.success?Vi[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function Wi(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 Gi=new Map,Ki=new Map,qi=Bi({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function Ji(e,t){Ki.delete(e),t&&Ki.set(e,t),ea(e)}function Yi(e){Gi.delete(e),Ki.delete(e);let t=qi.currentPanel();t?.sessionId===e&&t.close()}function Xi(e){let t=Gi.get(e.id);t&&t.updatedAt>e.updatedAt||(Gi.set(e.id,e),ea(e.id))}function Zi(e){Gi.clear();for(let[t,n]of Object.entries(e.sessions))Gi.set(t,n);let t=qi.currentPanel();t&&ea(t.sessionId)}function Qi(e){return Hi(Ki.get(e)??null).map(t=>({...t,onActivate:()=>ta(e)}))}function $i(e){return Gi.get(e)?.journal.ok===!0}function ea(e){let t=qi.currentPanel();if(!t||t.sessionId!==e)return;let n=Wi(Ki.get(e)??null,Gi.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>D(`p`,null,e)))}function ta(e){let t=D(`div`,`coherence-journal-reading`),n=D(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=D(`div`,`coherence-journal-entries`);qi.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>ea(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function na(e){let t=qi.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=Ui(e),n=D(`article`,`coherence-journal-entry`);return n.append(D(`h4`,null,t.heading),D(`p`,null,t.text)),t.detail&&n.append(D(`p`,null,t.detail)),t.supersedes&&n.append(D(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var ra=new Set([`waiting`,`monitoring`]);function ia(e){return Object.fromEntries(Pt.flatMap(t=>{let n=ra.has(t)?8:6;return[[`--state-${t}`,e[t]],[`--state-${t}-bg`,`color-mix(in oklab, var(--state-${t}) ${n}%, transparent)`]]}))}function aa(e){return{...Object.fromEntries(Object.entries(e.chrome).map(([e,t])=>[`--${e}`,t])),...ia(e.states)}}var oa={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`}},sa={dark:{black:`--border`,brightBlack:`--text-muted`,white:`--text`,brightWhite:`--text-head`},light:{black:`--text-head`,brightBlack:`--text-dim`,white:`--text-dim`,brightWhite:`--text`}},ca=.35;function la(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 ua(e){if(e.accentAnsiSlot===`none`)return{};let t=`bright${e.accentAnsiSlot[0].toUpperCase()}${e.accentAnsiSlot.slice(1)}`;return{[e.accentAnsiSlot]:`--accent`,[t]:la(e.chrome.accent,ca)}}function da(e){return{label:e.label,colors:aa(e),terminal:{background:`--bg-card`,foreground:`--text`,cursor:`--accent`,cursorAccent:`--bg-card`,...sa[e.mode],...oa[e.mode],...ua(e)}}}var fa={golgari:da({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:da({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:da({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:da({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:da({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":da({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":da({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`}})},pa=`phyrexian`,ma=null,ha=null,ga=null,_a={};function va(e){return Object.hasOwn(fa,e)?fa[e]:_a[e]}function ya(e){_a=Object.fromEntries(e.map(({id:e,palette:t})=>[e,da(t)]));let t=ga??pa,n=va(t)?t:pa;return n===ha&&!Object.hasOwn(_a,n)?!1:(xa(n),!0)}function ba(e){ga=e,va(e)&&xa(e)}function xa(e){let t=va(e);if(!t)return;let n=ha;ha=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`&&ma?.()}function Sa(e){ma=e}function Ca(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function wa(){let e=va(ha||pa);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 Ta(){return{id:ha,colors:{...va(ha??pa)?.colors}}}function Ea(){return Object.entries({...fa,..._a}).map(([e,t])=>({id:e,label:t.label}))}function Da(){let e=wa();e.background&&e.foreground&&v({type:`terminal-colors`,background:e.background,foreground:e.foreground})}var Oa=3e4,ka=24,Aa=null,ja=[`Android`,`iPhone`,`iPad`,`Windows`,`Mac OS X`,`Linux`],Ma=[/Firefox\/\d+/,/Edg\/\d+/,/Chrome\/\d+/,/Version\/\d+/];function Na(){let e=navigator.userAgent,t=ja.find(t=>e.includes(t))??`unknown platform`;return`${Ma.map(t=>t.exec(e)?.[0]).find(e=>e!==void 0)?.replace(`Version`,`Safari`)??`unknown browser`} on ${t}`}function Pa(){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 Fa(){return[navigator.onLine?`online`:`offline`,...Pa()].join(` `)}function Ia(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 La(e,t){let n=e.join(` `);if(n.length<=t)return n;let r=t-ka,i=Ia(e,r/2),a=Ia(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 Ra(e){return e.marks.some(e=>e.startsWith(`terminal-bytes`))}function za(e){let t=Ra(e)&&!e.isCapped?`terminal live`:`terminal not live after ${Oa/1e3} s`,n=`hidden ${Math.round(e.hiddenForMs/1e3)} s, ${t}, ${Na()}, ${e.networkAtWake}: `,r=n+La(e.marks,yt-n.length);return v({type:`client-log`,scope:`wake`,text:r.slice(0,yt)})}function Ba(){let e=Aa;e&&(e.isCapped||Ra(e))&&za(e)&&(Aa=null,clearTimeout(e.capTimer))}function Va(){Aa&&(Aa.isCapped=!0,Ba())}function Ha(e,t){e.marks.push(`${t}+${Math.round(performance.now()-e.startedAtMs)}`)}function Ua(e){Aa&&(e===`terminal-bytes`&&Ra(Aa)||(Ha(Aa,e),(e===`terminal-bytes`||e===`control-opened`)&&Ba()))}function Wa(e){Aa&&Ha(Aa,e===`link`?[`link`,...Pa()].join(`-`):e)}function Ga(e,t){Aa||={startedAtMs:performance.now(),hiddenForMs:t,networkAtWake:Fa(),marks:[],isCapped:!1,capTimer:setTimeout(Va,Oa)},Ua(e)}function Ka(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function qa(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 Ja=null,Ya=null;function Xa(){return Ja}function Za(){return Ja?Promise.resolve(Ja):(Ya??=Promise.all([N(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.t),__vite__mapDeps([0,1])),N(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.r),__vite__mapDeps([0,1])),N(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.n),__vite__mapDeps([0,1]))]).then(([e,t,n])=>(Ja={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},Ja)).catch(e=>{throw Ya=null,e}),Ya)}var Qa=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,$a=new Map;function eo(e){return e.clientWidth>0&&e.clientHeight>0}function to(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 no(e){$a.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,to(e)}function ro(e){let t=[e],n=M.snapshot().borrowedCardId,r=n?k.get(n):void 0;r&&t.push(r);for(let e of qa([...$a.keys()],Qa,t))no(e),e.needsWebGLReload=!0}function io(e){e?.term&&Ka({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:eo(e.termWrap)})&&lo(e,{isForced:!0})}function ao(){for(let e of $a.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{no(e),e.needsWebGLReload=!0}}}var oo=!1;function so(){oo||(oo=!0,requestAnimationFrame(()=>{oo=!1,ao()}))}function co(e){e?.addEventListener(`contextrestored`,so)}function lo(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){$a.delete(e),$a.set(e,!0);return}e.webglAddon&&(to(e),$a.delete(e));let n=Xa();if(!n)return;ro(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,$a.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(co),r.onAddTextureAtlasCanvas(co),co(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!eo(e.termWrap),$a.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,$a.delete(e)}}var uo=`(max-width: 768px)`,fo=`(pointer: coarse)`;function po({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var mo=window.matchMedia?.(fo),ho=window.matchMedia?.(uo);function go(){return po({coarse:!!mo?.matches,narrowWidth:!!ho?.matches})}function _o(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function vo(){M.subscribe((e,t)=>{t.includes(`layout`)&&_o(e.layout)});let e=go();_o(e),M.dispatch(`setLayout`,e);let t=()=>M.dispatch(`setLayout`,go());return mo?.addEventListener?.(`change`,t),ho?.addEventListener?.(`change`,t),e}function yo(){return M.snapshot().layout===`phone`}function bo(e){return M.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var xo=``,So=`\x1B`,Co=`\r`,wo=new Map([[`deleteContentBackward`,xo],[`deleteByComposition`,xo],[`deleteCompositionText`,xo],[`deleteWordBackward`,So],[`deleteSoftLineBackward`,So],[`deleteHardLineBackward`,So]]);function To(e){return wo.get(e)??``}var Eo=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function Do(e){return typeof e!=`string`||e===``||!Eo.has(e)}function Oo(e){return e?e.keyCode===229||e.key===`Process`:!1}function ko(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 xo.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,Co)}var Ao=`Upload`;async function jo(e,t){return zn(Ao,e),No(e,t)}async function Mo(e,t){zn(Ao,e);for(let n of t)await No(e,n)}async function No(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:(Bn({source:Ao,sessionId:e,message:await Po(r,t.name)}),!1)}catch{return Bn({source:Ao,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 Po(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 Fo=new WeakMap,Io=5e3,Lo=15e3,Ro=`The agent copied text. The browser needs a click before it can reach your clipboard.`,zo=`The clipboard is unavailable in this browser.`;function Bo(e,t,n,r){let i=Fo.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(()=>Vo(e,t),n===`ok`?Io:Lo)))}function Vo(e,t){let n=Fo.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function Ho(e){let t=e.buffer.active;return t.viewportY<t.baseY}function Uo(e,t,{hasNewOutput:n=!1}={}){let r=Fo.get(e)?.jumpToLatest;if(!r)return;let i=Ho(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function Wo(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 Go(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),Bo(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function Ko(e,t,n,r){let i=zt(t);i?i.then(()=>{r&&Bo(e,`clipboard`,`ok`,r)}).catch(t=>Go(e,n,t)):Bo(e,`clipboard`,`error`,zo)}function qo(e,t){let n=Fo.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function Jo(e){let t=Fo.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,Ko(e,n,`osc52 write`,`Copied to the clipboard.`))}function Yo(e,t,n){let r=Rn(`terminal-notice`),i=D(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=w({variant:`primary`,label:`Copy to clipboard`,onClick:()=>Jo(t)});i.append(D(`span`,`terminal-clipboard-prompt-text`,Ro),a);let o=D(`div`,`terminal-notices`);o.append(i,r.element);let s=D(`div`,`terminal-jump-latest`);s.hidden=!0,s.append(w({variant:`secondary`,label:`Jump to latest`,onClick:()=>{n.scrollToBottom(),n.focus()}}),D(`span`,`terminal-jump-latest-new-output`));let c=D(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(D(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),Fo.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatest:s})}var Xo=1024,Zo=`Keys you type now are held and sent once the terminal reconnects.`,Qo=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,$o=!1;function es(e){let t=e._inputQueue,n=e.dataWs;if(!$o&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,Vo(e,`keys`)}}function ts(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!$o&&!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>=Xo?(Bo(e,`keys`,`error`,Qo),!1):(e._inputQueue.push(t),r&&Bo(e,`keys`,`busy`,Zo),!0)}function ns(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,yo()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=ko(i,r.value);return i=r.value,e!==``&&(ts(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{yo()?n(e):a()},!0)};c(`keydown`,e=>{Oo(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(!Do(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=To(e.inputType);r!==``&&(ts(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function rs(e){return!!e&&Array.from(e.types).includes(`Files`)}function is(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),Mo(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{rs(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,rs(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),Mo(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function as(e){$o=e}var os=6,ss=262144,cs=16384,ls=()=>{};function us(e,t){if(t.length<=cs)e.push(t);else for(let n=0;n<t.length;n+=cs)e.push(t.slice(n,n+cs))}function ds({budget:e=os,maxChunkBytes:t=ss,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)us(l,e),m+=e.length,a.readIdx++;else{m===0&&(us(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,ls);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 fs=ds(),ps=ae().int().min(1).max(500),ms=ae().int().min(1).max(200);ie(`type`,[x({type:b(`input`),data:ne()}),x({type:b(`claim`),cols:ps,rows:ms}),x({type:b(`unview`)}),x({type:b(`pause-output`)}),x({type:b(`resume-output`)})]);var hs=x({type:b(`pty-size`),cols:ps,rows:ms,seq:ae().int().nonnegative()}),gs=x({type:b(`output-beat`)}),_s=ie(`type`,[hs,gs]),vs=`history`,ys=`output`,bs=`paused`;re([`screen`,`deep`]);function xs(e){try{return JSON.parse(e)}catch{return null}}function Ss(e){let t=_s.safeParse(xs(e));return t.success?t.data:null}var Cs=new Set([1,5,25,100]);function ws(e){return e.isOutputPaused?`${e.history} paused`:e.history}function Ts(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function Es(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function Ds(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function Os({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&Ts(e,n))}function ks({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function As({isBorrowedCard:e,isTerminalFaceShown:t}){return!e||!t}function js({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function Ms(e,t,n){let r=new URLSearchParams;t&&r.set(vs,`deep`),n&&r.set(ys,bs);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function Ns({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:Os({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function Ps({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function Fs({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!Ts(e,t),s=Es(n)?Ds(n):null,c=r&&!!s&&!Ts(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:Os({authoritative:e,isActiveViewer:r,lastClaim:a})}}function Is(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function Ls(e){let t=Is(e);return t===null?null:Ss(t)}function Rs(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=Ls(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 zs=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,Bs=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,P=`[^\\S\\r\\n]`,Vs=`${zs}${P}*(?:=>|[:=])${P}*`,Hs=`[?&][A-Za-z0-9_.-]*`,Us=`[^\\r\\n;&|]{0,200}?`,Ws=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,Gs=RegExp(`(${Vs})${Bs}`,`gi`),Ks=RegExp(`(\\bBearer${P}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),qs=[/\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],Js=[RegExp(`((?:^|\\s)--?${zs}${P}+)${Bs}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${P}*=?${P}*)${Bs}`,`g`),RegExp(`(-AsPlainText${P}+)${Bs}`,`gi`),RegExp(`((?:^|\\s)setx${P}+[^\\s\\r\\n]*${zs}[^\\s\\r\\n]*${P}+)${Bs}`,`gi`)],Ys=[RegExp(`(\\bauthorization${P}*:${P}*Basic${P}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${P}+login\\b${Us}${P}-p(?:${P}+|=))${Bs}`,`gi`),RegExp(`(\\bcurl\\b${Us}${P}(?:--user|-u)(?:${P}+|=)[^\\s:\\r\\n]+:)${Bs}`,`gi`),RegExp(`(\\b${Ws}\\b${Us}${P}-p)${Bs}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi],Xs=[/-----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],Zs=RegExp(`(${Hs}(?:${zs}|_key)=)[^&#\\s]+`,`gi`),Qs=[Gs,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${Bs}`,`g`)],$s=[Ks,...Js,...Ys,...qs,...Xs];function ec(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function tc(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 nc(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 rc(e){let t=ec(e,Zs);return nc([...t,...Qs.flatMap(n=>tc(ec(e,n),t)),...$s.flatMap(t=>ec(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var ic=`glimmervoid-streamer-mode`,ac=new Set,oc=er(ic,!1)===!0;function sc(e){document.documentElement.toggleAttribute(`data-streamer`,e)}sc(oc);function cc(){return oc}function lc(e){if($n(ic,e),e!==cc()){oc=e,sc(e);for(let t of ac)t(e)}}function uc(e){return ac.add(e),()=>ac.delete(e)}async function dc(e){try{let t=await a(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:Un});return t.type===`settings-error`?String(t.message):(lc(e),``)}catch(e){return Hn(e,Un)}}var fc=`Streamer mode`;async function pc(){let e=!cc();e&&lc(!0);let t=await dc(e);t?Bn({source:fc,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}):zn(fc)}function mc(){pc()}var hc=`#808080`,gc=new WeakMap;function _c(e,t,n){return`${e}:${t}:${n}`}function vc(e){return _c(e.marker.line,e.x,e.width)}function yc(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function bc(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function xc(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function Sc(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 Cc(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 wc(e,t,n,r){let i=[];if(rc(xc(e,t,n)).length===0)return i;let{text:a,cellAt:o}=Sc(e,t,n,r);for(let e of rc(a))Cc(i,o.slice(e.start,e.end));return i}function Tc(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=bc(e,i);r.push(...wc(e,i,t,n)),i=t+1}return r}function Ec(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function Dc(e){e.decoration.dispose(),e.marker.dispose()}function Oc(e){for(let t of e.masks)Dc(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function kc(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function Ac(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 jc(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(vc(r),r),r=e.masks.at(-1);return Ac(e),n}function Mc(e,t){let n={normal:Ec(),alternate:Ec()},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??hc,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(!cc())return;let t=e.buffer.active,r=n[t.type],i=yc(t,kc(r,t)),a=jc(r,i);for(let e of Tc(t,i)){let n=_c(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())Dc(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){Oc(n.normal),Oc(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=>{Oc(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=uc(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),gc.delete(e)},{once:!0}),gc.set(e,d)}function Nc(e){gc.get(e)?.()}function Pc({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var Fc=`-4 -4 108 108`,Ic=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`}]),Lc=`M50 39L61 50L50 61L39 50Z`,Rc=11,zc=`#e8e0ff`,Bc=`#c084fc`;function Vc({frame:e,light:t,strokeWidth:n=Rc}){return`<path d="${Ic.map(({d:e})=>e).join(``)}" fill="none" stroke="${e}" stroke-width="${n}" stroke-linejoin="miter" stroke-linecap="butt"/><path d="${Lc}" fill="${t}"/>`}function Hc(e,t){return As({isBorrowedCard:M.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var Uc=new WeakMap,Wc=new WeakMap,Gc=new WeakSet,Kc=new WeakSet,qc=new WeakSet;function Jc(e,t){if(Uc.has(e)||!Ho(t))return;let n=t.buffer.active,r=n.length-n.viewportY;Gc.has(e)?Uc.set(e,r):Wc.set(e,r)}function Yc(e,t,n){let r=e.term;r&&js({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:Gc.has(e)})&&(Gc.add(e),Kc.add(e),Uc.set(e,r.buffer.active.length-n),Cl(t))}var Xc=new WeakMap;function Zc(e,t){return document.visibilityState===`visible`&&!Hc(e,t)}function Qc(e,t){if(e&&pl(e,t))return;let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=Zc(e,t);Xc.get(n)!==r&&(Xc.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function $c(){for(let[e,t]of k)Qc(t,e)}document.addEventListener(`visibilitychange`,$c),M.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&$c()});function el(e,t){return k.get(e)===t&&!t.dataWs}function tl(e){return e.querySelector(`:scope > .terminal-connecting`)}function nl(){let e=se(`svg`,{class:`loading-mark`,viewBox:Fc,"aria-hidden":`true`});for(let{side:t,d:n}of Ic)e.append(se(`path`,{class:`loading-mark-bracket`,"data-side":t,d:n}));return e}function rl(e){if(tl(e))return;let t=D(`div`,`terminal-connecting`);t.append(nl(),D(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}var il=new Set,al=new WeakSet;function ol(e){return il.add(e),()=>il.delete(e)}function sl(){let e=0;for(let[t,n]of k)n.card.dataset.link===`connecting`&&Zc(n,t)&&e++;return e}function cl(e){let t=Pc({hasTerminal:e.term!==null||al.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:$o}),n=t===`connecting`&&!$o&&Kc.has(e)?`live`:t;n===`none`?(delete e.card.dataset.link,ll()):(e.card.dataset.link=n,ll())}function ll(){for(let e of il)e()}function ul(e,t,n){Jc(t,n),fs.unregister(e),t.dataWs=null,cl(t),t._resetGridClaim?.()}var dl=new WeakMap;function fl(e,t,r,i){ul(e,t,r),clearTimeout(dl.get(t)),dl.delete(t),i===0&&y()?Sl(e,t,r):dl.set(t,setTimeout(()=>{dl.delete(t),el(e,t)&&n().catch(()=>{}).then(()=>{el(e,t)&&Sl(e,t,r)})},i))}function pl(e,t){let n=qc.has(e),r=!e.dataWs&&k.get(t)===e;return!(n||r)||!e.term||!Zc(e,t)?!1:(qc.delete(e),e._dataWsRetryAttempt=0,fl(t,e,e.term,0),!0)}function ml(e,t,n){ul(e,t,n),qc.add(t)}var hl=15e3,gl=new Map;function _l(e){if(!y()||gl.has(e)||k.get(e)?.dataWs)return;let n=Ms(e,!1,!1),r=new WebSocket(t(location,te(n)));r.binaryType=`arraybuffer`;let a=[],o=e=>a.push(e),s=()=>vl(e,r),c=()=>{r.readyState===WebSocket.CONNECTING&&s()};r.addEventListener(`message`,o),r.addEventListener(`close`,s);let l=setTimeout(c,i),u=setTimeout(s,hl);gl.set(e,{socket:r,attachPath:n,bufferedMessages:a,release:()=>{r.removeEventListener(`message`,o),r.removeEventListener(`close`,s),clearTimeout(l),clearTimeout(u)}})}function vl(e,t){let n=gl.get(e);n?.socket===t&&(gl.delete(e),n.release(),t.close())}function yl(e,t){let n=gl.get(e);if(!n)return null;let r=n.socket.readyState===WebSocket.CONNECTING||n.socket.readyState===WebSocket.OPEN;return n.attachPath!==t||!r?(vl(e,n.socket),null):(gl.delete(e),n.release(),n)}var bl=new WeakMap;function xl(e,t,n){if(t.openedAtMs===null)return;let r=Math.round(performance.now()-t.openedAtMs);if(r>=1e3){bl.delete(e);return}let i=(bl.get(e)??0)+1;if(bl.set(e,i),!Cs.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 Sl(n,r,a){qc.delete(r);let o=Uc.get(r);Uc.delete(r);let c=Wc.get(r);Wc.delete(r);let l=o!==void 0,u=o??c,d=!1,f=Zc(r,n),p=Ms(n,l,!f),m=yl(n,p),h=m?.socket??new WebSocket(t(location,te(p)));Xc.set(h,f),h.binaryType=`arraybuffer`,r.dataWs=h,f&&Ua(`terminal-connecting`),cl(r);let g=!1,_=!1,v={sessionId:n,attachDescription:ws({history:l?`deep`:`screen`,isOutputPaused:!f}),openedAtMs:null,hasReceivedBytes:!1},y={hasSeenSize:!1,lastSeq:0},ee=setTimeout(()=>{h.readyState===WebSocket.CONNECTING&&(_=!0,f&&Ua(`terminal-abandoned`),h.close())},i);fs.register(n,(e,t)=>a.write(e,t));let b=e=>{if(r.dataWs!==h)return;let t=Rs(e.data,y);if(t.kind===`bytes`){v.hasReceivedBytes=!0,Yn(r),Xc.get(h)&&Ua(`terminal-bytes`);let e=d;if(d=!1,fs.enqueue(n,t.data),!e)return;let i=u??0;fs.enqueueAction(n,()=>{a.scrollToLine(Math.max(0,a.buffer.active.length-i))});return}if(t.kind===`beat`){Yn(r);return}if(t.kind===`attach-size`){d=u!==void 0,l||Gc.delete(r),y.hasSeenSize=!0,y.lastSeq=t.seq,a.reset(),Nc(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};fs.enqueueAction(n,()=>{r.ptySize=i,r._syncGrid?.()})};h.addEventListener(`message`,b),h.addEventListener(`close`,t=>{if(clearTimeout(ee),r.dataWs!==h)return;if(xl(r,v,t),f&&!_&&Ua(`terminal-closed`),Kc.delete(r),!g&&!_&&s(),!Zc(r,n)){ml(n,r,a);return}if(_){fl(n,r,a,0);return}let i=e(r._dataWsRetryAttempt||0);r._dataWsRetryAttempt=(r._dataWsRetryAttempt||0)+1,fl(n,r,a,i)});let x=()=>{clearTimeout(ee),g=!0,v.openedAtMs=performance.now(),f&&Ua(`terminal-opened`),r._dataWsRetryAttempt=0,Kc.delete(r),cl(r),Qc(r,n),r._syncGrid?.({isActivationEdge:!0}),r._retryOwedGridClaim?.(),r._inputQueue?.length&&setTimeout(()=>{r.dataWs===h&&es(r)},50)};h.addEventListener(`open`,x),h.readyState===WebSocket.OPEN&&x();for(let e of m?.bufferedMessages??[])b(e)}function Cl(e){let t=A(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,fl(e,t,t.term,0),n?.close()}function wl(){for(let[e,t]of k)t.term&&(Zc(t,e)?Cl(e):Tl(e,t,t.term))}function Tl(e,t,n){let r=t.dataWs;r&&(ml(e,t,n),r.close())}function El(){for(let[e,t]of k)t.term&&Tl(e,t,t.term)}function Dl(e,t){let n=e.dataWs;e.dataWs=null,fs.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}var Ol=`CommitMono`,kl=[400,700].map(e=>`${e} 14px ${Ol}`),Al=`monospace`;function jl(e){return e.trim().replace(/^['"]|['"]$/g,``)}function Ml(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>jl(e)!==Ol);return r.length>0?r.join(`, `):Al}function Nl(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function Pl(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function Fl(){return document.fonts?kl.every(e=>document.fonts.check(e)):!1}function Il(){return Ml(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),Fl())}function Ll(e){document.fonts&&Nl(document.fonts,kl,e)}var Rl=Ur(navigator.userAgent),zl=`next-attention-keys`,Bl=Er();function Vl(){return Bl}function Hl(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(D(`span`,`shortcut-sep`,`+`)),e.appendChild(D(`kbd`,`kbd`,t))})}function Ul(e){let t=D(`span`,`shortcut-keys`);return Hl(t,e),t}function Wl(){let e=Ul(Gr(`next-attention`,Rl,Bl));return e.classList.add(zl),e}function Gl(e){Bl=e;let t=Gr(`next-attention`,Rl,e);for(let e of document.querySelectorAll(`.${zl}`))e.replaceChildren(),Hl(e,t)}var Kl=/\bElectron\/\d/,ql=new Set([`localhost`,`127.0.0.1`]);function Jl(e){return Kl.test(e)}function Yl({userAgent:e,pageHostname:t}){return Jl(e)&&ql.has(t)}function Xl(e){return qr(e)!==null}var Zl=new Set([0,1]);function Ql({button:e,opensInNewTab:t}){return t&&Zl.has(e)}function $l(){return Yl({userAgent:navigator.userAgent,pageHostname:location.hostname})}function eu(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function tu(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}}function nu(e){!$l()||!Xl(e)?eu(e):tu(e).then(t=>{t||eu(e)})}function ru(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&Ql({button:e.button,opensInNewTab:t.target===`_blank`})&&Xl(t.href)&&(e.preventDefault(),nu(t.href))}function iu(e){$l()&&(e.addEventListener(`click`,ru,!0),e.addEventListener(`auxclick`,ru,!0))}var au=/https?:\/\/[^\s<>"']+/g,ou=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),su={")":`(`,"]":`[`,"}":`{`};function cu(e,t){let n=0;for(let r of e)r===t&&n++;return n}function lu(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(ou.has(t)){e=e.slice(0,-1);continue}let n=su[t];if(n&&cu(e,n)<cu(e,t))e=e.slice(0,-1);else return e}}function uu(e){let t=[];for(let n of e.matchAll(au)){let e=lu(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var du=50;function fu(){return{activate(e,t){nu(t)},allowNonHttpProtocols:!1}}function pu(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<du;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<du;)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 mu(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=pu(r,t),o=[];for(let{start:e,end:t,url:n}of uu(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){nu(t)}})}n(o.length?o:void 0)}})}var hu=10,gu=1.2,_u=.005,vu=4,yu=.08,bu=5;function xu(e,t){let n=Math.abs(t);return n<hu?!1:n>Math.abs(e)*gu}function Su(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 Cu(e,t,n){let r=e.length>=vu?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function wu(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>=yu))return 0;let o=Math.min(a,bu);return i<0?-o:o}function Tu({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function Eu(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)-_u*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=Su(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function Du(e,t){return e===`alternate`||!!t&&t!==`none`}function Ou(e,t){return!(e>0)||!(t>0)?0:e/t}var ku=1;function Au(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function ju(e,t){for(let n of e)if(n.identifier===t)return n;return null}function Mu(e,t){if(Au(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=()=>Du(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return Ou(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:ku,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}=Eu(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=Tu({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=ju(e.touches,r);if(!u)return;if(!s){if(!xu(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=Cu([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=Cu(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=Su(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=Cu(l,o,e.timeStamp);let t=wu(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function Nu(e){let t=mr(e,Rl,{isTerminalFocused:!0},Vl());return t?Or(t,document.body.dataset.activeView):!1}var Pu=250,Fu=`(max-width: 768px)`,Iu=12,Lu=14,Ru=5e4,zu=!1;function Bu(e){zu=e}var Vu=!1;window.addEventListener(`blur`,()=>{Vu=!0}),window.addEventListener(`focus`,()=>{Vu=!1});function Hu(e){let t=document.activeElement;return ks({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:Vu,isPhoneLayout:yo()})}function Uu(e,t,n){let r=window.matchMedia?.(Fu).matches?Iu:Lu,i=new n.Terminal({cursorBlink:zu,fontSize:r,fontFamily:Il(),theme:wa(),scrollback:Ru,allowProposedApi:!0,linkHandler:fu()}),a=new n.FitAddon;i.loadAddon(a),rl(e),i.open(e),Yo(e,t,i),mu(i),Mc(i,t.abortController.signal),t.term=i,t.fitAddon=a,no(t);let o=null,s=null,c=!1,l=null,u=null;function d(){s!==null&&(clearTimeout(s),s=null)}function f(){if(!c)return null;let e=t.fitAddon;if(!e)return null;let n=e.proposeDimensions();return n?{cols:n.cols,rows:n.rows}:null}function p(e){if(!c||!Hu(t.card)||t.dataWs?.readyState!==WebSocket.OPEN)return!1;t.dataWs.send(JSON.stringify({type:`claim`,cols:e.cols,rows:e.rows})),l=e,u=null;let n=Os({authoritative:t.ptySize??null,isActiveViewer:c,lastClaim:l});return t.card.dataset.grid=n?`following`:`exact`,!0}function m(e){d(),u=e,s=setTimeout(()=>{s=null,p(e)},Pu)}function h(){u&&s===null&&p(u)}function g({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=Fs({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:f(),isActiveViewer:c,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});r.resizeTo&&n.resize(r.resizeTo.cols,r.resizeTo.rows),t.card.dataset.grid=r.isFollowing?`following`:`exact`,r.keepsPendingSettle||(d(),u=null),r.sendUnview?(l=null,t.dataWs?.send(JSON.stringify({type:`unview`}))):r.owedClaim&&(e&&p(r.owedClaim)||m(r.owedClaim))}function _(){let e=Ns({authoritative:t.ptySize??null,isActiveViewer:c,isDocumentEngaged:Hu(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});e!==`none`&&(d(),e===`rebid`&&(l=null),g({isActivationEdge:!0}))}let v=new ResizeObserver(()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,g()}))});v.observe(e),t.resizeObserver=v,t._syncGrid=g,t._resetGridClaim=()=>{d(),u=Ps({isActiveViewer:c,lastClaim:l,owedClaim:u}),l=null},t._retryOwedGridClaim=h,t._syncGridOnEngagementEdge=_,t._isActiveViewer=()=>c,t._setActiveViewer=e=>{c!==e&&(c=e,d(),u=null,e&&io(t),g({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{Vu=!1,_()},{signal:t.abortController.signal}),lo(t);let y=null;i.onScroll(()=>{y===null&&(y=requestAnimationFrame(()=>{y=null,t.term&&(t.term.refresh(0,t.term.rows-1),Uo(t,t.term))}))}),i.onWriteParsed(()=>Uo(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=Wo(r)}catch(e){return Go(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(Ko(t,i,`osc52 write`),!0):(qo(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`&&ts(t,`\x1B\r`),!1;if(e.type!==`keydown`)return!0;if(Nu(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),Ko(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(ts(t,`\x1B`),!1):!0}),ns(e,i,t),Mu(e,i)}function Wu(){as(!0);for(let e of k.values())cl(e)}function Gu(){as(!1);for(let e of k.values())cl(e),es(e)}function Ku(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{ts(e,n),e.unseenOutcome&&v({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{Yc(e,t,n)}),is(e.termWrap,t,e.abortController.signal),cl(e),queueMicrotask(()=>{el(t,e)&&Sl(t,e,n)}))}function qu(e,t){if(e.term||al.has(e))return;let n=Xa();if(n){Ju(e,t,n);return}al.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},rl(e.termWrap),cl(e),Za().then(n=>{al.delete(e),!(e.term||e.abortController.signal.aborted||k.get(t)!==e)&&(Ju(e,t,n),e._setActiveViewer?.(r))},()=>{al.delete(e),cl(e)})}function Ju(e,t,n){Uu(e.termWrap,e,n),Ku(e,t)}function Yu(e){e?._syncGridOnEngagementEdge?.()}function Xu(e,t){if(!e)return;qu(e,t),Qc(e,t),io(e);let n=e.term;n&&(n.refresh(0,n.rows-1),Yu(e))}function Zu(e,t,n){e&&(n&&qu(e,t),e._setActiveViewer?.(n))}var Qu={isVisible:document.visibilityState===`visible`,isFrozen:!1,isProbing:!1,isReplacing:!1},$u=document.visibilityState===`visible`?null:Date.now(),ed=null,td=null;function nd(){ed!==null&&window.clearTimeout(ed),ed=null}function rd(e){nd();let t=Date.now()+e;ed=window.setTimeout(()=>{ed=null,od({kind:`heartbeat-due`,lateByMs:Date.now()-t})},e)}function id(){td!==null&&window.clearTimeout(td),td=null}function ad(e){switch(e.kind){case`probe-control`:p(e.deadlineMs,e.isAnnounced).then(e=>{od({kind:e?`pong`:`pong-missed`})});return;case`replace-control`:g();return;case`close-sockets`:id(),_(),El();return;case`reconnect-shown-terminals`:wl();return;case`hold-input`:Wu();return;case`release-input`:Gu();return;case`schedule-heartbeat`:rd(e.inMs);return;case`cancel-heartbeat`:nd();return}}function od(e){let t=ee(Qu,e);Qu=t.state;for(let e of t.actions)ad(e)}function sd(){if(document.visibilityState!==`visible`){$u=Date.now(),od({kind:`hidden`});return}let e=$u===null?0:Date.now()-$u;$u=null,Ga(`shown`,e),od({kind:`shown`,hiddenForMs:e})}function cd(e){id(),Ua(`control-${e}`),e===`connecting`?td=window.setTimeout(()=>{td=null,od({kind:`handshake-overdue`})},i):(e===`opened`&&Da(),od({kind:e===`opened`?`control-opened`:`control-closed`}))}function ld(){Ga(`resumed`,$u===null?0:Date.now()-$u),od({kind:`resumed`})}function ud(){let e=Reflect.get(navigator,`connection`);e instanceof EventTarget&&e.addEventListener(`change`,()=>{Wa(`link`),od({kind:`network-changed`})})}function dd(){r(cd),document.addEventListener(`visibilitychange`,sd),document.addEventListener(`freeze`,()=>od({kind:`frozen`})),document.addEventListener(`resume`,ld),window.addEventListener(`pagehide`,e=>{e.persisted&&od({kind:`frozen`})}),window.addEventListener(`pageshow`,e=>{e.persisted&&ld()}),window.addEventListener(`online`,()=>{Wa(`online`),od({kind:`network-changed`})}),window.addEventListener(`offline`,()=>Wa(`offline`)),ud()}var fd=!1,pd=!1,md=!1,hd=null,gd=null;function _d(){return gd??=N(()=>import(`./nyan-cat-DQg7Jylj.js`).then(e=>e.r).then(e=>(hd=e,e),e=>(gd=null,u(`flying-animals`,`nyan cat failed to load: ${d(e)}`),null)),__vite__mapDeps([2,1,3,4,5,6,7,8])),gd}function vd(e){!md||e.currentFlightBlockReason(!0)?e.stopNyanCat():e.startNyanCat()}function yd(){pd=!0,bd(Wr())}function bd(e){let t=document.documentElement;fd||(fd=!0,bo(()=>bd(Wr())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>bd(Wr()))),md=e,e?(t.dataset.flyingAnimals=`true`,hd?vd(hd):pd&&_d().then(e=>{e&&vd(e)})):(delete t.dataset.flyingAnimals,hd?.stopNyanCat())}var xd=45e3,Sd=`The server did not answer within ${xd/1e3} s.`,Cd=`Select the issue to load its description.`,wd=null,Td=null,Ed=new Map,Dd=null,Od=new Map,kd=new Map,Ad=null,F=new Map,jd=new Map,Md=new Map,Nd=new Map,Pd=new Set;function I(e){for(let t of Pd)t(e)}function Fd(e){return`${e.key}:${e.updatedAt}`}function Id(e){let t=Od.get(e);t&&(Od.delete(e),F.set(t.issueKey,{text:Sd,tone:`error`}),I(`detail`))}function Ld(e){let t=Od.get(e);return t?(clearTimeout(t.timeoutHandle),Od.delete(e),t):null}function Rd(){return{latestStatus:Td,issueByKey:Ed,selectedKey:wd}}function zd(e){Pd.add(e)}function Bd(e){wd=e,Ad&&Ad.issue.key!==e&&(Ad=null)}function Vd(){if(wd)return Ed.get(wd)??(Ad?.issue.key===wd?Ad.issue:void 0)}function Hd(e){return Ad?.issue.key===e.key&&Ad.isClosed}function Ud(e){return[...kd.values()].some(t=>t.issue.key===e.key)}function Wd(e,t){if(Ud(e))return;let n=h(`set-issue-state`);Dd?.({type:`set-issue-state`,requestId:n,repo:e.repo,issueNumber:e.number,state:t})?(kd.set(n,{issue:e,state:t,timeoutHandle:setTimeout(()=>{kd.delete(n),F.set(e.key,{text:Sd,tone:`error`}),I(`detail`)},xd)}),F.set(e.key,{text:t===`closed`?`Closing issue.`:`Reopening issue.`,tone:`busy`}),I(`detail`)):(F.set(e.key,{text:De,tone:`error`}),I(`detail`))}function Gd(e){let t=kd.get(e.requestId);if(!t)return;clearTimeout(t.timeoutHandle),kd.delete(e.requestId);let{issue:n,state:r}=t;e.ok?(Ad={issue:n,isClosed:r===`closed`},F.set(n.key,{text:r===`closed`?`Closed as completed.`:`Reopened.`,tone:`ok`}),I(`detail`)):(F.set(n.key,{text:e.error||`Could not ${r===`closed`?`close`:`reopen`} the issue.`,tone:`error`}),I(`detail`))}function Kd(e){return[...Od.values()].some(t=>t.issueKey===e.key)}function qd(e){return F.get(e.key)}function Jd(e){let t=Fd(e),n=Md.get(t);return n===``?`No description.`:n??Nd.get(t)??`Loading description.`}function Yd(e){let t=Fd(e);if(Md.has(t)||[...jd.values()].some(e=>e.cacheKey===t))return;let n=h(`issue-detail`);Nd.delete(t),Dd?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?jd.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{jd.delete(n),Nd.set(t,`${Sd} ${Cd}`),I(`detail`)},xd)}):Nd.set(t,`${De} ${Cd}`)}function Xd(e){let t=e.projectId;if(!t||Kd(e))return;let n=h(`open-issue-session`);Dd?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(Od.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>Id(n),xd)}),F.set(e.key,{text:`Opening session.`,tone:`busy`}),I(`detail`)):(F.set(e.key,{text:De,tone:`error`}),I(`detail`))}function Zd(e){Dd?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function Qd(e){Dd=e}function $d(){I(`session-state`)}function ef(e){if(!e){for(let e of Od.values())clearTimeout(e.timeoutHandle),F.set(e.issueKey,{text:De,tone:`error`});Od.clear();for(let e of kd.values())clearTimeout(e.timeoutHandle),F.set(e.issue.key,{text:De,tone:`error`});kd.clear();for(let e of jd.values())clearTimeout(e.timeoutHandle),Nd.set(e.cacheKey,`${De} ${Cd}`);jd.clear(),I(`status`)}}function tf(e){let t=Td?.issues.find(e=>e.key===wd);Td=e,Ed=new Map(e.issues.map(e=>[e.key,e])),Ad&&!Ad.isClosed&&Ed.has(Ad.issue.key)&&(Ad=null);let n=e.issues.find(e=>e.key===wd);n&&n.updatedAt!==t?.updatedAt&&Yd(n),I(`status`)}function nf(e){let t=jd.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),jd.delete(e.requestId),e.ok&&e.body!==null&&Md.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&Nd.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),I(`detail`))}function rf(e){if(typeof e.requestId!=`string`)return;let t=Ld(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`;F.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=Td?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),I(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;F.set(n,{text:r,tone:`error`}),I(`detail`)}var af=new Map,of=new Set;function sf(e){let t=Se.safeParse(e);if(!t.success)u(`reviews`,`dropped github-prs: ${c(t.error.issues)}`);else{af=new Map(Object.entries(t.data.prs));for(let e of of)e()}}function cf(e){return af.get(e.toLowerCase())}function lf(e){of.add(e)}var uf=20,df=[],ff=null,pf=!1,mf=0,hf=null;function gf(){return hf??=N(()=>import(`./celebration-player-B6pp3XJS.js`),__vite__mapDeps([9,3,4,5,6,7,10])).catch(e=>(hf=null,u(`merge-celebration`,`celebration player failed to load: ${d(e)}`),null)),hf}function _f(e){return pf?`playing`:e?`queued`:`empty`}function vf(){if(!ff)return;let e=df.length>0,t=_f(e);ff.tray.dataset.state=t,ff.count.textContent=e?String(df.length):``,ff.toggle.element.disabled=t!==`queued`,ff.toggle.setState(t===`queued`?`attention`:`idle`)}function yf(){let e=df.shift();if(pf=e!==void 0,vf(),!e)return;let t=mf;mf+=1,gf().then(n=>{n?(n.playCelebration(e,t),window.setTimeout(yf,n.CELEBRATION_DURATION_MS)):(df.unshift(e),pf=!1,vf())})}function bf(e,t,n){ff={tray:e,toggle:t,count:n},t.element.addEventListener(`click`,()=>{mf=0,yf()}),vf()}function xf(e){df.push(e),df.length>uf&&df.shift(),vf()}var Sf={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},Cf=new Set([`FAILURE`,`ERROR`]);function wf(e){return Sf[e]}function Tf(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&&Cf.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function Ef(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 Df(e){let t=st.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:Ef(t)}}var Of=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],kf=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],Af={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`},jf={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`},Mf={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`},Nf={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 Pf(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 Ff(e){return Of[e.rows.reduce((e,{pr:t})=>Math.min(e,Of.indexOf(Af[t.stage])),Of.length-1)]}function If(e){let t=new Map(Of.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of Pf(e)){let e=t.get(Ff(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return kf.flatMap(e=>t.get(e)??[])}function Lf(e,t){return Pf(e).find(e=>e.rows.some(e=>e.pr.key===t))?.rows??[]}function Rf(e){return e.stackSize<2?null:`Stack ${e.depth+1}/${e.stackHeight}`}function zf(e){return jf[e]}function Bf(e){return Mf[e]}function Vf(e){return Nf[e]}function Hf(e){return e?.isKeepMergeableEnabled!==!1}function Uf(e,t){if(!t||!e.keepMergeable||e.isKeepMergeableFixInFlight)return!1;let n=e.keepMergeableAttempt?.outcome;return n!==void 0&&n!==`pushed`&&n!==`stopped`}function Wf(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...Df({...n,repo:r}),...e}]})}function Gf(e){let t=new Map;for(let n of e)for(let e of n.links){let r=Ke(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 Kf(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 qf=3;function Jf(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,qf).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 Yf(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:de(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,isAuthorOrgMember:n.isAuthorOrgMember,liveHead:n.headRefOid,prStage:Df(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n)}}var Xf=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`];function Zf(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 Qf(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function $f(e){return e.status===`posted`&&ep(e)}function ep(e){if(!Qf(e)||Dt(e))return!1;let t=ap(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 tp(e){return op(e).length>0||$f(e)}function np(e){return tp(e)?`actionable`:Zf(e).band}function rp(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[Zf(t).band].push(t);for(let e of Xf)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(tp(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!sp(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[np(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 Xf)t.ready.push(...n[e]);return t}function ip(e,t){return e.commit===t?e.isViewer||Mt.has(e.state):!1}function ap(e){return e.liveHead??e.reviewedHead}function op(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function sp(e){return op(e).length>0?!0:Dt(e)?!1:ep(e)?!0:!(e.githubReviews??[]).some(t=>ip(t,ap(e)))}function cp(e,t){return`${e}#${t}`}var lp=null,up={},dp=[],fp=[],pp={},mp={},hp=[],gp={},_p={},vp={},yp=null,bp=new Set,xp=new Map,Sp=!1,Cp=new Set;function wp(e){for(let t of Cp)t(e)}function Tp(){return[...xp].flatMap(([e,t])=>{let n=k.get(e);return!n||t.length===0?[]:[{id:e,title:Tn(n)||e,links:t}]})}function Ep(){let e=Wf(lp?.prs??[],cf),t=Kf(yp,e);yp=e,Ap(t),wp({kind:`prs`})}function Dp(){Sp||(Sp=!0,queueMicrotask(()=>{Sp=!1,Ep()}))}function Op(e){Cp.add(e)}function kp(){return{prs:Wf(lp?.prs??[],cf).map(e=>({...e,reviewItems:mp[e.key]??e.reviewItems})),status:lp,sessionsByPrKey:Gf(Tp()),handledByPr:up,prFlowWarnings:dp,prFlowApprovals:fp,sourceRunsByPr:pp,prFlowActions:hp,actionRunsByPr:gp,prActionsByPr:_p,prActionRunsByPr:vp}}function Ap(e){let t=e.filter(e=>!bp.has(e.key));if(t.length!==0){for(let e of t)bp.add(e.key);xf(Jf(t))}}function jp(e){xp=e,Dp()}function Mp(){wp({kind:`session-state`})}function Np(e){let t=Ye.safeParse(e);t.success?(lp=t.data,Ep()):u(`reviews`,`dropped my-prs-status: ${c(t.error.issues)}`)}function Pp(e){let t=ft.safeParse(e);t.success?(up=t.data.handledByPr,dp=t.data.warnings,fp=t.data.pendingApprovals,pp=t.data.sourceRunsByPr,mp=t.data.reviewItemsByPr,hp=t.data.actions,gp=t.data.actionRunsByPr,_p=t.data.prActionsByPr,vp=t.data.prActionRunsByPr,wp({kind:`prs`})):u(`reviews`,`dropped pr-flows-status: ${c(t.error.issues)}`)}function Fp(e){wp({kind:`merge-result`,message:e})}function Ip(e){wp({kind:`connection`,isConnected:e})}lf(Dp);var Lp=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}])),Rp={turn:`Your turn`,working:`Agent working`,waiting:`Waiting on others`,aside:`Set aside`},zp=[`turn`,`working`,`waiting`,`aside`],Bp={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`},Vp={settled:`review-settled`,inReview:`review-in-flight`,queued:`review-queued`,posted:`review-posted`,discarded:`review-discarded`},Hp=Xf.indexOf(`waiting-on-author`);function Up(e){return e.status===`ready`?Zf(e).band===`blocking-others`?`review-direct-ask`:`review-ready`:`review-follow-up`}function Wp(e,t){return t===`ready`?Up(e):t===`attention`?`status`in e&&e.status===`error`?`review-failed`:`review-stale`:Vp[t]}function Gp(e,t,n){let r=e.state===`OPEN`;if(r&&Uf(e,n))return`mine-repair-failed`;if(r&&n&&e.keepMergeable&&e.isKeepMergeableFixInFlight)return`mine-repairing`;let i=Bp[e.stage];return Lp.get(i)?.group===`turn`&&e.stage!==`ready`&&t.has(Ke(e))?`mine-agent-fixing`:i}function Kp(e,t){return t===`ready`||t===`attention`?Xf.indexOf(np(e)):t===`queued`?Xf.indexOf(Zf(e).band):0}function qp(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function Jp(e){let t=op(e).flatMap(e=>qp(e.lastReplyAt)??[]);return t.length>0?Math.max(...t):null}function Yp(e,t){if(t===`inReview`)return qp(e.startedAt)??1/0;if(t===`queued`)return qp(e.prCreatedAt)??1/0;let n=e;return Jp(n)??qp(n.reviewedAt)??qp(n.prCreatedAt)??1/0}function Xp(e){return qp(e.mergedAt??e.stageSinceMs??e.updatedAt)??1/0}function Zp(e,t,n,r){let i=Lp.get(e);return i?[{item:r(i),row:i,priorityBandRank:t,waitStartMs:n}]:[]}function Qp(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=>Zp(Wp(t,e),Kp(t,e),Yp(t,e),({action:n,kind:r})=>({source:`team`,key:`team:${t.key}`,prKey:Ke(t),kind:e,review:t,action:n,attention:r}))))}function $p(e,t,n){return If(e).flatMap(e=>e.rows).flatMap(e=>Zp(Gp(e.pr,t,n),0,Xp(e.pr),({action:t,kind:n})=>({source:`mine`,key:`mine:${e.pr.key}`,prKey:Ke(e.pr),pr:e.pr,stackRow:e,action:t,attention:n})))}function em(e){return e.row.kind===`failed`?0:e.row.state===`review-direct-ask`?1:e.priorityBandRank>=Hp?3:2}function tm(e,t){let n=e.waitStartMs-t.waitStartMs;return e.row.group===`turn`?em(e)-em(t)||n||e.item.key.localeCompare(t.item.key):e.row.rank-t.row.rank||e.priorityBandRank-t.priorityBandRank||n}function nm(e,t,n,r){let i=new Map(zp.map(e=>[e,[]]));for(let a of[...Qp(e),...$p(t,n,r)])i.get(a.row.group)?.push(a);return zp.map(e=>({id:e,title:Rp[e],items:(i.get(e)??[]).toSorted(tm).map(e=>e.item)}))}var rm=[`turn`,`working`,`aside`],im=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 am(e){return e.status===`ready`&&e.verdict?`ready-${e.verdict}`:e.status}function om(e){let t=Date.parse(e.item.createdAt);return Number.isNaN(t)?1/0:t}function sm(e){let t=e.flatMap(e=>{let t=im.get(am(e));return t?[{row:t,askedAtMs:om(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 rm.map(e=>({id:e,title:Rp[e],items:t.filter(t=>t.row.group===e).map(e=>e.item)}))}function cm(e){return`${e.key}@${e.entry.status}:${e.entry.finishedAt??``}`}function lm(e){return e.find(e=>e.id===`turn`)?.items??[]}function um(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function dm(e,t){return um(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function fm(e){return e.source===`mine`?cp(e.pr.repo,e.pr.number):cp(e.review.repo,e.review.number)}function pm(e,t){return lm(e).map(e=>({id:e.key,kind:e.attention??`waiting`,name:t(e)}))}function mm(e){return pm(e,fm)}function hm(e,t){return mm(e).filter(e=>e.id!==t)}function gm({capturedOrder:e,actedKey:t,groups:n}){let r=lm(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 _m(e,t){let n=lm(e).map(e=>e.key),r=t?n.indexOf(t):-1;return r===-1?``:`${r+1} of ${n.length} in Your turn`}function vm(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 ym(e){return lm(e).map(vm)}function bm({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:Xe([...i]),unseen:Xe([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:Xe([...a]),unseen:Xe([...o])}}function xm(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 Sm(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function Cm(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 wm=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 Tm(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`:wm.get(e.key)??null}function Em(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 Dm=null,Om=null,km=new Set;function Am(e){for(let t of km)t(e)}function jm(){Om=Yf(Dm,cf),Am({kind:`status`})}function Mm(e){km.add(e)}function Nm(){return Om}function Pm(){return rp(Om)}function Fm(e){let t=At.safeParse(e);t.success?(Dm=t.data,jm()):u(`reviews`,`dropped team-review-status: ${c(t.error.issues)}`)}function Im(e){Am({kind:`action-result`,message:e})}function Lm(e){Am({kind:`open-session-result`,message:e})}function Rm(e){Am({kind:`connection`,isConnected:e})}lf(jm);var zm=[],Bm=null,Vm=null,Hm=null,Um=!1,Wm=null,Gm=zr(),Km=yr(),qm=new Set(Km.split(`|`).filter(Boolean)),Jm=new Set,Ym=new Set;function Xm(e){for(let t of Ym)t(e)}function Zm(e){e!==Gm&&(Gm=e,ur(e))}function Qm(e){e!==Km&&(Km=e,qm=new Set(e.split(`|`).filter(Boolean)),or(e))}function $m(){return Nm()!==null&&kp().status!==null}function eh(){if(!$m())return;let e=bm({turnEntries:ym(zm),acknowledged:Gm,unseen:Km,isLooking:Vm?.isLooking()??!1});Zm(e.acknowledged),Qm(e.unseen),Wm?.(e.isShown)}function th(e){Hm=e,Xm({kind:`reveal`})}function nh(e){Ym.add(e)}function rh(e){Vm=e,eh()}function ih(){let{prs:e,sessionsByPrKey:t,status:n}=kp();return zm=nm(Pm(),e,new Set(t.keys()),Hf(n)),eh(),zm}function ah(){$m()&&(Zm(Xe(ym(zm))),eh())}function oh(e){Wm=e,eh()}function sh(){return Km}function ch(e){return qm.has(e)}function lh(e){return qm.has(e)?(Qm(Xe([...qm].filter(t=>t!==e))),!0):!1}function uh(e){Bm=e}function dh(){return Bm}function fh(){let e=Hm;return Hm=null,e}function ph(e){if(e!==Um){Um=e;for(let e of Jm)e()}}function mh(e){Jm.add(e)}function hh(){return document.documentElement.dataset.layout===`phone`&&Um}function gh(){hh()&&Xm({kind:`return-to-queue`})}function _h(){let e=hm(zm,Vm?.selectedKey()??null)[0]?.id??null;return e?(th(e),!0):!1}function vh(e){let t=zm.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!Bm?.openReviews()?!1:(th(t.key),ah(),!0)}Mm(e=>{e.kind===`status`&&ih()}),Op(e=>{e.kind===`prs`&&ih()});function yh(){return{groups:zm}}var bh={OPEN:0,MERGED:1,CLOSED:2};function xh(e){return e?bh[e.state]:bh.OPEN}function Sh(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:$t(void 0)};let i=Bf(t.stage);return{key:n,text:r,detailText:`${r} ${t.title}`,stateText:zf(t.stage),url:t.url,prTitle:t.title,look:{icon:Vf(t.stage),tone:i},tier:$t(i)}}function Ch(e,t){let n=e.map(e=>{let n=t(Ke(e));return{link:e,pr:n?Df(n):void 0}});return n.sort((e,t)=>xh(e.pr)-xh(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>Sh(e,t))}var wh=new Map;function Th(e){return document.querySelectorAll(`[data-pr-rows-for="${CSS.escape(e)}"]`)}function Eh(e){return Ch(wh.get(e)??[],cf).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,onActivate:()=>{vh(e.key)||nu(e.url)}}))}function Dh(e,t){let n=Ze(`session-pr-chip-unlink`);return n.append(C(Ct)),n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),Jt({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:()=>{ci(t,{type:`unlink-session-pr`,id:t,key:e.key})}})}),n}function Oh(e,t){let n=dn({...e,text:e.key},{...e,className:`linked-pr-row-link`});e.prTitle&&n.append(D(`span`,`linked-pr-row-title`,e.prTitle)),e.stateText&&n.append(D(`span`,`linked-pr-row-stage`,e.stateText));let r=D(`li`,`linked-pr-row`);return r.append(n,Dh(e,t)),r}function kh(e,t){e.dataset.prRowsFor=t;let n=Eh(t);yn(e,n,e=>Oh(e,t),{visibleCount:n.length})}function Ah(e){for(let t of e){let e=t.dataset.prRowsFor;e&&kh(t,e)}}function jh(e,t){let n=Tt.shape.links.safeParse(t??[]);wh.set(e,n.success?n.data:[]),Ah(Th(e)),_n(e),jp(wh)}function Mh(e){wh.delete(e),jp(wh)}lf(()=>{Ah(document.querySelectorAll(`[data-pr-rows-for]`)),mn()});function L(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Nh(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function Ph(e,t){return e||Nh(t)>0}var Fh={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},Ih=null,Lh=!1,Rh=!1,zh=null,Bh=null,Vh=null,Hh=`—`;function Uh(e){return e==null?Hh:et(e,`GB`)}function Wh(e){return e==null?Hh:he(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function Gh(e){return e==null?Hh:`${Wh(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function Kh(){let e=D(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=D(`div`,`health-summary`),n=Ze(`health-toggle`);n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=D(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,D(`span`,`health-toggle-label`,`Health`));let i=D(`div`,`health-stats`);t.append(n,i);let a=D(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{Rh=!Rh,e.dataset.expanded=String(Rh),n.setAttribute(`aria-expanded`,String(Rh)),a.hidden=!Rh,Rh&&(v({type:`request-health-snapshot`}),Jh())}),e.append(t,a),zh=e,Bh=i,Vh=a,e}function qh(){if(!Bh||!Ih)return;let e=Ih,t=Nh(e.anomalies);Bh.innerHTML=`
|
|
3
3
|
<span class="health-stat"><span class="health-stat-label">Heap</span> ${Uh(e.process.heapUsed)}</span>
|
|
4
4
|
<span class="health-stat"><span class="health-stat-label">Memory</span> ${Uh(e.process.rss)}</span>
|
|
5
5
|
<span class="health-stat"><span class="health-stat-label">Buffers</span> ${Uh(e.process.external)}</span>
|
|
@@ -70,6 +70,6 @@ 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 a
|
|
|
70
70
|
<tbody>${o||`<tr><td colspan="8" class="health-dim">No sessions</td></tr>`}</tbody>
|
|
71
71
|
</table>
|
|
72
72
|
</div>
|
|
73
|
-
`}function Yh(){if(!zh)return;let e=Ph(Lh,Ih?.anomalies),t=zh.hidden;zh.hidden=!e,e&&t&&Ih&&(qh(),Rh&&Jh())}function Xh(e){Lh=e,Yh()}function Zh(e){if(zh)return zh;let t=Kh();return e.appendChild(t),Yh(),t}function Qh(e){Ih=e,Yh(),zh&&!zh.hidden&&(qh(),Rh&&Jh())}var $h=null,eg=null,tg=!1,ng=null,rg=new Set;function ig(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function ag(){for(let e of rg)e()}function og(){return{report:$h,hasReportSendFailed:tg}}function sg(e){rg.add(e)}function cg(e){eg=e}function lg(){if(!eg)return;ng=h(`hooks-report`);let e=eg({type:`request-hooks-report`,requestId:ng});e!==!tg&&(tg=!e,ag())}function ug(e){ig(e,ng)&&($h=e,tg=!1,ag())}function dg(){lg()}var fg=new Map;function pg(e){return fg.get(e)??[]}function mg(e){return pg(e).length>0}function hg(e){let t=A(e)?.btnDocs;t&&(t.hidden=!mg(e))}var gg=null,_g=null;function vg(){return _g??=N(()=>import(`./doc-editor-ui-rP-g8eGO.js`).then(e=>(gg=e,e),e=>(_g=null,u(`doc-editor`,`doc editor failed to load: ${d(e)}`),null)),__vite__mapDeps([11,12,13,5,3,14,15,16,17,18])),_g}function yg(e){vg().then(t=>t?.openDocEditor(e))}function bg(e){gg?.applyDocsToOpenEditor(e)}function xg(e){fg.set(e.id,e.docs),e.docs.length===0&&fg.delete(e.id),hg(e.id),bg(e.id)}function Sg(e){let t=[...fg.keys()];fg.clear();for(let[t,n]of Object.entries(e.sessions))fg.set(t,n);for(let e of new Set([...t,...fg.keys()]))hg(e),bg(e)}var Cg=10,wg={low:0,medium:1,high:2};function Tg(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 Eg(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 Dg(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function Og(e,t){for(let n of e.hotspots)Dg(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`});for(let n of e.blastRadius)n.transitiveDependentCount<Cg||Dg(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`})}function kg(e,t){return e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function Ag(e){return e.conflictRisk===null?-1:wg[e.conflictRisk]}function jg(e,t){return t.severity-e.severity||Ag(t)-Ag(e)||e.heading.localeCompare(t.heading)||e.groupKey.localeCompare(t.groupKey)}function Mg(e,t){return e===null||t===null?e??t:wg[t]>wg[e]?t:e}function Ng(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?(e.lines.push(n),e.conflictRisk=Mg(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(kg);return n.sort(jg)}function Pg(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:Tg(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of Eg(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);Og(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:Ng(r.values()),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function Fg(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 Ig(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 Lg(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=Ig(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 Rg(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function zg(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 Bg({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=Hg(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 Vg({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?Bg({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 Hg(e){return e||`base`}function Ug(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function Wg(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function Gg({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 Kg({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function qg(e){if(!e)return[];let t=new Map;for(let n of[...Lg(e.committed?.diff),...Lg(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 Jg(e,t){return t===null?null:e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)??null}function Yg(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 Xg(e){return e!==T.DORMANT&&e!==T.DONE&&e!==T.FAILED}function Zg(e,t){return(Ft.includes(e)||e===T.RUNNING)&&t}function Qg(e){let{status:t,reason:n,isFetched:r,hasCommits:i,isWorkspace:a,state:o,effectiveBase:s}=e,c=zg(e.files),l=Xg(o),u=Wg(t,n,Zg(o,i)),d=Kg({fetched:r,changedFileCount:c.files,hasCommits:i}),f=Vg({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=Gg({status:t,hasCommits:i,live:l,state:o});return{sentence:t===`parked`?`${f.text}. ${Ug(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 $g=5e3,e_=new Map,t_=new Map,n_=new Map,r_=new Map,i_=new Map,a_=new Map,o_=new WeakMap,s_=new WeakMap,c_=new Set,l_=new Set,u_=null,d_=null,f_=null,p_=null,m_=null;function h_(e){return c_.add(e),()=>c_.delete(e)}function g_(e){for(let t of c_)t(e)}function __(e){if(!e)return[];let t=o_.get(e);if(t)return t;let n=qg(e);return o_.set(e,n),n}function v_(e){if(!e)return null;let t=s_.get(e);if(t)return t;let n=Pg(e);return s_.set(e,n),n}function y_(e){return k.get(e)?.card.dataset.workspace!==void 0}function b_(e){let t=k.get(e);if(!t)return null;let n=n_.get(e)??null,r=__(n),i=r_.get(e)??null;return{...Qg({status:e_.get(e)||`none`,reason:t_.get(e)??null,isFetched:n_.has(e),hasCommits:n?.hasCommits===!0,hasDiffError:i!==null,isWorkspace:y_(e),state:t.currentState,effectiveBase:t.effectiveBase,isMergeInFlight:a_.has(e),files:r}),sessionId:e,sessionName:t.card.dataset.session||e,files:r,diffError:i,changeMapView:v_(i_.get(e)),notice:u_?.sessionId===e?u_.text:null,isWorkspace:y_(e)}}function x_(e,t){u_={sessionId:e,text:t},d_&&clearTimeout(d_),d_=setTimeout(()=>{u_=null,g_(e)},$g),g_(e)}function S_(e){i_.has(e)||i_.set(e,null),v({type:`request-change-map`,id:e})}function C_(e){v({type:`request-session-diff`,id:e}),S_(e)}function w_(e,t){let n=e_.get(e);e_.set(e,t),Rg(n,t)&&(n_.delete(e),r_.delete(e),i_.delete(e),e===Yr()&&C_(e)),g_(e)}function T_(e,t,n=null){let r=t||`none`;t_.set(e,n);let i=a_.get(e);i!==void 0&&i!==r&&a_.delete(e),w_(e,r)}function E_(e,t,n=null){t_.set(e,n),a_.delete(e),w_(e,t||`none`)}function D_(e,t){let n=O(e);n&&(n_.set(n,t),r_.delete(n),g_(n))}function O_(e,t){let n=O(e);n&&(r_.set(n,t),g_(n))}function k_(e,t){let n=O(e);if(!n)return;let r=oe.safeParse(t);r.success&&r.data.sessionId===n&&(i_.set(n,r.data),g_(n))}function A_(e){let t=O(e);t&&t===Yr()&&C_(t)}function j_(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function M_(e){let t=O(e);if(!t||t!==Yr())return;let n=!n_.has(t)||r_.has(t),r=!i_.has(t)||j_(i_.get(t));n&&C_(t),r&&!n&&S_(t),g_(t)}function N_(e){let t=O(e);t&&a_.delete(t)&&g_(t)}function P_(e){let t=O(e);e_.delete(t),t_.delete(t),n_.delete(t),r_.delete(t),i_.delete(t),a_.delete(t),t===Yr()?ui(null):g_(t)}function F_(e,t){a_.has(e)||(v(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(a_.set(e,e_.get(e)||`none`),g_(e)):x_(e,`Not connected. The merge was not sent.`))}function I_(e){let t=b_(e);return t?a_.has(e)?(x_(e,`Merge is already on its way for "${t.sessionName}".`),!1):t.isMergeEnabled?k.get(e)?.currentState===T.RUNNING?(Jt({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:()=>F_(e,!0)}),!0):(F_(e,!1),!0):(x_(e,t.mergeRefusal??`Nothing to merge in "${t.sessionName}" right now.`),!1):!1}function L_(e){let t=b_(e);t?.isDiscardShown&&Jt({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 R_(){return[...l_].some(e=>!e.hasAttribute(`data-slot-held`))}function z_(){let e=R_()&&document.visibilityState===`visible`?Yr():null;e!==f_&&(p_&&clearInterval(p_),p_=null,f_=e,v({type:`watch-session-changes`,id:e}),e&&(p_=setInterval(()=>v({type:`watch-session-changes`,id:e}),St)))}function B_(e){m_??=V_(),m_.observe(e)}function V_(){return document.addEventListener(`visibilitychange`,z_),Qr(e=>{e&&C_(e),z_()}),new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&l_.add(t.target),t.isIntersecting||l_.delete(t.target);z_()})}var H_=!1,U_=new Set;function W_(e){H_=!!e,tv();for(let e of U_)e(H_)}function G_(e){return U_.add(e),()=>U_.delete(e)}function K_(){return H_}function q_(){let e=D(`div`,`debug-close`);return e.append(w({variant:`icon`,size:`small`,label:`Close debug overlay`,icon:C(Ct)})),e}function J_(e){return e?fe(new Date(e)):`-`}function Y_(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function X_(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Y_(e.quietMs)})`:``}function Z_(e){let t=`<span class="debug-dim">${J_(e.ts)}</span>`;if(e.kind===`signal`){let n=L([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${L(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=X_(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${L(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=L(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${L(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${L(e.category||`?`)}: <span class="debug-dim">${L(e.from||`?`)} → ${L(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${L(e.kind||`decision`)}</span>`}function Q_(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">${L(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">${L(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${J_(e.timestamp)}</span> ${L(e.from)} → ${L(e.to)} <span class="debug-label">${L(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?`${L(a.signal)} (${L(a.source||`?`)}${a.confidence?`/${L(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">${L(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 ${Y_(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">${L(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">${Z_(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(q_())}function $_(e,t){if(e.debugOpen){ev(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(q_()),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`)&&ev(e)}),v({type:`debug-state`,id:t})}function ev(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function tv(){for(let[,e]of k)e.btnDebug.classList.toggle(`visible`,H_),e.btnTrace.classList.toggle(`visible`,H_),!H_&&e.debugOpen&&ev(e)}function nv(e){let t=typeof e.id==`string`?k.get(e.id):void 0;t?.debugOpen&&Q_(t,e.payload)}function rv(e){A(e)?.debugOpen&&v({type:`debug-state`,id:e})}function iv(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0}}function av(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 ov(e,t){return{body:t.join(`
|
|
74
|
-
`),tag:`glimmervoid-alert-${e.id}`,renotify:e.isStart}}var sv=4e3;function cv(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function lv(e,t,n,r=sv){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 uv=`#plan/`;function dv(e){return`${uv}${encodeURIComponent(e)}`}function fv(e){if(!e.startsWith(uv))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var pv=null;function mv(){return pv??=N(()=>import(`./alert-sound-Da6VQFBS.js`),__vite__mapDeps([10,7])).catch(e=>(pv=null,u(`alert-sound`,`alert sound failed to load: ${d(e)}`),null)),pv}function hv(){let e=xr();mv().then(t=>t?.playAlertSound(e))}function gv(){return typeof Notification>`u`?null:Notification}function _v(){return gv()!==null}function vv(){let e=gv();return e?e.permission:`unavailable`}async function yv(){let e=gv();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function bv(){return!_v()&&!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.`:_v()?vv()===`denied`&&gr()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function xv(){return gr()&&vv()==="default"}function Sv(e=()=>{}){let t=D(`div`,`notification-permission`),n=()=>{let r=bv();if(t.replaceChildren(),t.hidden=!r&&!xv(),r){t.append(D(`p`,`notification-permission-hint text-meta text-text-muted`,r));return}let i=w({variant:`secondary`,label:`Enable desktop notifications`});i.addEventListener(`click`,()=>{i.disabled=!0,yv().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var Cv=`Notifications`,wv=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,Tv=new Map,Ev=!1;function Dv(){Ev||(Ev=!0,Bn({source:Cv,message:wv,hidesInStreamerMode:!1}))}function Ov(e,t){let n=Tv.get(e)??new Set;n.add(t),Tv.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function kv(e){let t=Tv.get(e);if(t){Tv.delete(e);for(let e of t)e.close()}}function Av(e){return!_v()||!gr()||document.documentElement.hasAttribute(`data-streamer`)?!1:e||!document.hasFocus()}function jv(){return Av(!1)&&vv()===`granted`}var Mv=null;function Nv(e,t){let n=gv();if(!n||(Mv=av(Mv,t,e.message),zn(Cv),!lv(window.localStorage,cv(`group-${t.id}`,`${e.session}-${e.category}`),Date.now())))return;let r=t.sessionIds.length===1?k.get(e.session):void 0,i=t.sessionIds.length>1?`${t.sessionIds.length} sessions`:r?Tn(r):`Glimmervoid`;try{let r=new n(i,ov(t,Mv.lines));r.onclick=()=>{window.focus(),e.kind===`plan`&&(window.location.hash=dv(e.session)),r.close()};for(let e of t.sessionIds)k.has(e)&&Ov(e,r)}catch{}}var Pv=null;function Fv(e){return!e||e.id!==Pv&&(Pv=e.id,!0)}function Iv(e){k.get(e.session)?._isActiveViewer?.()===!0?v({type:`alert-seen`,id:e.session}):Fv(e.group)&&Vr()&&hv()}function Lv(e,t){t?Nv(e,t):Bv(e)}function Rv(){let e=Reflect.get(navigator,`userAgentData`);return typeof e!=`object`||!e?!1:Reflect.get(e,`platform`)===`macOS`}function zv(e){if(document.hasFocus()){Iv(e);return}let t=e.group;jv()&&(Lv(e,t),!Rv())||(Av(!1)&&vv()===`denied`&&Dv(),t?.isStart!==!1&&Fv(t)&&Vr()&&hv())}function Bv({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=gv();if(!a||!Av(!!i)||(a.permission===`denied`&&Dv(),a.permission!==`granted`)||(zn(Cv),!lv(window.localStorage,cv(e,t),Date.now())))return;let o=typeof e==`string`?e:``,s=k.get(o),c=s?Tn(s):``;try{let i=new a(c||`Glimmervoid`,iv(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=dv(o)),i.close()},s&&Ov(o,i)}catch{}}var Vv=null;function Hv(){return Vv??=N(()=>import(`./resume-dialog-B-yl3qdF.js`),__vite__mapDeps([19,12,13,5,3,14,20,15,21])).catch(e=>(Vv=null,u(`resume-dialog`,`restart dialog failed to load: ${d(e)}`),null)),Vv}var Uv=null,Wv=null;function Gv(){return Wv??=N(()=>import(`./plan-face-oyJASo0C.js`).then(e=>(Uv=e,e),()=>(Wv=null,null)),__vite__mapDeps([22,13,5,3,14,23,24,16,17,25])),Wv}function Kv(e){let t=D(`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,Gv().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 qv(e,t){let n=A(e);n?yi(n).show(`error`,t):Bn({source:`Session`,sessionId:typeof e==`string`?e:void 0,message:t})}function Jv(e,t){let n=A(e);if(!n)return;let r=n.card.querySelector(`:scope > .session-failure-reason`);if(!(n.currentState===T.FAILED&&t)){r?.remove();return}let i=r??D(`p`,`session-failure-reason`);i.setAttribute(`role`,`status`),i.textContent=t,r||n.termWrap.before(i)}var Yv=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function Xv(e){return e===`approve`||e===`approve-accept-edits`}function Zv(e){return(e.state===`decided`||e.state===`closed`)&&Xv(e.lastDecision)}function Qv(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&Zv(n)}function $v(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function ey(e){let t=$v(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 ty(e,t){return $v(e,t)?.openRevision?.revision??null}function ny(e,t,n){if(n===null)return null;let r=$v(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function ry(e,t){let n=t-e;return Number.isFinite(n)?Re(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function iy(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 ay(e,t,n){let r=iy(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return Yv.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function oy(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 sy(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function cy(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+lt}function ly(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 ${ke} characters, so nothing was sent`:sy(e)>1e4?`the feedback composes more than the ${Me} characters the hook reply carries, so nothing was sent`:cy(e)>Qe?`the decision is larger than one control frame carries, so nothing was sent`:null}function uy(e){return e?`, ${e}`:``}function dy(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=oy(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 fy(e,t,n){let r=dy(e,t,n);return r?`${r}${uy(e.problem)}`:e.problem??``}function py(e){let t=$v(e.state,e.selectedAgentId),n=ey(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:ny(e.state,t?.agentId??null,n),status:fy(e,t,n),actions:ay(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:ny(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:iy(e,t,n)}]}}function my(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 hy({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 gy({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var _y=e=>Wt.includes(e),vy=e=>Lt.includes(e);function yy(e){let t=e.currentState;e.btnRestart.classList.toggle(`visible`,_y(t)||vy(t)||t===T.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,K_()),e.btnPlan.hidden=gy(e)===`hidden`}function by(e){let t=A(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(O(e)),yy(t),Qc(t,O(e)),!0)}function xy(e,t){let n=A(e);n&&(n.hasPlan=t===!0,yy(n))}function Sy(e){let t=A(e.id);t&&(t.planReviewState=my(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),yy(t))}function Cy(e){let t=A(e.id);t&&t.planFace.update({draft:e})}function wy(e){let t=A(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),yy(t))}function Ty(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=A(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function Ey(e){for(let[,t]of k)t.planFace.update({isConnected:e})}var Dy=160,Oy=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 ky(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=Dy?t:`${t.slice(0,157)}...`}function Ay(e,t){let n=Oy[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?ky(r):``}var jy=5e3;function My(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function Ny(e,t){if(!e.toolUseId)return My(e.text)??`context`;let n=t.get(e.toolUseId);return n?Ay(n.name,n.input)||n.name:`expansion`}function Py(e){return e.kind!==`expansion`||e.toolUseId?!1:My(e.text)!==null}function Fy(e){return e.kind===`prompt`||e.kind===`session`||Py(e)}function Iy(e){return new TextEncoder().encode(e).byteLength}var Ly={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`};function Ry(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:ky(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:ky(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:ky(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:ky(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:ky(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:Ny(e,t)};if(e.kind===`tool_call`){let t=Ay(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:`${Iy(e.content)} bytes`}}function zy(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function By(e,t){let n=Ry(e,t),r=zy(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:Ly[e.kind],text:`${r}${i}`,tone:o,badges:a}}function Vy(e,t){return{record:e,...By(e,t)}}function Hy(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function Uy(e,t){let n=Hy(e);return!n||t.has(n)?null:n}function Wy(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function Gy(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function Ky(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=Hy(i.record);a&&t.has(a)&&(n.rows[r]=Vy(i.record,e.toolCallByUseId))}}function qy(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function Jy(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function Yy(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=Iy(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function Xy(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=Uy(i,e.toolCallByUseId);t&&Wy(e.unresolvedToolUseCounts,t);let a=Vy(i,e.toolCallByUseId);if(Fy(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:Jy()},Yy(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:Jy()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),Yy(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 Zy(e,t){let n=qy();Xy(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)||Wy(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],Ky(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function Qy(e){return e.rows.length+ +!!e.head}function $y(e){let t=0;for(let n of e.turns)t+=Qy(n);return t}function eb(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=Hy(n.record);t&&Gy(e.unresolvedToolUseCounts,t)}}function tb(e,t){eb(e,t.head?[t.head,...t.rows]:t.rows)}function nb(e,t){let n=e.turns[0];if(!n)return 0;let r=Math.min(t,n.rows.length);if(r<=0)return 0;let i=n.rows.slice(0,r);eb(e,i);for(let e of i)Yy(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function rb(e,t=jy){let n=$y(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=Qy(t),tb(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:nb(e,n-t)}}function ib(e){let t=[],n=new Set;for(let r of e)r.id&&r.name&&!n.has(r.id)&&(n.add(r.id),t.push({id:r.id,label:r.name}));return t}function ab(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 ob(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 sb(e,t=jy){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function cb(e,t=jy){return!sb(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function lb(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 ub=1e4,db=null,fb=null,pb=[],mb=null,hb=null,R=null,gb=null,_b=!1,vb=null,yb=()=>!1,bb=new Set;function z(e){for(let t of bb)t(e)}function xb(){gb&&=(clearTimeout(gb.timeoutHandle),null)}function Sb(){gb=null,vb=`The trace did not load within ${Math.round(ub/1e3)} s.`,z({kind:`rebuild`})}function Cb(e){xb(),_b=!1,vb=null,mb=e,R=e?{sessionId:e,grouping:qy(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,z({kind:`selection-reset`})}function wb(e){let t=ab(pb,hb,mb,e);return hb&&t===hb&&(hb=null),t!==mb&&(Cb(t),!0)}function Tb(e){if(!db)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};db(t)?gb={request:e,timeoutHandle:setTimeout(Sb,ub)}:(vb=De,z({kind:`header`}))}function Eb(e=!1){if(!db)return;let t=ob({selectedSessionId:mb,isPanelVisible:e||yb(),hasPendingRequest:!!gb,hasLoadedOnce:R?.hasLoadedOnce??!1,nextOffset:R?.nextOffset??0});t&&Tb(t)}function Db(){_b&&!gb&&(_b=!1,Eb())}function Ob(){if(!R)return;let e=rb(R.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!R.hasDroppedEarliestRows;t&&(R.hasDroppedEarliestRows=!0),z({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function kb(e){R&&(z({kind:`records-appended`,appends:Xy(R.grouping,e)}),Ob())}function Ab(e){R&&(z({kind:`records-prepended`,prepend:Zy(R.grouping,e)}),Ob())}function jb(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 Mb(){return{selectedSessionId:mb,hasPendingRequest:!!gb,hasLoadedOnce:R?.hasLoadedOnce??!1,hasDroppedEarliestRows:R?.hasDroppedEarliestRows??!1,firstOffset:R?.firstOffset??0,residentRowCount:R?$y(R.grouping):0}}function Nb(){return{sessionOptions:pb,selectedSessionId:mb,selectedTrace:R,pendingSessionId:gb?.request.id??null,traceFailureText:vb}}function Pb(e){bb.add(e)}function Fb(e){yb=e}function Ib(){if(!db)return;let e=cb(Mb());e&&Tb(e)}function Lb(e){pb.some(t=>t.id===e)&&e!==mb&&(hb=null,Cb(e),Eb(),z({kind:`rebuild`}))}function Rb(){let e=wb(!0);return Eb(!0),e}function zb(e){db=e}function Bb(e){fb=e}function Vb(e){hb=e,fb?.()}function Hb(e){pb=ib(e);let t=wb(yb());t&&Eb(),z({kind:`sessions`,hasSelectionChanged:t})}function Ub(e){let t=jb(e);if(!t)return;let n=lb({pendingRequest:gb?.request??null,resident:R?{sessionId:R.sessionId,firstOffset:R.firstOffset,nextOffset:R.nextOffset,hasLoadedOnce:R.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?Db():(xb(),vb&&(vb=null,z({kind:`header`})),n===`stale`?Db():n===`reset`?(Cb(t.id),R&&(R.filePath=t.path),Eb(),z({kind:`rebuild`}),Db()):R&&(R.filePath=t.path,n===`prepend`?(R.firstOffset=t.start,Ab(t.records),Db()):(n===`seed`&&(R.hasLoadedOnce=!0,R.firstOffset=t.start),R.nextOffset=t.next,kb(t.records),Db())))}function Wb(e){let t=e?.id;typeof t==`string`&&t===mb&&yb()&&(gb?_b=!0:Eb())}function Gb(e){let t=e?.id;if(typeof t!=`string`||gb?.request.id!==t)return!1;xb(),_b=!1;let n=e?.message;return vb=typeof n==`string`&&n?n:`The trace could not be read.`,z({kind:`rebuild`}),!0}function Kb(e){xb(),_b=!1,vb=e?null:De,e?(z({kind:`header`}),Eb()):z({kind:`rebuild`})}function qb(e){return e instanceof Error?e.message:String(e)}function Jb(e,t,n=!1){let r=D(`label`,`dialog-checkbox-label`),i=D(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,D(`span`,null,e)),r}function Yb(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function Xb(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:Yb(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 Zb(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:o}=Xt({title:`Workspace repositories`}),s=D(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),c=D(`fieldset`,`dialog-workspace-list`);c.setAttribute(`aria-label`,`Workspace repositories`),c.append(D(`div`,`dialog-hint`,`Loading repositories...`));let l=D(`div`,`dialog-hint`);l.setAttribute(`role`,`status`);let u=D(`div`,`dialog-error`),d=w({variant:`primary`,label:`Save`,disabled:!0});i.append(d),n.append(s,c,l,u,i),o.addEventListener(`click`,r),requestAnimationFrame(()=>o.focus()),Xb(e).then(e=>{if(t.isConnected){c.textContent=``;for(let t of e)c.append(Jb(t.name,t.path,t.isMember));d.disabled=!1}}).catch(e=>{t.isConnected&&(c.textContent=``,u.textContent=`Could not load repositories: ${qb(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: ${qb(e)}`)}).finally(()=>{l.textContent=``,d.disabled=!1}))})}function Qb(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function $b(e,t){bn(e.taskTitleEl,()=>xn(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),rn(e,t)}),e.nameEl.addEventListener(`click`,()=>{tn(e.nameEl)||ui(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),rn(e,t))}),e.btnRename.addEventListener(`click`,()=>{Qb(e),rn(e,t,{returnsFocusToTerminal:!e.renameTargetEl?.isConnected})}),e.btnRestart.addEventListener(`click`,()=>{Qb(e),Hv().then(n=>n?.openRestartDialog(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0}))}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{Qb(e),Zb(t)}),e.btnTrace.addEventListener(`click`,()=>{Qb(e),Vb(t)}),e.btnDocs.addEventListener(`click`,()=>{Qb(e),yg(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=gy(e);n!==`hidden`&&(n===`face`?by(t):location.hash=dv(t))}),e.btnRemove.addEventListener(`click`,()=>{Qb(e),ai(t)});function n(){for(let[,t]of k)t!==e&&Qb(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`)}e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation(),e.sessionMenu.classList.contains(`open`)?Qb(e):n()}),Si({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:()=>Qb(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&&Qb(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),Qb(e),$_(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&ev(e)},{signal:e.abortController.signal})}var ex=1500,tx=new WeakMap;function nx(e){clearTimeout(tx.get(e)),tx.delete(e)}function rx(e,t){let n=setTimeout(()=>{tx.delete(e),v({type:`dismiss`,id:t,expectedState:T.COMPLETE})},ex);tx.set(e,n)}function ix(e,t,n){let r=document.activeElement;return Zr({previousState:t,nextState:n,isPhoneLayout:yo(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}var ax=e=>e==null?``:String(e);function ox(e,t,n){let r=A(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&Sn(e,r.taskTitle)}}function sx(e){return typeof e==`string`&&k.has(e)}function cx(){return k.size}function lx(e){let t=e||{};t.cursorBlink!=null&&Bu(t.cursorBlink),t.debugMode!=null&&(W_(t.debugMode),Xh(t.debugMode));for(let[,e]of k)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function ux(){Pl(k.values(),Il())}function dx(e){return{state:e.currentState,unseenOutcome:e.unseenOutcome,ownerId:e.ownerId}}function fx(){let e=Cn(j.counts),t=e>0?`(${e}) Glimmervoid`:`Glimmervoid`;document.title!==t&&(document.title=t)}function px(e,t,n,r={}){if(!Mn)return;let i=O(e),a=ax(n)||T.DORMANT,o=on(i,ax(t),a,r),s=a===T.DORMANT;Mn.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),yy(c),Xu(c,i)}let u=new AbortController,d=Kv({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=>qv(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:ax(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=()=>Xu(c,i),c._showTerminalFace=l,c._showPreferredFace=l,c._setBorrowed=e=>{c.isBorrowed=e,o.card.toggleAttribute(`data-borrowed`,e),yy(c)},o.card.append(d.el);let f=k.get(i);return f&&Fn(j,dx(f)),k.set(i,c),En(j,dx(c)),qn(i,c),$b(c,i),yy(c),c.btnDocs.hidden=!mg(i),a===T.RUNNING&&Kn(c,!0),s||qu(c,i),fx(),c}function mx(e,t){let n=A(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function hx(e,t){let n=A(e);n&&(n.agent=typeof t==`string`?t:null,yy(n))}function gx(e,t){let n=A(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function _x(e,t,n=!1){let r=A(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=Kt(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function vx(e,t){let n=A(e);n&&(n.pendingPromptKind=typeof t==`string`?t:null)}function yx(e,t){let n=A(e);n&&(Fn(j,dx(n)),n.unseenOutcome=t??null,En(j,dx(n)))}function bx(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function xx(e,t,n=null){let r=A(e),i=ax(t)||`none`;r&&bx(r.card,i),T_(O(e),i,ax(n)||null)}function Sx(e,t,n=null){let r=A(e),i=ax(t)||`none`;r&&bx(r.card,i),E_(O(e),i,ax(n)||null)}function Cx(e,t){let n=A(e);if(!n)return;let r=ax(t);n.card.dataset.session=r,n.nameEl.textContent=r}function wx(e){let t=A(e);t&&(ev(t),Fn(j,dx(t)),k.delete(O(e)),qn(O(e),void 0),Uv?.dropPlanBodyCache(O(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),Dl(t,O(e)),no(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),fx())}function Tx(e,t,n){if(!t||!e.term)return;let r=n===T.DONE?`Session complete`:`Session failed`,i=n===T.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 Ex(e,t){e.term&&(t===T.DONE||t===T.FAILED)&&(e.term.clear(),e.term.reset())}function Dx(e){let t=k.get(e);t&&jn({state:t.currentState,unseenOutcome:t.unseenOutcome})&&document.visibilityState===`visible`&&(yo()||document.hasFocus())&&v({type:`dismiss`,id:e,expectedState:t.currentState})}function Ox(e,t,n){let r=A(e);if(!r)return;let i=ax(t),a=r.currentState;Fn(j,dx(r)),r.currentState=i,En(j,dx(r)),qn(O(e),r),i!==T.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(nx(r),r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),Kn(r,i===T.RUNNING)),a===T.DORMANT&&i!==T.DORMANT&&qu(r,O(e)),In({state:i})===`resting`&&kv(O(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,Kt(i,r.awaitingBackgroundTasks)),yy(r),ix(r,a,i)&&rx(r,O(e));let o=i===T.DONE||i===T.FAILED,s=a!==T.DONE&&a!==T.FAILED&&a!==T.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===T.DONE||i===T.FAILED)&&Tx(r,s,i),i===T.INITIALIZING&&Ex(r,a),fx()}var kx=Bi({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function Ax(e){let t=D(`ul`,`session-setup-list`);return t.append(...e.map(e=>D(`li`,null,e))),t}function jx(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=Ht(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[D(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=D(`div`,`session-setup-plugin`);return t.append(D(`h3`,null,e.name)),e.skills.length>0&&t.append(D(`p`,`session-setup-label`,`Skills`),Ax(e.skills)),e.agents.length>0&&t.append(D(`p`,`session-setup-label`,`Agents`),Ax(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[Ax(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=D(`p`,`session-setup-hook`);return t.append(D(`span`,null,e.event),D(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>D(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[Ax(t.skills)]:[]),n(`Agents`,t.agents.length>0?[Ax(t.agents)]:[])}function Mx(e){let t=D(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=D(`div`,`session-setup-sections`);kx.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function Nx(e){let t=kx.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;jx(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function Px(e){return Re(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function Fx(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${Px(Date.now()-e)} ago`}var Ix=e=>`polled ${Fx(e)}`;function Lx(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=Ix){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=Jn(a)}}}var Rx=80,zx=Object.freeze([{value:`day`,label:`Today`,days:1},{value:`week`,label:`Last 7 days`,days:7},{value:`month`,label:`Last 30 days`,days:30}]),Bx=`week`;function Vx(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function Hx(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function Ux(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${Vx(String(Math.abs(t)))}`}function Wx(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}$${Vx(r)}.${i}`}function Gx(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}${Hx((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${Hx((n/1e6).toFixed(2))}M`:`${t}${Hx((n/1e9).toFixed(2))}B`}function Kx(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=Rx?`warn`:`ok`}var qx=90;function Jx(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&S(e.budgetUsd,null)!==null):[]}function Yx(e){let t=S(e?.pct,null);return t===null?0:t}function Xx(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=S(n.pct,null),i=S(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}function Zx(e){return e?.vendor===`codex`||e?.vendor===`kimi`?e.vendor:`claude`}function Qx(e,t=null){let n=[],r=Kx(Xx(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 Jx(e)){let e=Yx(t);if(e<qx)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return Xe(n)}function $x(e,t=``){let n=e?.source;if(n===`fetched`){let e=je(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=je(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 eS(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 tS(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function nS(e){if(!e||typeof e!=`object`)return``;let t=[],n=tS(e.dirs);if(n!==null&&t.push(`${Ux(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${Ux(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${Ux(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${Ux(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 rS(e){return je(e?.error,``)}function iS(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}var aS=`Estimated list prices, not a bill.`,oS=`Enable in Settings.`,sS=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],cS=/^(\d{4})-(\d{2})-(\d{2})$/,lS=new Set([`day`,`model`,`label`]),uS=new Set([`model`,`label`]);function dS(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${Hx(e.toFixed(1))}%`}var fS=`tokens`,pS=Object.freeze([{value:`tokens`,label:`Tokens`},{value:`cost`,label:`Cost`}]);function mS(e){return e===`cost`?`cost`:fS}function hS(e,t){return t===`cost`?Wx(e):Gx(e)}function gS(e,t){if(t===`tokens`)return`tokens`;let n=Number(e?.costUSD);return Number.isFinite(n)&&n>0?`costUSD`:`tokens`}function _S(e){return e===`costUSD`?`share of cost`:`share of tokens`}function vS(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function yS(e){let t=cS.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=sS[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function bS(e){let t=xS(e);return t.length===0?``:t.length===1?yS(t[0]):`${yS(t[0])} to ${yS(t[t.length-1])}`}function xS(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>cS.test(e)).sort()}function SS(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:CS(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function CS(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=wS(e,n);return cS.test(r)?r:wS(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function wS(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function TS(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:he(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function ES(e,t){let n=Ot(t-864e5),[,r,i]=e.yesterday.day.split(`-`).map(Number),a=e.yesterday.day===n?`yesterday`:`${sS[r-1]} ${i}`,o=e.yesterday.sessionCount===1?`session`:`sessions`;return`${a}: ${e.yesterday.sessionCount} ${o}, ${TS(e.yesterday.activeMs/6e4)}`}function DS(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=sS[n.getMonth()];return r?`${r} ${n.getDate()} ${Be(n)}`:`-`}var OS=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`}),kS=`Sessions spawned by Glimmervoid; terminal sessions count as other`,AS=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function jS(e){let t=je(e,``);return t?OS[t]||t:OS.other}function MS(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function NS(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function PS(e){return MS(e).some(e=>NS(e.lane))}var FS=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function IS(e,t,n){let r=Xx(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function LS(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+S(t.costUSD,0),0),o=i.reduce((e,t)=>e+S(t.tokens,0),0),s=i.filter(e=>NS(e.lane)).map(e=>({lane:String(e.lane),label:jS(e.lane),tokens:S(e.tokens,0),costUSD:S(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?vS(c,a):vS(l,o),d=IS(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:FS[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function RS(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:OC.map(e=>LS(e.key,r[e.key],t,n)).filter(e=>e!==null)}function zS(e){return e.planPct===null?``:`about ${dS(e.planPct)} of plan`}function BS(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?Wx(e.costUSD):Gx(e.tokens)}`).join(`, `)}var VS=`team-review`;function HS(e){if(!Array.isArray(e?.byLane))return``;let t=MS(e).find(e=>e.lane===VS),n=S(t?.costUSD,0);if(n<=0)return``;let r=vS(n,e?.totals?.costUSD),i=r===null?``:`, ${dS(r)} of this period`;return`PR reviews cost ${Wx(n)}${i}.`}function US(e){let t=S(e,null);return t===null||t<=0?``:`${Ux(t)} ${t===1?`session`:`sessions`}`}function WS(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function GS(e){let t=WS(e);if(!t)return``;let n=S(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 ${Wx(n)}${i}, across ${Gx(S(t.cacheReadTokens,0))} cache read tokens.`}function KS(e){return e===`monthly`?`this month`:`today`}function qS(e){return`${Wx(S(e?.spentUsd,0))} of ${Wx(S(e?.budgetUsd,0))}`}function JS(e){return`${KS(e?.scope)} spend against budget`}var YS=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function XS(e){let t=cS.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function ZS(e){let t=XS(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Ot(t)}function QS(e){let t=cS.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function $S(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 eC(e,t){e.tokens+=S(t?.tokens,0),e.costUSD+=S(t?.costUSD,0),e.input+=S(t?.input,0),e.output+=S(t?.output,0),e.cacheCreate+=S(t?.cacheCreate,0),e.cacheRead+=S(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=zC(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+=S(t?.tokens,0),r.costUSD+=S(t?.costUSD,0),r.input+=S(t?.input,0),r.output+=S(t?.output,0),r.cacheCreate+=S(t?.cacheCreate,0),r.cacheRead+=S(t?.cacheRead,0),e.modelByName.set(n,r)}}function tC(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 nC(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)||$S(r);eC(i,e),n.set(r,i)}return Array.from(n.values()).map(tC)}function rC(e){return nC(e,ZS)}function iC(e){return nC(e,QS)}function aC(e,t){return t===`week`?rC(e):t===`month`?iC(e):Array.isArray(e)?[...e]:[]}var oC=/^(\d{4})-(\d{2})$/;function sC(e,t){if(t===`month`){let t=oC.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=sS[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=yS(e);return t===`-`?t:`week of ${t}`}return yS(e)}function cC(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var lC=16,uC=Object.freeze([.05,.25,.5,.75]),dC=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function fC(e,t){let n=S(e,0),r=S(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<uC.length;e+=1)i>=uC[e]&&(a=e+1);return a}function pC(e,{weeks:t=lC,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>cS.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`&&cS.test(n)?n:Ot(o),c=XS(ZS(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Ot(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,S(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=Ot(n),a=i.get(r)||null,o=r>s,c=p!==null&&r<p;d.push({day:r,week:e,weekday:t,tokens:S(a?.tokens,0),costUSD:S(a?.costUSD,0),source:a?.source===`history`?`history`:a?`live`:null,noData:o||c||!a&&p===null,tone:fC(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function mC(e){let t=yS(e?.day);if(e?.noData)return`${t}: no data`;let n=S(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${Gx(n)} tokens, ${Wx(S(e?.costUSD,0))}`}function hC(e){if(!e)return``;let t=S(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${yC(e.ratio)} the ${n} average: ${Wx(e.todayUsd)} against ${Wx(e.baselineUsd)}.`}function gC(e){return e?`This block is burning ${yC(e.ratio)} the usual rate: ${Gx(e.current)} tokens per minute against ${Gx(e.baseline)}.`:``}function _C(e){return[hC(e?.daily),gC(e?.burn)].filter(Boolean).join(` `)}function vC(e){return!!(e?.daily||e?.burn)}function yC(e){let t=S(e,null);return t===null?`-`:`${Hx(t.toFixed(1))}x`}var bC=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`,kimi:`Kimi`});function xC(e){let t=je(e,``);return t?bC[t]||t:bC.claude}function SC(e,t){return wC(t)?xC(e?.vendor):``}function CC(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>S(t[n]?.tokens,0)-S(t[e]?.tokens,0)).map(e=>({vendor:e,label:xC(e),tokens:S(t[e]?.tokens,0),costUSD:S(t[e]?.costUSD,0)}))}function wC(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 TC=`Claude only`;function EC(e){return wC(e)?TC:``}var DC=36e5,OC=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]),kC=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`},{vendor:`kimi`,label:`Kimi Code`}]);function AC(e,t=Date.now()){let n=S(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function jC(e,t=Date.now()){let n=S(e,null);return n===null||n<=0||t-n>DC}function MC(e,t=Date.now()){if(!jC(e,t))return``;let n=AC(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function NC(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 PC(e){let t=je(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function FC(e){return rS(e)!==``}function IC(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 LC(e){return typeof e?.id==`string`&&e.id!==``}function RC(e){let t=je(e?.label,``);return LC(e)&&t?t:IC(e?.project)||t||`unknown project`}function zC(e){let t=typeof e==`string`?e:e?.model;return je(t,`unknown model`)}function BC(e){return String(e?.day??``)}function VC(e,t,n){if(!lS.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?BC(e):n(e)}function HC(e,t,n,r=RC){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=VC(e,t,r),o=VC(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 UC(e){return uS.has(e)?`asc`:`desc`}function WC(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:UC(t)}}function GC(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var KC=Object.freeze({key:`lastTs`,dir:`desc`}),qC=Object.freeze({key:`tokens`,dir:`desc`}),JC=Object.freeze({key:`day`,dir:`desc`});function YC(e,t=KC){return HC(e,t.key,t.dir,RC)}function XC(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 ZC(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${Ux(t)} hidden`}function QC(e,t=qC){return HC(e,t.key,t.dir,zC)}function $C(e,t=JC){return HC(e,t.key,t.dir,BC)}function ew(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function tw(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 nw=36e5,rw=24*nw,iw=Object.freeze({fiveHour:{lengthMs:5*nw,label:`5-hour`},sevenDay:{lengthMs:7*rw,label:`weekly`}}),aw=10,ow=80,sw=100,cw=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function lw(e,t){return e>=sw?`fail`:e>=ow||t!==null&&t>=ow?`warn`:`ok`}function uw(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 dw(e,t,n,r){let i=Xx(n,t);if(!i||i.pct===null||i.resetsAtMs!==null&&i.resetsAtMs<=r)return null;let a=iw[t],o=uw(a.lengthMs,i.resetsAtMs,r),s=o!==null&&o>=aw&&i.pct<sw?i.pct/(o/100):null;return{vendor:e,vendorLabel:kC.find(t=>t.vendor===e)?.label||e,key:t,windowLabel:a.label,usedPct:i.pct,elapsedPct:o,projectedPct:s,resetsAtMs:i.resetsAtMs,tone:lw(i.pct,s)}}function fw(e,t){return kC.flatMap(({vendor:n})=>OC.map(({key:r})=>dw(n,r,e[n],t)).filter(e=>e!==null))}function pw(e,t){let n=S(e,null);if(n===null||n<=0)return``;let r=new Date(n),i=Be(r);return Ot(n)===Ot(t)?i:n-t<7*rw&&r.getDay()!==new Date(t).getDay()?`${cw[r.getDay()]} ${i}`:`${sS[r.getMonth()]} ${r.getDate()} ${i}`}function mw(e){return`${Math.round(e)}%`}function hw(e){return Math.max(e.usedPct,e.projectedPct??0)}function gw(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 _w(e,t){let n=gw(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 ${mw(100-r.usedPct)} of its ${r.windowLabel} window left.`}function vw(e,t){let n=pw(e,t);return!n||e===null?`until the window resets`:`until ${n}, in ${TS((e-t)/6e4)}`}function yw(e,t,n){let r=[`${e.vendorLabel} sessions stop answering ${vw(e.resetsAtMs,n)}. Their worktrees and conversations stay intact.`,_w(t,e.vendor)];return{tone:`fail`,headline:`${e.vendorLabel} ${e.windowLabel} limit reached.`,detail:r.filter(Boolean).join(` `)}}function bw(e,t){let n=pw(e.resetsAtMs,t),r=n?`, resets ${n}`:``;if(e.usedPct>=ow)return{tone:`warn`,headline:`${e.vendorLabel} ${e.windowLabel} limit is at ${mw(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 ${mw(e.projectedPct??e.usedPct)}.`}}function xw(e){return{tone:`warn`,headline:`Over your ${KS(e.scope)===`today`?`daily`:`monthly`} budget.`,detail:`${qS(e)} spent ${KS(e.scope)}.`}}function Sw(e,t,n,r){let i=e.find(e=>e.tone===`fail`);if(i)return yw(i,e,r);let a=e.filter(e=>e.tone===`warn`).sort((e,t)=>hw(t)-hw(e))[0];if(a)return bw(a,r);let o=t.find(e=>S(e.pct,0)>=100);if(o)return xw(o);if(e.length===0)return{tone:`ok`,headline:n===null?`Nothing spent yet today.`:`${Wx(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)=>hw(t)-hw(e))[0],c=pw(s.resetsAtMs,r);return{tone:`ok`,headline:`Every limit has room.`,detail:`Closest is ${s.vendorLabel} ${s.windowLabel} at ${mw(s.usedPct)}${c?`, resets ${c}`:``}.`}}function Cw(e){return e.tone===`fail`?`limit reached`:e.projectedPct===null?e.elapsedPct===null?``:`too early to project`:`about ${mw(e.projectedPct)} at reset`}var ww=`report`;function Tw(e){return zx.find(t=>t.value===e)?.label||``}function Ew(e,t){return{key:gS(e,t),dir:`desc`}}function Dw(e,t){let n=QC(e?.models,Ew(e?.totals,t))[0];if(!n)return null;let r=gS(e?.totals,t);return{label:zC(n),sharePct:vS(n[r],e?.totals?.[r])}}function Ow(e,t){let n=YC(e?.sessions,Ew(e?.totals,t)),r=n[0];return{count:n.length,topLabel:r?RC(r):``}}function kw(e){let t=MS(e).filter(e=>NS(e.lane));return t.length===0?null:t.reduce((e,t)=>e+S(t.costUSD,0),0)}function Aw(e){let t=e.filter(e=>S(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 jw(e){return xS(e).length}function Mw(e,t){let n=XS(e);return!n||t<=0?[]:Array.from({length:t},(e,r)=>{let i=new Date(n);return i.setDate(n.getDate()-(t-1-r)),Ot(i)})}function Nw(e){return zx.find(t=>t.value===e)?.days??7}function Pw(e){return e.reduce((e,t)=>t.resetsAtMs===null?e:e===null?t.resetsAtMs:Math.min(e,t.resetsAtMs),null)}function Fw(e,t){let n=XS(e);return n?(n.setDate(n.getDate()+t),Ot(n)):``}function Iw(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=String(e?.day??``);cS.test(n)&&r.set(n,(r.get(n)??0)+S(e?.[t],0))}return r}function Lw(e,t){let n=XS(e);return n?t<=7?cw[n.getDay()]:String(n.getDate()):e}function Rw(e,t,n,r){let i=Iw(e,r===`cost`?`costUSD`:`tokens`),a=Mw(n,t).map(e=>({day:e,label:Lw(e,t),value:i.get(e)??0,isToday:e===n})),o=a.reduce((e,t)=>e+t.value,0),s=Mw(Fw(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 zw(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 Bw(e){return`${hS(e.average,e.metric)} a day on average`}function Vw(e){return wC(e)?CC(e).map(e=>`${e.label} ${Wx(e.costUSD)}`).join(`, `):``}function Hw(e){return wC(e)?CC(e).map(t=>({...t,sharePct:vS(t.tokens,e?.tokens)})):[]}function Uw(e){let t=e?.totals,n=[{label:`Processed tokens`,value:Gx(S(t?.tokens,0))},{label:`Cached input`,value:Gx(S(t?.cacheRead,0))},{label:`Uncached input`,value:Gx(S(t?.input,0))},{label:`Output`,value:Gx(S(t?.output,0))}],r=S(WS(e?.savings)?.savedUSD,0);return r>0&&n.push({label:`Cache savings`,value:Wx(r)}),n}function Ww(e){let t=(e?.yourDay?.insights??[]).map(e=>({text:e.text,tone:`ok`})),n=e?.anomaly;vC(n)&&t.push({text:_C(n),tone:`warn`});for(let n of[GS(e?.savings),HS(e)])n&&t.push({text:n,tone:`ok`});return t}function Gw(e,t,n,r){let i=gS(t,n),a=e.reduce((e,t)=>Math.max(e,S(t[i],0)),0);return e.map(e=>({row:e,label:r(e),tokens:S(e.tokens,0),costUSD:S(e.costUSD,0),sharePct:vS(e[i],t?.[i]),barPct:vS(e[i],a)??0}))}function Kw(e,t){return Gw(QC(e?.models,Ew(e?.totals,t)),e?.totals,t,zC)}function qw(e,t){return Gw(YC(e?.sessions,Ew(e?.totals,t)),e?.totals,t,RC)}function Jw(e){return[{label:`Input`,tokens:S(e.input,0)},{label:`Output`,tokens:S(e.output,0)},{label:`Cache write`,tokens:S(e.cacheCreate,0)},{label:`Cache read`,tokens:S(e.cacheRead,0)}]}var Yw=2e4,Xw=`glimmervoid-usage-metric`,Zw=null,Qw=null,$w={claude:null,codex:null,kimi:null},eT=null,tT=null,nT=null,rT=Bx,iT=mS(er(Xw,null)),aT=!1,oT=null,sT=null,cT=!0,lT=()=>!1,uT=new Set,dT=Et({getAck:Br,setAck:Ar,signature:()=>Qx(Zw,$w.claude),isLooking:()=>lT()});function fT(e){for(let t of uT)t(e)}function pT(){eT?.(dT.refresh())}function mT(e){aT=e,fT(`refresh-status`),oT&&=(clearTimeout(oT),null),e&&(oT=setTimeout(()=>{oT=null,aT=!1,sT=`Usage did not answer within ${Math.round(Yw/1e3)} s. Refresh to try again.`,fT(`refresh-status`)},Yw))}function hT(e){let t=zx.find(t=>t.value===e);return t?t.days:null}function gT(){return{report:Zw,sessions:Qw,planLimitsByVendor:$w,rangeValue:rT,metric:iT}}function _T(){let e=!cT||!aT&&sT!==null;return cT?aT?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:sT??``,isPending:!1,hasFailure:e}:{text:Zw?`${De} The figures below are from before the connection dropped.`:De,isPending:aT,hasFailure:e}}function vT(e){uT.add(e)}function yT(e){lT=e,pT()}function bT(){dT.acknowledge(),pT()}function xT(e){eT=e,pT()}function ST(e){tT?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function CT(e){tT=e}function wT(e){rT=e}function TT(e){iT=e,$n(Xw,e)}function ET({force:e=!1}={}){if(!tT)return;nT=h(`usage`);let t={type:`request-usage-report`,requestId:nT};e&&(t.force=!0);let n=hT(rT);n!==null&&(t.days=n),sT=null,mT(!0),!tT(t)&&(sT=De,mT(!1))}function DT(e){cT=e,fT(`refresh-status`)}function OT(e){Qw=e,fT(`sessions`)}function kT(e){let t=e;$w={...$w,[Zx(t)]:t},fT(`plan-limits`),pT()}function AT(e){iS(e,nT)&&(sT=null,mT(!1),Zw=e,fT(`report`),pT())}function jT(){let e=Zw?.pricing||(Qw?{source:Qw.pricingSource}:null),t=eS(e?.fetchedAt),n=[$x(e,t!==null&&t>0?Fx(t):``)],r=rS(Zw);r&&n.push(r);let i=nS(Zw?.scan);return i&&n.push(i),n}var MT=26,NT=97;function PT(e){return Object.values(e.elements).filter(e=>e.kind===`unit`)}function FT(e){let t=String.fromCharCode(NT+e%MT),n=Math.floor(e/MT);return n===0?t:`${t}${n+1}`}function IT(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 LT(e){let t=PT(e),n=IT(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}${FT(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 RT=14,zT=30,BT=40,VT=120,HT=300,UT=400,WT=4e4,GT=2e4,KT=4e5,qT=6,JT=12,YT=3e3,XT=14,ZT=8,QT=100,$T=6.6,eE=5,tE=10,nE=2,rE=[.5,.35,.65,.2,.8],iE=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}],aE={right:0,left:1,bottom:2,top:3},oE={left:0,right:1,top:2,bottom:3},sE=[1,0,3,2];function cE(e){return e===`left`||e===`right`}function lE(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function uE(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function dE(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 fE(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)pE(n.rect,e.rect)&&t(n,e);r.push(e)}}function pE(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 mE(e,t){return e[0]-t[0]||e[1]-t[1]}function hE(e){let t=[];return fE(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(mE)}function gE(e,t){let n=[];return fE([...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(mE)}function _E(e){return dE(e.map(e=>({...e,width:0,height:0})))??{x:0,y:0,width:0,height:0}}function vE(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 yE(e){return e.from.y===e.to.y}function bE(e,t){let n=t.x+t.width,r=t.y+t.height;if(yE(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 xE(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 SE(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 CE(e){return e.slice(1).flatMap((t,n)=>{let r=e[n];return r?[{from:r,to:t}]:[]})}function wE(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function TE(e){if(e.length<=we.layoutWarnings)return[...e];let t=e.slice(0,we.layoutWarnings-1);return[...t,`and ${e.length-t.length} more`]}function EE(e,t){return t.x>=e.x+e.width||t.x+t.width<=e.x}function DE(e,t,n){if(e.id===t.id)return{exitSide:`right`,entrySide:`top`};if(n)return{exitSide:`bottom`,entrySide:`bottom`};let r=lE(e),i=lE(t);return EE(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 OE=[`right`,`left`,`bottom`,`top`];function kE(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,...OE.filter(e=>e!==t.exitSide)],o=n.toSide?[n.toSide]:[t.entrySide,...OE.filter(e=>e!==t.entrySide)];return a.flatMap(e=>o.map(t=>({exitSide:e,entrySide:t})))}function AE(e,t){let n=e.outputPort??LE(e.from,t.exitSide,1)[0]??lE(e.from),r=LE(e.to,t.entrySide,1)[0]??lE(e.to);if(!HE(t.exitSide,t.entrySide))return{...e,...t,start:n,end:r};let i=UE(r,t.entrySide,e.to,n),a=i===r&&!e.outputPort?UE(n,t.exitSide,e.from,r):n;return{...e,...t,start:a,end:i}}function jE(e,t){return e.turnsAndCrossings<t.turnsAndCrossings||e.turnsAndCrossings===t.turnsAndCrossings&&e.cost<t.cost}function ME(e,t,n){let r=aD(e,t,{usageByEdge:new Map,usageByNodeAndAxis:new Map},null,n,{remainingExpansions:YT}),i=r?.at(-1),a=i===void 0?1/0:n.bestCost[i]??1/0;if(rD(n),!r||a===1/0)return null;let o=SE(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:CE(o),bounds:_E(o),bends:Math.max(o.length-2,0),cost:a}}function NE(e,t){let n=t.filter(t=>pE(e.bounds,t.bounds)&&t.segments.some(t=>e.segments.some(e=>wD(e,t)))).length;return{turnsAndCrossings:e.bends+n,cost:e.cost}}function PE(e,t,n){let r=new Map(e.map(e=>[e,kE(e,t.get(e)??{exitSide:e.exitSide,entrySide:e.entrySide})]));if(![...r.values()].some(e=>e.length>1))return;let i=XE([...r].flatMap(([e,t])=>t.map(t=>AE(e,t))),[...n.boxesById.values(),...n.panels],n.softObstacles,n.contentTop);if(!i)return;let a=nD(i),o=new Map(e.flatMap(e=>{let[t]=r.get(e)??[],n=t?ME(i,AE(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:NE(n,r)};for(let n of t.slice(1)){let t=ME(i,AE(e,n),a),o=t?NE(t,r):null;o&&jE(o,s.score)&&(s={pair:n,score:o})}s.pair&&(e.exitSide=s.pair.exitSide,e.entrySide=s.pair.entrySide)}}function FE(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 IE(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=DE(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??lE(r),end:lE(i)};return t.set(c,a),[c]});PE(n,t,e),FE(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 LE(e,t,n){let r=Array.from({length:n},(e,t)=>t);if(cE(t)){let i=Math.round(t===`left`?e.x:e.x+e.width),a=Math.min(XT,(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+ZT,Math.min(o,e.y+e.height-ZT-(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)*XT/2;return r.map(e=>({x:Math.round(a+e*XT),y:i}))}function RE(e,t){let n=cE(t)?e.height:e.width;return Math.max(1,Math.floor((n-16)/XT)+1)}function zE(e){return vE(e.flatMap(e=>[...e.outputPort?[]:[{box:e.from,side:e.exitSide,groupKey:`exit|${e.styleKey}`,wireId:e.wire.id,farPoint:lE(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??lE(e.from),assign:t=>{e.end=t}}]),e=>`${e.box.id}|${e.side}`)}function BE(e){return new Map([...e.entries()].map(([e,t])=>[e,[...vE(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+(cE(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 VE(e,t){for(let[n,r]of e){let e=r[0],i=t.get(n)??[];if(!e)continue;let a=LE(e.box,e.side,i.length);for(let e of r){let t=a[i.indexOf(e.groupKey)];t&&e.assign(t)}}}function HE(e,t){return e===`right`&&t===`left`||e===`left`&&t===`right`||e===`bottom`&&t===`top`||e===`top`&&t===`bottom`}function UE(e,t,n,r){return cE(t)?r.y>=n.y+ZT&&r.y<=n.y+n.height-ZT?{x:e.x,y:r.y}:e:r.x>=n.x+ZT&&r.x<=n.x+n.width-ZT?{x:r.x,y:e.y}:e}function WE(e,t){let n=(e,n)=>(t.get(`${e.id}|${n}`)?.length??0)===1,r=new Map([...vE(e,e=>e.exitKey)].map(([e,t])=>[e,t.length]));for(let t of e){if(t.from.id===t.to.id||!HE(t.exitSide,t.entrySide))continue;let e=t.busKey===null&&n(t.to,t.entrySide)?UE(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=UE(t.start,t.exitSide,t.from,t.end)):t.end=e}}function GE(e,t){return[...e.entries()].flatMap(([e,n])=>{let r=n[0],i=t.get(e)?.length??0;return!r||i<=RE(r.box,r.side)?[]:[`box ${r.box.id} has ${i} wires on its ${r.side} side, more than fit`]})}function KE(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 qE(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 JE(e,t,n){return{first:qE(e,t,!1),last:qE(e,n,!0)-1}}function YE(e,t,n){return{first:Math.max(0,qE(e,t,!1)-1),last:Math.min(qE(e,n,!0)-1,e.length-2)}}function XE(e,t,n,r){let i=[...t,...n],a=dE([...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-RT,e.x+e.width+RT]),a.x-42,a.x+a.width+42].map(Math.round),u=[...i.flatMap(e=>[e.y-RT,e.y+e.height+RT]),a.y-42,a.y+a.height+42].map(Math.round).filter(e=>e>=c),d=KE([...new Set([...l,...o])].sort((e,t)=>e-t)),f=KE([...new Set([...u,...s])].sort((e,t)=>e-t));if(d.length*f.length>WT)return null;let p=t.map(e=>uE(e,1)),m=(e,t)=>{let n=new Uint8Array(d.length*f.length);for(let r of t){let t=e===0?YE(d,r.x,r.x+r.width):JE(d,r.x,r.x+r.width),i=e===0?JE(f,r.y,r.y+r.height):YE(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 ZE(){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 QE(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 $E(e,t){return`${e}\n${t}`}function eD(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($E(t.busKey,t.exitKey))??0;return n+r-i}function tD(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?eD(a,t):0,c=s>0,l=a!==void 0&&a.total>s,u=o!==void 0&&o.total>eD(o,t);return(c?-i*.5:0)+(l?VT:0)+(u?BT:0)}function nD(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 rD(e){for(let t of e.touchedStates)e.bestCost[t]=1/0,e.cameFrom[t]=-1;e.touchedStates.length=0}function iD(e,t,n,r,i,a){let o=aD(e,t,n,r,i,a);return rD(i),o}function aD(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=aE[t.exitSide],m=oE[t.entrySide],{bestCost:h,cameFrom:g,touchedStates:_}=i,v=ZE(),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<GT&&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 oD(g,i);let l=s%o,u=(s-l)/o,y=h[i]??1/0;for(let[a,te]of iE.entries()){if(s===d&&a!==p||a===sE[c])continue;let b=l+te.x,x=u+te.y;if(b<0||x<0||b>=o||x>=e.ys.length)continue;let ne=x*o+b;if(ne===f&&a!==m)continue;let re=QE(e,l,u,a);if(s!==d&&ne!==f&&e.isBlocked[re.axis]?.[re.index]===1)continue;let ie={x:e.xs[l]??0,y:e.ys[u]??0},ae={x:e.xs[b]??0,y:e.ys[x]??0},oe=Math.abs(ae.x-ie.x)+Math.abs(ae.y-ie.y),se=r!==null&&bE({from:ie,to:ae},r),ce=oe+(a===c?0:zT)+(e.isSoft[re.axis]?.[re.index]===1?HT:0)+(se?UT:0)+tD(n,t,re,ne,oe),le=ne*4+a,ue=y+Math.max(ce,1);ue>=(h[le]??1/0)||(h[le]=ue,g[le]=i,_.push(le),v.push(le,ue+ee(b,x)))}}return null}function oD(e,t){let n=[];for(let r=t;r!==-1;r=e[r]??-1)n.push(r);return n.reverse()}function sD(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,$E(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=QE(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 cD(e,t){let n=iE[aE[t]]??{x:0,y:0};return{x:e.x+n.x*RT,y:e.y+n.y*RT}}function lD(e){let t=cD(e.start,e.exitSide),n=cD(e.end,e.entrySide);return SE([e.start,t,{x:n.x,y:t.y},n,e.end])}function uD(e,t){if(!e.wire.back)return null;let n=dE([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 dD(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 fD(e,t,n){let r=e&&n?SE(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}})):lD(t);return{plan:t,points:r,segments:CE(r),states:n}}function pD(e,t,n){let r=XE(e,[...t.boxesById.values(),...t.panels],t.softObstacles,t.contentTop),i=r?nD(r):null,a={usageByEdge:new Map,usageByNodeAndAxis:new Map},o=new Map;for(let s of dD(e,e=>e)){let e=r&&i?iD(r,s,a,uD(s,t.loopFrames),i,n):null;r&&e&&sD(r,a,s,e,1),o.set(s.wire.id,fD(r,s,e))}return{drawn:e.flatMap(e=>o.get(e.wire.id)??[]),grid:r,usage:a}}function mD(e){return Math.max(0,e.points.length-2)}function hD(e,t,n){let r=_E(e.points),i=t.filter(t=>pE(r,_E(t.points))&&DD(e,t)!==null).length;return kD(n).filter(t=>{let n=uE(t,-2);return pE(r,n)&&AD(e,t,n)}).length*QT+i}function gD(e,t){let{grid:n,usage:r}=e;if(!n)return e.drawn;let i=nD(n),a={remainingExpansions:KT},o=new Map(e.drawn.map(e=>[e.plan.wire.id,e]));for(let s of dD(e.drawn,e=>e.plan)){if(!s.states||a.remainingExpansions<=0)continue;let e=[...o.values()].filter(e=>e.plan!==s.plan),c=hD(s,e,t);if(c===0)continue;sD(n,r,s.plan,s.states,-1);let l=fD(n,s.plan,iD(n,s.plan,r,uD(s.plan,t.loopFrames),i,a)),u=mD(l)<=Math.max(mD(s),qT),d=l.states&&u&&hD(l,e,t)<c?l:s;sD(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 _D(e){return Math.ceil(e.length*$T)}function vD(e,t){return{x:e.x-t/2,y:e.y-tE,width:t,height:13}}function yD(e){return Math.abs(e.from.x-e.to.x)+Math.abs(e.from.y-e.to.y)}function bD(e,t){if(!yE(e))return[];let n=e.from.y;return[Math.min(e.from.x,e.to.x)+eE+t/2,Math.max(e.from.x,e.to.x)-eE-t/2].flatMap(e=>[{x:e,y:n-eE},{x:e,y:n+eE+tE}])}function xD(e,t){let n=[...e].sort((e,t)=>yD(t)-yD(e));return[...e.slice(0,1),...n].flatMap(e=>[...rE.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 yE(e)?[{x:r,y:i-eE},{x:r,y:i+eE+tE}]:[{x:r+eE+t/2,y:i+tE/2},{x:r-eE-t/2,y:i+tE/2}]}),...bD(e,t)])}function SD(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=_D(e),c=xD(o.segments,s),l=c.find(e=>{let n=vD(e,s);if(n.y<t.contentTop)return!1;let o=uE(n,nE);return i.some(e=>bE(e,o))||a.some(e=>xE(n,e))?!1:![...r.values()].some(e=>xE(n,e.bounds))}),u=l??c[0]??lE(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:vD(u,s)})}return r}function CD(e,t,n){return e>Math.min(t,n)+.5&&e<Math.max(t,n)-.5}function wD(e,t){if(yE(e)===yE(t))return!1;let n=yE(e)?e:t,r=n===e?t:e;return CD(r.from.x,n.from.x,n.to.x)&&CD(n.from.y,r.from.y,r.to.y)}function TD(e,t){if(yE(e)!==yE(t))return!1;let n=yE(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 ED(e,t){return e.plan.busKey!==null&&e.plan.busKey===t.plan.busKey||e.plan.exitKey===t.plan.exitKey}function DD(e,t){if(ED(e,t))return null;let n=e.segments.flatMap(e=>t.segments.map(t=>[e,t]));return n.some(([e,t])=>wD(e,t))?`wire ${e.plan.wire.id} crosses wire ${t.plan.wire.id}`:n.some(([e,t])=>TD(e,t))?`wire ${e.plan.wire.id} overlaps wire ${t.plan.wire.id}`:null}function OD(e){return hE(e.map(e=>_E(e.points))).flatMap(([t,n])=>{let r=e[t],i=e[n];return r&&i?DD(r,i)??[]:[]})}function kD(e){return[...e.boxesById.values(),...e.panels]}function AD(e,t,n){return t.id===e.plan.from.id||t.id===e.plan.to.id?!1:e.segments.some(e=>bE(e,n))}function jD(e,t){let n=kD(t),r=n.map(e=>uE(e,-2));return gE(e.map(e=>_E(e.points)),r).flatMap(([t,i])=>{let a=e[t],o=n[i],s=r[i];return!a||!o||!s?[]:AD(a,o,s)?[`wire ${a.plan.wire.id} runs through ${o.kind} ${o.id}`]:[]})}function MD(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=mD(e);return t>qT?[`wire ${e.plan.wire.id} bends ${t} times`]:[]})}function ND(e,t){return yE(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 PD(e,t){if(!t||t===e)return null;let n=e.points.find(e=>t.segments.some(t=>ND(e,t)));return!n||n.x===e.plan.end.x&&n.y===e.plan.end.y?null:n}function FD(e,t){let n=e[t],r=e[t+1];n!==void 0&&r!==void 0&&(e[t]=r,e[t+1]=n)}function ID(e,t,n,r,i){VE(n,r),WE(e,r);let a=pD(e,t,i);return{routed:a,crossingCost:jD(a.drawn,t).length*QT+OD(a.drawn).length}}function LD(e,t,n,r,i){let a=ID(e,t,n,r,i);if(e.length>JT)return gD(a.routed,t);for(let o of r.values())for(let s=0;a.crossingCost>0&&s+1<o.length;s+=1){FD(o,s);let c=ID(e,t,n,r,i);c.crossingCost<a.crossingCost?a=c:FD(o,s)}return gD(ID(e,t,n,r,i).routed,t)}function RD(e){let t=IE(e),n=zE(t),r=BE(n),i={remainingExpansions:KT},a=LD(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=SD(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:wE(n),start:t.start,end:t.end,label:t.wire.label,labelAt:c.get(t.wire.id)?.at??lE(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:PD(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,...jD(a,e),...OD(a),...MD(a),...GE(n,r),...s],extent:dE([...f,...d])}}var B=40,zD=44,BD=220,VD=90,HD=30,UD=12,WD=20,GD=18,KD=28,qD=12,JD=2,YD=20,XD=26,ZD=18,QD=26,$D=170,eO=21,tO=17,nO=10,rO=22,iO=24,aO=16,oO=16,sO=26,cO=24,lO=8,uO=10,dO=14,fO=4,pO=40,mO=26,hO=24,gO=8,_O=320,vO=Object.freeze({blue:`#60a5fa`,green:`#4ade80`,orange:`#fb923c`,pink:`#f472b6`,cyan:`#22d3ee`,yellow:`#facc15`});function yO(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 bO(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>qD){let t=yO(e.text,n-r-JD).map(e=>a(e,1,JD,null));return[a(``,0,0,i),...t]}let o=e.style===`item`?JD:i?i.length+1:0;return yO(e.text,n-r-o-+(e.style===`code`)).map((e,t)=>a(e,t,o,i))}function xO(e,t=XD){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,bO(e,n,t)))}function SO(e,t){let n=e.lanes.find(e=>e.id===t.lane);return n?{label:n.label||n.id,hex:vO[n.color]}:null}function CO(e){return e.column!==null&&e.at===null&&e.near===null}function wO(e){return e.width??BD}function TO(e,t){return Math.floor(e*(t-24)/196)}function EO(e){if(!e.media)return null;let t=wO(e),n=t-24,r=Math.round(_O*t/BD);return{width:n,height:Math.min(r,Math.max(1,Math.round(n*e.media.height/e.media.width)))}}function DO(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+UD,y:t.y+n,width:r.width,height:r.height}}function OO(e,t){let n=wO(t),r=TO(YD,n),i=yO(t.title,r),a=t.change===`relabeled`&&t.was?yO(t.was,r):[],o=xO(t.lines,TO(XD,n)),s=SO(e,t),c=s!==null&&!CO(t),l=UD+(a.length+i.length)*WD+o.length*GD,u=EO(t),d=u?u.height+gO:0,f=l+UD+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+gO,mediaSize:u,height:f+p.length*KD}}function V(e,t){return Object.values(e.elements).filter(e=>e.kind===t)}function kO(e){let t=yO(e.text,eO);return{lines:t,height:24+(t.length+1)*tO}}function AO(e){let t=new Map;for(let n of V(e,`note`)){let e=t.get(n.on),r=kO(n).height;t.set(n.on,e===void 0?r:e+nO+r)}return t}function jO(e){return e.columns.map(e=>e.title?yO(e.title,iO):[])}function MO(e){return(Math.max(1,...e.map(e=>e.length))-1)*aO}function NO(e,t){let n=V(e,`box`).filter(CO),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=>uO+(e!==void 0&&a.has(e)?ZD: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(VD,186):VD}})}function PO(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)*dO:0,s=a>0?e.left+e.right+a+20:0;return Math.max(e.minimumWidth,o,s)})}function FO(e){let t=new Map(e.columns.map((e,t)=>[e.id,t])),n=e.columns.map(()=>BD);for(let r of V(e,`box`).filter(CO)){let e=t.get(r.column)??0;n[e]=Math.max(n[e]??BD,wO(r))}return n}function IO(e,t){let n=[],r=B;for(let[i,a]of e.entries())n.push(r),r+=a+(t[i]??VD);return n}function LO(e,t){return(e.at(-1)??B)+(t.at(-1)??BD)}function RO(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 zO(e,t){return e===t?0:(e?ZD:0)+(t?44:0)}function BO(e,t){return e.lanes.some(e=>e.id===t.lane)?t.lane??``:``}function VO(e,t){let n=new Set(t.map(t=>BO(e,t)));return[``,...e.lanes.map(e=>e.id)].filter(e=>n.has(e))}function HO(e,t,n){let r=OO(e,t),i=wO(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:DO(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*KD+KD/2}}))}}function UO(e,t,n,r,i,a){let o=RO(e),s=V(e,`box`).filter(CO).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=VO(e,s),l=c.some(e=>e!==``),u=LO(t,n),d=[],f=r;for(let n of c){let r=e.lanes.find(e=>e.id===n),c=f+(l?mO:0),p=new Map,m=new Map;for(let r of s){if(BO(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)+zO(m.get(r.column)??null,l),d=HO(e,r,{x:t[s]??B,y:u}),f=(i.get(r.id)??0)-lO;p.set(r.column,u+Math.max(d.height,f)+HD),m.set(r.column,l),a.set(r.id,d)}let h=Math.max(c,...p.values())-HD;l&&d.push({id:n,label:r?r.label||r.id:``,hex:r?vO[r.color]:``,x:B,y:f,width:u-B,height:h-f}),f=h+hO+HD}return d}function WO(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 GO(e,t){let n=[...e.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0);return{x:e.size>0?n+VD:B,y:t}}function KO(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:wO(i),height:OO(e,i).height},f=u?WO(u,i.near,d):GO(n,t),p=HO(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 qO(e,t,n,r,i){let a=LO(n,r),o=Math.max(a,...t.map(e=>e.x+e.width))+VD,s=V(e,`panel`).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id)),c=i;return s.map(e=>{let t=yO(e.title,YD),n=xO(e.lines),r=24+t.length*WD+n.length*GD,i={kind:`panel`,id:e.id,x:Math.round(o),y:c,width:BD,height:r,titleLines:t,bodyLines:n};return c+=r+HD,i})}function JO(e,t,n,r,i){let a=new Map,o=[],s=UO(e,t,n,r,i,a);for(let t of V(e,`box`))t.at&&a.set(t.id,HO(e,t,t.at));KO(e,r,a,o);for(let t of V(e,`box`))a.has(t.id)||a.set(t.id,HO(e,t,GO(a,r)));return{boxesById:a,bands:s,warnings:o}}function YO(e,t){return V(e,`frame`).flatMap(e=>{let n=dE(e.contains.flatMap(e=>t.get(e)??[]));return n?[{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,x:n.x-ZD,y:n.y-ZD-QD,width:n.width+36,height:n.height+36+QD}]:[]})}function XO(e){return e.resolvedBy?`resolved by ${e.resolvedBy}`:e.author?`from ${e.author}`:``}function ZO(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}=kO(e),o=n.get(e.on)??r.y-lO;return n.set(e.on,o+a+nO),[{kind:`note`,id:e.id,x:r.x+r.width-cO,y:o,width:$D,height:a,lines:i,byline:XO(e),isResolved:e.resolvedBy!==null}]})}function QO(e,t,n,r){let i=dE([...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 $O(e,t){return e.slice(0,-1).map((n,r)=>{let i=n+(t[r]??BD);return{left:i,right:e[r+1]??i}})}function ek(e,t,n){let r=e.segments.filter(e=>e.from.x===e.to.x).map(e=>e.from.x);return $O(t,n).map(e=>new Set(r.filter(t=>t>e.left&&t<e.right)).size)}function tk(e,t,n){return $O(t,n).map(t=>e.wires.reduce((e,n)=>n.label&&n.labelAt.x>t.left&&n.labelAt.x<t.right?Math.max(e,_D(n.label)):e,0))}function nk(e,t,n,r){let i=[...e.values()],a=[...i,...t],o=hE(a).flatMap(([e,t])=>{let n=a[e],r=a[t];return n&&r&&xE(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:QD};return!s.get(e.id)?.has(t.id)&&xE(t,n)?[`box ${t.id} covers the title of frame ${e.id}`]:[]}));return[...o,...c]}function rk(e,t){let n=FO(e),r=IO(n,t.gapWidths),{boxesById:i,bands:a,warnings:o}=JO(e,r,n,t.boxesTop,t.stackHeightByBoxId),s=YO(e,i),c=ZO(e,i),l=qO(e,[...i.values(),...c],r,n,t.boxesTop),u=RD({wires:V(e,`wire`),boxesById:i,panels:l,softObstacles:[...c,...s.map(e=>({x:e.x,y:e.y,width:e.width,height:QD}))],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,...nk(i,l,s,e)],tracksByGap:ek(u,r,n),labelWidthByGap:tk(u,r,n)}}function ik(e,t){return Array.from({length:Math.max(e.length,t.length)},(n,r)=>Math.max(e[r]??0,t[r]??0))}function ak(e,t){let n=[],r=[];for(let i=1;;i+=1){let a=rk(e,{gapWidths:PO(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>=fO||!o&&!s)return a;n=ik(n,a.tracksByGap),r=ik(r,a.labelWidthByGap)}}function ok(e){let t=yO(e.title,YD),n=xO(e.lines),r=+!!e.linkedBoardId;return{titleLines:t,bodyLines:n,height:42+t.length*WD+(n.length+r)*GD}}function sk(e){let t=new Map,n=new Map;for(let r of LT(e)){let i=e.elements[r.unitId];if(i?.kind!==`unit`)continue;let a=ok(i),o=n.get(r.level)??70;n.set(r.level,o+a.height+HD),t.set(i.id,{kind:`unit`,id:i.id,x:B+(r.level-1)*310,y:o,width:BD,height:a.height,label:r.label,status:i.status,titleLines:a.titleLines,bodyLines:a.bodyLines,linkedBoardId:i.linkedBoardId})}return t}function ck(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(VD/2);return wE(SE([n,{x:i,y:n.y},{x:i,y:r.y},r]))}function lk(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?[ck(r,n)]:[]}):[]})}function uk(e){return e.size===0?B:Math.max(...[...e.values()].map(e=>e.y+e.height))+pO}function dk(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 fk={plain:null,fail:`failure path`,join:`joins`,lane:null};function pk(e,t,n){return`${e}|${t}|${n}`}function mk(e,t,n){let r=[fk[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var hk={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function gk(e){let t=new Set(V(e,`box`).map(e=>e.change));return Te.flatMap(e=>e===`none`||!t.has(e)?[]:[{label:hk[e],swatch:{kind:`change`,change:e}}])}function _k(e){return e.size===0?[]:He.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}}))}function vk(e,t){let n=e.lanes.map(e=>({label:e.label||e.id,swatch:{kind:`lane`,hex:vO[e.color]}})),r=new Map(e.legend.map(e=>[pk(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=pk(e.tone,t,e.back),a=r.get(n)??mk(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(pk(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,...gk(e),..._k(t)]}function yk(e){let t=sk(e),n=uk(t),r=n-B,i=dk(e,r),a=AO(i),o=jO(i),s=MO(o),c=n+sO+s,l=n+zD+s,u=ak(i,{reserves:NO(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=QO(p,u.routing.extent,LO(d,f),l),h=m.y+m.height,g=vk(i,t).map((e,t)=>({...e,x:B,y:h+t*rO})),_=h+g.length*rO+(g.length>0?12:0),v=i.caption?{text:i.caption,x:B,y:_}:null,y=g.length*rO+(v?30:0)+(g.length>0?12:0);return{columns:i.columns.map((e,t)=>({id:e.id,titleLines:o[t]??[],titleBaselineY:n+oO,ruleY:c,x:d[t]??B,width:f[t]??BD})),bands:u.bands,elements:p,legend:g,caption:v,pinnedOffsetY:r,plan:t.size>0?{titleAt:{x:B,y:56},arrowPaths:lk(i,t)}:null,bounds:{...m,height:m.height+y},warnings:TE([...u.placementWarnings,...u.routing.warnings])}}function bk(e){return JSON.stringify(e)}var xk=Object.freeze({box:Nt,frame:ce,wire:_t,note:We,unit:Ge,panel:ye});Object.freeze({id:`operator`,name:`operator`});function Sk(e,t,n){if(n[0]===`put`)return n[1].id===t?n[1]:null;if(n[0]===`remove`||!e)return null;let r=xk[e.kind].safeParse({...e,...n[1]});return r.success&&r.data.id===t?r.data:null}function Ck(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=Sk(t,e,n);if(!r)return null;n[0]===`put`&&delete i[e],i[e]=r}return Object.keys(i).length>we.elements?null:{...e,...t.fields,elements:i,version:n,updatedAt:r}}var wk=new Map,Tk=new Map,Ek=[],Dk=[],Ok=[],kk=new Map;function Ak(){for(let e of[...Ek])e()}function jk(e){for(let t of Dk)t(e)}function Mk(e){return e.type===`whiteboard-result`}async function Nk(e,t){try{let n=await a(e,t,{timeoutMs:Un});return Mk(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:Hn(e,Un)}}}function Pk(e){let t=Tk.get(e);if(t)return t;let n=Nk(`whiteboard-get`,{boardId:e}).then(t=>{Tk.delete(e),t.ok&&t.reply.board&&(wk.set(e,t.reply.board),jk(e))});return Tk.set(e,n),n}function Fk(){return Ok}function Ik(e){return wk.get(e)??null}function Lk(e){return wk.has(e)?Promise.resolve():Pk(e)}function Rk(e){return Ek.push(e),()=>{let t=Ek.indexOf(e);t>=0&&Ek.splice(t,1)}}function zk(e){Dk.push(e)}function Bk(){let e=new Map;for(let t of Ok)for(let n of t.connectedSessionIds){let r=e.get(n);r?r.push(t):e.set(n,[t])}kk=e}function Vk(e){Ok=[...e.boards].sort((e,t)=>t.updatedAt-e.updatedAt),Bk();let t=new Map(Ok.map(e=>[e.id,e.version]));for(let[e,n]of[...wk]){let r=t.get(e);r!==n.version&&(wk.delete(e),r===void 0?jk(e):Pk(e))}Ak()}function Hk(e){let t=wk.get(e.boardId);if(!t||t.version>=e.toVersion)return;if(t.version!==e.fromVersion){wk.delete(e.boardId),Pk(e.boardId);return}let n=Ck(t,e.diff,e.toVersion,e.updatedAt);n?(wk.set(e.boardId,n),jk(e.boardId)):(wk.delete(e.boardId),Pk(e.boardId))}function Uk(e){wk.delete(e.boardId),Ok=Ok.filter(t=>t.id!==e.boardId),Bk(),jk(e.boardId),Ak()}async function Wk(e){let t=await Nk(`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 Gk(e,t){let n=await Nk(`whiteboard-op`,{boardId:e,ops:t});return n.ok?{ok:!0,diff:n.reply.patch?.diff??null}:n}async function Kk(e){let t={"x-glimmervoid-upload-name":encodeURIComponent(e.name)};e.type&&(t[`content-type`]=e.type);let n=await fetch(ve,{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=Ie.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 qk(e){let t=await Nk(`whiteboard-delete`,{boardId:e});return t.ok?{ok:!0}:t}async function Jk(e,t){let n=await Nk(`whiteboard-connect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function Yk(e,t){let n=await Nk(`whiteboard-disconnect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function Xk(e,t){let n=await Nk(`whiteboard-nudge`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function Zk(e){let t=await Nk(`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 Qk=null;function $k(e){Qk=e}function eA(e,t){Qk?.(e,t)}function tA(e){return kk.get(e)??[]}var nA=null;function rA(e,t){nA={boardId:e,sessionId:t}}function iA(){let e=nA;return nA=null,e}var aA=()=>{};function oA(e){aA=e}function sA(e,t){rA(e,t),aA()}function cA(e,t){let n=e.queuedBySessionId[t]??0;return n===0?``:`${n} queued`}function lA(e,t,n){let r=cA(e,t),i=r?`wait`:`muted`;return{key:`board:${e.id}`,text:n,detailText:e.title,stateText:r,look:{icon:`board`,tone:i},tier:$t(i),className:`session-pr-chip session-board-chip`,ariaLabel:`Open board ${e.title}`,onActivate:()=>sA(e.id,t)}}function uA(e,t){let n=cA(e,t);return lA(e,t,n?`${e.title}, ${n}`:e.title)}function dA(e){return tA(e).map(t=>lA(t,e,t.title))}function fA(e,t,n){let r=uA(e,t),i=Ze(`session-pr-chip-unlink`);i.append(C(Ct)),i.setAttribute(`aria-label`,`Disconnect board ${e.title}`),i.addEventListener(`click`,r=>{r.stopPropagation(),r.preventDefault(),Jt({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:()=>{Yk(e.id,t).then(e=>n(e.ok?null:e.error))}})});let a=D(`span`,`session-pr-chip-item`);return a.append(dn(r,r),i),a}function pA(e){let{dialog:t,close:n,actions:r,btnCancel:i}=Xt({title:`Connect board`}),a=D(`div`,`session-pr-chips dialog-linked-prs`),o=D(`p`,`dialog-message`,`A connected session is told what others changed on the board with its next whiteboard get or prompt.`),s=D(`select`,`dialog-input`);s.setAttribute(`aria-label`,`Board to connect`);let c=Rn(`action-status`),l=w({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=tA(e);yn(a,t.map(t=>uA(t,e)),n=>{let r=t.find(e=>`board:${e.id}`===n.key);return r?fA(r,e,u):dn(n,n)});let n=Fk().filter(t=>!t.connectedSessionIds.includes(e));s.replaceChildren(...n.map(e=>{let t=D(`option`,null,e.title);return t.value=e.id,t})),n.length===0&&s.append(D(`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,Jk(t,e).then(e=>{e.ok?n():(c.show(`error`,e.error),d())}))}),i.addEventListener(`click`,n);let f=Rk(()=>{t.isConnected?d():f()});d()}Rk(mn);function mA(){return M.snapshot().borrowedCardId}var hA=null;function gA(e,t,n,{className:r,onRelease:i}={}){if(!e?.card||!n)return;let a=mA();a&&a!==t&&_A();let o=e.card;o._cardHostClass&&o._cardHostClass!==r&&o.classList.remove(o._cardHostClass),o._cardHostClass=r||``,r&&o.classList.add(r),Gt(o,n),hA=i??null,M.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function _A(){let e=mA(),t=hA;if(hA=null,t?.(),M.dispatch(`borrowCard`,null),!e)return null;let n=k.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,Rt(r,Mn)),e}var vA=null,yA=null,bA={},xA=null,SA=null,CA=null,wA=new Map,TA=new Map;function EA(){return yA??=N(()=>import(`./phone-shell-D522Pzmm.js`).then(e=>{e.mountPhoneShell(bA),CA&&e.orderPhonePanels(CA);for(let[t,n]of wA)e.setPhoneScreenAvailable(t,n);for(let[t,n]of TA)e.setPhoneScreenAttention(t,n);return vA=e,e},e=>(yA=null,u(`phone-shell`,`phone shell failed to load: ${d(e)}`),null)),__vite__mapDeps([26,13,5,3,27,12,14,20,15,28,29,23,30,4,6,7,21,31,24,32])),yA}function DA(e){bA=e}async function OA(e){let t={options:e};xA=t;let n=await EA();if(xA!==t)return!1;if(!n)return xA=null,SA=null,!1;xA=null,n.activatePhoneShell(t.options);let r=SA;return SA=null,r?.(n),!0}function kA(){xA=null,SA=null,vA?.deactivatePhoneShell()}function AA(){return xA!==null||(vA?.isPhoneShellActive()??!1)}function jA(){return xA?xA.options?.sessionId??null:vA?.getPhoneSessionId()??null}function MA(e){CA=e,vA?.orderPhonePanels(e)}function NA(e,t){wA.set(e,t),vA?.setPhoneScreenAvailable(e,t)}function PA(e,t){TA.set(e,t),vA?.setPhoneScreenAttention(e,t)}function FA(){vA?.refreshPhoneBoard()}function IA(){vA?.syncPhoneHistory()}function LA(e){return xA?(SA=t=>{e(t)},!0):vA?e(vA):!1}function RA(e){return LA(t=>t.showPhonePlan(e))}function zA(e){return LA(t=>t.showPhoneSession(e))}function BA(e){return LA(t=>t.showPhoneScreen(e))}function VA(){let e=jA();e&&A(e)?._isActiveViewer?.()===!0&&Dx(e)}function HA(){Yu(A(mA())),VA()}function UA(){window.addEventListener(`focus`,HA),window.addEventListener(`blur`,HA),document.addEventListener(`visibilitychange`,HA),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&ao()}),window.addEventListener(`pageshow`,e=>{e.persisted&&ao()})}function WA(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function GA(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function KA({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=WA(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=GA(e.key,a);if(n===null)return;e.preventDefault();let r=u(t.getBoundingClientRect().width+l*n);r!==null&&s(r)})}var qA={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.`}},JA=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:It[e],meaning:t}),YA=Object.freeze([JA(T.DORMANT,`Not started yet.`),JA(T.STARTING,`Setting up the worktree and booting the agent.`),JA(T.RUNNING,`The agent is mid-turn.`),JA(T.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),JA(T.WAITING,`Waiting on a permission prompt or your answer.`),JA(T.COMPLETE,`Finished a turn you have not looked at yet.`),JA(T.IDLE,`Ready for the next prompt.`),JA(T.DONE,`The agent process ended.`),JA(T.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 XA(e,t){let n=D(`section`,`status-legend`),r=D(`dl`,`status-legend-rows`);return r.append(...t),n.append(D(`h2`,`status-legend-title`,e),r),n}function ZA(e,t){let n=D(`div`,`status-legend-row`);return n.append(e,D(`dd`,`status-legend-meaning`,t)),n}function QA(){return XA(`Status colors`,YA.map(e=>{let t=D(`dt`,`status-legend-badge`),n=D(`span`,`status-legend-glyph`),r=D(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=ZA(t,e.meaning);return nn(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function $A(){return XA(`Pull request icons`,Object.keys(qA).map(e=>{let t=qA[e],n=D(`dt`,`status-legend-badge`);return n.append(Ci(e),D(`span`,`status-legend-name`,t.label)),ZA(n,t.meaning)}))}var ej=null,tj=null,nj=!1,rj=null;function ij(){return tj??=N(()=>import(`./first-run-checklist-Ct-fQ9SZ.js`).then(e=>(ej=e,e),e=>(tj=null,u(`first-run`,`first-run checklist failed to load: ${d(e)}`),null)),__vite__mapDeps([33,12,13,5,3,15,29,14,20,23,30,4,6,7,21,34,35])),tj}function aj(e,t){rj={host:e,isShown:t},ej?ej.showFirstRunChecklist(e,t):t&&nj&&ij().then(e=>{e&&rj&&e.showFirstRunChecklist(rj.host,rj.isShown)})}function oj(){ej?.refreshFirstRunChecklist()}function sj(){nj=!0,rj&&aj(rj.host,rj.isShown)}var cj=`(no path)`;function lj(e){if(!e)return cj;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||cj}function uj(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):cj),s=i.get(o);s||(s=r?{...r,projectPath:null,rows:[]}:{key:o,label:o===cj?cj:lj(o),title:o,projectPath:o===cj?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 dj(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 fj(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 pj=`removed`,mj=new Set([T.COMPLETE,T.DONE,T.FAILED,pj]);function hj(e){return mj.has(e)}function gj(e,t){let n=e.filter(e=>hj(t(e))).length;return{settled:n,total:e.length,isAllSettled:e.length>0&&n===e.length}}var _j=[],vj=new Set;function yj(e){vj.add(e)}function bj(){return _j}function xj(e){_j=e.races;for(let e of vj)e()}function Sj(e){let t=Cj(e.id);if(!t)return null;let n=gj(Object.values(t.sessionIdByContestant),e=>k.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 Cj(e){return _j.find(t=>Object.values(t.sessionIdByContestant).includes(e))??null}var wj=()=>{};function Tj(e){wj=e.openTerminal}function Ej(e){wj(e)}function Dj({onAdd:e}){let t=D(`div`,`session-group-header`),n=D(`span`,`session-group-label`),r=D(`span`,`session-group-count`),i=D(`span`,`session-group-rule`);i.setAttribute(`aria-hidden`,`true`);let a=w({variant:`icon`,size:`small`,label:`Add session to this project`,icon:C($e),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 Oj(e,t){let{header:n,label:r,count:i,addButton:a}=e;gi(n,`path`,t.projectPath??``),gi(n,`label`,t.label),Xr(r,t.label),Xr(i,String(t.rows.length)),ei(a,t.projectPath===null)}var kj={waitingCount:0,finishedCount:0,failedCount:0},Aj={failed:qt[T.FAILED],waiting:qt[T.WAITING],finished:qt[T.COMPLETE]},jj={failed:`failed`,waiting:`needs you`,finished:`finished`},Mj=[`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`],Nj=2500,Pj=`cubic-bezier(0.16, 1, 0.3, 1)`,Fj=`cubic-bezier(0.5, 0, 0.2, 1)`,Ij=260,Lj=200,Rj=200,zj=300,Bj=28,Vj=360,Hj=420,Uj=200,Wj=3,Gj=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),Kj=new WeakMap;function qj(e){let t=Kj.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function Jj(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function Yj(){return Gj?.matches??!1}function Xj(e){return e.map(e=>({easing:Pj,...e}))}function Zj(e,t){let n=D(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${Nn.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${Nn.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${Nn.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${Nn.overflowSlot}px`);let r=D(`span`,`attention-banner-chips`),i=D(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=D(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=D(`span`,`attention-banner-status`);o.append(r,D(`span`,`attention-banner-count`),a);let s=Ze(`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),Kj.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(()=>$j(n)).observe(r),Qj(n,kj,[]),n}function Qj(e,t,n){let r=qj(e);r.tiles=n,Xr(Vt(e,`.attention-banner-count`),Dn(t));let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&hM(e,r),$j(e)}function $j(e){let t=qj(e),n=Vt(e,`.attention-banner-chips`),r=Vt(n,`.attention-tile-overflow`),i=Jj(e),a=t.tiles.slice(0,On(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():rM(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??tM(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),nM(s,i,a===0),(s.parentElement!==n||eM(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;ei(r,p===0),Xr(r,`+${p}`),Jr(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)&&sM(e,null),i){for(let e of d)iM(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?oM(r,a):a!==0&&aM(r,a,n)})}}function eM(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function tM(e,t){let n=D(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=D(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>sM(e,t)),n.addEventListener(`pointerleave`,()=>sM(e,null)),n}function nM(e,{kind:t,name:n},r){e.dataset.kind=t,e.toggleAttribute(`data-head`,r);let i=`${n}, ${jj[t]}`;e.setAttribute(`aria-label`,i),Wn(Vt(e,`.attention-tile-icon`),Aj[t])}function rM(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=Yj()?[{opacity:1},{opacity:0}]:Xj([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:Rj,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function iM(e){let t=Yj()?[{opacity:0},{opacity:1}]:Xj([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:Lj})}function aM(e,t,n){Yj()||e.animate(Xj([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:zj,delay:n*Bj,fill:`backwards`})}function oM(e,t){Yj()?e.animate([{opacity:.35},{opacity:1}],{duration:Vj,easing:Pj}):e.animate(Xj([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:Vj})}function sM(e,t){let n=qj(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 cM(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function lM(e,t,n){let r=qj(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!Jj(e)){n();return}sM(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=cM(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(uM(o,s),dM(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function uM(e,t){return!t||Yj()?[{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 dM(e){return!e||Yj()?{duration:Uj,fill:`forwards`}:{duration:Hj,easing:Fj,fill:`forwards`}}function fM(e){let t=qj(e);e.hasAttribute(`data-empty`)&&mM(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!Jj(e))return;let n={duration:Ij};if(t.pressAnimations.push(e.animate(Xj([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!Yj()){t.pressAnimations.push(e.animate(Xj([{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(Xj([{transform:`none`},{transform:`translateY(${Wj}px)`,offset:.3},{transform:`none`}]),n),r.animate(Xj([{transform:`none`},{transform:`translateY(-${Wj}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function pM(e){let t=Mj.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??Mj[0]}function mM(e,t){let n=pM(t.lastAllClearLine);t.lastAllClearLine=n,Vt(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>hM(e,t),Nj)}function hM(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var gM={terminal:`Terminal`,board:`Board`},_M=[`terminal`,`board`],vM=.05,yM=`application/x-glimmervoid-pane-tab`;function bM(){let e=Ir(),t=new Set([`terminal`]),n=vr(e,t),r=null,i=D(`div`,`pane-layout`),a=D(`div`,`pane-trail`),o=D(`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=D(`div`,`pane-body`);return t.id=`focus-pane-${e}`,t.dataset.pane=e,t.setAttribute(`role`,`tabpanel`),t}function p(e){let t=D(`div`,`pane-title`);return t.dataset.tab=e,t}function m(t){let n=Ze(`pane-tab`);return n.append(D(`span`,`sr-only`,gM[t])),n.draggable=!0,n.dataset.tab=t,n.setAttribute(`role`,`tab`),n.setAttribute(`aria-controls`,`focus-pane-${t}`),n.addEventListener(`click`,()=>v(Fr(e,t))),n.addEventListener(`dragstart`,e=>{r=t,e.dataTransfer?.setData(yM,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`),i.dataset.dragging=``}),n.addEventListener(`dragend`,_),n}function h(t){let i=D(`section`,`pane-group`),a=D(`div`,`pane-strip pane-header`),o=D(`div`,`pane-tabs`);o.setAttribute(`role`,`tablist`),a.append(o);let s=D(`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(hr(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 wr(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,Kr(e),x())}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 b(e,t,n){let r=l[t];r.hidden=!n,e.tabList.nextElementSibling!==r&&e.tabList.after(r)}function x(){n=vr(e,t);for(let e of _M)l[e].hidden=!0,t.has(e)||(s[e].hidden=!0);let r=Lr(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),b(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 ne(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=jr(e,ne(t)),x())});let re=t=>{o.hasPointerCapture(t.pointerId)&&(o.releasePointerCapture(t.pointerId),delete o.dataset.dragging,Kr(e))};return o.addEventListener(`pointerup`,re),o.addEventListener(`pointercancel`,re),o.addEventListener(`keydown`,t=>{let n={ArrowLeft:-.05,ArrowUp:-.05,ArrowRight:vM,ArrowDown:vM}[t.key];n!==void 0&&e.kind===`split`&&(t.preventDefault(),v(jr(e,e.firstShare+n)))}),x(),{element:i,trailSlot:a,bodyOf:e=>s[e],titleSlotOf:e=>l[e],setStripHost:(e,t)=>{t&&u.set(e,t),t||u.delete(e),x()},showTabs:e=>{t=e,x()},showTab:t=>v(Fr(e,t))}}var xM=[],SM=new Set,CM=new WeakSet,wM=null,TM=null;function EM(e){xM.some(t=>t.id===e.id)||(xM.push(e),OM(e.id,null))}function DM(){return xM}function OM(e,t){for(let n of SM)n(e,t)}function kM(e){return SM.add(e),()=>SM.delete(e)}function AM(e){e!==wM&&(PM(),wM=e)}function jM(e){wM===e&&(PM(),wM=null)}function MM(e,t){return TM?.page.id===e&&TM.sessionId===t}function NM(e,t,n=null){let r=xM.find(t=>t.id===e);if(!r||!wM||wM.sessionId()!==t||!r.isAvailableFor(t)||MM(e,t)&&n===null)return;PM();let i=wM,a=i.elementFor(r);LM(a),TM={page:r,sessionId:t},r.mount(a,t,{placement:i.placement,target:n}),i.didShow(r),OM(r.id,t)}function PM(){if(!TM)return;let{page:e,sessionId:t}=TM;TM=null,e.unmount(),wM?.didHide(e),OM(e.id,t)}function FM(){return TM?.page.canStepBack()??!1}function IM(){return TM?TM.page.canStepBack()?(TM.page.stepBack(),!0):(PM(),!0):!1}function LM(e){CM.has(e)||(CM.add(e),e.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Bt(e)||IM()&&e.preventDefault()}))}function RM({style:e}){let t=D(`div`,`session-page-bar session-page-bar-${e}`),n=new Map,r=null;function i(n){let i=e===`header`,a=w({variant:`quiet`,size:i?`small`:`default`,label:n.label,icon:C(n.iconPath),action:`${i?`open`:`show`}-${n.id}`});a.addEventListener(`click`,()=>{r&&NM(n.id,r)});let o=D(`span`,`session-page-dot`);o.setAttribute(`aria-hidden`,`true`);let s=D(`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 xM)a(e)}return kM((e,t)=>{if(t!==null&&t!==r)return;let n=xM.find(t=>t.id===e);n&&a(n)}),o(),{element:t,showSession(e){r=e,o()}}}var zM=5,BM={high:`High`,medium:`Medium`,low:`Low`};function VM(e,t){let n=Ze(`review-look-line`,e.path);return n.append(D(`span`,`review-look-detail`,e.detail)),n.addEventListener(`click`,()=>t(e.openPath)),n}function HM(e,t){let n=D(`div`,`review-look-group`);n.dataset.kind=e.kind;let r=D(`p`,`review-look-text`,e.heading);if(e.conflictRisk){let t=D(`span`,`review-look-risk`,`Conflict risk: ${BM[e.conflictRisk]}`);t.dataset.risk=e.conflictRisk,r.append(` `,t)}n.append(r);for(let r of e.lines)n.append(VM(r,t));return n}function UM(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=D(`section`,`review-look`);if(i.append(D(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=D(`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,zM);if(a.length>0){let e=D(`div`,`review-look-list`);for(let t of a)e.append(HM(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=D(`div`,`review-look-more`),c=w({variant:`quiet`,size:`small`,label:`Show all`,action:`show-all-worth-a-look`,onClick:n});return s.append(D(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function WM(e){return(e??[]).map(e=>D(`span`,`review-file-hint`,e.text))}var GM=`changes`,KM={add:`+`,del:`-`,meta:`\\`},H=null,qM=null,U=null,W=null,JM=null,YM=!1;function XM(){let e=D(`section`,`review-reader`);e.setAttribute(`aria-label`,`Changes`),e.tabIndex=-1,e.hidden=!0;let t=D(`div`,`review-reader-bar`),n=D(`p`,`review-reader-status`);n.setAttribute(`role`,`status`);let r=D(`p`,`review-reader-notice`);r.setAttribute(`role`,`status`);let i=D(`div`,`review-reader-actions`),a=w({variant:`primary`,label:`Merge`,action:`merge-session`,onClick:()=>{U&&I_(U)}}),o=w({variant:`danger`,label:`Discard`,action:`discard-session`,onClick:()=>{U&&L_(U)}}),s=w({variant:`secondary`,label:`Close`,action:`close-reader`,onClick:PM});i.append(a,o,s),t.append(n,r,i);let c=D(`div`,`review-reader-body`),l=D(`div`,`review-reader-files`),u=D(`div`,`review-reader-diff`);return c.append(l,u),e.append(t,c),e.addEventListener(`keydown`,QM),h_(e=>{e===U&&nN()}),Qr(()=>{W=null,YM=!1,nN(),$M()}),B_(e),{root:e,status:n,notice:r,mergeButton:a,discardButton:o,closeButton:s,fileColumn:l,diff:u}}function ZM(){return H??=XM(),H}function QM(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Bt(e))return;let t=e.key===`j`?1:e.key===`k`?-1:0;if(t===0||!U)return;e.preventDefault();let n=Yg(b_(U)?.files??[],W,t);n&&eN(n)}function $M(){U&&OM(GM,U)}function eN(e){W=e,nN(),H?.fileColumn.querySelector(`.review-reader-file[aria-current="true"]`)?.scrollIntoView({block:`nearest`}),$M()}function tN(e){let t=Jg(e,JM);t&&(W=t.path,JM=null),!Jg(e,W)&&(W=qM===`overlay`?e[0]?.path??null:null)}function nN(){if(!H||qM===null)return;U=Yr();let e=U?b_(U):null;if(H.closeButton.hidden=qM!==`overlay`,!e){rN(H);return}let t=W!==null;tN(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=qM===`screen`&&W!==null?`diff`:`list`,iN(H.fileColumn,e),cN(H.diff,Jg(e.files,W)),t!==(W!==null)&&$M()}function rN(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 iN(e,t){let n=e.scrollTop;if(e.replaceChildren(),t.diffError){e.append(D(`p`,`review-diff-error`,t.diffError));return}if(t.isEmpty){e.append(D(`p`,`review-empty-title`,t.sentence));return}t.totals.files>0&&e.append(aN(t.totals));let r=D(`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?Fg(i,e.path):null;n&&n!==a&&r.append(D(`div`,`review-repo-label`,n)),a=n,r.append(oN(e,t))}e.append(r);let o=t.changeMapView?UM(t.changeMapView,{isShowingAll:YM,onShowAll:lN,onOpenFile:uN}):null;o&&e.append(o),e.scrollTop=n}function aN(e){let t=D(`p`,`review-reader-totals`);return t.append(D(`span`,`review-stat-files`,`${e.files} file${e.files===1?``:`s`}`),D(`span`,`review-add`,`+${e.added}`),D(`span`,`review-del`,`-${e.removed}`)),t}function oN(e,t){let n=Ze(`review-reader-file`);n.dataset.path=e.path,n.setAttribute(`role`,`listitem`),n.setAttribute(`aria-current`,String(e.path===W));let r=D(`span`,`review-file-name`);r.append(D(`span`,`review-file-path`,e.path));let i=WM(t.changeMapView?.hintsByOpenPath.get(e.path));if(i.length>0){let e=D(`span`,`review-file-hints`);e.append(...i),r.append(e)}return n.append(r,sN(e)),n.addEventListener(`click`,()=>eN(e.path)),n}function sN(e){let t=D(`span`,`review-file-counts`);return e.binary?(t.append(D(`span`,`review-bin`,`bin`)),t):(t.append(D(`span`,`review-add`,`+${e.added}`),D(`span`,`review-del`,`-${e.removed}`)),t)}function cN(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=D(`div`,`review-reader-diff-head`);if(r.append(D(`span`,`review-file-path`,t.path),sN(t)),e.append(r),t.binary){e.append(D(`div`,`review-file-binary`,`Binary file not shown`));return}let i=D(`div`,`review-file-body`);for(let e of t.hunks){i.append(D(`div`,`review-hunk-head`,e.header));for(let t of e.lines){let e=D(`div`,`review-line review-line-${t.type}`);e.append(D(`span`,`review-line-gutter`,KM[t.type]??` `),D(`span`,`review-line-text`,t.text)),i.append(e)}}e.append(i),e.scrollTop=n}function lN(){YM=!0,nN()}function uN(e){let t=Jg(U?b_(U)?.files??[]:[],e);t&&eN(t.path)}function dN(e,t){let{root:n}=ZM();n.parentElement!==e&&e.append(n),qM=t,n.dataset.placement=t,n.hidden=!1}function fN(){H&&(H.root.hidden=!0,H.root.remove(),qM=null)}function pN(){W!==null&&(W=null,nN(),$M())}function mN(e,t){t===`header`&&(B_(e),new MutationObserver(z_).observe(e,{attributes:!0,attributeFilter:[`data-slot-held`]}))}h_(e=>OM(GM,e));var hN={id:GM,label:`Changes`,iconPath:mt,isAvailableFor:e=>b_(e)!==null,hasUnreadFor:()=>!1,mount(e,t,{placement:n,target:r}){dN(e,n),JM=r,nN(),n===`overlay`&&ZM().root.focus({preventScroll:!0})},unmount:fN,canStepBack:()=>qM===`screen`&&W!==null,stepBack:pN,attachButton:mN};function gN(){EM(hN)}var _N=new Set([`terminal`]),vN=new Set([`terminal`,`board`]),yN=new Set([`board`]),bN=e=>e.ui.path,xN=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),SN=null,G=null,CN=null,wN=null,K=null,TN=null,EN=null,DN=null,ON=null,kN=null,AN=null,q=null,jN=null,MN=new Map,NN=null,PN=null,FN=null,J=!1,IN=!1,LN=null,RN=new Map,Y=new Map,zN=new Map,BN=new Map,X=null,VN=``,HN=[],UN=new Set;function WN(){return dj(KN(nP()),UN)}function GN(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 KN(e){return uj(e,bN,Sj)}function qN(e){let t=BN.get(e.key),n=zN.get(e.key);return(!t||!n)&&(t=Dj({onAdd:ii}),n=D(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),BN.set(e.key,t),zN.set(e.key,n)),Oj(t,e),Jr(n,`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function JN(){return J}function Z(){return M.snapshot().focusedSessionId}function YN(){return J&&q!==null}function XN({rail:e,center:t,resizer:n}){if(SN=e,CN=t,!SN||!CN)return;let r=SN,i=CN;$N(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,Sr(Rl)),G=Zj({onJump:xP,rowFor:e=>Y.get(e)},Wl());let a=D(`details`,`rail-section rail-status-key`);a.append(D(`summary`,`rail-section-summary`,`Status key`),QA()),fP(a,rr(),fr),r.append(G,a),NN=D(`div`,`focus-empty`),NN.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,PN=NN.querySelector(`.focus-empty-title`),FN=NN.querySelector(`.focus-empty-desc`),K=bM(),K.element.addEventListener(`click`,DP),wN=K.bodyOf(`terminal`),jN=pP(),gN(),TN=RM({style:`header`}),K.trailSlot.append(TN.element),i.append(NN,K.element),yj(()=>{J&&dP()}),Rk(()=>{if(!J)return;let e=q!==null;dP(),e&&q===null&&JP()}),r.addEventListener(`keydown`,eP)}var ZN={minPx:180,maxPx:480},QN=16;function $N(e){e&&SN&&KA({resizer:e,column:SN,widthHost:SN,widthProperty:`--rail-width`,bounds:ZN,keyStepPx:QN,getStoredWidth:Dr,setStoredWidth:dr})}function eP(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(),ai(n);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=tP(),n=t.find(t=>t===e.target)??(X?Y.get(X):null),r=n?t.indexOf(n):-1,i=wn(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&&GN(a.dataset.id),a.focus())}function tP(){return SN?[...SN.querySelectorAll(`button.session-row[data-id], button.session-row[data-board-id]`)].filter(e=>!e.closest(`details:not([open])`)):[]}function nP(){return kn(di(rP))}function rP(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function iP(e){let{row:t,refs:n}=pn();t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,()=>aP(e)),t.addEventListener(`pointerenter`,()=>{G&&sM(G,e)}),t.addEventListener(`pointerleave`,()=>{G&&sM(G,null)});let{item:r,removeButton:i}=an(t,()=>ai(e),()=>vi(e));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,Object.assign(t,{_refs:n,_row:r})}function aP(e){let t=mi(e);t&&sP(t,e)}function oP(e){let t=mi(e);t&&sP(t,e)}function sP(e,t){LP(t),CP(e,t)}function cP(e,{id:t,ui:n,state:r,name:i},a){let o=RN.get(t)||`none`;e.classList.toggle(`focused`,t===Z()),un(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a});let s=t===X;Jr(e,`aria-selected`,String(s)),Jr(e,`tabindex`,s?`0`:`-1`)}function lP(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||``:Zn(r._refs?.glyph))}Gn(lP),Qn((e,t)=>{if(!J)return;let n=Y.get(e);n&&Xr(n._refs.elapsed,Xn(t))});var uP=new Map;function dP(e){if(!J)return;let t=SN;if(!t)return;let n=nP(),r=KN(n),i=new Set,a=An(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=iP(t),Y.set(t,r));let s=o.get(t)??null;(!e||a||e.has(t)||uP.get(t)!==s)&&cP(r,n,s),uP.set(t,s)}a||_i(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===VN;VN=l;for(let e of r.groups){let{header:n,list:r}=qN(e);u||t.append(n,r),s(e.rows,r)}jN&&(!u||jN.section.parentElement!==t)&&t.append(jN.section),jN&&hP(jN);for(let[e,t]of[...BN])c.has(e)||(t.header.remove(),zN.get(e)?.remove(),BN.delete(e),zN.delete(e));for(let[e,t]of Y)i.has(e)||(t._row.remove(),Y.delete(e),uP.delete(e),e===X&&(X=null));for(let e of[...RN.keys()])k.has(e)||RN.delete(e);let d=HN;HN=dj(r,UN);let f=Z();if(f&&!ni(f)){PM(),M.dispatch(`focusSession`,null),X=null;let e=vP(d,f);if(e){let t=!document.activeElement||document.activeElement===document.body;LP(e),t&&CP(k.get(e),e);return}}RP();let p=Z();if(p){let e=k.get(p);e&&e.card.parentElement!==wN&&TP(e,p)}TN?.showSession(q?null:p),MP(),bP(n,a)}function fP(e,t,n){e.open=t,e.addEventListener(`toggle`,()=>n(e.open))}function pP(){let e=D(`div`,`rail-section rail-boards`),t=D(`details`,`rail-boards-details`),n=D(`span`,`session-group-count`),r=D(`summary`,`rail-section-summary`);r.append(`Boards `,n);let i=D(`div`,`focus-rail-list focus-board-list`);i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,`Boards with no session`),t.append(r,i),fP(t,cr(),ar);let a=w({variant:`icon`,size:`small`,label:`New board`,icon:C($e),action:`new-board`,onClick:_P});return a.classList.add(`rail-section-action`),e.append(t,a),{section:e,count:n,list:i}}function mP(e){let{row:t,refs:n}=pn();t.dataset.boardId=e,t.addEventListener(`click`,()=>gP(e));let r=D(`div`,`session-row-item`);return r.append(t),Object.assign(t,{_refs:n,_row:r})}function hP(e){let t=Fk();q&&!t.some(e=>e.id===q)&&(q=null);let n=fj(t,e=>k.has(e)),r=new Set(n.map(e=>e.id));for(let[e,t]of MN)r.has(e)||(t._row.remove(),MN.delete(e));for(let e of n){let t=MN.get(e.id);t||(t=mP(e.id),MN.set(e.id,t)),gn(t,t._refs,e.title),t.classList.toggle(`focused`,e.id===q)}_i(e.list,n.flatMap(e=>MN.get(e.id)?._row??[])),Xr(e.count,String(n.length)),Jr(e.count,`aria-label`,`${n.length} ${n.length===1?`board`:`boards`} with no session`)}function gP(e){J&&(IP(),q=e,kN=null,GN(null),dP())}function _P(){OP().then(e=>e.createBoardFromDialog(gP),kP)}function vP(e,t){let n=e.filter(e=>e===t||ni(e));if(n.length<2)return HN.find(e=>ni(e))??null;let r=n.indexOf(t)===n.length-1;return wn(n,t,r?-1:1)}function yP(){return An(nP(),Z())}function bP(e,t){G&&Qj(G,Pn(e),t)}function xP(){if(!J)return;G&&fM(G);let e=yP()[0]?.id;e&&SP(e)}function SP(e){J&&(mi(e),Y.get(e)?.scrollIntoView({block:`nearest`}),G&&lM(G,e,()=>wP(e)),LP(e),CP(k.get(e),e))}function CP(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{J&&Z()===t&&e.term?.focus()}))}function wP(e){if(xN?.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=k.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function TP(e,t){if(!wN)return;let n=e.card.querySelector(`:scope > .session-card-header`);gA(e,t,wN,{className:`focus-centered`,onRelease:()=>{n?.classList.remove(`pane-header`),K?.setStripHost(`terminal`,null)}}),n?.classList.add(`pane-header`),n&&EP(n),Zu(e,t,!0)}function EP(e){let t=e.querySelector(`:scope > .session-name`);K?.setStripHost(`terminal`,{parent:e,before:t})}function DP(e){if(!(e.target instanceof Element)||!e.target.closest(`.pane-tab[data-tab="terminal"]`))return;let t=Z(),n=t?k.get(t):null;n&&n.face!==`terminal`&&n._showTerminalFace?.()}function OP(){return EN??=N(()=>import(`./boards-view-CV4wmZLl.js`).then(e=>(DN=e,e)),__vite__mapDeps([36,13,5,3,14,20,15,12,31,24,37])),EN}function kP(e){EN=null,u(`focus`,`the board pane failed to load: ${d(e)}`)}function AP(e){K&&AN!==e&&(AN=e,K.showTabs(e))}function jP(e){AP(yN);let t=ON!==null||kN!==e;ON=null,kN=e,OP().then(n=>NP(n,null,t?e:null),kP)}function MP(e=null){if(q){jP(q);return}let t=Z(),n=t?tA(t):[],[r]=n;if(AP(r?vN:_N),!t||!r){ON=null,kN=null;return}let i=n.some(e=>e.id===kN),a=ON!==t||e!==null||!i;ON=t;let o=a?e??r.id:null;o&&(kN=o),OP().then(e=>NP(e,t,o),kP)}function NP(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 PP(){J&&(ON||q)&&DN?.reopenSelectedBoard()}function FP(){let e=iA();J&&e?.sessionId&&k.has(e.sessionId)&&(LP(e.sessionId),MP(e.boardId),K?.showTab(`board`))}function IP(){PM();let e=Z();e&&(mA()===e&&_A(),M.dispatch(`focusSession`,null))}function LP(e){J&&k.has(e)&&(Dx(e),fi(e),e!==Z()&&(IP(),q=null,M.dispatch(`focusSession`,e),X=e,dP()))}function RP(){if(!NN||!PN||!FN)return;let e=Z(),t=!!q||!!(e&&k.has(e)),n=k.size>0;ei(NN,t),K&&ei(K.element,!t),aj(NN,!n),ei(PN,!n),ei(FN,!n),!t&&n&&(Xr(PN,`No session selected`),Xr(FN,`Select a session from the rail on the left to focus it here.`))}function zP(e,t){RN.set(O(e),typeof t==`string`&&t?t:`none`),J&&dP()}var BP={placement:`overlay`,sessionId:()=>J&&CN&&!q?Z():null,elementFor:()=>{if(!CN)throw Error(`Focus view is not mounted`);return CN},didShow:()=>{},didHide:()=>{let e=Z();e&&CP(k.get(e),e)}};function VP(e=null){let t=Z();t&&NM(`changes`,t,e)}function HP(e){J&&k.has(e)&&LP(e)}function UP(e){return!J||!k.has(e)?!1:(LP(e),by(e))}function WP(e){if(!J)return;let t=WN()[e-1];t&&ni(t)&&aP(t)}function GP(e){if(!J)return;let t=WN().filter(e=>e===X||ni(e)),n=wn(t,X,e);n!=null&&ni(n)&&(oP(n),Y.get(n)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=Z();J&&e&&Dx(e)});function KP(){SN&&(J=!0,AM(BP),IP(),X=null,dP(),IN&&LN?SP(LN):IN&&yP().length>0?xP():(IN&&G&&fM(G),JP()))}function qP(e,t=null){IN=!0,LN=t;try{e()}finally{IN=!1,LN=null}}function JP(){if(!J||Z()||q)return;let e=li();e&&LP(e)}function YP(){J&&=(IP(),jM(BP),X=null,!1)}var XP=[],ZP=new Set;function QP(e){let t=rt.safeParse(e);if(t.success){XP=t.data;for(let e of ZP)e()}}function $P(e){return XP.find(t=>t.agent===e)??null}function eF(e){return ZP.add(e),()=>{ZP.delete(e)}}var tF=2e3,nF={},rF=null,iF=null,aF=ut,oF=null,sF=!1,cF=null,lF=[],uF=null,dF=()=>null,fF=()=>{},pF=!1,mF=new Set,hF=new Set;function gF(e){for(let t of hF)t(e)}function _F(e){hF.add(e)}function vF(){return nF}function yF(e){return nF={...nF,...e},nF}function bF(){return{status:rF,journal:iF,request:aF,lastAutoCheckAt:oF,isCheckInFlight:sF,checkSendFailure:cF}}function xF(e){let t=Fe(aF,e);t!==aF&&(aF=t,gF({kind:`update`,frame:`request`}))}function SF(){xF(v({type:`update-apply`})?`request-sent`:`request-unsent`)}function CF(){oF=Date.now();let e=v({type:`update-check`});sF=e,cF=e?null:De,gF({kind:`update`,frame:`request`})}function wF(e){fF=e}function TF(){fF()}function EF(e){lF=[...e]}function DF(){return lF}function OF(e=null,t=null,n=null){let r=uF!==null&&(uF.sectionId!==null||uF.isLink);e===null&&n===null&&r||(uF={sectionId:e,settingId:t,hashAtRequest:n??location.hash,isLink:n!==null},gF({kind:`activate`}))}function kF(){let e=uF;return uF=null,e}function AF(e){dF=e}function jF(){for(let e of mF)e()}function MF(e){mF.add(e)}function NF(){return yo()&&dF()===`section`}function PF(){NF()&&gF({kind:`return-to-list`})}function FF(e){e&&(nF=e,QP(nF.agentLogins),gF({kind:`broadcast`}))}function IF(){pF||(pF=!0,window.setTimeout(()=>{a(`get-settings`,{}).then(e=>{e.settings&&FF(e.settings)}).catch(()=>{pF=!1})},tF))}function LF(){gF({kind:`status`})}function RF(e){LF()}function zF(e){rF=e,sF=!1,cF=null,aF=Fe(aF,`status-frame`),gF({kind:`update`,frame:`status`})}function BF(e){iF=e,aF=Fe(aF,`progress-frame`),gF({kind:`update`,frame:`progress`})}function VF(e){if(e.scope!==`update`)return!1;let t=Ve(e.message),n=aF.requested;return aF=Fe(aF,`error-frame`,t),sF=!1,n||(cF=t),gF({kind:`update`,frame:`error`}),!0}var HF=200;function UF(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function WF(e){return/^#settings(?:[/?]|$)/.test(e)}function GF(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function KF(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,HF).join(``).trim()}}function qF(e,t,n){let r=D(`a`,`settings-link`,n);return r.href=UF(e,t),r}var JF={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},YF=[{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`}],XF=null,ZF=null,QF=null,$F=()=>!1,eI=new Set,tI=new Set,nI=Et({getAck:Mr,setAck:Nr,signature:()=>xt({posthog:XF}),isLooking:()=>$F()});function rI(e){for(let t of tI)t(e)}function iI(){ZF?.(nI.refresh())}function aI(){return{latest:XF,archivedLocally:eI,traceOpener:QF}}function oI(e){tI.add(e)}function sI(e){$F=e,iI()}function cI(e){eI.add(e)}function lI(){nI.acknowledge(),iI()}function uI(e){ZF=e,iI()}function dI(e){QF=e}function fI(e){XF=e,wt(XF,eI),rI({kind:`status`}),iI()}function pI(e){let t=qe(XF,e.projectId,e.issueId)?.inFlight===!0;gt(XF,e)&&rI({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function mI(e){let t=xe(XF,e);rI({kind:`investigation-finished`,frame:e,isPatched:t}),t&&iI()}var hI=null,gI=[],_I=()=>!1,vI=null,yI=kr(),bI=Pr(),xI=new Set(bI.split(`|`).filter(Boolean)),SI=new Set;function CI(e){for(let t of SI)t(e)}function wI(){return lm(gI).map(cm)}function TI(e){e!==yI&&(yI=e,sr(e))}function EI(e){e!==bI&&(bI=e,xI=new Set(e.split(`|`).filter(Boolean)),Tr(e))}function DI(){if(!hI)return;let e=bm({turnEntries:wI(),acknowledged:yI,unseen:bI,isLooking:_I()});TI(e.acknowledged),EI(e.unseen),vI?.(e.isShown)}function OI(e){SI.add(e)}function kI(){return hI}function AI(){return gI}function jI(e){_I=e,DI()}function MI(e){vI=e,DI()}function NI(){hI&&(TI(Xe(wI())),DI())}function PI(){return bI}function FI(e){return xI.has(e)}function II(e){return xI.has(e)?(EI(Xe([...xI].filter(t=>t!==e))),!0):!1}function LI(e){let t=vt.safeParse(e);t.success?(hI=t.data,gI=sm(t.data.entries),DI(),CI({kind:`status`})):u(`community`,`dropped community-status: ${c(t.error.issues)}`)}function RI(e){CI({kind:`connection`,isConnected:e})}function zI({source:e,className:t,title:n,allowsScripts:r}){let i=D(`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 BI=`panel-action`,VI=524288,HI=[`key`,`prKey`,`repo`,`number`,`action`,`actionId`,`itemKey`,`fingerprint`],UI=900;function WI(e){let t=pt.options.find(t=>t.shape.type.value===e);return new Set(Object.keys(t?.shape??{}).filter(e=>e!==`type`&&e!==`requestId`))}function GI(e){return e.map(e=>`${e.path.map(String).join(`.`)||`request`}: ${e.message}`).join(`; `)}function KI(e,t){let n=Ne.safeParse(t);if(!n.success)return{ok:!1,error:`not sent: ${GI(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=pt.safeParse({...n.data,requestId:BI});if(!r.success)return{ok:!1,error:`${n.data.type} not sent: ${GI(r.error.issues)}`};let i=WI(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 ${VI} byte limit`}:{ok:!0,type:r.data.type,payload:a}}function qI(e,t,n){return`${e} sent ${t} ${HI.flatMap(e=>{let t=n[e];return typeof t==`string`||typeof t==`number`?[`${e}=${t}`]:[]}).join(` `)}`.trim().slice(0,UI)}var JI=`•`.repeat(8),YI=`[^/\\\\\\s"'\`<>:]+`,XI=RegExp(`(?<![\\w./\\\\-])(?:/home/${YI}|/Users/${YI}|[A-Za-z]:[\\\\/]Users[\\\\/]${YI}|/root(?![\\w.-]))`,`g`);function ZI(e){let t=rc(e);if(t.length===0)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+JI,r=i.end;return n+e.slice(r)}function QI(e){return e.replace(XI,`~`)}function $I(e){return QI(ZI(e))}var eL=1e3,tL=12e4,nL=new Map,rL=null;function iL(e){return cc()?$I(e):e}var aL={sessions:()=>({sessions:[...k].map(([e,t])=>({id:e,name:iL(Tn(t)),agent:t.agent??null,state:t.currentState,stateSinceMs:t.stateSince,taskTitle:t.taskTitle===null?null:iL(t.taskTitle)}))}),focus:()=>({sessionId:M.snapshot().focusedSessionId,view:M.snapshot().activeView,isStreamerMode:cc()}),theme:()=>Ta(),usage:()=>({planLimits:Object.entries(gT().planLimitsByVendor).flatMap(([e,t])=>t===null||e!==`claude`&&e!==`codex`&&e!==`kimi`?[]:[{vendor:e,fiveHour:Xx(t,`fiveHour`),sevenDay:Xx(t,`sevenDay`)}])}),attention:()=>{let e=Pn([...k.values()].map(e=>({state:e.currentState,unseenOutcome:e.unseenOutcome??null})));return{waiting:e.waitingCount,finished:e.finishedCount,failed:e.failedCount}},reviews:()=>yh()};function oL(e,t){e.frame.contentWindow?.postMessage(t,`*`)}function sL(e,t){let n=t.get(e);if(n)return n;let r=aL[e](),i={data:r,dataJson:JSON.stringify(r)};return t.set(e,i),i}function cL(e,t,n=new Map){let{data:r,dataJson:i}=sL(t,n);e.lastSentJsonByTopic.get(t)!==i&&(e.lastSentJsonByTopic.set(t,i),oL(e,Oe.parse({v:1,kind:`topic`,topic:t,data:r})))}function lL(){let e=!1,t=new Map;for(let n of nL.values()){for(let e of n.subscribedTopics)cL(n,e,t);e||=n.subscribedTopics.size>0}e||rL===null||(clearInterval(rL),rL=null)}var uL=new Map;async function dL(e,t){let n=await a(e,t).catch(e=>qb(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 fL(e,t){oL(e,{v:1,kind:`store`,data:uL.get(e.packName)??{},error:t})}async function pL(e){let t=await dL(`pack-data-get`,{pack:e.packName});t.ok&&uL.set(e.packName,t.data),fL(e,t.ok?null:t.error)}async function mL(e,t,n){let r=Ee(e.packName,be(uL.get(e.packName)??{},t,n));if(r!==null){fL(e,r);return}let i=await dL(`pack-data-set`,{pack:e.packName,key:t,value:n});if(!i.ok)fL(e,i.error);else{uL.set(e.packName,i.data);for(let t of nL.values())t.packName===e.packName&&fL(t,null)}}function hL(e,t){e.subscribedTopics=new Set(t.filter(t=>e.grantedTopics.has(t))),e.lastSentJsonByTopic.clear(),oL(e,{v:1,kind:`hello`,granted:[...e.subscribedTopics]}),pL(e);for(let t of e.subscribedTopics)cL(e,t);rL??=setInterval(lL,eL)}function gL(e,t,n,r,i=!1){oL(e,{v:1,kind:`action-result`,id:t,ok:r===null,timedOut:i,result:n,error:r})}function _L(e,t){return t.ok===!1?typeof t.error==`string`&&t.error!==``?t.error:`${e} was refused`:null}async function vL(e,t,n){let r=KI(e.acts,n);if(!r.ok){gL(e,t,null,r.error);return}v({type:`client-log`,scope:`packs`,text:qI(e.viewId,r.type,r.payload)});let i=await a(r.type,r.payload,{timeoutMs:tL}).catch(e=>qb(e));if(i===`Request timed out`){gL(e,t,null,`${r.type} got no answer within ${tL/1e3} s; it may still run, so check before sending it again`,!0);return}if(typeof i==`string`){gL(e,t,null,`${r.type} failed: ${i}`);return}let o={...i};gL(e,t,o,_L(r.type,o))}function yL(e){let t=[...nL.values()].find(t=>t.frame.contentWindow!==null&&t.frame.contentWindow===e.source);if(!t)return;let n=Ae.safeParse(e.data);if(n.success){vL(t,n.data.id,n.data.request);return}let r=ge.safeParse(e.data);r.success&&(r.data.kind===`store-set`?mL(t,r.data.key,r.data.value):r.data.kind===`subscribe`&&hL(t,r.data.topics))}function bL(e,t,n){nL.size===0&&window.addEventListener(`message`,yL),nL.set(e,{viewId:e,frame:t,packName:n.pack,acts:n.acts,grantedTopics:new Set(n.reads),subscribedTopics:new Set,lastSentJsonByTopic:new Map})}var xL=null,SL=new Set;function CL(){return xL}function wL(e){return SL.add(e),()=>SL.delete(e)}function TL(e){let t=dt.safeParse(e);if(!t.success)u(`settings`,`dropped packs-status: ${c(t.error.issues)}`);else{xL=t.data,ya(t.data.themes)&&Da();for(let e of SL)e()}}var EL=`about:blank`,DL={pack:``,reads:[],acts:[]},OL=new Map,kL=new Map;function AL(e){let t=D(`img`,`pack-tab-icon`);return t.src=e,t.alt=``,t.decoding=`async`,t.referrerPolicy=`no-referrer`,t}function jL(e){return kL.set(e.viewId,e),{mount(t){let n=kL.get(e.viewId);t.replaceChildren(ML(e.viewId,n?.entryUrl??EL,e.label,n??DL))}}}function ML(e,t,n,r){let i=zI({source:{kind:`url`,url:t},className:`pack-panel-frame`,title:n,allowsScripts:!0});return OL.set(e,i),bL(e,i,r),i}function NL(e,t,n,r){let i=OL.get(e);i&&i.getAttribute(`src`)!==t&&i.replaceWith(ML(e,t,n,r))}function PL(e){kL.set(e.viewId,e),NL(e.viewId,e.entryUrl,e.label,e)}function FL(e){kL.delete(e),NL(e,EL,OL.get(e)?.title??``,DL)}function IL(e){let t=()=>e(CL()?.panels??[]);wL(t),t()}function LL(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function RL(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function zL(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 BL(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 VL(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function HL(e,t,n){t&&e?.refreshOn?.includes(n)&&t.refresh?.(n)}function UL(e,t,n,r){for(let i of e)LL(i.view,t)&&HL(i,r(i.view),n)}function WL(){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 GL(e,t,n){let r=Number(e);return!e||!Number.isFinite(r)||t-r>n}var KL=`glimmervoid:preload-error-reload-at`,qL=3e4,JL=1e3,YL=WL();function XL(e,t){let n=YL.mountedModuleOf(e.view);n?t(n):YL.show(e).then(t).catch(t=>{throw u(`view`,`${e.view} failed to show: ${d(t)}`),t})}function ZL(e){return YL.mountedModuleOf(e)}function QL(e){YL.mountEagerViews(e)}function $L(e){let t=()=>{YL.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,JL)}function eR(e){let t=Date.now();GL(e.getItem(KL),t,qL)&&(e.setItem(KL,String(t)),location.reload())}function tR(e){window.addEventListener(`vite:preloadError`,()=>eR(e()))}function nR(e,t){fetch(e,{method:`HEAD`,cache:`no-store`}).then(e=>{e.status===404&&eR(t())}).catch(()=>{})}function rR(e,t,n){let r=E(document,`#app-main`,`main`),i=Ze(`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)??D(`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=D(`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}=VL(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 iR(e){return e.iconUrl?AL(e.iconUrl):C(tt)}function aR(e){return rR({view:e.viewId,label:e.label,iconPath:``,panelClass:`pack-panel-view`,hasPanelChrome:!1,module:jL(e)},iR(e),()=>{})}function oR(e,t){e.tab.replaceChildren(iR(t),t.label)}function sR(e){uh({openTerminal:e.openTerminal,openReviews:e.openReviews}),Tj({openTerminal:e.openTerminal}),wF(e.onRestart),$k(e.openReviewFile);let t=[{view:`focus`,label:`Focus`,iconPath:ht,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,refreshOn:[`connected`],module:{mount:()=>XN({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:KP,deactivate:YP,refresh:PP}},{view:`prs`,label:`Reviews`,iconPath:Le,panelClass:`pr-view`,gate:{fromSettings:JF.teamReview},load:()=>N(()=>import(`./review-queue-panel-CyOulPXz.js`).then(e=>e.view),__vite__mapDeps([38,12,13,5,3,14,15,4,6,7,39,32,40,41,34,42,27,20,28,29,23,30,21,31,24,43])),refreshOn:[`shown`],attention:{subscribe:oh,acknowledge:ah},onConnectionChange:e=>{Ip(e),Rm(e)}},{view:`issues`,label:`Issues`,iconPath:Je,panelClass:`issues-view`,gate:{fromSettings:JF.issues},load:()=>N(()=>import(`./issues-panel-DKsEpAx-.js`).then(e=>e.view),__vite__mapDeps([44,13,5,3,14,20,15,12,29,23,30,4,6,7,21,32,41,16,17,42,27,28,31,24,45])),refreshOn:[`shown`],onConnectionChange:ef},{view:`usage`,label:`Usage`,iconPath:pe,panelClass:`usage-view`,gate:{fromSettings:JF.usage},load:()=>N(()=>import(`./usage-panel-j6iTPjbO.js`).then(e=>e.view),__vite__mapDeps([46,13,5,3,47,48])),attention:{subscribe:xT,acknowledge:bT},onConnectionChange:DT,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,iconPath:kt,panelClass:`radar-view`,gate:{fromSettings:JF.posthog},load:()=>N(()=>import(`./radar-panel-2TxF0hbk.js`).then(e=>e.view),__vite__mapDeps([49,12,13,5,3,14,20,15,50,28,29,23,30,4,6,7,21,35,47,51])),attention:{subscribe:uI,acknowledge:lI}},{view:`community`,label:`Community`,iconPath:it,panelClass:`community-view`,gate:{fromSettings:JF.community},load:()=>N(()=>import(`./community-panel-BGBC6NFJ.js`).then(e=>e.view),__vite__mapDeps([52,12,13,5,3,14,20,15,39,32,40,41,4,6,7,34,53])),refreshOn:[`shown`],attention:{subscribe:MI,acknowledge:NI},onConnectionChange:RI},{view:`boards`,label:`Boards`,iconPath:tt,isPhoneNavScreen:!0,isPhoneOnly:!0,panelClass:`boards-screen`,hasPanelChrome:!1,load:()=>N(()=>import(`./boards-view-CV4wmZLl.js`).then(e=>e.view),__vite__mapDeps([36,13,5,3,14,20,15,12,31,24,37])),refreshOn:[`shown`,`connected`]},{view:`hooks`,label:`Hooks`,iconPath:at,panelClass:`hooks-view`,load:()=>N(()=>import(`./hooks-panel-B1MBTFrw.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:ze,panelClass:`trace-view`,gate:{subscribe:G_},load:()=>N(()=>import(`./trace-panel-BA5q4ttn.js`).then(e=>e.view),__vite__mapDeps([56,13,5,3,15,12,4,6,7,57])),refreshOn:[`shown`],onAvailabilityChange:e=>dI(e?Vb:null),onConnectionChange:Kb},{view:`benchmarks`,label:`Arena`,iconPath:bt,panelClass:`bench-view`,load:()=>N(()=>import(`./arena-panel-BysN3T5_.js`).then(e=>e.view),__vite__mapDeps([58,12,13,5,3,14,20,30,28,59])),onConnectionChange:Ii},{view:`settings`,label:`Settings`,iconPath:ue,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>N(()=>import(`./settings-panel-Dk9IgiNx.js`).then(e=>e.view),__vite__mapDeps([60,12,13,5,3,14,15,4,6,7,10,50,28,20,29,23,30,21,35,61,8,42,27,31,24,32,43,2,1,62]))}].map(t=>rR(t,C(t.iconPath),e.setPhoneAttention));return E(document,`#header-tabs`,`div`).replaceChildren(...t.map(e=>e.tab)),t}function cR(e){return e===`remote`?`remote`:`local`}function lR(e,t){return cR(t)===`local`||e!==`shutdown`}var uR=!1,dR=new Set;function fR({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){let o=cx(),s=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;Jt({title:t,message:s,confirmLabel:n,danger:r||o>0,onConfirm:()=>v({type:e})})}function pR(){fR({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function mR(){fR({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})}function hR(e){uR=lR(`shutdown`,e);for(let e of dR)e.isConnected?e.hidden=!uR:dR.delete(e)}function gR(e){e.hidden=!uR,dR.add(e)}function _R(e){e&&OF(e),!BA(`settings`)&&$(`settings`,{section:e})}function vR(e){BA(e)||$(e)}function yR(){BA(`boards`)||($(`focus`),FP())}function bR(){WF(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}var Q=sR({onRestart:pR,openTerminal:e=>{zA(e)||($(`focus`),HP(e))},openPlan:e=>{$(`focus`),UP(e)},openReviewFile:(e,t)=>{sx(e)&&(zA(e)||($(`focus`),HP(e),VP(t)))},openReviews:()=>wR(`prs`)?(BA(`prs`)||$(`prs`),!0):!1,setPhoneAttention:PA});function xR(){return Q.map(e=>e.view)}var SR=xR();function CR(e){return Q.find(t=>t.view===e)}function wR(e){return Q.some(t=>t.view===e&&!t.tab.hidden)}var TR=!0,ER=null;function DR(e){CR(e)?.attention?.acknowledge()}var OR=null;function kR(e){OR=v({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function AR(){OR&&kR(OR)}function jR(e){let t=CR(e);t&&(XL(t,e=>HL(t,e,`shown`)),kR(e))}function MR(e){UL(Q,{isPhoneShellActive:AA(),activeView:Ln(),phoneScreen:M.snapshot().phoneScreen},e,ZL)}function $(e,{section:t,setting:n,persist:r=!0}={}){let i=CR(e);if(!i||!wR(e))return;let a=Ln();M.dispatch(`setActiveView`,e),TR=r,r&&(ER=null),document.body.dataset.activeView=e,r&&ir(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&&ZL(a)?.deactivate?.(),XL(i,r=>{Ln()===e&&(r.activate?.(),HL(i,r,`shown`),e===`settings`&&t&&OF(t,n??null))}),kR(e),a===`settings`&&e!==`settings`&&bR(),DR(e)}function NR(e,t){let{view:n}=e;e.tab.hidden=!t,NA(n,t),e.onAvailabilityChange?.(t),!AA()&&(!t&&Ln()===n&&$(`focus`),t&&ER===n&&$(n))}function PR(e){for(let{view:t,isAvailable:n}of RL(Q,e))NR(t,n)}var FR;function IR(e){FR=e;let t=zL(SR,e);Q.every((e,n)=>e.view===t[n])||(Q.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),E(document,`#header-tabs`,`div`).append(...Q.map(e=>e.tab)),MA(t))}function LR(){return Q.filter(e=>!e.tab.hidden)}function RR(e,t){let n=e[t];return $(n.view),n.tab}function zR(e,t){let n=LR(),r=n.findIndex(t=>t.view===e);return RR(n,bi(r,t,n.length))}function BR(e){Q.some(e=>e.tab===document.activeElement)&&e.focus()}var VR=null;function HR(e){let t=xR();IR(e),a(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&IR(t)}).catch(()=>IR(t))}function UR(e){let t=VR;if(VR=null,!t||t===e)return;let n=xR();HR(BL(n,t,n.indexOf(e)))}function WR({view:e,tab:t}){t.addEventListener(`click`,()=>$(e)),t.addEventListener(`dragstart`,t=>{VR=e,t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),t.addEventListener(`dragover`,n=>{VR&&VR!==e&&(n.preventDefault(),t.dataset.dropTarget=`true`)}),t.addEventListener(`dragleave`,()=>delete t.dataset.dropTarget),t.addEventListener(`drop`,n=>{n.preventDefault(),delete t.dataset.dropTarget,UR(e)}),t.addEventListener(`dragend`,()=>{VR=null}),t.addEventListener(`keydown`,e=>{if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=LR(),n=t.findIndex(e=>e.view===Ln()),r=xi(e.key,n,t.length,`horizontal`);r!==null&&(e.preventDefault(),RR(t,r).focus())})}var GR=`pack:`,KR=new Map;function qR(e){let t=aR(e);return Q.push(t),SR.push(t.view),E(document,`#header-tabs`,`div`).append(t.tab),WR(t),t}function JR(e){let t=new Set(e.map(e=>e.viewId));for(let e of Q)e.view.startsWith(GR)&&!t.has(e.view)&&(FL(e.view),NR(e,!1));for(let t of e){let e=CR(t.viewId)??qR(t),n=KR.get(t.viewId);n&&(n.label!==t.label||n.iconUrl!==t.iconUrl)&&oR(e,t),KR.set(t.viewId,t),PL(t),NR(e,!0)}IR(FR)}function YR(){let e=Rr(),t=WF(location.hash),n=fv(location.hash);if(t&&(OF(null,null,location.hash),$(`settings`,{persist:!1})),n&&$(`focus`,{persist:!1}),t||n)return;let r=wR(e);r||(ER=e),$(r?e:`focus`,{persist:r})}function XR(){let e=Ln();$(wR(e)?e:`focus`,{persist:TR})}function ZR(){EF(Q),QL(Q);for(let e of Q)e.gate&&(NR(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>NR(e,t)));Bb(()=>{wR(`trace`)&&(BA(`trace`)||$(`trace`))});for(let e of Q)WR(e);YR(),IL(JR)}function QR(e){return WF(e)?(OF(null,null,e),BA(`settings`)||$(`settings`,{persist:!1}),!0):!1}var $R=`No plan is stored for this session yet. It appears here once the agent writes one.`,ez=`Plan`;function tz(e){let t=fv(e);return t?!sx(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),AA()?(RA(t)||Bn({source:ez,sessionId:t,message:$R}),!0):($(`focus`,{persist:!1}),UP(t)||Bn({source:ez,sessionId:t,message:$R}),!0)):!1}function nz(e){return tz(e)?!0:QR(e)}function rz(e){e.newURL===location.href&&nz(location.hash)}function iz(){document.addEventListener(`click`,e=>{if(!AA()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&nz(t.hash)&&e.preventDefault()}),window.addEventListener(`hashchange`,rz)}var az=null,oz=new Set;function sz(){az?.setState(Vr()?`idle`:`off`)}function cz(e){pr(e),sz();for(let t of oz)t(e)}function lz(e){oz.add(e)}function uz(e){az=e,sz(),e.element.addEventListener(`click`,()=>cz(!Vr()))}var dz=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,fz=[`title`,`label`],pz=new WeakMap,mz=new WeakMap,hz=null;function gz(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(dz)!==null}function _z(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function vz(e,t){if(t&&e===t.masked)return t;let n=$I(e);return n===e?null:{original:e,masked:n}}function yz(e){let t=_z(e)?null:vz(e.data,pz.get(e));t?(pz.set(e,t),e.data!==t.masked&&(e.data=t.masked)):pz.delete(e)}function bz(e,t){let n=e.getAttribute(t),r=mz.get(e),i=n===null?null:vz(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),mz.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function xz(e){for(let t of fz)bz(e,t)}function Sz(e){return e instanceof Element&&e.matches(dz)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function Cz(e){xz(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,Sz);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&yz(e),e instanceof Element&&xz(e)}function wz(e){gz(e)||(e instanceof Text&&yz(e),e instanceof Element&&Cz(e))}function Tz(e){e instanceof Element&&!gz(e)&&xz(e)}function Ez(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&&wz(e);for(let e of n)e.isConnected&&Tz(e)}function Dz(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);Oz(e);for(let e=t.nextNode();e;e=t.nextNode())Oz(e)}function Oz(e){if(e instanceof Text){let t=pz.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=mz.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function kz(){if(hz)return;let e=new MutationObserver(t=>{Ez(t),e.takeRecords()});Cz(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:fz}),hz=e}function Az(){hz&&(hz.disconnect(),hz=null,Dz(document.body),pz=new WeakMap,mz=new WeakMap)}function jz(e){e?kz():Az()}function Mz(){jz(cc()),uc(jz)}var Nz=ct({label:`Play queued merge celebrations`,icon:C(me,`1.6`),action:`play-celebrations`,states:[`idle`,`attention`]}),Pz=w({variant:`primary`,label:`Session`,icon:C($e),action:`add-session`,onClick:pi});Pz.id=`btn-add-session-header`;var Fz=ct({label:`Keyboard shortcuts and version`,icon:C(ot,`1.6`),action:`open-shortcuts-help`,onClick:()=>_R(`browser-shortcuts`),states:[`idle`]}).element,Iz=ct({label:`Mute alerts`,icon:C(jt,`1.6`),action:`toggle-mute`,states:[`idle`,`off`]}),Lz=Iz.element,Rz=w({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-header-status`});Rz.id=`header-status-dismiss`;var zz=E(document,`#celebration-tray`,`div`);zz.prepend(Nz.element),E(document,`.header-right`,`div`).append(Pz,Fz,Lz),E(document,`#header-status`,`p`).append(Rz);function Bz(){uz(Iz),Mz(),Ut(document.querySelector(`.header`))}function Vz(){bf(zz,Nz,E(document,`#celebration-tray-count`,`span`))}function Hz(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 Uz(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 Wz(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function Gz(e,t){return t||Wz(e)?!1:Uz(e)}var Kz=w({variant:`primary`,size:`small`,label:`Restart`,action:`restart-to-update`,hidden:!0}),qz=w({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-update-command`}),Jz=w({variant:`icon`,size:`small`,label:`Dismiss update notice`,icon:C(Ct),action:`dismiss-update-banner`});E(document,`#update-banner-cmd`,`code`).before(Kz),E(document,`#update-banner-copy-status`,`span`).before(qz),E(document,`#update-banner`,`div`).append(Jz);var Yz=w({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-leftovers-command`}),Xz=w({variant:`icon`,size:`small`,label:`Dismiss old report notice`,icon:C(Ct),action:`dismiss-leftovers-banner`});E(document,`#post-turn-leftovers-copy-status`,`span`).before(Yz),E(document,`#post-turn-leftovers-banner`,`div`).append(Xz);var Zz,Qz=null;function $z(e,t,n){e.onclick=()=>{let e=zt(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var eB=qF(Ce,_e,`Update`).href;function tB(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function nB(e){let t=E(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=Ue(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=tB(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===Qz||!a&&Zz!==void 0&&s===Zz||!a&&s&&Cr()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);E(document,`#update-banner-text`,`span`).textContent=i,E(document,`#update-banner-cmd`,`code`).textContent=c;let l=E(document,`#update-banner-update`,`a`);l.href=eB,l.hidden=n!==`link`,Kz.hidden=n!==`restart`,Kz.onclick=pR;let u=E(document,`#update-banner-cmd`,`code`);u.hidden=n!==`command`,qz.hidden=n!==`command`;let d=E(document,`#update-banner-copy-status`,`span`);d.hidden=n!==`command`,d.textContent=``;let f=E(document,`#update-banner-link`,`a`);f.hidden=!e.releaseUrl,f.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,$z(qz,d,c),Jz.onclick=()=>{t.hidden=!0,a?Qz=i:(Zz=s,nr(s))}}var rB=!1;function iB({repositories:e,command:t}){let n=E(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(rB)return;let r=E(document,`#post-turn-leftovers-copy-status`,`span`);E(document,`#post-turn-leftovers-text`,`span`).textContent=Hz(e.length),E(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,$z(Yz,r,t),Xz.onclick=()=>{rB=!0,n.hidden=!0}}var aB=E(document,`#telemetry-banner`,`div`),oB=w({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-telemetry-banner`});aB.append(oB);function sB(){tr(!0),aB.hidden=!0}function cB(e){aB.hidden=!Gz(e,lr())}function lB(){let e=E(document,`#telemetry-banner-settings`,`a`);e.href=qF(`privacy`,`telemetry-enabled`,`What's collected`).href,e.addEventListener(`click`,sB),oB.addEventListener(`click`,sB)}function uB(e){N(()=>import(`./feature-hint-C53CYgsG.js`).then(t=>t.showFeatureHint(e,{isFeatureEnabled:e=>wR(le[e]),openView:vR,openSetting:(e,t)=>QR(UF(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 dB(){N(()=>import(`./feature-hint-C53CYgsG.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 fB=2500;function pB({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}function mB(e){Ca(e.isExperimentalBuild===!0&&Hr()),lx(e),FF(e),PR(e),cB(e),IR(e.viewTabOrder),lc(e.streamerMode===!0)}var hB=Object.freeze({top:[0,1],right:[-1,0],bottom:[0,-1],left:[1,0]}),gB=160,_B=950,vB=900,yB=980,bB=450,xB=720,SB=260,CB=`cubic-bezier(0.22, 1, 0.36, 1)`,wB=`cubic-bezier(0.2, 0.8, 0.3, 1)`,TB=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),EB=e=>new Promise(t=>{setTimeout(t,e)});function DB(e){return e!==void 0&&Object.hasOwn(hB,e)}function OB(e){return[...e.querySelectorAll(`.loading-mark-bracket`)].flatMap(e=>{let t=e instanceof SVGElement?e.dataset.side:void 0;if(!(e instanceof SVGElement)||!DB(t))return[];let[n,r]=hB[t];return[{bracket:e,dx:n,dy:r}]})}function kB(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:zc}],{duration:gB,easing:`ease-out`})}}function AB(e){e.animate([{transform:`rotate(0deg)`,easing:`cubic-bezier(0.5, 0, 0.15, 1)`},{transform:`rotate(360deg)`,offset:.86,easing:wB},{transform:`rotate(354deg)`,offset:.93,easing:wB},{transform:`rotate(360deg)`}],{duration:_B})}function jB(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:vB,easing:`cubic-bezier(0.2, 0.9, 0.3, 1)`})}}function MB(e,t){e.animate([{transform:`scale(0)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:yB,easing:CB,fill:`forwards`}),t.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`})}function NB(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:xB,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:xB,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 PB(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(TB?.matches||document.hidden||!(t instanceof SVGElement)||!n||!r||!i)return;let a=OB(t);kB(a),e.dataset.unlock=`spin`,await EB(gB),AB(n),jB(a),MB(r,i),await EB(yB),e.dataset.unlock=`lit`,await EB(bB),e.dataset.unlock=`burst`,NB(a,r,i),await EB(SB)}var FB=E(document,`#connection-status`,`span`),IB=E(FB,`.connection-label`,`span`),LB=E(document,`#loading-screen`,`div`),RB=E(document,`#loading-status`,`div`),zB=E(document,`#loading-detail`,`div`),BB=E(document,`#shutdown-screen`,`div`),VB=E(document,`#shutdown-status`,`div`),HB=!1,UB=null,WB=!1;function GB(){HB||UB===null||pB({hasSnapshot:WB,connectingTerminalCount:sl(),msSinceConnected:performance.now()-UB})===`reveal`&&qB()}function KB(){WB=!0,GB()}function qB(){HB||(HB=!0,$L(Q),yd(),sj(),PB(LB).then(JB,JB))}function JB(){LB.classList.add(`fade-out`);let e=()=>LB.remove();LB.addEventListener(`transitionend`,t=>{t.target===LB&&e()}),setTimeout(e,1e3)}function YB(e,t){FB.dataset.state=`shutdown`,IB.textContent=e,VB.textContent=t,BB.classList.add(`active`)}var XB=new Set([`disconnected`,`connecting`]);function ZB(e,t,n){FB.dataset.state=e,FB.toggleAttribute(`data-reconnected`,n),IB.textContent=t}function QB(e,t){ZB(e,t,e===`connected`&&XB.has(FB.dataset.state??``))}function $B(e,t){FB.dataset.state!==`shutdown`&&ZB(e===`verified`?`connected`:e,t,!1)}var eV=1e4,tV=`Server`,nV=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,rV=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,iV=null,aV=!1;function oV(){RB.textContent=`Reconnecting to server...`,zB.textContent=rV,zB.hidden=!aV}function sV(){iV=null,aV=!0,HB?Bn({source:tV,message:nV,hidesInStreamerMode:!1}):oV()}function cV(){iV!==null||aV||(iV=window.setTimeout(sV,eV))}function lV(){iV!==null&&window.clearTimeout(iV),iV=null,aV=!1,zB.hidden=!0,zn(tV)}function uV(){lV(),nR(import.meta.url,()=>window.sessionStorage),AR(),BB.classList.contains(`active`)?location.reload():(oj(),document.body.classList.add(`app-ready`),!HB&&UB===null&&(UB=performance.now(),RB.textContent=`Connecting to sessions...`,setTimeout(qB,fB)),GB(),MR(`connected`),a(`get-settings`,{}).then(e=>{e.settings&&(mB(e.settings),Ln()===`settings`&&QR(location.hash))}).catch(()=>{}))}function dV(e,t){if(e===`connecting`||e===`verified`)$B(e,t);else{QB(e,t),Ey(e===`connected`);for(let t of Q)t.onConnectionChange?.(e===`connected`);e===`connected`?uV():e===`disconnected`&&BB.classList.contains(`active`)?VB.textContent=`Waiting for server...`:(cV(),HB||oV())}}function fV(){ol(GB),o(dV)}var pV=14,mV=Object.freeze({idle:Bc,failed:`#ef4444`,waiting:`#f59e0b`});function hV({waitingCount:e,failedCount:t}){return e>0?`waiting`:t>0?`failed`:`idle`}function gV(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)">${Vc({frame:zc,light:mV[e],strokeWidth:pV})}</g></svg>`}function _V(){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 vV=_V(),yV=`idle`;function bV(e){let t=hV(e);t!==yV&&(yV=t,vV.href=`data:image/svg+xml,${encodeURIComponent(gV(t))}`)}function xV(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 SV(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 CV(){$d(),Mp(),FA()}function wV(){dP(),CV()}function TV(){$r(e=>{dP(e),CV()})}var EV=null;function DV(e){let t=xV(EV,e);EV=t.knownBuild,t.reload&&location.reload()}function OV(e){Vn(e),wx(e),Yi(e),P_(e),Mh(e)}function kV(e){let t=new Set(e.map(e=>e.id));for(let e of[...k.keys()])t.has(e)||OV(e)}function AV(e){kV(e),RF(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){Ji(t.id,t.coherenceHooks),jh(t.id,t.linkedPrs);let e=sx(t.id);e&&Ox(t.id,t.state,t.stateSince),e&&cn(t.id,!!t.saneYolo),e||px(t.id,t.name,t.state,SV(t)),Jv(t.id,t.failureReason),ox(t.id,t.taskTitle,t.taskTitleIsCustom),hx(t.id,t.agent),Sx(t.id,t.mergeStatus,t.mergeReason),mx(t.id,t.effectiveBase),_x(t.id,t.activeAgents,t.awaitingBackgroundTasks),vx(t.id,t.pendingPromptKind),yx(t.id,t.unseenOutcome),xy(t.id,t.hasPlan)}fx(),bV(j.counts),dP(),JP(),CV(),jV(),tz(location.hash),VA(),KB()}function jV(){Hb([...k].map(([e,t])=>({id:e,name:Tn(t)||e})))}function MV(e,t){xy(e,t?.hasPlan===!0),yx(e,t?.unseenOutcome)}var NV=new Set([T.DONE,T.FAILED]);function PV(e,t){return e!==void 0&&NV.has(e)&&!NV.has(t)&&t!==T.DORMANT}function FV(e){let t=k.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;wx(e.id),px(e.id,e.session,T.DORMANT,SV({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})),hx(e.id,t?.agent),MV(e.id,t)}function IV(e,t){let n=k.get(String(e.id))?.currentState;t.to===T.DORMANT&&n!==T.DORMANT?(FV(e),M_(e.id)):(Ox(e.id,t.to,e.timestamp),Jv(e.id,e.failureReason),e.saneYolo!==void 0&&cn(e.id,e.saneYolo),M_(e.id),PV(n,t.to)&&Cl(e.id))}function LV(e){if(sx(e.id))e.transition&&IV(e,e.transition),e.activeAgents!==void 0&&_x(e.id,e.activeAgents,e.awaitingBackgroundTasks),e.unseenOutcome!==void 0&&yx(e.id,e.unseenOutcome),e.pendingPromptKind!==void 0&&vx(e.id,e.pendingPromptKind),e.unseenOutcome!==void 0&&fx(),bV(j.counts),ri(e.id),rv(e.id);else{if(!e.transition)return;px(e.id,e.session,e.transition.to,SV({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),bV(j.counts),$d()}}function RV(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 zV={"session-trace-response":e=>Ub(e),"session-trace-changed":e=>Wb(e),"session-plan-changed":e=>{Sy(e),CV()},"session-plan-draft":e=>{Cy(e)},"session-plan-response":e=>{wy(e)},"session-docs-changed":e=>xg(e),"session-docs-snapshot":e=>Sg(e),"session-coherence-hooks":e=>{Ji(e.id,e.coherenceHooks),wV()},"session-coherence":e=>{Xi(e),wV()},"session-coherence-snapshot":e=>{Zi(e),wV()},"session-coherence-journal-response":e=>na(e)},BV={"team-review-status":e=>Fm(e),"github-prs":e=>sf(e),"my-prs-status":Np,"pr-flows-status":Pp,"packs-status":TL,"my-pr-merge-result":e=>Fp(e),"team-review-action-result":e=>Im(e),"open-team-review-session-result":e=>Lm(e),"issues-status":e=>tf(e),"issue-detail-result":e=>nf(e),"open-issue-session-result":e=>rf(e),"set-issue-state-result":e=>Gd(e)},VV={"radar-status":e=>fI(e),"radar-investigation-activity":e=>pI(e),"radar-investigation-finished":e=>mI(e),"community-status":e=>LI(e),"benchmark-status":e=>Li(e),"benchmark-action-result":e=>Ri(e),"race-status":e=>xj(e),"usage-sessions":e=>OT(e),"usage-report":e=>{AT(e),LF()},"plan-limits":e=>kT(e),"usage-budget-alert":e=>Bv({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0})},HV={snapshot:e=>{DV(e.serverBuild),AV(e.sessions)},"hooks-report":e=>ug(e),"save-hook-result":()=>dg(),"delete-hook-result":()=>dg(),"update-status":e=>{nB(e),zF(e)},"update-progress":e=>BF(e.journal),"post-turn-leftovers":e=>iB(e),"feature-hint":e=>uB(e.hint),"star-hint":()=>dB(),error:e=>{let t=VF(e),n=Gb(e),r=Ty(e);t||n||r||(e.id?qv(e.id,e.message):Bn({source:tV,message:e.message}))},"settings-updated":e=>{e.settings&&mB(e.settings),oj()},"agent-logins":e=>QP(e.logins),"health-snapshot":e=>{e.stats&&Qh(e.stats)},"client-trust":e=>hR(e.trust),"shutting-down":()=>YB(`Shutting down...`,`Shutting down sessions...`),restarting:()=>YB(`Restarting...`,`Restarting server...`)},UV={"session-status":e=>LV(e),"session-added":e=>{jh(e.id,e.linkedPrs),sx(e.id)||(px(e.id,e.session,e.state,SV(e)),hx(e.id,e.agent)),bV(j.counts),wV(),jV()},"session-close-confirm":e=>{oi(e.id)},"session-removed":e=>{OV(e.id),bV(j.counts),wV(),jV()},"session-title":e=>{ox(e.id,e.taskTitle,e.isCustom),wV()},"session-prs":e=>jh(e.id,e.linkedPrs),"session-renamed":e=>{Cx(e.id,e.newName),wV(),jV()},"session-modified":e=>{let t=k.get(String(e.id)),n=Yr()===String(e.id);Ji(e.id,null),wx(e.id),P_(e.id),jh(e.id,e.linkedPrs),px(e.id,e.session,e.state,SV(e)),n&&ui(String(e.id)),hx(e.id,e.agent),MV(e.id,t),bV(j.counts),wV(),jV()},"session-git":e=>gx(e.id,!!e.worktree),"session-merge-status":e=>{xx(e.id,e.mergeStatus,e.reason),zP(e.id,e.mergeStatus),CV()},"debug-state-response":e=>nv(e),"session-setup-response":e=>Nx(e),notify:e=>{zv(e),rv(e.session)},"session-error":e=>{N_(e.id),!Ty(e)&&qv(e.id,e.message)}},WV={"whiteboards-snapshot":e=>Vk(e),"whiteboard-patch":e=>Hk(e),"whiteboard-removed":e=>Uk(e)},GV=`Worktree`,KV=`Worktree warning`,qV=RV([HV,UV,{"session-worktree-blocked":e=>{Bn({source:GV,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=>{Bn({source:KV,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=>{zn(GV,e.id),mx(e.id,e.base)},"session-diff":e=>{D_(e.id,e)},"session-diff-error":e=>{O_(e.id,e.message)},"change-map":e=>k_(e.id,e.map),"session-changed":e=>A_(e.id)},zV,WV,BV,VV]);function JV(e){let t=qV[e.type];t&&t(e)}function YV(){l(e=>{JV(e),MR(e.type)})}function XV(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 ZV(){DA({panels:XV(Q),onScreenShown:e=>{jR(e),e!==`settings`&&bR(),e===`settings`&&!WF(location.hash)&&OF(),DR(e)},canGoBack:e=>e===`settings`&&NF()||e===`prs`&&hh(),onBack:e=>{e===`settings`&&PF(),e===`prs`&&gh()},headerControls:[E(document,`.header-title`,`h1`),E(document,`#status-indicator`,`div`),E(document,`#celebration-tray`,`div`),Pz,Fz,Lz]}),MF(IA),mh(IA)}function QV(e){if(e===`phone`){let e=Z();for(let e of Q)ZL(e.view)?.deactivate?.();let t=WF(location.hash);OA({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}).then(e=>{e&&t&&OF(null,null,location.hash),!e&&yo()&&!AA()&&XR()});return}let t=jA();kA(),XR(),t&&HP(t)}function $V(){ZV(),yo()&&QV(`phone`),bo(QV)}function eH(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function tH(e){HP(e),fi(e),requestAnimationFrame(()=>requestAnimationFrame(()=>k.get(e)?.term?.focus()))}function nH(){let e=eH()??Yr();e?ti(e):document.getElementById(`btn-add-session-header`)?.click()}function rH({action:e,step:t}){switch(e){case`merge`:{let e=Yr();return!e||YN()?!1:(I_(e),!0)}case`close-session`:{let e=Yr();return e?(ai(e),!0):!1}case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return nH(),!0;case`next-attention`:return yo()?!1:JN()?(xP(),!0):(Ln()===`prs`&&_h()||qP(()=>$(`focus`)),!0);case`rail-step`:return JN()?(GP(t),!0):!1;case`view-step`:return!yo()&&(BR(zR(Ln(),t)),!0);case`session-nth`:return JN()?(WP(t),!0):!1;case`streamer-mode`:return mc(),!0}}function iH(e){return e.code!==`KeyZ`||e.altKey||e.shiftKey?!1:Rl===`mac`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function aH(){si(tH),document.addEventListener(`keydown`,e=>{if(e.repeat||Bt(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1;if(!t&&iH(e)&&!Yt()&&hi()){e.preventDefault(),e.stopImmediatePropagation();return}let n=mr(e,Rl,{isTerminalFocused:t},Vl());n&&(Yt()||rH(n)&&e.preventDefault())})}function oH(){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))}),tR(()=>window.sessionStorage)}ba(br()),Sa(()=>{N(()=>import(`./alert-sound-Da6VQFBS.js`).then(e=>e.playNyanJingle(),e=>u(`alert-sound`,`nyan jingle failed to load: ${d(e)}`)),__vite__mapDeps([10,7]))}),bd(Wr()),vo(),iu(document),fV(),TV(),CT(v),N(()=>import(`./your-day-tip-z4FxKfuQ.js`).then(e=>e.startYourDayTips({openUsage:()=>vR(`usage`)}),e=>u(`your-day-tip`,`your day tips failed to load: ${d(e)}`)),__vite__mapDeps([65,13,5,3,20,63,12,4,6,7,61,8,64])),cg(v),zb(v),Qd(v),Pi(v),ln(kh),vn(Qi),vn(Eh,`links`),vn(dA,`links`),hn(pA),oA(yR),sn({isReadable:$i,open:ta}),fn(Mx),uc(()=>MR(`settings-updated`)),YV(),lB(),Bz(),iz(),Vz(),ZR(),$V(),aH(),UA(),oH(),Zh(E(document,`#health-footer-mount`,`div`)),Ll(ux),cV(),dd(),f();var sH=_r();sH&&n().then(()=>_l(sH));export{DM as $,Rd as $i,SS as $n,rh as $r,AS as $t,jF as A,Fi as Aa,Zf as Ai,zC as An,Pb as Ar,Ik as At,_F as B,Rf as Bi,vS as Bn,ty as Br,ET as Bt,YF as C,yo as Ca,lm as Ci,cC as Cn,Px as Cr,Fk as Ct,GF as D,ba as Da,kp as Di,MS as Dn,Ib as Dr,zk as Dt,UF as E,Ca as Ea,Ap as Ei,jS as En,Rb as Er,Xk as Et,PF as F,ep as Fi,BS as Fn,py as Fr,Kk as Ft,gN as G,Tf as Gi,aC as Gn,_v as Gr,_T as Gt,$P as H,zf as Hi,Mw as Hn,ny as Hr,TT as Ht,AF as I,Hf as Ii,zS as In,hy as Ir,Ck as It,RM as J,qd as Ji,MC as Jn,pg as Jr,JC as Jt,FM as K,cf as Ki,Rw as Kn,cv as Kr,gT as Kt,DF as L,$f as Li,Cw as Ln,ry as Lr,bk as Lt,SF as M,rp as Mi,Jw as Mn,Nb as Mr,Zk as Mt,CF as N,Qf as Ni,Pw as Nn,sb as Nr,Gk as Nt,FF as O,Ea as Oa,Op as Oi,US as On,Lb as Or,Rk as Ot,TF as P,Uf as Pi,WC as Pn,by as Pr,iA as Pt,jM as Q,Jd as Qi,qw as Qn,L as Qr,pS as Qt,vF as R,Lf as Ri,Sw as Rn,Qv as Rr,yk as Rt,JF as S,jo as Sa,Yp as Si,jw as Sn,Fx as Sr,_A as St,KF as T,Da as Ta,qp as Ti,FC as Tn,Jb as Tr,qk as Tt,QP as U,Bf as Ui,zw as Un,Sv as Ur,wT as Ut,kF as V,Vf as Vi,Bw as Vn,ly as Vr,yT as Vt,eF as W,wf as Wi,sC as Wn,yv as Wr,vT as Wt,kM as X,Hd as Xi,Tw as Xn,lg as Xr,dC as Xt,MM as Y,Ud as Yi,Nw as Yn,og as Yr,ww as Yt,NM as Z,Kd as Zi,Kw as Zn,sg as Zr,kS as Zt,OI as _,Vl as _a,vm as _i,kw as _n,Jx as _r,$A as _t,gR as a,Wd as aa,sh as ai,GC as an,_S as ar,lM as at,sI as b,dc as ba,Sm as bi,mC as bn,rS as br,gA as bt,CL as c,Zu as ca,nh as ci,JS as cn,Uw as cr,Ej as ct,jI as d,Xl as da,Nm as di,Aw as dn,Vw as dr,yj as dt,Xd as ea,ch as ei,YS as en,Ww as er,AM as et,AI as f,Rl as fa,xm as fi,EC as fn,Hw as fr,pj as ft,II as g,Ul as ga,gm as gi,dS as gn,Yx as gr,aj as gt,FI as h,Wl as ha,cm as hi,hS as hn,zx as hr,dj as ht,mR as i,Vd as ia,dh as ii,oS as in,gS as ir,fM as it,IF as j,Mi as ja,ap as ji,SC as jn,Mb as jr,eA as jt,yF as k,Ni as ka,op as ki,NC as kn,Fb as kr,Lk as kt,wL as l,uu as la,fh as li,qS as ln,Dw as lr,Sj as lt,PI as m,Gl as ma,Cm as mi,bS as mn,ES as mr,uj as mt,lz as n,Yd as na,ih as ni,OC as nn,ZC as nr,Zj as nt,BL as o,zd as oa,ph as oi,tw as on,$C as or,Dj as ot,kI as p,Hl as pa,dm as pi,ew as pn,XC as pr,gj as pt,PM as q,lf as qi,AC as qn,lv as qr,jT as qt,pR as r,Bd as ra,gh as ri,aS as rn,Ow as rr,Qj as rt,zL as s,bd as sa,vh as si,DS as sn,QC as sr,Oj as st,cz as t,Zd as ta,lh as ti,kC as tn,pw as tr,IM as tt,zI as u,nu as ua,Mm as ui,KS as un,PC as ur,bj as ut,cI as v,cc as va,um as vi,RS as vn,Gx as vr,QA as vt,qF as w,bo as wa,_m as wi,LC as wn,Dx as wr,Wk as wt,oI as x,ts as xa,Em as xi,pC as xn,Lx as xr,mA as xt,aI as y,uc as ya,Tm as yi,PS as yn,Wx as yr,KA as yt,bF as z,cp as zi,fw as zn,Xv as zr,ST as zt};
|
|
73
|
+
`}function Yh(){if(!zh)return;let e=Ph(Lh,Ih?.anomalies),t=zh.hidden;zh.hidden=!e,e&&t&&Ih&&(qh(),Rh&&Jh())}function Xh(e){Lh=e,Yh()}function Zh(e){if(zh)return zh;let t=Kh();return e.appendChild(t),Yh(),t}function Qh(e){Ih=e,Yh(),zh&&!zh.hidden&&(qh(),Rh&&Jh())}var $h=null,eg=null,tg=!1,ng=null,rg=new Set;function ig(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function ag(){for(let e of rg)e()}function og(){return{report:$h,hasReportSendFailed:tg}}function sg(e){rg.add(e)}function cg(e){eg=e}function lg(){if(!eg)return;ng=h(`hooks-report`);let e=eg({type:`request-hooks-report`,requestId:ng});e!==!tg&&(tg=!e,ag())}function ug(e){ig(e,ng)&&($h=e,tg=!1,ag())}function dg(){lg()}var fg=new Map;function pg(e){return fg.get(e)??[]}function mg(e){return pg(e).length>0}function hg(e){let t=A(e)?.btnDocs;t&&(t.hidden=!mg(e))}var gg=null,_g=null;function vg(){return _g??=N(()=>import(`./doc-editor-ui-DmSq6oxC.js`).then(e=>(gg=e,e),e=>(_g=null,u(`doc-editor`,`doc editor failed to load: ${d(e)}`),null)),__vite__mapDeps([11,12,13,5,3,14,15,16,17,18])),_g}function yg(e){vg().then(t=>t?.openDocEditor(e))}function bg(e){gg?.applyDocsToOpenEditor(e)}function xg(e){fg.set(e.id,e.docs),e.docs.length===0&&fg.delete(e.id),hg(e.id),bg(e.id)}function Sg(e){let t=[...fg.keys()];fg.clear();for(let[t,n]of Object.entries(e.sessions))fg.set(t,n);for(let e of new Set([...t,...fg.keys()]))hg(e),bg(e)}var Cg=10,wg={low:0,medium:1,high:2};function Tg(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 Eg(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 Dg(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function Og(e,t){for(let n of e.hotspots)Dg(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`});for(let n of e.blastRadius)n.transitiveDependentCount<Cg||Dg(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`})}function kg(e,t){return e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function Ag(e){return e.conflictRisk===null?-1:wg[e.conflictRisk]}function jg(e,t){return t.severity-e.severity||Ag(t)-Ag(e)||e.heading.localeCompare(t.heading)||e.groupKey.localeCompare(t.groupKey)}function Mg(e,t){return e===null||t===null?e??t:wg[t]>wg[e]?t:e}function Ng(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?(e.lines.push(n),e.conflictRisk=Mg(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(kg);return n.sort(jg)}function Pg(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:Tg(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of Eg(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);Og(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:Ng(r.values()),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function Fg(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 Ig(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 Lg(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=Ig(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 Rg(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function zg(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 Bg({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=Hg(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 Vg({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?Bg({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 Hg(e){return e||`base`}function Ug(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function Wg(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function Gg({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 Kg({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function qg(e){if(!e)return[];let t=new Map;for(let n of[...Lg(e.committed?.diff),...Lg(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 Jg(e,t){return t===null?null:e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)??null}function Yg(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 Xg(e){return e!==T.DORMANT&&e!==T.DONE&&e!==T.FAILED}function Zg(e,t){return(Ft.includes(e)||e===T.RUNNING)&&t}function Qg(e){let{status:t,reason:n,isFetched:r,hasCommits:i,isWorkspace:a,state:o,effectiveBase:s}=e,c=zg(e.files),l=Xg(o),u=Wg(t,n,Zg(o,i)),d=Kg({fetched:r,changedFileCount:c.files,hasCommits:i}),f=Vg({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=Gg({status:t,hasCommits:i,live:l,state:o});return{sentence:t===`parked`?`${f.text}. ${Ug(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 $g=5e3,e_=new Map,t_=new Map,n_=new Map,r_=new Map,i_=new Map,a_=new Map,o_=new WeakMap,s_=new WeakMap,c_=new Set,l_=new Set,u_=null,d_=null,f_=null,p_=null,m_=null;function h_(e){return c_.add(e),()=>c_.delete(e)}function g_(e){for(let t of c_)t(e)}function __(e){if(!e)return[];let t=o_.get(e);if(t)return t;let n=qg(e);return o_.set(e,n),n}function v_(e){if(!e)return null;let t=s_.get(e);if(t)return t;let n=Pg(e);return s_.set(e,n),n}function y_(e){return k.get(e)?.card.dataset.workspace!==void 0}function b_(e){let t=k.get(e);if(!t)return null;let n=n_.get(e)??null,r=__(n),i=r_.get(e)??null;return{...Qg({status:e_.get(e)||`none`,reason:t_.get(e)??null,isFetched:n_.has(e),hasCommits:n?.hasCommits===!0,hasDiffError:i!==null,isWorkspace:y_(e),state:t.currentState,effectiveBase:t.effectiveBase,isMergeInFlight:a_.has(e),files:r}),sessionId:e,sessionName:t.card.dataset.session||e,files:r,diffError:i,changeMapView:v_(i_.get(e)),notice:u_?.sessionId===e?u_.text:null,isWorkspace:y_(e)}}function x_(e,t){u_={sessionId:e,text:t},d_&&clearTimeout(d_),d_=setTimeout(()=>{u_=null,g_(e)},$g),g_(e)}function S_(e){i_.has(e)||i_.set(e,null),v({type:`request-change-map`,id:e})}function C_(e){v({type:`request-session-diff`,id:e}),S_(e)}function w_(e,t){let n=e_.get(e);e_.set(e,t),Rg(n,t)&&(n_.delete(e),r_.delete(e),i_.delete(e),e===Yr()&&C_(e)),g_(e)}function T_(e,t,n=null){let r=t||`none`;t_.set(e,n);let i=a_.get(e);i!==void 0&&i!==r&&a_.delete(e),w_(e,r)}function E_(e,t,n=null){t_.set(e,n),a_.delete(e),w_(e,t||`none`)}function D_(e,t){let n=O(e);n&&(n_.set(n,t),r_.delete(n),g_(n))}function O_(e,t){let n=O(e);n&&(r_.set(n,t),g_(n))}function k_(e,t){let n=O(e);if(!n)return;let r=oe.safeParse(t);r.success&&r.data.sessionId===n&&(i_.set(n,r.data),g_(n))}function A_(e){let t=O(e);t&&t===Yr()&&C_(t)}function j_(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function M_(e){let t=O(e);if(!t||t!==Yr())return;let n=!n_.has(t)||r_.has(t),r=!i_.has(t)||j_(i_.get(t));n&&C_(t),r&&!n&&S_(t),g_(t)}function N_(e){let t=O(e);t&&a_.delete(t)&&g_(t)}function P_(e){let t=O(e);e_.delete(t),t_.delete(t),n_.delete(t),r_.delete(t),i_.delete(t),a_.delete(t),t===Yr()?ui(null):g_(t)}function F_(e,t){a_.has(e)||(v(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(a_.set(e,e_.get(e)||`none`),g_(e)):x_(e,`Not connected. The merge was not sent.`))}function I_(e){let t=b_(e);return t?a_.has(e)?(x_(e,`Merge is already on its way for "${t.sessionName}".`),!1):t.isMergeEnabled?k.get(e)?.currentState===T.RUNNING?(Jt({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:()=>F_(e,!0)}),!0):(F_(e,!1),!0):(x_(e,t.mergeRefusal??`Nothing to merge in "${t.sessionName}" right now.`),!1):!1}function L_(e){let t=b_(e);t?.isDiscardShown&&Jt({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 R_(){return[...l_].some(e=>!e.hasAttribute(`data-slot-held`))}function z_(){let e=R_()&&document.visibilityState===`visible`?Yr():null;e!==f_&&(p_&&clearInterval(p_),p_=null,f_=e,v({type:`watch-session-changes`,id:e}),e&&(p_=setInterval(()=>v({type:`watch-session-changes`,id:e}),St)))}function B_(e){m_??=V_(),m_.observe(e)}function V_(){return document.addEventListener(`visibilitychange`,z_),Qr(e=>{e&&C_(e),z_()}),new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&l_.add(t.target),t.isIntersecting||l_.delete(t.target);z_()})}var H_=!1,U_=new Set;function W_(e){H_=!!e,tv();for(let e of U_)e(H_)}function G_(e){return U_.add(e),()=>U_.delete(e)}function K_(){return H_}function q_(){let e=D(`div`,`debug-close`);return e.append(w({variant:`icon`,size:`small`,label:`Close debug overlay`,icon:C(Ct)})),e}function J_(e){return e?fe(new Date(e)):`-`}function Y_(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function X_(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Y_(e.quietMs)})`:``}function Z_(e){let t=`<span class="debug-dim">${J_(e.ts)}</span>`;if(e.kind===`signal`){let n=L([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${L(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=X_(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${L(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=L(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${L(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${L(e.category||`?`)}: <span class="debug-dim">${L(e.from||`?`)} → ${L(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${L(e.kind||`decision`)}</span>`}function Q_(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">${L(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">${L(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${J_(e.timestamp)}</span> ${L(e.from)} → ${L(e.to)} <span class="debug-label">${L(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?`${L(a.signal)} (${L(a.source||`?`)}${a.confidence?`/${L(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">${L(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 ${Y_(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">${L(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">${Z_(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(q_())}function $_(e,t){if(e.debugOpen){ev(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(q_()),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`)&&ev(e)}),v({type:`debug-state`,id:t})}function ev(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function tv(){for(let[,e]of k)e.btnDebug.classList.toggle(`visible`,H_),e.btnTrace.classList.toggle(`visible`,H_),!H_&&e.debugOpen&&ev(e)}function nv(e){let t=typeof e.id==`string`?k.get(e.id):void 0;t?.debugOpen&&Q_(t,e.payload)}function rv(e){A(e)?.debugOpen&&v({type:`debug-state`,id:e})}function iv(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0}}function av(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 ov(e,t){return{body:t.join(`
|
|
74
|
+
`),tag:`glimmervoid-alert-${e.id}`,renotify:e.isStart}}var sv=4e3;function cv(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function lv(e,t,n,r=sv){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 uv=`#plan/`;function dv(e){return`${uv}${encodeURIComponent(e)}`}function fv(e){if(!e.startsWith(uv))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var pv=null;function mv(){return pv??=N(()=>import(`./alert-sound-Da6VQFBS.js`),__vite__mapDeps([10,7])).catch(e=>(pv=null,u(`alert-sound`,`alert sound failed to load: ${d(e)}`),null)),pv}function hv(){let e=xr();mv().then(t=>t?.playAlertSound(e))}function gv(){return typeof Notification>`u`?null:Notification}function _v(){return gv()!==null}function vv(){let e=gv();return e?e.permission:`unavailable`}async function yv(){let e=gv();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function bv(){return!_v()&&!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.`:_v()?vv()===`denied`&&gr()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function xv(){return gr()&&vv()==="default"}function Sv(e=()=>{}){let t=D(`div`,`notification-permission`),n=()=>{let r=bv();if(t.replaceChildren(),t.hidden=!r&&!xv(),r){t.append(D(`p`,`notification-permission-hint text-meta text-text-muted`,r));return}let i=w({variant:`secondary`,label:`Enable desktop notifications`});i.addEventListener(`click`,()=>{i.disabled=!0,yv().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var Cv=`Notifications`,wv=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,Tv=new Map,Ev=!1;function Dv(){Ev||(Ev=!0,Bn({source:Cv,message:wv,hidesInStreamerMode:!1}))}function Ov(e,t){let n=Tv.get(e)??new Set;n.add(t),Tv.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function kv(e){let t=Tv.get(e);if(t){Tv.delete(e);for(let e of t)e.close()}}function Av(e){return!_v()||!gr()||document.documentElement.hasAttribute(`data-streamer`)?!1:e||!document.hasFocus()}function jv(){return Av(!1)&&vv()===`granted`}var Mv=null;function Nv(e,t){let n=gv();if(!n||(Mv=av(Mv,t,e.message),zn(Cv),!lv(window.localStorage,cv(`group-${t.id}`,`${e.session}-${e.category}`),Date.now())))return;let r=t.sessionIds.length===1?k.get(e.session):void 0,i=t.sessionIds.length>1?`${t.sessionIds.length} sessions`:r?Tn(r):`Glimmervoid`;try{let r=new n(i,ov(t,Mv.lines));r.onclick=()=>{window.focus(),e.kind===`plan`&&(window.location.hash=dv(e.session)),r.close()};for(let e of t.sessionIds)k.has(e)&&Ov(e,r)}catch{}}var Pv=null;function Fv(e){return!e||e.id!==Pv&&(Pv=e.id,!0)}function Iv(e){k.get(e.session)?._isActiveViewer?.()===!0?v({type:`alert-seen`,id:e.session}):Fv(e.group)&&Vr()&&hv()}function Lv(e,t){t?Nv(e,t):Bv(e)}function Rv(){let e=Reflect.get(navigator,`userAgentData`);return typeof e!=`object`||!e?!1:Reflect.get(e,`platform`)===`macOS`}function zv(e){if(document.hasFocus()){Iv(e);return}let t=e.group;jv()&&(Lv(e,t),!Rv())||(Av(!1)&&vv()===`denied`&&Dv(),t?.isStart!==!1&&Fv(t)&&Vr()&&hv())}function Bv({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=gv();if(!a||!Av(!!i)||(a.permission===`denied`&&Dv(),a.permission!==`granted`)||(zn(Cv),!lv(window.localStorage,cv(e,t),Date.now())))return;let o=typeof e==`string`?e:``,s=k.get(o),c=s?Tn(s):``;try{let i=new a(c||`Glimmervoid`,iv(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=dv(o)),i.close()},s&&Ov(o,i)}catch{}}var Vv=null;function Hv(){return Vv??=N(()=>import(`./resume-dialog-j14Lv2au.js`),__vite__mapDeps([19,12,13,5,3,14,20,15,21])).catch(e=>(Vv=null,u(`resume-dialog`,`restart dialog failed to load: ${d(e)}`),null)),Vv}var Uv=null,Wv=null;function Gv(){return Wv??=N(()=>import(`./plan-face-DjGyIJPj.js`).then(e=>(Uv=e,e),()=>(Wv=null,null)),__vite__mapDeps([22,13,5,3,14,23,24,16,17,25])),Wv}function Kv(e){let t=D(`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,Gv().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 qv(e,t){let n=A(e);n?yi(n).show(`error`,t):Bn({source:`Session`,sessionId:typeof e==`string`?e:void 0,message:t})}function Jv(e,t){let n=A(e);if(!n)return;let r=n.card.querySelector(`:scope > .session-failure-reason`);if(!(n.currentState===T.FAILED&&t)){r?.remove();return}let i=r??D(`p`,`session-failure-reason`);i.setAttribute(`role`,`status`),i.textContent=t,r||n.termWrap.before(i)}var Yv=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function Xv(e){return e===`approve`||e===`approve-accept-edits`}function Zv(e){return(e.state===`decided`||e.state===`closed`)&&Xv(e.lastDecision)}function Qv(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&Zv(n)}function $v(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function ey(e){let t=$v(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 ty(e,t){return $v(e,t)?.openRevision?.revision??null}function ny(e,t,n){if(n===null)return null;let r=$v(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function ry(e,t){let n=t-e;return Number.isFinite(n)?Re(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function iy(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 ay(e,t,n){let r=iy(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return Yv.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function oy(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 sy(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function cy(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+lt}function ly(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 ${ke} characters, so nothing was sent`:sy(e)>1e4?`the feedback composes more than the ${Me} characters the hook reply carries, so nothing was sent`:cy(e)>Qe?`the decision is larger than one control frame carries, so nothing was sent`:null}function uy(e){return e?`, ${e}`:``}function dy(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=oy(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 fy(e,t,n){let r=dy(e,t,n);return r?`${r}${uy(e.problem)}`:e.problem??``}function py(e){let t=$v(e.state,e.selectedAgentId),n=ey(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:ny(e.state,t?.agentId??null,n),status:fy(e,t,n),actions:ay(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:ny(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:iy(e,t,n)}]}}function my(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 hy({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 gy({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var _y=e=>Wt.includes(e),vy=e=>Lt.includes(e);function yy(e){let t=e.currentState;e.btnRestart.classList.toggle(`visible`,_y(t)||vy(t)||t===T.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,K_()),e.btnPlan.hidden=gy(e)===`hidden`}function by(e){let t=A(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(O(e)),yy(t),Qc(t,O(e)),!0)}function xy(e,t){let n=A(e);n&&(n.hasPlan=t===!0,yy(n))}function Sy(e){let t=A(e.id);t&&(t.planReviewState=my(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),yy(t))}function Cy(e){let t=A(e.id);t&&t.planFace.update({draft:e})}function wy(e){let t=A(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),yy(t))}function Ty(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=A(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function Ey(e){for(let[,t]of k)t.planFace.update({isConnected:e})}var Dy=160,Oy=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 ky(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=Dy?t:`${t.slice(0,157)}...`}function Ay(e,t){let n=Oy[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?ky(r):``}var jy=5e3;function My(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function Ny(e,t){if(!e.toolUseId)return My(e.text)??`context`;let n=t.get(e.toolUseId);return n?Ay(n.name,n.input)||n.name:`expansion`}function Py(e){return e.kind!==`expansion`||e.toolUseId?!1:My(e.text)!==null}function Fy(e){return e.kind===`prompt`||e.kind===`session`||Py(e)}function Iy(e){return new TextEncoder().encode(e).byteLength}var Ly={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`};function Ry(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:ky(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:ky(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:ky(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:ky(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:ky(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:Ny(e,t)};if(e.kind===`tool_call`){let t=Ay(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:`${Iy(e.content)} bytes`}}function zy(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function By(e,t){let n=Ry(e,t),r=zy(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:Ly[e.kind],text:`${r}${i}`,tone:o,badges:a}}function Vy(e,t){return{record:e,...By(e,t)}}function Hy(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function Uy(e,t){let n=Hy(e);return!n||t.has(n)?null:n}function Wy(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function Gy(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function Ky(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=Hy(i.record);a&&t.has(a)&&(n.rows[r]=Vy(i.record,e.toolCallByUseId))}}function qy(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function Jy(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function Yy(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=Iy(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function Xy(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=Uy(i,e.toolCallByUseId);t&&Wy(e.unresolvedToolUseCounts,t);let a=Vy(i,e.toolCallByUseId);if(Fy(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:Jy()},Yy(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:Jy()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),Yy(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 Zy(e,t){let n=qy();Xy(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)||Wy(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],Ky(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function Qy(e){return e.rows.length+ +!!e.head}function $y(e){let t=0;for(let n of e.turns)t+=Qy(n);return t}function eb(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=Hy(n.record);t&&Gy(e.unresolvedToolUseCounts,t)}}function tb(e,t){eb(e,t.head?[t.head,...t.rows]:t.rows)}function nb(e,t){let n=e.turns[0];if(!n)return 0;let r=Math.min(t,n.rows.length);if(r<=0)return 0;let i=n.rows.slice(0,r);eb(e,i);for(let e of i)Yy(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function rb(e,t=jy){let n=$y(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=Qy(t),tb(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:nb(e,n-t)}}function ib(e){let t=[],n=new Set;for(let r of e)r.id&&r.name&&!n.has(r.id)&&(n.add(r.id),t.push({id:r.id,label:r.name}));return t}function ab(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 ob(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 sb(e,t=jy){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function cb(e,t=jy){return!sb(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function lb(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 ub=1e4,db=null,fb=null,pb=[],mb=null,hb=null,R=null,gb=null,_b=!1,vb=null,yb=()=>!1,bb=new Set;function z(e){for(let t of bb)t(e)}function xb(){gb&&=(clearTimeout(gb.timeoutHandle),null)}function Sb(){gb=null,vb=`The trace did not load within ${Math.round(ub/1e3)} s.`,z({kind:`rebuild`})}function Cb(e){xb(),_b=!1,vb=null,mb=e,R=e?{sessionId:e,grouping:qy(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,z({kind:`selection-reset`})}function wb(e){let t=ab(pb,hb,mb,e);return hb&&t===hb&&(hb=null),t!==mb&&(Cb(t),!0)}function Tb(e){if(!db)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};db(t)?gb={request:e,timeoutHandle:setTimeout(Sb,ub)}:(vb=De,z({kind:`header`}))}function Eb(e=!1){if(!db)return;let t=ob({selectedSessionId:mb,isPanelVisible:e||yb(),hasPendingRequest:!!gb,hasLoadedOnce:R?.hasLoadedOnce??!1,nextOffset:R?.nextOffset??0});t&&Tb(t)}function Db(){_b&&!gb&&(_b=!1,Eb())}function Ob(){if(!R)return;let e=rb(R.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!R.hasDroppedEarliestRows;t&&(R.hasDroppedEarliestRows=!0),z({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function kb(e){R&&(z({kind:`records-appended`,appends:Xy(R.grouping,e)}),Ob())}function Ab(e){R&&(z({kind:`records-prepended`,prepend:Zy(R.grouping,e)}),Ob())}function jb(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 Mb(){return{selectedSessionId:mb,hasPendingRequest:!!gb,hasLoadedOnce:R?.hasLoadedOnce??!1,hasDroppedEarliestRows:R?.hasDroppedEarliestRows??!1,firstOffset:R?.firstOffset??0,residentRowCount:R?$y(R.grouping):0}}function Nb(){return{sessionOptions:pb,selectedSessionId:mb,selectedTrace:R,pendingSessionId:gb?.request.id??null,traceFailureText:vb}}function Pb(e){bb.add(e)}function Fb(e){yb=e}function Ib(){if(!db)return;let e=cb(Mb());e&&Tb(e)}function Lb(e){pb.some(t=>t.id===e)&&e!==mb&&(hb=null,Cb(e),Eb(),z({kind:`rebuild`}))}function Rb(){let e=wb(!0);return Eb(!0),e}function zb(e){db=e}function Bb(e){fb=e}function Vb(e){hb=e,fb?.()}function Hb(e){pb=ib(e);let t=wb(yb());t&&Eb(),z({kind:`sessions`,hasSelectionChanged:t})}function Ub(e){let t=jb(e);if(!t)return;let n=lb({pendingRequest:gb?.request??null,resident:R?{sessionId:R.sessionId,firstOffset:R.firstOffset,nextOffset:R.nextOffset,hasLoadedOnce:R.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?Db():(xb(),vb&&(vb=null,z({kind:`header`})),n===`stale`?Db():n===`reset`?(Cb(t.id),R&&(R.filePath=t.path),Eb(),z({kind:`rebuild`}),Db()):R&&(R.filePath=t.path,n===`prepend`?(R.firstOffset=t.start,Ab(t.records),Db()):(n===`seed`&&(R.hasLoadedOnce=!0,R.firstOffset=t.start),R.nextOffset=t.next,kb(t.records),Db())))}function Wb(e){let t=e?.id;typeof t==`string`&&t===mb&&yb()&&(gb?_b=!0:Eb())}function Gb(e){let t=e?.id;if(typeof t!=`string`||gb?.request.id!==t)return!1;xb(),_b=!1;let n=e?.message;return vb=typeof n==`string`&&n?n:`The trace could not be read.`,z({kind:`rebuild`}),!0}function Kb(e){xb(),_b=!1,vb=e?null:De,e?(z({kind:`header`}),Eb()):z({kind:`rebuild`})}function qb(e){return e instanceof Error?e.message:String(e)}function Jb(e,t,n=!1){let r=D(`label`,`dialog-checkbox-label`),i=D(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,D(`span`,null,e)),r}function Yb(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function Xb(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:Yb(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 Zb(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:o}=Xt({title:`Workspace repositories`}),s=D(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),c=D(`fieldset`,`dialog-workspace-list`);c.setAttribute(`aria-label`,`Workspace repositories`),c.append(D(`div`,`dialog-hint`,`Loading repositories...`));let l=D(`div`,`dialog-hint`);l.setAttribute(`role`,`status`);let u=D(`div`,`dialog-error`),d=w({variant:`primary`,label:`Save`,disabled:!0});i.append(d),n.append(s,c,l,u,i),o.addEventListener(`click`,r),requestAnimationFrame(()=>o.focus()),Xb(e).then(e=>{if(t.isConnected){c.textContent=``;for(let t of e)c.append(Jb(t.name,t.path,t.isMember));d.disabled=!1}}).catch(e=>{t.isConnected&&(c.textContent=``,u.textContent=`Could not load repositories: ${qb(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: ${qb(e)}`)}).finally(()=>{l.textContent=``,d.disabled=!1}))})}function Qb(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function $b(e,t){bn(e.taskTitleEl,()=>xn(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),rn(e,t)}),e.nameEl.addEventListener(`click`,()=>{tn(e.nameEl)||ui(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),rn(e,t))}),e.btnRename.addEventListener(`click`,()=>{Qb(e),rn(e,t,{returnsFocusToTerminal:!e.renameTargetEl?.isConnected})}),e.btnRestart.addEventListener(`click`,()=>{Qb(e),Hv().then(n=>n?.openRestartDialog(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0}))}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{Qb(e),Zb(t)}),e.btnTrace.addEventListener(`click`,()=>{Qb(e),Vb(t)}),e.btnDocs.addEventListener(`click`,()=>{Qb(e),yg(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=gy(e);n!==`hidden`&&(n===`face`?by(t):location.hash=dv(t))}),e.btnRemove.addEventListener(`click`,()=>{Qb(e),ai(t)});function n(){for(let[,t]of k)t!==e&&Qb(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`)}e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation(),e.sessionMenu.classList.contains(`open`)?Qb(e):n()}),Si({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:()=>Qb(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&&Qb(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),Qb(e),$_(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&ev(e)},{signal:e.abortController.signal})}var ex=1500,tx=new WeakMap;function nx(e){clearTimeout(tx.get(e)),tx.delete(e)}function rx(e,t){let n=setTimeout(()=>{tx.delete(e),v({type:`dismiss`,id:t,expectedState:T.COMPLETE})},ex);tx.set(e,n)}function ix(e,t,n){let r=document.activeElement;return Zr({previousState:t,nextState:n,isPhoneLayout:yo(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}var ax=e=>e==null?``:String(e);function ox(e,t,n){let r=A(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&Sn(e,r.taskTitle)}}function sx(e){return typeof e==`string`&&k.has(e)}function cx(){return k.size}function lx(e){let t=e||{};t.cursorBlink!=null&&Bu(t.cursorBlink),t.debugMode!=null&&(W_(t.debugMode),Xh(t.debugMode));for(let[,e]of k)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function ux(){Pl(k.values(),Il())}function dx(e){return{state:e.currentState,unseenOutcome:e.unseenOutcome,ownerId:e.ownerId}}function fx(){let e=Cn(j.counts),t=e>0?`(${e}) Glimmervoid`:`Glimmervoid`;document.title!==t&&(document.title=t)}function px(e,t,n,r={}){if(!Mn)return;let i=O(e),a=ax(n)||T.DORMANT,o=on(i,ax(t),a,r),s=a===T.DORMANT;Mn.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),yy(c),Xu(c,i)}let u=new AbortController,d=Kv({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=>qv(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:ax(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=()=>Xu(c,i),c._showTerminalFace=l,c._showPreferredFace=l,c._setBorrowed=e=>{c.isBorrowed=e,o.card.toggleAttribute(`data-borrowed`,e),yy(c)},o.card.append(d.el);let f=k.get(i);return f&&Fn(j,dx(f)),k.set(i,c),En(j,dx(c)),qn(i,c),$b(c,i),yy(c),c.btnDocs.hidden=!mg(i),a===T.RUNNING&&Kn(c,!0),s||qu(c,i),fx(),c}function mx(e,t){let n=A(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function hx(e,t){let n=A(e);n&&(n.agent=typeof t==`string`?t:null,yy(n))}function gx(e,t){let n=A(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function _x(e,t,n=!1){let r=A(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=Kt(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function vx(e,t){let n=A(e);n&&(n.pendingPromptKind=typeof t==`string`?t:null)}function yx(e,t){let n=A(e);n&&(Fn(j,dx(n)),n.unseenOutcome=t??null,En(j,dx(n)))}function bx(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function xx(e,t,n=null){let r=A(e),i=ax(t)||`none`;r&&bx(r.card,i),T_(O(e),i,ax(n)||null)}function Sx(e,t,n=null){let r=A(e),i=ax(t)||`none`;r&&bx(r.card,i),E_(O(e),i,ax(n)||null)}function Cx(e,t){let n=A(e);if(!n)return;let r=ax(t);n.card.dataset.session=r,n.nameEl.textContent=r}function wx(e){let t=A(e);t&&(ev(t),Fn(j,dx(t)),k.delete(O(e)),qn(O(e),void 0),Uv?.dropPlanBodyCache(O(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),Dl(t,O(e)),no(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),fx())}function Tx(e,t,n){if(!t||!e.term)return;let r=n===T.DONE?`Session complete`:`Session failed`,i=n===T.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 Ex(e,t){e.term&&(t===T.DONE||t===T.FAILED)&&(e.term.clear(),e.term.reset())}function Dx(e){let t=k.get(e);t&&jn({state:t.currentState,unseenOutcome:t.unseenOutcome})&&document.visibilityState===`visible`&&(yo()||document.hasFocus())&&v({type:`dismiss`,id:e,expectedState:t.currentState})}function Ox(e,t,n){let r=A(e);if(!r)return;let i=ax(t),a=r.currentState;Fn(j,dx(r)),r.currentState=i,En(j,dx(r)),qn(O(e),r),i!==T.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(nx(r),r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),Kn(r,i===T.RUNNING)),a===T.DORMANT&&i!==T.DORMANT&&qu(r,O(e)),In({state:i})===`resting`&&kv(O(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,Kt(i,r.awaitingBackgroundTasks)),yy(r),ix(r,a,i)&&rx(r,O(e));let o=i===T.DONE||i===T.FAILED,s=a!==T.DONE&&a!==T.FAILED&&a!==T.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===T.DONE||i===T.FAILED)&&Tx(r,s,i),i===T.INITIALIZING&&Ex(r,a),fx()}var kx=Bi({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function Ax(e){let t=D(`ul`,`session-setup-list`);return t.append(...e.map(e=>D(`li`,null,e))),t}function jx(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=Ht(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[D(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=D(`div`,`session-setup-plugin`);return t.append(D(`h3`,null,e.name)),e.skills.length>0&&t.append(D(`p`,`session-setup-label`,`Skills`),Ax(e.skills)),e.agents.length>0&&t.append(D(`p`,`session-setup-label`,`Agents`),Ax(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[Ax(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=D(`p`,`session-setup-hook`);return t.append(D(`span`,null,e.event),D(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>D(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[Ax(t.skills)]:[]),n(`Agents`,t.agents.length>0?[Ax(t.agents)]:[])}function Mx(e){let t=D(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=D(`div`,`session-setup-sections`);kx.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function Nx(e){let t=kx.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;jx(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function Px(e){return Re(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function Fx(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${Px(Date.now()-e)} ago`}var Ix=e=>`polled ${Fx(e)}`;function Lx(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=Ix){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=Jn(a)}}}var Rx=80,zx=Object.freeze([{value:`day`,label:`Today`,days:1},{value:`week`,label:`Last 7 days`,days:7},{value:`month`,label:`Last 30 days`,days:30}]),Bx=`week`;function Vx(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function Hx(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function Ux(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${Vx(String(Math.abs(t)))}`}function Wx(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}$${Vx(r)}.${i}`}function Gx(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}${Hx((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${Hx((n/1e6).toFixed(2))}M`:`${t}${Hx((n/1e9).toFixed(2))}B`}function Kx(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=Rx?`warn`:`ok`}var qx=90;function Jx(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&S(e.budgetUsd,null)!==null):[]}function Yx(e){let t=S(e?.pct,null);return t===null?0:t}function Xx(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=S(n.pct,null),i=S(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}function Zx(e){return e?.vendor===`codex`||e?.vendor===`kimi`?e.vendor:`claude`}function Qx(e,t=null){let n=[],r=Kx(Xx(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 Jx(e)){let e=Yx(t);if(e<qx)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return Xe(n)}function $x(e,t=``){let n=e?.source;if(n===`fetched`){let e=je(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=je(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 eS(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 tS(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function nS(e){if(!e||typeof e!=`object`)return``;let t=[],n=tS(e.dirs);if(n!==null&&t.push(`${Ux(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${Ux(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${Ux(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${Ux(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 rS(e){return je(e?.error,``)}function iS(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}var aS=`Estimated list prices, not a bill.`,oS=`Enable in Settings.`,sS=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],cS=/^(\d{4})-(\d{2})-(\d{2})$/,lS=new Set([`day`,`model`,`label`]),uS=new Set([`model`,`label`]);function dS(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${Hx(e.toFixed(1))}%`}var fS=`tokens`,pS=Object.freeze([{value:`tokens`,label:`Tokens`},{value:`cost`,label:`Cost`}]);function mS(e){return e===`cost`?`cost`:fS}function hS(e,t){return t===`cost`?Wx(e):Gx(e)}function gS(e,t){if(t===`tokens`)return`tokens`;let n=Number(e?.costUSD);return Number.isFinite(n)&&n>0?`costUSD`:`tokens`}function _S(e){return e===`costUSD`?`share of cost`:`share of tokens`}function vS(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function yS(e){let t=cS.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=sS[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function bS(e){let t=xS(e);return t.length===0?``:t.length===1?yS(t[0]):`${yS(t[0])} to ${yS(t[t.length-1])}`}function xS(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>cS.test(e)).sort()}function SS(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:CS(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function CS(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=wS(e,n);return cS.test(r)?r:wS(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function wS(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function TS(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:he(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function ES(e,t){let n=Ot(t-864e5),[,r,i]=e.yesterday.day.split(`-`).map(Number),a=e.yesterday.day===n?`yesterday`:`${sS[r-1]} ${i}`,o=e.yesterday.sessionCount===1?`session`:`sessions`;return`${a}: ${e.yesterday.sessionCount} ${o}, ${TS(e.yesterday.activeMs/6e4)}`}function DS(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=sS[n.getMonth()];return r?`${r} ${n.getDate()} ${Be(n)}`:`-`}var OS=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`}),kS=`Sessions spawned by Glimmervoid; terminal sessions count as other`,AS=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function jS(e){let t=je(e,``);return t?OS[t]||t:OS.other}function MS(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function NS(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function PS(e){return MS(e).some(e=>NS(e.lane))}var FS=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function IS(e,t,n){let r=Xx(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function LS(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+S(t.costUSD,0),0),o=i.reduce((e,t)=>e+S(t.tokens,0),0),s=i.filter(e=>NS(e.lane)).map(e=>({lane:String(e.lane),label:jS(e.lane),tokens:S(e.tokens,0),costUSD:S(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?vS(c,a):vS(l,o),d=IS(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:FS[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function RS(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:OC.map(e=>LS(e.key,r[e.key],t,n)).filter(e=>e!==null)}function zS(e){return e.planPct===null?``:`about ${dS(e.planPct)} of plan`}function BS(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?Wx(e.costUSD):Gx(e.tokens)}`).join(`, `)}var VS=`team-review`;function HS(e){if(!Array.isArray(e?.byLane))return``;let t=MS(e).find(e=>e.lane===VS),n=S(t?.costUSD,0);if(n<=0)return``;let r=vS(n,e?.totals?.costUSD),i=r===null?``:`, ${dS(r)} of this period`;return`PR reviews cost ${Wx(n)}${i}.`}function US(e){let t=S(e,null);return t===null||t<=0?``:`${Ux(t)} ${t===1?`session`:`sessions`}`}function WS(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function GS(e){let t=WS(e);if(!t)return``;let n=S(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 ${Wx(n)}${i}, across ${Gx(S(t.cacheReadTokens,0))} cache read tokens.`}function KS(e){return e===`monthly`?`this month`:`today`}function qS(e){return`${Wx(S(e?.spentUsd,0))} of ${Wx(S(e?.budgetUsd,0))}`}function JS(e){return`${KS(e?.scope)} spend against budget`}var YS=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function XS(e){let t=cS.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function ZS(e){let t=XS(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Ot(t)}function QS(e){let t=cS.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function $S(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 eC(e,t){e.tokens+=S(t?.tokens,0),e.costUSD+=S(t?.costUSD,0),e.input+=S(t?.input,0),e.output+=S(t?.output,0),e.cacheCreate+=S(t?.cacheCreate,0),e.cacheRead+=S(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=zC(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+=S(t?.tokens,0),r.costUSD+=S(t?.costUSD,0),r.input+=S(t?.input,0),r.output+=S(t?.output,0),r.cacheCreate+=S(t?.cacheCreate,0),r.cacheRead+=S(t?.cacheRead,0),e.modelByName.set(n,r)}}function tC(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 nC(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)||$S(r);eC(i,e),n.set(r,i)}return Array.from(n.values()).map(tC)}function rC(e){return nC(e,ZS)}function iC(e){return nC(e,QS)}function aC(e,t){return t===`week`?rC(e):t===`month`?iC(e):Array.isArray(e)?[...e]:[]}var oC=/^(\d{4})-(\d{2})$/;function sC(e,t){if(t===`month`){let t=oC.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=sS[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=yS(e);return t===`-`?t:`week of ${t}`}return yS(e)}function cC(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var lC=16,uC=Object.freeze([.05,.25,.5,.75]),dC=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function fC(e,t){let n=S(e,0),r=S(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<uC.length;e+=1)i>=uC[e]&&(a=e+1);return a}function pC(e,{weeks:t=lC,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>cS.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`&&cS.test(n)?n:Ot(o),c=XS(ZS(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Ot(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,S(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=Ot(n),a=i.get(r)||null,o=r>s,c=p!==null&&r<p;d.push({day:r,week:e,weekday:t,tokens:S(a?.tokens,0),costUSD:S(a?.costUSD,0),source:a?.source===`history`?`history`:a?`live`:null,noData:o||c||!a&&p===null,tone:fC(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function mC(e){let t=yS(e?.day);if(e?.noData)return`${t}: no data`;let n=S(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${Gx(n)} tokens, ${Wx(S(e?.costUSD,0))}`}function hC(e){if(!e)return``;let t=S(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${yC(e.ratio)} the ${n} average: ${Wx(e.todayUsd)} against ${Wx(e.baselineUsd)}.`}function gC(e){return e?`This block is burning ${yC(e.ratio)} the usual rate: ${Gx(e.current)} tokens per minute against ${Gx(e.baseline)}.`:``}function _C(e){return[hC(e?.daily),gC(e?.burn)].filter(Boolean).join(` `)}function vC(e){return!!(e?.daily||e?.burn)}function yC(e){let t=S(e,null);return t===null?`-`:`${Hx(t.toFixed(1))}x`}var bC=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`,kimi:`Kimi`});function xC(e){let t=je(e,``);return t?bC[t]||t:bC.claude}function SC(e,t){return wC(t)?xC(e?.vendor):``}function CC(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>S(t[n]?.tokens,0)-S(t[e]?.tokens,0)).map(e=>({vendor:e,label:xC(e),tokens:S(t[e]?.tokens,0),costUSD:S(t[e]?.costUSD,0)}))}function wC(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 TC=`Claude only`;function EC(e){return wC(e)?TC:``}var DC=36e5,OC=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]),kC=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`},{vendor:`kimi`,label:`Kimi Code`}]);function AC(e,t=Date.now()){let n=S(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function jC(e,t=Date.now()){let n=S(e,null);return n===null||n<=0||t-n>DC}function MC(e,t=Date.now()){if(!jC(e,t))return``;let n=AC(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function NC(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 PC(e){let t=je(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function FC(e){return rS(e)!==``}function IC(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 LC(e){return typeof e?.id==`string`&&e.id!==``}function RC(e){let t=je(e?.label,``);return LC(e)&&t?t:IC(e?.project)||t||`unknown project`}function zC(e){let t=typeof e==`string`?e:e?.model;return je(t,`unknown model`)}function BC(e){return String(e?.day??``)}function VC(e,t,n){if(!lS.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?BC(e):n(e)}function HC(e,t,n,r=RC){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=VC(e,t,r),o=VC(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 UC(e){return uS.has(e)?`asc`:`desc`}function WC(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:UC(t)}}function GC(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var KC=Object.freeze({key:`lastTs`,dir:`desc`}),qC=Object.freeze({key:`tokens`,dir:`desc`}),JC=Object.freeze({key:`day`,dir:`desc`});function YC(e,t=KC){return HC(e,t.key,t.dir,RC)}function XC(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 ZC(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${Ux(t)} hidden`}function QC(e,t=qC){return HC(e,t.key,t.dir,zC)}function $C(e,t=JC){return HC(e,t.key,t.dir,BC)}function ew(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function tw(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 nw=36e5,rw=24*nw,iw=Object.freeze({fiveHour:{lengthMs:5*nw,label:`5-hour`},sevenDay:{lengthMs:7*rw,label:`weekly`}}),aw=10,ow=80,sw=100,cw=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function lw(e,t){return e>=sw?`fail`:e>=ow||t!==null&&t>=ow?`warn`:`ok`}function uw(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 dw(e,t,n,r){let i=Xx(n,t);if(!i||i.pct===null||i.resetsAtMs!==null&&i.resetsAtMs<=r)return null;let a=iw[t],o=uw(a.lengthMs,i.resetsAtMs,r),s=o!==null&&o>=aw&&i.pct<sw?i.pct/(o/100):null;return{vendor:e,vendorLabel:kC.find(t=>t.vendor===e)?.label||e,key:t,windowLabel:a.label,usedPct:i.pct,elapsedPct:o,projectedPct:s,resetsAtMs:i.resetsAtMs,tone:lw(i.pct,s)}}function fw(e,t){return kC.flatMap(({vendor:n})=>OC.map(({key:r})=>dw(n,r,e[n],t)).filter(e=>e!==null))}function pw(e,t){let n=S(e,null);if(n===null||n<=0)return``;let r=new Date(n),i=Be(r);return Ot(n)===Ot(t)?i:n-t<7*rw&&r.getDay()!==new Date(t).getDay()?`${cw[r.getDay()]} ${i}`:`${sS[r.getMonth()]} ${r.getDate()} ${i}`}function mw(e){return`${Math.round(e)}%`}function hw(e){return Math.max(e.usedPct,e.projectedPct??0)}function gw(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 _w(e,t){let n=gw(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 ${mw(100-r.usedPct)} of its ${r.windowLabel} window left.`}function vw(e,t){let n=pw(e,t);return!n||e===null?`until the window resets`:`until ${n}, in ${TS((e-t)/6e4)}`}function yw(e,t,n){let r=[`${e.vendorLabel} sessions stop answering ${vw(e.resetsAtMs,n)}. Their worktrees and conversations stay intact.`,_w(t,e.vendor)];return{tone:`fail`,headline:`${e.vendorLabel} ${e.windowLabel} limit reached.`,detail:r.filter(Boolean).join(` `)}}function bw(e,t){let n=pw(e.resetsAtMs,t),r=n?`, resets ${n}`:``;if(e.usedPct>=ow)return{tone:`warn`,headline:`${e.vendorLabel} ${e.windowLabel} limit is at ${mw(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 ${mw(e.projectedPct??e.usedPct)}.`}}function xw(e){return{tone:`warn`,headline:`Over your ${KS(e.scope)===`today`?`daily`:`monthly`} budget.`,detail:`${qS(e)} spent ${KS(e.scope)}.`}}function Sw(e,t,n,r){let i=e.find(e=>e.tone===`fail`);if(i)return yw(i,e,r);let a=e.filter(e=>e.tone===`warn`).sort((e,t)=>hw(t)-hw(e))[0];if(a)return bw(a,r);let o=t.find(e=>S(e.pct,0)>=100);if(o)return xw(o);if(e.length===0)return{tone:`ok`,headline:n===null?`Nothing spent yet today.`:`${Wx(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)=>hw(t)-hw(e))[0],c=pw(s.resetsAtMs,r);return{tone:`ok`,headline:`Every limit has room.`,detail:`Closest is ${s.vendorLabel} ${s.windowLabel} at ${mw(s.usedPct)}${c?`, resets ${c}`:``}.`}}function Cw(e){return e.tone===`fail`?`limit reached`:e.projectedPct===null?e.elapsedPct===null?``:`too early to project`:`about ${mw(e.projectedPct)} at reset`}var ww=`report`;function Tw(e){return zx.find(t=>t.value===e)?.label||``}function Ew(e,t){return{key:gS(e,t),dir:`desc`}}function Dw(e,t){let n=QC(e?.models,Ew(e?.totals,t))[0];if(!n)return null;let r=gS(e?.totals,t);return{label:zC(n),sharePct:vS(n[r],e?.totals?.[r])}}function Ow(e,t){let n=YC(e?.sessions,Ew(e?.totals,t)),r=n[0];return{count:n.length,topLabel:r?RC(r):``}}function kw(e){let t=MS(e).filter(e=>NS(e.lane));return t.length===0?null:t.reduce((e,t)=>e+S(t.costUSD,0),0)}function Aw(e){let t=e.filter(e=>S(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 jw(e){return xS(e).length}function Mw(e,t){let n=XS(e);return!n||t<=0?[]:Array.from({length:t},(e,r)=>{let i=new Date(n);return i.setDate(n.getDate()-(t-1-r)),Ot(i)})}function Nw(e){return zx.find(t=>t.value===e)?.days??7}function Pw(e){return e.reduce((e,t)=>t.resetsAtMs===null?e:e===null?t.resetsAtMs:Math.min(e,t.resetsAtMs),null)}function Fw(e,t){let n=XS(e);return n?(n.setDate(n.getDate()+t),Ot(n)):``}function Iw(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=String(e?.day??``);cS.test(n)&&r.set(n,(r.get(n)??0)+S(e?.[t],0))}return r}function Lw(e,t){let n=XS(e);return n?t<=7?cw[n.getDay()]:String(n.getDate()):e}function Rw(e,t,n,r){let i=Iw(e,r===`cost`?`costUSD`:`tokens`),a=Mw(n,t).map(e=>({day:e,label:Lw(e,t),value:i.get(e)??0,isToday:e===n})),o=a.reduce((e,t)=>e+t.value,0),s=Mw(Fw(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 zw(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 Bw(e){return`${hS(e.average,e.metric)} a day on average`}function Vw(e){return wC(e)?CC(e).map(e=>`${e.label} ${Wx(e.costUSD)}`).join(`, `):``}function Hw(e){return wC(e)?CC(e).map(t=>({...t,sharePct:vS(t.tokens,e?.tokens)})):[]}function Uw(e){let t=e?.totals,n=[{label:`Processed tokens`,value:Gx(S(t?.tokens,0))},{label:`Cached input`,value:Gx(S(t?.cacheRead,0))},{label:`Uncached input`,value:Gx(S(t?.input,0))},{label:`Output`,value:Gx(S(t?.output,0))}],r=S(WS(e?.savings)?.savedUSD,0);return r>0&&n.push({label:`Cache savings`,value:Wx(r)}),n}function Ww(e){let t=(e?.yourDay?.insights??[]).map(e=>({text:e.text,tone:`ok`})),n=e?.anomaly;vC(n)&&t.push({text:_C(n),tone:`warn`});for(let n of[GS(e?.savings),HS(e)])n&&t.push({text:n,tone:`ok`});return t}function Gw(e,t,n,r){let i=gS(t,n),a=e.reduce((e,t)=>Math.max(e,S(t[i],0)),0);return e.map(e=>({row:e,label:r(e),tokens:S(e.tokens,0),costUSD:S(e.costUSD,0),sharePct:vS(e[i],t?.[i]),barPct:vS(e[i],a)??0}))}function Kw(e,t){return Gw(QC(e?.models,Ew(e?.totals,t)),e?.totals,t,zC)}function qw(e,t){return Gw(YC(e?.sessions,Ew(e?.totals,t)),e?.totals,t,RC)}function Jw(e){return[{label:`Input`,tokens:S(e.input,0)},{label:`Output`,tokens:S(e.output,0)},{label:`Cache write`,tokens:S(e.cacheCreate,0)},{label:`Cache read`,tokens:S(e.cacheRead,0)}]}var Yw=2e4,Xw=`glimmervoid-usage-metric`,Zw=null,Qw=null,$w={claude:null,codex:null,kimi:null},eT=null,tT=null,nT=null,rT=Bx,iT=mS(er(Xw,null)),aT=!1,oT=null,sT=null,cT=!0,lT=()=>!1,uT=new Set,dT=Et({getAck:Br,setAck:Ar,signature:()=>Qx(Zw,$w.claude),isLooking:()=>lT()});function fT(e){for(let t of uT)t(e)}function pT(){eT?.(dT.refresh())}function mT(e){aT=e,fT(`refresh-status`),oT&&=(clearTimeout(oT),null),e&&(oT=setTimeout(()=>{oT=null,aT=!1,sT=`Usage did not answer within ${Math.round(Yw/1e3)} s. Refresh to try again.`,fT(`refresh-status`)},Yw))}function hT(e){let t=zx.find(t=>t.value===e);return t?t.days:null}function gT(){return{report:Zw,sessions:Qw,planLimitsByVendor:$w,rangeValue:rT,metric:iT}}function _T(){let e=!cT||!aT&&sT!==null;return cT?aT?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:sT??``,isPending:!1,hasFailure:e}:{text:Zw?`${De} The figures below are from before the connection dropped.`:De,isPending:aT,hasFailure:e}}function vT(e){uT.add(e)}function yT(e){lT=e,pT()}function bT(){dT.acknowledge(),pT()}function xT(e){eT=e,pT()}function ST(e){tT?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function CT(e){tT=e}function wT(e){rT=e}function TT(e){iT=e,$n(Xw,e)}function ET({force:e=!1}={}){if(!tT)return;nT=h(`usage`);let t={type:`request-usage-report`,requestId:nT};e&&(t.force=!0);let n=hT(rT);n!==null&&(t.days=n),sT=null,mT(!0),!tT(t)&&(sT=De,mT(!1))}function DT(e){cT=e,fT(`refresh-status`)}function OT(e){Qw=e,fT(`sessions`)}function kT(e){let t=e;$w={...$w,[Zx(t)]:t},fT(`plan-limits`),pT()}function AT(e){iS(e,nT)&&(sT=null,mT(!1),Zw=e,fT(`report`),pT())}function jT(){let e=Zw?.pricing||(Qw?{source:Qw.pricingSource}:null),t=eS(e?.fetchedAt),n=[$x(e,t!==null&&t>0?Fx(t):``)],r=rS(Zw);r&&n.push(r);let i=nS(Zw?.scan);return i&&n.push(i),n}var MT=26,NT=97;function PT(e){return Object.values(e.elements).filter(e=>e.kind===`unit`)}function FT(e){let t=String.fromCharCode(NT+e%MT),n=Math.floor(e/MT);return n===0?t:`${t}${n+1}`}function IT(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 LT(e){let t=PT(e),n=IT(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}${FT(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 RT=14,zT=30,BT=40,VT=120,HT=300,UT=400,WT=4e4,GT=2e4,KT=4e5,qT=6,JT=12,YT=3e3,XT=14,ZT=8,QT=100,$T=6.6,eE=5,tE=10,nE=2,rE=[.5,.35,.65,.2,.8],iE=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}],aE={right:0,left:1,bottom:2,top:3},oE={left:0,right:1,top:2,bottom:3},sE=[1,0,3,2];function cE(e){return e===`left`||e===`right`}function lE(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function uE(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function dE(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 fE(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)pE(n.rect,e.rect)&&t(n,e);r.push(e)}}function pE(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 mE(e,t){return e[0]-t[0]||e[1]-t[1]}function hE(e){let t=[];return fE(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(mE)}function gE(e,t){let n=[];return fE([...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(mE)}function _E(e){return dE(e.map(e=>({...e,width:0,height:0})))??{x:0,y:0,width:0,height:0}}function vE(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 yE(e){return e.from.y===e.to.y}function bE(e,t){let n=t.x+t.width,r=t.y+t.height;if(yE(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 xE(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 SE(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 CE(e){return e.slice(1).flatMap((t,n)=>{let r=e[n];return r?[{from:r,to:t}]:[]})}function wE(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function TE(e){if(e.length<=we.layoutWarnings)return[...e];let t=e.slice(0,we.layoutWarnings-1);return[...t,`and ${e.length-t.length} more`]}function EE(e,t){return t.x>=e.x+e.width||t.x+t.width<=e.x}function DE(e,t,n){if(e.id===t.id)return{exitSide:`right`,entrySide:`top`};if(n)return{exitSide:`bottom`,entrySide:`bottom`};let r=lE(e),i=lE(t);return EE(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 OE=[`right`,`left`,`bottom`,`top`];function kE(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,...OE.filter(e=>e!==t.exitSide)],o=n.toSide?[n.toSide]:[t.entrySide,...OE.filter(e=>e!==t.entrySide)];return a.flatMap(e=>o.map(t=>({exitSide:e,entrySide:t})))}function AE(e,t){let n=e.outputPort??LE(e.from,t.exitSide,1)[0]??lE(e.from),r=LE(e.to,t.entrySide,1)[0]??lE(e.to);if(!HE(t.exitSide,t.entrySide))return{...e,...t,start:n,end:r};let i=UE(r,t.entrySide,e.to,n),a=i===r&&!e.outputPort?UE(n,t.exitSide,e.from,r):n;return{...e,...t,start:a,end:i}}function jE(e,t){return e.turnsAndCrossings<t.turnsAndCrossings||e.turnsAndCrossings===t.turnsAndCrossings&&e.cost<t.cost}function ME(e,t,n){let r=aD(e,t,{usageByEdge:new Map,usageByNodeAndAxis:new Map},null,n,{remainingExpansions:YT}),i=r?.at(-1),a=i===void 0?1/0:n.bestCost[i]??1/0;if(rD(n),!r||a===1/0)return null;let o=SE(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:CE(o),bounds:_E(o),bends:Math.max(o.length-2,0),cost:a}}function NE(e,t){let n=t.filter(t=>pE(e.bounds,t.bounds)&&t.segments.some(t=>e.segments.some(e=>wD(e,t)))).length;return{turnsAndCrossings:e.bends+n,cost:e.cost}}function PE(e,t,n){let r=new Map(e.map(e=>[e,kE(e,t.get(e)??{exitSide:e.exitSide,entrySide:e.entrySide})]));if(![...r.values()].some(e=>e.length>1))return;let i=XE([...r].flatMap(([e,t])=>t.map(t=>AE(e,t))),[...n.boxesById.values(),...n.panels],n.softObstacles,n.contentTop);if(!i)return;let a=nD(i),o=new Map(e.flatMap(e=>{let[t]=r.get(e)??[],n=t?ME(i,AE(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:NE(n,r)};for(let n of t.slice(1)){let t=ME(i,AE(e,n),a),o=t?NE(t,r):null;o&&jE(o,s.score)&&(s={pair:n,score:o})}s.pair&&(e.exitSide=s.pair.exitSide,e.entrySide=s.pair.entrySide)}}function FE(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 IE(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=DE(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??lE(r),end:lE(i)};return t.set(c,a),[c]});PE(n,t,e),FE(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 LE(e,t,n){let r=Array.from({length:n},(e,t)=>t);if(cE(t)){let i=Math.round(t===`left`?e.x:e.x+e.width),a=Math.min(XT,(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+ZT,Math.min(o,e.y+e.height-ZT-(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)*XT/2;return r.map(e=>({x:Math.round(a+e*XT),y:i}))}function RE(e,t){let n=cE(t)?e.height:e.width;return Math.max(1,Math.floor((n-16)/XT)+1)}function zE(e){return vE(e.flatMap(e=>[...e.outputPort?[]:[{box:e.from,side:e.exitSide,groupKey:`exit|${e.styleKey}`,wireId:e.wire.id,farPoint:lE(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??lE(e.from),assign:t=>{e.end=t}}]),e=>`${e.box.id}|${e.side}`)}function BE(e){return new Map([...e.entries()].map(([e,t])=>[e,[...vE(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+(cE(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 VE(e,t){for(let[n,r]of e){let e=r[0],i=t.get(n)??[];if(!e)continue;let a=LE(e.box,e.side,i.length);for(let e of r){let t=a[i.indexOf(e.groupKey)];t&&e.assign(t)}}}function HE(e,t){return e===`right`&&t===`left`||e===`left`&&t===`right`||e===`bottom`&&t===`top`||e===`top`&&t===`bottom`}function UE(e,t,n,r){return cE(t)?r.y>=n.y+ZT&&r.y<=n.y+n.height-ZT?{x:e.x,y:r.y}:e:r.x>=n.x+ZT&&r.x<=n.x+n.width-ZT?{x:r.x,y:e.y}:e}function WE(e,t){let n=(e,n)=>(t.get(`${e.id}|${n}`)?.length??0)===1,r=new Map([...vE(e,e=>e.exitKey)].map(([e,t])=>[e,t.length]));for(let t of e){if(t.from.id===t.to.id||!HE(t.exitSide,t.entrySide))continue;let e=t.busKey===null&&n(t.to,t.entrySide)?UE(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=UE(t.start,t.exitSide,t.from,t.end)):t.end=e}}function GE(e,t){return[...e.entries()].flatMap(([e,n])=>{let r=n[0],i=t.get(e)?.length??0;return!r||i<=RE(r.box,r.side)?[]:[`box ${r.box.id} has ${i} wires on its ${r.side} side, more than fit`]})}function KE(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 qE(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 JE(e,t,n){return{first:qE(e,t,!1),last:qE(e,n,!0)-1}}function YE(e,t,n){return{first:Math.max(0,qE(e,t,!1)-1),last:Math.min(qE(e,n,!0)-1,e.length-2)}}function XE(e,t,n,r){let i=[...t,...n],a=dE([...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-RT,e.x+e.width+RT]),a.x-42,a.x+a.width+42].map(Math.round),u=[...i.flatMap(e=>[e.y-RT,e.y+e.height+RT]),a.y-42,a.y+a.height+42].map(Math.round).filter(e=>e>=c),d=KE([...new Set([...l,...o])].sort((e,t)=>e-t)),f=KE([...new Set([...u,...s])].sort((e,t)=>e-t));if(d.length*f.length>WT)return null;let p=t.map(e=>uE(e,1)),m=(e,t)=>{let n=new Uint8Array(d.length*f.length);for(let r of t){let t=e===0?YE(d,r.x,r.x+r.width):JE(d,r.x,r.x+r.width),i=e===0?JE(f,r.y,r.y+r.height):YE(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 ZE(){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 QE(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 $E(e,t){return`${e}\n${t}`}function eD(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($E(t.busKey,t.exitKey))??0;return n+r-i}function tD(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?eD(a,t):0,c=s>0,l=a!==void 0&&a.total>s,u=o!==void 0&&o.total>eD(o,t);return(c?-i*.5:0)+(l?VT:0)+(u?BT:0)}function nD(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 rD(e){for(let t of e.touchedStates)e.bestCost[t]=1/0,e.cameFrom[t]=-1;e.touchedStates.length=0}function iD(e,t,n,r,i,a){let o=aD(e,t,n,r,i,a);return rD(i),o}function aD(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=aE[t.exitSide],m=oE[t.entrySide],{bestCost:h,cameFrom:g,touchedStates:_}=i,v=ZE(),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<GT&&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 oD(g,i);let l=s%o,u=(s-l)/o,y=h[i]??1/0;for(let[a,te]of iE.entries()){if(s===d&&a!==p||a===sE[c])continue;let b=l+te.x,x=u+te.y;if(b<0||x<0||b>=o||x>=e.ys.length)continue;let ne=x*o+b;if(ne===f&&a!==m)continue;let re=QE(e,l,u,a);if(s!==d&&ne!==f&&e.isBlocked[re.axis]?.[re.index]===1)continue;let ie={x:e.xs[l]??0,y:e.ys[u]??0},ae={x:e.xs[b]??0,y:e.ys[x]??0},oe=Math.abs(ae.x-ie.x)+Math.abs(ae.y-ie.y),se=r!==null&&bE({from:ie,to:ae},r),ce=oe+(a===c?0:zT)+(e.isSoft[re.axis]?.[re.index]===1?HT:0)+(se?UT:0)+tD(n,t,re,ne,oe),le=ne*4+a,ue=y+Math.max(ce,1);ue>=(h[le]??1/0)||(h[le]=ue,g[le]=i,_.push(le),v.push(le,ue+ee(b,x)))}}return null}function oD(e,t){let n=[];for(let r=t;r!==-1;r=e[r]??-1)n.push(r);return n.reverse()}function sD(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,$E(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=QE(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 cD(e,t){let n=iE[aE[t]]??{x:0,y:0};return{x:e.x+n.x*RT,y:e.y+n.y*RT}}function lD(e){let t=cD(e.start,e.exitSide),n=cD(e.end,e.entrySide);return SE([e.start,t,{x:n.x,y:t.y},n,e.end])}function uD(e,t){if(!e.wire.back)return null;let n=dE([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 dD(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 fD(e,t,n){let r=e&&n?SE(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}})):lD(t);return{plan:t,points:r,segments:CE(r),states:n}}function pD(e,t,n){let r=XE(e,[...t.boxesById.values(),...t.panels],t.softObstacles,t.contentTop),i=r?nD(r):null,a={usageByEdge:new Map,usageByNodeAndAxis:new Map},o=new Map;for(let s of dD(e,e=>e)){let e=r&&i?iD(r,s,a,uD(s,t.loopFrames),i,n):null;r&&e&&sD(r,a,s,e,1),o.set(s.wire.id,fD(r,s,e))}return{drawn:e.flatMap(e=>o.get(e.wire.id)??[]),grid:r,usage:a}}function mD(e){return Math.max(0,e.points.length-2)}function hD(e,t,n){let r=_E(e.points),i=t.filter(t=>pE(r,_E(t.points))&&DD(e,t)!==null).length;return kD(n).filter(t=>{let n=uE(t,-2);return pE(r,n)&&AD(e,t,n)}).length*QT+i}function gD(e,t){let{grid:n,usage:r}=e;if(!n)return e.drawn;let i=nD(n),a={remainingExpansions:KT},o=new Map(e.drawn.map(e=>[e.plan.wire.id,e]));for(let s of dD(e.drawn,e=>e.plan)){if(!s.states||a.remainingExpansions<=0)continue;let e=[...o.values()].filter(e=>e.plan!==s.plan),c=hD(s,e,t);if(c===0)continue;sD(n,r,s.plan,s.states,-1);let l=fD(n,s.plan,iD(n,s.plan,r,uD(s.plan,t.loopFrames),i,a)),u=mD(l)<=Math.max(mD(s),qT),d=l.states&&u&&hD(l,e,t)<c?l:s;sD(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 _D(e){return Math.ceil(e.length*$T)}function vD(e,t){return{x:e.x-t/2,y:e.y-tE,width:t,height:13}}function yD(e){return Math.abs(e.from.x-e.to.x)+Math.abs(e.from.y-e.to.y)}function bD(e,t){if(!yE(e))return[];let n=e.from.y;return[Math.min(e.from.x,e.to.x)+eE+t/2,Math.max(e.from.x,e.to.x)-eE-t/2].flatMap(e=>[{x:e,y:n-eE},{x:e,y:n+eE+tE}])}function xD(e,t){let n=[...e].sort((e,t)=>yD(t)-yD(e));return[...e.slice(0,1),...n].flatMap(e=>[...rE.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 yE(e)?[{x:r,y:i-eE},{x:r,y:i+eE+tE}]:[{x:r+eE+t/2,y:i+tE/2},{x:r-eE-t/2,y:i+tE/2}]}),...bD(e,t)])}function SD(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=_D(e),c=xD(o.segments,s),l=c.find(e=>{let n=vD(e,s);if(n.y<t.contentTop)return!1;let o=uE(n,nE);return i.some(e=>bE(e,o))||a.some(e=>xE(n,e))?!1:![...r.values()].some(e=>xE(n,e.bounds))}),u=l??c[0]??lE(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:vD(u,s)})}return r}function CD(e,t,n){return e>Math.min(t,n)+.5&&e<Math.max(t,n)-.5}function wD(e,t){if(yE(e)===yE(t))return!1;let n=yE(e)?e:t,r=n===e?t:e;return CD(r.from.x,n.from.x,n.to.x)&&CD(n.from.y,r.from.y,r.to.y)}function TD(e,t){if(yE(e)!==yE(t))return!1;let n=yE(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 ED(e,t){return e.plan.busKey!==null&&e.plan.busKey===t.plan.busKey||e.plan.exitKey===t.plan.exitKey}function DD(e,t){if(ED(e,t))return null;let n=e.segments.flatMap(e=>t.segments.map(t=>[e,t]));return n.some(([e,t])=>wD(e,t))?`wire ${e.plan.wire.id} crosses wire ${t.plan.wire.id}`:n.some(([e,t])=>TD(e,t))?`wire ${e.plan.wire.id} overlaps wire ${t.plan.wire.id}`:null}function OD(e){return hE(e.map(e=>_E(e.points))).flatMap(([t,n])=>{let r=e[t],i=e[n];return r&&i?DD(r,i)??[]:[]})}function kD(e){return[...e.boxesById.values(),...e.panels]}function AD(e,t,n){return t.id===e.plan.from.id||t.id===e.plan.to.id?!1:e.segments.some(e=>bE(e,n))}function jD(e,t){let n=kD(t),r=n.map(e=>uE(e,-2));return gE(e.map(e=>_E(e.points)),r).flatMap(([t,i])=>{let a=e[t],o=n[i],s=r[i];return!a||!o||!s?[]:AD(a,o,s)?[`wire ${a.plan.wire.id} runs through ${o.kind} ${o.id}`]:[]})}function MD(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=mD(e);return t>qT?[`wire ${e.plan.wire.id} bends ${t} times`]:[]})}function ND(e,t){return yE(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 PD(e,t){if(!t||t===e)return null;let n=e.points.find(e=>t.segments.some(t=>ND(e,t)));return!n||n.x===e.plan.end.x&&n.y===e.plan.end.y?null:n}function FD(e,t){let n=e[t],r=e[t+1];n!==void 0&&r!==void 0&&(e[t]=r,e[t+1]=n)}function ID(e,t,n,r,i){VE(n,r),WE(e,r);let a=pD(e,t,i);return{routed:a,crossingCost:jD(a.drawn,t).length*QT+OD(a.drawn).length}}function LD(e,t,n,r,i){let a=ID(e,t,n,r,i);if(e.length>JT)return gD(a.routed,t);for(let o of r.values())for(let s=0;a.crossingCost>0&&s+1<o.length;s+=1){FD(o,s);let c=ID(e,t,n,r,i);c.crossingCost<a.crossingCost?a=c:FD(o,s)}return gD(ID(e,t,n,r,i).routed,t)}function RD(e){let t=IE(e),n=zE(t),r=BE(n),i={remainingExpansions:KT},a=LD(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=SD(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:wE(n),start:t.start,end:t.end,label:t.wire.label,labelAt:c.get(t.wire.id)?.at??lE(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:PD(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,...jD(a,e),...OD(a),...MD(a),...GE(n,r),...s],extent:dE([...f,...d])}}var B=40,zD=44,BD=220,VD=90,HD=30,UD=12,WD=20,GD=18,KD=28,qD=12,JD=2,YD=20,XD=26,ZD=18,QD=26,$D=170,eO=21,tO=17,nO=10,rO=22,iO=24,aO=16,oO=16,sO=26,cO=24,lO=8,uO=10,dO=14,fO=4,pO=40,mO=26,hO=24,gO=8,_O=320,vO=Object.freeze({blue:`#60a5fa`,green:`#4ade80`,orange:`#fb923c`,pink:`#f472b6`,cyan:`#22d3ee`,yellow:`#facc15`});function yO(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 bO(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>qD){let t=yO(e.text,n-r-JD).map(e=>a(e,1,JD,null));return[a(``,0,0,i),...t]}let o=e.style===`item`?JD:i?i.length+1:0;return yO(e.text,n-r-o-+(e.style===`code`)).map((e,t)=>a(e,t,o,i))}function xO(e,t=XD){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,bO(e,n,t)))}function SO(e,t){let n=e.lanes.find(e=>e.id===t.lane);return n?{label:n.label||n.id,hex:vO[n.color]}:null}function CO(e){return e.column!==null&&e.at===null&&e.near===null}function wO(e){return e.width??BD}function TO(e,t){return Math.floor(e*(t-24)/196)}function EO(e){if(!e.media)return null;let t=wO(e),n=t-24,r=Math.round(_O*t/BD);return{width:n,height:Math.min(r,Math.max(1,Math.round(n*e.media.height/e.media.width)))}}function DO(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+UD,y:t.y+n,width:r.width,height:r.height}}function OO(e,t){let n=wO(t),r=TO(YD,n),i=yO(t.title,r),a=t.change===`relabeled`&&t.was?yO(t.was,r):[],o=xO(t.lines,TO(XD,n)),s=SO(e,t),c=s!==null&&!CO(t),l=UD+(a.length+i.length)*WD+o.length*GD,u=EO(t),d=u?u.height+gO:0,f=l+UD+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+gO,mediaSize:u,height:f+p.length*KD}}function V(e,t){return Object.values(e.elements).filter(e=>e.kind===t)}function kO(e){let t=yO(e.text,eO);return{lines:t,height:24+(t.length+1)*tO}}function AO(e){let t=new Map;for(let n of V(e,`note`)){let e=t.get(n.on),r=kO(n).height;t.set(n.on,e===void 0?r:e+nO+r)}return t}function jO(e){return e.columns.map(e=>e.title?yO(e.title,iO):[])}function MO(e){return(Math.max(1,...e.map(e=>e.length))-1)*aO}function NO(e,t){let n=V(e,`box`).filter(CO),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=>uO+(e!==void 0&&a.has(e)?ZD: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(VD,186):VD}})}function PO(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)*dO:0,s=a>0?e.left+e.right+a+20:0;return Math.max(e.minimumWidth,o,s)})}function FO(e){let t=new Map(e.columns.map((e,t)=>[e.id,t])),n=e.columns.map(()=>BD);for(let r of V(e,`box`).filter(CO)){let e=t.get(r.column)??0;n[e]=Math.max(n[e]??BD,wO(r))}return n}function IO(e,t){let n=[],r=B;for(let[i,a]of e.entries())n.push(r),r+=a+(t[i]??VD);return n}function LO(e,t){return(e.at(-1)??B)+(t.at(-1)??BD)}function RO(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 zO(e,t){return e===t?0:(e?ZD:0)+(t?44:0)}function BO(e,t){return e.lanes.some(e=>e.id===t.lane)?t.lane??``:``}function VO(e,t){let n=new Set(t.map(t=>BO(e,t)));return[``,...e.lanes.map(e=>e.id)].filter(e=>n.has(e))}function HO(e,t,n){let r=OO(e,t),i=wO(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:DO(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*KD+KD/2}}))}}function UO(e,t,n,r,i,a){let o=RO(e),s=V(e,`box`).filter(CO).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=VO(e,s),l=c.some(e=>e!==``),u=LO(t,n),d=[],f=r;for(let n of c){let r=e.lanes.find(e=>e.id===n),c=f+(l?mO:0),p=new Map,m=new Map;for(let r of s){if(BO(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)+zO(m.get(r.column)??null,l),d=HO(e,r,{x:t[s]??B,y:u}),f=(i.get(r.id)??0)-lO;p.set(r.column,u+Math.max(d.height,f)+HD),m.set(r.column,l),a.set(r.id,d)}let h=Math.max(c,...p.values())-HD;l&&d.push({id:n,label:r?r.label||r.id:``,hex:r?vO[r.color]:``,x:B,y:f,width:u-B,height:h-f}),f=h+hO+HD}return d}function WO(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 GO(e,t){let n=[...e.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0);return{x:e.size>0?n+VD:B,y:t}}function KO(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:wO(i),height:OO(e,i).height},f=u?WO(u,i.near,d):GO(n,t),p=HO(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 qO(e,t,n,r,i){let a=LO(n,r),o=Math.max(a,...t.map(e=>e.x+e.width))+VD,s=V(e,`panel`).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id)),c=i;return s.map(e=>{let t=yO(e.title,YD),n=xO(e.lines),r=24+t.length*WD+n.length*GD,i={kind:`panel`,id:e.id,x:Math.round(o),y:c,width:BD,height:r,titleLines:t,bodyLines:n};return c+=r+HD,i})}function JO(e,t,n,r,i){let a=new Map,o=[],s=UO(e,t,n,r,i,a);for(let t of V(e,`box`))t.at&&a.set(t.id,HO(e,t,t.at));KO(e,r,a,o);for(let t of V(e,`box`))a.has(t.id)||a.set(t.id,HO(e,t,GO(a,r)));return{boxesById:a,bands:s,warnings:o}}function YO(e,t){return V(e,`frame`).flatMap(e=>{let n=dE(e.contains.flatMap(e=>t.get(e)??[]));return n?[{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,x:n.x-ZD,y:n.y-ZD-QD,width:n.width+36,height:n.height+36+QD}]:[]})}function XO(e){return e.resolvedBy?`resolved by ${e.resolvedBy}`:e.author?`from ${e.author}`:``}function ZO(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}=kO(e),o=n.get(e.on)??r.y-lO;return n.set(e.on,o+a+nO),[{kind:`note`,id:e.id,x:r.x+r.width-cO,y:o,width:$D,height:a,lines:i,byline:XO(e),isResolved:e.resolvedBy!==null}]})}function QO(e,t,n,r){let i=dE([...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 $O(e,t){return e.slice(0,-1).map((n,r)=>{let i=n+(t[r]??BD);return{left:i,right:e[r+1]??i}})}function ek(e,t,n){let r=e.segments.filter(e=>e.from.x===e.to.x).map(e=>e.from.x);return $O(t,n).map(e=>new Set(r.filter(t=>t>e.left&&t<e.right)).size)}function tk(e,t,n){return $O(t,n).map(t=>e.wires.reduce((e,n)=>n.label&&n.labelAt.x>t.left&&n.labelAt.x<t.right?Math.max(e,_D(n.label)):e,0))}function nk(e,t,n,r){let i=[...e.values()],a=[...i,...t],o=hE(a).flatMap(([e,t])=>{let n=a[e],r=a[t];return n&&r&&xE(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:QD};return!s.get(e.id)?.has(t.id)&&xE(t,n)?[`box ${t.id} covers the title of frame ${e.id}`]:[]}));return[...o,...c]}function rk(e,t){let n=FO(e),r=IO(n,t.gapWidths),{boxesById:i,bands:a,warnings:o}=JO(e,r,n,t.boxesTop,t.stackHeightByBoxId),s=YO(e,i),c=ZO(e,i),l=qO(e,[...i.values(),...c],r,n,t.boxesTop),u=RD({wires:V(e,`wire`),boxesById:i,panels:l,softObstacles:[...c,...s.map(e=>({x:e.x,y:e.y,width:e.width,height:QD}))],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,...nk(i,l,s,e)],tracksByGap:ek(u,r,n),labelWidthByGap:tk(u,r,n)}}function ik(e,t){return Array.from({length:Math.max(e.length,t.length)},(n,r)=>Math.max(e[r]??0,t[r]??0))}function ak(e,t){let n=[],r=[];for(let i=1;;i+=1){let a=rk(e,{gapWidths:PO(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>=fO||!o&&!s)return a;n=ik(n,a.tracksByGap),r=ik(r,a.labelWidthByGap)}}function ok(e){let t=yO(e.title,YD),n=xO(e.lines),r=+!!e.linkedBoardId;return{titleLines:t,bodyLines:n,height:42+t.length*WD+(n.length+r)*GD}}function sk(e){let t=new Map,n=new Map;for(let r of LT(e)){let i=e.elements[r.unitId];if(i?.kind!==`unit`)continue;let a=ok(i),o=n.get(r.level)??70;n.set(r.level,o+a.height+HD),t.set(i.id,{kind:`unit`,id:i.id,x:B+(r.level-1)*310,y:o,width:BD,height:a.height,label:r.label,status:i.status,titleLines:a.titleLines,bodyLines:a.bodyLines,linkedBoardId:i.linkedBoardId})}return t}function ck(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(VD/2);return wE(SE([n,{x:i,y:n.y},{x:i,y:r.y},r]))}function lk(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?[ck(r,n)]:[]}):[]})}function uk(e){return e.size===0?B:Math.max(...[...e.values()].map(e=>e.y+e.height))+pO}function dk(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 fk={plain:null,fail:`failure path`,join:`joins`,lane:null};function pk(e,t,n){return`${e}|${t}|${n}`}function mk(e,t,n){let r=[fk[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var hk={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function gk(e){let t=new Set(V(e,`box`).map(e=>e.change));return Te.flatMap(e=>e===`none`||!t.has(e)?[]:[{label:hk[e],swatch:{kind:`change`,change:e}}])}function _k(e){return e.size===0?[]:He.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}}))}function vk(e,t){let n=e.lanes.map(e=>({label:e.label||e.id,swatch:{kind:`lane`,hex:vO[e.color]}})),r=new Map(e.legend.map(e=>[pk(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=pk(e.tone,t,e.back),a=r.get(n)??mk(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(pk(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,...gk(e),..._k(t)]}function yk(e){let t=sk(e),n=uk(t),r=n-B,i=dk(e,r),a=AO(i),o=jO(i),s=MO(o),c=n+sO+s,l=n+zD+s,u=ak(i,{reserves:NO(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=QO(p,u.routing.extent,LO(d,f),l),h=m.y+m.height,g=vk(i,t).map((e,t)=>({...e,x:B,y:h+t*rO})),_=h+g.length*rO+(g.length>0?12:0),v=i.caption?{text:i.caption,x:B,y:_}:null,y=g.length*rO+(v?30:0)+(g.length>0?12:0);return{columns:i.columns.map((e,t)=>({id:e.id,titleLines:o[t]??[],titleBaselineY:n+oO,ruleY:c,x:d[t]??B,width:f[t]??BD})),bands:u.bands,elements:p,legend:g,caption:v,pinnedOffsetY:r,plan:t.size>0?{titleAt:{x:B,y:56},arrowPaths:lk(i,t)}:null,bounds:{...m,height:m.height+y},warnings:TE([...u.placementWarnings,...u.routing.warnings])}}function bk(e){return JSON.stringify(e)}var xk=Object.freeze({box:Nt,frame:ce,wire:_t,note:We,unit:Ge,panel:ye});Object.freeze({id:`operator`,name:`operator`});function Sk(e,t,n){if(n[0]===`put`)return n[1].id===t?n[1]:null;if(n[0]===`remove`||!e)return null;let r=xk[e.kind].safeParse({...e,...n[1]});return r.success&&r.data.id===t?r.data:null}function Ck(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=Sk(t,e,n);if(!r)return null;n[0]===`put`&&delete i[e],i[e]=r}return Object.keys(i).length>we.elements?null:{...e,...t.fields,elements:i,version:n,updatedAt:r}}var wk=new Map,Tk=new Map,Ek=[],Dk=[],Ok=[],kk=new Map;function Ak(){for(let e of[...Ek])e()}function jk(e){for(let t of Dk)t(e)}function Mk(e){return e.type===`whiteboard-result`}async function Nk(e,t){try{let n=await a(e,t,{timeoutMs:Un});return Mk(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:Hn(e,Un)}}}function Pk(e){let t=Tk.get(e);if(t)return t;let n=Nk(`whiteboard-get`,{boardId:e}).then(t=>{Tk.delete(e),t.ok&&t.reply.board&&(wk.set(e,t.reply.board),jk(e))});return Tk.set(e,n),n}function Fk(){return Ok}function Ik(e){return wk.get(e)??null}function Lk(e){return wk.has(e)?Promise.resolve():Pk(e)}function Rk(e){return Ek.push(e),()=>{let t=Ek.indexOf(e);t>=0&&Ek.splice(t,1)}}function zk(e){Dk.push(e)}function Bk(){let e=new Map;for(let t of Ok)for(let n of t.connectedSessionIds){let r=e.get(n);r?r.push(t):e.set(n,[t])}kk=e}function Vk(e){Ok=[...e.boards].sort((e,t)=>t.updatedAt-e.updatedAt),Bk();let t=new Map(Ok.map(e=>[e.id,e.version]));for(let[e,n]of[...wk]){let r=t.get(e);r!==n.version&&(wk.delete(e),r===void 0?jk(e):Pk(e))}Ak()}function Hk(e){let t=wk.get(e.boardId);if(!t||t.version>=e.toVersion)return;if(t.version!==e.fromVersion){wk.delete(e.boardId),Pk(e.boardId);return}let n=Ck(t,e.diff,e.toVersion,e.updatedAt);n?(wk.set(e.boardId,n),jk(e.boardId)):(wk.delete(e.boardId),Pk(e.boardId))}function Uk(e){wk.delete(e.boardId),Ok=Ok.filter(t=>t.id!==e.boardId),Bk(),jk(e.boardId),Ak()}async function Wk(e){let t=await Nk(`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 Gk(e,t){let n=await Nk(`whiteboard-op`,{boardId:e,ops:t});return n.ok?{ok:!0,diff:n.reply.patch?.diff??null}:n}async function Kk(e){let t={"x-glimmervoid-upload-name":encodeURIComponent(e.name)};e.type&&(t[`content-type`]=e.type);let n=await fetch(ve,{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=Ie.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 qk(e){let t=await Nk(`whiteboard-delete`,{boardId:e});return t.ok?{ok:!0}:t}async function Jk(e,t){let n=await Nk(`whiteboard-connect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function Yk(e,t){let n=await Nk(`whiteboard-disconnect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function Xk(e,t){let n=await Nk(`whiteboard-nudge`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function Zk(e){let t=await Nk(`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 Qk=null;function $k(e){Qk=e}function eA(e,t){Qk?.(e,t)}function tA(e){return kk.get(e)??[]}var nA=null;function rA(e,t){nA={boardId:e,sessionId:t}}function iA(){let e=nA;return nA=null,e}var aA=()=>{};function oA(e){aA=e}function sA(e,t){rA(e,t),aA()}function cA(e,t){let n=e.queuedBySessionId[t]??0;return n===0?``:`${n} queued`}function lA(e,t,n){let r=cA(e,t),i=r?`wait`:`muted`;return{key:`board:${e.id}`,text:n,detailText:e.title,stateText:r,look:{icon:`board`,tone:i},tier:$t(i),className:`session-pr-chip session-board-chip`,ariaLabel:`Open board ${e.title}`,onActivate:()=>sA(e.id,t)}}function uA(e,t){let n=cA(e,t);return lA(e,t,n?`${e.title}, ${n}`:e.title)}function dA(e){return tA(e).map(t=>lA(t,e,t.title))}function fA(e,t,n){let r=uA(e,t),i=Ze(`session-pr-chip-unlink`);i.append(C(Ct)),i.setAttribute(`aria-label`,`Disconnect board ${e.title}`),i.addEventListener(`click`,r=>{r.stopPropagation(),r.preventDefault(),Jt({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:()=>{Yk(e.id,t).then(e=>n(e.ok?null:e.error))}})});let a=D(`span`,`session-pr-chip-item`);return a.append(dn(r,r),i),a}function pA(e){let{dialog:t,close:n,actions:r,btnCancel:i}=Xt({title:`Connect board`}),a=D(`div`,`session-pr-chips dialog-linked-prs`),o=D(`p`,`dialog-message`,`A connected session is told what others changed on the board with its next whiteboard get or prompt.`),s=D(`select`,`dialog-input`);s.setAttribute(`aria-label`,`Board to connect`);let c=Rn(`action-status`),l=w({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=tA(e);yn(a,t.map(t=>uA(t,e)),n=>{let r=t.find(e=>`board:${e.id}`===n.key);return r?fA(r,e,u):dn(n,n)});let n=Fk().filter(t=>!t.connectedSessionIds.includes(e));s.replaceChildren(...n.map(e=>{let t=D(`option`,null,e.title);return t.value=e.id,t})),n.length===0&&s.append(D(`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,Jk(t,e).then(e=>{e.ok?n():(c.show(`error`,e.error),d())}))}),i.addEventListener(`click`,n);let f=Rk(()=>{t.isConnected?d():f()});d()}Rk(mn);function mA(){return M.snapshot().borrowedCardId}var hA=null;function gA(e,t,n,{className:r,onRelease:i}={}){if(!e?.card||!n)return;let a=mA();a&&a!==t&&_A();let o=e.card;o._cardHostClass&&o._cardHostClass!==r&&o.classList.remove(o._cardHostClass),o._cardHostClass=r||``,r&&o.classList.add(r),Gt(o,n),hA=i??null,M.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function _A(){let e=mA(),t=hA;if(hA=null,t?.(),M.dispatch(`borrowCard`,null),!e)return null;let n=k.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,Rt(r,Mn)),e}var vA=null,yA=null,bA={},xA=null,SA=null,CA=null,wA=new Map,TA=new Map;function EA(){return yA??=N(()=>import(`./phone-shell-BGIx4-6z.js`).then(e=>{e.mountPhoneShell(bA),CA&&e.orderPhonePanels(CA);for(let[t,n]of wA)e.setPhoneScreenAvailable(t,n);for(let[t,n]of TA)e.setPhoneScreenAttention(t,n);return vA=e,e},e=>(yA=null,u(`phone-shell`,`phone shell failed to load: ${d(e)}`),null)),__vite__mapDeps([26,13,5,3,27,12,14,20,15,28,29,23,30,4,6,7,21,31,24,32])),yA}function DA(e){bA=e}async function OA(e){let t={options:e};xA=t;let n=await EA();if(xA!==t)return!1;if(!n)return xA=null,SA=null,!1;xA=null,n.activatePhoneShell(t.options);let r=SA;return SA=null,r?.(n),!0}function kA(){xA=null,SA=null,vA?.deactivatePhoneShell()}function AA(){return xA!==null||(vA?.isPhoneShellActive()??!1)}function jA(){return xA?xA.options?.sessionId??null:vA?.getPhoneSessionId()??null}function MA(e){CA=e,vA?.orderPhonePanels(e)}function NA(e,t){wA.set(e,t),vA?.setPhoneScreenAvailable(e,t)}function PA(e,t){TA.set(e,t),vA?.setPhoneScreenAttention(e,t)}function FA(){vA?.refreshPhoneBoard()}function IA(){vA?.syncPhoneHistory()}function LA(e){return xA?(SA=t=>{e(t)},!0):vA?e(vA):!1}function RA(e){return LA(t=>t.showPhonePlan(e))}function zA(e){return LA(t=>t.showPhoneSession(e))}function BA(e){return LA(t=>t.showPhoneScreen(e))}function VA(){let e=jA();e&&A(e)?._isActiveViewer?.()===!0&&Dx(e)}function HA(){Yu(A(mA())),VA()}function UA(){window.addEventListener(`focus`,HA),window.addEventListener(`blur`,HA),document.addEventListener(`visibilitychange`,HA),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&ao()}),window.addEventListener(`pageshow`,e=>{e.persisted&&ao()})}function WA(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function GA(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function KA({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=WA(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=GA(e.key,a);if(n===null)return;e.preventDefault();let r=u(t.getBoundingClientRect().width+l*n);r!==null&&s(r)})}var qA={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.`}},JA=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:It[e],meaning:t}),YA=Object.freeze([JA(T.DORMANT,`Not started yet.`),JA(T.STARTING,`Setting up the worktree and booting the agent.`),JA(T.RUNNING,`The agent is mid-turn.`),JA(T.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),JA(T.WAITING,`Waiting on a permission prompt or your answer.`),JA(T.COMPLETE,`Finished a turn you have not looked at yet.`),JA(T.IDLE,`Ready for the next prompt.`),JA(T.DONE,`The agent process ended.`),JA(T.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 XA(e,t){let n=D(`section`,`status-legend`),r=D(`dl`,`status-legend-rows`);return r.append(...t),n.append(D(`h2`,`status-legend-title`,e),r),n}function ZA(e,t){let n=D(`div`,`status-legend-row`);return n.append(e,D(`dd`,`status-legend-meaning`,t)),n}function QA(){return XA(`Status colors`,YA.map(e=>{let t=D(`dt`,`status-legend-badge`),n=D(`span`,`status-legend-glyph`),r=D(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=ZA(t,e.meaning);return nn(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function $A(){return XA(`Pull request icons`,Object.keys(qA).map(e=>{let t=qA[e],n=D(`dt`,`status-legend-badge`);return n.append(Ci(e),D(`span`,`status-legend-name`,t.label)),ZA(n,t.meaning)}))}var ej=null,tj=null,nj=!1,rj=null;function ij(){return tj??=N(()=>import(`./first-run-checklist-2LJwKdE8.js`).then(e=>(ej=e,e),e=>(tj=null,u(`first-run`,`first-run checklist failed to load: ${d(e)}`),null)),__vite__mapDeps([33,12,13,5,3,15,29,14,20,23,30,4,6,7,21,34,35])),tj}function aj(e,t){rj={host:e,isShown:t},ej?ej.showFirstRunChecklist(e,t):t&&nj&&ij().then(e=>{e&&rj&&e.showFirstRunChecklist(rj.host,rj.isShown)})}function oj(){ej?.refreshFirstRunChecklist()}function sj(){nj=!0,rj&&aj(rj.host,rj.isShown)}var cj=`(no path)`;function lj(e){if(!e)return cj;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||cj}function uj(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):cj),s=i.get(o);s||(s=r?{...r,projectPath:null,rows:[]}:{key:o,label:o===cj?cj:lj(o),title:o,projectPath:o===cj?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 dj(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 fj(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 pj=`removed`,mj=new Set([T.COMPLETE,T.DONE,T.FAILED,pj]);function hj(e){return mj.has(e)}function gj(e,t){let n=e.filter(e=>hj(t(e))).length;return{settled:n,total:e.length,isAllSettled:e.length>0&&n===e.length}}var _j=[],vj=new Set;function yj(e){vj.add(e)}function bj(){return _j}function xj(e){_j=e.races;for(let e of vj)e()}function Sj(e){let t=Cj(e.id);if(!t)return null;let n=gj(Object.values(t.sessionIdByContestant),e=>k.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 Cj(e){return _j.find(t=>Object.values(t.sessionIdByContestant).includes(e))??null}var wj=()=>{};function Tj(e){wj=e.openTerminal}function Ej(e){wj(e)}function Dj({onAdd:e}){let t=D(`div`,`session-group-header`),n=D(`span`,`session-group-label`),r=D(`span`,`session-group-count`),i=D(`span`,`session-group-rule`);i.setAttribute(`aria-hidden`,`true`);let a=w({variant:`icon`,size:`small`,label:`Add session to this project`,icon:C($e),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 Oj(e,t){let{header:n,label:r,count:i,addButton:a}=e;gi(n,`path`,t.projectPath??``),gi(n,`label`,t.label),Xr(r,t.label),Xr(i,String(t.rows.length)),ei(a,t.projectPath===null)}var kj={waitingCount:0,finishedCount:0,failedCount:0},Aj={failed:qt[T.FAILED],waiting:qt[T.WAITING],finished:qt[T.COMPLETE]},jj={failed:`failed`,waiting:`needs you`,finished:`finished`},Mj=[`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`],Nj=2500,Pj=`cubic-bezier(0.16, 1, 0.3, 1)`,Fj=`cubic-bezier(0.5, 0, 0.2, 1)`,Ij=260,Lj=200,Rj=200,zj=300,Bj=28,Vj=360,Hj=420,Uj=200,Wj=3,Gj=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),Kj=new WeakMap;function qj(e){let t=Kj.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function Jj(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function Yj(){return Gj?.matches??!1}function Xj(e){return e.map(e=>({easing:Pj,...e}))}function Zj(e,t){let n=D(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${Nn.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${Nn.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${Nn.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${Nn.overflowSlot}px`);let r=D(`span`,`attention-banner-chips`),i=D(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=D(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=D(`span`,`attention-banner-status`);o.append(r,D(`span`,`attention-banner-count`),a);let s=Ze(`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),Kj.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(()=>$j(n)).observe(r),Qj(n,kj,[]),n}function Qj(e,t,n){let r=qj(e);r.tiles=n,Xr(Vt(e,`.attention-banner-count`),Dn(t));let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&hM(e,r),$j(e)}function $j(e){let t=qj(e),n=Vt(e,`.attention-banner-chips`),r=Vt(n,`.attention-tile-overflow`),i=Jj(e),a=t.tiles.slice(0,On(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():rM(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??tM(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),nM(s,i,a===0),(s.parentElement!==n||eM(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;ei(r,p===0),Xr(r,`+${p}`),Jr(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)&&sM(e,null),i){for(let e of d)iM(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?oM(r,a):a!==0&&aM(r,a,n)})}}function eM(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function tM(e,t){let n=D(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=D(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>sM(e,t)),n.addEventListener(`pointerleave`,()=>sM(e,null)),n}function nM(e,{kind:t,name:n},r){e.dataset.kind=t,e.toggleAttribute(`data-head`,r);let i=`${n}, ${jj[t]}`;e.setAttribute(`aria-label`,i),Wn(Vt(e,`.attention-tile-icon`),Aj[t])}function rM(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=Yj()?[{opacity:1},{opacity:0}]:Xj([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:Rj,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function iM(e){let t=Yj()?[{opacity:0},{opacity:1}]:Xj([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:Lj})}function aM(e,t,n){Yj()||e.animate(Xj([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:zj,delay:n*Bj,fill:`backwards`})}function oM(e,t){Yj()?e.animate([{opacity:.35},{opacity:1}],{duration:Vj,easing:Pj}):e.animate(Xj([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:Vj})}function sM(e,t){let n=qj(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 cM(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function lM(e,t,n){let r=qj(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!Jj(e)){n();return}sM(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=cM(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(uM(o,s),dM(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function uM(e,t){return!t||Yj()?[{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 dM(e){return!e||Yj()?{duration:Uj,fill:`forwards`}:{duration:Hj,easing:Fj,fill:`forwards`}}function fM(e){let t=qj(e);e.hasAttribute(`data-empty`)&&mM(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!Jj(e))return;let n={duration:Ij};if(t.pressAnimations.push(e.animate(Xj([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!Yj()){t.pressAnimations.push(e.animate(Xj([{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(Xj([{transform:`none`},{transform:`translateY(${Wj}px)`,offset:.3},{transform:`none`}]),n),r.animate(Xj([{transform:`none`},{transform:`translateY(-${Wj}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function pM(e){let t=Mj.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??Mj[0]}function mM(e,t){let n=pM(t.lastAllClearLine);t.lastAllClearLine=n,Vt(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>hM(e,t),Nj)}function hM(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var gM={terminal:`Terminal`,board:`Board`},_M=[`terminal`,`board`],vM=.05,yM=`application/x-glimmervoid-pane-tab`;function bM(){let e=Ir(),t=new Set([`terminal`]),n=vr(e,t),r=null,i=D(`div`,`pane-layout`),a=D(`div`,`pane-trail`),o=D(`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=D(`div`,`pane-body`);return t.id=`focus-pane-${e}`,t.dataset.pane=e,t.setAttribute(`role`,`tabpanel`),t}function p(e){let t=D(`div`,`pane-title`);return t.dataset.tab=e,t}function m(t){let n=Ze(`pane-tab`);return n.append(D(`span`,`sr-only`,gM[t])),n.draggable=!0,n.dataset.tab=t,n.setAttribute(`role`,`tab`),n.setAttribute(`aria-controls`,`focus-pane-${t}`),n.addEventListener(`click`,()=>v(Fr(e,t))),n.addEventListener(`dragstart`,e=>{r=t,e.dataTransfer?.setData(yM,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`),i.dataset.dragging=``}),n.addEventListener(`dragend`,_),n}function h(t){let i=D(`section`,`pane-group`),a=D(`div`,`pane-strip pane-header`),o=D(`div`,`pane-tabs`);o.setAttribute(`role`,`tablist`),a.append(o);let s=D(`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(hr(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 wr(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,Kr(e),x())}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 b(e,t,n){let r=l[t];r.hidden=!n,e.tabList.nextElementSibling!==r&&e.tabList.after(r)}function x(){n=vr(e,t);for(let e of _M)l[e].hidden=!0,t.has(e)||(s[e].hidden=!0);let r=Lr(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),b(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 ne(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=jr(e,ne(t)),x())});let re=t=>{o.hasPointerCapture(t.pointerId)&&(o.releasePointerCapture(t.pointerId),delete o.dataset.dragging,Kr(e))};return o.addEventListener(`pointerup`,re),o.addEventListener(`pointercancel`,re),o.addEventListener(`keydown`,t=>{let n={ArrowLeft:-.05,ArrowUp:-.05,ArrowRight:vM,ArrowDown:vM}[t.key];n!==void 0&&e.kind===`split`&&(t.preventDefault(),v(jr(e,e.firstShare+n)))}),x(),{element:i,trailSlot:a,bodyOf:e=>s[e],titleSlotOf:e=>l[e],setStripHost:(e,t)=>{t&&u.set(e,t),t||u.delete(e),x()},showTabs:e=>{t=e,x()},showTab:t=>v(Fr(e,t))}}var xM=[],SM=new Set,CM=new WeakSet,wM=null,TM=null;function EM(e){xM.some(t=>t.id===e.id)||(xM.push(e),OM(e.id,null))}function DM(){return xM}function OM(e,t){for(let n of SM)n(e,t)}function kM(e){return SM.add(e),()=>SM.delete(e)}function AM(e){e!==wM&&(PM(),wM=e)}function jM(e){wM===e&&(PM(),wM=null)}function MM(e,t){return TM?.page.id===e&&TM.sessionId===t}function NM(e,t,n=null){let r=xM.find(t=>t.id===e);if(!r||!wM||wM.sessionId()!==t||!r.isAvailableFor(t)||MM(e,t)&&n===null)return;PM();let i=wM,a=i.elementFor(r);LM(a),TM={page:r,sessionId:t},r.mount(a,t,{placement:i.placement,target:n}),i.didShow(r),OM(r.id,t)}function PM(){if(!TM)return;let{page:e,sessionId:t}=TM;TM=null,e.unmount(),wM?.didHide(e),OM(e.id,t)}function FM(){return TM?.page.canStepBack()??!1}function IM(){return TM?TM.page.canStepBack()?(TM.page.stepBack(),!0):(PM(),!0):!1}function LM(e){CM.has(e)||(CM.add(e),e.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Bt(e)||IM()&&e.preventDefault()}))}function RM({style:e}){let t=D(`div`,`session-page-bar session-page-bar-${e}`),n=new Map,r=null;function i(n){let i=e===`header`,a=w({variant:`quiet`,size:i?`small`:`default`,label:n.label,icon:C(n.iconPath),action:`${i?`open`:`show`}-${n.id}`});a.addEventListener(`click`,()=>{r&&NM(n.id,r)});let o=D(`span`,`session-page-dot`);o.setAttribute(`aria-hidden`,`true`);let s=D(`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 xM)a(e)}return kM((e,t)=>{if(t!==null&&t!==r)return;let n=xM.find(t=>t.id===e);n&&a(n)}),o(),{element:t,showSession(e){r=e,o()}}}var zM=5,BM={high:`High`,medium:`Medium`,low:`Low`};function VM(e,t){let n=Ze(`review-look-line`,e.path);return n.append(D(`span`,`review-look-detail`,e.detail)),n.addEventListener(`click`,()=>t(e.openPath)),n}function HM(e,t){let n=D(`div`,`review-look-group`);n.dataset.kind=e.kind;let r=D(`p`,`review-look-text`,e.heading);if(e.conflictRisk){let t=D(`span`,`review-look-risk`,`Conflict risk: ${BM[e.conflictRisk]}`);t.dataset.risk=e.conflictRisk,r.append(` `,t)}n.append(r);for(let r of e.lines)n.append(VM(r,t));return n}function UM(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=D(`section`,`review-look`);if(i.append(D(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=D(`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,zM);if(a.length>0){let e=D(`div`,`review-look-list`);for(let t of a)e.append(HM(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=D(`div`,`review-look-more`),c=w({variant:`quiet`,size:`small`,label:`Show all`,action:`show-all-worth-a-look`,onClick:n});return s.append(D(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function WM(e){return(e??[]).map(e=>D(`span`,`review-file-hint`,e.text))}var GM=`changes`,KM={add:`+`,del:`-`,meta:`\\`},H=null,qM=null,U=null,W=null,JM=null,YM=!1;function XM(){let e=D(`section`,`review-reader`);e.setAttribute(`aria-label`,`Changes`),e.tabIndex=-1,e.hidden=!0;let t=D(`div`,`review-reader-bar`),n=D(`p`,`review-reader-status`);n.setAttribute(`role`,`status`);let r=D(`p`,`review-reader-notice`);r.setAttribute(`role`,`status`);let i=D(`div`,`review-reader-actions`),a=w({variant:`primary`,label:`Merge`,action:`merge-session`,onClick:()=>{U&&I_(U)}}),o=w({variant:`danger`,label:`Discard`,action:`discard-session`,onClick:()=>{U&&L_(U)}}),s=w({variant:`secondary`,label:`Close`,action:`close-reader`,onClick:PM});i.append(a,o,s),t.append(n,r,i);let c=D(`div`,`review-reader-body`),l=D(`div`,`review-reader-files`),u=D(`div`,`review-reader-diff`);return c.append(l,u),e.append(t,c),e.addEventListener(`keydown`,QM),h_(e=>{e===U&&nN()}),Qr(()=>{W=null,YM=!1,nN(),$M()}),B_(e),{root:e,status:n,notice:r,mergeButton:a,discardButton:o,closeButton:s,fileColumn:l,diff:u}}function ZM(){return H??=XM(),H}function QM(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Bt(e))return;let t=e.key===`j`?1:e.key===`k`?-1:0;if(t===0||!U)return;e.preventDefault();let n=Yg(b_(U)?.files??[],W,t);n&&eN(n)}function $M(){U&&OM(GM,U)}function eN(e){W=e,nN(),H?.fileColumn.querySelector(`.review-reader-file[aria-current="true"]`)?.scrollIntoView({block:`nearest`}),$M()}function tN(e){let t=Jg(e,JM);t&&(W=t.path,JM=null),!Jg(e,W)&&(W=qM===`overlay`?e[0]?.path??null:null)}function nN(){if(!H||qM===null)return;U=Yr();let e=U?b_(U):null;if(H.closeButton.hidden=qM!==`overlay`,!e){rN(H);return}let t=W!==null;tN(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=qM===`screen`&&W!==null?`diff`:`list`,iN(H.fileColumn,e),cN(H.diff,Jg(e.files,W)),t!==(W!==null)&&$M()}function rN(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 iN(e,t){let n=e.scrollTop;if(e.replaceChildren(),t.diffError){e.append(D(`p`,`review-diff-error`,t.diffError));return}if(t.isEmpty){e.append(D(`p`,`review-empty-title`,t.sentence));return}t.totals.files>0&&e.append(aN(t.totals));let r=D(`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?Fg(i,e.path):null;n&&n!==a&&r.append(D(`div`,`review-repo-label`,n)),a=n,r.append(oN(e,t))}e.append(r);let o=t.changeMapView?UM(t.changeMapView,{isShowingAll:YM,onShowAll:lN,onOpenFile:uN}):null;o&&e.append(o),e.scrollTop=n}function aN(e){let t=D(`p`,`review-reader-totals`);return t.append(D(`span`,`review-stat-files`,`${e.files} file${e.files===1?``:`s`}`),D(`span`,`review-add`,`+${e.added}`),D(`span`,`review-del`,`-${e.removed}`)),t}function oN(e,t){let n=Ze(`review-reader-file`);n.dataset.path=e.path,n.setAttribute(`role`,`listitem`),n.setAttribute(`aria-current`,String(e.path===W));let r=D(`span`,`review-file-name`);r.append(D(`span`,`review-file-path`,e.path));let i=WM(t.changeMapView?.hintsByOpenPath.get(e.path));if(i.length>0){let e=D(`span`,`review-file-hints`);e.append(...i),r.append(e)}return n.append(r,sN(e)),n.addEventListener(`click`,()=>eN(e.path)),n}function sN(e){let t=D(`span`,`review-file-counts`);return e.binary?(t.append(D(`span`,`review-bin`,`bin`)),t):(t.append(D(`span`,`review-add`,`+${e.added}`),D(`span`,`review-del`,`-${e.removed}`)),t)}function cN(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=D(`div`,`review-reader-diff-head`);if(r.append(D(`span`,`review-file-path`,t.path),sN(t)),e.append(r),t.binary){e.append(D(`div`,`review-file-binary`,`Binary file not shown`));return}let i=D(`div`,`review-file-body`);for(let e of t.hunks){i.append(D(`div`,`review-hunk-head`,e.header));for(let t of e.lines){let e=D(`div`,`review-line review-line-${t.type}`);e.append(D(`span`,`review-line-gutter`,KM[t.type]??` `),D(`span`,`review-line-text`,t.text)),i.append(e)}}e.append(i),e.scrollTop=n}function lN(){YM=!0,nN()}function uN(e){let t=Jg(U?b_(U)?.files??[]:[],e);t&&eN(t.path)}function dN(e,t){let{root:n}=ZM();n.parentElement!==e&&e.append(n),qM=t,n.dataset.placement=t,n.hidden=!1}function fN(){H&&(H.root.hidden=!0,H.root.remove(),qM=null)}function pN(){W!==null&&(W=null,nN(),$M())}function mN(e,t){t===`header`&&(B_(e),new MutationObserver(z_).observe(e,{attributes:!0,attributeFilter:[`data-slot-held`]}))}h_(e=>OM(GM,e));var hN={id:GM,label:`Changes`,iconPath:mt,isAvailableFor:e=>b_(e)!==null,hasUnreadFor:()=>!1,mount(e,t,{placement:n,target:r}){dN(e,n),JM=r,nN(),n===`overlay`&&ZM().root.focus({preventScroll:!0})},unmount:fN,canStepBack:()=>qM===`screen`&&W!==null,stepBack:pN,attachButton:mN};function gN(){EM(hN)}var _N=new Set([`terminal`]),vN=new Set([`terminal`,`board`]),yN=new Set([`board`]),bN=e=>e.ui.path,xN=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),SN=null,G=null,CN=null,wN=null,K=null,TN=null,EN=null,DN=null,ON=null,kN=null,AN=null,q=null,jN=null,MN=new Map,NN=null,PN=null,FN=null,J=!1,IN=!1,LN=null,RN=new Map,Y=new Map,zN=new Map,BN=new Map,X=null,VN=``,HN=[],UN=new Set;function WN(){return dj(KN(nP()),UN)}function GN(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 KN(e){return uj(e,bN,Sj)}function qN(e){let t=BN.get(e.key),n=zN.get(e.key);return(!t||!n)&&(t=Dj({onAdd:ii}),n=D(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),BN.set(e.key,t),zN.set(e.key,n)),Oj(t,e),Jr(n,`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function JN(){return J}function Z(){return M.snapshot().focusedSessionId}function YN(){return J&&q!==null}function XN({rail:e,center:t,resizer:n}){if(SN=e,CN=t,!SN||!CN)return;let r=SN,i=CN;$N(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,Sr(Rl)),G=Zj({onJump:xP,rowFor:e=>Y.get(e)},Wl());let a=D(`details`,`rail-section rail-status-key`);a.append(D(`summary`,`rail-section-summary`,`Status key`),QA()),fP(a,rr(),fr),r.append(G,a),NN=D(`div`,`focus-empty`),NN.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,PN=NN.querySelector(`.focus-empty-title`),FN=NN.querySelector(`.focus-empty-desc`),K=bM(),K.element.addEventListener(`click`,DP),wN=K.bodyOf(`terminal`),jN=pP(),gN(),TN=RM({style:`header`}),K.trailSlot.append(TN.element),i.append(NN,K.element),yj(()=>{J&&dP()}),Rk(()=>{if(!J)return;let e=q!==null;dP(),e&&q===null&&JP()}),r.addEventListener(`keydown`,eP)}var ZN={minPx:180,maxPx:480},QN=16;function $N(e){e&&SN&&KA({resizer:e,column:SN,widthHost:SN,widthProperty:`--rail-width`,bounds:ZN,keyStepPx:QN,getStoredWidth:Dr,setStoredWidth:dr})}function eP(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(),ai(n);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=tP(),n=t.find(t=>t===e.target)??(X?Y.get(X):null),r=n?t.indexOf(n):-1,i=wn(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&&GN(a.dataset.id),a.focus())}function tP(){return SN?[...SN.querySelectorAll(`button.session-row[data-id], button.session-row[data-board-id]`)].filter(e=>!e.closest(`details:not([open])`)):[]}function nP(){return kn(di(rP))}function rP(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function iP(e){let{row:t,refs:n}=pn();t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,()=>aP(e)),t.addEventListener(`pointerenter`,()=>{G&&sM(G,e)}),t.addEventListener(`pointerleave`,()=>{G&&sM(G,null)});let{item:r,removeButton:i}=an(t,()=>ai(e),()=>vi(e));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,Object.assign(t,{_refs:n,_row:r})}function aP(e){let t=mi(e);t&&sP(t,e)}function oP(e){let t=mi(e);t&&sP(t,e)}function sP(e,t){LP(t),CP(e,t)}function cP(e,{id:t,ui:n,state:r,name:i},a){let o=RN.get(t)||`none`;e.classList.toggle(`focused`,t===Z()),un(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a});let s=t===X;Jr(e,`aria-selected`,String(s)),Jr(e,`tabindex`,s?`0`:`-1`)}function lP(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||``:Zn(r._refs?.glyph))}Gn(lP),Qn((e,t)=>{if(!J)return;let n=Y.get(e);n&&Xr(n._refs.elapsed,Xn(t))});var uP=new Map;function dP(e){if(!J)return;let t=SN;if(!t)return;let n=nP(),r=KN(n),i=new Set,a=An(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=iP(t),Y.set(t,r));let s=o.get(t)??null;(!e||a||e.has(t)||uP.get(t)!==s)&&cP(r,n,s),uP.set(t,s)}a||_i(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===VN;VN=l;for(let e of r.groups){let{header:n,list:r}=qN(e);u||t.append(n,r),s(e.rows,r)}jN&&(!u||jN.section.parentElement!==t)&&t.append(jN.section),jN&&hP(jN);for(let[e,t]of[...BN])c.has(e)||(t.header.remove(),zN.get(e)?.remove(),BN.delete(e),zN.delete(e));for(let[e,t]of Y)i.has(e)||(t._row.remove(),Y.delete(e),uP.delete(e),e===X&&(X=null));for(let e of[...RN.keys()])k.has(e)||RN.delete(e);let d=HN;HN=dj(r,UN);let f=Z();if(f&&!ni(f)){PM(),M.dispatch(`focusSession`,null),X=null;let e=vP(d,f);if(e){let t=!document.activeElement||document.activeElement===document.body;LP(e),t&&CP(k.get(e),e);return}}RP();let p=Z();if(p){let e=k.get(p);e&&e.card.parentElement!==wN&&TP(e,p)}TN?.showSession(q?null:p),MP(),bP(n,a)}function fP(e,t,n){e.open=t,e.addEventListener(`toggle`,()=>n(e.open))}function pP(){let e=D(`div`,`rail-section rail-boards`),t=D(`details`,`rail-boards-details`),n=D(`span`,`session-group-count`),r=D(`summary`,`rail-section-summary`);r.append(`Boards `,n);let i=D(`div`,`focus-rail-list focus-board-list`);i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,`Boards with no session`),t.append(r,i),fP(t,cr(),ar);let a=w({variant:`icon`,size:`small`,label:`New board`,icon:C($e),action:`new-board`,onClick:_P});return a.classList.add(`rail-section-action`),e.append(t,a),{section:e,count:n,list:i}}function mP(e){let{row:t,refs:n}=pn();t.dataset.boardId=e,t.addEventListener(`click`,()=>gP(e));let r=D(`div`,`session-row-item`);return r.append(t),Object.assign(t,{_refs:n,_row:r})}function hP(e){let t=Fk();q&&!t.some(e=>e.id===q)&&(q=null);let n=fj(t,e=>k.has(e)),r=new Set(n.map(e=>e.id));for(let[e,t]of MN)r.has(e)||(t._row.remove(),MN.delete(e));for(let e of n){let t=MN.get(e.id);t||(t=mP(e.id),MN.set(e.id,t)),gn(t,t._refs,e.title),t.classList.toggle(`focused`,e.id===q)}_i(e.list,n.flatMap(e=>MN.get(e.id)?._row??[])),Xr(e.count,String(n.length)),Jr(e.count,`aria-label`,`${n.length} ${n.length===1?`board`:`boards`} with no session`)}function gP(e){J&&(IP(),q=e,kN=null,GN(null),dP())}function _P(){OP().then(e=>e.createBoardFromDialog(gP),kP)}function vP(e,t){let n=e.filter(e=>e===t||ni(e));if(n.length<2)return HN.find(e=>ni(e))??null;let r=n.indexOf(t)===n.length-1;return wn(n,t,r?-1:1)}function yP(){return An(nP(),Z())}function bP(e,t){G&&Qj(G,Pn(e),t)}function xP(){if(!J)return;G&&fM(G);let e=yP()[0]?.id;e&&SP(e)}function SP(e){J&&(mi(e),Y.get(e)?.scrollIntoView({block:`nearest`}),G&&lM(G,e,()=>wP(e)),LP(e),CP(k.get(e),e))}function CP(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{J&&Z()===t&&e.term?.focus()}))}function wP(e){if(xN?.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=k.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function TP(e,t){if(!wN)return;let n=e.card.querySelector(`:scope > .session-card-header`);gA(e,t,wN,{className:`focus-centered`,onRelease:()=>{n?.classList.remove(`pane-header`),K?.setStripHost(`terminal`,null)}}),n?.classList.add(`pane-header`),n&&EP(n),Zu(e,t,!0)}function EP(e){let t=e.querySelector(`:scope > .session-name`);K?.setStripHost(`terminal`,{parent:e,before:t})}function DP(e){if(!(e.target instanceof Element)||!e.target.closest(`.pane-tab[data-tab="terminal"]`))return;let t=Z(),n=t?k.get(t):null;n&&n.face!==`terminal`&&n._showTerminalFace?.()}function OP(){return EN??=N(()=>import(`./boards-view-Dib7ZZVH.js`).then(e=>(DN=e,e)),__vite__mapDeps([36,13,5,3,14,20,15,12,31,24,37])),EN}function kP(e){EN=null,u(`focus`,`the board pane failed to load: ${d(e)}`)}function AP(e){K&&AN!==e&&(AN=e,K.showTabs(e))}function jP(e){AP(yN);let t=ON!==null||kN!==e;ON=null,kN=e,OP().then(n=>NP(n,null,t?e:null),kP)}function MP(e=null){if(q){jP(q);return}let t=Z(),n=t?tA(t):[],[r]=n;if(AP(r?vN:_N),!t||!r){ON=null,kN=null;return}let i=n.some(e=>e.id===kN),a=ON!==t||e!==null||!i;ON=t;let o=a?e??r.id:null;o&&(kN=o),OP().then(e=>NP(e,t,o),kP)}function NP(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 PP(){J&&(ON||q)&&DN?.reopenSelectedBoard()}function FP(){let e=iA();J&&e?.sessionId&&k.has(e.sessionId)&&(LP(e.sessionId),MP(e.boardId),K?.showTab(`board`))}function IP(){PM();let e=Z();e&&(mA()===e&&_A(),M.dispatch(`focusSession`,null))}function LP(e){J&&k.has(e)&&(Dx(e),fi(e),e!==Z()&&(IP(),q=null,M.dispatch(`focusSession`,e),X=e,dP()))}function RP(){if(!NN||!PN||!FN)return;let e=Z(),t=!!q||!!(e&&k.has(e)),n=k.size>0;ei(NN,t),K&&ei(K.element,!t),aj(NN,!n),ei(PN,!n),ei(FN,!n),!t&&n&&(Xr(PN,`No session selected`),Xr(FN,`Select a session from the rail on the left to focus it here.`))}function zP(e,t){RN.set(O(e),typeof t==`string`&&t?t:`none`),J&&dP()}var BP={placement:`overlay`,sessionId:()=>J&&CN&&!q?Z():null,elementFor:()=>{if(!CN)throw Error(`Focus view is not mounted`);return CN},didShow:()=>{},didHide:()=>{let e=Z();e&&CP(k.get(e),e)}};function VP(e=null){let t=Z();t&&NM(`changes`,t,e)}function HP(e){J&&k.has(e)&&LP(e)}function UP(e){return!J||!k.has(e)?!1:(LP(e),by(e))}function WP(e){if(!J)return;let t=WN()[e-1];t&&ni(t)&&aP(t)}function GP(e){if(!J)return;let t=WN().filter(e=>e===X||ni(e)),n=wn(t,X,e);n!=null&&ni(n)&&(oP(n),Y.get(n)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=Z();J&&e&&Dx(e)});function KP(){SN&&(J=!0,AM(BP),IP(),X=null,dP(),IN&&LN?SP(LN):IN&&yP().length>0?xP():(IN&&G&&fM(G),JP()))}function qP(e,t=null){IN=!0,LN=t;try{e()}finally{IN=!1,LN=null}}function JP(){if(!J||Z()||q)return;let e=li();e&&LP(e)}function YP(){J&&=(IP(),jM(BP),X=null,!1)}var XP=[],ZP=new Set;function QP(e){let t=rt.safeParse(e);if(t.success){XP=t.data;for(let e of ZP)e()}}function $P(e){return XP.find(t=>t.agent===e)??null}function eF(e){return ZP.add(e),()=>{ZP.delete(e)}}var tF=2e3,nF={},rF=null,iF=null,aF=ut,oF=null,sF=!1,cF=null,lF=[],uF=null,dF=()=>null,fF=()=>{},pF=!1,mF=new Set,hF=new Set;function gF(e){for(let t of hF)t(e)}function _F(e){hF.add(e)}function vF(){return nF}function yF(e){return nF={...nF,...e},nF}function bF(){return{status:rF,journal:iF,request:aF,lastAutoCheckAt:oF,isCheckInFlight:sF,checkSendFailure:cF}}function xF(e){let t=Fe(aF,e);t!==aF&&(aF=t,gF({kind:`update`,frame:`request`}))}function SF(){xF(v({type:`update-apply`})?`request-sent`:`request-unsent`)}function CF(){oF=Date.now();let e=v({type:`update-check`});sF=e,cF=e?null:De,gF({kind:`update`,frame:`request`})}function wF(e){fF=e}function TF(){fF()}function EF(e){lF=[...e]}function DF(){return lF}function OF(e=null,t=null,n=null){let r=uF!==null&&(uF.sectionId!==null||uF.isLink);e===null&&n===null&&r||(uF={sectionId:e,settingId:t,hashAtRequest:n??location.hash,isLink:n!==null},gF({kind:`activate`}))}function kF(){let e=uF;return uF=null,e}function AF(e){dF=e}function jF(){for(let e of mF)e()}function MF(e){mF.add(e)}function NF(){return yo()&&dF()===`section`}function PF(){NF()&&gF({kind:`return-to-list`})}function FF(e){e&&(nF=e,QP(nF.agentLogins),gF({kind:`broadcast`}))}function IF(){pF||(pF=!0,window.setTimeout(()=>{a(`get-settings`,{}).then(e=>{e.settings&&FF(e.settings)}).catch(()=>{pF=!1})},tF))}function LF(){gF({kind:`status`})}function RF(e){LF()}function zF(e){rF=e,sF=!1,cF=null,aF=Fe(aF,`status-frame`),gF({kind:`update`,frame:`status`})}function BF(e){iF=e,aF=Fe(aF,`progress-frame`),gF({kind:`update`,frame:`progress`})}function VF(e){if(e.scope!==`update`)return!1;let t=Ve(e.message),n=aF.requested;return aF=Fe(aF,`error-frame`,t),sF=!1,n||(cF=t),gF({kind:`update`,frame:`error`}),!0}var HF=200;function UF(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function WF(e){return/^#settings(?:[/?]|$)/.test(e)}function GF(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function KF(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,HF).join(``).trim()}}function qF(e,t,n){let r=D(`a`,`settings-link`,n);return r.href=UF(e,t),r}var JF={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},YF=[{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`}],XF=null,ZF=null,QF=null,$F=()=>!1,eI=new Set,tI=new Set,nI=Et({getAck:Mr,setAck:Nr,signature:()=>xt({posthog:XF}),isLooking:()=>$F()});function rI(e){for(let t of tI)t(e)}function iI(){ZF?.(nI.refresh())}function aI(){return{latest:XF,archivedLocally:eI,traceOpener:QF}}function oI(e){tI.add(e)}function sI(e){$F=e,iI()}function cI(e){eI.add(e)}function lI(){nI.acknowledge(),iI()}function uI(e){ZF=e,iI()}function dI(e){QF=e}function fI(e){XF=e,wt(XF,eI),rI({kind:`status`}),iI()}function pI(e){let t=qe(XF,e.projectId,e.issueId)?.inFlight===!0;gt(XF,e)&&rI({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function mI(e){let t=xe(XF,e);rI({kind:`investigation-finished`,frame:e,isPatched:t}),t&&iI()}var hI=null,gI=[],_I=()=>!1,vI=null,yI=kr(),bI=Pr(),xI=new Set(bI.split(`|`).filter(Boolean)),SI=new Set;function CI(e){for(let t of SI)t(e)}function wI(){return lm(gI).map(cm)}function TI(e){e!==yI&&(yI=e,sr(e))}function EI(e){e!==bI&&(bI=e,xI=new Set(e.split(`|`).filter(Boolean)),Tr(e))}function DI(){if(!hI)return;let e=bm({turnEntries:wI(),acknowledged:yI,unseen:bI,isLooking:_I()});TI(e.acknowledged),EI(e.unseen),vI?.(e.isShown)}function OI(e){SI.add(e)}function kI(){return hI}function AI(){return gI}function jI(e){_I=e,DI()}function MI(e){vI=e,DI()}function NI(){hI&&(TI(Xe(wI())),DI())}function PI(){return bI}function FI(e){return xI.has(e)}function II(e){return xI.has(e)?(EI(Xe([...xI].filter(t=>t!==e))),!0):!1}function LI(e){let t=vt.safeParse(e);t.success?(hI=t.data,gI=sm(t.data.entries),DI(),CI({kind:`status`})):u(`community`,`dropped community-status: ${c(t.error.issues)}`)}function RI(e){CI({kind:`connection`,isConnected:e})}function zI({source:e,className:t,title:n,allowsScripts:r}){let i=D(`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 BI=`panel-action`,VI=524288,HI=[`key`,`prKey`,`repo`,`number`,`action`,`actionId`,`itemKey`,`fingerprint`],UI=900;function WI(e){let t=pt.options.find(t=>t.shape.type.value===e);return new Set(Object.keys(t?.shape??{}).filter(e=>e!==`type`&&e!==`requestId`))}function GI(e){return e.map(e=>`${e.path.map(String).join(`.`)||`request`}: ${e.message}`).join(`; `)}function KI(e,t){let n=Ne.safeParse(t);if(!n.success)return{ok:!1,error:`not sent: ${GI(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=pt.safeParse({...n.data,requestId:BI});if(!r.success)return{ok:!1,error:`${n.data.type} not sent: ${GI(r.error.issues)}`};let i=WI(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 ${VI} byte limit`}:{ok:!0,type:r.data.type,payload:a}}function qI(e,t,n){return`${e} sent ${t} ${HI.flatMap(e=>{let t=n[e];return typeof t==`string`||typeof t==`number`?[`${e}=${t}`]:[]}).join(` `)}`.trim().slice(0,UI)}var JI=`•`.repeat(8),YI=`[^/\\\\\\s"'\`<>:]+`,XI=RegExp(`(?<![\\w./\\\\-])(?:/home/${YI}|/Users/${YI}|[A-Za-z]:[\\\\/]Users[\\\\/]${YI}|/root(?![\\w.-]))`,`g`);function ZI(e){let t=rc(e);if(t.length===0)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+JI,r=i.end;return n+e.slice(r)}function QI(e){return e.replace(XI,`~`)}function $I(e){return QI(ZI(e))}var eL=1e3,tL=12e4,nL=new Map,rL=null;function iL(e){return cc()?$I(e):e}var aL={sessions:()=>({sessions:[...k].map(([e,t])=>({id:e,name:iL(Tn(t)),agent:t.agent??null,state:t.currentState,stateSinceMs:t.stateSince,taskTitle:t.taskTitle===null?null:iL(t.taskTitle)}))}),focus:()=>({sessionId:M.snapshot().focusedSessionId,view:M.snapshot().activeView,isStreamerMode:cc()}),theme:()=>Ta(),usage:()=>({planLimits:Object.entries(gT().planLimitsByVendor).flatMap(([e,t])=>t===null||e!==`claude`&&e!==`codex`&&e!==`kimi`?[]:[{vendor:e,fiveHour:Xx(t,`fiveHour`),sevenDay:Xx(t,`sevenDay`)}])}),attention:()=>{let e=Pn([...k.values()].map(e=>({state:e.currentState,unseenOutcome:e.unseenOutcome??null})));return{waiting:e.waitingCount,finished:e.finishedCount,failed:e.failedCount}},reviews:()=>yh()};function oL(e,t){e.frame.contentWindow?.postMessage(t,`*`)}function sL(e,t){let n=t.get(e);if(n)return n;let r=aL[e](),i={data:r,dataJson:JSON.stringify(r)};return t.set(e,i),i}function cL(e,t,n=new Map){let{data:r,dataJson:i}=sL(t,n);e.lastSentJsonByTopic.get(t)!==i&&(e.lastSentJsonByTopic.set(t,i),oL(e,Oe.parse({v:1,kind:`topic`,topic:t,data:r})))}function lL(){let e=!1,t=new Map;for(let n of nL.values()){for(let e of n.subscribedTopics)cL(n,e,t);e||=n.subscribedTopics.size>0}e||rL===null||(clearInterval(rL),rL=null)}var uL=new Map;async function dL(e,t){let n=await a(e,t).catch(e=>qb(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 fL(e,t){oL(e,{v:1,kind:`store`,data:uL.get(e.packName)??{},error:t})}async function pL(e){let t=await dL(`pack-data-get`,{pack:e.packName});t.ok&&uL.set(e.packName,t.data),fL(e,t.ok?null:t.error)}async function mL(e,t,n){let r=Ee(e.packName,be(uL.get(e.packName)??{},t,n));if(r!==null){fL(e,r);return}let i=await dL(`pack-data-set`,{pack:e.packName,key:t,value:n});if(!i.ok)fL(e,i.error);else{uL.set(e.packName,i.data);for(let t of nL.values())t.packName===e.packName&&fL(t,null)}}function hL(e,t){e.subscribedTopics=new Set(t.filter(t=>e.grantedTopics.has(t))),e.lastSentJsonByTopic.clear(),oL(e,{v:1,kind:`hello`,granted:[...e.subscribedTopics]}),pL(e);for(let t of e.subscribedTopics)cL(e,t);rL??=setInterval(lL,eL)}function gL(e,t,n,r,i=!1){oL(e,{v:1,kind:`action-result`,id:t,ok:r===null,timedOut:i,result:n,error:r})}function _L(e,t){return t.ok===!1?typeof t.error==`string`&&t.error!==``?t.error:`${e} was refused`:null}async function vL(e,t,n){let r=KI(e.acts,n);if(!r.ok){gL(e,t,null,r.error);return}v({type:`client-log`,scope:`packs`,text:qI(e.viewId,r.type,r.payload)});let i=await a(r.type,r.payload,{timeoutMs:tL}).catch(e=>qb(e));if(i===`Request timed out`){gL(e,t,null,`${r.type} got no answer within ${tL/1e3} s; it may still run, so check before sending it again`,!0);return}if(typeof i==`string`){gL(e,t,null,`${r.type} failed: ${i}`);return}let o={...i};gL(e,t,o,_L(r.type,o))}function yL(e){let t=[...nL.values()].find(t=>t.frame.contentWindow!==null&&t.frame.contentWindow===e.source);if(!t)return;let n=Ae.safeParse(e.data);if(n.success){vL(t,n.data.id,n.data.request);return}let r=ge.safeParse(e.data);r.success&&(r.data.kind===`store-set`?mL(t,r.data.key,r.data.value):r.data.kind===`subscribe`&&hL(t,r.data.topics))}function bL(e,t,n){nL.size===0&&window.addEventListener(`message`,yL),nL.set(e,{viewId:e,frame:t,packName:n.pack,acts:n.acts,grantedTopics:new Set(n.reads),subscribedTopics:new Set,lastSentJsonByTopic:new Map})}var xL=null,SL=new Set;function CL(){return xL}function wL(e){return SL.add(e),()=>SL.delete(e)}function TL(e){let t=dt.safeParse(e);if(!t.success)u(`settings`,`dropped packs-status: ${c(t.error.issues)}`);else{xL=t.data,ya(t.data.themes)&&Da();for(let e of SL)e()}}var EL=`about:blank`,DL={pack:``,reads:[],acts:[]},OL=new Map,kL=new Map;function AL(e){let t=D(`img`,`pack-tab-icon`);return t.src=e,t.alt=``,t.decoding=`async`,t.referrerPolicy=`no-referrer`,t}function jL(e){return kL.set(e.viewId,e),{mount(t){let n=kL.get(e.viewId);t.replaceChildren(ML(e.viewId,n?.entryUrl??EL,e.label,n??DL))}}}function ML(e,t,n,r){let i=zI({source:{kind:`url`,url:t},className:`pack-panel-frame`,title:n,allowsScripts:!0});return OL.set(e,i),bL(e,i,r),i}function NL(e,t,n,r){let i=OL.get(e);i&&i.getAttribute(`src`)!==t&&i.replaceWith(ML(e,t,n,r))}function PL(e){kL.set(e.viewId,e),NL(e.viewId,e.entryUrl,e.label,e)}function FL(e){kL.delete(e),NL(e,EL,OL.get(e)?.title??``,DL)}function IL(e){let t=()=>e(CL()?.panels??[]);wL(t),t()}function LL(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function RL(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function zL(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 BL(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 VL(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function HL(e,t,n){t&&e?.refreshOn?.includes(n)&&t.refresh?.(n)}function UL(e,t,n,r){for(let i of e)LL(i.view,t)&&HL(i,r(i.view),n)}function WL(){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 GL(e,t,n){let r=Number(e);return!e||!Number.isFinite(r)||t-r>n}var KL=`glimmervoid:preload-error-reload-at`,qL=3e4,JL=1e3,YL=WL();function XL(e,t){let n=YL.mountedModuleOf(e.view);n?t(n):YL.show(e).then(t).catch(t=>{throw u(`view`,`${e.view} failed to show: ${d(t)}`),t})}function ZL(e){return YL.mountedModuleOf(e)}function QL(e){YL.mountEagerViews(e)}function $L(e){let t=()=>{YL.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,JL)}function eR(e){let t=Date.now();GL(e.getItem(KL),t,qL)&&(e.setItem(KL,String(t)),location.reload())}function tR(e){window.addEventListener(`vite:preloadError`,()=>eR(e()))}function nR(e,t){fetch(e,{method:`HEAD`,cache:`no-store`}).then(e=>{e.status===404&&eR(t())}).catch(()=>{})}function rR(e,t,n){let r=E(document,`#app-main`,`main`),i=Ze(`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)??D(`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=D(`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}=VL(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 iR(e){return e.iconUrl?AL(e.iconUrl):C(tt)}function aR(e){return rR({view:e.viewId,label:e.label,iconPath:``,panelClass:`pack-panel-view`,hasPanelChrome:!1,module:jL(e)},iR(e),()=>{})}function oR(e,t){e.tab.replaceChildren(iR(t),t.label)}function sR(e){uh({openTerminal:e.openTerminal,openReviews:e.openReviews}),Tj({openTerminal:e.openTerminal}),wF(e.onRestart),$k(e.openReviewFile);let t=[{view:`focus`,label:`Focus`,iconPath:ht,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,refreshOn:[`connected`],module:{mount:()=>XN({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:KP,deactivate:YP,refresh:PP}},{view:`prs`,label:`Reviews`,iconPath:Le,panelClass:`pr-view`,gate:{fromSettings:JF.teamReview},load:()=>N(()=>import(`./review-queue-panel-8u_I7_Hn.js`).then(e=>e.view),__vite__mapDeps([38,12,13,5,3,14,15,4,6,7,39,32,40,41,34,42,27,20,28,29,23,30,21,31,24,43])),refreshOn:[`shown`],attention:{subscribe:oh,acknowledge:ah},onConnectionChange:e=>{Ip(e),Rm(e)}},{view:`issues`,label:`Issues`,iconPath:Je,panelClass:`issues-view`,gate:{fromSettings:JF.issues},load:()=>N(()=>import(`./issues-panel-cmaZg8pa.js`).then(e=>e.view),__vite__mapDeps([44,13,5,3,14,20,15,12,29,23,30,4,6,7,21,32,41,16,17,42,27,28,31,24,45])),refreshOn:[`shown`],onConnectionChange:ef},{view:`usage`,label:`Usage`,iconPath:pe,panelClass:`usage-view`,gate:{fromSettings:JF.usage},load:()=>N(()=>import(`./usage-panel-DFauLty3.js`).then(e=>e.view),__vite__mapDeps([46,13,5,3,47,48])),attention:{subscribe:xT,acknowledge:bT},onConnectionChange:DT,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,iconPath:kt,panelClass:`radar-view`,gate:{fromSettings:JF.posthog},load:()=>N(()=>import(`./radar-panel-9SuG7CHS.js`).then(e=>e.view),__vite__mapDeps([49,12,13,5,3,14,20,15,50,28,29,23,30,4,6,7,21,35,47,51])),attention:{subscribe:uI,acknowledge:lI}},{view:`community`,label:`Community`,iconPath:it,panelClass:`community-view`,gate:{fromSettings:JF.community},load:()=>N(()=>import(`./community-panel-BiOV5-sV.js`).then(e=>e.view),__vite__mapDeps([52,12,13,5,3,14,20,15,39,32,40,41,4,6,7,34,53])),refreshOn:[`shown`],attention:{subscribe:MI,acknowledge:NI},onConnectionChange:RI},{view:`boards`,label:`Boards`,iconPath:tt,isPhoneNavScreen:!0,isPhoneOnly:!0,panelClass:`boards-screen`,hasPanelChrome:!1,load:()=>N(()=>import(`./boards-view-Dib7ZZVH.js`).then(e=>e.view),__vite__mapDeps([36,13,5,3,14,20,15,12,31,24,37])),refreshOn:[`shown`,`connected`]},{view:`hooks`,label:`Hooks`,iconPath:at,panelClass:`hooks-view`,load:()=>N(()=>import(`./hooks-panel-D-3mY4mZ.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:ze,panelClass:`trace-view`,gate:{subscribe:G_},load:()=>N(()=>import(`./trace-panel-B1xwTFQF.js`).then(e=>e.view),__vite__mapDeps([56,13,5,3,15,12,4,6,7,57])),refreshOn:[`shown`],onAvailabilityChange:e=>dI(e?Vb:null),onConnectionChange:Kb},{view:`benchmarks`,label:`Arena`,iconPath:bt,panelClass:`bench-view`,load:()=>N(()=>import(`./arena-panel-DbKIlSCb.js`).then(e=>e.view),__vite__mapDeps([58,12,13,5,3,14,20,30,28,59])),onConnectionChange:Ii},{view:`settings`,label:`Settings`,iconPath:ue,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>N(()=>import(`./settings-panel-Djq38v9c.js`).then(e=>e.view),__vite__mapDeps([60,12,13,5,3,14,15,4,6,7,10,50,28,20,29,23,30,21,35,61,8,42,27,31,24,32,43,2,1,62]))}].map(t=>rR(t,C(t.iconPath),e.setPhoneAttention));return E(document,`#header-tabs`,`div`).replaceChildren(...t.map(e=>e.tab)),t}function cR(e){return e===`remote`?`remote`:`local`}function lR(e,t){return cR(t)===`local`||e!==`shutdown`}var uR=!1,dR=new Set;function fR({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){let o=cx(),s=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;Jt({title:t,message:s,confirmLabel:n,danger:r||o>0,onConfirm:()=>v({type:e})})}function pR(){fR({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function mR(){fR({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})}function hR(e){uR=lR(`shutdown`,e);for(let e of dR)e.isConnected?e.hidden=!uR:dR.delete(e)}function gR(e){e.hidden=!uR,dR.add(e)}function _R(e){e&&OF(e),!BA(`settings`)&&$(`settings`,{section:e})}function vR(e){BA(e)||$(e)}function yR(){BA(`boards`)||($(`focus`),FP())}function bR(){WF(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}var Q=sR({onRestart:pR,openTerminal:e=>{zA(e)||($(`focus`),HP(e))},openPlan:e=>{$(`focus`),UP(e)},openReviewFile:(e,t)=>{sx(e)&&(zA(e)||($(`focus`),HP(e),VP(t)))},openReviews:()=>wR(`prs`)?(BA(`prs`)||$(`prs`),!0):!1,setPhoneAttention:PA});function xR(){return Q.map(e=>e.view)}var SR=xR();function CR(e){return Q.find(t=>t.view===e)}function wR(e){return Q.some(t=>t.view===e&&!t.tab.hidden)}var TR=!0,ER=null;function DR(e){CR(e)?.attention?.acknowledge()}var OR=null;function kR(e){OR=v({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function AR(){OR&&kR(OR)}function jR(e){let t=CR(e);t&&(XL(t,e=>HL(t,e,`shown`)),kR(e))}function MR(e){UL(Q,{isPhoneShellActive:AA(),activeView:Ln(),phoneScreen:M.snapshot().phoneScreen},e,ZL)}function $(e,{section:t,setting:n,persist:r=!0}={}){let i=CR(e);if(!i||!wR(e))return;let a=Ln();M.dispatch(`setActiveView`,e),TR=r,r&&(ER=null),document.body.dataset.activeView=e,r&&ir(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&&ZL(a)?.deactivate?.(),XL(i,r=>{Ln()===e&&(r.activate?.(),HL(i,r,`shown`),e===`settings`&&t&&OF(t,n??null))}),kR(e),a===`settings`&&e!==`settings`&&bR(),DR(e)}function NR(e,t){let{view:n}=e;e.tab.hidden=!t,NA(n,t),e.onAvailabilityChange?.(t),!AA()&&(!t&&Ln()===n&&$(`focus`),t&&ER===n&&$(n))}function PR(e){for(let{view:t,isAvailable:n}of RL(Q,e))NR(t,n)}var FR;function IR(e){FR=e;let t=zL(SR,e);Q.every((e,n)=>e.view===t[n])||(Q.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),E(document,`#header-tabs`,`div`).append(...Q.map(e=>e.tab)),MA(t))}function LR(){return Q.filter(e=>!e.tab.hidden)}function RR(e,t){let n=e[t];return $(n.view),n.tab}function zR(e,t){let n=LR(),r=n.findIndex(t=>t.view===e);return RR(n,bi(r,t,n.length))}function BR(e){Q.some(e=>e.tab===document.activeElement)&&e.focus()}var VR=null;function HR(e){let t=xR();IR(e),a(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&IR(t)}).catch(()=>IR(t))}function UR(e){let t=VR;if(VR=null,!t||t===e)return;let n=xR();HR(BL(n,t,n.indexOf(e)))}function WR({view:e,tab:t}){t.addEventListener(`click`,()=>$(e)),t.addEventListener(`dragstart`,t=>{VR=e,t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),t.addEventListener(`dragover`,n=>{VR&&VR!==e&&(n.preventDefault(),t.dataset.dropTarget=`true`)}),t.addEventListener(`dragleave`,()=>delete t.dataset.dropTarget),t.addEventListener(`drop`,n=>{n.preventDefault(),delete t.dataset.dropTarget,UR(e)}),t.addEventListener(`dragend`,()=>{VR=null}),t.addEventListener(`keydown`,e=>{if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=LR(),n=t.findIndex(e=>e.view===Ln()),r=xi(e.key,n,t.length,`horizontal`);r!==null&&(e.preventDefault(),RR(t,r).focus())})}var GR=`pack:`,KR=new Map;function qR(e){let t=aR(e);return Q.push(t),SR.push(t.view),E(document,`#header-tabs`,`div`).append(t.tab),WR(t),t}function JR(e){let t=new Set(e.map(e=>e.viewId));for(let e of Q)e.view.startsWith(GR)&&!t.has(e.view)&&(FL(e.view),NR(e,!1));for(let t of e){let e=CR(t.viewId)??qR(t),n=KR.get(t.viewId);n&&(n.label!==t.label||n.iconUrl!==t.iconUrl)&&oR(e,t),KR.set(t.viewId,t),PL(t),NR(e,!0)}IR(FR)}function YR(){let e=Rr(),t=WF(location.hash),n=fv(location.hash);if(t&&(OF(null,null,location.hash),$(`settings`,{persist:!1})),n&&$(`focus`,{persist:!1}),t||n)return;let r=wR(e);r||(ER=e),$(r?e:`focus`,{persist:r})}function XR(){let e=Ln();$(wR(e)?e:`focus`,{persist:TR})}function ZR(){EF(Q),QL(Q);for(let e of Q)e.gate&&(NR(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>NR(e,t)));Bb(()=>{wR(`trace`)&&(BA(`trace`)||$(`trace`))});for(let e of Q)WR(e);YR(),IL(JR)}function QR(e){return WF(e)?(OF(null,null,e),BA(`settings`)||$(`settings`,{persist:!1}),!0):!1}var $R=`No plan is stored for this session yet. It appears here once the agent writes one.`,ez=`Plan`;function tz(e){let t=fv(e);return t?!sx(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),AA()?(RA(t)||Bn({source:ez,sessionId:t,message:$R}),!0):($(`focus`,{persist:!1}),UP(t)||Bn({source:ez,sessionId:t,message:$R}),!0)):!1}function nz(e){return tz(e)?!0:QR(e)}function rz(e){e.newURL===location.href&&nz(location.hash)}function iz(){document.addEventListener(`click`,e=>{if(!AA()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&nz(t.hash)&&e.preventDefault()}),window.addEventListener(`hashchange`,rz)}var az=null,oz=new Set;function sz(){az?.setState(Vr()?`idle`:`off`)}function cz(e){pr(e),sz();for(let t of oz)t(e)}function lz(e){oz.add(e)}function uz(e){az=e,sz(),e.element.addEventListener(`click`,()=>cz(!Vr()))}var dz=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,fz=[`title`,`label`],pz=new WeakMap,mz=new WeakMap,hz=null;function gz(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(dz)!==null}function _z(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function vz(e,t){if(t&&e===t.masked)return t;let n=$I(e);return n===e?null:{original:e,masked:n}}function yz(e){let t=_z(e)?null:vz(e.data,pz.get(e));t?(pz.set(e,t),e.data!==t.masked&&(e.data=t.masked)):pz.delete(e)}function bz(e,t){let n=e.getAttribute(t),r=mz.get(e),i=n===null?null:vz(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),mz.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function xz(e){for(let t of fz)bz(e,t)}function Sz(e){return e instanceof Element&&e.matches(dz)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function Cz(e){xz(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,Sz);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&yz(e),e instanceof Element&&xz(e)}function wz(e){gz(e)||(e instanceof Text&&yz(e),e instanceof Element&&Cz(e))}function Tz(e){e instanceof Element&&!gz(e)&&xz(e)}function Ez(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&&wz(e);for(let e of n)e.isConnected&&Tz(e)}function Dz(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);Oz(e);for(let e=t.nextNode();e;e=t.nextNode())Oz(e)}function Oz(e){if(e instanceof Text){let t=pz.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=mz.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function kz(){if(hz)return;let e=new MutationObserver(t=>{Ez(t),e.takeRecords()});Cz(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:fz}),hz=e}function Az(){hz&&(hz.disconnect(),hz=null,Dz(document.body),pz=new WeakMap,mz=new WeakMap)}function jz(e){e?kz():Az()}function Mz(){jz(cc()),uc(jz)}var Nz=ct({label:`Play queued merge celebrations`,icon:C(me,`1.6`),action:`play-celebrations`,states:[`idle`,`attention`]}),Pz=w({variant:`primary`,label:`Session`,icon:C($e),action:`add-session`,onClick:pi});Pz.id=`btn-add-session-header`;var Fz=ct({label:`Keyboard shortcuts and version`,icon:C(ot,`1.6`),action:`open-shortcuts-help`,onClick:()=>_R(`browser-shortcuts`),states:[`idle`]}).element,Iz=ct({label:`Mute alerts`,icon:C(jt,`1.6`),action:`toggle-mute`,states:[`idle`,`off`]}),Lz=Iz.element,Rz=w({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-header-status`});Rz.id=`header-status-dismiss`;var zz=E(document,`#celebration-tray`,`div`);zz.prepend(Nz.element),E(document,`.header-right`,`div`).append(Pz,Fz,Lz),E(document,`#header-status`,`p`).append(Rz);function Bz(){uz(Iz),Mz(),Ut(document.querySelector(`.header`))}function Vz(){bf(zz,Nz,E(document,`#celebration-tray-count`,`span`))}function Hz(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 Uz(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 Wz(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function Gz(e,t){return t||Wz(e)?!1:Uz(e)}var Kz=w({variant:`primary`,size:`small`,label:`Restart`,action:`restart-to-update`,hidden:!0}),qz=w({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-update-command`}),Jz=w({variant:`icon`,size:`small`,label:`Dismiss update notice`,icon:C(Ct),action:`dismiss-update-banner`});E(document,`#update-banner-cmd`,`code`).before(Kz),E(document,`#update-banner-copy-status`,`span`).before(qz),E(document,`#update-banner`,`div`).append(Jz);var Yz=w({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-leftovers-command`}),Xz=w({variant:`icon`,size:`small`,label:`Dismiss old report notice`,icon:C(Ct),action:`dismiss-leftovers-banner`});E(document,`#post-turn-leftovers-copy-status`,`span`).before(Yz),E(document,`#post-turn-leftovers-banner`,`div`).append(Xz);var Zz,Qz=null;function $z(e,t,n){e.onclick=()=>{let e=zt(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var eB=qF(Ce,_e,`Update`).href;function tB(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function nB(e){let t=E(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=Ue(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=tB(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===Qz||!a&&Zz!==void 0&&s===Zz||!a&&s&&Cr()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);E(document,`#update-banner-text`,`span`).textContent=i,E(document,`#update-banner-cmd`,`code`).textContent=c;let l=E(document,`#update-banner-update`,`a`);l.href=eB,l.hidden=n!==`link`,Kz.hidden=n!==`restart`,Kz.onclick=pR;let u=E(document,`#update-banner-cmd`,`code`);u.hidden=n!==`command`,qz.hidden=n!==`command`;let d=E(document,`#update-banner-copy-status`,`span`);d.hidden=n!==`command`,d.textContent=``;let f=E(document,`#update-banner-link`,`a`);f.hidden=!e.releaseUrl,f.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,$z(qz,d,c),Jz.onclick=()=>{t.hidden=!0,a?Qz=i:(Zz=s,nr(s))}}var rB=!1;function iB({repositories:e,command:t}){let n=E(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(rB)return;let r=E(document,`#post-turn-leftovers-copy-status`,`span`);E(document,`#post-turn-leftovers-text`,`span`).textContent=Hz(e.length),E(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,$z(Yz,r,t),Xz.onclick=()=>{rB=!0,n.hidden=!0}}var aB=E(document,`#telemetry-banner`,`div`),oB=w({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-telemetry-banner`});aB.append(oB);function sB(){tr(!0),aB.hidden=!0}function cB(e){aB.hidden=!Gz(e,lr())}function lB(){let e=E(document,`#telemetry-banner-settings`,`a`);e.href=qF(`privacy`,`telemetry-enabled`,`What's collected`).href,e.addEventListener(`click`,sB),oB.addEventListener(`click`,sB)}function uB(e){N(()=>import(`./feature-hint-DnrqJolm.js`).then(t=>t.showFeatureHint(e,{isFeatureEnabled:e=>wR(le[e]),openView:vR,openSetting:(e,t)=>QR(UF(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 dB(){N(()=>import(`./feature-hint-DnrqJolm.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 fB=2500;function pB({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}function mB(e){Ca(e.isExperimentalBuild===!0&&Hr()),lx(e),FF(e),PR(e),cB(e),IR(e.viewTabOrder),lc(e.streamerMode===!0)}var hB=Object.freeze({top:[0,1],right:[-1,0],bottom:[0,-1],left:[1,0]}),gB=160,_B=950,vB=900,yB=980,bB=450,xB=720,SB=260,CB=`cubic-bezier(0.22, 1, 0.36, 1)`,wB=`cubic-bezier(0.2, 0.8, 0.3, 1)`,TB=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),EB=e=>new Promise(t=>{setTimeout(t,e)});function DB(e){return e!==void 0&&Object.hasOwn(hB,e)}function OB(e){return[...e.querySelectorAll(`.loading-mark-bracket`)].flatMap(e=>{let t=e instanceof SVGElement?e.dataset.side:void 0;if(!(e instanceof SVGElement)||!DB(t))return[];let[n,r]=hB[t];return[{bracket:e,dx:n,dy:r}]})}function kB(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:zc}],{duration:gB,easing:`ease-out`})}}function AB(e){e.animate([{transform:`rotate(0deg)`,easing:`cubic-bezier(0.5, 0, 0.15, 1)`},{transform:`rotate(360deg)`,offset:.86,easing:wB},{transform:`rotate(354deg)`,offset:.93,easing:wB},{transform:`rotate(360deg)`}],{duration:_B})}function jB(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:vB,easing:`cubic-bezier(0.2, 0.9, 0.3, 1)`})}}function MB(e,t){e.animate([{transform:`scale(0)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:yB,easing:CB,fill:`forwards`}),t.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`})}function NB(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:xB,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:xB,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 PB(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(TB?.matches||document.hidden||!(t instanceof SVGElement)||!n||!r||!i)return;let a=OB(t);kB(a),e.dataset.unlock=`spin`,await EB(gB),AB(n),jB(a),MB(r,i),await EB(yB),e.dataset.unlock=`lit`,await EB(bB),e.dataset.unlock=`burst`,NB(a,r,i),await EB(SB)}var FB=E(document,`#connection-status`,`span`),IB=E(FB,`.connection-label`,`span`),LB=E(document,`#loading-screen`,`div`),RB=E(document,`#loading-status`,`div`),zB=E(document,`#loading-detail`,`div`),BB=E(document,`#shutdown-screen`,`div`),VB=E(document,`#shutdown-status`,`div`),HB=!1,UB=null,WB=!1;function GB(){HB||UB===null||pB({hasSnapshot:WB,connectingTerminalCount:sl(),msSinceConnected:performance.now()-UB})===`reveal`&&qB()}function KB(){WB=!0,GB()}function qB(){HB||(HB=!0,$L(Q),yd(),sj(),PB(LB).then(JB,JB))}function JB(){LB.classList.add(`fade-out`);let e=()=>LB.remove();LB.addEventListener(`transitionend`,t=>{t.target===LB&&e()}),setTimeout(e,1e3)}function YB(e,t){FB.dataset.state=`shutdown`,IB.textContent=e,VB.textContent=t,BB.classList.add(`active`)}var XB=new Set([`disconnected`,`connecting`]);function ZB(e,t,n){FB.dataset.state=e,FB.toggleAttribute(`data-reconnected`,n),IB.textContent=t}function QB(e,t){ZB(e,t,e===`connected`&&XB.has(FB.dataset.state??``))}function $B(e,t){FB.dataset.state!==`shutdown`&&ZB(e===`verified`?`connected`:e,t,!1)}var eV=1e4,tV=`Server`,nV=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,rV=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,iV=null,aV=!1;function oV(){RB.textContent=`Reconnecting to server...`,zB.textContent=rV,zB.hidden=!aV}function sV(){iV=null,aV=!0,HB?Bn({source:tV,message:nV,hidesInStreamerMode:!1}):oV()}function cV(){iV!==null||aV||(iV=window.setTimeout(sV,eV))}function lV(){iV!==null&&window.clearTimeout(iV),iV=null,aV=!1,zB.hidden=!0,zn(tV)}function uV(){lV(),nR(import.meta.url,()=>window.sessionStorage),AR(),BB.classList.contains(`active`)?location.reload():(oj(),document.body.classList.add(`app-ready`),!HB&&UB===null&&(UB=performance.now(),RB.textContent=`Connecting to sessions...`,setTimeout(qB,fB)),GB(),MR(`connected`),a(`get-settings`,{}).then(e=>{e.settings&&(mB(e.settings),Ln()===`settings`&&QR(location.hash))}).catch(()=>{}))}function dV(e,t){if(e===`connecting`||e===`verified`)$B(e,t);else{QB(e,t),Ey(e===`connected`);for(let t of Q)t.onConnectionChange?.(e===`connected`);e===`connected`?uV():e===`disconnected`&&BB.classList.contains(`active`)?VB.textContent=`Waiting for server...`:(cV(),HB||oV())}}function fV(){ol(GB),o(dV)}var pV=14,mV=Object.freeze({idle:Bc,failed:`#ef4444`,waiting:`#f59e0b`});function hV({waitingCount:e,failedCount:t}){return e>0?`waiting`:t>0?`failed`:`idle`}function gV(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)">${Vc({frame:zc,light:mV[e],strokeWidth:pV})}</g></svg>`}function _V(){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 vV=_V(),yV=`idle`;function bV(e){let t=hV(e);t!==yV&&(yV=t,vV.href=`data:image/svg+xml,${encodeURIComponent(gV(t))}`)}function xV(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 SV(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 CV(){$d(),Mp(),FA()}function wV(){dP(),CV()}function TV(){$r(e=>{dP(e),CV()})}var EV=null;function DV(e){let t=xV(EV,e);EV=t.knownBuild,t.reload&&location.reload()}function OV(e){Vn(e),wx(e),Yi(e),P_(e),Mh(e)}function kV(e){let t=new Set(e.map(e=>e.id));for(let e of[...k.keys()])t.has(e)||OV(e)}function AV(e){kV(e),RF(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){Ji(t.id,t.coherenceHooks),jh(t.id,t.linkedPrs);let e=sx(t.id);e&&Ox(t.id,t.state,t.stateSince),e&&cn(t.id,!!t.saneYolo),e||px(t.id,t.name,t.state,SV(t)),Jv(t.id,t.failureReason),ox(t.id,t.taskTitle,t.taskTitleIsCustom),hx(t.id,t.agent),Sx(t.id,t.mergeStatus,t.mergeReason),mx(t.id,t.effectiveBase),_x(t.id,t.activeAgents,t.awaitingBackgroundTasks),vx(t.id,t.pendingPromptKind),yx(t.id,t.unseenOutcome),xy(t.id,t.hasPlan)}fx(),bV(j.counts),dP(),JP(),CV(),jV(),tz(location.hash),VA(),KB()}function jV(){Hb([...k].map(([e,t])=>({id:e,name:Tn(t)||e})))}function MV(e,t){xy(e,t?.hasPlan===!0),yx(e,t?.unseenOutcome)}var NV=new Set([T.DONE,T.FAILED]);function PV(e,t){return e!==void 0&&NV.has(e)&&!NV.has(t)&&t!==T.DORMANT}function FV(e){let t=k.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;wx(e.id),px(e.id,e.session,T.DORMANT,SV({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})),hx(e.id,t?.agent),MV(e.id,t)}function IV(e,t){let n=k.get(String(e.id))?.currentState;t.to===T.DORMANT&&n!==T.DORMANT?(FV(e),M_(e.id)):(Ox(e.id,t.to,e.timestamp),Jv(e.id,e.failureReason),e.saneYolo!==void 0&&cn(e.id,e.saneYolo),M_(e.id),PV(n,t.to)&&Cl(e.id))}function LV(e){if(sx(e.id))e.transition&&IV(e,e.transition),e.activeAgents!==void 0&&_x(e.id,e.activeAgents,e.awaitingBackgroundTasks),e.unseenOutcome!==void 0&&yx(e.id,e.unseenOutcome),e.pendingPromptKind!==void 0&&vx(e.id,e.pendingPromptKind),e.unseenOutcome!==void 0&&fx(),bV(j.counts),ri(e.id),rv(e.id);else{if(!e.transition)return;px(e.id,e.session,e.transition.to,SV({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),bV(j.counts),$d()}}function RV(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 zV={"session-trace-response":e=>Ub(e),"session-trace-changed":e=>Wb(e),"session-plan-changed":e=>{Sy(e),CV()},"session-plan-draft":e=>{Cy(e)},"session-plan-response":e=>{wy(e)},"session-docs-changed":e=>xg(e),"session-docs-snapshot":e=>Sg(e),"session-coherence-hooks":e=>{Ji(e.id,e.coherenceHooks),wV()},"session-coherence":e=>{Xi(e),wV()},"session-coherence-snapshot":e=>{Zi(e),wV()},"session-coherence-journal-response":e=>na(e)},BV={"team-review-status":e=>Fm(e),"github-prs":e=>sf(e),"my-prs-status":Np,"pr-flows-status":Pp,"packs-status":TL,"my-pr-merge-result":e=>Fp(e),"team-review-action-result":e=>Im(e),"open-team-review-session-result":e=>Lm(e),"issues-status":e=>tf(e),"issue-detail-result":e=>nf(e),"open-issue-session-result":e=>rf(e),"set-issue-state-result":e=>Gd(e)},VV={"radar-status":e=>fI(e),"radar-investigation-activity":e=>pI(e),"radar-investigation-finished":e=>mI(e),"community-status":e=>LI(e),"benchmark-status":e=>Li(e),"benchmark-action-result":e=>Ri(e),"race-status":e=>xj(e),"usage-sessions":e=>OT(e),"usage-report":e=>{AT(e),LF()},"plan-limits":e=>kT(e),"usage-budget-alert":e=>Bv({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0})},HV={snapshot:e=>{DV(e.serverBuild),AV(e.sessions)},"hooks-report":e=>ug(e),"save-hook-result":()=>dg(),"delete-hook-result":()=>dg(),"update-status":e=>{nB(e),zF(e)},"update-progress":e=>BF(e.journal),"post-turn-leftovers":e=>iB(e),"feature-hint":e=>uB(e.hint),"star-hint":()=>dB(),error:e=>{let t=VF(e),n=Gb(e),r=Ty(e);t||n||r||(e.id?qv(e.id,e.message):Bn({source:tV,message:e.message}))},"settings-updated":e=>{e.settings&&mB(e.settings),oj()},"agent-logins":e=>QP(e.logins),"health-snapshot":e=>{e.stats&&Qh(e.stats)},"client-trust":e=>hR(e.trust),"shutting-down":()=>YB(`Shutting down...`,`Shutting down sessions...`),restarting:()=>YB(`Restarting...`,`Restarting server...`)},UV={"session-status":e=>LV(e),"session-added":e=>{jh(e.id,e.linkedPrs),sx(e.id)||(px(e.id,e.session,e.state,SV(e)),hx(e.id,e.agent)),bV(j.counts),wV(),jV()},"session-close-confirm":e=>{oi(e.id)},"session-removed":e=>{OV(e.id),bV(j.counts),wV(),jV()},"session-title":e=>{ox(e.id,e.taskTitle,e.isCustom),wV()},"session-prs":e=>jh(e.id,e.linkedPrs),"session-renamed":e=>{Cx(e.id,e.newName),wV(),jV()},"session-modified":e=>{let t=k.get(String(e.id)),n=Yr()===String(e.id);Ji(e.id,null),wx(e.id),P_(e.id),jh(e.id,e.linkedPrs),px(e.id,e.session,e.state,SV(e)),n&&ui(String(e.id)),hx(e.id,e.agent),MV(e.id,t),bV(j.counts),wV(),jV()},"session-git":e=>gx(e.id,!!e.worktree),"session-merge-status":e=>{xx(e.id,e.mergeStatus,e.reason),zP(e.id,e.mergeStatus),CV()},"debug-state-response":e=>nv(e),"session-setup-response":e=>Nx(e),notify:e=>{zv(e),rv(e.session)},"session-error":e=>{N_(e.id),!Ty(e)&&qv(e.id,e.message)}},WV={"whiteboards-snapshot":e=>Vk(e),"whiteboard-patch":e=>Hk(e),"whiteboard-removed":e=>Uk(e)},GV=`Worktree`,KV=`Worktree warning`,qV=RV([HV,UV,{"session-worktree-blocked":e=>{Bn({source:GV,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=>{Bn({source:KV,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=>{zn(GV,e.id),mx(e.id,e.base)},"session-diff":e=>{D_(e.id,e)},"session-diff-error":e=>{O_(e.id,e.message)},"change-map":e=>k_(e.id,e.map),"session-changed":e=>A_(e.id)},zV,WV,BV,VV]);function JV(e){let t=qV[e.type];t&&t(e)}function YV(){l(e=>{JV(e),MR(e.type)})}function XV(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 ZV(){DA({panels:XV(Q),onScreenShown:e=>{jR(e),e!==`settings`&&bR(),e===`settings`&&!WF(location.hash)&&OF(),DR(e)},canGoBack:e=>e===`settings`&&NF()||e===`prs`&&hh(),onBack:e=>{e===`settings`&&PF(),e===`prs`&&gh()},headerControls:[E(document,`.header-title`,`h1`),E(document,`#status-indicator`,`div`),E(document,`#celebration-tray`,`div`),Pz,Fz,Lz]}),MF(IA),mh(IA)}function QV(e){if(e===`phone`){let e=Z();for(let e of Q)ZL(e.view)?.deactivate?.();let t=WF(location.hash);OA({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}).then(e=>{e&&t&&OF(null,null,location.hash),!e&&yo()&&!AA()&&XR()});return}let t=jA();kA(),XR(),t&&HP(t)}function $V(){ZV(),yo()&&QV(`phone`),bo(QV)}function eH(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function tH(e){HP(e),fi(e),requestAnimationFrame(()=>requestAnimationFrame(()=>k.get(e)?.term?.focus()))}function nH(){let e=eH()??Yr();e?ti(e):document.getElementById(`btn-add-session-header`)?.click()}function rH({action:e,step:t}){switch(e){case`merge`:{let e=Yr();return!e||YN()?!1:(I_(e),!0)}case`close-session`:{let e=Yr();return e?(ai(e),!0):!1}case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return nH(),!0;case`next-attention`:return yo()?!1:JN()?(xP(),!0):(Ln()===`prs`&&_h()||qP(()=>$(`focus`)),!0);case`rail-step`:return JN()?(GP(t),!0):!1;case`view-step`:return!yo()&&(BR(zR(Ln(),t)),!0);case`session-nth`:return JN()?(WP(t),!0):!1;case`streamer-mode`:return mc(),!0}}function iH(e){return e.code!==`KeyZ`||e.altKey||e.shiftKey?!1:Rl===`mac`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function aH(){si(tH),document.addEventListener(`keydown`,e=>{if(e.repeat||Bt(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1;if(!t&&iH(e)&&!Yt()&&hi()){e.preventDefault(),e.stopImmediatePropagation();return}let n=mr(e,Rl,{isTerminalFocused:t},Vl());n&&(Yt()||rH(n)&&e.preventDefault())})}function oH(){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))}),tR(()=>window.sessionStorage)}ba(br()),Sa(()=>{N(()=>import(`./alert-sound-Da6VQFBS.js`).then(e=>e.playNyanJingle(),e=>u(`alert-sound`,`nyan jingle failed to load: ${d(e)}`)),__vite__mapDeps([10,7]))}),bd(Wr()),vo(),iu(document),fV(),TV(),CT(v),N(()=>import(`./your-day-tip-126RabsR.js`).then(e=>e.startYourDayTips({openUsage:()=>vR(`usage`)}),e=>u(`your-day-tip`,`your day tips failed to load: ${d(e)}`)),__vite__mapDeps([65,13,5,3,20,63,12,4,6,7,61,8,64])),cg(v),zb(v),Qd(v),Pi(v),ln(kh),vn(Qi),vn(Eh,`links`),vn(dA,`links`),hn(pA),oA(yR),sn({isReadable:$i,open:ta}),fn(Mx),uc(()=>MR(`settings-updated`)),YV(),lB(),Bz(),iz(),Vz(),ZR(),$V(),aH(),UA(),oH(),Zh(E(document,`#health-footer-mount`,`div`)),Ll(ux),cV(),dd(),f();var sH=_r();sH&&n().then(()=>_l(sH));export{DM as $,Rd as $i,SS as $n,rh as $r,AS as $t,jF as A,Fi as Aa,Zf as Ai,zC as An,Pb as Ar,Ik as At,_F as B,Rf as Bi,vS as Bn,ty as Br,ET as Bt,YF as C,yo as Ca,lm as Ci,cC as Cn,Px as Cr,Fk as Ct,GF as D,ba as Da,kp as Di,MS as Dn,Ib as Dr,zk as Dt,UF as E,Ca as Ea,Ap as Ei,jS as En,Rb as Er,Xk as Et,PF as F,ep as Fi,BS as Fn,py as Fr,Kk as Ft,gN as G,Tf as Gi,aC as Gn,_v as Gr,_T as Gt,$P as H,zf as Hi,Mw as Hn,ny as Hr,TT as Ht,AF as I,Hf as Ii,zS as In,hy as Ir,Ck as It,RM as J,qd as Ji,MC as Jn,pg as Jr,JC as Jt,FM as K,cf as Ki,Rw as Kn,cv as Kr,gT as Kt,DF as L,$f as Li,Cw as Ln,ry as Lr,bk as Lt,SF as M,rp as Mi,Jw as Mn,Nb as Mr,Zk as Mt,CF as N,Qf as Ni,Pw as Nn,sb as Nr,Gk as Nt,FF as O,Ea as Oa,Op as Oi,US as On,Lb as Or,Rk as Ot,TF as P,Uf as Pi,WC as Pn,by as Pr,iA as Pt,jM as Q,Jd as Qi,qw as Qn,L as Qr,pS as Qt,vF as R,Lf as Ri,Sw as Rn,Qv as Rr,yk as Rt,JF as S,jo as Sa,Yp as Si,jw as Sn,Fx as Sr,_A as St,KF as T,Da as Ta,qp as Ti,FC as Tn,Jb as Tr,qk as Tt,QP as U,Bf as Ui,zw as Un,Sv as Ur,wT as Ut,kF as V,Vf as Vi,Bw as Vn,ly as Vr,yT as Vt,eF as W,wf as Wi,sC as Wn,yv as Wr,vT as Wt,kM as X,Hd as Xi,Tw as Xn,lg as Xr,dC as Xt,MM as Y,Ud as Yi,Nw as Yn,og as Yr,ww as Yt,NM as Z,Kd as Zi,Kw as Zn,sg as Zr,kS as Zt,OI as _,Vl as _a,vm as _i,kw as _n,Jx as _r,$A as _t,gR as a,Wd as aa,sh as ai,GC as an,_S as ar,lM as at,sI as b,dc as ba,Sm as bi,mC as bn,rS as br,gA as bt,CL as c,Zu as ca,nh as ci,JS as cn,Uw as cr,Ej as ct,jI as d,Xl as da,Nm as di,Aw as dn,Vw as dr,yj as dt,Xd as ea,ch as ei,YS as en,Ww as er,AM as et,AI as f,Rl as fa,xm as fi,EC as fn,Hw as fr,pj as ft,II as g,Ul as ga,gm as gi,dS as gn,Yx as gr,aj as gt,FI as h,Wl as ha,cm as hi,hS as hn,zx as hr,dj as ht,mR as i,Vd as ia,dh as ii,oS as in,gS as ir,fM as it,IF as j,Mi as ja,ap as ji,SC as jn,Mb as jr,eA as jt,yF as k,Ni as ka,op as ki,NC as kn,Fb as kr,Lk as kt,wL as l,uu as la,fh as li,qS as ln,Dw as lr,Sj as lt,PI as m,Gl as ma,Cm as mi,bS as mn,ES as mr,uj as mt,lz as n,Yd as na,ih as ni,OC as nn,ZC as nr,Zj as nt,BL as o,zd as oa,ph as oi,tw as on,$C as or,Dj as ot,kI as p,Hl as pa,dm as pi,ew as pn,XC as pr,gj as pt,PM as q,lf as qi,AC as qn,lv as qr,jT as qt,pR as r,Bd as ra,gh as ri,aS as rn,Ow as rr,Qj as rt,zL as s,bd as sa,vh as si,DS as sn,QC as sr,Oj as st,cz as t,Zd as ta,lh as ti,kC as tn,pw as tr,IM as tt,zI as u,nu as ua,Mm as ui,KS as un,PC as ur,bj as ut,cI as v,cc as va,um as vi,RS as vn,Gx as vr,QA as vt,qF as w,bo as wa,_m as wi,LC as wn,Dx as wr,Wk as wt,oI as x,ts as xa,Em as xi,pC as xn,Lx as xr,mA as xt,aI as y,uc as ya,Tm as yi,PS as yn,Wx as yr,KA as yt,bF as z,cp as zi,fw as zn,Xv as zr,ST as zt};
|