glimmervoid 0.52.2-next.678 → 0.52.2-next.680
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/client/assets/{benchmark-panel-C-c9Kiea.js → benchmark-panel-CY0VHbkC.js} +1 -1
- package/dist/client/assets/benchmark-panel-CY0VHbkC.js.br +0 -0
- package/dist/client/assets/boards-view-B_bSKyat.js +1 -0
- package/dist/client/assets/boards-view-B_bSKyat.js.br +0 -0
- package/dist/client/assets/boards-view-SutPL47N.css +1 -0
- package/dist/client/assets/boards-view-SutPL47N.css.br +0 -0
- package/dist/client/assets/{community-panel-DCkLaMpV.js → community-panel-i92fc4IR.js} +1 -1
- package/dist/client/assets/community-panel-i92fc4IR.js.br +0 -0
- package/dist/client/assets/{dialogs-C8Txp6-B.js → dialogs-Rk6V83C7.js} +1 -1
- package/dist/client/assets/dialogs-Rk6V83C7.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-Cstwx4PY.js → doc-editor-ui-BsVwtyem.js} +1 -1
- package/dist/client/assets/doc-editor-ui-BsVwtyem.js.br +0 -0
- package/dist/client/assets/{feature-hint-D4Bf1Vud.js → feature-hint-B7CA-mZd.js} +1 -1
- package/dist/client/assets/feature-hint-B7CA-mZd.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-DafZ5DVx.js → first-run-checklist-CmgKy8Jx.js} +1 -1
- package/dist/client/assets/first-run-checklist-CmgKy8Jx.js.br +0 -0
- package/dist/client/assets/{hooks-panel-Ch4jXXip.js → hooks-panel-RR2ZdDf2.js} +1 -1
- package/dist/client/assets/hooks-panel-RR2ZdDf2.js.br +0 -0
- package/dist/client/assets/{index-rP0diPsR.css → index-BCYtNn4q.css} +1 -1
- package/dist/client/assets/index-BCYtNn4q.css.br +0 -0
- package/dist/client/assets/{index-a2YtrnZZ.js → index-rE4BiGZz.js} +5 -5
- package/dist/client/assets/index-rE4BiGZz.js.br +0 -0
- package/dist/client/assets/{issues-panel-ChwlyxV5.js → issues-panel-CI002Sa4.js} +1 -1
- package/dist/client/assets/issues-panel-CI002Sa4.js.br +0 -0
- package/dist/client/assets/{lane-read-token-step-D90X5SVN.js → lane-read-token-step-B_KgzYQY.js} +1 -1
- package/dist/client/assets/lane-read-token-step-B_KgzYQY.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-Cz-N7Lra.js → my-prs-panel-BnX5BWwa.js} +1 -1
- package/dist/client/assets/my-prs-panel-BnX5BWwa.js.br +0 -0
- package/dist/client/assets/{nyan-cat-BpoWglF_.js → nyan-cat-DhXDT3zE.js} +1 -1
- package/dist/client/assets/nyan-cat-DhXDT3zE.js.br +0 -0
- package/dist/client/assets/{phone-shell-vH02KbDK.js → phone-shell-C_5TyptC.js} +1 -1
- package/dist/client/assets/phone-shell-C_5TyptC.js.br +0 -0
- package/dist/client/assets/{plan-face-C0__OQaK.js → plan-face-DReWFWAO.js} +1 -1
- package/dist/client/assets/plan-face-DReWFWAO.js.br +0 -0
- package/dist/client/assets/{plan-render-D2_wGxUV.js → plan-render-DpH9hL6E.js} +1 -1
- package/dist/client/assets/plan-render-DpH9hL6E.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-pyISZz_q.js → pr-queue-columns-3w9gLVud.js} +1 -1
- package/dist/client/assets/pr-queue-columns-3w9gLVud.js.br +0 -0
- package/dist/client/assets/{radar-panel-08x269rn.js → radar-panel-8_2t93G1.js} +1 -1
- package/dist/client/assets/radar-panel-8_2t93G1.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-BZ81IqA7.js → repo-roots-adder-B0wMYrsO.js} +1 -1
- package/dist/client/assets/repo-roots-adder-B0wMYrsO.js.br +0 -0
- package/dist/client/assets/{resume-dialog-B769M43A.js → resume-dialog-ukLRYAb4.js} +1 -1
- package/dist/client/assets/resume-dialog-ukLRYAb4.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-CoiWjuL2.js → review-queue-panel-D7EPFEjb.js} +1 -1
- package/dist/client/assets/review-queue-panel-D7EPFEjb.js.br +0 -0
- package/dist/client/assets/{session-actions-CpQIAl2X.js → session-actions-ByUeN2DK.js} +2 -2
- package/dist/client/assets/session-actions-ByUeN2DK.js.br +0 -0
- package/dist/client/assets/{session-row-CnEx_48g.js → session-row-bZ0xZako.js} +1 -1
- package/dist/client/assets/session-row-bZ0xZako.js.br +0 -0
- package/dist/client/assets/{settings-panel-DXCr-n06.js → settings-panel-BTHxXdtR.js} +2 -2
- package/dist/client/assets/settings-panel-BTHxXdtR.js.br +0 -0
- package/dist/client/assets/{shown-face-BN8KlCPx.js → shown-face-DTH_HMvh.js} +1 -1
- package/dist/client/assets/shown-face-DTH_HMvh.js.br +0 -0
- package/dist/client/assets/{trace-panel-BpiZzlnb.js → trace-panel-ws0zMLD_.js} +1 -1
- package/dist/client/assets/trace-panel-ws0zMLD_.js.br +0 -0
- package/dist/client/assets/{usage-panel-BlO-SI6M.js → usage-panel-D-F5UoXU.js} +1 -1
- package/dist/client/assets/usage-panel-D-F5UoXU.js.br +0 -0
- package/dist/client/assets/{your-day-tip-HkTB4v3D.js → your-day-tip-BW0Kb-tN.js} +1 -1
- package/dist/client/assets/your-day-tip-BW0Kb-tN.js.br +0 -0
- package/dist/client/index.html +4 -4
- package/dist/client/index.html.br +0 -0
- package/package.json +1 -1
- package/dist/client/assets/benchmark-panel-C-c9Kiea.js.br +0 -0
- package/dist/client/assets/boards-view-BkqnO7wI.js +0 -1
- package/dist/client/assets/boards-view-BkqnO7wI.js.br +0 -0
- package/dist/client/assets/boards-view-DY1WYiXM.css +0 -1
- package/dist/client/assets/boards-view-DY1WYiXM.css.br +0 -0
- package/dist/client/assets/community-panel-DCkLaMpV.js.br +0 -0
- package/dist/client/assets/dialogs-C8Txp6-B.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-Cstwx4PY.js.br +0 -0
- package/dist/client/assets/feature-hint-D4Bf1Vud.js.br +0 -0
- package/dist/client/assets/first-run-checklist-DafZ5DVx.js.br +0 -0
- package/dist/client/assets/hooks-panel-Ch4jXXip.js.br +0 -0
- package/dist/client/assets/index-a2YtrnZZ.js.br +0 -0
- package/dist/client/assets/index-rP0diPsR.css.br +0 -0
- package/dist/client/assets/issues-panel-ChwlyxV5.js.br +0 -0
- package/dist/client/assets/lane-read-token-step-D90X5SVN.js.br +0 -0
- package/dist/client/assets/my-prs-panel-Cz-N7Lra.js.br +0 -0
- package/dist/client/assets/nyan-cat-BpoWglF_.js.br +0 -0
- package/dist/client/assets/phone-shell-vH02KbDK.js.br +0 -0
- package/dist/client/assets/plan-face-C0__OQaK.js.br +0 -0
- package/dist/client/assets/plan-render-D2_wGxUV.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-pyISZz_q.js.br +0 -0
- package/dist/client/assets/radar-panel-08x269rn.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-BZ81IqA7.js.br +0 -0
- package/dist/client/assets/resume-dialog-B769M43A.js.br +0 -0
- package/dist/client/assets/review-queue-panel-CoiWjuL2.js.br +0 -0
- package/dist/client/assets/session-actions-CpQIAl2X.js.br +0 -0
- package/dist/client/assets/session-row-CnEx_48g.js.br +0 -0
- package/dist/client/assets/settings-panel-DXCr-n06.js.br +0 -0
- package/dist/client/assets/shown-face-BN8KlCPx.js.br +0 -0
- package/dist/client/assets/trace-panel-BpiZzlnb.js.br +0 -0
- package/dist/client/assets/usage-panel-BlO-SI6M.js.br +0 -0
- package/dist/client/assets/your-day-tip-HkTB4v3D.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 ee,u as _,v,x as te,y as ne}from"./control-ws-t9cKDDGy.js";import{c as y,d as b,g as re,n as ie,o as ae,u as oe}from"./zod-_N0uRWDY.js";import{A as x,Bt as se,C as ce,Cn as le,Ct as ue,D as de,Dn as fe,Dt as pe,Et as me,H as he,Ht as ge,J as _e,K as ve,Lt as ye,M as be,Mn as xe,Mt as Se,N as Ce,Nt as we,O as Te,Ot as S,P as Ee,Pt as De,Q as Oe,Rt as ke,S as Ae,Sn as je,T as Me,Tt as Ne,Ut as Pe,W as Fe,Wt as Ie,Xt as Le,Y as Re,_ as ze,_n as Be,a as Ve,an as He,bn as Ue,c as We,cn as Ge,ct as Ke,dn as qe,dt as Je,f as Ye,g as Xe,gn as Ze,h as Qe,i as $e,in as et,jn as tt,jt as nt,k as rt,kt as it,l as at,ln as ot,mn as st,nn as ct,on as lt,p as ut,q as dt,rn as ft,s as pt,sn as mt,t as C,tn as ht,u as gt,un as _t,v as vt,vn as yt,vt as bt,w as xt,wt as St,x as Ct,xt as wt,yt as Tt,z as Et,zt as Dt}from"./button-Cnom-MQM.js";import{J as Ot,K as kt,X as w,Y as At,_ as jt,b as Mt,f as Nt,g as T,h as Pt,n as Ft,p as It,q as Lt,s as E,t as Rt,u as zt,x as Bt}from"./dom-helpers-Bs-xZEnd.js";import{a as Vt,i as Ht,n as Ut,r as Wt,t as Gt}from"./modal-C-Lb5-jJ.js";import{C as Kt,S as qt,_ as Jt,a as Yt,b as Xt,c as Zt,d as Qt,f as $t,g as en,h as tn,i as nn,l as rn,m as an,n as on,o as sn,p as cn,r as ln,s as un,t as dn,u as fn,v as pn,x as mn,y as hn}from"./session-row-CnEx_48g.js";import{S as gn,_ as _n,a as vn,b as yn,c as bn,f as xn,g as Sn,h as Cn,i as D,m as wn,n as Tn,o as O,r as k,s as En,t as A,u as Dn,x as On,y as kn}from"./card-registry-W9ss4JHS.js";import{n as j,t as An}from"./ui-state-core-Nssh-6QJ.js";import{t as M}from"./preload-helper-BLdHbfdN.js";import{i as jn,n as Mn,o as Nn,r as Pn,s as Fn,t as In,u as Ln}from"./action-status-B0E-UYey.js";import{a as Rn,c as zn,i as Bn,n as Vn,o as Hn,r as Un,s as Wn,t as Gn}from"./session-tick-CY_ByGke.js";import{n as Kn,t as qn}from"./local-store-CVQ5ByvB.js";import{$ as Jn,C as Yn,D as Xn,E as Zn,G as Qn,H as $n,K as er,L as tr,O as nr,Q as rr,S as ir,T as ar,W as or,Y as sr,at as cr,b as lr,c as ur,dt as dr,et as fr,f as pr,ft as mr,g as hr,gt as gr,h as _r,i as vr,it as yr,l as br,m as xr,mt as Sr,n as Cr,nt as wr,p as Tr,q as Er,r as Dr,rt as Or,s as kr,t as Ar,tt as jr,u as Mr,v as Nr,vt as Pr,x as Fr,y as Ir}from"./ui-prefs-zUfHHNE_.js";import{t as Lr}from"./http-url-B85DM2Ri.js";import{C as Rr,D as zr,E as Br,I as Vr,O as Hr,S as Ur,T as Wr,_ as Gr,a as Kr,b as qr,c as Jr,d as Yr,f as Xr,g as Zr,h as Qr,i as $r,k as ei,l as ti,m as ni,o as ri,u as ii,v as ai,w as oi,x as si,y as ci}from"./session-actions-CpQIAl2X.js";import{n as li}from"./card-actions-unth0mGA.js";import{n as ui,t as di}from"./roving-keys-core-BDobx2It.js";import{n as fi}from"./menu-DK4rQWp6.js";import{t as pi}from"./pr-status-icon-D1RIxNiH.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 mi={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},hi=null,gi=null,_i=!0,vi=new Map,yi=new Map,bi=new Set;function xi(){for(let e of bi)e()}function Si(e){bi.add(e)}function Ci(){return{status:hi,isServerConnected:_i,pendingActionBySuite:vi,outcomeBySuite:yi}}function wi(e){gi=e}function Ti(e,t){gi?.({type:`benchmark-action`,requestId:h(`benchmark`),suiteId:e,action:t})===!0?(vi.set(e,t),yi.set(e,mi[t]),xi()):(yi.set(e,Ee),xi())}function Ei(e){if(_i=e,!e){for(let e of vi.keys())yi.delete(e);vi.clear()}xi()}function Di(e){hi=e,xi()}function Oi(e){vi.delete(e.suiteId);let t=hi?.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.`};yi.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),xi()}function ki({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=Wt({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=E(`div`,`coherence-journal-header`),s=E(`h3`,`dialog-title`,t);s.id=n;let c=C({variant:`secondary`,label:`Close`,action:`close-coherence-panel`,onClick:i});return o.append(s,c),a.dialog.append(o,...r),Gt(a.dialog,s.id),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function Ai({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=ki({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(),_(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 ji={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 Mi(e){return e?.active!==!1||e.reason===Le.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,detailText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:qt.broken}]}function Ni(e){let t=ye.safeParse(e.kind);return{heading:`${t.success?ji[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function Pi(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 Fi=new Map,Ii=new Map,Li=Ai({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function Ri(e,t){Ii.delete(e),t&&Ii.set(e,t),Wi(e)}function zi(e){Fi.delete(e),Ii.delete(e);let t=Li.currentPanel();t?.sessionId===e&&t.close()}function Bi(e){let t=Fi.get(e.id);t&&t.updatedAt>e.updatedAt||(Fi.set(e.id,e),Wi(e.id))}function Vi(e){Fi.clear();for(let[t,n]of Object.entries(e.sessions))Fi.set(t,n);let t=Li.currentPanel();t&&Wi(t.sessionId)}function Hi(e){return Mi(Ii.get(e)??null).map(t=>({...t,onActivate:()=>Gi(e)}))}function Ui(e){return Fi.get(e)?.journal.ok===!0}function Wi(e){let t=Li.currentPanel();if(!t||t.sessionId!==e)return;let n=Pi(Ii.get(e)??null,Fi.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>E(`p`,null,e)))}function Gi(e){let t=E(`div`,`coherence-journal-reading`),n=E(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=E(`div`,`coherence-journal-entries`);Li.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>Wi(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function Ki(e){let t=Li.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=Ni(e),n=E(`article`,`coherence-journal-entry`);return n.append(E(`h4`,null,t.heading),E(`p`,null,t.text)),t.detail&&n.append(E(`p`,null,t.detail)),t.supersedes&&n.append(E(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var qi=[`running`,`waiting`,`failed`,`monitoring`,`done`,`initializing`,`idle`,`starting`,`complete`],Ji=new Set([`waiting`,`monitoring`]),Yi={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`}},Xi={dark:{black:`--border`,brightBlack:`--text-muted`,white:`--text`,brightWhite:`--text-head`},light:{black:`--text-head`,brightBlack:`--text-dim`,white:`--text-dim`,brightWhite:`--text`}},Zi=.35;function Qi(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 $i(e){let t={};for(let n of qi){let r=Ji.has(n)?8:6;t[`--state-${n}`]=e[n],t[`--state-${n}-bg`]=`color-mix(in oklab, var(--state-${n}) ${r}%, transparent)`}return t}function ea(e){if(e.accentAnsiSlot===`none`)return{};let t=`bright${e.accentAnsiSlot[0].toUpperCase()}${e.accentAnsiSlot.slice(1)}`;return{[e.accentAnsiSlot]:`--accent`,[t]:Qi(e.chrome.accent,Zi)}}function ta(e){let t=Object.fromEntries(Object.entries(e.chrome).map(([e,t])=>[`--${e}`,t]));return{label:e.label,colors:{...t,...$i(e.states)},terminal:{background:`--bg-card`,foreground:`--text`,cursor:`--accent`,cursorAccent:`--bg-card`,...Xi[e.mode],...Yi[e.mode],...ea(e)}}}var na={golgari:ta({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:ta({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:ta({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:ta({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:ta({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":ta({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":ta({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`}})},ra=`phyrexian`,ia=null,aa=null;function oa(e){let t=na[e];if(!t)return;let n=aa;aa=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`&&ia?.()}function sa(e){ia=e}function ca(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function la(){let e=na[aa||ra];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 ua(){return Object.entries(na).map(([e,t])=>({id:e,label:t.label}))}function da(){let e=la();e.background&&e.foreground&&_({type:`terminal-colors`,background:e.background,foreground:e.foreground})}var fa=3e4,pa=24,ma=null,ha=[`Android`,`iPhone`,`iPad`,`Windows`,`Mac OS X`,`Linux`],ga=[/Firefox\/\d+/,/Edg\/\d+/,/Chrome\/\d+/,/Version\/\d+/];function _a(){let e=navigator.userAgent,t=ha.find(t=>e.includes(t))??`unknown platform`;return`${ga.map(t=>t.exec(e)?.[0]).find(e=>e!==void 0)?.replace(`Version`,`Safari`)??`unknown browser`} on ${t}`}function va(){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 ya(){return[navigator.onLine?`online`:`offline`,...va()].join(` `)}function ba(e,t){let n=[],r=0;for(let i of e){let e=i.length+1;if(r+e>t)break;n.push(i),r+=e}return{takenMarks:n,usedChars:r}}function xa(e,t){let n=e.join(` `);if(n.length<=t)return n;let r=t-pa,i=ba(e,r/2),a=ba(e.slice(i.takenMarks.length).reverse(),r-i.usedChars),o=e.length-i.takenMarks.length-a.takenMarks.length;return[...i.takenMarks,`(${o} marks dropped)`,...a.takenMarks.reverse()].join(` `)}function Sa(e){return e.marks.some(e=>e.startsWith(`terminal-bytes`))}function Ca(e){let t=Sa(e)&&!e.isCapped?`terminal live`:`terminal not live after ${fa/1e3} s`,n=`hidden ${Math.round(e.hiddenForMs/1e3)} s, ${t}, ${_a()}, ${e.networkAtWake}: `,r=n+xa(e.marks,ge-n.length);return _({type:`client-log`,scope:`wake`,text:r.slice(0,ge)})}function wa(){let e=ma;e&&(e.isCapped||Sa(e))&&Ca(e)&&(ma=null,clearTimeout(e.capTimer))}function Ta(){ma&&(ma.isCapped=!0,wa())}function Ea(e,t){e.marks.push(`${t}+${Math.round(performance.now()-e.startedAtMs)}`)}function Da(e){ma&&(e===`terminal-bytes`&&Sa(ma)||(Ea(ma,e),(e===`terminal-bytes`||e===`control-opened`)&&wa()))}function Oa(e){ma&&Ea(ma,e===`link`?[`link`,...va()].join(`-`):e)}function ka(e,t){ma||={startedAtMs:performance.now(),hiddenForMs:t,networkAtWake:ya(),marks:[],isCapped:!1,capTimer:setTimeout(Ta,fa)},Da(e)}function Aa(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function ja(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 Ma=null,Na=null;function Pa(){return Ma}function Fa(){return Ma?Promise.resolve(Ma):(Na??=Promise.all([M(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.t),__vite__mapDeps([0,1])),M(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.r),__vite__mapDeps([0,1])),M(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.n),__vite__mapDeps([0,1]))]).then(([e,t,n])=>(Ma={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},Ma)).catch(e=>{throw Na=null,e}),Na)}var Ia=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,La=new Map;function Ra(e){return e.clientWidth>0&&e.clientHeight>0}function za(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 Ba(e){La.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,za(e)}function Va(e){let t=[e],n=j.snapshot().borrowedCardId,r=n?O.get(n):void 0;r&&t.push(r);for(let e of ja([...La.keys()],Ia,t))Ba(e),e.needsWebGLReload=!0}function Ha(e){e?.term&&Aa({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:Ra(e.termWrap)})&&qa(e,{isForced:!0})}function Ua(){for(let e of La.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{Ba(e),e.needsWebGLReload=!0}}}var Wa=!1;function Ga(){Wa||(Wa=!0,requestAnimationFrame(()=>{Wa=!1,Ua()}))}function Ka(e){e?.addEventListener(`contextrestored`,Ga)}function qa(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){La.delete(e),La.set(e,!0);return}e.webglAddon&&(za(e),La.delete(e));let n=Pa();if(!n)return;Va(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,La.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(Ka),r.onAddTextureAtlasCanvas(Ka),Ka(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!Ra(e.termWrap),La.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,La.delete(e)}}var Ja=`(max-width: 768px)`,Ya=`(pointer: coarse)`;function Xa({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var Za=window.matchMedia?.(Ya),Qa=window.matchMedia?.(Ja);function $a(){return Xa({coarse:!!Za?.matches,narrowWidth:!!Qa?.matches})}function eo(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function to(){j.subscribe((e,t)=>{t.includes(`layout`)&&eo(e.layout)});let e=$a();eo(e),j.dispatch(`setLayout`,e);let t=()=>j.dispatch(`setLayout`,$a());return Za?.addEventListener?.(`change`,t),Qa?.addEventListener?.(`change`,t),e}function no(){return j.snapshot().layout===`phone`}function ro(e){return j.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var io=``,ao=`\x1B`,oo=`\r`,so=new Map([[`deleteContentBackward`,io],[`deleteByComposition`,io],[`deleteCompositionText`,io],[`deleteWordBackward`,ao],[`deleteSoftLineBackward`,ao],[`deleteHardLineBackward`,ao]]);function co(e){return so.get(e)??``}var lo=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function uo(e){return typeof e!=`string`||e===``||!lo.has(e)}function fo(e){return e?e.keyCode===229||e.key===`Process`:!1}function po(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 io.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,oo)}var mo=`Upload`;async function ho(e,t){return Mn(mo,e),_o(e,t)}async function go(e,t){Mn(mo,e);for(let n of t)await _o(e,n)}async function _o(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:(Nn({source:mo,sessionId:e,message:await vo(r,t.name)}),!1)}catch{return Nn({source:mo,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 vo(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 yo=new WeakMap,bo=5e3,xo=15e3,So=`The agent copied text. The browser needs a click before it can reach your clipboard.`,Co=`The clipboard is unavailable in this browser.`;function wo(e,t,n,r){let i=yo.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(()=>To(e,t),n===`ok`?bo:xo)))}function To(e,t){let n=yo.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function Eo(e){let t=e.buffer.active;return t.viewportY<t.baseY}function Do(e,t,{hasNewOutput:n=!1}={}){let r=yo.get(e)?.jumpToLatest;if(!r)return;let i=Eo(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function Oo(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 ko(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),wo(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function Ao(e,t,n,r){let i=Mt(t);i?i.then(()=>{r&&wo(e,`clipboard`,`ok`,r)}).catch(t=>ko(e,n,t)):wo(e,`clipboard`,`error`,Co)}function jo(e,t){let n=yo.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function Mo(e){let t=yo.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,Ao(e,n,`osc52 write`,`Copied to the clipboard.`))}function No(e,t,n){let r=jn(`terminal-notice`),i=E(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=C({variant:`primary`,label:`Copy to clipboard`,onClick:()=>Mo(t)});i.append(E(`span`,`terminal-clipboard-prompt-text`,So),a);let o=E(`div`,`terminal-notices`);o.append(i,r.element);let s=E(`div`,`terminal-jump-latest`);s.hidden=!0,s.append(C({variant:`secondary`,label:`Jump to latest`,onClick:()=>{n.scrollToBottom(),n.focus()}}),E(`span`,`terminal-jump-latest-new-output`));let c=E(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(E(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),yo.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatest:s})}var Po=1024,Fo=`Keys you type now are held and sent once the terminal reconnects.`,Io=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,Lo=!1;function Ro(e){let t=e._inputQueue,n=e.dataWs;if(!Lo&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,To(e,`keys`)}}function zo(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!Lo&&!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>=Po?(wo(e,`keys`,`error`,Io),!1):(e._inputQueue.push(t),r&&wo(e,`keys`,`busy`,Fo),!0)}function Bo(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,no()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=po(i,r.value);return i=r.value,e!==``&&(zo(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{no()?n(e):a()},!0)};c(`keydown`,e=>{fo(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(!uo(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=co(e.inputType);r!==``&&(zo(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function Vo(e){return!!e&&Array.from(e.types).includes(`Files`)}function Ho(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),go(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{Vo(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,Vo(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),go(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function Uo(e){Lo=e}var Wo=6,Go=262144,Ko=16384,qo=()=>{};function Jo(e,t){if(t.length<=Ko)e.push(t);else for(let n=0;n<t.length;n+=Ko)e.push(t.slice(n,n+Ko))}function Yo({budget:e=Wo,maxChunkBytes:t=Go,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)Jo(l,e),m+=e.length,a.readIdx++;else{m===0&&(Jo(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,qo);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 Xo=Yo(),Zo=oe().int().min(1).max(500),Qo=oe().int().min(1).max(200);ae(`type`,[b({type:y(`input`),data:re()}),b({type:y(`claim`),cols:Zo,rows:Qo}),b({type:y(`unview`)}),b({type:y(`pause-output`)}),b({type:y(`resume-output`)})]);var $o=b({type:y(`pty-size`),cols:Zo,rows:Qo,seq:oe().int().nonnegative()}),es=b({type:y(`output-beat`)}),ts=ae(`type`,[$o,es]),ns=`history`,rs=`output`,is=`paused`;ie([`screen`,`deep`]);function as(e){try{return JSON.parse(e)}catch{return null}}function os(e){let t=ts.safeParse(as(e));return t.success?t.data:null}var ss=new Set([1,5,25,100]);function cs(e){return e.isOutputPaused?`${e.history} paused`:e.history}function ls(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function us(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 fs({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&ls(e,n))}function ps({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function ms({isBorrowedCard:e,isTerminalFaceShown:t}){return!e||!t}function hs({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function gs(e,t,n){let r=new URLSearchParams;t&&r.set(ns,`deep`),n&&r.set(rs,is);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function _s({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:fs({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function vs({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function ys({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!ls(e,t),s=us(n)?ds(n):null,c=r&&!!s&&!ls(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:fs({authoritative:e,isActiveViewer:r,lastClaim:a})}}function bs(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function xs(e){let t=bs(e);return t===null?null:os(t)}function Ss(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=xs(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 Cs=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,ws=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,N=`[^\\S\\r\\n]`,Ts=`${Cs}${N}*(?:=>|[:=])${N}*`,Es=`[?&][A-Za-z0-9_.-]*`,Ds=`[^\\r\\n;&|]{0,200}?`,Os=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,ks=RegExp(`(${Ts})${ws}`,`gi`),As=RegExp(`(\\bBearer${N}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),js=[/\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],Ms=[RegExp(`((?:^|\\s)--?${Cs}${N}+)${ws}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${N}*=?${N}*)${ws}`,`g`),RegExp(`(-AsPlainText${N}+)${ws}`,`gi`),RegExp(`((?:^|\\s)setx${N}+[^\\s\\r\\n]*${Cs}[^\\s\\r\\n]*${N}+)${ws}`,`gi`)],Ns=[RegExp(`(\\bauthorization${N}*:${N}*Basic${N}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${N}+login\\b${Ds}${N}-p(?:${N}+|=))${ws}`,`gi`),RegExp(`(\\bcurl\\b${Ds}${N}(?:--user|-u)(?:${N}+|=)[^\\s:\\r\\n]+:)${ws}`,`gi`),RegExp(`(\\b${Os}\\b${Ds}${N}-p)${ws}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi],Ps=[/-----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],Fs=RegExp(`(${Es}(?:${Cs}|_key)=)[^&#\\s]+`,`gi`),Is=[ks,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${ws}`,`g`)],Ls=[As,...Ms,...Ns,...js,...Ps];function Rs(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function zs(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 Bs(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 Vs(e){let t=Rs(e,Fs);return Bs([...t,...Is.flatMap(n=>zs(Rs(e,n),t)),...Ls.flatMap(t=>Rs(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var Hs=`glimmervoid-streamer-mode`,Us=new Set,Ws=qn(Hs,!1)===!0;function Gs(e){document.documentElement.toggleAttribute(`data-streamer`,e)}Gs(Ws);function Ks(){return Ws}function qs(e){if(Kn(Hs,e),e!==Ks()){Ws=e,Gs(e);for(let t of Us)t(e)}}function Js(e){return Us.add(e),()=>Us.delete(e)}async function Ys(e){try{let t=await a(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:In});return t.type===`settings-error`?String(t.message):(qs(e),``)}catch(e){return Fn(e,In)}}var Xs=`Streamer mode`;async function Zs(){let e=!Ks();e&&qs(!0);let t=await Ys(e);t?Nn({source:Xs,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}):Mn(Xs)}function Qs(){Zs()}var $s=`#808080`,ec=new WeakMap;function tc(e,t,n){return`${e}:${t}:${n}`}function nc(e){return tc(e.marker.line,e.x,e.width)}function rc(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function ic(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function ac(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function oc(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 sc(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 cc(e,t,n,r){let i=[];if(Vs(ac(e,t,n)).length===0)return i;let{text:a,cellAt:o}=oc(e,t,n,r);for(let e of Vs(a))sc(i,o.slice(e.start,e.end));return i}function lc(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=ic(e,i);r.push(...cc(e,i,t,n)),i=t+1}return r}function uc(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function dc(e){e.decoration.dispose(),e.marker.dispose()}function fc(e){for(let t of e.masks)dc(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function pc(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function mc(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 hc(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(nc(r),r),r=e.masks.at(-1);return mc(e),n}function gc(e,t){let n={normal:uc(),alternate:uc()},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??$s,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(!Ks())return;let t=e.buffer.active,r=n[t.type],i=rc(t,pc(r,t)),a=hc(r,i);for(let e of lc(t,i)){let n=tc(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(){fc(n.normal),fc(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=>{fc(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=Js(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),ec.delete(e)},{once:!0}),ec.set(e,d)}function _c(e){ec.get(e)?.()}function vc({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var yc=`-4 -4 108 108`,bc=Object.freeze([{side:`top`,d:`M33 29L50 12L67 29`},{side:`right`,d:`M71 33L88 50L71 67`},{side:`bottom`,d:`M67 71L50 88L33 71`},{side:`left`,d:`M29 67L12 50L29 33`}]),xc=`M50 39L61 50L50 61L39 50Z`,Sc=11,Cc=`#e8e0ff`,wc=`#c084fc`;function Tc({frame:e,light:t,strokeWidth:n=Sc}){return`<path d="${bc.map(({d:e})=>e).join(``)}" fill="none" stroke="${e}" stroke-width="${n}" stroke-linejoin="miter" stroke-linecap="butt"/><path d="${xc}" fill="${t}"/>`}function Ec(e,t){return ms({isBorrowedCard:j.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var Dc=new WeakMap,Oc=new WeakMap,kc=new WeakSet,Ac=new WeakSet,jc=new WeakSet;function Mc(e,t){if(Dc.has(e)||!Eo(t))return;let n=t.buffer.active,r=n.length-n.viewportY;kc.has(e)?Dc.set(e,r):Oc.set(e,r)}function Nc(e,t,n){let r=e.term;r&&hs({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:kc.has(e)})&&(kc.add(e),Ac.add(e),Dc.set(e,r.buffer.active.length-n),sl(t))}var Pc=new WeakMap;function Fc(e,t){return document.visibilityState===`visible`&&!Ec(e,t)}function Ic(e,t){if(e&&Zc(e,t))return;let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=Fc(e,t);Pc.get(n)!==r&&(Pc.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function Lc(){for(let[e,t]of O)Ic(t,e)}document.addEventListener(`visibilitychange`,Lc),j.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&Lc()});function Rc(e,t){return O.get(e)===t&&!t.dataWs}function zc(e){return e.querySelector(`:scope > .terminal-connecting`)}function Bc(){let e=be(`svg`,{class:`loading-mark`,viewBox:yc,"aria-hidden":`true`});for(let{side:t,d:n}of bc)e.append(be(`path`,{class:`loading-mark-bracket`,"data-side":t,d:n}));return e}function Vc(e){if(zc(e))return;let t=E(`div`,`terminal-connecting`);t.append(Bc(),E(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}var Hc=new Set,Uc=new WeakSet;function Wc(e){return Hc.add(e),()=>Hc.delete(e)}function Gc(){let e=0;for(let[t,n]of O)n.card.dataset.link===`connecting`&&Fc(n,t)&&e++;return e}function Kc(e){let t=vc({hasTerminal:e.term!==null||Uc.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:Lo}),n=t===`connecting`&&!Lo&&Ac.has(e)?`live`:t;n===`none`?(delete e.card.dataset.link,qc()):(e.card.dataset.link=n,qc())}function qc(){for(let e of Hc)e()}function Jc(e,t,n){Mc(t,n),Xo.unregister(e),t.dataWs=null,Kc(t),t._resetGridClaim?.()}var Yc=new WeakMap;function Xc(e,t,r,i){Jc(e,t,r),clearTimeout(Yc.get(t)),Yc.delete(t),i===0&&v()?ol(e,t,r):Yc.set(t,setTimeout(()=>{Yc.delete(t),Rc(e,t)&&n().catch(()=>{}).then(()=>{Rc(e,t)&&ol(e,t,r)})},i))}function Zc(e,t){let n=jc.has(e),r=!e.dataWs&&O.get(t)===e;return!(n||r)||!e.term||!Fc(e,t)?!1:(jc.delete(e),e._dataWsRetryAttempt=0,Xc(t,e,e.term,0),!0)}function Qc(e,t,n){Jc(e,t,n),jc.add(t)}var $c=15e3,el=new Map;function tl(e){if(!v()||el.has(e)||O.get(e)?.dataWs)return;let n=gs(e,!1,!1),r=new WebSocket(t(location,ne(n)));r.binaryType=`arraybuffer`;let a=[],o=e=>a.push(e),s=()=>nl(e,r),c=()=>{r.readyState===WebSocket.CONNECTING&&s()};r.addEventListener(`message`,o),r.addEventListener(`close`,s);let l=setTimeout(c,i),u=setTimeout(s,$c);el.set(e,{socket:r,attachPath:n,bufferedMessages:a,release:()=>{r.removeEventListener(`message`,o),r.removeEventListener(`close`,s),clearTimeout(l),clearTimeout(u)}})}function nl(e,t){let n=el.get(e);n?.socket===t&&(el.delete(e),n.release(),t.close())}function rl(e,t){let n=el.get(e);if(!n)return null;let r=n.socket.readyState===WebSocket.CONNECTING||n.socket.readyState===WebSocket.OPEN;return n.attachPath!==t||!r?(nl(e,n.socket),null):(el.delete(e),n.release(),n)}var il=new WeakMap;function al(e,t,n){if(t.openedAtMs===null)return;let r=Math.round(performance.now()-t.openedAtMs);if(r>=1e3){il.delete(e);return}let i=(il.get(e)??0)+1;if(il.set(e,i),!ss.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 ol(n,r,a){jc.delete(r);let o=Dc.get(r);Dc.delete(r);let c=Oc.get(r);Oc.delete(r);let l=o!==void 0,u=o??c,d=!1,f=Fc(r,n),p=gs(n,l,!f),m=rl(n,p),h=m?.socket??new WebSocket(t(location,ne(p)));Pc.set(h,f),h.binaryType=`arraybuffer`,r.dataWs=h,f&&Da(`terminal-connecting`),Kc(r);let g=!1,ee=!1,_={sessionId:n,attachDescription:cs({history:l?`deep`:`screen`,isOutputPaused:!f}),openedAtMs:null,hasReceivedBytes:!1},v={hasSeenSize:!1,lastSeq:0},te=setTimeout(()=>{h.readyState===WebSocket.CONNECTING&&(ee=!0,f&&Da(`terminal-abandoned`),h.close())},i);Xo.register(n,(e,t)=>a.write(e,t));let y=e=>{if(r.dataWs!==h)return;let t=Ss(e.data,v);if(t.kind===`bytes`){_.hasReceivedBytes=!0,Hn(r),Pc.get(h)&&Da(`terminal-bytes`);let e=d;if(d=!1,Xo.enqueue(n,t.data),!e)return;let i=u??0;Xo.enqueueAction(n,()=>{a.scrollToLine(Math.max(0,a.buffer.active.length-i))});return}if(t.kind===`beat`){Hn(r);return}if(t.kind===`attach-size`){d=u!==void 0,l||kc.delete(r),v.hasSeenSize=!0,v.lastSeq=t.seq,a.reset(),_c(a),r.ptySize={cols:t.cols,rows:t.rows},r._syncGrid?.();return}if(t.kind!==`size`)return;v.lastSeq=t.seq;let i={cols:t.cols,rows:t.rows};Xo.enqueueAction(n,()=>{r.ptySize=i,r._syncGrid?.()})};h.addEventListener(`message`,y),h.addEventListener(`close`,t=>{if(clearTimeout(te),r.dataWs!==h)return;if(al(r,_,t),f&&!ee&&Da(`terminal-closed`),Ac.delete(r),!g&&!ee&&s(),!Fc(r,n)){Qc(n,r,a);return}if(ee){Xc(n,r,a,0);return}let i=e(r._dataWsRetryAttempt||0);r._dataWsRetryAttempt=(r._dataWsRetryAttempt||0)+1,Xc(n,r,a,i)});let b=()=>{clearTimeout(te),g=!0,_.openedAtMs=performance.now(),f&&Da(`terminal-opened`),r._dataWsRetryAttempt=0,Ac.delete(r),Kc(r),Ic(r,n),r._syncGrid?.({isActivationEdge:!0}),r._retryOwedGridClaim?.(),r._inputQueue?.length&&setTimeout(()=>{r.dataWs===h&&Ro(r)},50)};h.addEventListener(`open`,b),h.readyState===WebSocket.OPEN&&b();for(let e of m?.bufferedMessages??[])y(e)}function sl(e){let t=k(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,Xc(e,t,t.term,0),n?.close()}function cl(){for(let[e,t]of O)t.term&&(Fc(t,e)?sl(e):ll(e,t,t.term))}function ll(e,t,n){let r=t.dataWs;r&&(Qc(e,t,n),r.close())}function ul(){for(let[e,t]of O)t.term&&ll(e,t,t.term)}function dl(e,t){let n=e.dataWs;e.dataWs=null,Xo.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}var fl=`CommitMono`,pl=[400,700].map(e=>`${e} 14px ${fl}`),ml=`monospace`;function hl(e){return e.trim().replace(/^['"]|['"]$/g,``)}function gl(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>hl(e)!==fl);return r.length>0?r.join(`, `):ml}function _l(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function vl(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function yl(){return document.fonts?pl.every(e=>document.fonts.check(e)):!1}function bl(){return gl(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),yl())}function xl(e){document.fonts&&_l(document.fonts,pl,e)}var Sl=Pr(navigator.userAgent),Cl=`next-attention-keys`,wl=br();function Tl(){return wl}function El(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(E(`span`,`shortcut-sep`,`+`)),e.appendChild(E(`kbd`,`kbd`,t))})}function Dl(e){let t=E(`span`,`shortcut-keys`);return El(t,e),t}function Ol(){let e=Dl(gr(`next-attention`,Sl,wl));return e.classList.add(Cl),e}function kl(e){wl=e;let t=gr(`next-attention`,Sl,e);for(let e of document.querySelectorAll(`.${Cl}`))e.replaceChildren(),El(e,t)}var Al=/\bElectron\/\d/,jl=new Set([`localhost`,`127.0.0.1`]);function Ml(e){return Al.test(e)}function Nl({userAgent:e,pageHostname:t}){return Ml(e)&&jl.has(t)}function Pl(e){return Lr(e)!==null}var Fl=new Set([0,1]);function Il({button:e,opensInNewTab:t}){return t&&Fl.has(e)}function Ll(){return Nl({userAgent:navigator.userAgent,pageHostname:location.hostname})}function Rl(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function zl(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 Bl(e){!Ll()||!Pl(e)?Rl(e):zl(e).then(t=>{t||Rl(e)})}function Vl(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&Il({button:e.button,opensInNewTab:t.target===`_blank`})&&Pl(t.href)&&(e.preventDefault(),Bl(t.href))}function Hl(e){Ll()&&(e.addEventListener(`click`,Vl,!0),e.addEventListener(`auxclick`,Vl,!0))}var Ul=/https?:\/\/[^\s<>"']+/g,Wl=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),Gl={")":`(`,"]":`[`,"}":`{`};function Kl(e,t){let n=0;for(let r of e)r===t&&n++;return n}function ql(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(Wl.has(t)){e=e.slice(0,-1);continue}let n=Gl[t];if(n&&Kl(e,n)<Kl(e,t))e=e.slice(0,-1);else return e}}function Jl(e){let t=[];for(let n of e.matchAll(Ul)){let e=ql(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var Yl=50;function Xl(){return{activate(e,t){Bl(t)},allowNonHttpProtocols:!1}}function Zl(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<Yl;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<Yl;)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 Ql(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=Zl(r,t),o=[];for(let{start:e,end:t,url:n}of Jl(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){Bl(t)}})}n(o.length?o:void 0)}})}var $l=10,eu=1.2,tu=.005,nu=4,ru=.08,iu=5;function au(e,t){let n=Math.abs(t);return n<$l?!1:n>Math.abs(e)*eu}function ou(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 su(e,t,n){let r=e.length>=nu?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function cu(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>=ru))return 0;let o=Math.min(a,iu);return i<0?-o:o}function lu({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function uu(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)-tu*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=ou(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 fu(e,t){return!(e>0)||!(t>0)?0:e/t}var pu=1;function mu(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function hu(e,t){for(let n of e)if(n.identifier===t)return n;return null}function gu(e,t){if(mu(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 fu(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:pu,clientX:n,clientY:r,bubbles:!0,cancelable:!0}))},ee=()=>{if(d=null,!u)return;if(!e.isConnected||!n()||p()){f();return}let r=t.buffer?.active?.viewportY,{scrollLines:i,state:a}=uu(u,performance.now());u=a,i!==0&&t.scrollLines(i),u&&(i!==0&&t.buffer?.active?.viewportY===r?f():d=requestAnimationFrame(ee))},_=(e,t,n)=>{u=lu({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:m(),pendingPx:n}),u&&(d=requestAnimationFrame(ee))};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=hu(e.touches,r);if(!u)return;if(!s){if(!au(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=su([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=su(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=ou(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=su(l,o,e.timeStamp);let t=cu(l),n=c;h(),t!==0&&_(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function _u(e){let t=Sr(e,Sl,{isTerminalFocused:!0},Tl());return t?dr(t,document.body.dataset.activeView):!1}var vu=250,yu=`(max-width: 768px)`,bu=12,xu=14,Su=5e4,Cu=!1;function wu(e){Cu=e}var Tu=!1;window.addEventListener(`blur`,()=>{Tu=!0}),window.addEventListener(`focus`,()=>{Tu=!1});function Eu(e){let t=document.activeElement;return ps({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:Tu,isPhoneLayout:no()})}function Du(e,t,n){let r=window.matchMedia?.(yu).matches?bu:xu,i=new n.Terminal({cursorBlink:Cu,fontSize:r,fontFamily:bl(),theme:la(),scrollback:Su,allowProposedApi:!0,linkHandler:Xl()}),a=new n.FitAddon;i.loadAddon(a),Vc(e),i.open(e),No(e,t,i),Ql(i),gc(i,t.abortController.signal),t.term=i,t.fitAddon=a,Ba(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||!Eu(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=fs({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)},vu)}function h(){u&&s===null&&p(u)}function g({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=ys({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 ee(){let e=_s({authoritative:t.ptySize??null,isActiveViewer:c,isDocumentEngaged:Eu(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});e!==`none`&&(d(),e===`rebid`&&(l=null),g({isActivationEdge:!0}))}let _=new ResizeObserver(()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,g()}))});_.observe(e),t.resizeObserver=_,t._syncGrid=g,t._resetGridClaim=()=>{d(),u=vs({isActiveViewer:c,lastClaim:l,owedClaim:u}),l=null},t._retryOwedGridClaim=h,t._syncGridOnEngagementEdge=ee,t._isActiveViewer=()=>c,t._setActiveViewer=e=>{c!==e&&(c=e,d(),u=null,e&&Ha(t),g({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{Tu=!1,ee()},{signal:t.abortController.signal}),qa(t);let v=null;i.onScroll(()=>{v===null&&(v=requestAnimationFrame(()=>{v=null,t.term&&(t.term.refresh(0,t.term.rows-1),Do(t,t.term))}))}),i.onWriteParsed(()=>Do(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=Oo(r)}catch(e){return ko(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(Ao(t,i,`osc52 write`),!0):(jo(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`&&zo(t,`\x1B\r`),!1;if(e.type!==`keydown`)return!0;if(_u(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),Ao(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(zo(t,`\x1B`),!1):!0}),Bo(e,i,t),gu(e,i)}function Ou(){Uo(!0);for(let e of O.values())Kc(e)}function ku(){Uo(!1);for(let e of O.values())Kc(e),Ro(e)}function Au(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{zo(e,n),e.unseenOutcome&&_({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{Nc(e,t,n)}),Ho(e.termWrap,t,e.abortController.signal),Kc(e),queueMicrotask(()=>{Rc(t,e)&&ol(t,e,n)}))}function ju(e,t){if(e.term||Uc.has(e))return;let n=Pa();if(n){Mu(e,t,n);return}Uc.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},Vc(e.termWrap),Kc(e),Fa().then(n=>{Uc.delete(e),!(e.term||e.abortController.signal.aborted||O.get(t)!==e)&&(Mu(e,t,n),e._setActiveViewer?.(r))},()=>{Uc.delete(e),Kc(e)})}function Mu(e,t,n){Du(e.termWrap,e,n),Au(e,t)}function Nu(e){e?._syncGridOnEngagementEdge?.()}function Pu(e,t){if(!e)return;ju(e,t),Ic(e,t),Ha(e);let n=e.term;n&&(n.refresh(0,n.rows-1),Nu(e))}function Fu(e,t,n){e&&(n&&ju(e,t),e._setActiveViewer?.(n))}var Iu={isVisible:document.visibilityState===`visible`,isFrozen:!1,isProbing:!1,isReplacing:!1},Lu=document.visibilityState===`visible`?null:Date.now(),Ru=null,zu=null;function Bu(){Ru!==null&&window.clearTimeout(Ru),Ru=null}function Vu(e){Bu();let t=Date.now()+e;Ru=window.setTimeout(()=>{Ru=null,Wu({kind:`heartbeat-due`,lateByMs:Date.now()-t})},e)}function Hu(){zu!==null&&window.clearTimeout(zu),zu=null}function Uu(e){switch(e.kind){case`probe-control`:p(e.deadlineMs,e.isAnnounced).then(e=>{Wu({kind:e?`pong`:`pong-missed`})});return;case`replace-control`:g();return;case`close-sockets`:Hu(),ee(),ul();return;case`reconnect-shown-terminals`:cl();return;case`hold-input`:Ou();return;case`release-input`:ku();return;case`schedule-heartbeat`:Vu(e.inMs);return;case`cancel-heartbeat`:Bu();return}}function Wu(e){let t=te(Iu,e);Iu=t.state;for(let e of t.actions)Uu(e)}function Gu(){if(document.visibilityState!==`visible`){Lu=Date.now(),Wu({kind:`hidden`});return}let e=Lu===null?0:Date.now()-Lu;Lu=null,ka(`shown`,e),Wu({kind:`shown`,hiddenForMs:e})}function Ku(e){Hu(),Da(`control-${e}`),e===`connecting`?zu=window.setTimeout(()=>{zu=null,Wu({kind:`handshake-overdue`})},i):(e===`opened`&&da(),Wu({kind:e===`opened`?`control-opened`:`control-closed`}))}function qu(){ka(`resumed`,Lu===null?0:Date.now()-Lu),Wu({kind:`resumed`})}function Ju(){let e=Reflect.get(navigator,`connection`);e instanceof EventTarget&&e.addEventListener(`change`,()=>{Oa(`link`),Wu({kind:`network-changed`})})}function Yu(){r(Ku),document.addEventListener(`visibilitychange`,Gu),document.addEventListener(`freeze`,()=>Wu({kind:`frozen`})),document.addEventListener(`resume`,qu),window.addEventListener(`pagehide`,e=>{e.persisted&&Wu({kind:`frozen`})}),window.addEventListener(`pageshow`,e=>{e.persisted&&qu()}),window.addEventListener(`online`,()=>{Oa(`online`),Wu({kind:`network-changed`})}),window.addEventListener(`offline`,()=>Oa(`offline`)),Ju()}var Xu=!1,Zu=!1,Qu=!1,$u=null,ed=null;function td(){return ed??=M(()=>import(`./nyan-cat-BpoWglF_.js`).then(e=>e.r).then(e=>($u=e,e),e=>(ed=null,u(`flying-animals`,`nyan cat failed to load: ${d(e)}`),null)),__vite__mapDeps([2,1,3,4,5,6,7,8])),ed}function nd(e){!Qu||e.currentFlightBlockReason(!0)?e.stopNyanCat():e.startNyanCat()}function rd(){Zu=!0,id(Ir())}function id(e){let t=document.documentElement;Xu||(Xu=!0,ro(()=>id(Ir())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>id(Ir()))),Qu=e,e?(t.dataset.flyingAnimals=`true`,$u?nd($u):Zu&&td().then(e=>{e&&nd(e)})):(delete t.dataset.flyingAnimals,$u?.stopNyanCat())}var ad=45e3,od=`The server did not answer within ${ad/1e3} s.`,sd=`Select the issue to load its description.`,cd=null,ld=null,ud=new Map,dd=null,fd=new Map,pd=new Map,md=null,hd=new Map,gd=new Map,_d=new Map,vd=new Map,yd=new Set;function P(e){for(let t of yd)t(e)}function bd(e){return`${e.key}:${e.updatedAt}`}function xd(e){let t=fd.get(e);t&&(fd.delete(e),hd.set(t.issueKey,{text:od,tone:`error`}),P(`detail`))}function Sd(e){let t=fd.get(e);return t?(clearTimeout(t.timeoutHandle),fd.delete(e),t):null}function Cd(){return{latestStatus:ld,issueByKey:ud,selectedKey:cd}}function wd(e){yd.add(e)}function Td(e){cd=e,md&&md.issue.key!==e&&(md=null)}function Ed(){if(cd)return ud.get(cd)??(md?.issue.key===cd?md.issue:void 0)}function Dd(e){return md?.issue.key===e.key&&md.isClosed}function Od(e){return[...pd.values()].some(t=>t.issue.key===e.key)}function kd(e,t){if(Od(e))return;let n=h(`set-issue-state`);dd?.({type:`set-issue-state`,requestId:n,repo:e.repo,issueNumber:e.number,state:t})?(pd.set(n,{issue:e,state:t,timeoutHandle:setTimeout(()=>{pd.delete(n),hd.set(e.key,{text:od,tone:`error`}),P(`detail`)},ad)}),hd.set(e.key,{text:t===`closed`?`Closing issue.`:`Reopening issue.`,tone:`busy`}),P(`detail`)):(hd.set(e.key,{text:Ee,tone:`error`}),P(`detail`))}function Ad(e){let t=pd.get(e.requestId);if(!t)return;clearTimeout(t.timeoutHandle),pd.delete(e.requestId);let{issue:n,state:r}=t;e.ok?(md={issue:n,isClosed:r===`closed`},hd.set(n.key,{text:r===`closed`?`Closed as completed.`:`Reopened.`,tone:`ok`}),P(`detail`)):(hd.set(n.key,{text:e.error||`Could not ${r===`closed`?`close`:`reopen`} the issue.`,tone:`error`}),P(`detail`))}function jd(e){return[...fd.values()].some(t=>t.issueKey===e.key)}function Md(e){return hd.get(e.key)}function Nd(e){let t=bd(e),n=_d.get(t);return n===``?`No description.`:n??vd.get(t)??`Loading description.`}function Pd(e){let t=bd(e);if(_d.has(t)||[...gd.values()].some(e=>e.cacheKey===t))return;let n=h(`issue-detail`);vd.delete(t),dd?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?gd.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{gd.delete(n),vd.set(t,`${od} ${sd}`),P(`detail`)},ad)}):vd.set(t,`${Ee} ${sd}`)}function Fd(e){let t=e.projectId;if(!t||jd(e))return;let n=h(`open-issue-session`);dd?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(fd.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>xd(n),ad)}),hd.set(e.key,{text:`Opening session.`,tone:`busy`}),P(`detail`)):(hd.set(e.key,{text:Ee,tone:`error`}),P(`detail`))}function Id(e){dd?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function Ld(e){dd=e}function Rd(){P(`session-state`)}function zd(e){if(!e){for(let e of fd.values())clearTimeout(e.timeoutHandle),hd.set(e.issueKey,{text:Ee,tone:`error`});fd.clear();for(let e of pd.values())clearTimeout(e.timeoutHandle),hd.set(e.issue.key,{text:Ee,tone:`error`});pd.clear();for(let e of gd.values())clearTimeout(e.timeoutHandle),vd.set(e.cacheKey,`${Ee} ${sd}`);gd.clear(),P(`status`)}}function Bd(e){let t=ld?.issues.find(e=>e.key===cd);ld=e,ud=new Map(e.issues.map(e=>[e.key,e])),md&&!md.isClosed&&ud.has(md.issue.key)&&(md=null);let n=e.issues.find(e=>e.key===cd);n&&n.updatedAt!==t?.updatedAt&&Pd(n),P(`status`)}function Vd(e){let t=gd.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),gd.delete(e.requestId),e.ok&&e.body!==null&&_d.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&vd.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),P(`detail`))}function Hd(e){if(typeof e.requestId!=`string`)return;let t=Sd(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`;hd.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=ld?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),P(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;hd.set(n,{text:r,tone:`error`}),P(`detail`)}var Ud=new Map,Wd=new Set;function Gd(e){let t=we.safeParse(e);if(!t.success)u(`reviews`,`dropped github-prs: ${c(t.error.issues)}`);else{Ud=new Map(Object.entries(t.data.prs));for(let e of Wd)e()}}function Kd(e){return Ud.get(e.toLowerCase())}function qd(e){Wd.add(e)}var Jd=20,Yd=[],Xd=null,Zd=!1,Qd=0,$d=null;function ef(){return $d??=M(()=>import(`./celebration-player-CKjlfzoq.js`),__vite__mapDeps([9,3,4,5,6,7,10])).catch(e=>($d=null,u(`merge-celebration`,`celebration player failed to load: ${d(e)}`),null)),$d}function tf(e){return Zd?`playing`:e?`queued`:`empty`}function nf(){if(!Xd)return;let e=Yd.length>0,t=tf(e);Xd.tray.dataset.state=t,Xd.count.textContent=e?String(Yd.length):``,Xd.toggle.element.disabled=t!==`queued`,Xd.toggle.setState(t===`queued`?`attention`:`idle`)}function rf(){let e=Yd.shift();if(Zd=e!==void 0,nf(),!e)return;let t=Qd;Qd+=1,ef().then(n=>{n?(n.playCelebration(e,t),window.setTimeout(rf,n.CELEBRATION_DURATION_MS)):(Yd.unshift(e),Zd=!1,nf())})}function af(e,t,n){Xd={tray:e,toggle:t,count:n},t.element.addEventListener(`click`,()=>{Qd=0,rf()}),nf()}function of(e){Yd.push(e),Yd.length>Jd&&Yd.shift(),nf()}var sf={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},cf=new Set([`FAILURE`,`ERROR`]);function lf(e){return sf[e]}function uf(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 df(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 ff(e){let t=st.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:df(t)}}var pf=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],mf=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],hf={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`},gf={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`},_f={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`},vf={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 yf(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 bf(e){return pf[e.rows.reduce((e,{pr:t})=>Math.min(e,pf.indexOf(hf[t.stage])),pf.length-1)]}function xf(e){let t=new Map(pf.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of yf(e)){let e=t.get(bf(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return mf.flatMap(e=>t.get(e)??[])}function Sf(e,t){return yf(e).find(e=>e.rows.some(e=>e.pr.key===t))?.rows??[]}function Cf(e){return e.stackSize<2?null:`Stack ${e.depth+1}/${e.stackHeight}`}function wf(e){return gf[e]}function Tf(e){return _f[e]}function Ef(e){return vf[e]}function Df(e){return e?.isKeepMergeableEnabled!==!1}function Of(e,t){if(!t||!e.keepMergeable||e.isKeepMergeableFixInFlight)return!1;let n=e.keepMergeableAttempt?.outcome;return n!==void 0&&n!==`pushed`&&n!==`stopped`}function kf(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...ff({...n,repo:r}),...e}]})}function Af(e){let t=new Map;for(let n of e)for(let e of n.links){let r=De(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 jf(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 Mf=3;function Nf(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,Mf).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 Pf(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:je(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,isAuthorOrgMember:n.isAuthorOrgMember,liveHead:n.headRefOid,prStage:ff(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n)}}var Ff=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`];function If(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 Lf(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function Rf(e){return e.status===`posted`&&zf(e)}function zf(e){if(!Lf(e)||le(e))return!1;let t=Wf(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 Bf(e){return Gf(e).length>0||Rf(e)}function Vf(e){return Bf(e)?`actionable`:If(e).band}function Hf(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[If(t).band].push(t);for(let e of Ff)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(Bf(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!Kf(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[Vf(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 Ff)t.ready.push(...n[e]);return t}function Uf(e,t){return e.commit===t?e.isViewer||yt.has(e.state):!1}function Wf(e){return e.liveHead??e.reviewedHead}function Gf(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function Kf(e){return Gf(e).length>0?!0:le(e)?!1:zf(e)?!0:!(e.githubReviews??[]).some(t=>Uf(t,Wf(e)))}function qf(e,t){return`${e}#${t}`}var Jf=null,Yf={},Xf=[],Zf=[],Qf={},$f={},ep=[],tp={},np={},rp={},ip=null,ap=new Set,op=new Map,sp=!1,cp=new Set;function lp(e){for(let t of cp)t(e)}function up(){return[...op].flatMap(([e,t])=>{let n=O.get(e);return!n||t.length===0?[]:[{id:e,title:vn(n)||e,links:t}]})}function dp(){let e=kf(Jf?.prs??[],Kd),t=jf(ip,e);ip=e,hp(t),lp({kind:`prs`})}function fp(){sp||(sp=!0,queueMicrotask(()=>{sp=!1,dp()}))}function pp(e){cp.add(e)}function mp(){return{prs:kf(Jf?.prs??[],Kd).map(e=>({...e,reviewItems:$f[e.key]??e.reviewItems})),status:Jf,sessionsByPrKey:Af(up()),handledByPr:Yf,prFlowWarnings:Xf,prFlowApprovals:Zf,sourceRunsByPr:Qf,prFlowActions:ep,actionRunsByPr:tp,prActionsByPr:np,prActionRunsByPr:rp}}function hp(e){let t=e.filter(e=>!ap.has(e.key));if(t.length!==0){for(let e of t)ap.add(e.key);of(Nf(t))}}function gp(e){op=e,fp()}function _p(){lp({kind:`session-state`})}function vp(e){let t=Ze.safeParse(e);t.success?(Jf=t.data,dp()):u(`reviews`,`dropped my-prs-status: ${c(t.error.issues)}`)}function yp(e){let t=fe.safeParse(e);t.success?(Yf=t.data.handledByPr,Xf=t.data.warnings,Zf=t.data.pendingApprovals,Qf=t.data.sourceRunsByPr,$f=t.data.reviewItemsByPr,ep=t.data.actions,tp=t.data.actionRunsByPr,np=t.data.prActionsByPr,rp=t.data.prActionRunsByPr,lp({kind:`prs`})):u(`reviews`,`dropped pr-flows-status: ${c(t.error.issues)}`)}function bp(e){lp({kind:`merge-result`,message:e})}function xp(e){lp({kind:`connection`,isConnected:e})}qd(fp);var Sp=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}])),Cp={turn:`Your turn`,working:`Agent working`,waiting:`Waiting on others`,aside:`Set aside`},wp=[`turn`,`working`,`waiting`,`aside`],Tp={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`},Ep={settled:`review-settled`,inReview:`review-in-flight`,queued:`review-queued`,posted:`review-posted`,discarded:`review-discarded`};function Dp(e){return e.status===`ready`?If(e).band===`blocking-others`?`review-direct-ask`:`review-ready`:`review-follow-up`}function Op(e,t){return t===`ready`?Dp(e):t===`attention`?`status`in e&&e.status===`error`?`review-failed`:`review-stale`:Ep[t]}function kp(e,t,n){let r=e.state===`OPEN`;if(r&&Of(e,n))return`mine-repair-failed`;if(r&&n&&e.keepMergeable&&e.isKeepMergeableFixInFlight)return`mine-repairing`;let i=Tp[e.stage];return Sp.get(i)?.group===`turn`&&e.stage!==`ready`&&t.has(De(e))?`mine-agent-fixing`:i}function Ap(e,t){return t===`ready`?Ff.indexOf(Vf(e)):t===`queued`?Ff.indexOf(If(e).band):0}function jp(e,t,n,r){let i=Sp.get(e);if(!i)return[];let a=n?Date.parse(n):NaN;return[{item:r(i),row:i,priorityBandRank:t,openedAtMs:Number.isNaN(a)?1/0:a}]}function Mp(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=>jp(Op(t,e),Ap(t,e),t.prCreatedAt,({action:n,kind:r})=>({source:`team`,key:`team:${t.key}`,prKey:De(t),kind:e,review:t,action:n,attention:r}))))}function Np(e,t,n){return xf(e).flatMap(e=>e.rows).flatMap(e=>jp(kp(e.pr,t,n),0,e.pr.createdAt,({action:t,kind:n})=>({source:`mine`,key:`mine:${e.pr.key}`,prKey:De(e.pr),pr:e.pr,stackRow:e,action:t,attention:n})))}function Pp(e,t){return e.row.rank-t.row.rank||e.priorityBandRank-t.priorityBandRank||e.openedAtMs-t.openedAtMs}function Fp(e,t,n,r){let i=new Map(wp.map(e=>[e,[]]));for(let a of[...Mp(e),...Np(t,n,r)])i.get(a.row.group)?.push(a);return wp.map(e=>({id:e,title:Cp[e],items:(i.get(e)??[]).toSorted(Pp).map(e=>e.item)}))}var Ip=[`turn`,`working`,`aside`],Lp=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 Rp(e){return e.status===`ready`&&e.verdict?`ready-${e.verdict}`:e.status}function zp(e){let t=Date.parse(e.item.createdAt);return Number.isNaN(t)?1/0:t}function Bp(e){let t=e.flatMap(e=>{let t=Lp.get(Rp(e));return t?[{row:t,askedAtMs:zp(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 Ip.map(e=>({id:e,title:Cp[e],items:t.filter(t=>t.row.group===e).map(e=>e.item)}))}function Vp(e){return`${e.key}@${e.entry.status}:${e.entry.finishedAt??``}`}function Hp(e){return e.find(e=>e.id===`turn`)?.items??[]}function Up(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function Wp(e,t){return Up(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function Gp(e){return e.source===`mine`?qf(e.pr.repo,e.pr.number):qf(e.review.repo,e.review.number)}function Kp(e,t){return Hp(e).map(e=>({id:e.key,kind:e.attention??`waiting`,name:t(e)}))}function qp(e){return Kp(e,Gp)}function Jp(e,t){return qp(e).filter(e=>e.id!==t)}function Yp({capturedOrder:e,actedKey:t,groups:n}){let r=Hp(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 Xp(e,t){let n=Hp(e).map(e=>e.key),r=t?n.indexOf(t):-1;return r===-1?``:`${r+1} of ${n.length} in Your turn`}function Zp(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 Qp(e){return Hp(e).map(Zp)}function $p({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:bt([...i]),unseen:bt([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:bt([...a]),unseen:bt([...o])}}function em(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 tm(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function nm(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 rm=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 im(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`:rm.get(e.key)??null}function am(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 om=null,sm=null,cm=new Set;function lm(e){for(let t of cm)t(e)}function um(){sm=Pf(om,Kd),lm({kind:`status`})}function dm(e){cm.add(e)}function fm(){return sm}function pm(){return Hf(sm)}function mm(e){let t=Ue.safeParse(e);t.success?(om=t.data,um()):u(`reviews`,`dropped team-review-status: ${c(t.error.issues)}`)}function hm(e){lm({kind:`action-result`,message:e})}function gm(e){lm({kind:`open-session-result`,message:e})}function _m(e){lm({kind:`connection`,isConnected:e})}qd(um);var vm=[],ym=null,bm=null,xm=null,Sm=!1,Cm=null,wm=Mr(),Tm=pr(),Em=new Set(Tm.split(`|`).filter(Boolean)),Dm=new Set,Om=new Set;function km(e){for(let t of Om)t(e)}function Am(e){e!==wm&&(wm=e,$n(e))}function jm(e){e!==Tm&&(Tm=e,Em=new Set(e.split(`|`).filter(Boolean)),or(e))}function Mm(){return fm()!==null&&mp().status!==null}function Nm(){if(!Mm())return;let e=$p({turnEntries:Qp(vm),acknowledged:wm,unseen:Tm,isLooking:bm?.isLooking()??!1});Am(e.acknowledged),jm(e.unseen),Cm?.(e.isShown)}function Pm(e){xm=e,km({kind:`reveal`})}function Fm(e){Om.add(e)}function Im(e){bm=e,Nm()}function Lm(){let{prs:e,sessionsByPrKey:t,status:n}=mp();return vm=Fp(pm(),e,new Set(t.keys()),Df(n)),Nm(),vm}function Rm(){Mm()&&(Am(bt(Qp(vm))),Nm())}function zm(e){Cm=e,Nm()}function Bm(){return Tm}function Vm(e){return Em.has(e)}function Hm(e){return Em.has(e)?(jm(bt([...Em].filter(t=>t!==e))),!0):!1}function Um(e){ym=e}function Wm(){return ym}function Gm(){let e=xm;return xm=null,e}function Km(e){if(e!==Sm){Sm=e;for(let e of Dm)e()}}function qm(e){Dm.add(e)}function Jm(){return document.documentElement.dataset.layout===`phone`&&Sm}function Ym(){Jm()&&km({kind:`return-to-queue`})}function Xm(){let e=Jp(vm,bm?.selectedKey()??null)[0]?.id??null;return e?(Pm(e),!0):!1}function Zm(e){let t=vm.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!ym?.openReviews()?!1:(Pm(t.key),Rm(),!0)}dm(e=>{e.kind===`status`&&Lm()}),pp(e=>{e.kind===`prs`&&Lm()});var Qm={OPEN:0,MERGED:1,CLOSED:2};function $m(e){return e?Qm[e.state]:Qm.OPEN}function eh(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:Kt(void 0)};let i=Tf(t.stage);return{key:n,text:r,detailText:`${r} ${t.title}`,stateText:wf(t.stage),url:t.url,prTitle:t.title,look:{icon:Ef(t.stage),tone:i},tier:Kt(i)}}function th(e,t){let n=e.map(e=>{let n=t(De(e));return{link:e,pr:n?ff(n):void 0}});return n.sort((e,t)=>$m(e.pr)-$m(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>eh(e,t))}var nh=new Map;function rh(e){return document.querySelectorAll(`[data-pr-rows-for="${CSS.escape(e)}"]`)}function ih(e){return th(nh.get(e)??[],Kd).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,onActivate:()=>{Zm(e.key)||Bl(e.url)}}))}function ah(e,t){let n=Ve(`session-pr-chip-unlink`);return n.append(x(gt)),n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),Vt({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:()=>{Qr(t,{type:`unlink-session-pr`,id:t,key:e.key})}})}),n}function oh(e,t){let n=rn({...e,text:e.key},{...e,className:`linked-pr-row-link`});e.prTitle&&n.append(E(`span`,`linked-pr-row-title`,e.prTitle)),e.stateText&&n.append(E(`span`,`linked-pr-row-stage`,e.stateText));let r=E(`li`,`linked-pr-row`);return r.append(n,ah(e,t)),r}function sh(e,t){e.dataset.prRowsFor=t;let n=ih(t);fn(e,n,e=>oh(e,t),{visibleCount:n.length})}function ch(e){for(let t of e){let e=t.dataset.prRowsFor;e&&sh(t,e)}}function lh(e,t){let n=Be.shape.links.safeParse(t??[]);nh.set(e,n.success?n.data:[]),ch(rh(e)),un(e),gp(nh)}function uh(e){nh.delete(e),gp(nh)}qd(()=>{ch(document.querySelectorAll(`[data-pr-rows-for]`)),sn()});function F(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function dh(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function fh(e,t){return e||dh(t)>0}var ph={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},mh=null,hh=!1,gh=!1,_h=null,vh=null,yh=null,bh=`—`;function xh(e){return e==null?bh:wt(e,`GB`)}function Sh(e){return e==null?bh:pe(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function Ch(e){return e==null?bh:`${Sh(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function wh(){let e=E(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=E(`div`,`health-summary`),n=Ve(`health-toggle`);n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=E(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,E(`span`,`health-toggle-label`,`Health`));let i=E(`div`,`health-stats`);t.append(n,i);let a=E(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{gh=!gh,e.dataset.expanded=String(gh),n.setAttribute(`aria-expanded`,String(gh)),a.hidden=!gh,gh&&(_({type:`request-health-snapshot`}),Eh())}),e.append(t,a),_h=e,vh=i,yh=a,e}function Th(){if(!vh||!mh)return;let e=mh,t=dh(e.anomalies);vh.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-DhXDT3zE.js","assets/dom-helpers-Bs-xZEnd.js","assets/ui-prefs-zUfHHNE_.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-CKjlfzoq.js","assets/alert-sound-Da6VQFBS.js","assets/doc-editor-ui-BsVwtyem.js","assets/control-ws-t9cKDDGy.js","assets/button-Cnom-MQM.js","assets/modal-C-Lb5-jJ.js","assets/action-status-B0E-UYey.js","assets/plan-render-DpH9hL6E.js","assets/http-url-B85DM2Ri.js","assets/doc-editor-ui-5jSk9zTx.css","assets/shown-face-DTH_HMvh.js","assets/sandboxed-frame-DDgtJ2Ng.js","assets/resume-dialog-ukLRYAb4.js","assets/card-registry-W9ss4JHS.js","assets/card-actions-unth0mGA.js","assets/plan-face-DReWFWAO.js","assets/ui-state-core-Nssh-6QJ.js","assets/roving-keys-core-BDobx2It.js","assets/plan-face-CNqLL3OW.css","assets/phone-shell-C_5TyptC.js","assets/session-row-bZ0xZako.js","assets/session-tick-CY_ByGke.js","assets/session-actions-ByUeN2DK.js","assets/preload-helper-BLdHbfdN.js","assets/menu-DK4rQWp6.js","assets/pr-status-icon-D1RIxNiH.js","assets/first-run-checklist-CmgKy8Jx.js","assets/setup-step-DTtM5S-5.js","assets/repo-roots-adder-B0wMYrsO.js","assets/boards-view-B_bSKyat.js","assets/boards-view-SutPL47N.css","assets/review-queue-panel-D7EPFEjb.js","assets/lane-read-token-step-B_KgzYQY.js","assets/lane-read-token-step-W8nsxXSA.css","assets/pr-queue-columns-3w9gLVud.js","assets/my-prs-panel-BnX5BWwa.js","assets/team-review-settings-core-BHv0yl1m.js","assets/issues-panel-CI002Sa4.js","assets/issues-panel-1vb6hHuv.css","assets/usage-panel-D-F5UoXU.js","assets/chart-readout-CFE3tWIs.js","assets/usage-panel-DV0ckKqY.css","assets/radar-panel-8_2t93G1.js","assets/dialogs-Rk6V83C7.js","assets/radar-panel-LHOTTm1M.css","assets/community-panel-i92fc4IR.js","assets/community-panel-DR_-RgSK.css","assets/hooks-panel-RR2ZdDf2.js","assets/hooks-panel-BUBv4dvX.css","assets/trace-panel-ws0zMLD_.js","assets/trace-panel-D-AIzBSZ.css","assets/benchmark-panel-CY0VHbkC.js","assets/benchmark-panel-E7vrfppm.css","assets/settings-panel-BTHxXdtR.js","assets/flying-animal-preview-1gEU_KZB.js","assets/settings-panel-X7mCNTBQ.css","assets/feature-hint-B7CA-mZd.js","assets/feature-hint-Dm-eD9Sz.css","assets/your-day-tip-BW0Kb-tN.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 ee,u as _,v,x as te,y as ne}from"./control-ws-t9cKDDGy.js";import{c as y,d as b,g as re,n as ie,o as ae,u as oe}from"./zod-_N0uRWDY.js";import{A as x,Bt as se,C as ce,Cn as le,Ct as ue,D as de,Dn as fe,Dt as pe,Et as me,H as he,Ht as ge,J as _e,K as ve,Lt as ye,M as be,Mn as xe,Mt as Se,N as Ce,Nt as we,O as Te,Ot as S,P as Ee,Pt as De,Q as Oe,Rt as ke,S as Ae,Sn as je,T as Me,Tt as Ne,Ut as Pe,W as Fe,Wt as Ie,Xt as Le,Y as Re,_ as ze,_n as Be,a as Ve,an as He,bn as Ue,c as We,cn as Ge,ct as Ke,dn as qe,dt as Je,f as Ye,g as Xe,gn as Ze,h as Qe,i as $e,in as et,jn as tt,jt as nt,k as rt,kt as it,l as at,ln as ot,mn as st,nn as ct,on as lt,p as ut,q as dt,rn as ft,s as pt,sn as mt,t as C,tn as ht,u as gt,un as _t,v as vt,vn as yt,vt as bt,w as xt,wt as St,x as Ct,xt as wt,yt as Tt,z as Et,zt as Dt}from"./button-Cnom-MQM.js";import{J as Ot,K as kt,X as w,Y as At,_ as jt,b as Mt,f as Nt,g as T,h as Pt,n as Ft,p as It,q as Lt,s as E,t as Rt,u as zt,x as Bt}from"./dom-helpers-Bs-xZEnd.js";import{a as Vt,i as Ht,n as Ut,r as Wt,t as Gt}from"./modal-C-Lb5-jJ.js";import{C as Kt,S as qt,_ as Jt,a as Yt,b as Xt,c as Zt,d as Qt,f as $t,g as en,h as tn,i as nn,l as rn,m as an,n as on,o as sn,p as cn,r as ln,s as un,t as dn,u as fn,v as pn,x as mn,y as hn}from"./session-row-bZ0xZako.js";import{S as gn,_ as _n,a as vn,b as yn,c as bn,f as xn,g as Sn,h as Cn,i as D,m as wn,n as Tn,o as O,r as k,s as En,t as A,u as Dn,x as On,y as kn}from"./card-registry-W9ss4JHS.js";import{n as j,t as An}from"./ui-state-core-Nssh-6QJ.js";import{t as M}from"./preload-helper-BLdHbfdN.js";import{i as jn,n as Mn,o as Nn,r as Pn,s as Fn,t as In,u as Ln}from"./action-status-B0E-UYey.js";import{a as Rn,c as zn,i as Bn,n as Vn,o as Hn,r as Un,s as Wn,t as Gn}from"./session-tick-CY_ByGke.js";import{n as Kn,t as qn}from"./local-store-CVQ5ByvB.js";import{$ as Jn,C as Yn,D as Xn,E as Zn,G as Qn,H as $n,K as er,L as tr,O as nr,Q as rr,S as ir,T as ar,W as or,Y as sr,at as cr,b as lr,c as ur,dt as dr,et as fr,f as pr,ft as mr,g as hr,gt as gr,h as _r,i as vr,it as yr,l as br,m as xr,mt as Sr,n as Cr,nt as wr,p as Tr,q as Er,r as Dr,rt as Or,s as kr,t as Ar,tt as jr,u as Mr,v as Nr,vt as Pr,x as Fr,y as Ir}from"./ui-prefs-zUfHHNE_.js";import{t as Lr}from"./http-url-B85DM2Ri.js";import{C as Rr,D as zr,E as Br,I as Vr,O as Hr,S as Ur,T as Wr,_ as Gr,a as Kr,b as qr,c as Jr,d as Yr,f as Xr,g as Zr,h as Qr,i as $r,k as ei,l as ti,m as ni,o as ri,u as ii,v as ai,w as oi,x as si,y as ci}from"./session-actions-ByUeN2DK.js";import{n as li}from"./card-actions-unth0mGA.js";import{n as ui,t as di}from"./roving-keys-core-BDobx2It.js";import{n as fi}from"./menu-DK4rQWp6.js";import{t as pi}from"./pr-status-icon-D1RIxNiH.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 mi={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},hi=null,gi=null,_i=!0,vi=new Map,yi=new Map,bi=new Set;function xi(){for(let e of bi)e()}function Si(e){bi.add(e)}function Ci(){return{status:hi,isServerConnected:_i,pendingActionBySuite:vi,outcomeBySuite:yi}}function wi(e){gi=e}function Ti(e,t){gi?.({type:`benchmark-action`,requestId:h(`benchmark`),suiteId:e,action:t})===!0?(vi.set(e,t),yi.set(e,mi[t]),xi()):(yi.set(e,Ee),xi())}function Ei(e){if(_i=e,!e){for(let e of vi.keys())yi.delete(e);vi.clear()}xi()}function Di(e){hi=e,xi()}function Oi(e){vi.delete(e.suiteId);let t=hi?.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.`};yi.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),xi()}function ki({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=Wt({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=E(`div`,`coherence-journal-header`),s=E(`h3`,`dialog-title`,t);s.id=n;let c=C({variant:`secondary`,label:`Close`,action:`close-coherence-panel`,onClick:i});return o.append(s,c),a.dialog.append(o,...r),Gt(a.dialog,s.id),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function Ai({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=ki({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(),_(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 ji={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 Mi(e){return e?.active!==!1||e.reason===Le.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,detailText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:qt.broken}]}function Ni(e){let t=ye.safeParse(e.kind);return{heading:`${t.success?ji[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function Pi(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 Fi=new Map,Ii=new Map,Li=Ai({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function Ri(e,t){Ii.delete(e),t&&Ii.set(e,t),Wi(e)}function zi(e){Fi.delete(e),Ii.delete(e);let t=Li.currentPanel();t?.sessionId===e&&t.close()}function Bi(e){let t=Fi.get(e.id);t&&t.updatedAt>e.updatedAt||(Fi.set(e.id,e),Wi(e.id))}function Vi(e){Fi.clear();for(let[t,n]of Object.entries(e.sessions))Fi.set(t,n);let t=Li.currentPanel();t&&Wi(t.sessionId)}function Hi(e){return Mi(Ii.get(e)??null).map(t=>({...t,onActivate:()=>Gi(e)}))}function Ui(e){return Fi.get(e)?.journal.ok===!0}function Wi(e){let t=Li.currentPanel();if(!t||t.sessionId!==e)return;let n=Pi(Ii.get(e)??null,Fi.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>E(`p`,null,e)))}function Gi(e){let t=E(`div`,`coherence-journal-reading`),n=E(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=E(`div`,`coherence-journal-entries`);Li.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>Wi(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function Ki(e){let t=Li.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=Ni(e),n=E(`article`,`coherence-journal-entry`);return n.append(E(`h4`,null,t.heading),E(`p`,null,t.text)),t.detail&&n.append(E(`p`,null,t.detail)),t.supersedes&&n.append(E(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var qi=[`running`,`waiting`,`failed`,`monitoring`,`done`,`initializing`,`idle`,`starting`,`complete`],Ji=new Set([`waiting`,`monitoring`]),Yi={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`}},Xi={dark:{black:`--border`,brightBlack:`--text-muted`,white:`--text`,brightWhite:`--text-head`},light:{black:`--text-head`,brightBlack:`--text-dim`,white:`--text-dim`,brightWhite:`--text`}},Zi=.35;function Qi(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 $i(e){let t={};for(let n of qi){let r=Ji.has(n)?8:6;t[`--state-${n}`]=e[n],t[`--state-${n}-bg`]=`color-mix(in oklab, var(--state-${n}) ${r}%, transparent)`}return t}function ea(e){if(e.accentAnsiSlot===`none`)return{};let t=`bright${e.accentAnsiSlot[0].toUpperCase()}${e.accentAnsiSlot.slice(1)}`;return{[e.accentAnsiSlot]:`--accent`,[t]:Qi(e.chrome.accent,Zi)}}function ta(e){let t=Object.fromEntries(Object.entries(e.chrome).map(([e,t])=>[`--${e}`,t]));return{label:e.label,colors:{...t,...$i(e.states)},terminal:{background:`--bg-card`,foreground:`--text`,cursor:`--accent`,cursorAccent:`--bg-card`,...Xi[e.mode],...Yi[e.mode],...ea(e)}}}var na={golgari:ta({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:ta({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:ta({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:ta({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:ta({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":ta({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":ta({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`}})},ra=`phyrexian`,ia=null,aa=null;function oa(e){let t=na[e];if(!t)return;let n=aa;aa=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`&&ia?.()}function sa(e){ia=e}function ca(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function la(){let e=na[aa||ra];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 ua(){return Object.entries(na).map(([e,t])=>({id:e,label:t.label}))}function da(){let e=la();e.background&&e.foreground&&_({type:`terminal-colors`,background:e.background,foreground:e.foreground})}var fa=3e4,pa=24,ma=null,ha=[`Android`,`iPhone`,`iPad`,`Windows`,`Mac OS X`,`Linux`],ga=[/Firefox\/\d+/,/Edg\/\d+/,/Chrome\/\d+/,/Version\/\d+/];function _a(){let e=navigator.userAgent,t=ha.find(t=>e.includes(t))??`unknown platform`;return`${ga.map(t=>t.exec(e)?.[0]).find(e=>e!==void 0)?.replace(`Version`,`Safari`)??`unknown browser`} on ${t}`}function va(){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 ya(){return[navigator.onLine?`online`:`offline`,...va()].join(` `)}function ba(e,t){let n=[],r=0;for(let i of e){let e=i.length+1;if(r+e>t)break;n.push(i),r+=e}return{takenMarks:n,usedChars:r}}function xa(e,t){let n=e.join(` `);if(n.length<=t)return n;let r=t-pa,i=ba(e,r/2),a=ba(e.slice(i.takenMarks.length).reverse(),r-i.usedChars),o=e.length-i.takenMarks.length-a.takenMarks.length;return[...i.takenMarks,`(${o} marks dropped)`,...a.takenMarks.reverse()].join(` `)}function Sa(e){return e.marks.some(e=>e.startsWith(`terminal-bytes`))}function Ca(e){let t=Sa(e)&&!e.isCapped?`terminal live`:`terminal not live after ${fa/1e3} s`,n=`hidden ${Math.round(e.hiddenForMs/1e3)} s, ${t}, ${_a()}, ${e.networkAtWake}: `,r=n+xa(e.marks,ge-n.length);return _({type:`client-log`,scope:`wake`,text:r.slice(0,ge)})}function wa(){let e=ma;e&&(e.isCapped||Sa(e))&&Ca(e)&&(ma=null,clearTimeout(e.capTimer))}function Ta(){ma&&(ma.isCapped=!0,wa())}function Ea(e,t){e.marks.push(`${t}+${Math.round(performance.now()-e.startedAtMs)}`)}function Da(e){ma&&(e===`terminal-bytes`&&Sa(ma)||(Ea(ma,e),(e===`terminal-bytes`||e===`control-opened`)&&wa()))}function Oa(e){ma&&Ea(ma,e===`link`?[`link`,...va()].join(`-`):e)}function ka(e,t){ma||={startedAtMs:performance.now(),hiddenForMs:t,networkAtWake:ya(),marks:[],isCapped:!1,capTimer:setTimeout(Ta,fa)},Da(e)}function Aa(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function ja(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 Ma=null,Na=null;function Pa(){return Ma}function Fa(){return Ma?Promise.resolve(Ma):(Na??=Promise.all([M(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.t),__vite__mapDeps([0,1])),M(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.r),__vite__mapDeps([0,1])),M(()=>import(`./xterm-CdMfg81L.js`).then(e=>e.n),__vite__mapDeps([0,1]))]).then(([e,t,n])=>(Ma={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},Ma)).catch(e=>{throw Na=null,e}),Na)}var Ia=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,La=new Map;function Ra(e){return e.clientWidth>0&&e.clientHeight>0}function za(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 Ba(e){La.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,za(e)}function Va(e){let t=[e],n=j.snapshot().borrowedCardId,r=n?O.get(n):void 0;r&&t.push(r);for(let e of ja([...La.keys()],Ia,t))Ba(e),e.needsWebGLReload=!0}function Ha(e){e?.term&&Aa({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:Ra(e.termWrap)})&&qa(e,{isForced:!0})}function Ua(){for(let e of La.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{Ba(e),e.needsWebGLReload=!0}}}var Wa=!1;function Ga(){Wa||(Wa=!0,requestAnimationFrame(()=>{Wa=!1,Ua()}))}function Ka(e){e?.addEventListener(`contextrestored`,Ga)}function qa(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){La.delete(e),La.set(e,!0);return}e.webglAddon&&(za(e),La.delete(e));let n=Pa();if(!n)return;Va(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,La.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(Ka),r.onAddTextureAtlasCanvas(Ka),Ka(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!Ra(e.termWrap),La.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,La.delete(e)}}var Ja=`(max-width: 768px)`,Ya=`(pointer: coarse)`;function Xa({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var Za=window.matchMedia?.(Ya),Qa=window.matchMedia?.(Ja);function $a(){return Xa({coarse:!!Za?.matches,narrowWidth:!!Qa?.matches})}function eo(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function to(){j.subscribe((e,t)=>{t.includes(`layout`)&&eo(e.layout)});let e=$a();eo(e),j.dispatch(`setLayout`,e);let t=()=>j.dispatch(`setLayout`,$a());return Za?.addEventListener?.(`change`,t),Qa?.addEventListener?.(`change`,t),e}function no(){return j.snapshot().layout===`phone`}function ro(e){return j.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var io=``,ao=`\x1B`,oo=`\r`,so=new Map([[`deleteContentBackward`,io],[`deleteByComposition`,io],[`deleteCompositionText`,io],[`deleteWordBackward`,ao],[`deleteSoftLineBackward`,ao],[`deleteHardLineBackward`,ao]]);function co(e){return so.get(e)??``}var lo=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function uo(e){return typeof e!=`string`||e===``||!lo.has(e)}function fo(e){return e?e.keyCode===229||e.key===`Process`:!1}function po(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 io.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,oo)}var mo=`Upload`;async function ho(e,t){return Mn(mo,e),_o(e,t)}async function go(e,t){Mn(mo,e);for(let n of t)await _o(e,n)}async function _o(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:(Nn({source:mo,sessionId:e,message:await vo(r,t.name)}),!1)}catch{return Nn({source:mo,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 vo(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 yo=new WeakMap,bo=5e3,xo=15e3,So=`The agent copied text. The browser needs a click before it can reach your clipboard.`,Co=`The clipboard is unavailable in this browser.`;function wo(e,t,n,r){let i=yo.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(()=>To(e,t),n===`ok`?bo:xo)))}function To(e,t){let n=yo.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function Eo(e){let t=e.buffer.active;return t.viewportY<t.baseY}function Do(e,t,{hasNewOutput:n=!1}={}){let r=yo.get(e)?.jumpToLatest;if(!r)return;let i=Eo(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function Oo(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 ko(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),wo(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function Ao(e,t,n,r){let i=Mt(t);i?i.then(()=>{r&&wo(e,`clipboard`,`ok`,r)}).catch(t=>ko(e,n,t)):wo(e,`clipboard`,`error`,Co)}function jo(e,t){let n=yo.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function Mo(e){let t=yo.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,Ao(e,n,`osc52 write`,`Copied to the clipboard.`))}function No(e,t,n){let r=jn(`terminal-notice`),i=E(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=C({variant:`primary`,label:`Copy to clipboard`,onClick:()=>Mo(t)});i.append(E(`span`,`terminal-clipboard-prompt-text`,So),a);let o=E(`div`,`terminal-notices`);o.append(i,r.element);let s=E(`div`,`terminal-jump-latest`);s.hidden=!0,s.append(C({variant:`secondary`,label:`Jump to latest`,onClick:()=>{n.scrollToBottom(),n.focus()}}),E(`span`,`terminal-jump-latest-new-output`));let c=E(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(E(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),yo.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatest:s})}var Po=1024,Fo=`Keys you type now are held and sent once the terminal reconnects.`,Io=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,Lo=!1;function Ro(e){let t=e._inputQueue,n=e.dataWs;if(!Lo&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,To(e,`keys`)}}function zo(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!Lo&&!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>=Po?(wo(e,`keys`,`error`,Io),!1):(e._inputQueue.push(t),r&&wo(e,`keys`,`busy`,Fo),!0)}function Bo(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,no()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=po(i,r.value);return i=r.value,e!==``&&(zo(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{no()?n(e):a()},!0)};c(`keydown`,e=>{fo(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(!uo(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=co(e.inputType);r!==``&&(zo(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function Vo(e){return!!e&&Array.from(e.types).includes(`Files`)}function Ho(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),go(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{Vo(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,Vo(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),go(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function Uo(e){Lo=e}var Wo=6,Go=262144,Ko=16384,qo=()=>{};function Jo(e,t){if(t.length<=Ko)e.push(t);else for(let n=0;n<t.length;n+=Ko)e.push(t.slice(n,n+Ko))}function Yo({budget:e=Wo,maxChunkBytes:t=Go,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)Jo(l,e),m+=e.length,a.readIdx++;else{m===0&&(Jo(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,qo);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 Xo=Yo(),Zo=oe().int().min(1).max(500),Qo=oe().int().min(1).max(200);ae(`type`,[b({type:y(`input`),data:re()}),b({type:y(`claim`),cols:Zo,rows:Qo}),b({type:y(`unview`)}),b({type:y(`pause-output`)}),b({type:y(`resume-output`)})]);var $o=b({type:y(`pty-size`),cols:Zo,rows:Qo,seq:oe().int().nonnegative()}),es=b({type:y(`output-beat`)}),ts=ae(`type`,[$o,es]),ns=`history`,rs=`output`,is=`paused`;ie([`screen`,`deep`]);function as(e){try{return JSON.parse(e)}catch{return null}}function os(e){let t=ts.safeParse(as(e));return t.success?t.data:null}var ss=new Set([1,5,25,100]);function cs(e){return e.isOutputPaused?`${e.history} paused`:e.history}function ls(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function us(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 fs({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&ls(e,n))}function ps({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function ms({isBorrowedCard:e,isTerminalFaceShown:t}){return!e||!t}function hs({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function gs(e,t,n){let r=new URLSearchParams;t&&r.set(ns,`deep`),n&&r.set(rs,is);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function _s({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:fs({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function vs({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function ys({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!ls(e,t),s=us(n)?ds(n):null,c=r&&!!s&&!ls(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:fs({authoritative:e,isActiveViewer:r,lastClaim:a})}}function bs(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function xs(e){let t=bs(e);return t===null?null:os(t)}function Ss(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=xs(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 Cs=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,ws=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,N=`[^\\S\\r\\n]`,Ts=`${Cs}${N}*(?:=>|[:=])${N}*`,Es=`[?&][A-Za-z0-9_.-]*`,Ds=`[^\\r\\n;&|]{0,200}?`,Os=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,ks=RegExp(`(${Ts})${ws}`,`gi`),As=RegExp(`(\\bBearer${N}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),js=[/\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],Ms=[RegExp(`((?:^|\\s)--?${Cs}${N}+)${ws}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${N}*=?${N}*)${ws}`,`g`),RegExp(`(-AsPlainText${N}+)${ws}`,`gi`),RegExp(`((?:^|\\s)setx${N}+[^\\s\\r\\n]*${Cs}[^\\s\\r\\n]*${N}+)${ws}`,`gi`)],Ns=[RegExp(`(\\bauthorization${N}*:${N}*Basic${N}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${N}+login\\b${Ds}${N}-p(?:${N}+|=))${ws}`,`gi`),RegExp(`(\\bcurl\\b${Ds}${N}(?:--user|-u)(?:${N}+|=)[^\\s:\\r\\n]+:)${ws}`,`gi`),RegExp(`(\\b${Os}\\b${Ds}${N}-p)${ws}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi],Ps=[/-----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],Fs=RegExp(`(${Es}(?:${Cs}|_key)=)[^&#\\s]+`,`gi`),Is=[ks,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${ws}`,`g`)],Ls=[As,...Ms,...Ns,...js,...Ps];function Rs(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function zs(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 Bs(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 Vs(e){let t=Rs(e,Fs);return Bs([...t,...Is.flatMap(n=>zs(Rs(e,n),t)),...Ls.flatMap(t=>Rs(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var Hs=`glimmervoid-streamer-mode`,Us=new Set,Ws=qn(Hs,!1)===!0;function Gs(e){document.documentElement.toggleAttribute(`data-streamer`,e)}Gs(Ws);function Ks(){return Ws}function qs(e){if(Kn(Hs,e),e!==Ks()){Ws=e,Gs(e);for(let t of Us)t(e)}}function Js(e){return Us.add(e),()=>Us.delete(e)}async function Ys(e){try{let t=await a(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:In});return t.type===`settings-error`?String(t.message):(qs(e),``)}catch(e){return Fn(e,In)}}var Xs=`Streamer mode`;async function Zs(){let e=!Ks();e&&qs(!0);let t=await Ys(e);t?Nn({source:Xs,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}):Mn(Xs)}function Qs(){Zs()}var $s=`#808080`,ec=new WeakMap;function tc(e,t,n){return`${e}:${t}:${n}`}function nc(e){return tc(e.marker.line,e.x,e.width)}function rc(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function ic(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function ac(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function oc(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 sc(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 cc(e,t,n,r){let i=[];if(Vs(ac(e,t,n)).length===0)return i;let{text:a,cellAt:o}=oc(e,t,n,r);for(let e of Vs(a))sc(i,o.slice(e.start,e.end));return i}function lc(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=ic(e,i);r.push(...cc(e,i,t,n)),i=t+1}return r}function uc(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function dc(e){e.decoration.dispose(),e.marker.dispose()}function fc(e){for(let t of e.masks)dc(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function pc(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function mc(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 hc(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(nc(r),r),r=e.masks.at(-1);return mc(e),n}function gc(e,t){let n={normal:uc(),alternate:uc()},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??$s,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(!Ks())return;let t=e.buffer.active,r=n[t.type],i=rc(t,pc(r,t)),a=hc(r,i);for(let e of lc(t,i)){let n=tc(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(){fc(n.normal),fc(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=>{fc(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=Js(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),ec.delete(e)},{once:!0}),ec.set(e,d)}function _c(e){ec.get(e)?.()}function vc({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var yc=`-4 -4 108 108`,bc=Object.freeze([{side:`top`,d:`M33 29L50 12L67 29`},{side:`right`,d:`M71 33L88 50L71 67`},{side:`bottom`,d:`M67 71L50 88L33 71`},{side:`left`,d:`M29 67L12 50L29 33`}]),xc=`M50 39L61 50L50 61L39 50Z`,Sc=11,Cc=`#e8e0ff`,wc=`#c084fc`;function Tc({frame:e,light:t,strokeWidth:n=Sc}){return`<path d="${bc.map(({d:e})=>e).join(``)}" fill="none" stroke="${e}" stroke-width="${n}" stroke-linejoin="miter" stroke-linecap="butt"/><path d="${xc}" fill="${t}"/>`}function Ec(e,t){return ms({isBorrowedCard:j.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var Dc=new WeakMap,Oc=new WeakMap,kc=new WeakSet,Ac=new WeakSet,jc=new WeakSet;function Mc(e,t){if(Dc.has(e)||!Eo(t))return;let n=t.buffer.active,r=n.length-n.viewportY;kc.has(e)?Dc.set(e,r):Oc.set(e,r)}function Nc(e,t,n){let r=e.term;r&&hs({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:kc.has(e)})&&(kc.add(e),Ac.add(e),Dc.set(e,r.buffer.active.length-n),sl(t))}var Pc=new WeakMap;function Fc(e,t){return document.visibilityState===`visible`&&!Ec(e,t)}function Ic(e,t){if(e&&Zc(e,t))return;let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=Fc(e,t);Pc.get(n)!==r&&(Pc.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function Lc(){for(let[e,t]of O)Ic(t,e)}document.addEventListener(`visibilitychange`,Lc),j.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&Lc()});function Rc(e,t){return O.get(e)===t&&!t.dataWs}function zc(e){return e.querySelector(`:scope > .terminal-connecting`)}function Bc(){let e=be(`svg`,{class:`loading-mark`,viewBox:yc,"aria-hidden":`true`});for(let{side:t,d:n}of bc)e.append(be(`path`,{class:`loading-mark-bracket`,"data-side":t,d:n}));return e}function Vc(e){if(zc(e))return;let t=E(`div`,`terminal-connecting`);t.append(Bc(),E(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}var Hc=new Set,Uc=new WeakSet;function Wc(e){return Hc.add(e),()=>Hc.delete(e)}function Gc(){let e=0;for(let[t,n]of O)n.card.dataset.link===`connecting`&&Fc(n,t)&&e++;return e}function Kc(e){let t=vc({hasTerminal:e.term!==null||Uc.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:Lo}),n=t===`connecting`&&!Lo&&Ac.has(e)?`live`:t;n===`none`?(delete e.card.dataset.link,qc()):(e.card.dataset.link=n,qc())}function qc(){for(let e of Hc)e()}function Jc(e,t,n){Mc(t,n),Xo.unregister(e),t.dataWs=null,Kc(t),t._resetGridClaim?.()}var Yc=new WeakMap;function Xc(e,t,r,i){Jc(e,t,r),clearTimeout(Yc.get(t)),Yc.delete(t),i===0&&v()?ol(e,t,r):Yc.set(t,setTimeout(()=>{Yc.delete(t),Rc(e,t)&&n().catch(()=>{}).then(()=>{Rc(e,t)&&ol(e,t,r)})},i))}function Zc(e,t){let n=jc.has(e),r=!e.dataWs&&O.get(t)===e;return!(n||r)||!e.term||!Fc(e,t)?!1:(jc.delete(e),e._dataWsRetryAttempt=0,Xc(t,e,e.term,0),!0)}function Qc(e,t,n){Jc(e,t,n),jc.add(t)}var $c=15e3,el=new Map;function tl(e){if(!v()||el.has(e)||O.get(e)?.dataWs)return;let n=gs(e,!1,!1),r=new WebSocket(t(location,ne(n)));r.binaryType=`arraybuffer`;let a=[],o=e=>a.push(e),s=()=>nl(e,r),c=()=>{r.readyState===WebSocket.CONNECTING&&s()};r.addEventListener(`message`,o),r.addEventListener(`close`,s);let l=setTimeout(c,i),u=setTimeout(s,$c);el.set(e,{socket:r,attachPath:n,bufferedMessages:a,release:()=>{r.removeEventListener(`message`,o),r.removeEventListener(`close`,s),clearTimeout(l),clearTimeout(u)}})}function nl(e,t){let n=el.get(e);n?.socket===t&&(el.delete(e),n.release(),t.close())}function rl(e,t){let n=el.get(e);if(!n)return null;let r=n.socket.readyState===WebSocket.CONNECTING||n.socket.readyState===WebSocket.OPEN;return n.attachPath!==t||!r?(nl(e,n.socket),null):(el.delete(e),n.release(),n)}var il=new WeakMap;function al(e,t,n){if(t.openedAtMs===null)return;let r=Math.round(performance.now()-t.openedAtMs);if(r>=1e3){il.delete(e);return}let i=(il.get(e)??0)+1;if(il.set(e,i),!ss.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 ol(n,r,a){jc.delete(r);let o=Dc.get(r);Dc.delete(r);let c=Oc.get(r);Oc.delete(r);let l=o!==void 0,u=o??c,d=!1,f=Fc(r,n),p=gs(n,l,!f),m=rl(n,p),h=m?.socket??new WebSocket(t(location,ne(p)));Pc.set(h,f),h.binaryType=`arraybuffer`,r.dataWs=h,f&&Da(`terminal-connecting`),Kc(r);let g=!1,ee=!1,_={sessionId:n,attachDescription:cs({history:l?`deep`:`screen`,isOutputPaused:!f}),openedAtMs:null,hasReceivedBytes:!1},v={hasSeenSize:!1,lastSeq:0},te=setTimeout(()=>{h.readyState===WebSocket.CONNECTING&&(ee=!0,f&&Da(`terminal-abandoned`),h.close())},i);Xo.register(n,(e,t)=>a.write(e,t));let y=e=>{if(r.dataWs!==h)return;let t=Ss(e.data,v);if(t.kind===`bytes`){_.hasReceivedBytes=!0,Hn(r),Pc.get(h)&&Da(`terminal-bytes`);let e=d;if(d=!1,Xo.enqueue(n,t.data),!e)return;let i=u??0;Xo.enqueueAction(n,()=>{a.scrollToLine(Math.max(0,a.buffer.active.length-i))});return}if(t.kind===`beat`){Hn(r);return}if(t.kind===`attach-size`){d=u!==void 0,l||kc.delete(r),v.hasSeenSize=!0,v.lastSeq=t.seq,a.reset(),_c(a),r.ptySize={cols:t.cols,rows:t.rows},r._syncGrid?.();return}if(t.kind!==`size`)return;v.lastSeq=t.seq;let i={cols:t.cols,rows:t.rows};Xo.enqueueAction(n,()=>{r.ptySize=i,r._syncGrid?.()})};h.addEventListener(`message`,y),h.addEventListener(`close`,t=>{if(clearTimeout(te),r.dataWs!==h)return;if(al(r,_,t),f&&!ee&&Da(`terminal-closed`),Ac.delete(r),!g&&!ee&&s(),!Fc(r,n)){Qc(n,r,a);return}if(ee){Xc(n,r,a,0);return}let i=e(r._dataWsRetryAttempt||0);r._dataWsRetryAttempt=(r._dataWsRetryAttempt||0)+1,Xc(n,r,a,i)});let b=()=>{clearTimeout(te),g=!0,_.openedAtMs=performance.now(),f&&Da(`terminal-opened`),r._dataWsRetryAttempt=0,Ac.delete(r),Kc(r),Ic(r,n),r._syncGrid?.({isActivationEdge:!0}),r._retryOwedGridClaim?.(),r._inputQueue?.length&&setTimeout(()=>{r.dataWs===h&&Ro(r)},50)};h.addEventListener(`open`,b),h.readyState===WebSocket.OPEN&&b();for(let e of m?.bufferedMessages??[])y(e)}function sl(e){let t=k(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,Xc(e,t,t.term,0),n?.close()}function cl(){for(let[e,t]of O)t.term&&(Fc(t,e)?sl(e):ll(e,t,t.term))}function ll(e,t,n){let r=t.dataWs;r&&(Qc(e,t,n),r.close())}function ul(){for(let[e,t]of O)t.term&&ll(e,t,t.term)}function dl(e,t){let n=e.dataWs;e.dataWs=null,Xo.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}var fl=`CommitMono`,pl=[400,700].map(e=>`${e} 14px ${fl}`),ml=`monospace`;function hl(e){return e.trim().replace(/^['"]|['"]$/g,``)}function gl(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>hl(e)!==fl);return r.length>0?r.join(`, `):ml}function _l(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function vl(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function yl(){return document.fonts?pl.every(e=>document.fonts.check(e)):!1}function bl(){return gl(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),yl())}function xl(e){document.fonts&&_l(document.fonts,pl,e)}var Sl=Pr(navigator.userAgent),Cl=`next-attention-keys`,wl=br();function Tl(){return wl}function El(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(E(`span`,`shortcut-sep`,`+`)),e.appendChild(E(`kbd`,`kbd`,t))})}function Dl(e){let t=E(`span`,`shortcut-keys`);return El(t,e),t}function Ol(){let e=Dl(gr(`next-attention`,Sl,wl));return e.classList.add(Cl),e}function kl(e){wl=e;let t=gr(`next-attention`,Sl,e);for(let e of document.querySelectorAll(`.${Cl}`))e.replaceChildren(),El(e,t)}var Al=/\bElectron\/\d/,jl=new Set([`localhost`,`127.0.0.1`]);function Ml(e){return Al.test(e)}function Nl({userAgent:e,pageHostname:t}){return Ml(e)&&jl.has(t)}function Pl(e){return Lr(e)!==null}var Fl=new Set([0,1]);function Il({button:e,opensInNewTab:t}){return t&&Fl.has(e)}function Ll(){return Nl({userAgent:navigator.userAgent,pageHostname:location.hostname})}function Rl(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function zl(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 Bl(e){!Ll()||!Pl(e)?Rl(e):zl(e).then(t=>{t||Rl(e)})}function Vl(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&Il({button:e.button,opensInNewTab:t.target===`_blank`})&&Pl(t.href)&&(e.preventDefault(),Bl(t.href))}function Hl(e){Ll()&&(e.addEventListener(`click`,Vl,!0),e.addEventListener(`auxclick`,Vl,!0))}var Ul=/https?:\/\/[^\s<>"']+/g,Wl=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),Gl={")":`(`,"]":`[`,"}":`{`};function Kl(e,t){let n=0;for(let r of e)r===t&&n++;return n}function ql(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(Wl.has(t)){e=e.slice(0,-1);continue}let n=Gl[t];if(n&&Kl(e,n)<Kl(e,t))e=e.slice(0,-1);else return e}}function Jl(e){let t=[];for(let n of e.matchAll(Ul)){let e=ql(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var Yl=50;function Xl(){return{activate(e,t){Bl(t)},allowNonHttpProtocols:!1}}function Zl(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<Yl;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<Yl;)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 Ql(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=Zl(r,t),o=[];for(let{start:e,end:t,url:n}of Jl(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){Bl(t)}})}n(o.length?o:void 0)}})}var $l=10,eu=1.2,tu=.005,nu=4,ru=.08,iu=5;function au(e,t){let n=Math.abs(t);return n<$l?!1:n>Math.abs(e)*eu}function ou(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 su(e,t,n){let r=e.length>=nu?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function cu(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>=ru))return 0;let o=Math.min(a,iu);return i<0?-o:o}function lu({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function uu(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)-tu*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=ou(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 fu(e,t){return!(e>0)||!(t>0)?0:e/t}var pu=1;function mu(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function hu(e,t){for(let n of e)if(n.identifier===t)return n;return null}function gu(e,t){if(mu(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 fu(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:pu,clientX:n,clientY:r,bubbles:!0,cancelable:!0}))},ee=()=>{if(d=null,!u)return;if(!e.isConnected||!n()||p()){f();return}let r=t.buffer?.active?.viewportY,{scrollLines:i,state:a}=uu(u,performance.now());u=a,i!==0&&t.scrollLines(i),u&&(i!==0&&t.buffer?.active?.viewportY===r?f():d=requestAnimationFrame(ee))},_=(e,t,n)=>{u=lu({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:m(),pendingPx:n}),u&&(d=requestAnimationFrame(ee))};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=hu(e.touches,r);if(!u)return;if(!s){if(!au(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=su([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=su(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=ou(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=su(l,o,e.timeStamp);let t=cu(l),n=c;h(),t!==0&&_(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function _u(e){let t=Sr(e,Sl,{isTerminalFocused:!0},Tl());return t?dr(t,document.body.dataset.activeView):!1}var vu=250,yu=`(max-width: 768px)`,bu=12,xu=14,Su=5e4,Cu=!1;function wu(e){Cu=e}var Tu=!1;window.addEventListener(`blur`,()=>{Tu=!0}),window.addEventListener(`focus`,()=>{Tu=!1});function Eu(e){let t=document.activeElement;return ps({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:Tu,isPhoneLayout:no()})}function Du(e,t,n){let r=window.matchMedia?.(yu).matches?bu:xu,i=new n.Terminal({cursorBlink:Cu,fontSize:r,fontFamily:bl(),theme:la(),scrollback:Su,allowProposedApi:!0,linkHandler:Xl()}),a=new n.FitAddon;i.loadAddon(a),Vc(e),i.open(e),No(e,t,i),Ql(i),gc(i,t.abortController.signal),t.term=i,t.fitAddon=a,Ba(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||!Eu(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=fs({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)},vu)}function h(){u&&s===null&&p(u)}function g({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=ys({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 ee(){let e=_s({authoritative:t.ptySize??null,isActiveViewer:c,isDocumentEngaged:Eu(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:l});e!==`none`&&(d(),e===`rebid`&&(l=null),g({isActivationEdge:!0}))}let _=new ResizeObserver(()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,g()}))});_.observe(e),t.resizeObserver=_,t._syncGrid=g,t._resetGridClaim=()=>{d(),u=vs({isActiveViewer:c,lastClaim:l,owedClaim:u}),l=null},t._retryOwedGridClaim=h,t._syncGridOnEngagementEdge=ee,t._isActiveViewer=()=>c,t._setActiveViewer=e=>{c!==e&&(c=e,d(),u=null,e&&Ha(t),g({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{Tu=!1,ee()},{signal:t.abortController.signal}),qa(t);let v=null;i.onScroll(()=>{v===null&&(v=requestAnimationFrame(()=>{v=null,t.term&&(t.term.refresh(0,t.term.rows-1),Do(t,t.term))}))}),i.onWriteParsed(()=>Do(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=Oo(r)}catch(e){return ko(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(Ao(t,i,`osc52 write`),!0):(jo(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`&&zo(t,`\x1B\r`),!1;if(e.type!==`keydown`)return!0;if(_u(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),Ao(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(zo(t,`\x1B`),!1):!0}),Bo(e,i,t),gu(e,i)}function Ou(){Uo(!0);for(let e of O.values())Kc(e)}function ku(){Uo(!1);for(let e of O.values())Kc(e),Ro(e)}function Au(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{zo(e,n),e.unseenOutcome&&_({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{Nc(e,t,n)}),Ho(e.termWrap,t,e.abortController.signal),Kc(e),queueMicrotask(()=>{Rc(t,e)&&ol(t,e,n)}))}function ju(e,t){if(e.term||Uc.has(e))return;let n=Pa();if(n){Mu(e,t,n);return}Uc.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},Vc(e.termWrap),Kc(e),Fa().then(n=>{Uc.delete(e),!(e.term||e.abortController.signal.aborted||O.get(t)!==e)&&(Mu(e,t,n),e._setActiveViewer?.(r))},()=>{Uc.delete(e),Kc(e)})}function Mu(e,t,n){Du(e.termWrap,e,n),Au(e,t)}function Nu(e){e?._syncGridOnEngagementEdge?.()}function Pu(e,t){if(!e)return;ju(e,t),Ic(e,t),Ha(e);let n=e.term;n&&(n.refresh(0,n.rows-1),Nu(e))}function Fu(e,t,n){e&&(n&&ju(e,t),e._setActiveViewer?.(n))}var Iu={isVisible:document.visibilityState===`visible`,isFrozen:!1,isProbing:!1,isReplacing:!1},Lu=document.visibilityState===`visible`?null:Date.now(),Ru=null,zu=null;function Bu(){Ru!==null&&window.clearTimeout(Ru),Ru=null}function Vu(e){Bu();let t=Date.now()+e;Ru=window.setTimeout(()=>{Ru=null,Wu({kind:`heartbeat-due`,lateByMs:Date.now()-t})},e)}function Hu(){zu!==null&&window.clearTimeout(zu),zu=null}function Uu(e){switch(e.kind){case`probe-control`:p(e.deadlineMs,e.isAnnounced).then(e=>{Wu({kind:e?`pong`:`pong-missed`})});return;case`replace-control`:g();return;case`close-sockets`:Hu(),ee(),ul();return;case`reconnect-shown-terminals`:cl();return;case`hold-input`:Ou();return;case`release-input`:ku();return;case`schedule-heartbeat`:Vu(e.inMs);return;case`cancel-heartbeat`:Bu();return}}function Wu(e){let t=te(Iu,e);Iu=t.state;for(let e of t.actions)Uu(e)}function Gu(){if(document.visibilityState!==`visible`){Lu=Date.now(),Wu({kind:`hidden`});return}let e=Lu===null?0:Date.now()-Lu;Lu=null,ka(`shown`,e),Wu({kind:`shown`,hiddenForMs:e})}function Ku(e){Hu(),Da(`control-${e}`),e===`connecting`?zu=window.setTimeout(()=>{zu=null,Wu({kind:`handshake-overdue`})},i):(e===`opened`&&da(),Wu({kind:e===`opened`?`control-opened`:`control-closed`}))}function qu(){ka(`resumed`,Lu===null?0:Date.now()-Lu),Wu({kind:`resumed`})}function Ju(){let e=Reflect.get(navigator,`connection`);e instanceof EventTarget&&e.addEventListener(`change`,()=>{Oa(`link`),Wu({kind:`network-changed`})})}function Yu(){r(Ku),document.addEventListener(`visibilitychange`,Gu),document.addEventListener(`freeze`,()=>Wu({kind:`frozen`})),document.addEventListener(`resume`,qu),window.addEventListener(`pagehide`,e=>{e.persisted&&Wu({kind:`frozen`})}),window.addEventListener(`pageshow`,e=>{e.persisted&&qu()}),window.addEventListener(`online`,()=>{Oa(`online`),Wu({kind:`network-changed`})}),window.addEventListener(`offline`,()=>Oa(`offline`)),Ju()}var Xu=!1,Zu=!1,Qu=!1,$u=null,ed=null;function td(){return ed??=M(()=>import(`./nyan-cat-DhXDT3zE.js`).then(e=>e.r).then(e=>($u=e,e),e=>(ed=null,u(`flying-animals`,`nyan cat failed to load: ${d(e)}`),null)),__vite__mapDeps([2,1,3,4,5,6,7,8])),ed}function nd(e){!Qu||e.currentFlightBlockReason(!0)?e.stopNyanCat():e.startNyanCat()}function rd(){Zu=!0,id(Ir())}function id(e){let t=document.documentElement;Xu||(Xu=!0,ro(()=>id(Ir())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>id(Ir()))),Qu=e,e?(t.dataset.flyingAnimals=`true`,$u?nd($u):Zu&&td().then(e=>{e&&nd(e)})):(delete t.dataset.flyingAnimals,$u?.stopNyanCat())}var ad=45e3,od=`The server did not answer within ${ad/1e3} s.`,sd=`Select the issue to load its description.`,cd=null,ld=null,ud=new Map,dd=null,fd=new Map,pd=new Map,md=null,hd=new Map,gd=new Map,_d=new Map,vd=new Map,yd=new Set;function P(e){for(let t of yd)t(e)}function bd(e){return`${e.key}:${e.updatedAt}`}function xd(e){let t=fd.get(e);t&&(fd.delete(e),hd.set(t.issueKey,{text:od,tone:`error`}),P(`detail`))}function Sd(e){let t=fd.get(e);return t?(clearTimeout(t.timeoutHandle),fd.delete(e),t):null}function Cd(){return{latestStatus:ld,issueByKey:ud,selectedKey:cd}}function wd(e){yd.add(e)}function Td(e){cd=e,md&&md.issue.key!==e&&(md=null)}function Ed(){if(cd)return ud.get(cd)??(md?.issue.key===cd?md.issue:void 0)}function Dd(e){return md?.issue.key===e.key&&md.isClosed}function Od(e){return[...pd.values()].some(t=>t.issue.key===e.key)}function kd(e,t){if(Od(e))return;let n=h(`set-issue-state`);dd?.({type:`set-issue-state`,requestId:n,repo:e.repo,issueNumber:e.number,state:t})?(pd.set(n,{issue:e,state:t,timeoutHandle:setTimeout(()=>{pd.delete(n),hd.set(e.key,{text:od,tone:`error`}),P(`detail`)},ad)}),hd.set(e.key,{text:t===`closed`?`Closing issue.`:`Reopening issue.`,tone:`busy`}),P(`detail`)):(hd.set(e.key,{text:Ee,tone:`error`}),P(`detail`))}function Ad(e){let t=pd.get(e.requestId);if(!t)return;clearTimeout(t.timeoutHandle),pd.delete(e.requestId);let{issue:n,state:r}=t;e.ok?(md={issue:n,isClosed:r===`closed`},hd.set(n.key,{text:r===`closed`?`Closed as completed.`:`Reopened.`,tone:`ok`}),P(`detail`)):(hd.set(n.key,{text:e.error||`Could not ${r===`closed`?`close`:`reopen`} the issue.`,tone:`error`}),P(`detail`))}function jd(e){return[...fd.values()].some(t=>t.issueKey===e.key)}function Md(e){return hd.get(e.key)}function Nd(e){let t=bd(e),n=_d.get(t);return n===``?`No description.`:n??vd.get(t)??`Loading description.`}function Pd(e){let t=bd(e);if(_d.has(t)||[...gd.values()].some(e=>e.cacheKey===t))return;let n=h(`issue-detail`);vd.delete(t),dd?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?gd.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{gd.delete(n),vd.set(t,`${od} ${sd}`),P(`detail`)},ad)}):vd.set(t,`${Ee} ${sd}`)}function Fd(e){let t=e.projectId;if(!t||jd(e))return;let n=h(`open-issue-session`);dd?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(fd.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>xd(n),ad)}),hd.set(e.key,{text:`Opening session.`,tone:`busy`}),P(`detail`)):(hd.set(e.key,{text:Ee,tone:`error`}),P(`detail`))}function Id(e){dd?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function Ld(e){dd=e}function Rd(){P(`session-state`)}function zd(e){if(!e){for(let e of fd.values())clearTimeout(e.timeoutHandle),hd.set(e.issueKey,{text:Ee,tone:`error`});fd.clear();for(let e of pd.values())clearTimeout(e.timeoutHandle),hd.set(e.issue.key,{text:Ee,tone:`error`});pd.clear();for(let e of gd.values())clearTimeout(e.timeoutHandle),vd.set(e.cacheKey,`${Ee} ${sd}`);gd.clear(),P(`status`)}}function Bd(e){let t=ld?.issues.find(e=>e.key===cd);ld=e,ud=new Map(e.issues.map(e=>[e.key,e])),md&&!md.isClosed&&ud.has(md.issue.key)&&(md=null);let n=e.issues.find(e=>e.key===cd);n&&n.updatedAt!==t?.updatedAt&&Pd(n),P(`status`)}function Vd(e){let t=gd.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),gd.delete(e.requestId),e.ok&&e.body!==null&&_d.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&vd.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),P(`detail`))}function Hd(e){if(typeof e.requestId!=`string`)return;let t=Sd(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`;hd.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=ld?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),P(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;hd.set(n,{text:r,tone:`error`}),P(`detail`)}var Ud=new Map,Wd=new Set;function Gd(e){let t=we.safeParse(e);if(!t.success)u(`reviews`,`dropped github-prs: ${c(t.error.issues)}`);else{Ud=new Map(Object.entries(t.data.prs));for(let e of Wd)e()}}function Kd(e){return Ud.get(e.toLowerCase())}function qd(e){Wd.add(e)}var Jd=20,Yd=[],Xd=null,Zd=!1,Qd=0,$d=null;function ef(){return $d??=M(()=>import(`./celebration-player-CKjlfzoq.js`),__vite__mapDeps([9,3,4,5,6,7,10])).catch(e=>($d=null,u(`merge-celebration`,`celebration player failed to load: ${d(e)}`),null)),$d}function tf(e){return Zd?`playing`:e?`queued`:`empty`}function nf(){if(!Xd)return;let e=Yd.length>0,t=tf(e);Xd.tray.dataset.state=t,Xd.count.textContent=e?String(Yd.length):``,Xd.toggle.element.disabled=t!==`queued`,Xd.toggle.setState(t===`queued`?`attention`:`idle`)}function rf(){let e=Yd.shift();if(Zd=e!==void 0,nf(),!e)return;let t=Qd;Qd+=1,ef().then(n=>{n?(n.playCelebration(e,t),window.setTimeout(rf,n.CELEBRATION_DURATION_MS)):(Yd.unshift(e),Zd=!1,nf())})}function af(e,t,n){Xd={tray:e,toggle:t,count:n},t.element.addEventListener(`click`,()=>{Qd=0,rf()}),nf()}function of(e){Yd.push(e),Yd.length>Jd&&Yd.shift(),nf()}var sf={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},cf=new Set([`FAILURE`,`ERROR`]);function lf(e){return sf[e]}function uf(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 df(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 ff(e){let t=st.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:df(t)}}var pf=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],mf=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],hf={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`},gf={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`},_f={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`},vf={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 yf(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 bf(e){return pf[e.rows.reduce((e,{pr:t})=>Math.min(e,pf.indexOf(hf[t.stage])),pf.length-1)]}function xf(e){let t=new Map(pf.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of yf(e)){let e=t.get(bf(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return mf.flatMap(e=>t.get(e)??[])}function Sf(e,t){return yf(e).find(e=>e.rows.some(e=>e.pr.key===t))?.rows??[]}function Cf(e){return e.stackSize<2?null:`Stack ${e.depth+1}/${e.stackHeight}`}function wf(e){return gf[e]}function Tf(e){return _f[e]}function Ef(e){return vf[e]}function Df(e){return e?.isKeepMergeableEnabled!==!1}function Of(e,t){if(!t||!e.keepMergeable||e.isKeepMergeableFixInFlight)return!1;let n=e.keepMergeableAttempt?.outcome;return n!==void 0&&n!==`pushed`&&n!==`stopped`}function kf(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...ff({...n,repo:r}),...e}]})}function Af(e){let t=new Map;for(let n of e)for(let e of n.links){let r=De(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 jf(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 Mf=3;function Nf(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,Mf).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 Pf(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:je(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,isAuthorOrgMember:n.isAuthorOrgMember,liveHead:n.headRefOid,prStage:ff(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n)}}var Ff=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`];function If(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 Lf(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function Rf(e){return e.status===`posted`&&zf(e)}function zf(e){if(!Lf(e)||le(e))return!1;let t=Wf(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 Bf(e){return Gf(e).length>0||Rf(e)}function Vf(e){return Bf(e)?`actionable`:If(e).band}function Hf(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[If(t).band].push(t);for(let e of Ff)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(Bf(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!Kf(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[Vf(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 Ff)t.ready.push(...n[e]);return t}function Uf(e,t){return e.commit===t?e.isViewer||yt.has(e.state):!1}function Wf(e){return e.liveHead??e.reviewedHead}function Gf(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function Kf(e){return Gf(e).length>0?!0:le(e)?!1:zf(e)?!0:!(e.githubReviews??[]).some(t=>Uf(t,Wf(e)))}function qf(e,t){return`${e}#${t}`}var Jf=null,Yf={},Xf=[],Zf=[],Qf={},$f={},ep=[],tp={},np={},rp={},ip=null,ap=new Set,op=new Map,sp=!1,cp=new Set;function lp(e){for(let t of cp)t(e)}function up(){return[...op].flatMap(([e,t])=>{let n=O.get(e);return!n||t.length===0?[]:[{id:e,title:vn(n)||e,links:t}]})}function dp(){let e=kf(Jf?.prs??[],Kd),t=jf(ip,e);ip=e,hp(t),lp({kind:`prs`})}function fp(){sp||(sp=!0,queueMicrotask(()=>{sp=!1,dp()}))}function pp(e){cp.add(e)}function mp(){return{prs:kf(Jf?.prs??[],Kd).map(e=>({...e,reviewItems:$f[e.key]??e.reviewItems})),status:Jf,sessionsByPrKey:Af(up()),handledByPr:Yf,prFlowWarnings:Xf,prFlowApprovals:Zf,sourceRunsByPr:Qf,prFlowActions:ep,actionRunsByPr:tp,prActionsByPr:np,prActionRunsByPr:rp}}function hp(e){let t=e.filter(e=>!ap.has(e.key));if(t.length!==0){for(let e of t)ap.add(e.key);of(Nf(t))}}function gp(e){op=e,fp()}function _p(){lp({kind:`session-state`})}function vp(e){let t=Ze.safeParse(e);t.success?(Jf=t.data,dp()):u(`reviews`,`dropped my-prs-status: ${c(t.error.issues)}`)}function yp(e){let t=fe.safeParse(e);t.success?(Yf=t.data.handledByPr,Xf=t.data.warnings,Zf=t.data.pendingApprovals,Qf=t.data.sourceRunsByPr,$f=t.data.reviewItemsByPr,ep=t.data.actions,tp=t.data.actionRunsByPr,np=t.data.prActionsByPr,rp=t.data.prActionRunsByPr,lp({kind:`prs`})):u(`reviews`,`dropped pr-flows-status: ${c(t.error.issues)}`)}function bp(e){lp({kind:`merge-result`,message:e})}function xp(e){lp({kind:`connection`,isConnected:e})}qd(fp);var Sp=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}])),Cp={turn:`Your turn`,working:`Agent working`,waiting:`Waiting on others`,aside:`Set aside`},wp=[`turn`,`working`,`waiting`,`aside`],Tp={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`},Ep={settled:`review-settled`,inReview:`review-in-flight`,queued:`review-queued`,posted:`review-posted`,discarded:`review-discarded`};function Dp(e){return e.status===`ready`?If(e).band===`blocking-others`?`review-direct-ask`:`review-ready`:`review-follow-up`}function Op(e,t){return t===`ready`?Dp(e):t===`attention`?`status`in e&&e.status===`error`?`review-failed`:`review-stale`:Ep[t]}function kp(e,t,n){let r=e.state===`OPEN`;if(r&&Of(e,n))return`mine-repair-failed`;if(r&&n&&e.keepMergeable&&e.isKeepMergeableFixInFlight)return`mine-repairing`;let i=Tp[e.stage];return Sp.get(i)?.group===`turn`&&e.stage!==`ready`&&t.has(De(e))?`mine-agent-fixing`:i}function Ap(e,t){return t===`ready`?Ff.indexOf(Vf(e)):t===`queued`?Ff.indexOf(If(e).band):0}function jp(e,t,n,r){let i=Sp.get(e);if(!i)return[];let a=n?Date.parse(n):NaN;return[{item:r(i),row:i,priorityBandRank:t,openedAtMs:Number.isNaN(a)?1/0:a}]}function Mp(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=>jp(Op(t,e),Ap(t,e),t.prCreatedAt,({action:n,kind:r})=>({source:`team`,key:`team:${t.key}`,prKey:De(t),kind:e,review:t,action:n,attention:r}))))}function Np(e,t,n){return xf(e).flatMap(e=>e.rows).flatMap(e=>jp(kp(e.pr,t,n),0,e.pr.createdAt,({action:t,kind:n})=>({source:`mine`,key:`mine:${e.pr.key}`,prKey:De(e.pr),pr:e.pr,stackRow:e,action:t,attention:n})))}function Pp(e,t){return e.row.rank-t.row.rank||e.priorityBandRank-t.priorityBandRank||e.openedAtMs-t.openedAtMs}function Fp(e,t,n,r){let i=new Map(wp.map(e=>[e,[]]));for(let a of[...Mp(e),...Np(t,n,r)])i.get(a.row.group)?.push(a);return wp.map(e=>({id:e,title:Cp[e],items:(i.get(e)??[]).toSorted(Pp).map(e=>e.item)}))}var Ip=[`turn`,`working`,`aside`],Lp=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 Rp(e){return e.status===`ready`&&e.verdict?`ready-${e.verdict}`:e.status}function zp(e){let t=Date.parse(e.item.createdAt);return Number.isNaN(t)?1/0:t}function Bp(e){let t=e.flatMap(e=>{let t=Lp.get(Rp(e));return t?[{row:t,askedAtMs:zp(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 Ip.map(e=>({id:e,title:Cp[e],items:t.filter(t=>t.row.group===e).map(e=>e.item)}))}function Vp(e){return`${e.key}@${e.entry.status}:${e.entry.finishedAt??``}`}function Hp(e){return e.find(e=>e.id===`turn`)?.items??[]}function Up(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function Wp(e,t){return Up(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function Gp(e){return e.source===`mine`?qf(e.pr.repo,e.pr.number):qf(e.review.repo,e.review.number)}function Kp(e,t){return Hp(e).map(e=>({id:e.key,kind:e.attention??`waiting`,name:t(e)}))}function qp(e){return Kp(e,Gp)}function Jp(e,t){return qp(e).filter(e=>e.id!==t)}function Yp({capturedOrder:e,actedKey:t,groups:n}){let r=Hp(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 Xp(e,t){let n=Hp(e).map(e=>e.key),r=t?n.indexOf(t):-1;return r===-1?``:`${r+1} of ${n.length} in Your turn`}function Zp(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 Qp(e){return Hp(e).map(Zp)}function $p({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:bt([...i]),unseen:bt([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:bt([...a]),unseen:bt([...o])}}function em(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 tm(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function nm(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 rm=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 im(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`:rm.get(e.key)??null}function am(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 om=null,sm=null,cm=new Set;function lm(e){for(let t of cm)t(e)}function um(){sm=Pf(om,Kd),lm({kind:`status`})}function dm(e){cm.add(e)}function fm(){return sm}function pm(){return Hf(sm)}function mm(e){let t=Ue.safeParse(e);t.success?(om=t.data,um()):u(`reviews`,`dropped team-review-status: ${c(t.error.issues)}`)}function hm(e){lm({kind:`action-result`,message:e})}function gm(e){lm({kind:`open-session-result`,message:e})}function _m(e){lm({kind:`connection`,isConnected:e})}qd(um);var vm=[],ym=null,bm=null,xm=null,Sm=!1,Cm=null,wm=Mr(),Tm=pr(),Em=new Set(Tm.split(`|`).filter(Boolean)),Dm=new Set,Om=new Set;function km(e){for(let t of Om)t(e)}function Am(e){e!==wm&&(wm=e,$n(e))}function jm(e){e!==Tm&&(Tm=e,Em=new Set(e.split(`|`).filter(Boolean)),or(e))}function Mm(){return fm()!==null&&mp().status!==null}function Nm(){if(!Mm())return;let e=$p({turnEntries:Qp(vm),acknowledged:wm,unseen:Tm,isLooking:bm?.isLooking()??!1});Am(e.acknowledged),jm(e.unseen),Cm?.(e.isShown)}function Pm(e){xm=e,km({kind:`reveal`})}function Fm(e){Om.add(e)}function Im(e){bm=e,Nm()}function Lm(){let{prs:e,sessionsByPrKey:t,status:n}=mp();return vm=Fp(pm(),e,new Set(t.keys()),Df(n)),Nm(),vm}function Rm(){Mm()&&(Am(bt(Qp(vm))),Nm())}function zm(e){Cm=e,Nm()}function Bm(){return Tm}function Vm(e){return Em.has(e)}function Hm(e){return Em.has(e)?(jm(bt([...Em].filter(t=>t!==e))),!0):!1}function Um(e){ym=e}function Wm(){return ym}function Gm(){let e=xm;return xm=null,e}function Km(e){if(e!==Sm){Sm=e;for(let e of Dm)e()}}function qm(e){Dm.add(e)}function Jm(){return document.documentElement.dataset.layout===`phone`&&Sm}function Ym(){Jm()&&km({kind:`return-to-queue`})}function Xm(){let e=Jp(vm,bm?.selectedKey()??null)[0]?.id??null;return e?(Pm(e),!0):!1}function Zm(e){let t=vm.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!ym?.openReviews()?!1:(Pm(t.key),Rm(),!0)}dm(e=>{e.kind===`status`&&Lm()}),pp(e=>{e.kind===`prs`&&Lm()});var Qm={OPEN:0,MERGED:1,CLOSED:2};function $m(e){return e?Qm[e.state]:Qm.OPEN}function eh(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:Kt(void 0)};let i=Tf(t.stage);return{key:n,text:r,detailText:`${r} ${t.title}`,stateText:wf(t.stage),url:t.url,prTitle:t.title,look:{icon:Ef(t.stage),tone:i},tier:Kt(i)}}function th(e,t){let n=e.map(e=>{let n=t(De(e));return{link:e,pr:n?ff(n):void 0}});return n.sort((e,t)=>$m(e.pr)-$m(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>eh(e,t))}var nh=new Map;function rh(e){return document.querySelectorAll(`[data-pr-rows-for="${CSS.escape(e)}"]`)}function ih(e){return th(nh.get(e)??[],Kd).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,onActivate:()=>{Zm(e.key)||Bl(e.url)}}))}function ah(e,t){let n=Ve(`session-pr-chip-unlink`);return n.append(x(gt)),n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),Vt({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:()=>{Qr(t,{type:`unlink-session-pr`,id:t,key:e.key})}})}),n}function oh(e,t){let n=rn({...e,text:e.key},{...e,className:`linked-pr-row-link`});e.prTitle&&n.append(E(`span`,`linked-pr-row-title`,e.prTitle)),e.stateText&&n.append(E(`span`,`linked-pr-row-stage`,e.stateText));let r=E(`li`,`linked-pr-row`);return r.append(n,ah(e,t)),r}function sh(e,t){e.dataset.prRowsFor=t;let n=ih(t);fn(e,n,e=>oh(e,t),{visibleCount:n.length})}function ch(e){for(let t of e){let e=t.dataset.prRowsFor;e&&sh(t,e)}}function lh(e,t){let n=Be.shape.links.safeParse(t??[]);nh.set(e,n.success?n.data:[]),ch(rh(e)),un(e),gp(nh)}function uh(e){nh.delete(e),gp(nh)}qd(()=>{ch(document.querySelectorAll(`[data-pr-rows-for]`)),sn()});function F(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function dh(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function fh(e,t){return e||dh(t)>0}var ph={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},mh=null,hh=!1,gh=!1,_h=null,vh=null,yh=null,bh=`—`;function xh(e){return e==null?bh:wt(e,`GB`)}function Sh(e){return e==null?bh:pe(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function Ch(e){return e==null?bh:`${Sh(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function wh(){let e=E(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=E(`div`,`health-summary`),n=Ve(`health-toggle`);n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=E(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,E(`span`,`health-toggle-label`,`Health`));let i=E(`div`,`health-stats`);t.append(n,i);let a=E(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{gh=!gh,e.dataset.expanded=String(gh),n.setAttribute(`aria-expanded`,String(gh)),a.hidden=!gh,gh&&(_({type:`request-health-snapshot`}),Eh())}),e.append(t,a),_h=e,vh=i,yh=a,e}function Th(){if(!vh||!mh)return;let e=mh,t=dh(e.anomalies);vh.innerHTML=`
|
|
3
3
|
<span class="health-stat"><span class="health-stat-label">Heap</span> ${xh(e.process.heapUsed)}</span>
|
|
4
4
|
<span class="health-stat"><span class="health-stat-label">Memory</span> ${xh(e.process.rss)}</span>
|
|
5
5
|
<span class="health-stat"><span class="health-stat-label">Buffers</span> ${xh(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 Dh(){if(!_h)return;let e=fh(hh,mh?.anomalies),t=_h.hidden;_h.hidden=!e,e&&t&&mh&&(Th(),gh&&Eh())}function Oh(e){hh=e,Dh()}function kh(e){if(_h)return _h;let t=wh();return e.appendChild(t),Dh(),t}function Ah(e){mh=e,Dh(),_h&&!_h.hidden&&(Th(),gh&&Eh())}var jh=null,Mh=null,Nh=!1,Ph=null,Fh=new Set;function Ih(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function Lh(){for(let e of Fh)e()}function Rh(){return{report:jh,hasReportSendFailed:Nh}}function zh(e){Fh.add(e)}function Bh(e){Mh=e}function Vh(){if(!Mh)return;Ph=h(`hooks-report`);let e=Mh({type:`request-hooks-report`,requestId:Ph});e!==!Nh&&(Nh=!e,Lh())}function Hh(e){Ih(e,Ph)&&(jh=e,Nh=!1,Lh())}function Uh(){Vh()}var Wh=new Map;function Gh(e){return Wh.get(e)??[]}function Kh(e){return Gh(e).length>0}function qh(e){let t=k(e)?.btnDocs;t&&(t.hidden=!Kh(e))}var Jh=null,Yh=null;function Xh(){return Yh??=M(()=>import(`./doc-editor-ui-Cstwx4PY.js`).then(e=>(Jh=e,e),e=>(Yh=null,u(`doc-editor`,`doc editor failed to load: ${d(e)}`),null)),__vite__mapDeps([11,12,13,5,3,14,15,16,17,18])),Yh}function Zh(e){Xh().then(t=>t?.openDocEditor(e))}function Qh(e){Jh?.applyDocsToOpenEditor(e)}function $h(e){Wh.set(e.id,e.docs),e.docs.length===0&&Wh.delete(e.id),qh(e.id),Qh(e.id)}function eg(e){let t=[...Wh.keys()];Wh.clear();for(let[t,n]of Object.entries(e.sessions))Wh.set(t,n);for(let e of new Set([...t,...Wh.keys()]))qh(e),Qh(e)}function tg(e,t){let n=k(e);n?li(n).show(`error`,t):Nn({source:`Session`,sessionId:typeof e==`string`?e:void 0,message:t})}function ng(e,t){let n=k(e);if(!n)return;let r=n.card.querySelector(`:scope > .session-failure-reason`);if(!(n.currentState===w.FAILED&&t)){r?.remove();return}let i=r??E(`p`,`session-failure-reason`);i.setAttribute(`role`,`status`),i.textContent=t,r||n.termWrap.before(i)}var rg=[],ig=new Set,ag=new WeakSet,og=null,sg=null;function cg(e){rg.some(t=>t.id===e.id)||(rg.push(e),ug(e.id,null))}function lg(){return rg}function ug(e,t){for(let n of ig)n(e,t)}function dg(e){return ig.add(e),()=>ig.delete(e)}function fg(e){e!==og&&(gg(),og=e)}function pg(e){og===e&&(gg(),og=null)}function mg(e,t){return sg?.page.id===e&&sg.sessionId===t}function hg(e,t,n=null){let r=rg.find(t=>t.id===e);if(!r||!og||og.sessionId()!==t||!r.isAvailableFor(t)||mg(e,t)&&n===null)return;gg();let i=og,a=i.elementFor(r);yg(a),sg={page:r,sessionId:t},r.mount(a,t,{placement:i.placement,target:n}),i.didShow(r),ug(r.id,t)}function gg(){if(!sg)return;let{page:e,sessionId:t}=sg;sg=null,e.unmount(),og?.didHide(e),ug(e.id,t)}function _g(){return sg?.page.canStepBack()??!1}function vg(){return sg?sg.page.canStepBack()?(sg.page.stepBack(),!0):(gg(),!0):!1}function yg(e){ag.has(e)||(ag.add(e),e.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Nt(e)||vg()&&e.preventDefault()}))}function bg({style:e}){let t=E(`div`,`session-page-bar session-page-bar-${e}`),n=new Map,r=null;function i(n){let i=e===`header`,a=C({variant:`quiet`,size:i?`small`:`default`,label:n.label,icon:x(n.iconPath),action:`${i?`open`:`show`}-${n.id}`});a.addEventListener(`click`,()=>{r&&hg(n.id,r)});let o=E(`span`,`session-page-dot`);o.setAttribute(`aria-hidden`,`true`);let s=E(`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 rg)a(e)}return dg((e,t)=>{if(t!==null&&t!==r)return;let n=rg.find(t=>t.id===e);n&&a(n)}),o(),{element:t,showSession(e){r=e,o()}}}var xg=2e3,Sg=`shown`,Cg=new Map,wg=new Map,Tg=[],Eg=[],Dg=null,Og=!1,kg=null,Ag=null;function jg(e){return Cg.get(e)??[]}function Mg(e){return jg(e).length>0}function Ng(e){return wg.get(e)??0}function Pg(e,t){return t.hasThumbnail?`/shown/${encodeURIComponent(e)}/${encodeURIComponent(`${t.id}.thumb.webp`)}`:null}function Fg(e){Tg.push(e)}function Ig(e){Eg.push(e)}function Lg(e){if(wg.delete(e)){ug(Sg,e);for(let t of Tg)t(e,[])}}async function Rg(e,t,n,r){let i=await Vg();mg(Sg,t)&&(i?((!kg||Ag!==t)&&(kg?.el.remove(),kg=i.createShownFace({sessionId:t,onClose:gg}),Ag=t),kg.el.dataset.placement=n,e.append(kg.el),kg.show(r),Lg(t)):(tg(t,`The shown files view did not load. Open it again to retry.`),gg()))}function zg(){kg?.hide(),kg?.el.remove()}var Bg={id:Sg,label:`Shown`,iconPath:ze,isAvailableFor:Mg,hasUnreadFor:e=>Ng(e)>0,mount(e,t,{placement:n,target:r}){Rg(e,t,n,r)},unmount:zg,canStepBack:()=>!1,stepBack:()=>{}};function Vg(){return Dg??=M(()=>import(`./shown-face-BN8KlCPx.js`).then(e=>e,e=>(Dg=null,u(`shown-files`,`shown file viewer failed to load: ${d(e)}`),null)),__vite__mapDeps([19,13,5,3,20])),Dg}function Hg(){let e=()=>{Vg()};`requestIdleCallback`in window?window.requestIdleCallback(e):setTimeout(e,xg)}function Ug(e,t=null){hg(Sg,e,t)}function Wg(e){return e.slice(-50)}function Gg(e,t){if(Ag===e&&kg?.applyArrivals(),t.length!==0){mg(Sg,e)||wg.set(e,Ng(e)+t.length),ug(Sg,e);for(let n of Tg)n(e,t)}}function Kg(e){let t=new Set(jg(e.id).map(e=>e.id)),n=e.files.filter(e=>!t.has(e.id));if(Cg.set(e.id,Wg([...jg(e.id),...n])),Gg(e.id,n),n.length!==0)for(let t of Eg)t(e.id,n)}function qg(e){let t=new Map(Cg),n=Og;Og=!0,Cg.clear();for(let[t,n]of Object.entries(e.sessions))Cg.set(t,Wg(n));for(let e of new Set([...t.keys(),...Cg.keys()])){Mg(e)||wg.delete(e);let r=new Set((t.get(e)??[]).map(e=>e.id)),i=n?jg(e).filter(e=>!r.has(e.id)):[];ug(Sg,e),Gg(e,i)}}var Jg=22,Yg={image:`Image`,video:`Video`,page:`Page`},Xg=new WeakMap;function Zg(e){let t=e.registerMarker(0);if(!t)return null;let n=Xg.get(e);if(n&&!n.marker.isDisposed&&n.marker.line===t.line)return t.dispose(),n;let r={marker:t,chipCount:0};return Xg.set(e,r),r}function Qg(e,t){let n=Ve(`shown-chip`);n.setAttribute(`aria-label`,`Open ${t.name}`);let r=Pg(e,t);if(r){let e=E(`img`,`shown-chip-thumb`);e.src=r,e.alt=``,e.decoding=`async`,n.append(e)}return r||n.append(E(`span`,`shown-chip-kind`,Yg[t.kind])),n.append(E(`span`,`shown-chip-name`,t.pageTitle??t.name)),n.addEventListener(`click`,n=>{n.stopPropagation(),Ug(e,t.id)}),n}function $g(e,t,n){let r=Zg(e);if(!r)return;let i=e.registerDecoration({marker:r.marker,anchor:`right`,x:r.chipCount*Jg,width:Jg,layer:`top`});if(!i)return;r.chipCount+=1;let a=Qg(t,n);i.onRender(e=>{e.contains(a)||e.replaceChildren(a),e.classList.add(`shown-chip-slot`)})}function e_(e,t){let n=k(e)?.term;if(n)for(let r of t)$g(n,e,r)}var t_=10,n_={low:0,medium:1,high:2};function r_(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 i_(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 a_(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function o_(e,t){for(let n of e.hotspots)a_(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`});for(let n of e.blastRadius)n.transitiveDependentCount<t_||a_(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`})}function s_(e,t){return e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function c_(e){return e.conflictRisk===null?-1:n_[e.conflictRisk]}function l_(e,t){return t.severity-e.severity||c_(t)-c_(e)||e.heading.localeCompare(t.heading)||e.groupKey.localeCompare(t.groupKey)}function u_(e,t){return e===null||t===null?e??t:n_[t]>n_[e]?t:e}function d_(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?(e.lines.push(n),e.conflictRisk=u_(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(s_);return n.sort(l_)}function f_(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:r_(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of i_(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);o_(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:d_(r.values()),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function p_(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 m_(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 h_(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=m_(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 g_(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function __(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 v_({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=b_(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 y_({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?v_({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 b_(e){return e||`base`}function x_(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function S_(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function C_({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 w_({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function T_(e){if(!e)return[];let t=new Map;for(let n of[...h_(e.committed?.diff),...h_(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 E_(e,t){return t===null?null:e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)??null}function D_(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 O_(e){return e!==w.DORMANT&&e!==w.DONE&&e!==w.FAILED}function k_(e,t){return(Ot.includes(e)||e===w.RUNNING)&&t}function A_(e){let{status:t,reason:n,isFetched:r,hasCommits:i,isWorkspace:a,state:o,effectiveBase:s}=e,c=__(e.files),l=O_(o),u=S_(t,n,k_(o,i)),d=w_({fetched:r,changedFileCount:c.files,hasCommits:i}),f=y_({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=C_({status:t,hasCommits:i,live:l,state:o});return{sentence:t===`parked`?`${f.text}. ${x_(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 j_=5e3,M_=new Map,N_=new Map,P_=new Map,F_=new Map,I_=new Map,L_=new Map,R_=new WeakMap,z_=new WeakMap,B_=new Set,V_=new Set,H_=null,U_=null,W_=null,G_=null,K_=null;function q_(e){return B_.add(e),()=>B_.delete(e)}function J_(e){for(let t of B_)t(e)}function Y_(e){if(!e)return[];let t=R_.get(e);if(t)return t;let n=T_(e);return R_.set(e,n),n}function X_(e){if(!e)return null;let t=z_.get(e);if(t)return t;let n=f_(e);return z_.set(e,n),n}function Z_(e){return O.get(e)?.card.dataset.workspace!==void 0}function Q_(e){let t=O.get(e);if(!t)return null;let n=P_.get(e)??null,r=Y_(n),i=F_.get(e)??null;return{...A_({status:M_.get(e)||`none`,reason:N_.get(e)??null,isFetched:P_.has(e),hasCommits:n?.hasCommits===!0,hasDiffError:i!==null,isWorkspace:Z_(e),state:t.currentState,effectiveBase:t.effectiveBase,isMergeInFlight:L_.has(e),files:r}),sessionId:e,sessionName:t.card.dataset.session||e,files:r,diffError:i,changeMapView:X_(I_.get(e)),notice:H_?.sessionId===e?H_.text:null,isWorkspace:Z_(e)}}function $_(e,t){H_={sessionId:e,text:t},U_&&clearTimeout(U_),U_=setTimeout(()=>{H_=null,J_(e)},j_),J_(e)}function ev(e){I_.has(e)||I_.set(e,null),_({type:`request-change-map`,id:e})}function tv(e){_({type:`request-session-diff`,id:e}),ev(e)}function nv(e,t){let n=M_.get(e);M_.set(e,t),g_(n,t)&&(P_.delete(e),F_.delete(e),I_.delete(e),e===zr()&&tv(e)),J_(e)}function rv(e,t,n=null){let r=t||`none`;N_.set(e,n);let i=L_.get(e);i!==void 0&&i!==r&&L_.delete(e),nv(e,r)}function iv(e,t,n=null){N_.set(e,n),L_.delete(e),nv(e,t||`none`)}function av(e,t){let n=D(e);n&&(P_.set(n,t),F_.delete(n),J_(n))}function ov(e,t){let n=D(e);n&&(F_.set(n,t),J_(n))}function sv(e,t){let n=D(e);if(!n)return;let r=ke.safeParse(t);r.success&&r.data.sessionId===n&&(I_.set(n,r.data),J_(n))}function cv(e){let t=D(e);t&&t===zr()&&tv(t)}function lv(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function uv(e){let t=D(e);if(!t||t!==zr())return;let n=!P_.has(t)||F_.has(t),r=!I_.has(t)||lv(I_.get(t));n&&tv(t),r&&!n&&ev(t),J_(t)}function dv(e){let t=D(e);t&&L_.delete(t)&&J_(t)}function fv(e){let t=D(e);M_.delete(t),N_.delete(t),P_.delete(t),F_.delete(t),I_.delete(t),L_.delete(t),t===zr()?ei(null):J_(t)}function pv(e,t){L_.has(e)||(_(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(L_.set(e,M_.get(e)||`none`),J_(e)):$_(e,`Not connected. The merge was not sent.`))}function mv(e){let t=Q_(e);return t?L_.has(e)?($_(e,`Merge is already on its way for "${t.sessionName}".`),!1):t.isMergeEnabled?O.get(e)?.currentState===w.RUNNING?(Vt({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:()=>pv(e,!0)}),!0):(pv(e,!1),!0):($_(e,t.mergeRefusal??`Nothing to merge in "${t.sessionName}" right now.`),!1):!1}function hv(e){let t=Q_(e);t?.isDiscardShown&&Vt({title:`Discard worktree`,message:`Throw away the worktree changes for "${t.sessionName}"? This cannot be undone.`,confirmLabel:`Discard`,danger:!0,onConfirm:()=>_({type:`discard-session-worktree`,id:e})})}function gv(){return[...V_].some(e=>!e.hasAttribute(`data-slot-held`))}function _v(){let e=gv()&&document.visibilityState===`visible`?zr():null;e!==W_&&(G_&&clearInterval(G_),G_=null,W_=e,_({type:`watch-session-changes`,id:e}),e&&(G_=setInterval(()=>_({type:`watch-session-changes`,id:e}),se)))}function vv(e){K_??=yv(),K_.observe(e)}function yv(){return document.addEventListener(`visibilitychange`,_v),Hr(e=>{e&&tv(e),_v()}),new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&V_.add(t.target),t.isIntersecting||V_.delete(t.target);_v()})}var bv=!1,xv=new Set;function Sv(e){bv=!!e,Nv();for(let e of xv)e(bv)}function Cv(e){return xv.add(e),()=>xv.delete(e)}function wv(){return bv}function Tv(){let e=E(`div`,`debug-close`);return e.append(C({variant:`icon`,size:`small`,label:`Close debug overlay`,icon:x(gt)})),e}function Ev(e){return e?St(new Date(e)):`-`}function Dv(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function Ov(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Dv(e.quietMs)})`:``}function kv(e){let t=`<span class="debug-dim">${Ev(e.ts)}</span>`;if(e.kind===`signal`){let n=F([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${F(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=Ov(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${F(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=F(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${F(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${F(e.category||`?`)}: <span class="debug-dim">${F(e.from||`?`)} → ${F(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${F(e.kind||`decision`)}</span>`}function Av(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">${F(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">${F(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${Ev(e.timestamp)}</span> ${F(e.from)} → ${F(e.to)} <span class="debug-label">${F(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?`${F(a.signal)} (${F(a.source||`?`)}${a.confidence?`/${F(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">${F(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 ${Dv(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">${F(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">${kv(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(Tv())}function jv(e,t){if(e.debugOpen){Mv(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(Tv()),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`)&&Mv(e)}),_({type:`debug-state`,id:t})}function Mv(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function Nv(){for(let[,e]of O)e.btnDebug.classList.toggle(`visible`,bv),e.btnTrace.classList.toggle(`visible`,bv),!bv&&e.debugOpen&&Mv(e)}function Pv(e){let t=typeof e.id==`string`?O.get(e.id):void 0;t?.debugOpen&&Av(t,e.payload)}function Fv(e){k(e)?.debugOpen&&_({type:`debug-state`,id:e})}function Iv(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0}}function Lv(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 Rv(e,t){return{body:t.join(`
|
|
74
|
-
`),tag:`glimmervoid-alert-${e.id}`,renotify:e.isStart}}var zv=4e3;function Bv(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function Vv(e,t,n,r=zv){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 Hv=`#plan/`;function Uv(e){return`${Hv}${encodeURIComponent(e)}`}function Wv(e){if(!e.startsWith(Hv))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var Gv=null;function Kv(){return Gv??=M(()=>import(`./alert-sound-Da6VQFBS.js`),__vite__mapDeps([10,7])).catch(e=>(Gv=null,u(`alert-sound`,`alert sound failed to load: ${d(e)}`),null)),Gv}function qv(){let e=_r();Kv().then(t=>t?.playAlertSound(e))}function Jv(){return typeof Notification>`u`?null:Notification}function Yv(){return Jv()!==null}function Xv(){let e=Jv();return e?e.permission:`unavailable`}async function Zv(){let e=Jv();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function Qv(){return!Yv()&&!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.`:Yv()?Xv()===`denied`&&lr()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function $v(){return lr()&&Xv()==="default"}function ey(e=()=>{}){let t=E(`div`,`notification-permission`),n=()=>{let r=Qv();if(t.replaceChildren(),t.hidden=!r&&!$v(),r){t.append(E(`p`,`notification-permission-hint text-meta text-text-muted`,r));return}let i=C({variant:`secondary`,label:`Enable desktop notifications`});i.addEventListener(`click`,()=>{i.disabled=!0,Zv().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var ty=`Notifications`,ny=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,ry=new Map,iy=!1;function ay(){iy||(iy=!0,Nn({source:ty,message:ny,hidesInStreamerMode:!1}))}function oy(e,t){let n=ry.get(e)??new Set;n.add(t),ry.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function sy(e){let t=ry.get(e);if(t){ry.delete(e);for(let e of t)e.close()}}function cy(e){return!Yv()||!lr()||document.documentElement.hasAttribute(`data-streamer`)?!1:e||!document.hasFocus()}function ly(){return cy(!1)&&Xv()===`granted`}var uy=null;function dy(e,t){let n=Jv();if(!n||(uy=Lv(uy,t,e.message),Mn(ty),!Vv(window.localStorage,Bv(`group-${t.id}`,`${e.session}-${e.category}`),Date.now())))return;let r=t.sessionIds.length===1?O.get(e.session):void 0,i=t.sessionIds.length>1?`${t.sessionIds.length} sessions`:r?vn(r):`Glimmervoid`;try{let r=new n(i,Rv(t,uy.lines));r.onclick=()=>{window.focus(),e.kind===`plan`&&(window.location.hash=Uv(e.session)),r.close()};for(let e of t.sessionIds)O.has(e)&&oy(e,r)}catch{}}var fy=null;function py(e){return!e||e.id!==fy&&(fy=e.id,!0)}function my(e){O.get(e.session)?._isActiveViewer?.()===!0?_({type:`alert-seen`,id:e.session}):py(e.group)&&ir()&&qv()}function hy(e,t){t?dy(e,t):vy(e)}function gy(){let e=Reflect.get(navigator,`userAgentData`);return typeof e!=`object`||!e?!1:Reflect.get(e,`platform`)===`macOS`}function _y(e){if(document.hasFocus()){my(e);return}let t=e.group;ly()&&(hy(e,t),!gy())||(cy(!1)&&Xv()===`denied`&&ay(),t?.isStart!==!1&&py(t)&&ir()&&qv())}function vy({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=Jv();if(!a||!cy(!!i)||(a.permission===`denied`&&ay(),a.permission!==`granted`)||(Mn(ty),!Vv(window.localStorage,Bv(e,t),Date.now())))return;let o=typeof e==`string`?e:``,s=O.get(o),c=s?vn(s):``;try{let i=new a(c||`Glimmervoid`,Iv(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=Uv(o)),i.close()},s&&oy(o,i)}catch{}}var yy=null;function by(){return yy??=M(()=>import(`./resume-dialog-B769M43A.js`),__vite__mapDeps([21,12,13,5,3,14,22,15,23])).catch(e=>(yy=null,u(`resume-dialog`,`restart dialog failed to load: ${d(e)}`),null)),yy}var xy=null,Sy=null;function Cy(){return Sy??=M(()=>import(`./plan-face-C0__OQaK.js`).then(e=>(xy=e,e),()=>(Sy=null,null)),__vite__mapDeps([24,13,5,3,14,25,26,16,17,27])),Sy}function wy(e){let t=E(`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,Cy().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))}}}var Ty=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function Ey(e){return e===`approve`||e===`approve-accept-edits`}function Dy(e){return(e.state===`decided`||e.state===`closed`)&&Ey(e.lastDecision)}function Oy(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&Dy(n)}function ky(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function Ay(e){let t=ky(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 jy(e,t){return ky(e,t)?.openRevision?.revision??null}function My(e,t,n){if(n===null)return null;let r=ky(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function Ny(e,t){let n=t-e;return Number.isFinite(n)?ue(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function Py(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 Fy(e,t,n){let r=Py(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return Ty.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function Iy(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 Ly(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function Ry(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+Pe}function zy(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 ${tt} characters, so nothing was sent`:Ly(e)>1e4?`the feedback composes more than the ${xe} characters the hook reply carries, so nothing was sent`:Ry(e)>Ie?`the decision is larger than one control frame carries, so nothing was sent`:null}function By(e){return e?`, ${e}`:``}function Vy(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=Iy(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 Hy(e,t,n){let r=Vy(e,t,n);return r?`${r}${By(e.problem)}`:e.problem??``}function Uy(e){let t=ky(e.state,e.selectedAgentId),n=Ay(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:My(e.state,t?.agentId??null,n),status:Hy(e,t,n),actions:Fy(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:My(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:Py(e,t,n)}]}}function Wy(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 Gy({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 Ky({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var qy=e=>Lt.includes(e),Jy=e=>At.includes(e);function Yy(e){let t=e.currentState;e.btnRestart.classList.toggle(`visible`,qy(t)||Jy(t)||t===w.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,wv()),e.btnPlan.hidden=Ky(e)===`hidden`}function Xy(e){let t=k(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(D(e)),Yy(t),Ic(t,D(e)),!0)}function Zy(e,t){let n=k(e);n&&(n.hasPlan=t===!0,Yy(n))}function Qy(e){let t=k(e.id);t&&(t.planReviewState=Wy(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),Yy(t))}function $y(e){let t=k(e.id);t&&t.planFace.update({draft:e})}function eb(e){let t=k(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),Yy(t))}function tb(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=k(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function nb(e){for(let[,t]of O)t.planFace.update({isConnected:e})}var rb=160,ib=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 ab(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=rb?t:`${t.slice(0,157)}...`}function ob(e,t){let n=ib[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?ab(r):``}var sb=5e3;function cb(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function lb(e,t){if(!e.toolUseId)return cb(e.text)??`context`;let n=t.get(e.toolUseId);return n?ob(n.name,n.input)||n.name:`expansion`}function ub(e){return e.kind!==`expansion`||e.toolUseId?!1:cb(e.text)!==null}function db(e){return e.kind===`prompt`||e.kind===`session`||ub(e)}function fb(e){return new TextEncoder().encode(e).byteLength}var pb={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`};function mb(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:ab(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:ab(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:ab(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:ab(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:ab(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:lb(e,t)};if(e.kind===`tool_call`){let t=ob(e.name,e.input);return t?{prefix:`${e.name}: `,text:t}:{prefix:``,text:e.name}}return{prefix:`${t.get(e.toolUseId)?.name??`Tool`} result: `,text:`${fb(e.content)} bytes`}}function hb(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function gb(e,t){let n=mb(e,t),r=hb(e),i=e.kind===`tool_call`||e.kind===`tool_result`?`${n.prefix}${n.text}`:n.text,a=[],o=e.kind===`notice`?`muted`:`default`;if(e.kind===`tool_result`&&e.isError&&(o=`error`,a.push(`error`)),e.truncated===!0&&(o!==`error`&&(o=`muted`),a.push(`truncated`)),e.kind===`tool_result`){let n=t.get(e.toolUseId),r=n?e.ts-n.ts:NaN;Number.isFinite(r)&&r>=0&&a.push(r>1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`)}return{kind:e.kind,tag:pb[e.kind],text:`${r}${i}`,tone:o,badges:a}}function _b(e,t){return{record:e,...gb(e,t)}}function vb(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function yb(e,t){let n=vb(e);return!n||t.has(n)?null:n}function bb(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function xb(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function Sb(e,t){if(t.size!==0)for(let n of e.turns)for(let r=0;r<n.rows.length;r+=1){let i=n.rows[r],a=vb(i.record);a&&t.has(a)&&(n.rows[r]=_b(i.record,e.toolCallByUseId))}}function Cb(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function wb(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function Tb(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=fb(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function Eb(e,t){for(let n of t)n.kind===`tool_call`&&e.toolCallByUseId.set(n.toolUseId,n);let n=[],r=e.turns[e.turns.length-1]??null;for(let i of t){let t=yb(i,e.toolCallByUseId);t&&bb(e.unresolvedToolUseCounts,t);let a=_b(i,e.toolCallByUseId);if(db(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:wb()},Tb(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:wb()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),Tb(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 Db(e,t){let n=Cb();Eb(n,t);let r=new Set;for(let[t,i]of n.toolCallByUseId)e.toolCallByUseId.has(t)||(e.toolCallByUseId.set(t,i),r.add(t));let i=new Set;for(let t of r)e.unresolvedToolUseCounts.delete(t)&&i.add(t);for(let[t,r]of n.unresolvedToolUseCounts)e.toolCallByUseId.has(t)||bb(e.unresolvedToolUseCounts,t,r);let a=n.turns[n.turns.length-1],o=e.turns[0],s=!!a&&!!o&&!o.head,c=s?a.head:null,l=s?a.rows:[];if(s){n.turns.pop();let e=a.startedAt,t=o.startedAt;e!==null&&(t===null||e<t)&&(o.startedAt=a.startedAt),o.head=c,o.rows=[...l,...o.rows],o.metrics={rowCount:a.metrics.rowCount+o.metrics.rowCount,toolCallCount:a.metrics.toolCallCount+o.metrics.toolCallCount,errorCount:a.metrics.errorCount+o.metrics.errorCount,resultBytes:a.metrics.resultBytes+o.metrics.resultBytes}}return e.turns=[...n.turns,...e.turns],Sb(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function Ob(e){return e.rows.length+ +!!e.head}function kb(e){let t=0;for(let n of e.turns)t+=Ob(n);return t}function Ab(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=vb(n.record);t&&xb(e.unresolvedToolUseCounts,t)}}function jb(e,t){Ab(e,t.head?[t.head,...t.rows]:t.rows)}function Mb(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);Ab(e,i);for(let e of i)Tb(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function Nb(e,t=sb){let n=kb(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=Ob(t),jb(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:Mb(e,n-t)}}function Pb(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 Fb(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 Ib(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 Lb(e,t=sb){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function Rb(e,t=sb){return!Lb(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function zb(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 Bb=1e4,Vb=null,Hb=null,Ub=[],Wb=null,Gb=null,I=null,Kb=null,qb=!1,Jb=null,Yb=()=>!1,Xb=new Set;function Zb(e){for(let t of Xb)t(e)}function Qb(){Kb&&=(clearTimeout(Kb.timeoutHandle),null)}function $b(){Kb=null,Jb=`The trace did not load within ${Math.round(Bb/1e3)} s.`,Zb({kind:`rebuild`})}function ex(e){Qb(),qb=!1,Jb=null,Wb=e,I=e?{sessionId:e,grouping:Cb(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,Zb({kind:`selection-reset`})}function tx(e){let t=Fb(Ub,Gb,Wb,e);return Gb&&t===Gb&&(Gb=null),t!==Wb&&(ex(t),!0)}function nx(e){if(!Vb)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};Vb(t)?Kb={request:e,timeoutHandle:setTimeout($b,Bb)}:(Jb=Ee,Zb({kind:`header`}))}function rx(e=!1){if(!Vb)return;let t=Ib({selectedSessionId:Wb,isPanelVisible:e||Yb(),hasPendingRequest:!!Kb,hasLoadedOnce:I?.hasLoadedOnce??!1,nextOffset:I?.nextOffset??0});t&&nx(t)}function ix(){qb&&!Kb&&(qb=!1,rx())}function ax(){if(!I)return;let e=Nb(I.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!I.hasDroppedEarliestRows;t&&(I.hasDroppedEarliestRows=!0),Zb({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function ox(e){I&&(Zb({kind:`records-appended`,appends:Eb(I.grouping,e)}),ax())}function sx(e){I&&(Zb({kind:`records-prepended`,prepend:Db(I.grouping,e)}),ax())}function cx(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 lx(){return{selectedSessionId:Wb,hasPendingRequest:!!Kb,hasLoadedOnce:I?.hasLoadedOnce??!1,hasDroppedEarliestRows:I?.hasDroppedEarliestRows??!1,firstOffset:I?.firstOffset??0,residentRowCount:I?kb(I.grouping):0}}function ux(){return{sessionOptions:Ub,selectedSessionId:Wb,selectedTrace:I,pendingSessionId:Kb?.request.id??null,traceFailureText:Jb}}function dx(e){Xb.add(e)}function fx(e){Yb=e}function px(){if(!Vb)return;let e=Rb(lx());e&&nx(e)}function mx(e){Ub.some(t=>t.id===e)&&e!==Wb&&(Gb=null,ex(e),rx(),Zb({kind:`rebuild`}))}function hx(){let e=tx(!0);return rx(!0),e}function gx(e){Vb=e}function _x(e){Hb=e}function vx(e){Gb=e,Hb?.()}function yx(e){Ub=Pb(e);let t=tx(Yb());t&&rx(),Zb({kind:`sessions`,hasSelectionChanged:t})}function bx(e){let t=cx(e);if(!t)return;let n=zb({pendingRequest:Kb?.request??null,resident:I?{sessionId:I.sessionId,firstOffset:I.firstOffset,nextOffset:I.nextOffset,hasLoadedOnce:I.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?ix():(Qb(),Jb&&(Jb=null,Zb({kind:`header`})),n===`stale`?ix():n===`reset`?(ex(t.id),I&&(I.filePath=t.path),rx(),Zb({kind:`rebuild`}),ix()):I&&(I.filePath=t.path,n===`prepend`?(I.firstOffset=t.start,sx(t.records),ix()):(n===`seed`&&(I.hasLoadedOnce=!0,I.firstOffset=t.start),I.nextOffset=t.next,ox(t.records),ix())))}function xx(e){let t=e?.id;typeof t==`string`&&t===Wb&&Yb()&&(Kb?qb=!0:rx())}function Sx(e){let t=e?.id;if(typeof t!=`string`||Kb?.request.id!==t)return!1;Qb(),qb=!1;let n=e?.message;return Jb=typeof n==`string`&&n?n:`The trace could not be read.`,Zb({kind:`rebuild`}),!0}function Cx(e){Qb(),qb=!1,Jb=e?null:Ee,e?(Zb({kind:`header`}),rx()):Zb({kind:`rebuild`})}function wx(e){return e instanceof Error?e.message:String(e)}function Tx(e,t,n=!1){let r=E(`label`,`dialog-checkbox-label`),i=E(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,E(`span`,null,e)),r}function Ex(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function Dx(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:Ex(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 Ox(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:o}=Ut({title:`Workspace repositories`}),s=E(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),c=E(`fieldset`,`dialog-workspace-list`);c.setAttribute(`aria-label`,`Workspace repositories`),c.append(E(`div`,`dialog-hint`,`Loading repositories...`));let l=E(`div`,`dialog-hint`);l.setAttribute(`role`,`status`);let u=E(`div`,`dialog-error`),d=C({variant:`primary`,label:`Save`,disabled:!0});i.append(d),n.append(s,c,l,u,i),o.addEventListener(`click`,r),requestAnimationFrame(()=>o.focus()),Dx(e).then(e=>{if(t.isConnected){c.textContent=``;for(let t of e)c.append(Tx(t.name,t.path,t.isMember));d.disabled=!1}}).catch(e=>{t.isConnected&&(c.textContent=``,u.textContent=`Could not load repositories: ${wx(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: ${wx(e)}`)}).finally(()=>{l.textContent=``,d.disabled=!1}))})}function kx(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function Ax(e,t){pn(e.taskTitleEl,()=>mn(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),Xt(e,t)}),e.nameEl.addEventListener(`click`,()=>{Jt(e.nameEl)||ei(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),Xt(e,t))}),e.btnRename.addEventListener(`click`,()=>{kx(e),Xt(e,t,{returnsFocusToTerminal:!e.renameTargetEl?.isConnected})}),e.btnRestart.addEventListener(`click`,()=>{kx(e),by().then(n=>n?.openRestartDialog(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0}))}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{kx(e),Ox(t)}),e.btnTrace.addEventListener(`click`,()=>{kx(e),vx(t)}),e.btnDocs.addEventListener(`click`,()=>{kx(e),Zh(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=Ky(e);n!==`hidden`&&(n===`face`?Xy(t):location.hash=Uv(t))}),e.btnRemove.addEventListener(`click`,()=>{kx(e),Yr(t)});function n(){for(let[,t]of O)t!==e&&kx(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`)}e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation(),e.sessionMenu.classList.contains(`open`)?kx(e):n()}),fi({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:()=>kx(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&&kx(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),kx(e),jv(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&Mv(e)},{signal:e.abortController.signal})}var jx=1500,Mx=new WeakMap;function Nx(e){clearTimeout(Mx.get(e)),Mx.delete(e)}function Px(e,t){let n=setTimeout(()=>{Mx.delete(e),_({type:`dismiss`,id:t,expectedState:w.COMPLETE})},jx);Mx.set(e,n)}function Fx(e,t,n){let r=document.activeElement;return Vr({previousState:t,nextState:n,isPhoneLayout:no(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}var Ix=e=>e==null?``:String(e);Ig(e_);function Lx(e,t,n){let r=k(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&hn(e,r.taskTitle)}}function Rx(e){return typeof e==`string`&&O.has(e)}function zx(){return O.size}function Bx(e){let t=e||{};t.cursorBlink!=null&&wu(t.cursorBlink),t.debugMode!=null&&(Sv(t.debugMode),Oh(t.debugMode));for(let[,e]of O)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function Vx(){vl(O.values(),bl())}function Hx(e){return{state:e.currentState,unseenOutcome:e.unseenOutcome,ownerId:e.ownerId}}function Ux(){let e=gn(A.counts),t=e>0?`(${e}) Glimmervoid`:`Glimmervoid`;document.title!==t&&(document.title=t)}function Wx(e,t,n,r={}){if(!Tn)return;let i=D(e),a=Ix(n)||w.DORMANT,o=Qt(i,Ix(t),a,r),s=a===w.DORMANT;Tn.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),Yy(c),Pu(c,i)}let u=new AbortController,d=wy({signal:u.signal,requestPlan:(e,t,n)=>_({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>_({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:l,sendDecision:(e,t)=>_({type:`plan-decision`,id:e,...t}),reportProblem:e=>tg(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:Ix(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=()=>Pu(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=O.get(i);return f&&On(A,Hx(f)),O.set(i,c),yn(A,Hx(c)),Bn(i,c),Ax(c,i),Yy(c),c.btnDocs.hidden=!Kh(i),a===w.RUNNING&&zn(c,!0),s||ju(c,i),Ux(),c}function Gx(e,t){let n=k(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function Kx(e,t){let n=k(e);n&&(n.agent=typeof t==`string`?t:null,Yy(n))}function qx(e,t){let n=k(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function Jx(e,t,n=!1){let r=k(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=zt(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function Yx(e,t){let n=k(e);n&&(n.pendingPromptKind=typeof t==`string`?t:null)}function Xx(e,t){let n=k(e);n&&(On(A,Hx(n)),n.unseenOutcome=t??null,yn(A,Hx(n)))}function Zx(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function Qx(e,t,n=null){let r=k(e),i=Ix(t)||`none`;r&&Zx(r.card,i),rv(D(e),i,Ix(n)||null)}function $x(e,t,n=null){let r=k(e),i=Ix(t)||`none`;r&&Zx(r.card,i),iv(D(e),i,Ix(n)||null)}function eS(e,t){let n=k(e);if(!n)return;let r=Ix(t);n.card.dataset.session=r,n.nameEl.textContent=r}function tS(e){let t=k(e);t&&(Mv(t),On(A,Hx(t)),O.delete(D(e)),Bn(D(e),void 0),xy?.dropPlanBodyCache(D(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),dl(t,D(e)),Ba(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),Ux())}function nS(e,t,n){if(!t||!e.term)return;let r=n===w.DONE?`Session complete`:`Session failed`,i=n===w.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 rS(e,t){e.term&&(t===w.DONE||t===w.FAILED)&&(e.term.clear(),e.term.reset())}function iS(e){let t=O.get(e);t&&wn({state:t.currentState,unseenOutcome:t.unseenOutcome})&&document.visibilityState===`visible`&&(no()||document.hasFocus())&&_({type:`dismiss`,id:e,expectedState:t.currentState})}function aS(e,t,n){let r=k(e);if(!r)return;let i=Ix(t),a=r.currentState;On(A,Hx(r)),r.currentState=i,yn(A,Hx(r)),Bn(D(e),r),i!==w.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(Nx(r),r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),zn(r,i===w.RUNNING)),a===w.DORMANT&&i!==w.DORMANT&&ju(r,D(e)),kn({state:i})===`resting`&&sy(D(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,zt(i,r.awaitingBackgroundTasks)),Yy(r),Fx(r,a,i)&&Px(r,D(e));let o=i===w.DONE||i===w.FAILED,s=a!==w.DONE&&a!==w.FAILED&&a!==w.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===w.DONE||i===w.FAILED)&&nS(r,s,i),i===w.INITIALIZING&&rS(r,a),Ux()}var oS=Ai({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function sS(e){let t=E(`ul`,`session-setup-list`);return t.append(...e.map(e=>E(`li`,null,e))),t}function cS(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=Ft(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[E(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=E(`div`,`session-setup-plugin`);return t.append(E(`h3`,null,e.name)),e.skills.length>0&&t.append(E(`p`,`session-setup-label`,`Skills`),sS(e.skills)),e.agents.length>0&&t.append(E(`p`,`session-setup-label`,`Agents`),sS(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[sS(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=E(`p`,`session-setup-hook`);return t.append(E(`span`,null,e.event),E(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>E(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[sS(t.skills)]:[]),n(`Agents`,t.agents.length>0?[sS(t.agents)]:[])}function lS(e){let t=E(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=E(`div`,`session-setup-sections`);oS.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function uS(e){let t=oS.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;cS(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function dS(e){return ue(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function fS(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${dS(Date.now()-e)} ago`}var pS=e=>`polled ${fS(e)}`;function mS(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=pS){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=Vn(a)}}}var hS=80,gS=Object.freeze([{value:`day`,label:`Today`,days:1},{value:`week`,label:`Last 7 days`,days:7},{value:`month`,label:`Last 30 days`,days:30}]),_S=`week`;function vS(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function yS(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function bS(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${vS(String(Math.abs(t)))}`}function xS(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.abs(e);if(t===0)return`$0.00`;let n=e<0?`-`:``;if(t<1e-4)return e<0?`above -$0.0001`:`<$0.0001`;if(t<.01)return`${n}$${t.toFixed(4)}`;let[r,i]=t.toFixed(2).split(`.`);return`${n}$${vS(r)}.${i}`}function SS(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}${yS((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${yS((n/1e6).toFixed(2))}M`:`${t}${yS((n/1e9).toFixed(2))}B`}function CS(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=hS?`warn`:`ok`}var wS=90;function TS(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&S(e.budgetUsd,null)!==null):[]}function ES(e){let t=S(e?.pct,null);return t===null?0:t}function DS(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 OS(e){return e?.vendor===`codex`||e?.vendor===`kimi`?e.vendor:`claude`}function kS(e,t=null){let n=[],r=CS(DS(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 TS(e)){let e=ES(t);if(e<wS)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return bt(n)}function AS(e,t=``){let n=e?.source;if(n===`fetched`){let e=it(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=it(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 jS(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 MS(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=MS(e.dirs);if(n!==null&&t.push(`${bS(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${bS(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${bS(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${bS(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 PS(e){return it(e?.error,``)}function FS(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}var IS=`Estimated list prices, not a bill.`,LS=`Enable in Settings.`,RS=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],zS=/^(\d{4})-(\d{2})-(\d{2})$/,BS=new Set([`day`,`model`,`label`]),VS=new Set([`model`,`label`]);function HS(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${yS(e.toFixed(1))}%`}var US=`tokens`,WS=Object.freeze([{value:`tokens`,label:`Tokens`},{value:`cost`,label:`Cost`}]);function GS(e){return e===`cost`?`cost`:US}function KS(e,t){return t===`cost`?xS(e):SS(e)}function qS(e,t){if(t===`tokens`)return`tokens`;let n=Number(e?.costUSD);return Number.isFinite(n)&&n>0?`costUSD`:`tokens`}function JS(e){return e===`costUSD`?`share of cost`:`share of tokens`}function YS(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function XS(e){let t=zS.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=RS[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function ZS(e){let t=QS(e);return t.length===0?``:t.length===1?XS(t[0]):`${XS(t[0])} to ${XS(t[t.length-1])}`}function QS(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>zS.test(e)).sort()}function $S(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:eC(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function eC(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=tC(e,n);return zS.test(r)?r:tC(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function tC(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function nC(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:pe(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function rC(e,t){let n=Ne(t-864e5),[,r,i]=e.yesterday.day.split(`-`).map(Number),a=e.yesterday.day===n?`yesterday`:`${RS[r-1]} ${i}`,o=e.yesterday.sessionCount===1?`session`:`sessions`;return`${a}: ${e.yesterday.sessionCount} ${o}, ${nC(e.yesterday.activeMs/6e4)}`}function iC(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=RS[n.getMonth()];return r?`${r} ${n.getDate()} ${me(n)}`:`-`}var aC=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`}),oC=`Sessions spawned by Glimmervoid; terminal sessions count as other`,sC=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function cC(e){let t=it(e,``);return t?aC[t]||t:aC.other}function lC(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function uC(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function dC(e){return lC(e).some(e=>uC(e.lane))}var fC=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function pC(e,t,n){let r=DS(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function mC(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=>uC(e.lane)).map(e=>({lane:String(e.lane),label:cC(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?YS(c,a):YS(l,o),d=pC(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:fC[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function hC(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:aw.map(e=>mC(e.key,r[e.key],t,n)).filter(e=>e!==null)}function gC(e){return e.planPct===null?``:`about ${HS(e.planPct)} of plan`}function _C(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?xS(e.costUSD):SS(e.tokens)}`).join(`, `)}var vC=`team-review`;function yC(e){if(!Array.isArray(e?.byLane))return``;let t=lC(e).find(e=>e.lane===vC),n=S(t?.costUSD,0);if(n<=0)return``;let r=YS(n,e?.totals?.costUSD),i=r===null?``:`, ${HS(r)} of this period`;return`PR reviews cost ${xS(n)}${i}.`}function bC(e){let t=S(e,null);return t===null||t<=0?``:`${bS(t)} ${t===1?`session`:`sessions`}`}function xC(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function SC(e){let t=xC(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 ${xS(n)}${i}, across ${SS(S(t.cacheReadTokens,0))} cache read tokens.`}function CC(e){return e===`monthly`?`this month`:`today`}function wC(e){return`${xS(S(e?.spentUsd,0))} of ${xS(S(e?.budgetUsd,0))}`}function TC(e){return`${CC(e?.scope)} spend against budget`}var EC=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function DC(e){let t=zS.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function OC(e){let t=DC(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Ne(t)}function kC(e){let t=zS.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function AC(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 jC(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=gw(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 MC(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)||AC(r);jC(i,e),n.set(r,i)}return Array.from(n.values()).map(MC)}function PC(e){return NC(e,OC)}function FC(e){return NC(e,kC)}function IC(e,t){return t===`week`?PC(e):t===`month`?FC(e):Array.isArray(e)?[...e]:[]}var LC=/^(\d{4})-(\d{2})$/;function RC(e,t){if(t===`month`){let t=LC.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=RS[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=XS(e);return t===`-`?t:`week of ${t}`}return XS(e)}function zC(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var BC=16,VC=Object.freeze([.05,.25,.5,.75]),HC=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function UC(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<VC.length;e+=1)i>=VC[e]&&(a=e+1);return a}function WC(e,{weeks:t=BC,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>zS.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`&&zS.test(n)?n:Ne(o),c=DC(OC(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Ne(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=Ne(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:UC(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function GC(e){let t=XS(e?.day);if(e?.noData)return`${t}: no data`;let n=S(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${SS(n)} tokens, ${xS(S(e?.costUSD,0))}`}function KC(e){if(!e)return``;let t=S(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${XC(e.ratio)} the ${n} average: ${xS(e.todayUsd)} against ${xS(e.baselineUsd)}.`}function qC(e){return e?`This block is burning ${XC(e.ratio)} the usual rate: ${SS(e.current)} tokens per minute against ${SS(e.baseline)}.`:``}function JC(e){return[KC(e?.daily),qC(e?.burn)].filter(Boolean).join(` `)}function YC(e){return!!(e?.daily||e?.burn)}function XC(e){let t=S(e,null);return t===null?`-`:`${yS(t.toFixed(1))}x`}var ZC=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`,kimi:`Kimi`});function QC(e){let t=it(e,``);return t?ZC[t]||t:ZC.claude}function $C(e,t){return tw(t)?QC(e?.vendor):``}function ew(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:QC(e),tokens:S(t[e]?.tokens,0),costUSD:S(t[e]?.costUSD,0)}))}function tw(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 nw=`Claude only`;function rw(e){return tw(e)?nw:``}var iw=36e5,aw=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]),ow=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`},{vendor:`kimi`,label:`Kimi Code`}]);function sw(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 cw(e,t=Date.now()){let n=S(e,null);return n===null||n<=0||t-n>iw}function lw(e,t=Date.now()){if(!cw(e,t))return``;let n=sw(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function uw(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 dw(e){let t=it(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function fw(e){return PS(e)!==``}function pw(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 mw(e){return typeof e?.id==`string`&&e.id!==``}function hw(e){let t=it(e?.label,``);return mw(e)&&t?t:pw(e?.project)||t||`unknown project`}function gw(e){let t=typeof e==`string`?e:e?.model;return it(t,`unknown model`)}function _w(e){return String(e?.day??``)}function vw(e,t,n){if(!BS.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?_w(e):n(e)}function yw(e,t,n,r=hw){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=vw(e,t,r),o=vw(n,t,r);if(typeof i==`string`||typeof o==`string`)return a*String(i).localeCompare(String(o));if(i!==o)return a*(i-o);let s=Number(e?.tokens),c=Number(n?.tokens),l=Number.isFinite(s)?s:0,u=Number.isFinite(c)?c:0;return l===u?r(e).localeCompare(r(n)):u-l})}function bw(e){return VS.has(e)?`asc`:`desc`}function xw(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:bw(t)}}function Sw(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var Cw=Object.freeze({key:`lastTs`,dir:`desc`}),ww=Object.freeze({key:`tokens`,dir:`desc`}),Tw=Object.freeze({key:`day`,dir:`desc`});function Ew(e,t=Cw){return yw(e,t.key,t.dir,hw)}function Dw(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 Ow(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${bS(t)} hidden`}function kw(e,t=ww){return yw(e,t.key,t.dir,gw)}function Aw(e,t=Tw){return yw(e,t.key,t.dir,_w)}function jw(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function Mw(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,Pw=24*Nw,Fw=Object.freeze({fiveHour:{lengthMs:5*Nw,label:`5-hour`},sevenDay:{lengthMs:7*Pw,label:`weekly`}}),Iw=10,Lw=80,Rw=100,zw=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function Bw(e,t){return e>=Rw?`fail`:e>=Lw||t!==null&&t>=Lw?`warn`:`ok`}function Vw(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 Hw(e,t,n,r){let i=DS(n,t);if(!i||i.pct===null||i.resetsAtMs!==null&&i.resetsAtMs<=r)return null;let a=Fw[t],o=Vw(a.lengthMs,i.resetsAtMs,r),s=o!==null&&o>=Iw&&i.pct<Rw?i.pct/(o/100):null;return{vendor:e,vendorLabel:ow.find(t=>t.vendor===e)?.label||e,key:t,windowLabel:a.label,usedPct:i.pct,elapsedPct:o,projectedPct:s,resetsAtMs:i.resetsAtMs,tone:Bw(i.pct,s)}}function Uw(e,t){return ow.flatMap(({vendor:n})=>aw.map(({key:r})=>Hw(n,r,e[n],t)).filter(e=>e!==null))}function Ww(e,t){let n=S(e,null);if(n===null||n<=0)return``;let r=new Date(n),i=me(r);return Ne(n)===Ne(t)?i:n-t<7*Pw&&r.getDay()!==new Date(t).getDay()?`${zw[r.getDay()]} ${i}`:`${RS[r.getMonth()]} ${r.getDate()} ${i}`}function Gw(e){return`${Math.round(e)}%`}function Kw(e){return Math.max(e.usedPct,e.projectedPct??0)}function qw(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 Jw(e,t){let n=qw(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 ${Gw(100-r.usedPct)} of its ${r.windowLabel} window left.`}function Yw(e,t){let n=Ww(e,t);return!n||e===null?`until the window resets`:`until ${n}, in ${nC((e-t)/6e4)}`}function Xw(e,t,n){let r=[`${e.vendorLabel} sessions stop answering ${Yw(e.resetsAtMs,n)}. Their worktrees and conversations stay intact.`,Jw(t,e.vendor)];return{tone:`fail`,headline:`${e.vendorLabel} ${e.windowLabel} limit reached.`,detail:r.filter(Boolean).join(` `)}}function Zw(e,t){let n=Ww(e.resetsAtMs,t),r=n?`, resets ${n}`:``;if(e.usedPct>=Lw)return{tone:`warn`,headline:`${e.vendorLabel} ${e.windowLabel} limit is at ${Gw(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 ${Gw(e.projectedPct??e.usedPct)}.`}}function Qw(e){return{tone:`warn`,headline:`Over your ${CC(e.scope)===`today`?`daily`:`monthly`} budget.`,detail:`${wC(e)} spent ${CC(e.scope)}.`}}function $w(e,t,n,r){let i=e.find(e=>e.tone===`fail`);if(i)return Xw(i,e,r);let a=e.filter(e=>e.tone===`warn`).sort((e,t)=>Kw(t)-Kw(e))[0];if(a)return Zw(a,r);let o=t.find(e=>S(e.pct,0)>=100);if(o)return Qw(o);if(e.length===0)return{tone:`ok`,headline:n===null?`Nothing spent yet today.`:`${xS(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)=>Kw(t)-Kw(e))[0],c=Ww(s.resetsAtMs,r);return{tone:`ok`,headline:`Every limit has room.`,detail:`Closest is ${s.vendorLabel} ${s.windowLabel} at ${Gw(s.usedPct)}${c?`, resets ${c}`:``}.`}}function eT(e){return e.tone===`fail`?`limit reached`:e.projectedPct===null?e.elapsedPct===null?``:`too early to project`:`about ${Gw(e.projectedPct)} at reset`}var tT=`report`;function nT(e){return gS.find(t=>t.value===e)?.label||``}function rT(e,t){return{key:qS(e,t),dir:`desc`}}function iT(e,t){let n=kw(e?.models,rT(e?.totals,t))[0];if(!n)return null;let r=qS(e?.totals,t);return{label:gw(n),sharePct:YS(n[r],e?.totals?.[r])}}function aT(e,t){let n=Ew(e?.sessions,rT(e?.totals,t)),r=n[0];return{count:n.length,topLabel:r?hw(r):``}}function oT(e){let t=lC(e).filter(e=>uC(e.lane));return t.length===0?null:t.reduce((e,t)=>e+S(t.costUSD,0),0)}function sT(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 cT(e){return QS(e).length}function lT(e,t){let n=DC(e);return!n||t<=0?[]:Array.from({length:t},(e,r)=>{let i=new Date(n);return i.setDate(n.getDate()-(t-1-r)),Ne(i)})}function uT(e){return gS.find(t=>t.value===e)?.days??7}function dT(e){return e.reduce((e,t)=>t.resetsAtMs===null?e:e===null?t.resetsAtMs:Math.min(e,t.resetsAtMs),null)}function fT(e,t){let n=DC(e);return n?(n.setDate(n.getDate()+t),Ne(n)):``}function pT(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=String(e?.day??``);zS.test(n)&&r.set(n,(r.get(n)??0)+S(e?.[t],0))}return r}function mT(e,t){let n=DC(e);return n?t<=7?zw[n.getDay()]:String(n.getDate()):e}function hT(e,t,n,r){let i=pT(e,r===`cost`?`costUSD`:`tokens`),a=lT(n,t).map(e=>({day:e,label:mT(e,t),value:i.get(e)??0,isToday:e===n})),o=a.reduce((e,t)=>e+t.value,0),s=lT(fT(n,-t),t),c=s.reduce((e,t)=>e+(i.get(t)??0),0);return{metric:r,total:o,deltaPct:s.some(e=>i.has(e))&&c>0?(o-c)/c*100:null,average:a.length>0?o/a.length:0,peak:a.reduce((e,t)=>Math.max(e,t.value),0),bars:a}}function gT(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 _T(e){return`${KS(e.average,e.metric)} a day on average`}function vT(e){return tw(e)?ew(e).map(e=>`${e.label} ${xS(e.costUSD)}`).join(`, `):``}function yT(e){return tw(e)?ew(e).map(t=>({...t,sharePct:YS(t.tokens,e?.tokens)})):[]}function bT(e){let t=e?.totals,n=[{label:`Processed tokens`,value:SS(S(t?.tokens,0))},{label:`Cached input`,value:SS(S(t?.cacheRead,0))},{label:`Uncached input`,value:SS(S(t?.input,0))},{label:`Output`,value:SS(S(t?.output,0))}],r=S(xC(e?.savings)?.savedUSD,0);return r>0&&n.push({label:`Cache savings`,value:xS(r)}),n}function xT(e){let t=(e?.yourDay?.insights??[]).map(e=>({text:e.text,tone:`ok`})),n=e?.anomaly;YC(n)&&t.push({text:JC(n),tone:`warn`});for(let n of[SC(e?.savings),yC(e)])n&&t.push({text:n,tone:`ok`});return t}function ST(e,t,n,r){let i=qS(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:YS(e[i],t?.[i]),barPct:YS(e[i],a)??0}))}function CT(e,t){return ST(kw(e?.models,rT(e?.totals,t)),e?.totals,t,gw)}function wT(e,t){return ST(Ew(e?.sessions,rT(e?.totals,t)),e?.totals,t,hw)}function TT(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 ET=2e4,DT=`glimmervoid-usage-metric`,OT=null,kT=null,AT={claude:null,codex:null,kimi:null},jT=null,MT=null,NT=null,PT=_S,FT=GS(qn(DT,null)),IT=!1,LT=null,RT=null,zT=!0,BT=()=>!1,VT=new Set,HT=Tt({getAck:Nr,setAck:rr,signature:()=>kS(OT,AT.claude),isLooking:()=>BT()});function UT(e){for(let t of VT)t(e)}function WT(){jT?.(HT.refresh())}function GT(e){IT=e,UT(`refresh-status`),LT&&=(clearTimeout(LT),null),e&&(LT=setTimeout(()=>{LT=null,IT=!1,RT=`Usage did not answer within ${Math.round(ET/1e3)} s. Refresh to try again.`,UT(`refresh-status`)},ET))}function KT(e){let t=gS.find(t=>t.value===e);return t?t.days:null}function qT(){return{report:OT,sessions:kT,planLimitsByVendor:AT,rangeValue:PT,metric:FT}}function JT(){let e=!zT||!IT&&RT!==null;return zT?IT?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:RT??``,isPending:!1,hasFailure:e}:{text:OT?`${Ee} The figures below are from before the connection dropped.`:Ee,isPending:IT,hasFailure:e}}function YT(e){VT.add(e)}function XT(e){BT=e,WT()}function ZT(){HT.acknowledge(),WT()}function QT(e){jT=e,WT()}function $T(e){MT?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function eE(e){MT=e}function tE(e){PT=e}function nE(e){FT=e,Kn(DT,e)}function rE({force:e=!1}={}){if(!MT)return;NT=h(`usage`);let t={type:`request-usage-report`,requestId:NT};e&&(t.force=!0);let n=KT(PT);n!==null&&(t.days=n),RT=null,GT(!0),!MT(t)&&(RT=Ee,GT(!1))}function iE(e){zT=e,UT(`refresh-status`)}function aE(e){kT=e,UT(`sessions`)}function oE(e){let t=e;AT={...AT,[OS(t)]:t},UT(`plan-limits`),WT()}function sE(e){FS(e,NT)&&(RT=null,GT(!1),OT=e,UT(`report`),WT())}function cE(){let e=OT?.pricing||(kT?{source:kT.pricingSource}:null),t=jS(e?.fetchedAt),n=[AS(e,t!==null&&t>0?fS(t):``)],r=PS(OT);r&&n.push(r);let i=NS(OT?.scan);return i&&n.push(i),n}var lE=26,uE=97;function dE(e){return Object.values(e.elements).filter(e=>e.kind===`unit`)}function fE(e){let t=String.fromCharCode(uE+e%lE),n=Math.floor(e/lE);return n===0?t:`${t}${n+1}`}function pE(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 mE(e){let t=dE(e),n=pE(t),r=new Map;for(let e of t){let t=n.get(e.id)??1;r.set(t,[...r.get(t)??[],e])}let i=new Map,a=[];for(let e of[...r.keys()].sort((e,t)=>e-t)){let t=(r.get(e)??[]).sort((e,t)=>e.title.localeCompare(t.title)||e.id.localeCompare(t.id));for(let[n,r]of t.entries())i.set(r.id,t.length===1?String(e):`${e}${fE(n)}`),a.push(r)}return a.map(e=>({unitId:e.id,title:e.title,status:e.status,level:n.get(e.id)??1,label:i.get(e.id)??``,afterLabels:e.after.flatMap(e=>i.get(e)??[]),linkedBoardId:e.linkedBoardId}))}function hE(e){let t=new Map(dE(e).map(e=>[e.id,e])),n=new Set,r=[];function i(e){let a=r.indexOf(e);if(a!==-1)return[...r.slice(a),e];if(n.has(e))return null;r.push(e);for(let n of t.get(e)?.after??[]){let e=i(n);if(e)return e}return r.pop(),n.add(e),null}for(let e of t.keys()){let t=i(e);if(t)return t}return null}var gE=14,_E=30,vE=40,yE=120,bE=300,xE=400,SE=4e4,CE=2e4,wE=4e5,TE=6,EE=12,DE=3e3,OE=14,kE=8,AE=100,jE=6.6,ME=5,NE=10,PE=2,FE=[.5,.35,.65,.2,.8],IE=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}],LE={right:0,left:1,bottom:2,top:3},RE={left:0,right:1,top:2,bottom:3},zE=[1,0,3,2];function BE(e){return e===`left`||e===`right`}function VE(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function HE(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function UE(e){if(e.length===0)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}}function WE(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 GE(e){return e.from.y===e.to.y}function KE(e,t){let n=t.x+t.width,r=t.y+t.height;if(GE(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 qE(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 JE(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 YE(e){return e.slice(1).flatMap((t,n)=>{let r=e[n];return r?[{from:r,to:t}]:[]})}function XE(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function ZE(e){if(e.length<=_t.layoutWarnings)return[...e];let t=e.slice(0,_t.layoutWarnings-1);return[...t,`and ${e.length-t.length} more`]}function QE(e,t){return t.x>=e.x+e.width||t.x+t.width<=e.x}function $E(e,t,n){if(e.id===t.id)return{exitSide:`right`,entrySide:`top`};if(n)return{exitSide:`bottom`,entrySide:`bottom`};let r=VE(e),i=VE(t);return QE(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 eD=[`right`,`left`,`bottom`,`top`];function tD(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,...eD.filter(e=>e!==t.exitSide)],o=n.toSide?[n.toSide]:[t.entrySide,...eD.filter(e=>e!==t.entrySide)];return a.flatMap(e=>o.map(t=>({exitSide:e,entrySide:t})))}function nD(e,t){let n=e.outputPort??lD(e.from,t.exitSide,1)[0]??VE(e.from),r=lD(e.to,t.entrySide,1)[0]??VE(e.to);if(!mD(t.exitSide,t.entrySide))return{...e,...t,start:n,end:r};let i=hD(r,t.entrySide,e.to,n),a=i===r&&!e.outputPort?hD(n,t.exitSide,e.from,r):n;return{...e,...t,start:a,end:i}}function rD(e,t){return e.turnsAndCrossings<t.turnsAndCrossings||e.turnsAndCrossings===t.turnsAndCrossings&&e.cost<t.cost}function iD(e,t,n){let r=OD(e,t,{usageByEdge:new Map,usageByNodeAndAxis:new Map},null,n,{remainingExpansions:DE}),i=r?.at(-1),a=i===void 0?1/0:n.bestCost[i]??1/0;if(ED(n),!r||a===1/0)return null;let o=JE(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:YE(o),bends:Math.max(o.length-2,0),cost:a}}function aD(e,t){let n=t.filter(t=>t.segments.some(t=>e.segments.some(e=>qD(e,t)))).length;return{turnsAndCrossings:e.bends+n,cost:e.cost}}function oD(e,t,n){let r=new Map(e.map(e=>[e,tD(e,t.get(e)??{exitSide:e.exitSide,entrySide:e.entrySide})]));if(![...r.values()].some(e=>e.length>1))return;let i=yD([...r].flatMap(([e,t])=>t.map(t=>nD(e,t))),[...n.boxesById.values(),...n.panels],n.softObstacles,n.contentTop);if(!i)return;let a=TD(i),o=new Map(e.flatMap(e=>{let[t]=r.get(e)??[],n=t?iD(i,nD(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:aD(n,r)};for(let n of t.slice(1)){let t=iD(i,nD(e,n),a),o=t?aD(t,r):null;o&&rD(o,s.score)&&(s={pair:n,score:o})}s.pair&&(e.exitSide=s.pair.exitSide,e.entrySide=s.pair.entrySide)}}function sD(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 cD(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=$E(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??VE(r),end:VE(i)};return t.set(c,a),[c]});oD(n,t,e),sD(n,t);for(let e of n){let t=e.wire.fromOutput;e.exitKey=e.outputPort&&t?`${e.from.id}|output ${t}|${e.styleKey}`:`${e.from.id}|${e.exitSide}|${e.styleKey}`}let r=e=>`${e.to.id}|${e.entrySide}|${e.styleKey}`,i=new Map;for(let e of n)i.set(r(e),(i.get(r(e))??0)+1);for(let e of n)(i.get(r(e))??0)>1&&(e.busKey=r(e));return n}function lD(e,t,n){let r=Array.from({length:n},(e,t)=>t);if(BE(t)){let i=Math.round(t===`left`?e.x:e.x+e.width),a=Math.min(OE,(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+kE,Math.min(o,e.y+e.height-kE-(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)*OE/2;return r.map(e=>({x:Math.round(a+e*OE),y:i}))}function uD(e,t){let n=BE(t)?e.height:e.width;return Math.max(1,Math.floor((n-16)/OE)+1)}function dD(e){return WE(e.flatMap(e=>[...e.outputPort?[]:[{box:e.from,side:e.exitSide,groupKey:`exit|${e.styleKey}`,wireId:e.wire.id,farPoint:VE(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??VE(e.from),assign:t=>{e.end=t}}]),e=>`${e.box.id}|${e.side}`)}function fD(e){return new Map([...e.entries()].map(([e,t])=>[e,[...WE(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+(BE(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 pD(e,t){for(let[n,r]of e){let e=r[0],i=t.get(n)??[];if(!e)continue;let a=lD(e.box,e.side,i.length);for(let e of r){let t=a[i.indexOf(e.groupKey)];t&&e.assign(t)}}}function mD(e,t){return e===`right`&&t===`left`||e===`left`&&t===`right`||e===`bottom`&&t===`top`||e===`top`&&t===`bottom`}function hD(e,t,n,r){return BE(t)?r.y>=n.y+kE&&r.y<=n.y+n.height-kE?{x:e.x,y:r.y}:e:r.x>=n.x+kE&&r.x<=n.x+n.width-kE?{x:r.x,y:e.y}:e}function gD(e,t){let n=(e,n)=>(t.get(`${e.id}|${n}`)?.length??0)===1,r=new Map([...WE(e,e=>e.exitKey)].map(([e,t])=>[e,t.length]));for(let t of e){if(t.from.id===t.to.id||!mD(t.exitSide,t.entrySide))continue;let e=t.busKey===null&&n(t.to,t.entrySide)?hD(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=hD(t.start,t.exitSide,t.from,t.end)):t.end=e}}function _D(e,t){return[...e.entries()].flatMap(([e,n])=>{let r=n[0],i=t.get(e)?.length??0;return!r||i<=uD(r.box,r.side)?[]:[`box ${r.box.id} has ${i} wires on its ${r.side} side, more than fit`]})}function vD(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 yD(e,t,n,r){let i=[...t,...n],a=UE([...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-gE,e.x+e.width+gE]),a.x-42,a.x+a.width+42].map(Math.round),u=[...i.flatMap(e=>[e.y-gE,e.y+e.height+gE]),a.y-42,a.y+a.height+42].map(Math.round).filter(e=>e>=c),d=vD([...new Set([...l,...o])].sort((e,t)=>e-t)),f=vD([...new Set([...u,...s])].sort((e,t)=>e-t));if(d.length*f.length>SE)return null;let p=t.map(e=>HE(e,1)),m=(e,t)=>{let n=new Uint8Array(d.length*f.length);for(let[r,i]of f.entries())for(let[a,o]of d.entries()){let s=d[a+1],c=f[r+1],l=e===0?s===void 0?null:{from:{x:o,y:i},to:{x:s,y:i}}:c===void 0?null:{from:{x:o,y:i},to:{x:o,y:c}};l&&t.some(e=>KE(l,e))&&(n[r*d.length+a]=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 bD(){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 xD(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 SD(e,t){return`${e}\n${t}`}function CD(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(SD(t.busKey,t.exitKey))??0;return n+r-i}function wD(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?CD(a,t):0,c=s>0,l=a!==void 0&&a.total>s,u=o!==void 0&&o.total>CD(o,t);return(c?-i*.5:0)+(l?yE:0)+(u?vE:0)}function TD(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 ED(e){for(let t of e.touchedStates)e.bestCost[t]=1/0,e.cameFrom[t]=-1;e.touchedStates.length=0}function DD(e,t,n,r,i,a){let o=OD(e,t,n,r,i,a);return ED(i),o}function OD(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=LE[t.exitSide],m=RE[t.entrySide],{bestCost:h,cameFrom:g,touchedStates:ee}=i,_=bD(),v=d*4+p,te=(n,r)=>Math.abs((e.xs[n]??0)-t.end.x)+Math.abs((e.ys[r]??0)-t.end.y);h[v]=0,ee.push(v),_.push(v,te(s,c));for(let i=0;i<CE&&a.remainingExpansions>0;i+=1){--a.remainingExpansions;let i=_.pop();if(i===void 0)return null;let s=i>>2,c=i&3;if(s===f&&c===m)return kD(g,i);let l=s%o,u=(s-l)/o,v=h[i]??1/0;for(let[a,ne]of IE.entries()){if(s===d&&a!==p||a===zE[c])continue;let y=l+ne.x,b=u+ne.y;if(y<0||b<0||y>=o||b>=e.ys.length)continue;let re=b*o+y;if(re===f&&a!==m)continue;let ie=xD(e,l,u,a);if(s!==d&&re!==f&&e.isBlocked[ie.axis]?.[ie.index]===1)continue;let ae={x:e.xs[l]??0,y:e.ys[u]??0},oe={x:e.xs[y]??0,y:e.ys[b]??0},x=Math.abs(oe.x-ae.x)+Math.abs(oe.y-ae.y),se=r!==null&&KE({from:ae,to:oe},r),ce=x+(a===c?0:_E)+(e.isSoft[ie.axis]?.[ie.index]===1?bE:0)+(se?xE:0)+wD(n,t,ie,re,x),le=re*4+a,ue=v+Math.max(ce,1);ue>=(h[le]??1/0)||(h[le]=ue,g[le]=i,ee.push(le),_.push(le,ue+te(y,b)))}}return null}function kD(e,t){let n=[];for(let r=t;r!==-1;r=e[r]??-1)n.push(r);return n.reverse()}function AD(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,SD(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=xD(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 jD(e,t){let n=IE[LE[t]]??{x:0,y:0};return{x:e.x+n.x*gE,y:e.y+n.y*gE}}function MD(e){let t=jD(e.start,e.exitSide),n=jD(e.end,e.entrySide);return JE([e.start,t,{x:n.x,y:t.y},n,e.end])}function ND(e,t){if(!e.wire.back)return null;let n=UE([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 PD(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?JE(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}})):MD(t);return{plan:t,points:r,segments:YE(r),states:n}}function ID(e,t,n){let r=yD(e,[...t.boxesById.values(),...t.panels],t.softObstacles,t.contentTop),i=r?TD(r):null,a={usageByEdge:new Map,usageByNodeAndAxis:new Map},o=new Map;for(let s of PD(e,e=>e)){let e=r&&i?DD(r,s,a,ND(s,t.loopFrames),i,n):null;r&&e&&AD(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 LD(e){return Math.max(0,e.points.length-2)}function RD(e,t,n){let r=t.filter(t=>XD(e,t)!==null).length;return QD([e],n).length*AE+r}function zD(e,t){let{grid:n,usage:r}=e;if(!n)return e.drawn;let i=TD(n),a={remainingExpansions:wE},o=new Map(e.drawn.map(e=>[e.plan.wire.id,e]));for(let s of PD(e.drawn,e=>e.plan)){if(!s.states||a.remainingExpansions<=0)continue;let e=[...o.values()].filter(e=>e.plan!==s.plan),c=RD(s,e,t);if(c===0)continue;AD(n,r,s.plan,s.states,-1);let l=FD(n,s.plan,DD(n,s.plan,r,ND(s.plan,t.loopFrames),i,a)),u=LD(l)<=Math.max(LD(s),TE),d=l.states&&u&&RD(l,e,t)<c?l:s;AD(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 BD(e){return Math.ceil(e.length*jE)}function VD(e,t){return{x:e.x-t/2,y:e.y-NE,width:t,height:13}}function HD(e){return Math.abs(e.from.x-e.to.x)+Math.abs(e.from.y-e.to.y)}function UD(e,t){if(!GE(e))return[];let n=e.from.y;return[Math.min(e.from.x,e.to.x)+ME+t/2,Math.max(e.from.x,e.to.x)-ME-t/2].flatMap(e=>[{x:e,y:n-ME},{x:e,y:n+ME+NE}])}function WD(e,t){let n=[...e].sort((e,t)=>HD(t)-HD(e));return[...e.slice(0,1),...n].flatMap(e=>[...FE.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 GE(e)?[{x:r,y:i-ME},{x:r,y:i+ME+NE}]:[{x:r+ME+t/2,y:i+NE/2},{x:r-ME-t/2,y:i+NE/2}]}),...UD(e,t)])}function GD(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=BD(e),c=WD(o.segments,s),l=c.find(e=>{let n=VD(e,s);if(n.y<t.contentTop)return!1;let o=HE(n,PE);return i.some(e=>KE(e,o))||a.some(e=>qE(n,e))?!1:![...r.values()].some(e=>qE(n,e.bounds))}),u=l??c[0]??VE(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 KD(e,t,n){return e>Math.min(t,n)+.5&&e<Math.max(t,n)-.5}function qD(e,t){if(GE(e)===GE(t))return!1;let n=GE(e)?e:t,r=n===e?t:e;return KD(r.from.x,n.from.x,n.to.x)&&KD(n.from.y,r.from.y,r.to.y)}function JD(e,t){if(GE(e)!==GE(t))return!1;let n=GE(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 YD(e,t){return e.plan.busKey!==null&&e.plan.busKey===t.plan.busKey||e.plan.exitKey===t.plan.exitKey}function XD(e,t){if(YD(e,t))return null;let n=e.segments.flatMap(e=>t.segments.map(t=>[e,t]));return n.some(([e,t])=>qD(e,t))?`wire ${e.plan.wire.id} crosses wire ${t.plan.wire.id}`:n.some(([e,t])=>JD(e,t))?`wire ${e.plan.wire.id} overlaps wire ${t.plan.wire.id}`:null}function ZD(e){return e.flatMap((t,n)=>e.slice(n+1).flatMap(e=>XD(t,e)??[]))}function QD(e,t){let n=[...t.boxesById.values(),...t.panels];return e.flatMap(e=>n.flatMap(t=>{if(t.id===e.plan.from.id||t.id===e.plan.to.id)return[];let n=HE(t,-2);return e.segments.some(e=>KE(e,n))?[`wire ${e.plan.wire.id} runs through ${t.kind} ${t.id}`]:[]}))}function $D(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=LD(e);return t>TE?[`wire ${e.plan.wire.id} bends ${t} times`]:[]})}function eO(e,t){return GE(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 tO(e,t){if(!t||t===e)return null;let n=e.points.find(e=>t.segments.some(t=>eO(e,t)));return!n||n.x===e.plan.end.x&&n.y===e.plan.end.y?null:n}function nO(e,t){let n=e[t],r=e[t+1];n!==void 0&&r!==void 0&&(e[t]=r,e[t+1]=n)}function rO(e,t,n,r,i){pD(n,r),gD(e,r);let a=ID(e,t,i);return{routed:a,crossingCost:QD(a.drawn,t).length*AE+ZD(a.drawn).length}}function iO(e,t,n,r,i){let a=rO(e,t,n,r,i);if(e.length>EE)return zD(a.routed,t);for(let o of r.values())for(let s=0;a.crossingCost>0&&s+1<o.length;s+=1){nO(o,s);let c=rO(e,t,n,r,i);c.crossingCost<a.crossingCost?a=c:nO(o,s)}return zD(rO(e,t,n,r,i).routed,t)}function aO(e){let t=cD(e),n=dD(t),r=fD(n),i={remainingExpansions:wE},a=iO(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=GD(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:XE(n),start:t.start,end:t.end,label:t.wire.label,labelAt:c.get(t.wire.id)?.at??VE(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:tO(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,...QD(a,e),...ZD(a),...$D(a),..._D(n,r),...s],extent:UE([...f,...d])}}var L=40,oO=44,sO=220,cO=90,lO=30,uO=12,dO=20,fO=18,pO=28,mO=12,hO=2,gO=20,_O=26,vO=18,yO=26,bO=170,xO=21,SO=17,CO=10,wO=22,TO=24,EO=16,DO=16,OO=26,kO=24,AO=8,jO=10,MO=14,NO=4,PO=40,FO=26,IO=24,LO=8,RO=320,zO=Object.freeze({blue:`#60a5fa`,green:`#4ade80`,orange:`#fb923c`,pink:`#f472b6`,cyan:`#22d3ee`,yellow:`#facc15`});function BO(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 VO(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>mO){let t=BO(e.text,n-r-hO).map(e=>a(e,1,hO,null));return[a(``,0,0,i),...t]}let o=e.style===`item`?hO:i?i.length+1:0;return BO(e.text,n-r-o-+(e.style===`code`)).map((e,t)=>a(e,t,o,i))}function HO(e,t=_O){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,VO(e,n,t)))}function UO(e,t){let n=e.lanes.find(e=>e.id===t.lane);return n?{label:n.label||n.id,hex:zO[n.color]}:null}function WO(e){return e.column!==null&&e.at===null&&e.near===null}function GO(e){return e.width??sO}function KO(e,t){return Math.floor(e*(t-24)/196)}function qO(e){if(!e.media)return null;let t=GO(e),n=t-24,r=Math.round(RO*t/sO);return{width:n,height:Math.min(r,Math.max(1,Math.round(n*e.media.height/e.media.width)))}}function JO(e,t,n,r){return!e.media||!r?null:{kind:e.media.kind,asset:e.media.asset,mime:e.media.mime,hasPreview:e.media.hasPreview,alt:e.media.alt,x:t.x+uO,y:t.y+n,width:r.width,height:r.height}}function YO(e,t){let n=GO(t),r=KO(gO,n),i=BO(t.title,r),a=t.change===`relabeled`&&t.was?BO(t.was,r):[],o=HO(t.lines,KO(_O,n)),s=UO(e,t),c=s!==null&&!WO(t),l=uO+(a.length+i.length)*dO+o.length*fO,u=qO(t),d=u?u.height+LO:0,f=l+uO+d+(c?26:0),p=t.shape===`decision`?t.outputs:[];return{titleLines:i,wasLines:a,bodyLines:o,lane:s,showsLanePill:c,headerHeight:f,outputs:p,mediaTop:l+LO,mediaSize:u,height:f+p.length*pO}}function R(e,t){return Object.values(e.elements).filter(e=>e.kind===t)}function XO(e){let t=BO(e.text,xO);return{lines:t,height:24+(t.length+1)*SO}}function ZO(e){let t=new Map;for(let n of R(e,`note`)){let e=t.get(n.on),r=XO(n).height;t.set(n.on,e===void 0?r:e+CO+r)}return t}function QO(e){return e.columns.map(e=>e.title?BO(e.title,TO):[])}function $O(e){return(Math.max(1,...e.map(e=>e.length))-1)*EO}function ek(e,t){let n=R(e,`box`).filter(WO),r=new Set(n.filter(e=>t.has(e.id)).map(e=>e.column)),i=new Set(R(e,`frame`).flatMap(e=>e.contains)),a=new Set(n.filter(e=>i.has(e.id)).map(e=>e.column)),o=e=>jO+(e!==void 0&&a.has(e)?vO: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(cO,186):cO}})}function tk(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)*MO:0,s=a>0?e.left+e.right+a+20:0;return Math.max(e.minimumWidth,o,s)})}function nk(e){let t=new Map(e.columns.map((e,t)=>[e.id,t])),n=e.columns.map(()=>sO);for(let r of R(e,`box`).filter(WO)){let e=t.get(r.column)??0;n[e]=Math.max(n[e]??sO,GO(r))}return n}function rk(e,t){let n=[],r=L;for(let[i,a]of e.entries())n.push(r),r+=a+(t[i]??cO);return n}function ik(e,t){return(e.at(-1)??L)+(t.at(-1)??sO)}function ak(e){let t=new Map;for(let n of R(e,`frame`))for(let e of n.contains)t.has(e)||t.set(e,n.id);return t}function ok(e,t){return e===t?0:(e?vO:0)+(t?44:0)}function sk(e,t){return e.lanes.some(e=>e.id===t.lane)?t.lane??``:``}function ck(e,t){let n=new Set(t.map(t=>sk(e,t)));return[``,...e.lanes.map(e=>e.id)].filter(e=>n.has(e))}function lk(e,t,n){let r=YO(e,t),i=GO(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:JO(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*pO+pO/2}}))}}function uk(e,t,n,r,i,a){let o=ak(e),s=R(e,`box`).filter(WO).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=ck(e,s),l=c.some(e=>e!==``),u=ik(t,n),d=[],f=r;for(let n of c){let r=e.lanes.find(e=>e.id===n),c=f+(l?FO:0),p=new Map,m=new Map;for(let r of s){if(sk(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)+ok(m.get(r.column)??null,l),d=lk(e,r,{x:t[s]??L,y:u}),f=(i.get(r.id)??0)-AO;p.set(r.column,u+Math.max(d.height,f)+lO),m.set(r.column,l),a.set(r.id,d)}let h=Math.max(c,...p.values())-lO;l&&d.push({id:n,label:r?r.label||r.id:``,hex:r?zO[r.color]:``,x:L,y:f,width:u-L,height:h-f}),f=h+IO+lO}return d}function dk(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 fk(e,t){let n=[...e.values()].map(e=>e.x+e.width);return{x:n.length>0?Math.max(...n)+cO:L,y:t}}function pk(e,t,n,r){let i=R(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:GO(i),height:YO(e,i).height},f=u?dk(u,i.near,d):fk(n,t),p=lk(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 mk(e,t,n,r,i){let a=ik(n,r),o=Math.max(a,...t.map(e=>e.x+e.width))+cO,s=R(e,`panel`).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id)),c=i;return s.map(e=>{let t=BO(e.title,gO),n=HO(e.lines),r=24+t.length*dO+n.length*fO,i={kind:`panel`,id:e.id,x:Math.round(o),y:c,width:sO,height:r,titleLines:t,bodyLines:n};return c+=r+lO,i})}function hk(e,t,n,r,i){let a=new Map,o=[],s=uk(e,t,n,r,i,a);for(let t of R(e,`box`))t.at&&a.set(t.id,lk(e,t,t.at));pk(e,r,a,o);for(let t of R(e,`box`))a.has(t.id)||a.set(t.id,lk(e,t,fk(a,r)));return{boxesById:a,bands:s,warnings:o}}function gk(e,t){return R(e,`frame`).flatMap(e=>{let n=UE(e.contains.flatMap(e=>t.get(e)??[]));return n?[{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,x:n.x-vO,y:n.y-vO-yO,width:n.width+36,height:n.height+36+yO}]:[]})}function _k(e){return e.resolvedBy?`resolved by ${e.resolvedBy}`:e.author?`from ${e.author}`:``}function vk(e,t){let n=new Map;return R(e,`note`).flatMap(e=>{let r=t.get(e.on);if(!r)return[];let{lines:i,height:a}=XO(e),o=n.get(e.on)??r.y-AO;return n.set(e.on,o+a+CO),[{kind:`note`,id:e.id,x:r.x+r.width-kO,y:o,width:bO,height:a,lines:i,byline:_k(e),isResolved:e.resolvedBy!==null}]})}function yk(e,t,n,r){let i=UE([...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-L),y:Math.min(0,i.y-L),width:i.width+80,height:i.height+80}:{x:0,y:0,width:n+L,height:80}}function bk(e,t){return e.slice(0,-1).map((n,r)=>{let i=n+(t[r]??sO);return{left:i,right:e[r+1]??i}})}function xk(e,t,n){let r=e.segments.filter(e=>e.from.x===e.to.x).map(e=>e.from.x);return bk(t,n).map(e=>new Set(r.filter(t=>t>e.left&&t<e.right)).size)}function Sk(e,t,n){return bk(t,n).map(t=>Math.max(0,...e.wires.flatMap(e=>e.label&&e.labelAt.x>t.left&&e.labelAt.x<t.right?[BD(e.label)]:[])))}function Ck(e,t,n,r){let i=[...e.values()],a=[...i,...t],o=a.flatMap((e,t)=>a.slice(t+1).flatMap(t=>qE(e,t)?[`${e.kind} ${e.id} overlaps ${t.kind} ${t.id}`]:[])),s=new Map(R(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:yO};return!s.get(e.id)?.has(t.id)&&qE(t,n)?[`box ${t.id} covers the title of frame ${e.id}`]:[]}));return[...o,...c]}function wk(e,t){let n=nk(e),r=rk(n,t.gapWidths),{boxesById:i,bands:a,warnings:o}=hk(e,r,n,t.boxesTop,t.stackHeightByBoxId),s=gk(e,i),c=vk(e,i),l=mk(e,[...i.values(),...c],r,n,t.boxesTop),u=aO({wires:R(e,`wire`),boxesById:i,panels:l,softObstacles:[...c,...s.map(e=>({x:e.x,y:e.y,width:e.width,height:yO}))],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,...Ck(i,l,s,e)],tracksByGap:xk(u,r,n),labelWidthByGap:Sk(u,r,n)}}function Tk(e,t){return Array.from({length:Math.max(e.length,t.length)},(n,r)=>Math.max(e[r]??0,t[r]??0))}function Ek(e,t){let n=[],r=[];for(let i=1;;i+=1){let a=wk(e,{gapWidths:tk(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>=NO||!o&&!s)return a;n=Tk(n,a.tracksByGap),r=Tk(r,a.labelWidthByGap)}}function Dk(e){let t=BO(e.title,gO),n=HO(e.lines),r=+!!e.linkedBoardId;return{titleLines:t,bodyLines:n,height:42+t.length*dO+(n.length+r)*fO}}function Ok(e){let t=new Map,n=new Map;for(let r of mE(e)){let i=e.elements[r.unitId];if(i?.kind!==`unit`)continue;let a=Dk(i),o=n.get(r.level)??70;n.set(r.level,o+a.height+lO),t.set(i.id,{kind:`unit`,id:i.id,x:L+(r.level-1)*310,y:o,width:sO,height:a.height,label:r.label,status:i.status,titleLines:a.titleLines,bodyLines:a.bodyLines,linkedBoardId:i.linkedBoardId})}return t}function kk(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(cO/2);return XE(JE([n,{x:i,y:n.y},{x:i,y:r.y},r]))}function Ak(e,t){return R(e,`unit`).flatMap(e=>{let n=t.get(e.id);return n?e.after.flatMap(e=>{let r=t.get(e);return r?[kk(r,n)]:[]}):[]})}function jk(e){return e.size===0?L:Math.max(...[...e.values()].map(e=>e.y+e.height))+PO}function Mk(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 Nk={plain:null,fail:`failure path`,join:`joins`,lane:null};function Pk(e,t,n){return`${e}|${t}|${n}`}function Fk(e,t,n){let r=[Nk[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var Ik={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function Lk(e){let t=new Set(R(e,`box`).map(e=>e.change));return ht.flatMap(e=>e===`none`||!t.has(e)?[]:[{label:Ik[e],swatch:{kind:`change`,change:e}}])}function Rk(e){return e.size===0?[]:mt.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}}))}function zk(e,t){let n=e.lanes.map(e=>({label:e.label||e.id,swatch:{kind:`lane`,hex:zO[e.color]}})),r=new Map(e.legend.map(e=>[Pk(e.tone,e.dashed||e.back,e.back),e.label])),i=new Set,a=R(e,`wire`).flatMap(e=>{let t=e.dashed||e.back,n=Pk(e.tone,t,e.back),a=r.get(n)??Fk(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,...Lk(e),...Rk(t)]}function Bk(e){let t=Ok(e),n=jk(t),r=n-L,i=Mk(e,r),a=ZO(i),o=QO(i),s=$O(o),c=n+OO+s,l=n+oO+s,u=Ek(i,{reserves:ek(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=yk(p,u.routing.extent,ik(d,f),l),h=m.y+m.height,g=zk(i,t).map((e,t)=>({...e,x:L,y:h+t*wO})),ee=h+g.length*wO+(g.length>0?12:0),_=i.caption?{text:i.caption,x:L,y:ee}:null,v=g.length*wO+(_?30:0)+(g.length>0?12:0);return{columns:i.columns.map((e,t)=>({id:e.id,titleLines:o[t]??[],titleBaselineY:n+DO,ruleY:c,x:d[t]??L,width:f[t]??sO})),bands:u.bands,elements:p,legend:g,caption:_,pinnedOffsetY:r,plan:t.size>0?{titleAt:{x:L,y:56},arrowPaths:Ak(i,t)}:null,bounds:{...m,height:m.height+v},warnings:ZE([...u.placementWarnings,...u.routing.warnings])}}function Vk(e){return JSON.stringify(e)}var Hk=Object.freeze({box:ft,frame:et,wire:qe,note:He,unit:Ge,panel:lt}),Uk=80,z={ok:!0},Wk=Object.freeze({id:`operator`,name:`operator`});function Gk(e){return e.id===Wk.id}function Kk(e,t){return Gk(t)?{...e,author:e.author===``?t.name:e.author}:{...e,author:t.name,resolvedBy:null}}function B(e){return{ok:!1,error:e}}function qk(e,t){return e.elements[t]?.kind===`box`}function Jk(e,t){if(t.kind===`box`)return Zk(e,t);if(t.kind===`unit`)return $k(e,t);if(t.kind===`wire`)return qk(e,t.from)?qk(e,t.to)?Yk(e,t):B(`wire ${t.id} ends at ${t.to}, which is not a box`):B(`wire ${t.id} starts at ${t.from}, which is not a box`);if(t.kind===`note`)return qk(e,t.on)?z:B(`note ${t.id} is on ${t.on}, which is not a box`);if(t.kind!==`frame`)return z;let n=t.contains.find(t=>!qk(e,t));return n?B(`frame ${t.id} contains ${n}, which is not a box`):z}function Yk(e,t){if(t.fromOutput===null)return z;let n=e.elements[t.from];return n?.kind!==`box`||n.shape!==`decision`?B(`wire ${t.id} starts at output ${t.fromOutput}, but ${t.from} is not a decision`):n.outputs.some(e=>e.id===t.fromOutput)?z:B(`wire ${t.id} starts at output ${t.fromOutput}, which decision ${t.from} does not have`)}function Xk(e,t){if(t.shape!==`decision`&&t.outputs.length>0)return B(`box ${t.id} has outputs, which only a decision has, so set shape to decision`);let n=new Set(t.outputs.map(e=>e.id));if(n.size!==t.outputs.length)return B(`box ${t.id} has two outputs with the same id`);let r=Object.values(e.elements).find(e=>e.kind===`wire`&&e.from===t.id&&e.fromOutput!==null&&!n.has(e.fromOutput));return r?.kind===`wire`?B(`wire ${r.id} still starts at output ${r.fromOutput} of ${t.id}, so change or remove that wire first`):z}function Zk(e,t){let n=Xk(e,t);return n.ok?t.change===`relabeled`&&!t.was?B(`box ${t.id} is relabeled, so give its old title in was`):t.column===null&&t.near===null&&t.at===null?B(`box ${t.id} needs a place: a column, near another box, or at a point`):t.column!==null&&!e.columns.some(e=>e.id===t.column)?B(`box ${t.id} names column ${t.column}, which the board does not have, so add it with a columns op first`):t.lane!==null&&!e.lanes.some(e=>e.id===t.lane)?B(`box ${t.id} names lane ${t.lane}, which the board does not have, so add it with a lanes op first`):t.near===null?z:t.near.of===t.id?B(`box ${t.id} cannot sit near itself`):qk(e,t.near.of)?Qk(e,t.near.of,t.id)?B(`box ${t.id} sits near ${t.near.of}, which already sits near ${t.id}, so they would place each other`):z:B(`box ${t.id} sits near ${t.near.of}, which is not a box`):n}function Qk(e,t,n){let r=new Set,i=t;for(;i!==void 0&&!r.has(i);){if(i===n)return!0;r.add(i);let t=e.elements[i];i=t?.kind===`box`?t.near?.of:void 0}return!1}function $k(e,t){if(t.after.includes(t.id))return B(`unit ${t.id} cannot come after itself`);let n=t.after.find(t=>e.elements[t]?.kind!==`unit`);return n?B(`unit ${t.id} comes after ${n}, which is not a unit on this board`):z}function eA(e,t,n){if(e.elements[t.id])return B(`an element with id ${t.id} already exists`);if(Object.keys(e.elements).length>=_t.elements)return B(`a board holds at most ${_t.elements} elements`);if(t.kind===`unit`&&dE(e).length>=_t.units)return B(`a board holds at most ${_t.units} units`);let r=t.kind===`note`?Kk(t,n):t,i=Jk(e,r);return i.ok?(e.elements[t.id]=r,z):i}function tA(e,t,n){return e.kind!==`note`||!(`text`in t||`on`in t)?{}:{author:n.name,resolvedBy:null}}function nA(e,t,n,r){let i=e.elements[t];if(!i)return B(`no element has id ${t}`);if(`kind`in n||`id`in n)return B(`set cannot change an element kind or id; remove it and add a new one`);if(!Gk(r)&&(`author`in n||`resolvedBy`in n))return B(`set cannot change who wrote or resolved a note; resolve it with a resolve op`);let a=Hk[i.kind].safeParse({...i,...tA(i,n,r),...n});if(!a.success)return B(`${t}: ${a.error.issues[0]?.message??`invalid fields`}`);let o=Jk(e,a.data);return o.ok?(e.elements[t]=a.data,z):o}function rA(e,t){let n=e.elements[t];if(!n)return B(`no element has id ${t}`);if(n.kind===`box`&&iA(e,t),delete e.elements[t],n.kind===`unit`){for(let n of dE(e))n.after.includes(t)&&(e.elements[n.id]={...n,after:n.after.filter(e=>e!==t)});return z}if(n.kind!==`box`)return z;for(let n of Object.values(e.elements))aA(e,n,t);return z}function iA(e,t){let n=Object.values(e.elements).flatMap(e=>e.kind===`box`&&e.near?.of===t?[e]:[]);if(n.length===0)return;let r=Bk(e);for(let t of n){let n=r.elements.find(e=>e.id===t.id);n&&n.kind===`box`&&(e.elements[t.id]={...t,near:null,at:{x:n.x,y:n.y-r.pinnedOffsetY}})}}function aA(e,t,n){if(t.kind===`wire`&&(t.from===n||t.to===n)||t.kind===`note`&&t.on===n){delete e.elements[t.id];return}if(t.kind!==`frame`)return;let r=t.contains.filter(e=>e!==n);r.length===0?delete e.elements[t.id]:e.elements[t.id]={...t,contains:r}}function oA(e,t,n){let r=e.elements[t];return r?.kind===`note`?(e.elements[t]={...r,resolvedBy:n.name},z):B(`no note has id ${t}`)}function sA(e,t,n){let r=new Set(t.map(e=>e.id));if(r.size!==t.length)return B(`column ids must be unique`);let i=Object.entries(n).find(([,e])=>!r.has(e));if(i)return B(`move sends column ${i[0]} to ${i[1]}, which is not in the new columns`);let a=Object.values(e.elements).flatMap(e=>e.kind!==`box`||e.column===null?[]:[{...e,column:Object.hasOwn(n,e.column)?n[e.column]??e.column:e.column}]),o=a.find(e=>e.column!==null&&!r.has(e.column));if(o)return B(`box ${o.id} is still in removed column ${o.column}, so name it in move or remove the box first`);for(let t of a)e.elements[t.id]=t;return e.columns=t,z}function cA(e,t){let n=new Set(t.map(e=>e.id));if(n.size!==t.length)return B(`lane ids must be unique`);e.lanes=t;for(let t of Object.values(e.elements))t.kind===`box`&&t.lane!==null&&!n.has(t.lane)&&(e.elements[t.id]={...t,lane:null});return z}function lA(e,t,n){switch(t.op){case`add`:return eA(e,t.element,n);case`set`:return nA(e,t.id,t.fields,n);case`remove`:return rA(e,t.id);case`resolve`:return oA(e,t.id,n);case`columns`:return sA(e,t.columns,t.move);case`lanes`:return cA(e,t.lanes);case`board`:return t.title!==void 0&&(e.title=t.title),t.caption!==void 0&&(e.caption=t.caption),t.legend!==void 0&&(e.legend=t.legend),t.codeSessionId!==void 0&&(e.codeSessionId=t.codeSessionId),z}}function uA(e,t,n,r){let i=structuredClone(e),a=e.version+1,o=[];for(let[e,r]of t.entries()){let t=dA(r),s=t===null?void 0:i.elements[t],c=lA(i,r,n);if(!c.ok)return{ok:!1,error:`op ${e+1}: ${c.error}`,opIndex:e};o.push({version:a,author:n.id,elementId:t,summary:`${n.name} ${hA(r,s,i)}`})}let s=hE(i);return s?{ok:!1,error:`that makes a dependency cycle: ${s.join(`, `)}`,opIndex:t.length-1}:(i.version=a,i.updatedAt=r,{ok:!0,board:i,changes:o})}function dA(e){return e.op===`add`?e.element.id:e.op===`set`||e.op===`remove`||e.op===`resolve`?e.id:null}function V(e,t,n=e.elements[t]){return n?n.kind===`box`||n.kind===`frame`||n.kind===`unit`||n.kind===`panel`?`"${n.title||t}"`:n.kind===`wire`?`wire ${V(e,n.from)} to ${V(e,n.to)}`:`note ${t}`:t}function fA(e,t,n){return n.length===0?`cleared what ${V(e,t)} comes after`:`set ${V(e,t)} to come after ${n.map(t=>V(e,t)).join(`, `)}`}function pA(e,t,n){let r=Object.keys(e.fields),i=n.elements[e.id];return r.length===1&&r[0]===`at`?`moved ${V(n,e.id)}`:r.length===1&&r[0]===`linkedBoardId`?i?.kind===`unit`&&i.linkedBoardId===null?`unlinked ${V(n,e.id)} from its board`:`linked ${V(n,e.id)} to a board`:r.length===1&&r[0]===`after`&&i?.kind===`unit`?fA(n,i.id,i.after):r.length===1&&r[0]===`status`&&i?.kind===`unit`?`marked ${V(n,e.id)} ${i.status}`:t?.kind===`box`&&i?.kind===`box`&&r.length===1&&r[0]===`title`?`renamed "${t.title}" to "${i.title}"`:`changed ${r.join(`, `)} of ${V(n,e.id)}`}function mA(e){return e.title===void 0?e.caption===void 0?e.codeSessionId===void 0?`set the legend`:e.codeSessionId===null?`cleared the code session`:`set the code session to ${e.codeSessionId}`:`changed the caption`:`renamed the board to "${e.title}"`}function hA(e,t,n){switch(e.op){case`add`:{let t=e.element;return t.kind===`note`?`note on ${V(n,t.on)}${t.ref?` at ${t.ref}`:``}: ${t.text.slice(0,Uk)} (note ${t.id})`:`added ${t.kind} ${V(n,t.id)}`}case`set`:return pA(e,t,n);case`remove`:return`removed ${t?.kind??`element`} ${V(n,e.id,t)}`;case`resolve`:return t?.kind===`note`?`resolved note ${e.id} on ${V(n,t.on)}`:`resolved note ${e.id}`;case`columns`:return`set the columns to ${e.columns.map(e=>e.title||e.id).join(`, `)||`none`}`;case`lanes`:return`set the lanes to ${e.lanes.map(e=>e.label||e.id).join(`, `)||`none`}`;case`board`:return mA(e)}}var gA=new Map,_A=new Map,vA=[],yA=[],bA=[],xA=new Map;function SA(){for(let e of[...vA])e()}function CA(e){for(let t of yA)t(e)}function wA(e){return e.type===`whiteboard-result`}async function TA(e,t){try{let n=await a(e,t,{timeoutMs:In});return wA(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:Fn(e,In)}}}function EA(e){let t=_A.get(e);if(t)return t;let n=TA(`whiteboard-get`,{boardId:e}).then(t=>{_A.delete(e),t.ok&&t.reply.board&&(gA.set(e,t.reply.board),CA(e))});return _A.set(e,n),n}function DA(){return bA}function OA(e){return gA.get(e)??null}function kA(e){return gA.has(e)?Promise.resolve():EA(e)}function AA(e){return vA.push(e),()=>{let t=vA.indexOf(e);t>=0&&vA.splice(t,1)}}function jA(e){yA.push(e)}function MA(){let e=new Map;for(let t of bA)for(let n of t.connectedSessionIds){let r=e.get(n);r?r.push(t):e.set(n,[t])}xA=e}var NA=!1;function PA(){return NA}function FA(e){bA=[...e.boards].sort((e,t)=>t.updatedAt-e.updatedAt),MA();let t=new Map(bA.map(e=>[e.id,e.version]));for(let[e,n]of[...gA]){let r=t.get(e);r!==n.version&&(gA.delete(e),r===void 0?CA(e):EA(e))}SA(),NA=!0}function IA(e){let t=gA.get(e.boardId);if(!t||t.version>=e.toVersion)return;if(t.version!==e.fromVersion){gA.delete(e.boardId),EA(e.boardId);return}let n=uA(t,e.ops,e.author,e.updatedAt);!n.ok||n.board.version!==e.toVersion?(gA.delete(e.boardId),EA(e.boardId)):(gA.set(e.boardId,n.board),CA(e.boardId))}function LA(e){gA.delete(e.boardId),bA=bA.filter(t=>t.id!==e.boardId),MA(),CA(e.boardId),SA()}async function RA(e){let t=await TA(`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 zA(e,t){let n=await TA(`whiteboard-op`,{boardId:e,ops:t});return n.ok?{ok:!0}:n}async function BA(e){let t={"x-glimmervoid-upload-name":encodeURIComponent(e.name)};e.type&&(t[`content-type`]=e.type);let n=await fetch(ot,{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=ct.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 VA(e){let t=await TA(`whiteboard-delete`,{boardId:e});return t.ok?{ok:!0}:t}async function HA(e,t){let n=await TA(`whiteboard-connect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function UA(e,t){let n=await TA(`whiteboard-disconnect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function WA(e,t){let n=await TA(`whiteboard-nudge`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function GA(e){let t=await TA(`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 KA=null;function qA(e){KA=e}function JA(e,t){KA?.(e,t)}function YA(e){return xA.get(e)??[]}var XA=null;function ZA(e,t){XA={boardId:e,sessionId:t}}function QA(){let e=XA;return XA=null,e}var $A=()=>{};function ej(e){$A=e}function tj(e,t){ZA(e,t),$A()}function nj(e,t){let n=e.queuedBySessionId[t]??0;return n===0?``:`${n} queued`}function rj(e,t,n){let r=nj(e,t),i=r?`wait`:`muted`;return{key:`board:${e.id}`,text:n,detailText:e.title,stateText:r,look:{icon:`board`,tone:i},tier:Kt(i),className:`session-pr-chip session-board-chip`,ariaLabel:`Open board ${e.title}`,onActivate:()=>tj(e.id,t)}}function ij(e,t){let n=nj(e,t);return rj(e,t,n?`${e.title}, ${n}`:e.title)}function aj(e){return YA(e).map(t=>rj(t,e,t.title))}function oj(e,t,n){let r=ij(e,t),i=Ve(`session-pr-chip-unlink`);i.append(x(gt)),i.setAttribute(`aria-label`,`Disconnect board ${e.title}`),i.addEventListener(`click`,r=>{r.stopPropagation(),r.preventDefault(),Vt({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:()=>{UA(e.id,t).then(e=>n(e.ok?null:e.error))}})});let a=E(`span`,`session-pr-chip-item`);return a.append(rn(r,r),i),a}function sj(e){let{dialog:t,close:n,actions:r,btnCancel:i}=Ut({title:`Connect board`}),a=E(`div`,`session-pr-chips dialog-linked-prs`),o=E(`p`,`dialog-message`,`A connected session is told what others changed on the board with its next whiteboard get or prompt.`),s=E(`select`,`dialog-input`);s.setAttribute(`aria-label`,`Board to connect`);let c=jn(`action-status`),l=C({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=YA(e);fn(a,t.map(t=>ij(t,e)),n=>{let r=t.find(e=>`board:${e.id}`===n.key);return r?oj(r,e,u):rn(n,n)});let n=DA().filter(t=>!t.connectedSessionIds.includes(e));s.replaceChildren(...n.map(e=>{let t=E(`option`,null,e.title);return t.value=e.id,t})),n.length===0&&s.append(E(`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,HA(t,e).then(e=>{e.ok?n():(c.show(`error`,e.error),d())}))}),i.addEventListener(`click`,n);let f=AA(()=>{t.isConnected?d():f()});d()}AA(sn);function cj(){return j.snapshot().borrowedCardId}var lj=null;function uj(e,t,n,{className:r,onRelease:i}={}){if(!e?.card||!n)return;let a=cj();a&&a!==t&&dj();let o=e.card;o._cardHostClass&&o._cardHostClass!==r&&o.classList.remove(o._cardHostClass),o._cardHostClass=r||``,r&&o.classList.add(r),Rt(o,n),lj=i??null,j.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function dj(){let e=cj(),t=lj;if(lj=null,t?.(),j.dispatch(`borrowCard`,null),!e)return null;let n=O.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,jt(r,Tn)),e}var fj=null,pj=null,mj={},hj=null,gj=null,_j=null,vj=new Map,yj=new Map;function bj(){return pj??=M(()=>import(`./phone-shell-vH02KbDK.js`).then(e=>{e.mountPhoneShell(mj),_j&&e.orderPhonePanels(_j);for(let[t,n]of vj)e.setPhoneScreenAvailable(t,n);for(let[t,n]of yj)e.setPhoneScreenAttention(t,n);return fj=e,e},e=>(pj=null,u(`phone-shell`,`phone shell failed to load: ${d(e)}`),null)),__vite__mapDeps([28,13,5,3,29,12,14,22,15,30,31,25,32,4,6,7,23,33,26,34])),pj}function xj(e){mj=e}async function Sj(e){let t={options:e};hj=t;let n=await bj();if(hj!==t)return!1;if(!n)return hj=null,gj=null,!1;hj=null,n.activatePhoneShell(t.options);let r=gj;return gj=null,r?.(n),!0}function Cj(){hj=null,gj=null,fj?.deactivatePhoneShell()}function wj(){return hj!==null||(fj?.isPhoneShellActive()??!1)}function Tj(){return hj?hj.options?.sessionId??null:fj?.getPhoneSessionId()??null}function Ej(e){_j=e,fj?.orderPhonePanels(e)}function Dj(e,t){vj.set(e,t),fj?.setPhoneScreenAvailable(e,t)}function Oj(e,t){yj.set(e,t),fj?.setPhoneScreenAttention(e,t)}function kj(){fj?.refreshPhoneBoard()}function Aj(){fj?.syncPhoneHistory()}function jj(e){return hj?(gj=t=>{e(t)},!0):fj?e(fj):!1}function Mj(e){return jj(t=>t.showPhonePlan(e))}function Nj(e){return jj(t=>t.showPhoneSession(e))}function Pj(e){return jj(t=>t.showPhoneScreen(e))}function Fj(){let e=Tj();e&&k(e)?._isActiveViewer?.()===!0&&iS(e)}function Ij(){Nu(k(cj())),Fj()}function Lj(){window.addEventListener(`focus`,Ij),window.addEventListener(`blur`,Ij),document.addEventListener(`visibilitychange`,Ij),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Ua()}),window.addEventListener(`pageshow`,e=>{e.persisted&&Ua()})}function Rj(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function zj(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function Bj({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=Rj(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=zj(e.key,a);if(n===null)return;e.preventDefault();let r=u(t.getBoundingClientRect().width+l*n);r!==null&&s(r)})}var Vj={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.`}},Hj=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:kt[e],meaning:t}),Uj=Object.freeze([Hj(w.DORMANT,`Not started yet.`),Hj(w.STARTING,`Setting up the worktree and booting the agent.`),Hj(w.RUNNING,`The agent is mid-turn.`),Hj(w.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),Hj(w.WAITING,`Waiting on a permission prompt or your answer.`),Hj(w.COMPLETE,`Finished a turn you have not looked at yet.`),Hj(w.IDLE,`Ready for the next prompt.`),Hj(w.DONE,`The agent process ended.`),Hj(w.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 Wj(e,t){let n=E(`section`,`status-legend`),r=E(`dl`,`status-legend-rows`);return r.append(...t),n.append(E(`h2`,`status-legend-title`,e),r),n}function Gj(e,t){let n=E(`div`,`status-legend-row`);return n.append(e,E(`dd`,`status-legend-meaning`,t)),n}function Kj(){return Wj(`Status colors`,Uj.map(e=>{let t=E(`dt`,`status-legend-badge`),n=E(`span`,`status-legend-glyph`),r=E(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=Gj(t,e.meaning);return Yt(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function qj(){return Wj(`Pull request icons`,Object.keys(Vj).map(e=>{let t=Vj[e],n=E(`dt`,`status-legend-badge`);return n.append(pi(e),E(`span`,`status-legend-name`,t.label)),Gj(n,t.meaning)}))}var Jj=null,Yj=null,Xj=!1,Zj=null;function Qj(){return Yj??=M(()=>import(`./first-run-checklist-DafZ5DVx.js`).then(e=>(Jj=e,e),e=>(Yj=null,u(`first-run`,`first-run checklist failed to load: ${d(e)}`),null)),__vite__mapDeps([35,12,13,5,3,15,31,14,22,25,32,4,6,7,23,36,37])),Yj}function $j(e,t){Zj={host:e,isShown:t},Jj?Jj.showFirstRunChecklist(e,t):t&&Xj&&Qj().then(e=>{e&&Zj&&e.showFirstRunChecklist(Zj.host,Zj.isShown)})}function eM(){Jj?.refreshFirstRunChecklist()}function tM(){Xj=!0,Zj&&$j(Zj.host,Zj.isShown)}var nM=`(no path)`;function rM(e){if(!e)return nM;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||`(no path)`}function iM(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=t(e),i=n?String(n):nM,a=r.get(i);a||(a={key:i,label:i===`(no path)`?nM:rM(i),title:i,rows:[]},r.set(i,a)),a.rows.push(e)}let i=[...r.values()];return i.sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0,sensitivity:`base`})||e.key.localeCompare(t.key)),{flat:r.size<=1,order:i.map(e=>e.key),groups:i}}function aM(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 oM(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))}function sM({onAdd:e}){let t=E(`div`,`session-group-header`),n=E(`span`,`session-group-label`),r=E(`span`,`session-group-count`),i=E(`span`,`session-group-rule`);i.setAttribute(`aria-hidden`,`true`);let a=C({variant:`icon`,size:`small`,label:`Add session to this project`,icon:x(Ae),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 cM(e,t){let{header:n,label:r,count:i,addButton:a}=e,o=t.key===nM;oi(n,`path`,t.key),oi(n,`label`,t.label),Br(r,t.label),Br(i,String(t.rows.length)),Wr(a,o)}var lM={waitingCount:0,finishedCount:0,failedCount:0},uM={failed:Bt[w.FAILED],waiting:Bt[w.WAITING],finished:Bt[w.COMPLETE]},dM={failed:`failed`,waiting:`needs you`,finished:`finished`},fM=[`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`],pM=2500,mM=`cubic-bezier(0.16, 1, 0.3, 1)`,hM=`cubic-bezier(0.5, 0, 0.2, 1)`,gM=260,_M=200,vM=200,yM=300,bM=28,xM=360,SM=420,CM=200,wM=3,TM=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),EM=new WeakMap;function DM(e){let t=EM.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function OM(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function kM(){return TM?.matches??!1}function AM(e){return e.map(e=>({easing:mM,...e}))}function jM(e,t){let n=E(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${En.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${En.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${En.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${En.overflowSlot}px`);let r=E(`span`,`attention-banner-chips`),i=E(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=E(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=E(`span`,`attention-banner-status`);o.append(r,E(`span`,`attention-banner-count`),a);let s=Ve(`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),EM.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(()=>NM(n)).observe(r),MM(n,lM,[]),n}function MM(e,t,n){let r=DM(e);r.tiles=n,Br(Pt(e,`.attention-banner-count`),bn(t));let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&YM(e,r),NM(e)}function NM(e){let t=DM(e),n=Pt(e,`.attention-banner-chips`),r=Pt(n,`.attention-tile-overflow`),i=OM(e),a=t.tiles.slice(0,xn(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():LM(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??FM(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),IM(s,i,a===0),(s.parentElement!==n||PM(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;Wr(r,p===0),Br(r,`+${p}`),Rr(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)&&VM(e,null),i){for(let e of d)RM(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?BM(r,a):a!==0&&zM(r,a,n)})}}function PM(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function FM(e,t){let n=E(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=E(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>VM(e,t)),n.addEventListener(`pointerleave`,()=>VM(e,null)),n}function IM(e,{kind:t,name:n},r){e.dataset.kind=t,e.toggleAttribute(`data-head`,r);let i=`${n}, ${dM[t]}`;e.setAttribute(`aria-label`,i),Ln(Pt(e,`.attention-tile-icon`),uM[t])}function LM(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=kM()?[{opacity:1},{opacity:0}]:AM([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:vM,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function RM(e){let t=kM()?[{opacity:0},{opacity:1}]:AM([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:_M})}function zM(e,t,n){kM()||e.animate(AM([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:yM,delay:n*bM,fill:`backwards`})}function BM(e,t){kM()?e.animate([{opacity:.35},{opacity:1}],{duration:xM,easing:mM}):e.animate(AM([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:xM})}function VM(e,t){let n=DM(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 HM(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function UM(e,t,n){let r=DM(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!OM(e)){n();return}VM(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=HM(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(WM(o,s),GM(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function WM(e,t){return!t||kM()?[{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 GM(e){return!e||kM()?{duration:CM,fill:`forwards`}:{duration:SM,easing:hM,fill:`forwards`}}function KM(e){let t=DM(e);e.hasAttribute(`data-empty`)&&JM(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!OM(e))return;let n={duration:gM};if(t.pressAnimations.push(e.animate(AM([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!kM()){t.pressAnimations.push(e.animate(AM([{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(AM([{transform:`none`},{transform:`translateY(${wM}px)`,offset:.3},{transform:`none`}]),n),r.animate(AM([{transform:`none`},{transform:`translateY(-${wM}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function qM(e){let t=fM.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??fM[0]}function JM(e,t){let n=qM(t.lastAllClearLine);t.lastAllClearLine=n,Pt(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>YM(e,t),pM)}function YM(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var XM={terminal:`Terminal`,board:`Board`},ZM=[`terminal`,`board`],QM=.05,$M=`application/x-glimmervoid-pane-tab`;function eN(){let e=kr(),t=new Set([`terminal`]),n=cr(e,t),r=null,i=!1,a=E(`div`,`pane-layout`),o=E(`div`,`pane-trail`),s=E(`div`,`pane-divider`);s.setAttribute(`role`,`separator`),s.setAttribute(`aria-label`,`Resize panes`),s.tabIndex=0;let c={terminal:p(`terminal`),board:p(`board`)},l={terminal:h(`terminal`),board:h(`board`)},u={terminal:m(`terminal`),board:m(`board`)},d=new Map,f=[g(0),g(1)];function p(e){let t=E(`div`,`pane-body`);return t.id=`focus-pane-${e}`,t.dataset.pane=e,t.setAttribute(`role`,`tabpanel`),t}function m(e){let t=E(`div`,`pane-title`);return t.dataset.tab=e,t}function h(e){let t=Ve(`pane-tab`);return t.append(E(`span`,`sr-only`,XM[e])),t.draggable=!0,t.dataset.tab=e,t.setAttribute(`role`,`tab`),t.setAttribute(`aria-controls`,`focus-pane-${e}`),t.addEventListener(`click`,()=>v(e)),t.addEventListener(`dragstart`,t=>{r=e,t.dataTransfer?.setData($M,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`),a.dataset.dragging=``}),t.addEventListener(`dragend`,_),t}function g(t){let i=E(`section`,`pane-group`),a=E(`div`,`pane-strip pane-header`),o=E(`div`,`pane-tabs`);o.setAttribute(`role`,`tablist`),a.append(o);let s=E(`div`,`pane-group-body`);return i.append(a,s),i.addEventListener(`dragover`,e=>{r&&(e.preventDefault(),i.dataset.dropZone=ee(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=ee(i,a,o),c=n.groupIndexes[t],l=r;_(),c!==void 0&&y(wr(e,l,c,s))}),{group:i,strip:a,tabList:o,body:s}}function ee(e,t,n){if(n.target instanceof Node&&t.contains(n.target))return`join`;let r=e.getBoundingClientRect();return fr(n.clientX-r.left,n.clientY-r.top,r)}function _(){r=null,delete a.dataset.dragging;for(let{group:e}of f)delete e.dataset.dropZone}function v(t){i&&t===`terminal`||te(Jn(e,t))}function te(t){i?(i=!1,t===e?oe():y(t)):y(t)}function ne(e){let t=jr(e).findIndex(e=>e.tabs.includes(`terminal`));return Jn(wr(e,`board`,t,`join`),`terminal`)}function y(t){t!==e&&(e=t,tr(e),oe())}function b(e,t){t.parentElement!==e&&e.append(t)}function re(e,t){e.children.length===t.length&&t.every((t,n)=>e.children[n]===t)||e.replaceChildren(...t)}function ie(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 ae(e,t,n){let r=u[t];r.hidden=!n,e.tabList.nextElementSibling!==r&&e.tabList.after(r)}function oe(){n=cr(i?ne(e):e,t);for(let e of ZM)l[e].draggable=!i;for(let e of ZM)u[e].hidden=!0,t.has(e)||(c[e].hidden=!0);let r=yr(n.groups);a.dataset.direction=n.direction??`single`;let p=n.groups.map((e,t)=>({group:e,parts:f[t]}));for(let{group:e,parts:t}of p){if(!t)continue;re(t.tabList,e.tabs.map(e=>l[e]));for(let n of e.tabs){let r=n===e.activeTab;l[n].setAttribute(`aria-selected`,String(r)),l[n].tabIndex=r?0:-1,b(t.body,c[n]),c[n].hidden=!r}let n=d.get(e.activeTab);ie(t,n),ae(t,e.activeTab,n===void 0)}let[m,h]=f;if(!m||!h)return;b((f[r]??m).strip,o);let g=n.groups.length===2?[m.group,s,h.group]:[m.group];re(a,g),m.group.style.flex=`${n.firstShare} 1 0`,h.group.style.flex=`${1-n.firstShare} 1 0`,s.setAttribute(`aria-orientation`,n.direction===`row`?`vertical`:`horizontal`),s.setAttribute(`aria-valuenow`,String(Math.round(n.firstShare*100)))}function x(e){let t=a.getBoundingClientRect();return n.direction===`row`?(e.clientX-t.left)/t.width:(e.clientY-t.top)/t.height}s.addEventListener(`pointerdown`,e=>{e.button===0&&(s.setPointerCapture(e.pointerId),s.dataset.dragging=`true`,e.preventDefault())}),s.addEventListener(`pointermove`,t=>{s.hasPointerCapture(t.pointerId)&&(e=Or(e,x(t)),oe())});let se=t=>{s.hasPointerCapture(t.pointerId)&&(s.releasePointerCapture(t.pointerId),delete s.dataset.dragging,tr(e))};return s.addEventListener(`pointerup`,se),s.addEventListener(`pointercancel`,se),s.addEventListener(`keydown`,t=>{let n={ArrowLeft:-.05,ArrowUp:-.05,ArrowRight:QM,ArrowDown:QM}[t.key];n!==void 0&&e.kind===`split`&&(t.preventDefault(),y(Or(e,e.firstShare+n)))}),oe(),{element:a,trailSlot:o,bodyOf:e=>c[e],titleSlotOf:e=>u[e],setStripHost:(e,t)=>{t&&d.set(e,t),t||d.delete(e),oe()},showTabs:(e,n)=>{t=e,i=n?.holdSplit===!0,oe()},showTab:t=>te(Jn(e,t))}}var tN=5,nN={high:`High`,medium:`Medium`,low:`Low`};function rN(e,t){let n=Ve(`review-look-line`,e.path);return n.append(E(`span`,`review-look-detail`,e.detail)),n.addEventListener(`click`,()=>t(e.openPath)),n}function iN(e,t){let n=E(`div`,`review-look-group`);n.dataset.kind=e.kind;let r=E(`p`,`review-look-text`,e.heading);if(e.conflictRisk){let t=E(`span`,`review-look-risk`,`Conflict risk: ${nN[e.conflictRisk]}`);t.dataset.risk=e.conflictRisk,r.append(` `,t)}n.append(r);for(let r of e.lines)n.append(rN(r,t));return n}function aN(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=E(`section`,`review-look`);if(i.append(E(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=E(`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,tN);if(a.length>0){let e=E(`div`,`review-look-list`);for(let t of a)e.append(iN(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=E(`div`,`review-look-more`),c=C({variant:`quiet`,size:`small`,label:`Show all`,action:`show-all-worth-a-look`,onClick:n});return s.append(E(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function oN(e){return(e??[]).map(e=>E(`span`,`review-file-hint`,e.text))}var sN=`changes`,cN={add:`+`,del:`-`,meta:`\\`},H=null,lN=null,U=null,W=null,uN=null,dN=!1;function fN(){let e=E(`section`,`review-reader`);e.setAttribute(`aria-label`,`Changes`),e.tabIndex=-1,e.hidden=!0;let t=E(`div`,`review-reader-bar`),n=E(`p`,`review-reader-status`);n.setAttribute(`role`,`status`);let r=E(`p`,`review-reader-notice`);r.setAttribute(`role`,`status`);let i=E(`div`,`review-reader-actions`),a=C({variant:`primary`,label:`Merge`,action:`merge-session`,onClick:()=>{U&&mv(U)}}),o=C({variant:`danger`,label:`Discard`,action:`discard-session`,onClick:()=>{U&&hv(U)}}),s=C({variant:`secondary`,label:`Close`,action:`close-reader`,onClick:gg});i.append(a,o,s),t.append(n,r,i);let c=E(`div`,`review-reader-body`),l=E(`div`,`review-reader-files`),u=E(`div`,`review-reader-diff`);return c.append(l,u),e.append(t,c),e.addEventListener(`keydown`,mN),q_(e=>{e===U&&vN()}),Hr(()=>{W=null,dN=!1,vN(),hN()}),vv(e),{root:e,status:n,notice:r,mergeButton:a,discardButton:o,closeButton:s,fileColumn:l,diff:u}}function pN(){return H??=fN(),H}function mN(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Nt(e))return;let t=e.key===`j`?1:e.key===`k`?-1:0;if(t===0||!U)return;e.preventDefault();let n=D_(Q_(U)?.files??[],W,t);n&&gN(n)}function hN(){U&&ug(sN,U)}function gN(e){W=e,vN(),H?.fileColumn.querySelector(`.review-reader-file[aria-current="true"]`)?.scrollIntoView({block:`nearest`}),hN()}function _N(e){let t=E_(e,uN);t&&(W=t.path,uN=null),!E_(e,W)&&(W=lN===`overlay`?e[0]?.path??null:null)}function vN(){if(!H||lN===null)return;U=zr();let e=U?Q_(U):null;if(H.closeButton.hidden=lN!==`overlay`,!e){yN(H);return}let t=W!==null;_N(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=lN===`screen`&&W!==null?`diff`:`list`,bN(H.fileColumn,e),wN(H.diff,E_(e.files,W)),t!==(W!==null)&&hN()}function yN(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 bN(e,t){let n=e.scrollTop;if(e.replaceChildren(),t.diffError){e.append(E(`p`,`review-diff-error`,t.diffError));return}if(t.isEmpty){e.append(E(`p`,`review-empty-title`,t.sentence));return}t.totals.files>0&&e.append(xN(t.totals));let r=E(`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?p_(i,e.path):null;n&&n!==a&&r.append(E(`div`,`review-repo-label`,n)),a=n,r.append(SN(e,t))}e.append(r);let o=t.changeMapView?aN(t.changeMapView,{isShowingAll:dN,onShowAll:TN,onOpenFile:EN}):null;o&&e.append(o),e.scrollTop=n}function xN(e){let t=E(`p`,`review-reader-totals`);return t.append(E(`span`,`review-stat-files`,`${e.files} file${e.files===1?``:`s`}`),E(`span`,`review-add`,`+${e.added}`),E(`span`,`review-del`,`-${e.removed}`)),t}function SN(e,t){let n=Ve(`review-reader-file`);n.dataset.path=e.path,n.setAttribute(`role`,`listitem`),n.setAttribute(`aria-current`,String(e.path===W));let r=E(`span`,`review-file-name`);r.append(E(`span`,`review-file-path`,e.path));let i=oN(t.changeMapView?.hintsByOpenPath.get(e.path));if(i.length>0){let e=E(`span`,`review-file-hints`);e.append(...i),r.append(e)}return n.append(r,CN(e)),n.addEventListener(`click`,()=>gN(e.path)),n}function CN(e){let t=E(`span`,`review-file-counts`);return e.binary?(t.append(E(`span`,`review-bin`,`bin`)),t):(t.append(E(`span`,`review-add`,`+${e.added}`),E(`span`,`review-del`,`-${e.removed}`)),t)}function wN(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=E(`div`,`review-reader-diff-head`);if(r.append(E(`span`,`review-file-path`,t.path),CN(t)),e.append(r),t.binary){e.append(E(`div`,`review-file-binary`,`Binary file not shown`));return}let i=E(`div`,`review-file-body`);for(let e of t.hunks){i.append(E(`div`,`review-hunk-head`,e.header));for(let t of e.lines){let e=E(`div`,`review-line review-line-${t.type}`);e.append(E(`span`,`review-line-gutter`,cN[t.type]??` `),E(`span`,`review-line-text`,t.text)),i.append(e)}}e.append(i),e.scrollTop=n}function TN(){dN=!0,vN()}function EN(e){let t=E_(U?Q_(U)?.files??[]:[],e);t&&gN(t.path)}function DN(e,t){let{root:n}=pN();n.parentElement!==e&&e.append(n),lN=t,n.dataset.placement=t,n.hidden=!1}function ON(){H&&(H.root.hidden=!0,H.root.remove(),lN=null)}function kN(){W!==null&&(W=null,vN(),hN())}function AN(e,t){t===`header`&&(vv(e),new MutationObserver(_v).observe(e,{attributes:!0,attributeFilter:[`data-slot-held`]}))}q_(e=>ug(sN,e));var jN={id:sN,label:`Changes`,iconPath:at,isAvailableFor:e=>Q_(e)!==null,hasUnreadFor:()=>!1,mount(e,t,{placement:n,target:r}){DN(e,n),uN=r,vN(),n===`overlay`&&pN().root.focus({preventScroll:!0})},unmount:ON,canStepBack:()=>lN===`screen`&&W!==null,stepBack:kN,attachButton:AN};function MN(){cg(jN),cg(Bg)}var NN=new Set([`terminal`]),PN=new Set([`terminal`,`board`]),FN=new Set([`board`]),IN=e=>e.ui.path,LN=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),RN=null,G=null,zN=null,BN=null,K=null,VN=null,HN=null,UN=null,WN=null,GN=null,KN=null,qN=null,q=null,JN=null,YN=new Map,XN=null,ZN=null,QN=null,J=!1,$N=!1,eP=null,tP=new Map,Y=new Map,nP=new Map,rP=new Map,X=null,iP=``,aP=[],oP=new Set;function sP(){return aM(lP(yP()),oP)}function cP(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 lP(e){return iM(e,IN)}function uP(e){let t=rP.get(e.key),n=nP.get(e.key);return(!t||!n)&&(t=sM({onAdd:Jr}),n=E(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),rP.set(e.key,t),nP.set(e.key,n)),cM(t,e),Rr(n,`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function dP(){return J}function Z(){return j.snapshot().focusedSessionId}function fP(){return J&&q!==null}function pP({rail:e,center:t,resizer:n}){if(RN=e,zN=t,!RN||!zN)return;let r=RN,i=zN;gP(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,mr(Sl)),G=jM({onJump:RP,rowFor:e=>Y.get(e)},Ol());let a=E(`details`,`rail-status-key`);a.append(E(`summary`,`rail-status-key-summary`,`Status key`),Kj()),r.append(G,a),XN=E(`div`,`focus-empty`),XN.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,ZN=XN.querySelector(`.focus-empty-title`),QN=XN.querySelector(`.focus-empty-desc`),K=eN(),K.element.addEventListener(`click`,WP),BN=K.bodyOf(`terminal`),JN=AP(),MN(),VN=bg({style:`header`}),K.trailSlot.append(VN.element),i.append(XN,K.element),AA(()=>{if(!J)return;let e=q!==null;kP(),e&&q===null&&dF()}),r.addEventListener(`keydown`,_P)}var mP={minPx:180,maxPx:480},hP=16;function gP(e){e&&RN&&Bj({resizer:e,column:RN,widthHost:RN,widthProperty:`--rail-width`,bounds:mP,keyStepPx:hP,getStoredWidth:xr,setStoredWidth:er})}function _P(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(),Yr(n);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=vP(),n=t.find(t=>t===e.target)??(X?Y.get(X):null),r=n?t.indexOf(n):-1,i=_n(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&&cP(a.dataset.id),a.focus())}function vP(){return RN?[...RN.querySelectorAll(`button.session-row[data-id], button.session-row[data-board-id]`)]:[]}function yP(){return Sn(ti(bP))}function bP(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function xP(e){let{row:t,refs:n}=on();t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,()=>SP(e)),t.addEventListener(`pointerenter`,()=>{G&&VM(G,e)}),t.addEventListener(`pointerleave`,()=>{G&&VM(G,null)});let{item:r,removeButton:i}=Zt(t,()=>Yr(e),()=>ci(e));r.setAttribute(`role`,`presentation`),i.tabIndex=-1;let a=E(`span`,`session-row-shown`);return a.hidden=!0,a.append(x(ze),E(`span`,`session-row-shown-count`)),n.name.after(a),Object.assign(t,{_refs:n,_row:r,_shownCount:a})}function SP(e){let t=ii(e);t&&wP(t,e)}function CP(e){let t=ii(e);t&&wP(t,e)}function wP(e,t){eF(t),BP(e,t)}function TP(e,t){Wr(e,t===0),Rr(e,`aria-label`,`${t} shown ${t===1?`file`:`files`} not opened`);let n=e.querySelector(`.session-row-shown-count`);n&&Br(n,String(t))}function EP(e,{id:t,ui:n,state:r,name:i},a){let o=tP.get(t)||`none`;e.classList.toggle(`focused`,t===Z()),nn(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a}),TP(e._shownCount,Ng(t));let s=t===X;Rr(e,`aria-selected`,String(s)),Rr(e,`tabindex`,s?`0`:`-1`)}function DP(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||``:Wn(r._refs?.glyph))}Rn(DP),Gn((e,t)=>{if(!J)return;let n=Y.get(e);n&&Br(n._refs.elapsed,Un(t))});var OP=new Map;function kP(e){if(!J)return;let t=RN;if(!t)return;let n=yP(),r=lP(n),i=new Set,a=Cn(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=xP(t),Y.set(t,r));let s=o.get(t)??null;(!e||a||e.has(t)||OP.get(t)!==s)&&EP(r,n,s),OP.set(t,s)}a||si(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===iP;iP=l;for(let e of r.groups){let{header:n,list:r}=uP(e);u||t.append(n,r),s(e.rows,r)}JN&&(!u||JN.header.parentElement!==t)&&t.append(JN.header,JN.list),JN&&MP(JN);for(let[e,t]of[...rP])c.has(e)||(t.header.remove(),nP.get(e)?.remove(),rP.delete(e),nP.delete(e));for(let[e,t]of Y)i.has(e)||(t._row.remove(),Y.delete(e),OP.delete(e),e===X&&(X=null));for(let e of[...tP.keys()])O.has(e)||tP.delete(e);let d=aP;aP=aM(r,oP);let f=Z();if(f&&!Kr(f)){gg(),j.dispatch(`focusSession`,null),X=null;let e=FP(d,f);if(e){let t=!document.activeElement||document.activeElement===document.body;eF(e),t&&BP(O.get(e),e);return}}tF();let p=Z();if(p){let e=O.get(p);e&&e.card.parentElement!==BN&&HP(e,p)}VN?.showSession(q?null:p),YP(),LP(n,a)}function AP(){let e=E(`div`,`session-group-header focus-boards-header`),t=E(`span`,`session-group-count`),n=E(`span`,`session-group-rule`);n.setAttribute(`aria-hidden`,`true`);let r=C({variant:`icon`,size:`small`,label:`New board`,icon:x(Ae),action:`new-board`,onClick:PP});e.append(E(`span`,`session-group-label`,`Boards`),t,n,r);let i=E(`div`,`focus-rail-list focus-board-list`);return i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,`Boards with no session`),{header:e,count:t,list:i}}function jP(e){let{row:t,refs:n}=on();t.dataset.boardId=e,t.addEventListener(`click`,()=>NP(e));let r=E(`div`,`session-row-item`);return r.append(t),Object.assign(t,{_refs:n,_row:r})}function MP(e){let t=DA();q&&!t.some(e=>e.id===q)&&(q=null);let n=oM(t,e=>O.has(e)),r=new Set(n.map(e=>e.id));for(let[e,t]of YN)r.has(e)||(t._row.remove(),YN.delete(e));for(let e of n){let t=YN.get(e.id);t||(t=jP(e.id),YN.set(e.id,t)),ln(t,t._refs,e.title),t.classList.toggle(`focused`,e.id===q)}si(e.list,n.flatMap(e=>YN.get(e.id)?._row??[])),Br(e.count,String(n.length)),Rr(e.count,`aria-label`,`${n.length} ${n.length===1?`board`:`boards`} with no session`)}function NP(e){J&&($P(),q=e,GN=null,cP(null),kP())}function PP(){GP().then(e=>e.createBoardFromDialog(NP),KP)}function FP(e,t){let n=e.filter(e=>e===t||Kr(e));if(n.length<2)return aP.find(e=>Kr(e))??null;let r=n.indexOf(t)===n.length-1;return _n(n,t,r?-1:1)}function IP(){return Cn(yP(),Z())}function LP(e,t){G&&MM(G,Dn(e),t)}function RP(){if(!J)return;G&&KM(G);let e=IP()[0]?.id;e&&zP(e)}function zP(e){J&&(ii(e),Y.get(e)?.scrollIntoView({block:`nearest`}),G&&UM(G,e,()=>VP(e)),eF(e),BP(O.get(e),e))}function BP(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{J&&Z()===t&&e.term?.focus()}))}function VP(e){if(LN?.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=O.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function HP(e,t){if(!BN)return;let n=e.card.querySelector(`:scope > .session-card-header`);uj(e,t,BN,{className:`focus-centered`,onRelease:()=>{n?.classList.remove(`pane-header`),K?.setStripHost(`terminal`,null)}}),n?.classList.add(`pane-header`),n&&UP(n),Fu(e,t,!0)}function UP(e){let t=e.querySelector(`:scope > .session-name`);K?.setStripHost(`terminal`,{parent:e,before:t})}function WP(e){if(!(e.target instanceof Element)||!e.target.closest(`.pane-tab[data-tab="terminal"]`))return;let t=Z(),n=t?O.get(t):null;n&&n.face!==`terminal`&&n._showTerminalFace?.()}function GP(){return HN??=M(()=>import(`./boards-view-BkqnO7wI.js`).then(e=>(UN=e,e)),__vite__mapDeps([38,13,5,3,14,22,15,12,33,26,20,39])),HN}function KP(e){HN=null,u(`focus`,`the board pane failed to load: ${d(e)}`)}function qP(e,t,n=!1){!K||KN===e&&qN===t||(KN=e,qN=t,K.showTabs(e,{holdSplit:n}))}function JP(e){qP(FN,null);let t=WN!==null||GN!==e;WN=null,GN=e,GP().then(n=>XP(n,null,t?e:null),KP)}function YP(e=null){if(q){JP(q);return}let t=Z(),n=t?YA(t):[],[r]=n,i=r?PN:NN;if(qP(i,t,PA()&&i===PN&&KN===NN&&qN===t&&e===null),!t||!r){WN=null,GN=null;return}let a=n.some(e=>e.id===GN),o=WN!==t||e!==null||!a;WN=t;let s=o?e??r.id:null;s&&(GN=s),GP().then(e=>XP(e,t,s),KP)}function XP(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 ZP(){J&&(WN||q)&&UN?.reopenSelectedBoard()}function QP(){let e=QA();J&&e?.sessionId&&O.has(e.sessionId)&&(eF(e.sessionId),YP(e.boardId),K?.showTab(`board`))}function $P(){gg();let e=Z();e&&(cj()===e&&dj(),j.dispatch(`focusSession`,null))}function eF(e){J&&O.has(e)&&(iS(e),ni(e),e!==Z()&&($P(),q=null,j.dispatch(`focusSession`,e),X=e,kP()))}function tF(){if(!XN||!ZN||!QN)return;let e=Z(),t=!!q||!!(e&&O.has(e)),n=O.size>0;Wr(XN,t),K&&Wr(K.element,!t),$j(XN,!n),Wr(ZN,!n),Wr(QN,!n),!t&&n&&(Br(ZN,`No session selected`),Br(QN,`Select a session from the rail on the left to focus it here.`))}function nF(e,t){tP.set(D(e),typeof t==`string`&&t?t:`none`),J&&kP()}var rF={placement:`overlay`,sessionId:()=>J&&zN&&!q?Z():null,elementFor:()=>{if(!zN)throw Error(`Focus view is not mounted`);return zN},didShow:()=>{},didHide:()=>{let e=Z();e&&BP(O.get(e),e)}};function iF(e=null){let t=Z();t&&hg(`changes`,t,e)}function aF(e){J&&O.has(e)&&eF(e)}function oF(e){return!J||!O.has(e)?!1:(eF(e),Xy(e))}function sF(e){if(!J)return;let t=sP()[e-1];t&&Kr(t)&&SP(t)}function cF(e){if(!J)return;let t=sP().filter(e=>e===X||Kr(e)),n=_n(t,X,e);n!=null&&Kr(n)&&(CP(n),Y.get(n)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=Z();J&&e&&iS(e)});function lF(){RN&&(J=!0,fg(rF),$P(),X=null,kP(),$N&&eP?zP(eP):$N&&IP().length>0?RP():($N&&G&&KM(G),dF()))}function uF(e,t=null){$N=!0,eP=t;try{e()}finally{$N=!1,eP=null}}function dF(){if(!J||Z()||q)return;let e=$r();e&&eF(e)}function fF(){J&&=($P(),pg(rF),X=null,!1)}var pF=[],mF=new Set;function hF(e){let t=Dt.safeParse(e);if(t.success){pF=t.data;for(let e of mF)e()}}function gF(e){return pF.find(t=>t.agent===e)??null}function _F(e){return mF.add(e),()=>{mF.delete(e)}}var vF=2e3,yF={},bF=null,xF=null,SF=Ce,CF=null,wF=!1,TF=null,EF=[],DF=null,OF=()=>null,kF=()=>{},AF=!1,jF=new Set,MF=new Set;function NF(e){for(let t of MF)t(e)}function PF(e){MF.add(e)}function FF(){return yF}function IF(e){return yF={...yF,...e},yF}function LF(){return{status:bF,journal:xF,request:SF,lastAutoCheckAt:CF,isCheckInFlight:wF,checkSendFailure:TF}}function RF(e){let t=Et(SF,e);t!==SF&&(SF=t,NF({kind:`update`,frame:`request`}))}function zF(){RF(_({type:`update-apply`})?`request-sent`:`request-unsent`)}function BF(){CF=Date.now();let e=_({type:`update-check`});wF=e,TF=e?null:Ee,NF({kind:`update`,frame:`request`})}function VF(e){kF=e}function HF(){kF()}function UF(e){EF=[...e]}function WF(){return EF}function GF(e=null,t=null,n=null){let r=DF!==null&&(DF.sectionId!==null||DF.isLink);e===null&&n===null&&r||(DF={sectionId:e,settingId:t,hashAtRequest:n??location.hash,isLink:n!==null},NF({kind:`activate`}))}function KF(){let e=DF;return DF=null,e}function qF(e){OF=e}function JF(){for(let e of jF)e()}function YF(e){jF.add(e)}function XF(){return no()&&OF()===`section`}function ZF(){XF()&&NF({kind:`return-to-list`})}function QF(e){e&&(yF=e,hF(yF.agentLogins),NF({kind:`broadcast`}))}function $F(){AF||(AF=!0,window.setTimeout(()=>{a(`get-settings`,{}).then(e=>{e.settings&&QF(e.settings)}).catch(()=>{AF=!1})},vF))}function eI(){NF({kind:`status`})}function tI(e){eI()}function nI(e){bF=e,wF=!1,TF=null,SF=Et(SF,`status-frame`),NF({kind:`update`,frame:`status`})}function rI(e){xF=e,SF=Et(SF,`progress-frame`),NF({kind:`update`,frame:`progress`})}function iI(e){if(e.scope!==`update`)return!1;let t=Fe(e.message),n=SF.requested;return SF=Et(SF,`error-frame`,t),wF=!1,n||(TF=t),NF({kind:`update`,frame:`error`}),!0}var aI=200;function oI(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function sI(e){return/^#settings(?:[/?]|$)/.test(e)}function cI(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function lI(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,aI).join(``).trim()}}function uI(e,t,n){let r=E(`a`,`settings-link`,n);return r.href=oI(e,t),r}var dI={teamReview:e=>e?.teamReview?.enabled!==!1,issues:e=>e?.issues?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,benchmarks:e=>e?.benchmarks?.enabled===!0,community:e=>e?.community?.enabled===!0},fI=[{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:`benchmarks`,sectionId:`lanes-benchmarks`,settingId:`benchmarks-enabled`},{rule:`community`,sectionId:`lanes-community`,settingId:`community-enabled`}],pI=null,mI=null,hI=null,gI=()=>!1,_I=new Set,vI=new Set,yI=Tt({getAck:Tr,setAck:Qn,signature:()=>Ke({posthog:pI}),isLooking:()=>gI()});function bI(e){for(let t of vI)t(e)}function xI(){mI?.(yI.refresh())}function SI(){return{latest:pI,archivedLocally:_I,traceOpener:hI}}function CI(e){vI.add(e)}function wI(e){gI=e,xI()}function TI(e){_I.add(e)}function EI(){yI.acknowledge(),xI()}function DI(e){mI=e,xI()}function OI(e){hI=e}function kI(e){pI=e,Je(pI,_I),bI({kind:`status`}),xI()}function AI(e){let t=Oe(pI,e.projectId,e.issueId)?.inFlight===!0;_e(pI,e)&&bI({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function jI(e){let t=Re(pI,e);bI({kind:`investigation-finished`,frame:e,isPatched:t}),t&&xI()}var MI=null,NI=[],PI=()=>!1,FI=null,II=Cr(),LI=Dr(),RI=new Set(LI.split(`|`).filter(Boolean)),zI=new Set;function BI(e){for(let t of zI)t(e)}function VI(){return Hp(NI).map(Vp)}function HI(e){e!==II&&(II=e,Zn(e))}function UI(e){e!==LI&&(LI=e,RI=new Set(e.split(`|`).filter(Boolean)),Xn(e))}function WI(){if(!MI)return;let e=$p({turnEntries:VI(),acknowledged:II,unseen:LI,isLooking:PI()});HI(e.acknowledged),UI(e.unseen),FI?.(e.isShown)}function GI(e){zI.add(e)}function KI(){return MI}function qI(){return NI}function JI(e){PI=e,WI()}function YI(e){FI=e,WI()}function XI(){MI&&(HI(bt(VI())),WI())}function ZI(){return LI}function QI(e){return RI.has(e)}function $I(e){return RI.has(e)?(UI(bt([...RI].filter(t=>t!==e))),!0):!1}function eL(e){let t=Se.safeParse(e);t.success?(MI=t.data,NI=Bp(t.data.entries),WI(),BI({kind:`status`})):u(`community`,`dropped community-status: ${c(t.error.issues)}`)}function tL(e){BI({kind:`connection`,isConnected:e})}function nL(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 iL(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 aL(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 oL(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function sL(e,t,n){t&&e?.refreshOn?.includes(n)&&t.refresh?.(n)}function cL(e,t,n,r){for(let i of e)nL(i.view,t)&&sL(i,r(i.view),n)}function lL(){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 uL(e,t,n){let r=Number(e);return!e||!Number.isFinite(r)||t-r>n}var dL=`glimmervoid:preload-error-reload-at`,fL=3e4,pL=1e3,mL=lL();function hL(e,t){let n=mL.mountedModuleOf(e.view);n?t(n):mL.show(e).then(t).catch(t=>{throw u(`view`,`${e.view} failed to show: ${d(t)}`),t})}function gL(e){return mL.mountedModuleOf(e)}function _L(e){mL.mountEagerViews(e)}function vL(e){let t=()=>{mL.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,pL)}function yL(e){let t=Date.now();uL(e.getItem(dL),t,fL)&&(e.setItem(dL,String(t)),location.reload())}function bL(e){window.addEventListener(`vite:preloadError`,()=>yL(e()))}function xL(e,t){fetch(e,{method:`HEAD`,cache:`no-store`}).then(e=>{e.status===404&&yL(t())}).catch(()=>{})}function SL(e){Um({openTerminal:e.openTerminal,openReviews:e.openReviews}),VF(e.onRestart),qA(e.openReviewFile);let t=[{view:`focus`,label:`Focus`,iconPath:ut,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,refreshOn:[`connected`],module:{mount:()=>pP({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:lF,deactivate:fF,refresh:ZP}},{view:`prs`,label:`Reviews`,iconPath:xt,panelClass:`pr-view`,gate:{fromSettings:dI.teamReview},load:()=>M(()=>import(`./review-queue-panel-CoiWjuL2.js`).then(e=>e.view),__vite__mapDeps([40,12,13,5,3,14,15,4,6,7,41,34,42,43,36,44,29,22,30,31,25,32,23,33,26,45])),refreshOn:[`shown`],attention:{subscribe:zm,acknowledge:Rm},onConnectionChange:e=>{xp(e),_m(e)}},{view:`issues`,label:`Issues`,iconPath:vt,panelClass:`issues-view`,gate:{fromSettings:dI.issues},load:()=>M(()=>import(`./issues-panel-ChwlyxV5.js`).then(e=>e.view),__vite__mapDeps([46,13,5,3,14,22,15,12,31,25,32,4,6,7,23,34,43,16,17,44,29,30,33,26,47])),refreshOn:[`shown`],onConnectionChange:zd},{view:`usage`,label:`Usage`,iconPath:rt,panelClass:`usage-view`,gate:{fromSettings:dI.usage},load:()=>M(()=>import(`./usage-panel-BlO-SI6M.js`).then(e=>e.view),__vite__mapDeps([48,13,5,3,49,50])),attention:{subscribe:QT,acknowledge:ZT},onConnectionChange:iE,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,iconPath:ce,panelClass:`radar-view`,gate:{fromSettings:dI.posthog},load:()=>M(()=>import(`./radar-panel-08x269rn.js`).then(e=>e.view),__vite__mapDeps([51,12,13,5,3,14,22,15,52,30,31,25,32,4,6,7,23,37,20,49,53])),attention:{subscribe:DI,acknowledge:EI}},{view:`community`,label:`Community`,iconPath:Ye,panelClass:`community-view`,gate:{fromSettings:dI.community},load:()=>M(()=>import(`./community-panel-DCkLaMpV.js`).then(e=>e.view),__vite__mapDeps([54,12,13,5,3,14,22,15,41,34,42,43,4,6,7,36,55])),refreshOn:[`shown`],attention:{subscribe:YI,acknowledge:XI},onConnectionChange:tL},{view:`boards`,label:`Boards`,iconPath:We,isPhoneNavScreen:!0,isPhoneOnly:!0,panelClass:`boards-screen`,hasPanelChrome:!1,load:()=>M(()=>import(`./boards-view-BkqnO7wI.js`).then(e=>e.view),__vite__mapDeps([38,13,5,3,14,22,15,12,33,26,20,39])),refreshOn:[`shown`,`connected`]},{view:`hooks`,label:`Hooks`,iconPath:Xe,panelClass:`hooks-view`,load:()=>M(()=>import(`./hooks-panel-Ch4jXXip.js`).then(e=>e.view),__vite__mapDeps([56,12,13,5,3,14,15,57])),refreshOn:[`shown`,`connected`,`hooks-updated`]},{view:`trace`,label:`Trace`,iconPath:de,panelClass:`trace-view`,gate:{subscribe:Cv},load:()=>M(()=>import(`./trace-panel-BpiZzlnb.js`).then(e=>e.view),__vite__mapDeps([58,13,5,3,15,12,4,6,7,59])),refreshOn:[`shown`],onAvailabilityChange:e=>OI(e?vx:null),onConnectionChange:Cx},{view:`benchmarks`,label:`Bench`,iconPath:pt,panelClass:`bench-view`,gate:{fromSettings:dI.benchmarks},load:()=>M(()=>import(`./benchmark-panel-C-c9Kiea.js`).then(e=>e.view),__vite__mapDeps([60,13,5,3,61])),onConnectionChange:Ei},{view:`settings`,label:`Settings`,iconPath:Me,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>M(()=>import(`./settings-panel-DXCr-n06.js`).then(e=>e.view),__vite__mapDeps([62,12,13,5,3,14,15,4,6,7,10,52,30,22,31,25,32,23,37,20,63,8,45,2,1,64]))}],n=T(document,`#app-main`,`main`),r=t.map(t=>{let r=Ve(`header-tab`,t.label);r.prepend(x(t.iconPath)),r.id=`tab-${t.view}`,r.draggable=!0;let i=`view-${t.view}`;r.setAttribute(`role`,`tab`),r.setAttribute(`aria-controls`,i);let a=t.view===`focus`;r.setAttribute(`aria-selected`,String(a)),r.tabIndex=a?0:-1;let o=document.getElementById(i)??E(`section`);if(o.classList.add(t.panelClass),o.id=i,o.setAttribute(`role`,`tabpanel`),o.setAttribute(`aria-labelledby`,r.id),o.hidden=!0,o.parentElement||n.append(o),r.hidden=t.gate!==void 0||t.isPhoneOnly===!0,o.classList.toggle(`view-panel`,t.hasPanelChrome!==!1),t.attention){let n=E(`span`,`tab-activity`);n.id=`tab-${t.view}-activity`,n.setAttribute(`aria-hidden`,`true`),r.append(n),t.attention.subscribe(r=>{let{isActive:i,level:a}=oL(r);n.classList.toggle(`active`,i),a===null&&n.removeAttribute(`data-attention`),a!==null&&n.setAttribute(`data-attention`,a),e.setPhoneAttention(t.view,r)})}return{...t,tab:r,el:o}});return T(document,`#header-tabs`,`div`).replaceChildren(...r.map(e=>e.tab)),r}function CL(e){return e===`remote`?`remote`:`local`}function wL(e,t){return CL(t)===`local`||e!==`shutdown`}var TL=!1,EL=new Set;function DL({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){let o=zx(),s=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;Vt({title:t,message:s,confirmLabel:n,danger:r||o>0,onConfirm:()=>_({type:e})})}function OL(){DL({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function kL(){DL({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})}function AL(e){TL=wL(`shutdown`,e);for(let e of EL)e.isConnected?e.hidden=!TL:EL.delete(e)}function jL(e){e.hidden=!TL,EL.add(e)}function ML(e){e&&GF(e),!Pj(`settings`)&&$(`settings`,{section:e})}function NL(e){Pj(e)||$(e)}function PL(){Pj(`boards`)||($(`focus`),QP())}function FL(){sI(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}var Q=SL({onRestart:OL,openTerminal:e=>{Nj(e)||($(`focus`),aF(e))},openPlan:e=>{$(`focus`),oF(e)},openReviewFile:(e,t)=>{Rx(e)&&(Nj(e)||($(`focus`),aF(e),iF(t)))},openReviews:()=>zL(`prs`)?(Pj(`prs`)||$(`prs`),!0):!1,setPhoneAttention:Oj});function IL(){return Q.map(e=>e.view)}var LL=IL();function RL(e){return Q.find(t=>t.view===e)}function zL(e){return Q.some(t=>t.view===e&&!t.tab.hidden)}var BL=!0,VL=null;function HL(e){RL(e)?.attention?.acknowledge()}var UL=null;function WL(e){UL=_({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function GL(){UL&&WL(UL)}function KL(e){let t=RL(e);t&&(hL(t,e=>sL(t,e,`shown`)),WL(e))}function qL(e){cL(Q,{isPhoneShellActive:wj(),activeView:An(),phoneScreen:j.snapshot().phoneScreen},e,gL)}function $(e,{section:t,setting:n,persist:r=!0}={}){let i=RL(e);if(!i||!zL(e))return;let a=An();j.dispatch(`setActiveView`,e),BL=r,r&&(VL=null),document.body.dataset.activeView=e,r&&ar(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&&gL(a)?.deactivate?.(),hL(i,r=>{An()===e&&(r.activate?.(),sL(i,r,`shown`),e===`settings`&&t&&GF(t,n??null))}),WL(e),a===`settings`&&e!==`settings`&&FL(),HL(e)}function JL(e,t){let{view:n}=e;e.tab.hidden=!t,Dj(n,t),e.onAvailabilityChange?.(t),!wj()&&(!t&&An()===n&&$(`focus`),t&&VL===n&&$(n))}function YL(e){for(let{view:t,isAvailable:n}of rL(Q,e))JL(t,n)}function XL(e){let t=iL(LL,e);Q.every((e,n)=>e.view===t[n])||(Q.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),T(document,`#header-tabs`,`div`).append(...Q.map(e=>e.tab)),Ej(t))}function ZL(){return Q.filter(e=>!e.tab.hidden)}function QL(e,t){let n=e[t];return $(n.view),n.tab}function $L(e,t){let n=ZL(),r=n.findIndex(t=>t.view===e);return QL(n,ui(r,t,n.length))}function eR(e){Q.some(e=>e.tab===document.activeElement)&&e.focus()}var tR=null;function nR(e){let t=IL();XL(e),a(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&XL(t)}).catch(()=>XL(t))}function rR(e){let t=tR;if(tR=null,!t||t===e)return;let n=IL();nR(aL(n,t,n.indexOf(e)))}function iR({view:e,tab:t}){t.addEventListener(`click`,()=>$(e)),t.addEventListener(`dragstart`,t=>{tR=e,t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),t.addEventListener(`dragover`,n=>{tR&&tR!==e&&(n.preventDefault(),t.dataset.dropTarget=`true`)}),t.addEventListener(`dragleave`,()=>delete t.dataset.dropTarget),t.addEventListener(`drop`,n=>{n.preventDefault(),delete t.dataset.dropTarget,rR(e)}),t.addEventListener(`dragend`,()=>{tR=null}),t.addEventListener(`keydown`,e=>{if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=ZL(),n=t.findIndex(e=>e.view===An()),r=di(e.key,n,t.length,`horizontal`);r!==null&&(e.preventDefault(),QL(t,r).focus())})}function aR(){let e=Ar(),t=sI(location.hash),n=Wv(location.hash);if(t&&(GF(null,null,location.hash),$(`settings`,{persist:!1})),n&&$(`focus`,{persist:!1}),t||n)return;let r=zL(e);r||(VL=e),$(r?e:`focus`,{persist:r})}function oR(){let e=An();$(zL(e)?e:`focus`,{persist:BL})}function sR(){UF(Q),_L(Q);for(let e of Q)e.gate&&(JL(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>JL(e,t)));_x(()=>{zL(`trace`)&&(Pj(`trace`)||$(`trace`))});for(let e of Q)iR(e);aR()}function cR(e){return sI(e)?(GF(null,null,e),Pj(`settings`)||$(`settings`,{persist:!1}),!0):!1}var lR=`No plan is stored for this session yet. It appears here once the agent writes one.`,uR=`Plan`;function dR(e){let t=Wv(e);return t?!Rx(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),wj()?(Mj(t)||Nn({source:uR,sessionId:t,message:lR}),!0):($(`focus`,{persist:!1}),oF(t)||Nn({source:uR,sessionId:t,message:lR}),!0)):!1}function fR(e){return dR(e)?!0:cR(e)}function pR(e){e.newURL===location.href&&fR(location.hash)}function mR(){document.addEventListener(`click`,e=>{if(!wj()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&fR(t.hash)&&e.preventDefault()}),window.addEventListener(`hashchange`,pR)}var hR=null,gR=new Set;function _R(){hR?.setState(ir()?`idle`:`off`)}function vR(e){Er(e),_R();for(let t of gR)t(e)}function yR(e){gR.add(e)}function bR(e){hR=e,_R(),e.element.addEventListener(`click`,()=>vR(!ir()))}var xR=`•`.repeat(8),SR=`[^/\\\\\\s"'\`<>:]+`,CR=RegExp(`(?<![\\w./\\\\-])(?:/home/${SR}|/Users/${SR}|[A-Za-z]:[\\\\/]Users[\\\\/]${SR}|/root(?![\\w.-]))`,`g`);function wR(e){let t=Vs(e);if(t.length===0)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+xR,r=i.end;return n+e.slice(r)}function TR(e){return e.replace(CR,`~`)}function ER(e){return TR(wR(e))}var DR=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,OR=[`title`,`label`],kR=new WeakMap,AR=new WeakMap,jR=null;function MR(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(DR)!==null}function NR(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function PR(e,t){if(t&&e===t.masked)return t;let n=ER(e);return n===e?null:{original:e,masked:n}}function FR(e){let t=NR(e)?null:PR(e.data,kR.get(e));t?(kR.set(e,t),e.data!==t.masked&&(e.data=t.masked)):kR.delete(e)}function IR(e,t){let n=e.getAttribute(t),r=AR.get(e),i=n===null?null:PR(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),AR.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function LR(e){for(let t of OR)IR(e,t)}function RR(e){return e instanceof Element&&e.matches(DR)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function zR(e){LR(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,RR);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&FR(e),e instanceof Element&&LR(e)}function BR(e){MR(e)||(e instanceof Text&&FR(e),e instanceof Element&&zR(e))}function VR(e){e instanceof Element&&!MR(e)&&LR(e)}function HR(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&&BR(e);for(let e of n)e.isConnected&&VR(e)}function UR(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);WR(e);for(let e=t.nextNode();e;e=t.nextNode())WR(e)}function WR(e){if(e instanceof Text){let t=kR.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=AR.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function GR(){if(jR)return;let e=new MutationObserver(t=>{HR(t),e.takeRecords()});zR(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:OR}),jR=e}function KR(){jR&&(jR.disconnect(),jR=null,UR(document.body),kR=new WeakMap,AR=new WeakMap)}function qR(e){e?GR():KR()}function JR(){qR(Ks()),Js(qR)}var YR=$e({label:`Play queued merge celebrations`,icon:x(Te,`1.6`),action:`play-celebrations`,states:[`idle`,`attention`]}),XR=C({variant:`primary`,label:`Session`,icon:x(Ae),action:`add-session`,onClick:ri});XR.id=`btn-add-session-header`;var ZR=$e({label:`Keyboard shortcuts and version`,icon:x(Qe,`1.6`),action:`open-shortcuts-help`,onClick:()=>ML(`browser-shortcuts`),states:[`idle`]}).element,QR=$e({label:`Mute alerts`,icon:x(Ct,`1.6`),action:`toggle-mute`,states:[`idle`,`off`]}),$R=QR.element,ez=C({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-header-status`});ez.id=`header-status-dismiss`;var tz=T(document,`#celebration-tray`,`div`);tz.prepend(YR.element),T(document,`.header-right`,`div`).append(XR,ZR,$R),T(document,`#header-status`,`p`).append(ez);function nz(){bR(QR),JR(),It(document.querySelector(`.header`))}function rz(){af(tz,YR,T(document,`#celebration-tray-count`,`span`))}function iz(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 az(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 oz(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function sz(e,t){return t||oz(e)?!1:az(e)}var cz=C({variant:`primary`,size:`small`,label:`Restart`,action:`restart-to-update`,hidden:!0}),lz=C({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-update-command`}),uz=C({variant:`icon`,size:`small`,label:`Dismiss update notice`,icon:x(gt),action:`dismiss-update-banner`});T(document,`#update-banner-cmd`,`code`).before(cz),T(document,`#update-banner-copy-status`,`span`).before(lz),T(document,`#update-banner`,`div`).append(uz);var dz=C({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-leftovers-command`}),fz=C({variant:`icon`,size:`small`,label:`Dismiss old report notice`,icon:x(gt),action:`dismiss-leftovers-banner`});T(document,`#post-turn-leftovers-copy-status`,`span`).before(dz),T(document,`#post-turn-leftovers-banner`,`div`).append(fz);var pz,mz=null;function hz(e,t,n){e.onclick=()=>{let e=Mt(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var gz=uI(dt,ve,`Update`).href;function _z(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function vz(e){let t=T(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=he(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=_z(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===mz||!a&&pz!==void 0&&s===pz||!a&&s&&vr()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);T(document,`#update-banner-text`,`span`).textContent=i,T(document,`#update-banner-cmd`,`code`).textContent=c;let l=T(document,`#update-banner-update`,`a`);l.href=gz,l.hidden=n!==`link`,cz.hidden=n!==`restart`,cz.onclick=OL;let u=T(document,`#update-banner-cmd`,`code`);u.hidden=n!==`command`,lz.hidden=n!==`command`;let d=T(document,`#update-banner-copy-status`,`span`);d.hidden=n!==`command`,d.textContent=``;let f=T(document,`#update-banner-link`,`a`);f.hidden=!e.releaseUrl,f.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,hz(lz,d,c),uz.onclick=()=>{t.hidden=!0,a?mz=i:(pz=s,nr(s))}}var yz=!1;function bz({repositories:e,command:t}){let n=T(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(yz)return;let r=T(document,`#post-turn-leftovers-copy-status`,`span`);T(document,`#post-turn-leftovers-text`,`span`).textContent=iz(e.length),T(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,hz(dz,r,t),fz.onclick=()=>{yz=!0,n.hidden=!0}}var xz=T(document,`#telemetry-banner`,`div`),Sz=C({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-telemetry-banner`});xz.append(Sz);function Cz(){sr(!0),xz.hidden=!0}function wz(e){xz.hidden=!sz(e,Yn())}function Tz(){let e=T(document,`#telemetry-banner-settings`,`a`);e.href=uI(`privacy`,`telemetry-enabled`,`What's collected`).href,e.addEventListener(`click`,Cz),Sz.addEventListener(`click`,Cz)}function Ez(e){M(()=>import(`./feature-hint-D4Bf1Vud.js`).then(t=>t.showFeatureHint(e,{isFeatureEnabled:e=>zL(nt[e]),openView:NL,openSetting:(e,t)=>cR(oI(e,t))}),e=>u(`feature-hint`,`hint card failed to load: ${d(e)}`)),__vite__mapDeps([65,12,13,5,3,4,6,7,63,8,66]))}function Dz(){M(()=>import(`./feature-hint-D4Bf1Vud.js`).then(e=>e.showStarHint(),e=>u(`star-hint`,`star card failed to load: ${d(e)}`)),__vite__mapDeps([65,12,13,5,3,4,6,7,63,8,66]))}var Oz=2500;function kz({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}function Az(e){ca(e.isExperimentalBuild===!0&&Fr()),Bx(e),QF(e),YL(e),wz(e),XL(e.viewTabOrder),qs(e.streamerMode===!0)}var jz=Object.freeze({top:[0,1],right:[-1,0],bottom:[0,-1],left:[1,0]}),Mz=160,Nz=950,Pz=900,Fz=980,Iz=450,Lz=720,Rz=260,zz=`cubic-bezier(0.22, 1, 0.36, 1)`,Bz=`cubic-bezier(0.2, 0.8, 0.3, 1)`,Vz=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),Hz=e=>new Promise(t=>{setTimeout(t,e)});function Uz(e){return e!==void 0&&Object.hasOwn(jz,e)}function Wz(e){return[...e.querySelectorAll(`.loading-mark-bracket`)].flatMap(e=>{let t=e instanceof SVGElement?e.dataset.side:void 0;if(!(e instanceof SVGElement)||!Uz(t))return[];let[n,r]=jz[t];return[{bracket:e,dx:n,dy:r}]})}function Gz(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:Cc}],{duration:Mz,easing:`ease-out`})}}function Kz(e){e.animate([{transform:`rotate(0deg)`,easing:`cubic-bezier(0.5, 0, 0.15, 1)`},{transform:`rotate(360deg)`,offset:.86,easing:Bz},{transform:`rotate(354deg)`,offset:.93,easing:Bz},{transform:`rotate(360deg)`}],{duration:Nz})}function qz(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:Pz,easing:`cubic-bezier(0.2, 0.9, 0.3, 1)`})}}function Jz(e,t){e.animate([{transform:`scale(0)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:Fz,easing:zz,fill:`forwards`}),t.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`})}function Yz(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:Lz,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:Lz,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 Xz(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(Vz?.matches||document.hidden||!(t instanceof SVGElement)||!n||!r||!i)return;let a=Wz(t);Gz(a),e.dataset.unlock=`spin`,await Hz(Mz),Kz(n),qz(a),Jz(r,i),await Hz(Fz),e.dataset.unlock=`lit`,await Hz(Iz),e.dataset.unlock=`burst`,Yz(a,r,i),await Hz(Rz)}var Zz=T(document,`#connection-status`,`span`),Qz=T(Zz,`.connection-label`,`span`),$z=T(document,`#loading-screen`,`div`),eB=T(document,`#loading-status`,`div`),tB=T(document,`#loading-detail`,`div`),nB=T(document,`#shutdown-screen`,`div`),rB=T(document,`#shutdown-status`,`div`),iB=!1,aB=null,oB=!1;function sB(){iB||aB===null||kz({hasSnapshot:oB,connectingTerminalCount:Gc(),msSinceConnected:performance.now()-aB})===`reveal`&&lB()}function cB(){oB=!0,sB()}function lB(){iB||(iB=!0,vL(Q),Hg(),rd(),tM(),Xz($z).then(uB,uB))}function uB(){$z.classList.add(`fade-out`);let e=()=>$z.remove();$z.addEventListener(`transitionend`,t=>{t.target===$z&&e()}),setTimeout(e,1e3)}function dB(e,t){Zz.dataset.state=`shutdown`,Qz.textContent=e,rB.textContent=t,nB.classList.add(`active`)}var fB=new Set([`disconnected`,`connecting`]);function pB(e,t,n){Zz.dataset.state=e,Zz.toggleAttribute(`data-reconnected`,n),Qz.textContent=t}function mB(e,t){pB(e,t,e===`connected`&&fB.has(Zz.dataset.state??``))}function hB(e,t){Zz.dataset.state!==`shutdown`&&pB(e===`verified`?`connected`:e,t,!1)}var gB=1e4,_B=`Server`,vB=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,yB=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,bB=null,xB=!1;function SB(){eB.textContent=`Reconnecting to server...`,tB.textContent=yB,tB.hidden=!xB}function CB(){bB=null,xB=!0,iB?Nn({source:_B,message:vB,hidesInStreamerMode:!1}):SB()}function wB(){bB!==null||xB||(bB=window.setTimeout(CB,gB))}function TB(){bB!==null&&window.clearTimeout(bB),bB=null,xB=!1,tB.hidden=!0,Mn(_B)}function EB(){TB(),xL(import.meta.url,()=>window.sessionStorage),GL(),nB.classList.contains(`active`)?location.reload():(eM(),document.body.classList.add(`app-ready`),!iB&&aB===null&&(aB=performance.now(),eB.textContent=`Connecting to sessions...`,setTimeout(lB,Oz)),sB(),qL(`connected`),a(`get-settings`,{}).then(e=>{e.settings&&(Az(e.settings),An()===`settings`&&cR(location.hash))}).catch(()=>{}))}function DB(e,t){if(e===`connecting`||e===`verified`)hB(e,t);else{mB(e,t),nb(e===`connected`);for(let t of Q)t.onConnectionChange?.(e===`connected`);e===`connected`?EB():e===`disconnected`&&nB.classList.contains(`active`)?rB.textContent=`Waiting for server...`:(wB(),iB||SB())}}function OB(){Wc(sB),o(DB)}var kB=14,AB=Object.freeze({idle:wc,failed:`#ef4444`,waiting:`#f59e0b`});function jB({waitingCount:e,failedCount:t}){return e>0?`waiting`:t>0?`failed`:`idle`}function MB(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)">${Tc({frame:Cc,light:AB[e],strokeWidth:kB})}</g></svg>`}function NB(){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 PB=NB(),FB=`idle`;function IB(e){let t=jB(e);t!==FB&&(FB=t,PB.href=`data:image/svg+xml,${encodeURIComponent(MB(t))}`)}function LB(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 RB(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 zB(){Rd(),_p(),kj()}function BB(){kP(),zB()}function VB(){Fg(()=>kP()),Ur(e=>{kP(e),zB()})}var HB=null;function UB(e){let t=LB(HB,e);HB=t.knownBuild,t.reload&&location.reload()}function WB(e){Pn(e),tS(e),zi(e),fv(e),uh(e)}function GB(e){let t=new Set(e.map(e=>e.id));for(let e of[...O.keys()])t.has(e)||WB(e)}function KB(e){GB(e),tI(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){Ri(t.id,t.coherenceHooks),lh(t.id,t.linkedPrs);let e=Rx(t.id);e&&aS(t.id,t.state,t.stateSince),e&&en(t.id,!!t.saneYolo),e||Wx(t.id,t.name,t.state,RB(t)),ng(t.id,t.failureReason),Lx(t.id,t.taskTitle,t.taskTitleIsCustom),Kx(t.id,t.agent),$x(t.id,t.mergeStatus,t.mergeReason),Gx(t.id,t.effectiveBase),Jx(t.id,t.activeAgents,t.awaitingBackgroundTasks),Yx(t.id,t.pendingPromptKind),Xx(t.id,t.unseenOutcome),Zy(t.id,t.hasPlan)}Ux(),IB(A.counts),kP(),dF(),zB(),qB(),dR(location.hash),Fj(),cB()}function qB(){yx([...O].map(([e,t])=>({id:e,name:vn(t)||e})))}function JB(e,t){Zy(e,t?.hasPlan===!0),Xx(e,t?.unseenOutcome)}var YB=new Set([w.DONE,w.FAILED]);function XB(e,t){return e!==void 0&&YB.has(e)&&!YB.has(t)&&t!==w.DORMANT}function ZB(e){let t=O.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;tS(e.id),Wx(e.id,e.session,w.DORMANT,RB({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})),Kx(e.id,t?.agent),JB(e.id,t)}function QB(e,t){let n=O.get(String(e.id))?.currentState;t.to===w.DORMANT&&n!==w.DORMANT?(ZB(e),uv(e.id)):(aS(e.id,t.to,e.timestamp),ng(e.id,e.failureReason),e.saneYolo!==void 0&&en(e.id,e.saneYolo),uv(e.id),XB(n,t.to)&&sl(e.id))}function $B(e){if(Rx(e.id))e.transition&&QB(e,e.transition),e.activeAgents!==void 0&&Jx(e.id,e.activeAgents,e.awaitingBackgroundTasks),e.unseenOutcome!==void 0&&Xx(e.id,e.unseenOutcome),e.pendingPromptKind!==void 0&&Yx(e.id,e.pendingPromptKind),e.unseenOutcome!==void 0&&Ux(),IB(A.counts),qr(e.id),Fv(e.id);else{if(!e.transition)return;Wx(e.id,e.session,e.transition.to,RB({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),IB(A.counts),Rd()}}function eV(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 tV={"session-trace-response":e=>bx(e),"session-trace-changed":e=>xx(e),"session-plan-changed":e=>{Qy(e),zB()},"session-plan-draft":e=>{$y(e)},"session-plan-response":e=>{eb(e)},"session-docs-changed":e=>$h(e),"session-docs-snapshot":e=>eg(e),"session-shown":e=>Kg(e),"session-shown-snapshot":e=>qg(e),"session-coherence-hooks":e=>{Ri(e.id,e.coherenceHooks),BB()},"session-coherence":e=>{Bi(e),BB()},"session-coherence-snapshot":e=>{Vi(e),BB()},"session-coherence-journal-response":e=>Ki(e)},nV={"team-review-status":e=>mm(e),"github-prs":e=>Gd(e),"my-prs-status":vp,"pr-flows-status":yp,"my-pr-merge-result":e=>bp(e),"team-review-action-result":e=>hm(e),"open-team-review-session-result":e=>gm(e),"issues-status":e=>Bd(e),"issue-detail-result":e=>Vd(e),"open-issue-session-result":e=>Hd(e),"set-issue-state-result":e=>Ad(e)},rV={"radar-status":e=>kI(e),"radar-investigation-activity":e=>AI(e),"radar-investigation-finished":e=>jI(e),"community-status":e=>eL(e),"benchmark-status":e=>Di(e),"benchmark-action-result":e=>Oi(e),"usage-sessions":e=>aE(e),"usage-report":e=>{sE(e),eI()},"plan-limits":e=>oE(e),"usage-budget-alert":e=>vy({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0})},iV={snapshot:e=>{UB(e.serverBuild),KB(e.sessions)},"hooks-report":e=>Hh(e),"save-hook-result":()=>Uh(),"delete-hook-result":()=>Uh(),"update-status":e=>{vz(e),nI(e)},"update-progress":e=>rI(e.journal),"post-turn-leftovers":e=>bz(e),"feature-hint":e=>Ez(e.hint),"star-hint":()=>Dz(),error:e=>{let t=iI(e),n=Sx(e),r=tb(e);t||n||r||(e.id?tg(e.id,e.message):Nn({source:_B,message:e.message}))},"settings-updated":e=>{e.settings&&Az(e.settings),eM()},"agent-logins":e=>hF(e.logins),"health-snapshot":e=>{e.stats&&Ah(e.stats)},"client-trust":e=>AL(e.trust),"shutting-down":()=>dB(`Shutting down...`,`Shutting down sessions...`),restarting:()=>dB(`Restarting...`,`Restarting server...`)},aV={"session-status":e=>$B(e),"session-added":e=>{lh(e.id,e.linkedPrs),Rx(e.id)||(Wx(e.id,e.session,e.state,RB(e)),Kx(e.id,e.agent)),IB(A.counts),BB(),qB()},"session-close-confirm":e=>{Xr(e.id)},"session-removed":e=>{WB(e.id),IB(A.counts),BB(),qB()},"session-title":e=>{Lx(e.id,e.taskTitle,e.isCustom),BB()},"session-prs":e=>lh(e.id,e.linkedPrs),"session-renamed":e=>{eS(e.id,e.newName),BB(),qB()},"session-modified":e=>{let t=O.get(String(e.id)),n=zr()===String(e.id);Ri(e.id,null),tS(e.id),fv(e.id),lh(e.id,e.linkedPrs),Wx(e.id,e.session,e.state,RB(e)),n&&ei(String(e.id)),Kx(e.id,e.agent),JB(e.id,t),IB(A.counts),BB(),qB()},"session-git":e=>qx(e.id,!!e.worktree),"session-merge-status":e=>{Qx(e.id,e.mergeStatus,e.reason),nF(e.id,e.mergeStatus),zB()},"debug-state-response":e=>Pv(e),"session-setup-response":e=>uS(e),notify:e=>{_y(e),Fv(e.session)},"session-error":e=>{dv(e.id),!tb(e)&&tg(e.id,e.message)}},oV={"whiteboards-snapshot":e=>FA(e),"whiteboard-patch":e=>IA(e),"whiteboard-removed":e=>LA(e)},sV=`Worktree`,cV=`Worktree warning`,lV=eV([iV,aV,{"session-worktree-blocked":e=>{Nn({source:sV,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=>{Nn({source:cV,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=>{Mn(sV,e.id),Gx(e.id,e.base)},"session-diff":e=>{av(e.id,e)},"session-diff-error":e=>{ov(e.id,e.message)},"change-map":e=>sv(e.id,e.map),"session-changed":e=>cv(e.id)},tV,oV,nV,rV]);function uV(e){let t=lV[e.type];t&&t(e)}function dV(){l(e=>{uV(e),qL(e.type)})}function fV(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 pV(){xj({panels:fV(Q),onScreenShown:e=>{KL(e),e!==`settings`&&FL(),e===`settings`&&!sI(location.hash)&&GF(),HL(e)},canGoBack:e=>e===`settings`&&XF()||e===`prs`&&Jm(),onBack:e=>{e===`settings`&&ZF(),e===`prs`&&Ym()},headerControls:[T(document,`.header-title`,`h1`),T(document,`#status-indicator`,`div`),T(document,`#celebration-tray`,`div`),XR,ZR,$R]}),YF(Aj),qm(Aj)}function mV(e){if(e===`phone`){let e=Z();for(let e of Q)gL(e.view)?.deactivate?.();let t=sI(location.hash);Sj({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}).then(e=>{e&&t&&GF(null,null,location.hash),!e&&no()&&!wj()&&oR()});return}let t=Tj();Cj(),oR(),t&&aF(t)}function hV(){pV(),no()&&mV(`phone`),ro(mV)}function gV(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function _V(e){aF(e),ni(e),requestAnimationFrame(()=>requestAnimationFrame(()=>O.get(e)?.term?.focus()))}function vV(){let e=gV()??zr();e?Gr(e):document.getElementById(`btn-add-session-header`)?.click()}function yV({action:e,step:t}){switch(e){case`merge`:{let e=zr();return!e||fP()?!1:(mv(e),!0)}case`close-session`:{let e=zr();return e?(Yr(e),!0):!1}case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return vV(),!0;case`next-attention`:return no()?!1:dP()?(RP(),!0):(An()===`prs`&&Xm()||uF(()=>$(`focus`)),!0);case`rail-step`:return dP()?(cF(t),!0):!1;case`view-step`:return!no()&&(eR($L(An(),t)),!0);case`session-nth`:return dP()?(sF(t),!0):!1;case`streamer-mode`:return Qs(),!0}}function bV(e){return e.code!==`KeyZ`||e.altKey||e.shiftKey?!1:Sl===`mac`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function xV(){Zr(_V),document.addEventListener(`keydown`,e=>{if(e.repeat||Nt(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1;if(!t&&bV(e)&&!Ht()&&ai()){e.preventDefault(),e.stopImmediatePropagation();return}let n=Sr(e,Sl,{isTerminalFocused:t},Tl());n&&(Ht()||yV(n)&&e.preventDefault())})}function SV(){let e=m(_);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))}),bL(()=>window.sessionStorage)}oa(hr()),sa(()=>{M(()=>import(`./alert-sound-Da6VQFBS.js`).then(e=>e.playNyanJingle(),e=>u(`alert-sound`,`nyan jingle failed to load: ${d(e)}`)),__vite__mapDeps([10,7]))}),id(Ir()),to(),Hl(document),OB(),VB(),eE(_),M(()=>import(`./your-day-tip-HkTB4v3D.js`).then(e=>e.startYourDayTips({openUsage:()=>NL(`usage`)}),e=>u(`your-day-tip`,`your day tips failed to load: ${d(e)}`)),__vite__mapDeps([67,13,5,3,22,65,12,4,6,7,63,8,66])),Bh(_),gx(_),Ld(_),wi(_),tn(sh),dn(Hi),dn(ih,`links`),dn(aj,`links`),cn(sj),ej(PL),$t({isReadable:Ui,open:Gi}),an(lS),Js(()=>qL(`settings-updated`)),dV(),Tz(),nz(),mR(),rz(),sR(),hV(),xV(),Lj(),SV(),kh(T(document,`#health-footer-mount`,`div`)),xl(Vx),wB(),Yu(),f();var CV=ur();CV&&n().then(()=>tl(CV));export{Kj as $,id as $i,TS as $n,Bm as $r,oT as $t,BF as A,Sf as Ai,lw as An,jg as Ar,Tw as At,hF as B,Md as Bi,qS as Bn,fg as Br,LS as Bt,oI as C,Si as Ca,Wf as Ci,_T as Cn,zy as Cr,XT as Ct,JF as D,zf as Di,IC as Dn,Yv as Dr,JT as Dt,IF as E,Of as Ei,RC as En,Zv as Er,YT as Et,FF as F,Tf as Fi,$S as Fn,mg as Fr,sC as Ft,KM as G,Cd as Gi,iT as Gn,zh as Gr,wC as Gt,MN as H,Dd as Hi,Aw as Hn,Gh as Hr,Mw as Ht,LF as I,lf as Ii,xT as In,dg as Ir,EC as It,cM as J,Pd as Ji,yT as Jn,Vm as Jr,rw as Jt,UM as K,Fd as Ki,dw as Kn,F as Kr,CC as Kt,PF as L,uf as Li,Ww as Ln,hg as Lr,ow as Lt,ZF as M,Cf as Mi,nT as Mn,_g as Mr,HC as Mt,qF as N,Ef as Ni,CT as Nn,gg as Nr,oC as Nt,$F as O,Df as Oi,hT as On,Bv as Or,qT as Ot,WF as P,wf as Pi,wT as Pn,bg as Pr,WS as Pt,qj as Q,wd as Qi,ES as Qn,Wm as Qr,HS as Qt,KF as R,Kd as Ri,Ow as Rn,pg as Rr,aw as Rt,lI as S,Ti as Sa,If as Si,YS as Sn,jy as Sr,rE as St,QF as T,Lf as Ti,gT as Tn,ey as Tr,tE as Tt,jM as U,jd as Ui,kw as Un,Rh as Ur,iC as Ut,_F as V,Od as Vi,JS as Vn,vg as Vr,Sw as Vt,MM as W,Nd as Wi,bT as Wn,Vh as Wr,TC as Wt,aM as X,Ed as Xi,rC as Xn,Lm as Xr,ZS as Xt,iM as Y,Td as Yi,Dw as Yn,Hm as Yr,jw as Yt,$j as Z,kd as Zi,gS as Zn,Ym as Zr,KS as Zt,wI as _,da as _a,Xp as _i,_C as _n,Uy as _r,Wk as _t,jL as a,El as aa,fm as ai,zC as an,dS as ar,RA as at,fI as b,ua as ba,pp as bi,$w as bn,Oy as br,Bk as bt,JI as c,Dl as ca,nm as ci,cC as cn,hx as cr,jA as ct,ZI as d,Js as da,Zp as di,uw as dn,fx as dr,OA as dt,Fu as ea,Km as ei,hC as en,SS as er,Bj as et,QI as f,Ys as fa,Up as fi,gw as fn,dx as fr,JA as ft,SI as g,ro as ga,Hp as gi,xw as gn,Xy as gr,BA as gt,TI as h,no as ha,am as hi,dT as hn,Lb as hr,QA as ht,kL as i,Sl as ia,dm as ii,cT as in,fS as ir,DA as it,HF as j,qf as ji,uT as jn,Pg as jr,tT as jt,zF as k,Rf as ki,sw as kn,Vv as kr,cE as kt,qI as l,Tl as la,Vp as li,lC as ln,px as lr,AA as lt,GI as m,ho as ma,tm as mi,TT as mn,ux as mr,zA as mt,yR as n,Bl as na,Fm as ni,GC as nn,PS as nr,cj as nt,aL as o,kl as oa,em as oi,mw as on,iS as or,VA as ot,$I as p,zo as pa,im as pi,$C as pn,lx as pr,GA as pt,sM as q,Id as qi,vT as qn,Im as qr,sT as qt,OL as r,Pl as ra,Gm as ri,WC as rn,mS as rr,dj as rt,iL as s,Ol as sa,Wp as si,fw as sn,Tx as sr,WA as st,vR as t,Jl as ta,Zm as ti,dC as tn,xS as tr,uj as tt,KI as u,Ks as ua,Yp as ui,bC as un,mx as ur,kA as ut,CI as v,ca as va,hp as vi,gC as vn,Gy as vr,uA as vt,cI as w,Hf as wi,lT as wn,My as wr,nE as wt,uI as x,Ci as xa,Gf as xi,Uw as xn,Ey as xr,$T as xt,dI as y,oa as ya,mp as yi,eT as yn,Ny as yr,Vk as yt,gF as z,qd as zi,aT as zn,lg as zr,IS as zt};
|
|
73
|
+
`}function Dh(){if(!_h)return;let e=fh(hh,mh?.anomalies),t=_h.hidden;_h.hidden=!e,e&&t&&mh&&(Th(),gh&&Eh())}function Oh(e){hh=e,Dh()}function kh(e){if(_h)return _h;let t=wh();return e.appendChild(t),Dh(),t}function Ah(e){mh=e,Dh(),_h&&!_h.hidden&&(Th(),gh&&Eh())}var jh=null,Mh=null,Nh=!1,Ph=null,Fh=new Set;function Ih(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function Lh(){for(let e of Fh)e()}function Rh(){return{report:jh,hasReportSendFailed:Nh}}function zh(e){Fh.add(e)}function Bh(e){Mh=e}function Vh(){if(!Mh)return;Ph=h(`hooks-report`);let e=Mh({type:`request-hooks-report`,requestId:Ph});e!==!Nh&&(Nh=!e,Lh())}function Hh(e){Ih(e,Ph)&&(jh=e,Nh=!1,Lh())}function Uh(){Vh()}var Wh=new Map;function Gh(e){return Wh.get(e)??[]}function Kh(e){return Gh(e).length>0}function qh(e){let t=k(e)?.btnDocs;t&&(t.hidden=!Kh(e))}var Jh=null,Yh=null;function Xh(){return Yh??=M(()=>import(`./doc-editor-ui-BsVwtyem.js`).then(e=>(Jh=e,e),e=>(Yh=null,u(`doc-editor`,`doc editor failed to load: ${d(e)}`),null)),__vite__mapDeps([11,12,13,5,3,14,15,16,17,18])),Yh}function Zh(e){Xh().then(t=>t?.openDocEditor(e))}function Qh(e){Jh?.applyDocsToOpenEditor(e)}function $h(e){Wh.set(e.id,e.docs),e.docs.length===0&&Wh.delete(e.id),qh(e.id),Qh(e.id)}function eg(e){let t=[...Wh.keys()];Wh.clear();for(let[t,n]of Object.entries(e.sessions))Wh.set(t,n);for(let e of new Set([...t,...Wh.keys()]))qh(e),Qh(e)}function tg(e,t){let n=k(e);n?li(n).show(`error`,t):Nn({source:`Session`,sessionId:typeof e==`string`?e:void 0,message:t})}function ng(e,t){let n=k(e);if(!n)return;let r=n.card.querySelector(`:scope > .session-failure-reason`);if(!(n.currentState===w.FAILED&&t)){r?.remove();return}let i=r??E(`p`,`session-failure-reason`);i.setAttribute(`role`,`status`),i.textContent=t,r||n.termWrap.before(i)}var rg=[],ig=new Set,ag=new WeakSet,og=null,sg=null;function cg(e){rg.some(t=>t.id===e.id)||(rg.push(e),ug(e.id,null))}function lg(){return rg}function ug(e,t){for(let n of ig)n(e,t)}function dg(e){return ig.add(e),()=>ig.delete(e)}function fg(e){e!==og&&(gg(),og=e)}function pg(e){og===e&&(gg(),og=null)}function mg(e,t){return sg?.page.id===e&&sg.sessionId===t}function hg(e,t,n=null){let r=rg.find(t=>t.id===e);if(!r||!og||og.sessionId()!==t||!r.isAvailableFor(t)||mg(e,t)&&n===null)return;gg();let i=og,a=i.elementFor(r);yg(a),sg={page:r,sessionId:t},r.mount(a,t,{placement:i.placement,target:n}),i.didShow(r),ug(r.id,t)}function gg(){if(!sg)return;let{page:e,sessionId:t}=sg;sg=null,e.unmount(),og?.didHide(e),ug(e.id,t)}function _g(){return sg?.page.canStepBack()??!1}function vg(){return sg?sg.page.canStepBack()?(sg.page.stepBack(),!0):(gg(),!0):!1}function yg(e){ag.has(e)||(ag.add(e),e.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Nt(e)||vg()&&e.preventDefault()}))}function bg({style:e}){let t=E(`div`,`session-page-bar session-page-bar-${e}`),n=new Map,r=null;function i(n){let i=e===`header`,a=C({variant:`quiet`,size:i?`small`:`default`,label:n.label,icon:x(n.iconPath),action:`${i?`open`:`show`}-${n.id}`});a.addEventListener(`click`,()=>{r&&hg(n.id,r)});let o=E(`span`,`session-page-dot`);o.setAttribute(`aria-hidden`,`true`);let s=E(`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 rg)a(e)}return dg((e,t)=>{if(t!==null&&t!==r)return;let n=rg.find(t=>t.id===e);n&&a(n)}),o(),{element:t,showSession(e){r=e,o()}}}var xg=2e3,Sg=`shown`,Cg=new Map,wg=new Map,Tg=[],Eg=[],Dg=null,Og=!1,kg=null,Ag=null;function jg(e){return Cg.get(e)??[]}function Mg(e){return jg(e).length>0}function Ng(e){return wg.get(e)??0}function Pg(e,t){return t.hasThumbnail?`/shown/${encodeURIComponent(e)}/${encodeURIComponent(`${t.id}.thumb.webp`)}`:null}function Fg(e){Tg.push(e)}function Ig(e){Eg.push(e)}function Lg(e){if(wg.delete(e)){ug(Sg,e);for(let t of Tg)t(e,[])}}async function Rg(e,t,n,r){let i=await Vg();mg(Sg,t)&&(i?((!kg||Ag!==t)&&(kg?.el.remove(),kg=i.createShownFace({sessionId:t,onClose:gg}),Ag=t),kg.el.dataset.placement=n,e.append(kg.el),kg.show(r),Lg(t)):(tg(t,`The shown files view did not load. Open it again to retry.`),gg()))}function zg(){kg?.hide(),kg?.el.remove()}var Bg={id:Sg,label:`Shown`,iconPath:ze,isAvailableFor:Mg,hasUnreadFor:e=>Ng(e)>0,mount(e,t,{placement:n,target:r}){Rg(e,t,n,r)},unmount:zg,canStepBack:()=>!1,stepBack:()=>{}};function Vg(){return Dg??=M(()=>import(`./shown-face-DTH_HMvh.js`).then(e=>e,e=>(Dg=null,u(`shown-files`,`shown file viewer failed to load: ${d(e)}`),null)),__vite__mapDeps([19,13,5,3,20])),Dg}function Hg(){let e=()=>{Vg()};`requestIdleCallback`in window?window.requestIdleCallback(e):setTimeout(e,xg)}function Ug(e,t=null){hg(Sg,e,t)}function Wg(e){return e.slice(-50)}function Gg(e,t){if(Ag===e&&kg?.applyArrivals(),t.length!==0){mg(Sg,e)||wg.set(e,Ng(e)+t.length),ug(Sg,e);for(let n of Tg)n(e,t)}}function Kg(e){let t=new Set(jg(e.id).map(e=>e.id)),n=e.files.filter(e=>!t.has(e.id));if(Cg.set(e.id,Wg([...jg(e.id),...n])),Gg(e.id,n),n.length!==0)for(let t of Eg)t(e.id,n)}function qg(e){let t=new Map(Cg),n=Og;Og=!0,Cg.clear();for(let[t,n]of Object.entries(e.sessions))Cg.set(t,Wg(n));for(let e of new Set([...t.keys(),...Cg.keys()])){Mg(e)||wg.delete(e);let r=new Set((t.get(e)??[]).map(e=>e.id)),i=n?jg(e).filter(e=>!r.has(e.id)):[];ug(Sg,e),Gg(e,i)}}var Jg=22,Yg={image:`Image`,video:`Video`,page:`Page`},Xg=new WeakMap;function Zg(e){let t=e.registerMarker(0);if(!t)return null;let n=Xg.get(e);if(n&&!n.marker.isDisposed&&n.marker.line===t.line)return t.dispose(),n;let r={marker:t,chipCount:0};return Xg.set(e,r),r}function Qg(e,t){let n=Ve(`shown-chip`);n.setAttribute(`aria-label`,`Open ${t.name}`);let r=Pg(e,t);if(r){let e=E(`img`,`shown-chip-thumb`);e.src=r,e.alt=``,e.decoding=`async`,n.append(e)}return r||n.append(E(`span`,`shown-chip-kind`,Yg[t.kind])),n.append(E(`span`,`shown-chip-name`,t.pageTitle??t.name)),n.addEventListener(`click`,n=>{n.stopPropagation(),Ug(e,t.id)}),n}function $g(e,t,n){let r=Zg(e);if(!r)return;let i=e.registerDecoration({marker:r.marker,anchor:`right`,x:r.chipCount*Jg,width:Jg,layer:`top`});if(!i)return;r.chipCount+=1;let a=Qg(t,n);i.onRender(e=>{e.contains(a)||e.replaceChildren(a),e.classList.add(`shown-chip-slot`)})}function e_(e,t){let n=k(e)?.term;if(n)for(let r of t)$g(n,e,r)}var t_=10,n_={low:0,medium:1,high:2};function r_(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 i_(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 a_(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function o_(e,t){for(let n of e.hotspots)a_(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`});for(let n of e.blastRadius)n.transitiveDependentCount<t_||a_(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`})}function s_(e,t){return e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function c_(e){return e.conflictRisk===null?-1:n_[e.conflictRisk]}function l_(e,t){return t.severity-e.severity||c_(t)-c_(e)||e.heading.localeCompare(t.heading)||e.groupKey.localeCompare(t.groupKey)}function u_(e,t){return e===null||t===null?e??t:n_[t]>n_[e]?t:e}function d_(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?(e.lines.push(n),e.conflictRisk=u_(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(s_);return n.sort(l_)}function f_(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:r_(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of i_(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);o_(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:d_(r.values()),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function p_(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 m_(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 h_(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=m_(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 g_(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function __(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 v_({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=b_(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 y_({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?v_({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 b_(e){return e||`base`}function x_(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function S_(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function C_({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 w_({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function T_(e){if(!e)return[];let t=new Map;for(let n of[...h_(e.committed?.diff),...h_(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 E_(e,t){return t===null?null:e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)??null}function D_(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 O_(e){return e!==w.DORMANT&&e!==w.DONE&&e!==w.FAILED}function k_(e,t){return(Ot.includes(e)||e===w.RUNNING)&&t}function A_(e){let{status:t,reason:n,isFetched:r,hasCommits:i,isWorkspace:a,state:o,effectiveBase:s}=e,c=__(e.files),l=O_(o),u=S_(t,n,k_(o,i)),d=w_({fetched:r,changedFileCount:c.files,hasCommits:i}),f=y_({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=C_({status:t,hasCommits:i,live:l,state:o});return{sentence:t===`parked`?`${f.text}. ${x_(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 j_=5e3,M_=new Map,N_=new Map,P_=new Map,F_=new Map,I_=new Map,L_=new Map,R_=new WeakMap,z_=new WeakMap,B_=new Set,V_=new Set,H_=null,U_=null,W_=null,G_=null,K_=null;function q_(e){return B_.add(e),()=>B_.delete(e)}function J_(e){for(let t of B_)t(e)}function Y_(e){if(!e)return[];let t=R_.get(e);if(t)return t;let n=T_(e);return R_.set(e,n),n}function X_(e){if(!e)return null;let t=z_.get(e);if(t)return t;let n=f_(e);return z_.set(e,n),n}function Z_(e){return O.get(e)?.card.dataset.workspace!==void 0}function Q_(e){let t=O.get(e);if(!t)return null;let n=P_.get(e)??null,r=Y_(n),i=F_.get(e)??null;return{...A_({status:M_.get(e)||`none`,reason:N_.get(e)??null,isFetched:P_.has(e),hasCommits:n?.hasCommits===!0,hasDiffError:i!==null,isWorkspace:Z_(e),state:t.currentState,effectiveBase:t.effectiveBase,isMergeInFlight:L_.has(e),files:r}),sessionId:e,sessionName:t.card.dataset.session||e,files:r,diffError:i,changeMapView:X_(I_.get(e)),notice:H_?.sessionId===e?H_.text:null,isWorkspace:Z_(e)}}function $_(e,t){H_={sessionId:e,text:t},U_&&clearTimeout(U_),U_=setTimeout(()=>{H_=null,J_(e)},j_),J_(e)}function ev(e){I_.has(e)||I_.set(e,null),_({type:`request-change-map`,id:e})}function tv(e){_({type:`request-session-diff`,id:e}),ev(e)}function nv(e,t){let n=M_.get(e);M_.set(e,t),g_(n,t)&&(P_.delete(e),F_.delete(e),I_.delete(e),e===zr()&&tv(e)),J_(e)}function rv(e,t,n=null){let r=t||`none`;N_.set(e,n);let i=L_.get(e);i!==void 0&&i!==r&&L_.delete(e),nv(e,r)}function iv(e,t,n=null){N_.set(e,n),L_.delete(e),nv(e,t||`none`)}function av(e,t){let n=D(e);n&&(P_.set(n,t),F_.delete(n),J_(n))}function ov(e,t){let n=D(e);n&&(F_.set(n,t),J_(n))}function sv(e,t){let n=D(e);if(!n)return;let r=ke.safeParse(t);r.success&&r.data.sessionId===n&&(I_.set(n,r.data),J_(n))}function cv(e){let t=D(e);t&&t===zr()&&tv(t)}function lv(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function uv(e){let t=D(e);if(!t||t!==zr())return;let n=!P_.has(t)||F_.has(t),r=!I_.has(t)||lv(I_.get(t));n&&tv(t),r&&!n&&ev(t),J_(t)}function dv(e){let t=D(e);t&&L_.delete(t)&&J_(t)}function fv(e){let t=D(e);M_.delete(t),N_.delete(t),P_.delete(t),F_.delete(t),I_.delete(t),L_.delete(t),t===zr()?ei(null):J_(t)}function pv(e,t){L_.has(e)||(_(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(L_.set(e,M_.get(e)||`none`),J_(e)):$_(e,`Not connected. The merge was not sent.`))}function mv(e){let t=Q_(e);return t?L_.has(e)?($_(e,`Merge is already on its way for "${t.sessionName}".`),!1):t.isMergeEnabled?O.get(e)?.currentState===w.RUNNING?(Vt({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:()=>pv(e,!0)}),!0):(pv(e,!1),!0):($_(e,t.mergeRefusal??`Nothing to merge in "${t.sessionName}" right now.`),!1):!1}function hv(e){let t=Q_(e);t?.isDiscardShown&&Vt({title:`Discard worktree`,message:`Throw away the worktree changes for "${t.sessionName}"? This cannot be undone.`,confirmLabel:`Discard`,danger:!0,onConfirm:()=>_({type:`discard-session-worktree`,id:e})})}function gv(){return[...V_].some(e=>!e.hasAttribute(`data-slot-held`))}function _v(){let e=gv()&&document.visibilityState===`visible`?zr():null;e!==W_&&(G_&&clearInterval(G_),G_=null,W_=e,_({type:`watch-session-changes`,id:e}),e&&(G_=setInterval(()=>_({type:`watch-session-changes`,id:e}),se)))}function vv(e){K_??=yv(),K_.observe(e)}function yv(){return document.addEventListener(`visibilitychange`,_v),Hr(e=>{e&&tv(e),_v()}),new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&V_.add(t.target),t.isIntersecting||V_.delete(t.target);_v()})}var bv=!1,xv=new Set;function Sv(e){bv=!!e,Nv();for(let e of xv)e(bv)}function Cv(e){return xv.add(e),()=>xv.delete(e)}function wv(){return bv}function Tv(){let e=E(`div`,`debug-close`);return e.append(C({variant:`icon`,size:`small`,label:`Close debug overlay`,icon:x(gt)})),e}function Ev(e){return e?St(new Date(e)):`-`}function Dv(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function Ov(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Dv(e.quietMs)})`:``}function kv(e){let t=`<span class="debug-dim">${Ev(e.ts)}</span>`;if(e.kind===`signal`){let n=F([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${F(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=Ov(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${F(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=F(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${F(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${F(e.category||`?`)}: <span class="debug-dim">${F(e.from||`?`)} → ${F(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${F(e.kind||`decision`)}</span>`}function Av(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">${F(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">${F(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${Ev(e.timestamp)}</span> ${F(e.from)} → ${F(e.to)} <span class="debug-label">${F(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?`${F(a.signal)} (${F(a.source||`?`)}${a.confidence?`/${F(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">${F(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 ${Dv(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">${F(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">${kv(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(Tv())}function jv(e,t){if(e.debugOpen){Mv(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(Tv()),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`)&&Mv(e)}),_({type:`debug-state`,id:t})}function Mv(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function Nv(){for(let[,e]of O)e.btnDebug.classList.toggle(`visible`,bv),e.btnTrace.classList.toggle(`visible`,bv),!bv&&e.debugOpen&&Mv(e)}function Pv(e){let t=typeof e.id==`string`?O.get(e.id):void 0;t?.debugOpen&&Av(t,e.payload)}function Fv(e){k(e)?.debugOpen&&_({type:`debug-state`,id:e})}function Iv(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0}}function Lv(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 Rv(e,t){return{body:t.join(`
|
|
74
|
+
`),tag:`glimmervoid-alert-${e.id}`,renotify:e.isStart}}var zv=4e3;function Bv(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function Vv(e,t,n,r=zv){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 Hv=`#plan/`;function Uv(e){return`${Hv}${encodeURIComponent(e)}`}function Wv(e){if(!e.startsWith(Hv))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var Gv=null;function Kv(){return Gv??=M(()=>import(`./alert-sound-Da6VQFBS.js`),__vite__mapDeps([10,7])).catch(e=>(Gv=null,u(`alert-sound`,`alert sound failed to load: ${d(e)}`),null)),Gv}function qv(){let e=_r();Kv().then(t=>t?.playAlertSound(e))}function Jv(){return typeof Notification>`u`?null:Notification}function Yv(){return Jv()!==null}function Xv(){let e=Jv();return e?e.permission:`unavailable`}async function Zv(){let e=Jv();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function Qv(){return!Yv()&&!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.`:Yv()?Xv()===`denied`&&lr()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function $v(){return lr()&&Xv()==="default"}function ey(e=()=>{}){let t=E(`div`,`notification-permission`),n=()=>{let r=Qv();if(t.replaceChildren(),t.hidden=!r&&!$v(),r){t.append(E(`p`,`notification-permission-hint text-meta text-text-muted`,r));return}let i=C({variant:`secondary`,label:`Enable desktop notifications`});i.addEventListener(`click`,()=>{i.disabled=!0,Zv().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var ty=`Notifications`,ny=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,ry=new Map,iy=!1;function ay(){iy||(iy=!0,Nn({source:ty,message:ny,hidesInStreamerMode:!1}))}function oy(e,t){let n=ry.get(e)??new Set;n.add(t),ry.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function sy(e){let t=ry.get(e);if(t){ry.delete(e);for(let e of t)e.close()}}function cy(e){return!Yv()||!lr()||document.documentElement.hasAttribute(`data-streamer`)?!1:e||!document.hasFocus()}function ly(){return cy(!1)&&Xv()===`granted`}var uy=null;function dy(e,t){let n=Jv();if(!n||(uy=Lv(uy,t,e.message),Mn(ty),!Vv(window.localStorage,Bv(`group-${t.id}`,`${e.session}-${e.category}`),Date.now())))return;let r=t.sessionIds.length===1?O.get(e.session):void 0,i=t.sessionIds.length>1?`${t.sessionIds.length} sessions`:r?vn(r):`Glimmervoid`;try{let r=new n(i,Rv(t,uy.lines));r.onclick=()=>{window.focus(),e.kind===`plan`&&(window.location.hash=Uv(e.session)),r.close()};for(let e of t.sessionIds)O.has(e)&&oy(e,r)}catch{}}var fy=null;function py(e){return!e||e.id!==fy&&(fy=e.id,!0)}function my(e){O.get(e.session)?._isActiveViewer?.()===!0?_({type:`alert-seen`,id:e.session}):py(e.group)&&ir()&&qv()}function hy(e,t){t?dy(e,t):vy(e)}function gy(){let e=Reflect.get(navigator,`userAgentData`);return typeof e!=`object`||!e?!1:Reflect.get(e,`platform`)===`macOS`}function _y(e){if(document.hasFocus()){my(e);return}let t=e.group;ly()&&(hy(e,t),!gy())||(cy(!1)&&Xv()===`denied`&&ay(),t?.isStart!==!1&&py(t)&&ir()&&qv())}function vy({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=Jv();if(!a||!cy(!!i)||(a.permission===`denied`&&ay(),a.permission!==`granted`)||(Mn(ty),!Vv(window.localStorage,Bv(e,t),Date.now())))return;let o=typeof e==`string`?e:``,s=O.get(o),c=s?vn(s):``;try{let i=new a(c||`Glimmervoid`,Iv(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=Uv(o)),i.close()},s&&oy(o,i)}catch{}}var yy=null;function by(){return yy??=M(()=>import(`./resume-dialog-ukLRYAb4.js`),__vite__mapDeps([21,12,13,5,3,14,22,15,23])).catch(e=>(yy=null,u(`resume-dialog`,`restart dialog failed to load: ${d(e)}`),null)),yy}var xy=null,Sy=null;function Cy(){return Sy??=M(()=>import(`./plan-face-DReWFWAO.js`).then(e=>(xy=e,e),()=>(Sy=null,null)),__vite__mapDeps([24,13,5,3,14,25,26,16,17,27])),Sy}function wy(e){let t=E(`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,Cy().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))}}}var Ty=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function Ey(e){return e===`approve`||e===`approve-accept-edits`}function Dy(e){return(e.state===`decided`||e.state===`closed`)&&Ey(e.lastDecision)}function Oy(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&Dy(n)}function ky(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function Ay(e){let t=ky(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 jy(e,t){return ky(e,t)?.openRevision?.revision??null}function My(e,t,n){if(n===null)return null;let r=ky(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function Ny(e,t){let n=t-e;return Number.isFinite(n)?ue(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function Py(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 Fy(e,t,n){let r=Py(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return Ty.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function Iy(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 Ly(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function Ry(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+Pe}function zy(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 ${tt} characters, so nothing was sent`:Ly(e)>1e4?`the feedback composes more than the ${xe} characters the hook reply carries, so nothing was sent`:Ry(e)>Ie?`the decision is larger than one control frame carries, so nothing was sent`:null}function By(e){return e?`, ${e}`:``}function Vy(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=Iy(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 Hy(e,t,n){let r=Vy(e,t,n);return r?`${r}${By(e.problem)}`:e.problem??``}function Uy(e){let t=ky(e.state,e.selectedAgentId),n=Ay(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:My(e.state,t?.agentId??null,n),status:Hy(e,t,n),actions:Fy(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:My(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:Py(e,t,n)}]}}function Wy(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 Gy({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 Ky({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var qy=e=>Lt.includes(e),Jy=e=>At.includes(e);function Yy(e){let t=e.currentState;e.btnRestart.classList.toggle(`visible`,qy(t)||Jy(t)||t===w.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,wv()),e.btnPlan.hidden=Ky(e)===`hidden`}function Xy(e){let t=k(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(D(e)),Yy(t),Ic(t,D(e)),!0)}function Zy(e,t){let n=k(e);n&&(n.hasPlan=t===!0,Yy(n))}function Qy(e){let t=k(e.id);t&&(t.planReviewState=Wy(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),Yy(t))}function $y(e){let t=k(e.id);t&&t.planFace.update({draft:e})}function eb(e){let t=k(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),Yy(t))}function tb(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=k(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function nb(e){for(let[,t]of O)t.planFace.update({isConnected:e})}var rb=160,ib=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 ab(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=rb?t:`${t.slice(0,157)}...`}function ob(e,t){let n=ib[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?ab(r):``}var sb=5e3;function cb(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function lb(e,t){if(!e.toolUseId)return cb(e.text)??`context`;let n=t.get(e.toolUseId);return n?ob(n.name,n.input)||n.name:`expansion`}function ub(e){return e.kind!==`expansion`||e.toolUseId?!1:cb(e.text)!==null}function db(e){return e.kind===`prompt`||e.kind===`session`||ub(e)}function fb(e){return new TextEncoder().encode(e).byteLength}var pb={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`};function mb(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:ab(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:ab(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:ab(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:ab(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:ab(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:lb(e,t)};if(e.kind===`tool_call`){let t=ob(e.name,e.input);return t?{prefix:`${e.name}: `,text:t}:{prefix:``,text:e.name}}return{prefix:`${t.get(e.toolUseId)?.name??`Tool`} result: `,text:`${fb(e.content)} bytes`}}function hb(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function gb(e,t){let n=mb(e,t),r=hb(e),i=e.kind===`tool_call`||e.kind===`tool_result`?`${n.prefix}${n.text}`:n.text,a=[],o=e.kind===`notice`?`muted`:`default`;if(e.kind===`tool_result`&&e.isError&&(o=`error`,a.push(`error`)),e.truncated===!0&&(o!==`error`&&(o=`muted`),a.push(`truncated`)),e.kind===`tool_result`){let n=t.get(e.toolUseId),r=n?e.ts-n.ts:NaN;Number.isFinite(r)&&r>=0&&a.push(r>1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`)}return{kind:e.kind,tag:pb[e.kind],text:`${r}${i}`,tone:o,badges:a}}function _b(e,t){return{record:e,...gb(e,t)}}function vb(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function yb(e,t){let n=vb(e);return!n||t.has(n)?null:n}function bb(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function xb(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function Sb(e,t){if(t.size!==0)for(let n of e.turns)for(let r=0;r<n.rows.length;r+=1){let i=n.rows[r],a=vb(i.record);a&&t.has(a)&&(n.rows[r]=_b(i.record,e.toolCallByUseId))}}function Cb(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function wb(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function Tb(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=fb(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function Eb(e,t){for(let n of t)n.kind===`tool_call`&&e.toolCallByUseId.set(n.toolUseId,n);let n=[],r=e.turns[e.turns.length-1]??null;for(let i of t){let t=yb(i,e.toolCallByUseId);t&&bb(e.unresolvedToolUseCounts,t);let a=_b(i,e.toolCallByUseId);if(db(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:wb()},Tb(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:wb()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),Tb(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 Db(e,t){let n=Cb();Eb(n,t);let r=new Set;for(let[t,i]of n.toolCallByUseId)e.toolCallByUseId.has(t)||(e.toolCallByUseId.set(t,i),r.add(t));let i=new Set;for(let t of r)e.unresolvedToolUseCounts.delete(t)&&i.add(t);for(let[t,r]of n.unresolvedToolUseCounts)e.toolCallByUseId.has(t)||bb(e.unresolvedToolUseCounts,t,r);let a=n.turns[n.turns.length-1],o=e.turns[0],s=!!a&&!!o&&!o.head,c=s?a.head:null,l=s?a.rows:[];if(s){n.turns.pop();let e=a.startedAt,t=o.startedAt;e!==null&&(t===null||e<t)&&(o.startedAt=a.startedAt),o.head=c,o.rows=[...l,...o.rows],o.metrics={rowCount:a.metrics.rowCount+o.metrics.rowCount,toolCallCount:a.metrics.toolCallCount+o.metrics.toolCallCount,errorCount:a.metrics.errorCount+o.metrics.errorCount,resultBytes:a.metrics.resultBytes+o.metrics.resultBytes}}return e.turns=[...n.turns,...e.turns],Sb(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function Ob(e){return e.rows.length+ +!!e.head}function kb(e){let t=0;for(let n of e.turns)t+=Ob(n);return t}function Ab(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=vb(n.record);t&&xb(e.unresolvedToolUseCounts,t)}}function jb(e,t){Ab(e,t.head?[t.head,...t.rows]:t.rows)}function Mb(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);Ab(e,i);for(let e of i)Tb(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function Nb(e,t=sb){let n=kb(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=Ob(t),jb(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:Mb(e,n-t)}}function Pb(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 Fb(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 Ib(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 Lb(e,t=sb){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function Rb(e,t=sb){return!Lb(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function zb(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 Bb=1e4,Vb=null,Hb=null,Ub=[],Wb=null,Gb=null,I=null,Kb=null,qb=!1,Jb=null,Yb=()=>!1,Xb=new Set;function Zb(e){for(let t of Xb)t(e)}function Qb(){Kb&&=(clearTimeout(Kb.timeoutHandle),null)}function $b(){Kb=null,Jb=`The trace did not load within ${Math.round(Bb/1e3)} s.`,Zb({kind:`rebuild`})}function ex(e){Qb(),qb=!1,Jb=null,Wb=e,I=e?{sessionId:e,grouping:Cb(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,Zb({kind:`selection-reset`})}function tx(e){let t=Fb(Ub,Gb,Wb,e);return Gb&&t===Gb&&(Gb=null),t!==Wb&&(ex(t),!0)}function nx(e){if(!Vb)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};Vb(t)?Kb={request:e,timeoutHandle:setTimeout($b,Bb)}:(Jb=Ee,Zb({kind:`header`}))}function rx(e=!1){if(!Vb)return;let t=Ib({selectedSessionId:Wb,isPanelVisible:e||Yb(),hasPendingRequest:!!Kb,hasLoadedOnce:I?.hasLoadedOnce??!1,nextOffset:I?.nextOffset??0});t&&nx(t)}function ix(){qb&&!Kb&&(qb=!1,rx())}function ax(){if(!I)return;let e=Nb(I.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!I.hasDroppedEarliestRows;t&&(I.hasDroppedEarliestRows=!0),Zb({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function ox(e){I&&(Zb({kind:`records-appended`,appends:Eb(I.grouping,e)}),ax())}function sx(e){I&&(Zb({kind:`records-prepended`,prepend:Db(I.grouping,e)}),ax())}function cx(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 lx(){return{selectedSessionId:Wb,hasPendingRequest:!!Kb,hasLoadedOnce:I?.hasLoadedOnce??!1,hasDroppedEarliestRows:I?.hasDroppedEarliestRows??!1,firstOffset:I?.firstOffset??0,residentRowCount:I?kb(I.grouping):0}}function ux(){return{sessionOptions:Ub,selectedSessionId:Wb,selectedTrace:I,pendingSessionId:Kb?.request.id??null,traceFailureText:Jb}}function dx(e){Xb.add(e)}function fx(e){Yb=e}function px(){if(!Vb)return;let e=Rb(lx());e&&nx(e)}function mx(e){Ub.some(t=>t.id===e)&&e!==Wb&&(Gb=null,ex(e),rx(),Zb({kind:`rebuild`}))}function hx(){let e=tx(!0);return rx(!0),e}function gx(e){Vb=e}function _x(e){Hb=e}function vx(e){Gb=e,Hb?.()}function yx(e){Ub=Pb(e);let t=tx(Yb());t&&rx(),Zb({kind:`sessions`,hasSelectionChanged:t})}function bx(e){let t=cx(e);if(!t)return;let n=zb({pendingRequest:Kb?.request??null,resident:I?{sessionId:I.sessionId,firstOffset:I.firstOffset,nextOffset:I.nextOffset,hasLoadedOnce:I.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?ix():(Qb(),Jb&&(Jb=null,Zb({kind:`header`})),n===`stale`?ix():n===`reset`?(ex(t.id),I&&(I.filePath=t.path),rx(),Zb({kind:`rebuild`}),ix()):I&&(I.filePath=t.path,n===`prepend`?(I.firstOffset=t.start,sx(t.records),ix()):(n===`seed`&&(I.hasLoadedOnce=!0,I.firstOffset=t.start),I.nextOffset=t.next,ox(t.records),ix())))}function xx(e){let t=e?.id;typeof t==`string`&&t===Wb&&Yb()&&(Kb?qb=!0:rx())}function Sx(e){let t=e?.id;if(typeof t!=`string`||Kb?.request.id!==t)return!1;Qb(),qb=!1;let n=e?.message;return Jb=typeof n==`string`&&n?n:`The trace could not be read.`,Zb({kind:`rebuild`}),!0}function Cx(e){Qb(),qb=!1,Jb=e?null:Ee,e?(Zb({kind:`header`}),rx()):Zb({kind:`rebuild`})}function wx(e){return e instanceof Error?e.message:String(e)}function Tx(e,t,n=!1){let r=E(`label`,`dialog-checkbox-label`),i=E(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,E(`span`,null,e)),r}function Ex(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function Dx(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:Ex(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 Ox(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:o}=Ut({title:`Workspace repositories`}),s=E(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),c=E(`fieldset`,`dialog-workspace-list`);c.setAttribute(`aria-label`,`Workspace repositories`),c.append(E(`div`,`dialog-hint`,`Loading repositories...`));let l=E(`div`,`dialog-hint`);l.setAttribute(`role`,`status`);let u=E(`div`,`dialog-error`),d=C({variant:`primary`,label:`Save`,disabled:!0});i.append(d),n.append(s,c,l,u,i),o.addEventListener(`click`,r),requestAnimationFrame(()=>o.focus()),Dx(e).then(e=>{if(t.isConnected){c.textContent=``;for(let t of e)c.append(Tx(t.name,t.path,t.isMember));d.disabled=!1}}).catch(e=>{t.isConnected&&(c.textContent=``,u.textContent=`Could not load repositories: ${wx(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: ${wx(e)}`)}).finally(()=>{l.textContent=``,d.disabled=!1}))})}function kx(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function Ax(e,t){pn(e.taskTitleEl,()=>mn(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),Xt(e,t)}),e.nameEl.addEventListener(`click`,()=>{Jt(e.nameEl)||ei(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),Xt(e,t))}),e.btnRename.addEventListener(`click`,()=>{kx(e),Xt(e,t,{returnsFocusToTerminal:!e.renameTargetEl?.isConnected})}),e.btnRestart.addEventListener(`click`,()=>{kx(e),by().then(n=>n?.openRestartDialog(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0}))}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{kx(e),Ox(t)}),e.btnTrace.addEventListener(`click`,()=>{kx(e),vx(t)}),e.btnDocs.addEventListener(`click`,()=>{kx(e),Zh(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=Ky(e);n!==`hidden`&&(n===`face`?Xy(t):location.hash=Uv(t))}),e.btnRemove.addEventListener(`click`,()=>{kx(e),Yr(t)});function n(){for(let[,t]of O)t!==e&&kx(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`)}e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation(),e.sessionMenu.classList.contains(`open`)?kx(e):n()}),fi({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:()=>kx(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&&kx(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),kx(e),jv(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&Mv(e)},{signal:e.abortController.signal})}var jx=1500,Mx=new WeakMap;function Nx(e){clearTimeout(Mx.get(e)),Mx.delete(e)}function Px(e,t){let n=setTimeout(()=>{Mx.delete(e),_({type:`dismiss`,id:t,expectedState:w.COMPLETE})},jx);Mx.set(e,n)}function Fx(e,t,n){let r=document.activeElement;return Vr({previousState:t,nextState:n,isPhoneLayout:no(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}var Ix=e=>e==null?``:String(e);Ig(e_);function Lx(e,t,n){let r=k(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&hn(e,r.taskTitle)}}function Rx(e){return typeof e==`string`&&O.has(e)}function zx(){return O.size}function Bx(e){let t=e||{};t.cursorBlink!=null&&wu(t.cursorBlink),t.debugMode!=null&&(Sv(t.debugMode),Oh(t.debugMode));for(let[,e]of O)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function Vx(){vl(O.values(),bl())}function Hx(e){return{state:e.currentState,unseenOutcome:e.unseenOutcome,ownerId:e.ownerId}}function Ux(){let e=gn(A.counts),t=e>0?`(${e}) Glimmervoid`:`Glimmervoid`;document.title!==t&&(document.title=t)}function Wx(e,t,n,r={}){if(!Tn)return;let i=D(e),a=Ix(n)||w.DORMANT,o=Qt(i,Ix(t),a,r),s=a===w.DORMANT;Tn.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),Yy(c),Pu(c,i)}let u=new AbortController,d=wy({signal:u.signal,requestPlan:(e,t,n)=>_({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>_({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:l,sendDecision:(e,t)=>_({type:`plan-decision`,id:e,...t}),reportProblem:e=>tg(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:Ix(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=()=>Pu(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=O.get(i);return f&&On(A,Hx(f)),O.set(i,c),yn(A,Hx(c)),Bn(i,c),Ax(c,i),Yy(c),c.btnDocs.hidden=!Kh(i),a===w.RUNNING&&zn(c,!0),s||ju(c,i),Ux(),c}function Gx(e,t){let n=k(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function Kx(e,t){let n=k(e);n&&(n.agent=typeof t==`string`?t:null,Yy(n))}function qx(e,t){let n=k(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function Jx(e,t,n=!1){let r=k(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=zt(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function Yx(e,t){let n=k(e);n&&(n.pendingPromptKind=typeof t==`string`?t:null)}function Xx(e,t){let n=k(e);n&&(On(A,Hx(n)),n.unseenOutcome=t??null,yn(A,Hx(n)))}function Zx(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function Qx(e,t,n=null){let r=k(e),i=Ix(t)||`none`;r&&Zx(r.card,i),rv(D(e),i,Ix(n)||null)}function $x(e,t,n=null){let r=k(e),i=Ix(t)||`none`;r&&Zx(r.card,i),iv(D(e),i,Ix(n)||null)}function eS(e,t){let n=k(e);if(!n)return;let r=Ix(t);n.card.dataset.session=r,n.nameEl.textContent=r}function tS(e){let t=k(e);t&&(Mv(t),On(A,Hx(t)),O.delete(D(e)),Bn(D(e),void 0),xy?.dropPlanBodyCache(D(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),dl(t,D(e)),Ba(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),Ux())}function nS(e,t,n){if(!t||!e.term)return;let r=n===w.DONE?`Session complete`:`Session failed`,i=n===w.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 rS(e,t){e.term&&(t===w.DONE||t===w.FAILED)&&(e.term.clear(),e.term.reset())}function iS(e){let t=O.get(e);t&&wn({state:t.currentState,unseenOutcome:t.unseenOutcome})&&document.visibilityState===`visible`&&(no()||document.hasFocus())&&_({type:`dismiss`,id:e,expectedState:t.currentState})}function aS(e,t,n){let r=k(e);if(!r)return;let i=Ix(t),a=r.currentState;On(A,Hx(r)),r.currentState=i,yn(A,Hx(r)),Bn(D(e),r),i!==w.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(Nx(r),r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),zn(r,i===w.RUNNING)),a===w.DORMANT&&i!==w.DORMANT&&ju(r,D(e)),kn({state:i})===`resting`&&sy(D(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,zt(i,r.awaitingBackgroundTasks)),Yy(r),Fx(r,a,i)&&Px(r,D(e));let o=i===w.DONE||i===w.FAILED,s=a!==w.DONE&&a!==w.FAILED&&a!==w.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===w.DONE||i===w.FAILED)&&nS(r,s,i),i===w.INITIALIZING&&rS(r,a),Ux()}var oS=Ai({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function sS(e){let t=E(`ul`,`session-setup-list`);return t.append(...e.map(e=>E(`li`,null,e))),t}function cS(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=Ft(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[E(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=E(`div`,`session-setup-plugin`);return t.append(E(`h3`,null,e.name)),e.skills.length>0&&t.append(E(`p`,`session-setup-label`,`Skills`),sS(e.skills)),e.agents.length>0&&t.append(E(`p`,`session-setup-label`,`Agents`),sS(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[sS(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=E(`p`,`session-setup-hook`);return t.append(E(`span`,null,e.event),E(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>E(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[sS(t.skills)]:[]),n(`Agents`,t.agents.length>0?[sS(t.agents)]:[])}function lS(e){let t=E(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=E(`div`,`session-setup-sections`);oS.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function uS(e){let t=oS.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;cS(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function dS(e){return ue(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function fS(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${dS(Date.now()-e)} ago`}var pS=e=>`polled ${fS(e)}`;function mS(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=pS){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=Vn(a)}}}var hS=80,gS=Object.freeze([{value:`day`,label:`Today`,days:1},{value:`week`,label:`Last 7 days`,days:7},{value:`month`,label:`Last 30 days`,days:30}]),_S=`week`;function vS(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function yS(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function bS(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${vS(String(Math.abs(t)))}`}function xS(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.abs(e);if(t===0)return`$0.00`;let n=e<0?`-`:``;if(t<1e-4)return e<0?`above -$0.0001`:`<$0.0001`;if(t<.01)return`${n}$${t.toFixed(4)}`;let[r,i]=t.toFixed(2).split(`.`);return`${n}$${vS(r)}.${i}`}function SS(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}${yS((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${yS((n/1e6).toFixed(2))}M`:`${t}${yS((n/1e9).toFixed(2))}B`}function CS(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=hS?`warn`:`ok`}var wS=90;function TS(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&S(e.budgetUsd,null)!==null):[]}function ES(e){let t=S(e?.pct,null);return t===null?0:t}function DS(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 OS(e){return e?.vendor===`codex`||e?.vendor===`kimi`?e.vendor:`claude`}function kS(e,t=null){let n=[],r=CS(DS(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 TS(e)){let e=ES(t);if(e<wS)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return bt(n)}function AS(e,t=``){let n=e?.source;if(n===`fetched`){let e=it(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=it(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 jS(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 MS(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=MS(e.dirs);if(n!==null&&t.push(`${bS(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${bS(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${bS(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${bS(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 PS(e){return it(e?.error,``)}function FS(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}var IS=`Estimated list prices, not a bill.`,LS=`Enable in Settings.`,RS=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],zS=/^(\d{4})-(\d{2})-(\d{2})$/,BS=new Set([`day`,`model`,`label`]),VS=new Set([`model`,`label`]);function HS(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${yS(e.toFixed(1))}%`}var US=`tokens`,WS=Object.freeze([{value:`tokens`,label:`Tokens`},{value:`cost`,label:`Cost`}]);function GS(e){return e===`cost`?`cost`:US}function KS(e,t){return t===`cost`?xS(e):SS(e)}function qS(e,t){if(t===`tokens`)return`tokens`;let n=Number(e?.costUSD);return Number.isFinite(n)&&n>0?`costUSD`:`tokens`}function JS(e){return e===`costUSD`?`share of cost`:`share of tokens`}function YS(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function XS(e){let t=zS.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=RS[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function ZS(e){let t=QS(e);return t.length===0?``:t.length===1?XS(t[0]):`${XS(t[0])} to ${XS(t[t.length-1])}`}function QS(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>zS.test(e)).sort()}function $S(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:eC(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function eC(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=tC(e,n);return zS.test(r)?r:tC(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function tC(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function nC(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:pe(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function rC(e,t){let n=Ne(t-864e5),[,r,i]=e.yesterday.day.split(`-`).map(Number),a=e.yesterday.day===n?`yesterday`:`${RS[r-1]} ${i}`,o=e.yesterday.sessionCount===1?`session`:`sessions`;return`${a}: ${e.yesterday.sessionCount} ${o}, ${nC(e.yesterday.activeMs/6e4)}`}function iC(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=RS[n.getMonth()];return r?`${r} ${n.getDate()} ${me(n)}`:`-`}var aC=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`}),oC=`Sessions spawned by Glimmervoid; terminal sessions count as other`,sC=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function cC(e){let t=it(e,``);return t?aC[t]||t:aC.other}function lC(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function uC(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function dC(e){return lC(e).some(e=>uC(e.lane))}var fC=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function pC(e,t,n){let r=DS(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function mC(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=>uC(e.lane)).map(e=>({lane:String(e.lane),label:cC(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?YS(c,a):YS(l,o),d=pC(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:fC[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function hC(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:aw.map(e=>mC(e.key,r[e.key],t,n)).filter(e=>e!==null)}function gC(e){return e.planPct===null?``:`about ${HS(e.planPct)} of plan`}function _C(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?xS(e.costUSD):SS(e.tokens)}`).join(`, `)}var vC=`team-review`;function yC(e){if(!Array.isArray(e?.byLane))return``;let t=lC(e).find(e=>e.lane===vC),n=S(t?.costUSD,0);if(n<=0)return``;let r=YS(n,e?.totals?.costUSD),i=r===null?``:`, ${HS(r)} of this period`;return`PR reviews cost ${xS(n)}${i}.`}function bC(e){let t=S(e,null);return t===null||t<=0?``:`${bS(t)} ${t===1?`session`:`sessions`}`}function xC(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function SC(e){let t=xC(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 ${xS(n)}${i}, across ${SS(S(t.cacheReadTokens,0))} cache read tokens.`}function CC(e){return e===`monthly`?`this month`:`today`}function wC(e){return`${xS(S(e?.spentUsd,0))} of ${xS(S(e?.budgetUsd,0))}`}function TC(e){return`${CC(e?.scope)} spend against budget`}var EC=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function DC(e){let t=zS.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function OC(e){let t=DC(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Ne(t)}function kC(e){let t=zS.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function AC(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 jC(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=gw(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 MC(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)||AC(r);jC(i,e),n.set(r,i)}return Array.from(n.values()).map(MC)}function PC(e){return NC(e,OC)}function FC(e){return NC(e,kC)}function IC(e,t){return t===`week`?PC(e):t===`month`?FC(e):Array.isArray(e)?[...e]:[]}var LC=/^(\d{4})-(\d{2})$/;function RC(e,t){if(t===`month`){let t=LC.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=RS[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=XS(e);return t===`-`?t:`week of ${t}`}return XS(e)}function zC(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var BC=16,VC=Object.freeze([.05,.25,.5,.75]),HC=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function UC(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<VC.length;e+=1)i>=VC[e]&&(a=e+1);return a}function WC(e,{weeks:t=BC,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>zS.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`&&zS.test(n)?n:Ne(o),c=DC(OC(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Ne(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=Ne(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:UC(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function GC(e){let t=XS(e?.day);if(e?.noData)return`${t}: no data`;let n=S(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${SS(n)} tokens, ${xS(S(e?.costUSD,0))}`}function KC(e){if(!e)return``;let t=S(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${XC(e.ratio)} the ${n} average: ${xS(e.todayUsd)} against ${xS(e.baselineUsd)}.`}function qC(e){return e?`This block is burning ${XC(e.ratio)} the usual rate: ${SS(e.current)} tokens per minute against ${SS(e.baseline)}.`:``}function JC(e){return[KC(e?.daily),qC(e?.burn)].filter(Boolean).join(` `)}function YC(e){return!!(e?.daily||e?.burn)}function XC(e){let t=S(e,null);return t===null?`-`:`${yS(t.toFixed(1))}x`}var ZC=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`,kimi:`Kimi`});function QC(e){let t=it(e,``);return t?ZC[t]||t:ZC.claude}function $C(e,t){return tw(t)?QC(e?.vendor):``}function ew(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:QC(e),tokens:S(t[e]?.tokens,0),costUSD:S(t[e]?.costUSD,0)}))}function tw(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 nw=`Claude only`;function rw(e){return tw(e)?nw:``}var iw=36e5,aw=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]),ow=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`},{vendor:`kimi`,label:`Kimi Code`}]);function sw(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 cw(e,t=Date.now()){let n=S(e,null);return n===null||n<=0||t-n>iw}function lw(e,t=Date.now()){if(!cw(e,t))return``;let n=sw(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function uw(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 dw(e){let t=it(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function fw(e){return PS(e)!==``}function pw(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 mw(e){return typeof e?.id==`string`&&e.id!==``}function hw(e){let t=it(e?.label,``);return mw(e)&&t?t:pw(e?.project)||t||`unknown project`}function gw(e){let t=typeof e==`string`?e:e?.model;return it(t,`unknown model`)}function _w(e){return String(e?.day??``)}function vw(e,t,n){if(!BS.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?_w(e):n(e)}function yw(e,t,n,r=hw){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=vw(e,t,r),o=vw(n,t,r);if(typeof i==`string`||typeof o==`string`)return a*String(i).localeCompare(String(o));if(i!==o)return a*(i-o);let s=Number(e?.tokens),c=Number(n?.tokens),l=Number.isFinite(s)?s:0,u=Number.isFinite(c)?c:0;return l===u?r(e).localeCompare(r(n)):u-l})}function bw(e){return VS.has(e)?`asc`:`desc`}function xw(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:bw(t)}}function Sw(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var Cw=Object.freeze({key:`lastTs`,dir:`desc`}),ww=Object.freeze({key:`tokens`,dir:`desc`}),Tw=Object.freeze({key:`day`,dir:`desc`});function Ew(e,t=Cw){return yw(e,t.key,t.dir,hw)}function Dw(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 Ow(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${bS(t)} hidden`}function kw(e,t=ww){return yw(e,t.key,t.dir,gw)}function Aw(e,t=Tw){return yw(e,t.key,t.dir,_w)}function jw(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function Mw(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,Pw=24*Nw,Fw=Object.freeze({fiveHour:{lengthMs:5*Nw,label:`5-hour`},sevenDay:{lengthMs:7*Pw,label:`weekly`}}),Iw=10,Lw=80,Rw=100,zw=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function Bw(e,t){return e>=Rw?`fail`:e>=Lw||t!==null&&t>=Lw?`warn`:`ok`}function Vw(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 Hw(e,t,n,r){let i=DS(n,t);if(!i||i.pct===null||i.resetsAtMs!==null&&i.resetsAtMs<=r)return null;let a=Fw[t],o=Vw(a.lengthMs,i.resetsAtMs,r),s=o!==null&&o>=Iw&&i.pct<Rw?i.pct/(o/100):null;return{vendor:e,vendorLabel:ow.find(t=>t.vendor===e)?.label||e,key:t,windowLabel:a.label,usedPct:i.pct,elapsedPct:o,projectedPct:s,resetsAtMs:i.resetsAtMs,tone:Bw(i.pct,s)}}function Uw(e,t){return ow.flatMap(({vendor:n})=>aw.map(({key:r})=>Hw(n,r,e[n],t)).filter(e=>e!==null))}function Ww(e,t){let n=S(e,null);if(n===null||n<=0)return``;let r=new Date(n),i=me(r);return Ne(n)===Ne(t)?i:n-t<7*Pw&&r.getDay()!==new Date(t).getDay()?`${zw[r.getDay()]} ${i}`:`${RS[r.getMonth()]} ${r.getDate()} ${i}`}function Gw(e){return`${Math.round(e)}%`}function Kw(e){return Math.max(e.usedPct,e.projectedPct??0)}function qw(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 Jw(e,t){let n=qw(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 ${Gw(100-r.usedPct)} of its ${r.windowLabel} window left.`}function Yw(e,t){let n=Ww(e,t);return!n||e===null?`until the window resets`:`until ${n}, in ${nC((e-t)/6e4)}`}function Xw(e,t,n){let r=[`${e.vendorLabel} sessions stop answering ${Yw(e.resetsAtMs,n)}. Their worktrees and conversations stay intact.`,Jw(t,e.vendor)];return{tone:`fail`,headline:`${e.vendorLabel} ${e.windowLabel} limit reached.`,detail:r.filter(Boolean).join(` `)}}function Zw(e,t){let n=Ww(e.resetsAtMs,t),r=n?`, resets ${n}`:``;if(e.usedPct>=Lw)return{tone:`warn`,headline:`${e.vendorLabel} ${e.windowLabel} limit is at ${Gw(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 ${Gw(e.projectedPct??e.usedPct)}.`}}function Qw(e){return{tone:`warn`,headline:`Over your ${CC(e.scope)===`today`?`daily`:`monthly`} budget.`,detail:`${wC(e)} spent ${CC(e.scope)}.`}}function $w(e,t,n,r){let i=e.find(e=>e.tone===`fail`);if(i)return Xw(i,e,r);let a=e.filter(e=>e.tone===`warn`).sort((e,t)=>Kw(t)-Kw(e))[0];if(a)return Zw(a,r);let o=t.find(e=>S(e.pct,0)>=100);if(o)return Qw(o);if(e.length===0)return{tone:`ok`,headline:n===null?`Nothing spent yet today.`:`${xS(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)=>Kw(t)-Kw(e))[0],c=Ww(s.resetsAtMs,r);return{tone:`ok`,headline:`Every limit has room.`,detail:`Closest is ${s.vendorLabel} ${s.windowLabel} at ${Gw(s.usedPct)}${c?`, resets ${c}`:``}.`}}function eT(e){return e.tone===`fail`?`limit reached`:e.projectedPct===null?e.elapsedPct===null?``:`too early to project`:`about ${Gw(e.projectedPct)} at reset`}var tT=`report`;function nT(e){return gS.find(t=>t.value===e)?.label||``}function rT(e,t){return{key:qS(e,t),dir:`desc`}}function iT(e,t){let n=kw(e?.models,rT(e?.totals,t))[0];if(!n)return null;let r=qS(e?.totals,t);return{label:gw(n),sharePct:YS(n[r],e?.totals?.[r])}}function aT(e,t){let n=Ew(e?.sessions,rT(e?.totals,t)),r=n[0];return{count:n.length,topLabel:r?hw(r):``}}function oT(e){let t=lC(e).filter(e=>uC(e.lane));return t.length===0?null:t.reduce((e,t)=>e+S(t.costUSD,0),0)}function sT(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 cT(e){return QS(e).length}function lT(e,t){let n=DC(e);return!n||t<=0?[]:Array.from({length:t},(e,r)=>{let i=new Date(n);return i.setDate(n.getDate()-(t-1-r)),Ne(i)})}function uT(e){return gS.find(t=>t.value===e)?.days??7}function dT(e){return e.reduce((e,t)=>t.resetsAtMs===null?e:e===null?t.resetsAtMs:Math.min(e,t.resetsAtMs),null)}function fT(e,t){let n=DC(e);return n?(n.setDate(n.getDate()+t),Ne(n)):``}function pT(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=String(e?.day??``);zS.test(n)&&r.set(n,(r.get(n)??0)+S(e?.[t],0))}return r}function mT(e,t){let n=DC(e);return n?t<=7?zw[n.getDay()]:String(n.getDate()):e}function hT(e,t,n,r){let i=pT(e,r===`cost`?`costUSD`:`tokens`),a=lT(n,t).map(e=>({day:e,label:mT(e,t),value:i.get(e)??0,isToday:e===n})),o=a.reduce((e,t)=>e+t.value,0),s=lT(fT(n,-t),t),c=s.reduce((e,t)=>e+(i.get(t)??0),0);return{metric:r,total:o,deltaPct:s.some(e=>i.has(e))&&c>0?(o-c)/c*100:null,average:a.length>0?o/a.length:0,peak:a.reduce((e,t)=>Math.max(e,t.value),0),bars:a}}function gT(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 _T(e){return`${KS(e.average,e.metric)} a day on average`}function vT(e){return tw(e)?ew(e).map(e=>`${e.label} ${xS(e.costUSD)}`).join(`, `):``}function yT(e){return tw(e)?ew(e).map(t=>({...t,sharePct:YS(t.tokens,e?.tokens)})):[]}function bT(e){let t=e?.totals,n=[{label:`Processed tokens`,value:SS(S(t?.tokens,0))},{label:`Cached input`,value:SS(S(t?.cacheRead,0))},{label:`Uncached input`,value:SS(S(t?.input,0))},{label:`Output`,value:SS(S(t?.output,0))}],r=S(xC(e?.savings)?.savedUSD,0);return r>0&&n.push({label:`Cache savings`,value:xS(r)}),n}function xT(e){let t=(e?.yourDay?.insights??[]).map(e=>({text:e.text,tone:`ok`})),n=e?.anomaly;YC(n)&&t.push({text:JC(n),tone:`warn`});for(let n of[SC(e?.savings),yC(e)])n&&t.push({text:n,tone:`ok`});return t}function ST(e,t,n,r){let i=qS(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:YS(e[i],t?.[i]),barPct:YS(e[i],a)??0}))}function CT(e,t){return ST(kw(e?.models,rT(e?.totals,t)),e?.totals,t,gw)}function wT(e,t){return ST(Ew(e?.sessions,rT(e?.totals,t)),e?.totals,t,hw)}function TT(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 ET=2e4,DT=`glimmervoid-usage-metric`,OT=null,kT=null,AT={claude:null,codex:null,kimi:null},jT=null,MT=null,NT=null,PT=_S,FT=GS(qn(DT,null)),IT=!1,LT=null,RT=null,zT=!0,BT=()=>!1,VT=new Set,HT=Tt({getAck:Nr,setAck:rr,signature:()=>kS(OT,AT.claude),isLooking:()=>BT()});function UT(e){for(let t of VT)t(e)}function WT(){jT?.(HT.refresh())}function GT(e){IT=e,UT(`refresh-status`),LT&&=(clearTimeout(LT),null),e&&(LT=setTimeout(()=>{LT=null,IT=!1,RT=`Usage did not answer within ${Math.round(ET/1e3)} s. Refresh to try again.`,UT(`refresh-status`)},ET))}function KT(e){let t=gS.find(t=>t.value===e);return t?t.days:null}function qT(){return{report:OT,sessions:kT,planLimitsByVendor:AT,rangeValue:PT,metric:FT}}function JT(){let e=!zT||!IT&&RT!==null;return zT?IT?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:RT??``,isPending:!1,hasFailure:e}:{text:OT?`${Ee} The figures below are from before the connection dropped.`:Ee,isPending:IT,hasFailure:e}}function YT(e){VT.add(e)}function XT(e){BT=e,WT()}function ZT(){HT.acknowledge(),WT()}function QT(e){jT=e,WT()}function $T(e){MT?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function eE(e){MT=e}function tE(e){PT=e}function nE(e){FT=e,Kn(DT,e)}function rE({force:e=!1}={}){if(!MT)return;NT=h(`usage`);let t={type:`request-usage-report`,requestId:NT};e&&(t.force=!0);let n=KT(PT);n!==null&&(t.days=n),RT=null,GT(!0),!MT(t)&&(RT=Ee,GT(!1))}function iE(e){zT=e,UT(`refresh-status`)}function aE(e){kT=e,UT(`sessions`)}function oE(e){let t=e;AT={...AT,[OS(t)]:t},UT(`plan-limits`),WT()}function sE(e){FS(e,NT)&&(RT=null,GT(!1),OT=e,UT(`report`),WT())}function cE(){let e=OT?.pricing||(kT?{source:kT.pricingSource}:null),t=jS(e?.fetchedAt),n=[AS(e,t!==null&&t>0?fS(t):``)],r=PS(OT);r&&n.push(r);let i=NS(OT?.scan);return i&&n.push(i),n}var lE=26,uE=97;function dE(e){return Object.values(e.elements).filter(e=>e.kind===`unit`)}function fE(e){let t=String.fromCharCode(uE+e%lE),n=Math.floor(e/lE);return n===0?t:`${t}${n+1}`}function pE(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 mE(e){let t=dE(e),n=pE(t),r=new Map;for(let e of t){let t=n.get(e.id)??1;r.set(t,[...r.get(t)??[],e])}let i=new Map,a=[];for(let e of[...r.keys()].sort((e,t)=>e-t)){let t=(r.get(e)??[]).sort((e,t)=>e.title.localeCompare(t.title)||e.id.localeCompare(t.id));for(let[n,r]of t.entries())i.set(r.id,t.length===1?String(e):`${e}${fE(n)}`),a.push(r)}return a.map(e=>({unitId:e.id,title:e.title,status:e.status,level:n.get(e.id)??1,label:i.get(e.id)??``,afterLabels:e.after.flatMap(e=>i.get(e)??[]),linkedBoardId:e.linkedBoardId}))}function hE(e){let t=new Map(dE(e).map(e=>[e.id,e])),n=new Set,r=[];function i(e){let a=r.indexOf(e);if(a!==-1)return[...r.slice(a),e];if(n.has(e))return null;r.push(e);for(let n of t.get(e)?.after??[]){let e=i(n);if(e)return e}return r.pop(),n.add(e),null}for(let e of t.keys()){let t=i(e);if(t)return t}return null}var gE=14,_E=30,vE=40,yE=120,bE=300,xE=400,SE=4e4,CE=2e4,wE=4e5,TE=6,EE=12,DE=3e3,OE=14,kE=8,AE=100,jE=6.6,ME=5,NE=10,PE=2,FE=[.5,.35,.65,.2,.8],IE=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}],LE={right:0,left:1,bottom:2,top:3},RE={left:0,right:1,top:2,bottom:3},zE=[1,0,3,2];function BE(e){return e===`left`||e===`right`}function VE(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function HE(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function UE(e){if(e.length===0)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}}function WE(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 GE(e){return e.from.y===e.to.y}function KE(e,t){let n=t.x+t.width,r=t.y+t.height;if(GE(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 qE(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 JE(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 YE(e){return e.slice(1).flatMap((t,n)=>{let r=e[n];return r?[{from:r,to:t}]:[]})}function XE(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function ZE(e){if(e.length<=_t.layoutWarnings)return[...e];let t=e.slice(0,_t.layoutWarnings-1);return[...t,`and ${e.length-t.length} more`]}function QE(e,t){return t.x>=e.x+e.width||t.x+t.width<=e.x}function $E(e,t,n){if(e.id===t.id)return{exitSide:`right`,entrySide:`top`};if(n)return{exitSide:`bottom`,entrySide:`bottom`};let r=VE(e),i=VE(t);return QE(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 eD=[`right`,`left`,`bottom`,`top`];function tD(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,...eD.filter(e=>e!==t.exitSide)],o=n.toSide?[n.toSide]:[t.entrySide,...eD.filter(e=>e!==t.entrySide)];return a.flatMap(e=>o.map(t=>({exitSide:e,entrySide:t})))}function nD(e,t){let n=e.outputPort??lD(e.from,t.exitSide,1)[0]??VE(e.from),r=lD(e.to,t.entrySide,1)[0]??VE(e.to);if(!mD(t.exitSide,t.entrySide))return{...e,...t,start:n,end:r};let i=hD(r,t.entrySide,e.to,n),a=i===r&&!e.outputPort?hD(n,t.exitSide,e.from,r):n;return{...e,...t,start:a,end:i}}function rD(e,t){return e.turnsAndCrossings<t.turnsAndCrossings||e.turnsAndCrossings===t.turnsAndCrossings&&e.cost<t.cost}function iD(e,t,n){let r=OD(e,t,{usageByEdge:new Map,usageByNodeAndAxis:new Map},null,n,{remainingExpansions:DE}),i=r?.at(-1),a=i===void 0?1/0:n.bestCost[i]??1/0;if(ED(n),!r||a===1/0)return null;let o=JE(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:YE(o),bends:Math.max(o.length-2,0),cost:a}}function aD(e,t){let n=t.filter(t=>t.segments.some(t=>e.segments.some(e=>qD(e,t)))).length;return{turnsAndCrossings:e.bends+n,cost:e.cost}}function oD(e,t,n){let r=new Map(e.map(e=>[e,tD(e,t.get(e)??{exitSide:e.exitSide,entrySide:e.entrySide})]));if(![...r.values()].some(e=>e.length>1))return;let i=yD([...r].flatMap(([e,t])=>t.map(t=>nD(e,t))),[...n.boxesById.values(),...n.panels],n.softObstacles,n.contentTop);if(!i)return;let a=TD(i),o=new Map(e.flatMap(e=>{let[t]=r.get(e)??[],n=t?iD(i,nD(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:aD(n,r)};for(let n of t.slice(1)){let t=iD(i,nD(e,n),a),o=t?aD(t,r):null;o&&rD(o,s.score)&&(s={pair:n,score:o})}s.pair&&(e.exitSide=s.pair.exitSide,e.entrySide=s.pair.entrySide)}}function sD(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 cD(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=$E(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??VE(r),end:VE(i)};return t.set(c,a),[c]});oD(n,t,e),sD(n,t);for(let e of n){let t=e.wire.fromOutput;e.exitKey=e.outputPort&&t?`${e.from.id}|output ${t}|${e.styleKey}`:`${e.from.id}|${e.exitSide}|${e.styleKey}`}let r=e=>`${e.to.id}|${e.entrySide}|${e.styleKey}`,i=new Map;for(let e of n)i.set(r(e),(i.get(r(e))??0)+1);for(let e of n)(i.get(r(e))??0)>1&&(e.busKey=r(e));return n}function lD(e,t,n){let r=Array.from({length:n},(e,t)=>t);if(BE(t)){let i=Math.round(t===`left`?e.x:e.x+e.width),a=Math.min(OE,(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+kE,Math.min(o,e.y+e.height-kE-(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)*OE/2;return r.map(e=>({x:Math.round(a+e*OE),y:i}))}function uD(e,t){let n=BE(t)?e.height:e.width;return Math.max(1,Math.floor((n-16)/OE)+1)}function dD(e){return WE(e.flatMap(e=>[...e.outputPort?[]:[{box:e.from,side:e.exitSide,groupKey:`exit|${e.styleKey}`,wireId:e.wire.id,farPoint:VE(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??VE(e.from),assign:t=>{e.end=t}}]),e=>`${e.box.id}|${e.side}`)}function fD(e){return new Map([...e.entries()].map(([e,t])=>[e,[...WE(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+(BE(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 pD(e,t){for(let[n,r]of e){let e=r[0],i=t.get(n)??[];if(!e)continue;let a=lD(e.box,e.side,i.length);for(let e of r){let t=a[i.indexOf(e.groupKey)];t&&e.assign(t)}}}function mD(e,t){return e===`right`&&t===`left`||e===`left`&&t===`right`||e===`bottom`&&t===`top`||e===`top`&&t===`bottom`}function hD(e,t,n,r){return BE(t)?r.y>=n.y+kE&&r.y<=n.y+n.height-kE?{x:e.x,y:r.y}:e:r.x>=n.x+kE&&r.x<=n.x+n.width-kE?{x:r.x,y:e.y}:e}function gD(e,t){let n=(e,n)=>(t.get(`${e.id}|${n}`)?.length??0)===1,r=new Map([...WE(e,e=>e.exitKey)].map(([e,t])=>[e,t.length]));for(let t of e){if(t.from.id===t.to.id||!mD(t.exitSide,t.entrySide))continue;let e=t.busKey===null&&n(t.to,t.entrySide)?hD(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=hD(t.start,t.exitSide,t.from,t.end)):t.end=e}}function _D(e,t){return[...e.entries()].flatMap(([e,n])=>{let r=n[0],i=t.get(e)?.length??0;return!r||i<=uD(r.box,r.side)?[]:[`box ${r.box.id} has ${i} wires on its ${r.side} side, more than fit`]})}function vD(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 yD(e,t,n,r){let i=[...t,...n],a=UE([...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-gE,e.x+e.width+gE]),a.x-42,a.x+a.width+42].map(Math.round),u=[...i.flatMap(e=>[e.y-gE,e.y+e.height+gE]),a.y-42,a.y+a.height+42].map(Math.round).filter(e=>e>=c),d=vD([...new Set([...l,...o])].sort((e,t)=>e-t)),f=vD([...new Set([...u,...s])].sort((e,t)=>e-t));if(d.length*f.length>SE)return null;let p=t.map(e=>HE(e,1)),m=(e,t)=>{let n=new Uint8Array(d.length*f.length);for(let[r,i]of f.entries())for(let[a,o]of d.entries()){let s=d[a+1],c=f[r+1],l=e===0?s===void 0?null:{from:{x:o,y:i},to:{x:s,y:i}}:c===void 0?null:{from:{x:o,y:i},to:{x:o,y:c}};l&&t.some(e=>KE(l,e))&&(n[r*d.length+a]=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 bD(){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 xD(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 SD(e,t){return`${e}\n${t}`}function CD(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(SD(t.busKey,t.exitKey))??0;return n+r-i}function wD(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?CD(a,t):0,c=s>0,l=a!==void 0&&a.total>s,u=o!==void 0&&o.total>CD(o,t);return(c?-i*.5:0)+(l?yE:0)+(u?vE:0)}function TD(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 ED(e){for(let t of e.touchedStates)e.bestCost[t]=1/0,e.cameFrom[t]=-1;e.touchedStates.length=0}function DD(e,t,n,r,i,a){let o=OD(e,t,n,r,i,a);return ED(i),o}function OD(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=LE[t.exitSide],m=RE[t.entrySide],{bestCost:h,cameFrom:g,touchedStates:ee}=i,_=bD(),v=d*4+p,te=(n,r)=>Math.abs((e.xs[n]??0)-t.end.x)+Math.abs((e.ys[r]??0)-t.end.y);h[v]=0,ee.push(v),_.push(v,te(s,c));for(let i=0;i<CE&&a.remainingExpansions>0;i+=1){--a.remainingExpansions;let i=_.pop();if(i===void 0)return null;let s=i>>2,c=i&3;if(s===f&&c===m)return kD(g,i);let l=s%o,u=(s-l)/o,v=h[i]??1/0;for(let[a,ne]of IE.entries()){if(s===d&&a!==p||a===zE[c])continue;let y=l+ne.x,b=u+ne.y;if(y<0||b<0||y>=o||b>=e.ys.length)continue;let re=b*o+y;if(re===f&&a!==m)continue;let ie=xD(e,l,u,a);if(s!==d&&re!==f&&e.isBlocked[ie.axis]?.[ie.index]===1)continue;let ae={x:e.xs[l]??0,y:e.ys[u]??0},oe={x:e.xs[y]??0,y:e.ys[b]??0},x=Math.abs(oe.x-ae.x)+Math.abs(oe.y-ae.y),se=r!==null&&KE({from:ae,to:oe},r),ce=x+(a===c?0:_E)+(e.isSoft[ie.axis]?.[ie.index]===1?bE:0)+(se?xE:0)+wD(n,t,ie,re,x),le=re*4+a,ue=v+Math.max(ce,1);ue>=(h[le]??1/0)||(h[le]=ue,g[le]=i,ee.push(le),_.push(le,ue+te(y,b)))}}return null}function kD(e,t){let n=[];for(let r=t;r!==-1;r=e[r]??-1)n.push(r);return n.reverse()}function AD(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,SD(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=xD(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 jD(e,t){let n=IE[LE[t]]??{x:0,y:0};return{x:e.x+n.x*gE,y:e.y+n.y*gE}}function MD(e){let t=jD(e.start,e.exitSide),n=jD(e.end,e.entrySide);return JE([e.start,t,{x:n.x,y:t.y},n,e.end])}function ND(e,t){if(!e.wire.back)return null;let n=UE([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 PD(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?JE(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}})):MD(t);return{plan:t,points:r,segments:YE(r),states:n}}function ID(e,t,n){let r=yD(e,[...t.boxesById.values(),...t.panels],t.softObstacles,t.contentTop),i=r?TD(r):null,a={usageByEdge:new Map,usageByNodeAndAxis:new Map},o=new Map;for(let s of PD(e,e=>e)){let e=r&&i?DD(r,s,a,ND(s,t.loopFrames),i,n):null;r&&e&&AD(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 LD(e){return Math.max(0,e.points.length-2)}function RD(e,t,n){let r=t.filter(t=>XD(e,t)!==null).length;return QD([e],n).length*AE+r}function zD(e,t){let{grid:n,usage:r}=e;if(!n)return e.drawn;let i=TD(n),a={remainingExpansions:wE},o=new Map(e.drawn.map(e=>[e.plan.wire.id,e]));for(let s of PD(e.drawn,e=>e.plan)){if(!s.states||a.remainingExpansions<=0)continue;let e=[...o.values()].filter(e=>e.plan!==s.plan),c=RD(s,e,t);if(c===0)continue;AD(n,r,s.plan,s.states,-1);let l=FD(n,s.plan,DD(n,s.plan,r,ND(s.plan,t.loopFrames),i,a)),u=LD(l)<=Math.max(LD(s),TE),d=l.states&&u&&RD(l,e,t)<c?l:s;AD(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 BD(e){return Math.ceil(e.length*jE)}function VD(e,t){return{x:e.x-t/2,y:e.y-NE,width:t,height:13}}function HD(e){return Math.abs(e.from.x-e.to.x)+Math.abs(e.from.y-e.to.y)}function UD(e,t){if(!GE(e))return[];let n=e.from.y;return[Math.min(e.from.x,e.to.x)+ME+t/2,Math.max(e.from.x,e.to.x)-ME-t/2].flatMap(e=>[{x:e,y:n-ME},{x:e,y:n+ME+NE}])}function WD(e,t){let n=[...e].sort((e,t)=>HD(t)-HD(e));return[...e.slice(0,1),...n].flatMap(e=>[...FE.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 GE(e)?[{x:r,y:i-ME},{x:r,y:i+ME+NE}]:[{x:r+ME+t/2,y:i+NE/2},{x:r-ME-t/2,y:i+NE/2}]}),...UD(e,t)])}function GD(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=BD(e),c=WD(o.segments,s),l=c.find(e=>{let n=VD(e,s);if(n.y<t.contentTop)return!1;let o=HE(n,PE);return i.some(e=>KE(e,o))||a.some(e=>qE(n,e))?!1:![...r.values()].some(e=>qE(n,e.bounds))}),u=l??c[0]??VE(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 KD(e,t,n){return e>Math.min(t,n)+.5&&e<Math.max(t,n)-.5}function qD(e,t){if(GE(e)===GE(t))return!1;let n=GE(e)?e:t,r=n===e?t:e;return KD(r.from.x,n.from.x,n.to.x)&&KD(n.from.y,r.from.y,r.to.y)}function JD(e,t){if(GE(e)!==GE(t))return!1;let n=GE(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 YD(e,t){return e.plan.busKey!==null&&e.plan.busKey===t.plan.busKey||e.plan.exitKey===t.plan.exitKey}function XD(e,t){if(YD(e,t))return null;let n=e.segments.flatMap(e=>t.segments.map(t=>[e,t]));return n.some(([e,t])=>qD(e,t))?`wire ${e.plan.wire.id} crosses wire ${t.plan.wire.id}`:n.some(([e,t])=>JD(e,t))?`wire ${e.plan.wire.id} overlaps wire ${t.plan.wire.id}`:null}function ZD(e){return e.flatMap((t,n)=>e.slice(n+1).flatMap(e=>XD(t,e)??[]))}function QD(e,t){let n=[...t.boxesById.values(),...t.panels];return e.flatMap(e=>n.flatMap(t=>{if(t.id===e.plan.from.id||t.id===e.plan.to.id)return[];let n=HE(t,-2);return e.segments.some(e=>KE(e,n))?[`wire ${e.plan.wire.id} runs through ${t.kind} ${t.id}`]:[]}))}function $D(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=LD(e);return t>TE?[`wire ${e.plan.wire.id} bends ${t} times`]:[]})}function eO(e,t){return GE(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 tO(e,t){if(!t||t===e)return null;let n=e.points.find(e=>t.segments.some(t=>eO(e,t)));return!n||n.x===e.plan.end.x&&n.y===e.plan.end.y?null:n}function nO(e,t){let n=e[t],r=e[t+1];n!==void 0&&r!==void 0&&(e[t]=r,e[t+1]=n)}function rO(e,t,n,r,i){pD(n,r),gD(e,r);let a=ID(e,t,i);return{routed:a,crossingCost:QD(a.drawn,t).length*AE+ZD(a.drawn).length}}function iO(e,t,n,r,i){let a=rO(e,t,n,r,i);if(e.length>EE)return zD(a.routed,t);for(let o of r.values())for(let s=0;a.crossingCost>0&&s+1<o.length;s+=1){nO(o,s);let c=rO(e,t,n,r,i);c.crossingCost<a.crossingCost?a=c:nO(o,s)}return zD(rO(e,t,n,r,i).routed,t)}function aO(e){let t=cD(e),n=dD(t),r=fD(n),i={remainingExpansions:wE},a=iO(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=GD(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:XE(n),start:t.start,end:t.end,label:t.wire.label,labelAt:c.get(t.wire.id)?.at??VE(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:tO(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,...QD(a,e),...ZD(a),...$D(a),..._D(n,r),...s],extent:UE([...f,...d])}}var L=40,oO=44,sO=220,cO=90,lO=30,uO=12,dO=20,fO=18,pO=28,mO=12,hO=2,gO=20,_O=26,vO=18,yO=26,bO=170,xO=21,SO=17,CO=10,wO=22,TO=24,EO=16,DO=16,OO=26,kO=24,AO=8,jO=10,MO=14,NO=4,PO=40,FO=26,IO=24,LO=8,RO=320,zO=Object.freeze({blue:`#60a5fa`,green:`#4ade80`,orange:`#fb923c`,pink:`#f472b6`,cyan:`#22d3ee`,yellow:`#facc15`});function BO(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 VO(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>mO){let t=BO(e.text,n-r-hO).map(e=>a(e,1,hO,null));return[a(``,0,0,i),...t]}let o=e.style===`item`?hO:i?i.length+1:0;return BO(e.text,n-r-o-+(e.style===`code`)).map((e,t)=>a(e,t,o,i))}function HO(e,t=_O){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,VO(e,n,t)))}function UO(e,t){let n=e.lanes.find(e=>e.id===t.lane);return n?{label:n.label||n.id,hex:zO[n.color]}:null}function WO(e){return e.column!==null&&e.at===null&&e.near===null}function GO(e){return e.width??sO}function KO(e,t){return Math.floor(e*(t-24)/196)}function qO(e){if(!e.media)return null;let t=GO(e),n=t-24,r=Math.round(RO*t/sO);return{width:n,height:Math.min(r,Math.max(1,Math.round(n*e.media.height/e.media.width)))}}function JO(e,t,n,r){return!e.media||!r?null:{kind:e.media.kind,asset:e.media.asset,mime:e.media.mime,hasPreview:e.media.hasPreview,alt:e.media.alt,x:t.x+uO,y:t.y+n,width:r.width,height:r.height}}function YO(e,t){let n=GO(t),r=KO(gO,n),i=BO(t.title,r),a=t.change===`relabeled`&&t.was?BO(t.was,r):[],o=HO(t.lines,KO(_O,n)),s=UO(e,t),c=s!==null&&!WO(t),l=uO+(a.length+i.length)*dO+o.length*fO,u=qO(t),d=u?u.height+LO:0,f=l+uO+d+(c?26:0),p=t.shape===`decision`?t.outputs:[];return{titleLines:i,wasLines:a,bodyLines:o,lane:s,showsLanePill:c,headerHeight:f,outputs:p,mediaTop:l+LO,mediaSize:u,height:f+p.length*pO}}function R(e,t){return Object.values(e.elements).filter(e=>e.kind===t)}function XO(e){let t=BO(e.text,xO);return{lines:t,height:24+(t.length+1)*SO}}function ZO(e){let t=new Map;for(let n of R(e,`note`)){let e=t.get(n.on),r=XO(n).height;t.set(n.on,e===void 0?r:e+CO+r)}return t}function QO(e){return e.columns.map(e=>e.title?BO(e.title,TO):[])}function $O(e){return(Math.max(1,...e.map(e=>e.length))-1)*EO}function ek(e,t){let n=R(e,`box`).filter(WO),r=new Set(n.filter(e=>t.has(e.id)).map(e=>e.column)),i=new Set(R(e,`frame`).flatMap(e=>e.contains)),a=new Set(n.filter(e=>i.has(e.id)).map(e=>e.column)),o=e=>jO+(e!==void 0&&a.has(e)?vO: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(cO,186):cO}})}function tk(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)*MO:0,s=a>0?e.left+e.right+a+20:0;return Math.max(e.minimumWidth,o,s)})}function nk(e){let t=new Map(e.columns.map((e,t)=>[e.id,t])),n=e.columns.map(()=>sO);for(let r of R(e,`box`).filter(WO)){let e=t.get(r.column)??0;n[e]=Math.max(n[e]??sO,GO(r))}return n}function rk(e,t){let n=[],r=L;for(let[i,a]of e.entries())n.push(r),r+=a+(t[i]??cO);return n}function ik(e,t){return(e.at(-1)??L)+(t.at(-1)??sO)}function ak(e){let t=new Map;for(let n of R(e,`frame`))for(let e of n.contains)t.has(e)||t.set(e,n.id);return t}function ok(e,t){return e===t?0:(e?vO:0)+(t?44:0)}function sk(e,t){return e.lanes.some(e=>e.id===t.lane)?t.lane??``:``}function ck(e,t){let n=new Set(t.map(t=>sk(e,t)));return[``,...e.lanes.map(e=>e.id)].filter(e=>n.has(e))}function lk(e,t,n){let r=YO(e,t),i=GO(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:JO(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*pO+pO/2}}))}}function uk(e,t,n,r,i,a){let o=ak(e),s=R(e,`box`).filter(WO).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=ck(e,s),l=c.some(e=>e!==``),u=ik(t,n),d=[],f=r;for(let n of c){let r=e.lanes.find(e=>e.id===n),c=f+(l?FO:0),p=new Map,m=new Map;for(let r of s){if(sk(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)+ok(m.get(r.column)??null,l),d=lk(e,r,{x:t[s]??L,y:u}),f=(i.get(r.id)??0)-AO;p.set(r.column,u+Math.max(d.height,f)+lO),m.set(r.column,l),a.set(r.id,d)}let h=Math.max(c,...p.values())-lO;l&&d.push({id:n,label:r?r.label||r.id:``,hex:r?zO[r.color]:``,x:L,y:f,width:u-L,height:h-f}),f=h+IO+lO}return d}function dk(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 fk(e,t){let n=[...e.values()].map(e=>e.x+e.width);return{x:n.length>0?Math.max(...n)+cO:L,y:t}}function pk(e,t,n,r){let i=R(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:GO(i),height:YO(e,i).height},f=u?dk(u,i.near,d):fk(n,t),p=lk(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 mk(e,t,n,r,i){let a=ik(n,r),o=Math.max(a,...t.map(e=>e.x+e.width))+cO,s=R(e,`panel`).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id)),c=i;return s.map(e=>{let t=BO(e.title,gO),n=HO(e.lines),r=24+t.length*dO+n.length*fO,i={kind:`panel`,id:e.id,x:Math.round(o),y:c,width:sO,height:r,titleLines:t,bodyLines:n};return c+=r+lO,i})}function hk(e,t,n,r,i){let a=new Map,o=[],s=uk(e,t,n,r,i,a);for(let t of R(e,`box`))t.at&&a.set(t.id,lk(e,t,t.at));pk(e,r,a,o);for(let t of R(e,`box`))a.has(t.id)||a.set(t.id,lk(e,t,fk(a,r)));return{boxesById:a,bands:s,warnings:o}}function gk(e,t){return R(e,`frame`).flatMap(e=>{let n=UE(e.contains.flatMap(e=>t.get(e)??[]));return n?[{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,x:n.x-vO,y:n.y-vO-yO,width:n.width+36,height:n.height+36+yO}]:[]})}function _k(e){return e.resolvedBy?`resolved by ${e.resolvedBy}`:e.author?`from ${e.author}`:``}function vk(e,t){let n=new Map;return R(e,`note`).flatMap(e=>{let r=t.get(e.on);if(!r)return[];let{lines:i,height:a}=XO(e),o=n.get(e.on)??r.y-AO;return n.set(e.on,o+a+CO),[{kind:`note`,id:e.id,x:r.x+r.width-kO,y:o,width:bO,height:a,lines:i,byline:_k(e),isResolved:e.resolvedBy!==null}]})}function yk(e,t,n,r){let i=UE([...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-L),y:Math.min(0,i.y-L),width:i.width+80,height:i.height+80}:{x:0,y:0,width:n+L,height:80}}function bk(e,t){return e.slice(0,-1).map((n,r)=>{let i=n+(t[r]??sO);return{left:i,right:e[r+1]??i}})}function xk(e,t,n){let r=e.segments.filter(e=>e.from.x===e.to.x).map(e=>e.from.x);return bk(t,n).map(e=>new Set(r.filter(t=>t>e.left&&t<e.right)).size)}function Sk(e,t,n){return bk(t,n).map(t=>Math.max(0,...e.wires.flatMap(e=>e.label&&e.labelAt.x>t.left&&e.labelAt.x<t.right?[BD(e.label)]:[])))}function Ck(e,t,n,r){let i=[...e.values()],a=[...i,...t],o=a.flatMap((e,t)=>a.slice(t+1).flatMap(t=>qE(e,t)?[`${e.kind} ${e.id} overlaps ${t.kind} ${t.id}`]:[])),s=new Map(R(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:yO};return!s.get(e.id)?.has(t.id)&&qE(t,n)?[`box ${t.id} covers the title of frame ${e.id}`]:[]}));return[...o,...c]}function wk(e,t){let n=nk(e),r=rk(n,t.gapWidths),{boxesById:i,bands:a,warnings:o}=hk(e,r,n,t.boxesTop,t.stackHeightByBoxId),s=gk(e,i),c=vk(e,i),l=mk(e,[...i.values(),...c],r,n,t.boxesTop),u=aO({wires:R(e,`wire`),boxesById:i,panels:l,softObstacles:[...c,...s.map(e=>({x:e.x,y:e.y,width:e.width,height:yO}))],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,...Ck(i,l,s,e)],tracksByGap:xk(u,r,n),labelWidthByGap:Sk(u,r,n)}}function Tk(e,t){return Array.from({length:Math.max(e.length,t.length)},(n,r)=>Math.max(e[r]??0,t[r]??0))}function Ek(e,t){let n=[],r=[];for(let i=1;;i+=1){let a=wk(e,{gapWidths:tk(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>=NO||!o&&!s)return a;n=Tk(n,a.tracksByGap),r=Tk(r,a.labelWidthByGap)}}function Dk(e){let t=BO(e.title,gO),n=HO(e.lines),r=+!!e.linkedBoardId;return{titleLines:t,bodyLines:n,height:42+t.length*dO+(n.length+r)*fO}}function Ok(e){let t=new Map,n=new Map;for(let r of mE(e)){let i=e.elements[r.unitId];if(i?.kind!==`unit`)continue;let a=Dk(i),o=n.get(r.level)??70;n.set(r.level,o+a.height+lO),t.set(i.id,{kind:`unit`,id:i.id,x:L+(r.level-1)*310,y:o,width:sO,height:a.height,label:r.label,status:i.status,titleLines:a.titleLines,bodyLines:a.bodyLines,linkedBoardId:i.linkedBoardId})}return t}function kk(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(cO/2);return XE(JE([n,{x:i,y:n.y},{x:i,y:r.y},r]))}function Ak(e,t){return R(e,`unit`).flatMap(e=>{let n=t.get(e.id);return n?e.after.flatMap(e=>{let r=t.get(e);return r?[kk(r,n)]:[]}):[]})}function jk(e){return e.size===0?L:Math.max(...[...e.values()].map(e=>e.y+e.height))+PO}function Mk(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 Nk={plain:null,fail:`failure path`,join:`joins`,lane:null};function Pk(e,t,n){return`${e}|${t}|${n}`}function Fk(e,t,n){let r=[Nk[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var Ik={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function Lk(e){let t=new Set(R(e,`box`).map(e=>e.change));return ht.flatMap(e=>e===`none`||!t.has(e)?[]:[{label:Ik[e],swatch:{kind:`change`,change:e}}])}function Rk(e){return e.size===0?[]:mt.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}}))}function zk(e,t){let n=e.lanes.map(e=>({label:e.label||e.id,swatch:{kind:`lane`,hex:zO[e.color]}})),r=new Map(e.legend.map(e=>[Pk(e.tone,e.dashed||e.back,e.back),e.label])),i=new Set,a=R(e,`wire`).flatMap(e=>{let t=e.dashed||e.back,n=Pk(e.tone,t,e.back),a=r.get(n)??Fk(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,...Lk(e),...Rk(t)]}function Bk(e){let t=Ok(e),n=jk(t),r=n-L,i=Mk(e,r),a=ZO(i),o=QO(i),s=$O(o),c=n+OO+s,l=n+oO+s,u=Ek(i,{reserves:ek(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=yk(p,u.routing.extent,ik(d,f),l),h=m.y+m.height,g=zk(i,t).map((e,t)=>({...e,x:L,y:h+t*wO})),ee=h+g.length*wO+(g.length>0?12:0),_=i.caption?{text:i.caption,x:L,y:ee}:null,v=g.length*wO+(_?30:0)+(g.length>0?12:0);return{columns:i.columns.map((e,t)=>({id:e.id,titleLines:o[t]??[],titleBaselineY:n+DO,ruleY:c,x:d[t]??L,width:f[t]??sO})),bands:u.bands,elements:p,legend:g,caption:_,pinnedOffsetY:r,plan:t.size>0?{titleAt:{x:L,y:56},arrowPaths:Ak(i,t)}:null,bounds:{...m,height:m.height+v},warnings:ZE([...u.placementWarnings,...u.routing.warnings])}}function Vk(e){return JSON.stringify(e)}var Hk=Object.freeze({box:ft,frame:et,wire:qe,note:He,unit:Ge,panel:lt}),Uk=80,z={ok:!0},Wk=Object.freeze({id:`operator`,name:`operator`});function Gk(e){return e.id===Wk.id}function Kk(e,t){return Gk(t)?{...e,author:e.author===``?t.name:e.author}:{...e,author:t.name,resolvedBy:null}}function B(e){return{ok:!1,error:e}}function qk(e,t){return e.elements[t]?.kind===`box`}function Jk(e,t){if(t.kind===`box`)return Zk(e,t);if(t.kind===`unit`)return $k(e,t);if(t.kind===`wire`)return qk(e,t.from)?qk(e,t.to)?Yk(e,t):B(`wire ${t.id} ends at ${t.to}, which is not a box`):B(`wire ${t.id} starts at ${t.from}, which is not a box`);if(t.kind===`note`)return qk(e,t.on)?z:B(`note ${t.id} is on ${t.on}, which is not a box`);if(t.kind!==`frame`)return z;let n=t.contains.find(t=>!qk(e,t));return n?B(`frame ${t.id} contains ${n}, which is not a box`):z}function Yk(e,t){if(t.fromOutput===null)return z;let n=e.elements[t.from];return n?.kind!==`box`||n.shape!==`decision`?B(`wire ${t.id} starts at output ${t.fromOutput}, but ${t.from} is not a decision`):n.outputs.some(e=>e.id===t.fromOutput)?z:B(`wire ${t.id} starts at output ${t.fromOutput}, which decision ${t.from} does not have`)}function Xk(e,t){if(t.shape!==`decision`&&t.outputs.length>0)return B(`box ${t.id} has outputs, which only a decision has, so set shape to decision`);let n=new Set(t.outputs.map(e=>e.id));if(n.size!==t.outputs.length)return B(`box ${t.id} has two outputs with the same id`);let r=Object.values(e.elements).find(e=>e.kind===`wire`&&e.from===t.id&&e.fromOutput!==null&&!n.has(e.fromOutput));return r?.kind===`wire`?B(`wire ${r.id} still starts at output ${r.fromOutput} of ${t.id}, so change or remove that wire first`):z}function Zk(e,t){let n=Xk(e,t);return n.ok?t.change===`relabeled`&&!t.was?B(`box ${t.id} is relabeled, so give its old title in was`):t.column===null&&t.near===null&&t.at===null?B(`box ${t.id} needs a place: a column, near another box, or at a point`):t.column!==null&&!e.columns.some(e=>e.id===t.column)?B(`box ${t.id} names column ${t.column}, which the board does not have, so add it with a columns op first`):t.lane!==null&&!e.lanes.some(e=>e.id===t.lane)?B(`box ${t.id} names lane ${t.lane}, which the board does not have, so add it with a lanes op first`):t.near===null?z:t.near.of===t.id?B(`box ${t.id} cannot sit near itself`):qk(e,t.near.of)?Qk(e,t.near.of,t.id)?B(`box ${t.id} sits near ${t.near.of}, which already sits near ${t.id}, so they would place each other`):z:B(`box ${t.id} sits near ${t.near.of}, which is not a box`):n}function Qk(e,t,n){let r=new Set,i=t;for(;i!==void 0&&!r.has(i);){if(i===n)return!0;r.add(i);let t=e.elements[i];i=t?.kind===`box`?t.near?.of:void 0}return!1}function $k(e,t){if(t.after.includes(t.id))return B(`unit ${t.id} cannot come after itself`);let n=t.after.find(t=>e.elements[t]?.kind!==`unit`);return n?B(`unit ${t.id} comes after ${n}, which is not a unit on this board`):z}function eA(e,t,n){if(e.elements[t.id])return B(`an element with id ${t.id} already exists`);if(Object.keys(e.elements).length>=_t.elements)return B(`a board holds at most ${_t.elements} elements`);if(t.kind===`unit`&&dE(e).length>=_t.units)return B(`a board holds at most ${_t.units} units`);let r=t.kind===`note`?Kk(t,n):t,i=Jk(e,r);return i.ok?(e.elements[t.id]=r,z):i}function tA(e,t,n){return e.kind!==`note`||!(`text`in t||`on`in t)?{}:{author:n.name,resolvedBy:null}}function nA(e,t,n,r){let i=e.elements[t];if(!i)return B(`no element has id ${t}`);if(`kind`in n||`id`in n)return B(`set cannot change an element kind or id; remove it and add a new one`);if(!Gk(r)&&(`author`in n||`resolvedBy`in n))return B(`set cannot change who wrote or resolved a note; resolve it with a resolve op`);let a=Hk[i.kind].safeParse({...i,...tA(i,n,r),...n});if(!a.success)return B(`${t}: ${a.error.issues[0]?.message??`invalid fields`}`);let o=Jk(e,a.data);return o.ok?(e.elements[t]=a.data,z):o}function rA(e,t){let n=e.elements[t];if(!n)return B(`no element has id ${t}`);if(n.kind===`box`&&iA(e,t),delete e.elements[t],n.kind===`unit`){for(let n of dE(e))n.after.includes(t)&&(e.elements[n.id]={...n,after:n.after.filter(e=>e!==t)});return z}if(n.kind!==`box`)return z;for(let n of Object.values(e.elements))aA(e,n,t);return z}function iA(e,t){let n=Object.values(e.elements).flatMap(e=>e.kind===`box`&&e.near?.of===t?[e]:[]);if(n.length===0)return;let r=Bk(e);for(let t of n){let n=r.elements.find(e=>e.id===t.id);n&&n.kind===`box`&&(e.elements[t.id]={...t,near:null,at:{x:n.x,y:n.y-r.pinnedOffsetY}})}}function aA(e,t,n){if(t.kind===`wire`&&(t.from===n||t.to===n)||t.kind===`note`&&t.on===n){delete e.elements[t.id];return}if(t.kind!==`frame`)return;let r=t.contains.filter(e=>e!==n);r.length===0?delete e.elements[t.id]:e.elements[t.id]={...t,contains:r}}function oA(e,t,n){let r=e.elements[t];return r?.kind===`note`?(e.elements[t]={...r,resolvedBy:n.name},z):B(`no note has id ${t}`)}function sA(e,t,n){let r=new Set(t.map(e=>e.id));if(r.size!==t.length)return B(`column ids must be unique`);let i=Object.entries(n).find(([,e])=>!r.has(e));if(i)return B(`move sends column ${i[0]} to ${i[1]}, which is not in the new columns`);let a=Object.values(e.elements).flatMap(e=>e.kind!==`box`||e.column===null?[]:[{...e,column:Object.hasOwn(n,e.column)?n[e.column]??e.column:e.column}]),o=a.find(e=>e.column!==null&&!r.has(e.column));if(o)return B(`box ${o.id} is still in removed column ${o.column}, so name it in move or remove the box first`);for(let t of a)e.elements[t.id]=t;return e.columns=t,z}function cA(e,t){let n=new Set(t.map(e=>e.id));if(n.size!==t.length)return B(`lane ids must be unique`);e.lanes=t;for(let t of Object.values(e.elements))t.kind===`box`&&t.lane!==null&&!n.has(t.lane)&&(e.elements[t.id]={...t,lane:null});return z}function lA(e,t,n){switch(t.op){case`add`:return eA(e,t.element,n);case`set`:return nA(e,t.id,t.fields,n);case`remove`:return rA(e,t.id);case`resolve`:return oA(e,t.id,n);case`columns`:return sA(e,t.columns,t.move);case`lanes`:return cA(e,t.lanes);case`board`:return t.title!==void 0&&(e.title=t.title),t.caption!==void 0&&(e.caption=t.caption),t.legend!==void 0&&(e.legend=t.legend),t.codeSessionId!==void 0&&(e.codeSessionId=t.codeSessionId),z}}function uA(e,t,n,r){let i=structuredClone(e),a=e.version+1,o=[];for(let[e,r]of t.entries()){let t=dA(r),s=t===null?void 0:i.elements[t],c=lA(i,r,n);if(!c.ok)return{ok:!1,error:`op ${e+1}: ${c.error}`,opIndex:e};o.push({version:a,author:n.id,elementId:t,summary:`${n.name} ${hA(r,s,i)}`})}let s=hE(i);return s?{ok:!1,error:`that makes a dependency cycle: ${s.join(`, `)}`,opIndex:t.length-1}:(i.version=a,i.updatedAt=r,{ok:!0,board:i,changes:o})}function dA(e){return e.op===`add`?e.element.id:e.op===`set`||e.op===`remove`||e.op===`resolve`?e.id:null}function V(e,t,n=e.elements[t]){return n?n.kind===`box`||n.kind===`frame`||n.kind===`unit`||n.kind===`panel`?`"${n.title||t}"`:n.kind===`wire`?`wire ${V(e,n.from)} to ${V(e,n.to)}`:`note ${t}`:t}function fA(e,t,n){return n.length===0?`cleared what ${V(e,t)} comes after`:`set ${V(e,t)} to come after ${n.map(t=>V(e,t)).join(`, `)}`}function pA(e,t,n){let r=Object.keys(e.fields),i=n.elements[e.id];return r.length===1&&r[0]===`at`?`moved ${V(n,e.id)}`:r.length===1&&r[0]===`linkedBoardId`?i?.kind===`unit`&&i.linkedBoardId===null?`unlinked ${V(n,e.id)} from its board`:`linked ${V(n,e.id)} to a board`:r.length===1&&r[0]===`after`&&i?.kind===`unit`?fA(n,i.id,i.after):r.length===1&&r[0]===`status`&&i?.kind===`unit`?`marked ${V(n,e.id)} ${i.status}`:t?.kind===`box`&&i?.kind===`box`&&r.length===1&&r[0]===`title`?`renamed "${t.title}" to "${i.title}"`:`changed ${r.join(`, `)} of ${V(n,e.id)}`}function mA(e){return e.title===void 0?e.caption===void 0?e.codeSessionId===void 0?`set the legend`:e.codeSessionId===null?`cleared the code session`:`set the code session to ${e.codeSessionId}`:`changed the caption`:`renamed the board to "${e.title}"`}function hA(e,t,n){switch(e.op){case`add`:{let t=e.element;return t.kind===`note`?`note on ${V(n,t.on)}${t.ref?` at ${t.ref}`:``}: ${t.text.slice(0,Uk)} (note ${t.id})`:`added ${t.kind} ${V(n,t.id)}`}case`set`:return pA(e,t,n);case`remove`:return`removed ${t?.kind??`element`} ${V(n,e.id,t)}`;case`resolve`:return t?.kind===`note`?`resolved note ${e.id} on ${V(n,t.on)}`:`resolved note ${e.id}`;case`columns`:return`set the columns to ${e.columns.map(e=>e.title||e.id).join(`, `)||`none`}`;case`lanes`:return`set the lanes to ${e.lanes.map(e=>e.label||e.id).join(`, `)||`none`}`;case`board`:return mA(e)}}var gA=new Map,_A=new Map,vA=[],yA=[],bA=[],xA=new Map;function SA(){for(let e of[...vA])e()}function CA(e){for(let t of yA)t(e)}function wA(e){return e.type===`whiteboard-result`}async function TA(e,t){try{let n=await a(e,t,{timeoutMs:In});return wA(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:Fn(e,In)}}}function EA(e){let t=_A.get(e);if(t)return t;let n=TA(`whiteboard-get`,{boardId:e}).then(t=>{_A.delete(e),t.ok&&t.reply.board&&(gA.set(e,t.reply.board),CA(e))});return _A.set(e,n),n}function DA(){return bA}function OA(e){return gA.get(e)??null}function kA(e){return gA.has(e)?Promise.resolve():EA(e)}function AA(e){return vA.push(e),()=>{let t=vA.indexOf(e);t>=0&&vA.splice(t,1)}}function jA(e){yA.push(e)}function MA(){let e=new Map;for(let t of bA)for(let n of t.connectedSessionIds){let r=e.get(n);r?r.push(t):e.set(n,[t])}xA=e}var NA=!1;function PA(){return NA}function FA(e){bA=[...e.boards].sort((e,t)=>t.updatedAt-e.updatedAt),MA();let t=new Map(bA.map(e=>[e.id,e.version]));for(let[e,n]of[...gA]){let r=t.get(e);r!==n.version&&(gA.delete(e),r===void 0?CA(e):EA(e))}SA(),NA=!0}function IA(e){let t=gA.get(e.boardId);if(!t||t.version>=e.toVersion)return;if(t.version!==e.fromVersion){gA.delete(e.boardId),EA(e.boardId);return}let n=uA(t,e.ops,e.author,e.updatedAt);!n.ok||n.board.version!==e.toVersion?(gA.delete(e.boardId),EA(e.boardId)):(gA.set(e.boardId,n.board),CA(e.boardId))}function LA(e){gA.delete(e.boardId),bA=bA.filter(t=>t.id!==e.boardId),MA(),CA(e.boardId),SA()}async function RA(e){let t=await TA(`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 zA(e,t){let n=await TA(`whiteboard-op`,{boardId:e,ops:t});return n.ok?{ok:!0}:n}async function BA(e){let t={"x-glimmervoid-upload-name":encodeURIComponent(e.name)};e.type&&(t[`content-type`]=e.type);let n=await fetch(ot,{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=ct.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 VA(e){let t=await TA(`whiteboard-delete`,{boardId:e});return t.ok?{ok:!0}:t}async function HA(e,t){let n=await TA(`whiteboard-connect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function UA(e,t){let n=await TA(`whiteboard-disconnect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function WA(e,t){let n=await TA(`whiteboard-nudge`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function GA(e){let t=await TA(`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 KA=null;function qA(e){KA=e}function JA(e,t){KA?.(e,t)}function YA(e){return xA.get(e)??[]}var XA=null;function ZA(e,t){XA={boardId:e,sessionId:t}}function QA(){let e=XA;return XA=null,e}var $A=()=>{};function ej(e){$A=e}function tj(e,t){ZA(e,t),$A()}function nj(e,t){let n=e.queuedBySessionId[t]??0;return n===0?``:`${n} queued`}function rj(e,t,n){let r=nj(e,t),i=r?`wait`:`muted`;return{key:`board:${e.id}`,text:n,detailText:e.title,stateText:r,look:{icon:`board`,tone:i},tier:Kt(i),className:`session-pr-chip session-board-chip`,ariaLabel:`Open board ${e.title}`,onActivate:()=>tj(e.id,t)}}function ij(e,t){let n=nj(e,t);return rj(e,t,n?`${e.title}, ${n}`:e.title)}function aj(e){return YA(e).map(t=>rj(t,e,t.title))}function oj(e,t,n){let r=ij(e,t),i=Ve(`session-pr-chip-unlink`);i.append(x(gt)),i.setAttribute(`aria-label`,`Disconnect board ${e.title}`),i.addEventListener(`click`,r=>{r.stopPropagation(),r.preventDefault(),Vt({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:()=>{UA(e.id,t).then(e=>n(e.ok?null:e.error))}})});let a=E(`span`,`session-pr-chip-item`);return a.append(rn(r,r),i),a}function sj(e){let{dialog:t,close:n,actions:r,btnCancel:i}=Ut({title:`Connect board`}),a=E(`div`,`session-pr-chips dialog-linked-prs`),o=E(`p`,`dialog-message`,`A connected session is told what others changed on the board with its next whiteboard get or prompt.`),s=E(`select`,`dialog-input`);s.setAttribute(`aria-label`,`Board to connect`);let c=jn(`action-status`),l=C({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=YA(e);fn(a,t.map(t=>ij(t,e)),n=>{let r=t.find(e=>`board:${e.id}`===n.key);return r?oj(r,e,u):rn(n,n)});let n=DA().filter(t=>!t.connectedSessionIds.includes(e));s.replaceChildren(...n.map(e=>{let t=E(`option`,null,e.title);return t.value=e.id,t})),n.length===0&&s.append(E(`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,HA(t,e).then(e=>{e.ok?n():(c.show(`error`,e.error),d())}))}),i.addEventListener(`click`,n);let f=AA(()=>{t.isConnected?d():f()});d()}AA(sn);function cj(){return j.snapshot().borrowedCardId}var lj=null;function uj(e,t,n,{className:r,onRelease:i}={}){if(!e?.card||!n)return;let a=cj();a&&a!==t&&dj();let o=e.card;o._cardHostClass&&o._cardHostClass!==r&&o.classList.remove(o._cardHostClass),o._cardHostClass=r||``,r&&o.classList.add(r),Rt(o,n),lj=i??null,j.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function dj(){let e=cj(),t=lj;if(lj=null,t?.(),j.dispatch(`borrowCard`,null),!e)return null;let n=O.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,jt(r,Tn)),e}var fj=null,pj=null,mj={},hj=null,gj=null,_j=null,vj=new Map,yj=new Map;function bj(){return pj??=M(()=>import(`./phone-shell-C_5TyptC.js`).then(e=>{e.mountPhoneShell(mj),_j&&e.orderPhonePanels(_j);for(let[t,n]of vj)e.setPhoneScreenAvailable(t,n);for(let[t,n]of yj)e.setPhoneScreenAttention(t,n);return fj=e,e},e=>(pj=null,u(`phone-shell`,`phone shell failed to load: ${d(e)}`),null)),__vite__mapDeps([28,13,5,3,29,12,14,22,15,30,31,25,32,4,6,7,23,33,26,34])),pj}function xj(e){mj=e}async function Sj(e){let t={options:e};hj=t;let n=await bj();if(hj!==t)return!1;if(!n)return hj=null,gj=null,!1;hj=null,n.activatePhoneShell(t.options);let r=gj;return gj=null,r?.(n),!0}function Cj(){hj=null,gj=null,fj?.deactivatePhoneShell()}function wj(){return hj!==null||(fj?.isPhoneShellActive()??!1)}function Tj(){return hj?hj.options?.sessionId??null:fj?.getPhoneSessionId()??null}function Ej(e){_j=e,fj?.orderPhonePanels(e)}function Dj(e,t){vj.set(e,t),fj?.setPhoneScreenAvailable(e,t)}function Oj(e,t){yj.set(e,t),fj?.setPhoneScreenAttention(e,t)}function kj(){fj?.refreshPhoneBoard()}function Aj(){fj?.syncPhoneHistory()}function jj(e){return hj?(gj=t=>{e(t)},!0):fj?e(fj):!1}function Mj(e){return jj(t=>t.showPhonePlan(e))}function Nj(e){return jj(t=>t.showPhoneSession(e))}function Pj(e){return jj(t=>t.showPhoneScreen(e))}function Fj(){let e=Tj();e&&k(e)?._isActiveViewer?.()===!0&&iS(e)}function Ij(){Nu(k(cj())),Fj()}function Lj(){window.addEventListener(`focus`,Ij),window.addEventListener(`blur`,Ij),document.addEventListener(`visibilitychange`,Ij),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Ua()}),window.addEventListener(`pageshow`,e=>{e.persisted&&Ua()})}function Rj(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function zj(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function Bj({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=Rj(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=zj(e.key,a);if(n===null)return;e.preventDefault();let r=u(t.getBoundingClientRect().width+l*n);r!==null&&s(r)})}var Vj={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.`}},Hj=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:kt[e],meaning:t}),Uj=Object.freeze([Hj(w.DORMANT,`Not started yet.`),Hj(w.STARTING,`Setting up the worktree and booting the agent.`),Hj(w.RUNNING,`The agent is mid-turn.`),Hj(w.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),Hj(w.WAITING,`Waiting on a permission prompt or your answer.`),Hj(w.COMPLETE,`Finished a turn you have not looked at yet.`),Hj(w.IDLE,`Ready for the next prompt.`),Hj(w.DONE,`The agent process ended.`),Hj(w.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 Wj(e,t){let n=E(`section`,`status-legend`),r=E(`dl`,`status-legend-rows`);return r.append(...t),n.append(E(`h2`,`status-legend-title`,e),r),n}function Gj(e,t){let n=E(`div`,`status-legend-row`);return n.append(e,E(`dd`,`status-legend-meaning`,t)),n}function Kj(){return Wj(`Status colors`,Uj.map(e=>{let t=E(`dt`,`status-legend-badge`),n=E(`span`,`status-legend-glyph`),r=E(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=Gj(t,e.meaning);return Yt(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function qj(){return Wj(`Pull request icons`,Object.keys(Vj).map(e=>{let t=Vj[e],n=E(`dt`,`status-legend-badge`);return n.append(pi(e),E(`span`,`status-legend-name`,t.label)),Gj(n,t.meaning)}))}var Jj=null,Yj=null,Xj=!1,Zj=null;function Qj(){return Yj??=M(()=>import(`./first-run-checklist-CmgKy8Jx.js`).then(e=>(Jj=e,e),e=>(Yj=null,u(`first-run`,`first-run checklist failed to load: ${d(e)}`),null)),__vite__mapDeps([35,12,13,5,3,15,31,14,22,25,32,4,6,7,23,36,37])),Yj}function $j(e,t){Zj={host:e,isShown:t},Jj?Jj.showFirstRunChecklist(e,t):t&&Xj&&Qj().then(e=>{e&&Zj&&e.showFirstRunChecklist(Zj.host,Zj.isShown)})}function eM(){Jj?.refreshFirstRunChecklist()}function tM(){Xj=!0,Zj&&$j(Zj.host,Zj.isShown)}var nM=`(no path)`;function rM(e){if(!e)return nM;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||`(no path)`}function iM(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=t(e),i=n?String(n):nM,a=r.get(i);a||(a={key:i,label:i===`(no path)`?nM:rM(i),title:i,rows:[]},r.set(i,a)),a.rows.push(e)}let i=[...r.values()];return i.sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0,sensitivity:`base`})||e.key.localeCompare(t.key)),{flat:r.size<=1,order:i.map(e=>e.key),groups:i}}function aM(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 oM(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))}function sM({onAdd:e}){let t=E(`div`,`session-group-header`),n=E(`span`,`session-group-label`),r=E(`span`,`session-group-count`),i=E(`span`,`session-group-rule`);i.setAttribute(`aria-hidden`,`true`);let a=C({variant:`icon`,size:`small`,label:`Add session to this project`,icon:x(Ae),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 cM(e,t){let{header:n,label:r,count:i,addButton:a}=e,o=t.key===nM;oi(n,`path`,t.key),oi(n,`label`,t.label),Br(r,t.label),Br(i,String(t.rows.length)),Wr(a,o)}var lM={waitingCount:0,finishedCount:0,failedCount:0},uM={failed:Bt[w.FAILED],waiting:Bt[w.WAITING],finished:Bt[w.COMPLETE]},dM={failed:`failed`,waiting:`needs you`,finished:`finished`},fM=[`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`],pM=2500,mM=`cubic-bezier(0.16, 1, 0.3, 1)`,hM=`cubic-bezier(0.5, 0, 0.2, 1)`,gM=260,_M=200,vM=200,yM=300,bM=28,xM=360,SM=420,CM=200,wM=3,TM=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),EM=new WeakMap;function DM(e){let t=EM.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function OM(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function kM(){return TM?.matches??!1}function AM(e){return e.map(e=>({easing:mM,...e}))}function jM(e,t){let n=E(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${En.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${En.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${En.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${En.overflowSlot}px`);let r=E(`span`,`attention-banner-chips`),i=E(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=E(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=E(`span`,`attention-banner-status`);o.append(r,E(`span`,`attention-banner-count`),a);let s=Ve(`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),EM.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(()=>NM(n)).observe(r),MM(n,lM,[]),n}function MM(e,t,n){let r=DM(e);r.tiles=n,Br(Pt(e,`.attention-banner-count`),bn(t));let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&YM(e,r),NM(e)}function NM(e){let t=DM(e),n=Pt(e,`.attention-banner-chips`),r=Pt(n,`.attention-tile-overflow`),i=OM(e),a=t.tiles.slice(0,xn(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():LM(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??FM(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),IM(s,i,a===0),(s.parentElement!==n||PM(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;Wr(r,p===0),Br(r,`+${p}`),Rr(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)&&VM(e,null),i){for(let e of d)RM(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?BM(r,a):a!==0&&zM(r,a,n)})}}function PM(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function FM(e,t){let n=E(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=E(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>VM(e,t)),n.addEventListener(`pointerleave`,()=>VM(e,null)),n}function IM(e,{kind:t,name:n},r){e.dataset.kind=t,e.toggleAttribute(`data-head`,r);let i=`${n}, ${dM[t]}`;e.setAttribute(`aria-label`,i),Ln(Pt(e,`.attention-tile-icon`),uM[t])}function LM(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=kM()?[{opacity:1},{opacity:0}]:AM([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:vM,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function RM(e){let t=kM()?[{opacity:0},{opacity:1}]:AM([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:_M})}function zM(e,t,n){kM()||e.animate(AM([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:yM,delay:n*bM,fill:`backwards`})}function BM(e,t){kM()?e.animate([{opacity:.35},{opacity:1}],{duration:xM,easing:mM}):e.animate(AM([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:xM})}function VM(e,t){let n=DM(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 HM(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function UM(e,t,n){let r=DM(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!OM(e)){n();return}VM(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=HM(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(WM(o,s),GM(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function WM(e,t){return!t||kM()?[{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 GM(e){return!e||kM()?{duration:CM,fill:`forwards`}:{duration:SM,easing:hM,fill:`forwards`}}function KM(e){let t=DM(e);e.hasAttribute(`data-empty`)&&JM(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!OM(e))return;let n={duration:gM};if(t.pressAnimations.push(e.animate(AM([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!kM()){t.pressAnimations.push(e.animate(AM([{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(AM([{transform:`none`},{transform:`translateY(${wM}px)`,offset:.3},{transform:`none`}]),n),r.animate(AM([{transform:`none`},{transform:`translateY(-${wM}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function qM(e){let t=fM.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??fM[0]}function JM(e,t){let n=qM(t.lastAllClearLine);t.lastAllClearLine=n,Pt(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>YM(e,t),pM)}function YM(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var XM={terminal:`Terminal`,board:`Board`},ZM=[`terminal`,`board`],QM=.05,$M=`application/x-glimmervoid-pane-tab`;function eN(){let e=kr(),t=new Set([`terminal`]),n=cr(e,t),r=null,i=!1,a=E(`div`,`pane-layout`),o=E(`div`,`pane-trail`),s=E(`div`,`pane-divider`);s.setAttribute(`role`,`separator`),s.setAttribute(`aria-label`,`Resize panes`),s.tabIndex=0;let c={terminal:p(`terminal`),board:p(`board`)},l={terminal:h(`terminal`),board:h(`board`)},u={terminal:m(`terminal`),board:m(`board`)},d=new Map,f=[g(0),g(1)];function p(e){let t=E(`div`,`pane-body`);return t.id=`focus-pane-${e}`,t.dataset.pane=e,t.setAttribute(`role`,`tabpanel`),t}function m(e){let t=E(`div`,`pane-title`);return t.dataset.tab=e,t}function h(e){let t=Ve(`pane-tab`);return t.append(E(`span`,`sr-only`,XM[e])),t.draggable=!0,t.dataset.tab=e,t.setAttribute(`role`,`tab`),t.setAttribute(`aria-controls`,`focus-pane-${e}`),t.addEventListener(`click`,()=>v(e)),t.addEventListener(`dragstart`,t=>{r=e,t.dataTransfer?.setData($M,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`),a.dataset.dragging=``}),t.addEventListener(`dragend`,_),t}function g(t){let i=E(`section`,`pane-group`),a=E(`div`,`pane-strip pane-header`),o=E(`div`,`pane-tabs`);o.setAttribute(`role`,`tablist`),a.append(o);let s=E(`div`,`pane-group-body`);return i.append(a,s),i.addEventListener(`dragover`,e=>{r&&(e.preventDefault(),i.dataset.dropZone=ee(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=ee(i,a,o),c=n.groupIndexes[t],l=r;_(),c!==void 0&&y(wr(e,l,c,s))}),{group:i,strip:a,tabList:o,body:s}}function ee(e,t,n){if(n.target instanceof Node&&t.contains(n.target))return`join`;let r=e.getBoundingClientRect();return fr(n.clientX-r.left,n.clientY-r.top,r)}function _(){r=null,delete a.dataset.dragging;for(let{group:e}of f)delete e.dataset.dropZone}function v(t){i&&t===`terminal`||te(Jn(e,t))}function te(t){i?(i=!1,t===e?oe():y(t)):y(t)}function ne(e){let t=jr(e).findIndex(e=>e.tabs.includes(`terminal`));return Jn(wr(e,`board`,t,`join`),`terminal`)}function y(t){t!==e&&(e=t,tr(e),oe())}function b(e,t){t.parentElement!==e&&e.append(t)}function re(e,t){e.children.length===t.length&&t.every((t,n)=>e.children[n]===t)||e.replaceChildren(...t)}function ie(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 ae(e,t,n){let r=u[t];r.hidden=!n,e.tabList.nextElementSibling!==r&&e.tabList.after(r)}function oe(){n=cr(i?ne(e):e,t);for(let e of ZM)l[e].draggable=!i;for(let e of ZM)u[e].hidden=!0,t.has(e)||(c[e].hidden=!0);let r=yr(n.groups);a.dataset.direction=n.direction??`single`;let p=n.groups.map((e,t)=>({group:e,parts:f[t]}));for(let{group:e,parts:t}of p){if(!t)continue;re(t.tabList,e.tabs.map(e=>l[e]));for(let n of e.tabs){let r=n===e.activeTab;l[n].setAttribute(`aria-selected`,String(r)),l[n].tabIndex=r?0:-1,b(t.body,c[n]),c[n].hidden=!r}let n=d.get(e.activeTab);ie(t,n),ae(t,e.activeTab,n===void 0)}let[m,h]=f;if(!m||!h)return;b((f[r]??m).strip,o);let g=n.groups.length===2?[m.group,s,h.group]:[m.group];re(a,g),m.group.style.flex=`${n.firstShare} 1 0`,h.group.style.flex=`${1-n.firstShare} 1 0`,s.setAttribute(`aria-orientation`,n.direction===`row`?`vertical`:`horizontal`),s.setAttribute(`aria-valuenow`,String(Math.round(n.firstShare*100)))}function x(e){let t=a.getBoundingClientRect();return n.direction===`row`?(e.clientX-t.left)/t.width:(e.clientY-t.top)/t.height}s.addEventListener(`pointerdown`,e=>{e.button===0&&(s.setPointerCapture(e.pointerId),s.dataset.dragging=`true`,e.preventDefault())}),s.addEventListener(`pointermove`,t=>{s.hasPointerCapture(t.pointerId)&&(e=Or(e,x(t)),oe())});let se=t=>{s.hasPointerCapture(t.pointerId)&&(s.releasePointerCapture(t.pointerId),delete s.dataset.dragging,tr(e))};return s.addEventListener(`pointerup`,se),s.addEventListener(`pointercancel`,se),s.addEventListener(`keydown`,t=>{let n={ArrowLeft:-.05,ArrowUp:-.05,ArrowRight:QM,ArrowDown:QM}[t.key];n!==void 0&&e.kind===`split`&&(t.preventDefault(),y(Or(e,e.firstShare+n)))}),oe(),{element:a,trailSlot:o,bodyOf:e=>c[e],titleSlotOf:e=>u[e],setStripHost:(e,t)=>{t&&d.set(e,t),t||d.delete(e),oe()},showTabs:(e,n)=>{t=e,i=n?.holdSplit===!0,oe()},showTab:t=>te(Jn(e,t))}}var tN=5,nN={high:`High`,medium:`Medium`,low:`Low`};function rN(e,t){let n=Ve(`review-look-line`,e.path);return n.append(E(`span`,`review-look-detail`,e.detail)),n.addEventListener(`click`,()=>t(e.openPath)),n}function iN(e,t){let n=E(`div`,`review-look-group`);n.dataset.kind=e.kind;let r=E(`p`,`review-look-text`,e.heading);if(e.conflictRisk){let t=E(`span`,`review-look-risk`,`Conflict risk: ${nN[e.conflictRisk]}`);t.dataset.risk=e.conflictRisk,r.append(` `,t)}n.append(r);for(let r of e.lines)n.append(rN(r,t));return n}function aN(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=E(`section`,`review-look`);if(i.append(E(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=E(`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,tN);if(a.length>0){let e=E(`div`,`review-look-list`);for(let t of a)e.append(iN(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=E(`div`,`review-look-more`),c=C({variant:`quiet`,size:`small`,label:`Show all`,action:`show-all-worth-a-look`,onClick:n});return s.append(E(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function oN(e){return(e??[]).map(e=>E(`span`,`review-file-hint`,e.text))}var sN=`changes`,cN={add:`+`,del:`-`,meta:`\\`},H=null,lN=null,U=null,W=null,uN=null,dN=!1;function fN(){let e=E(`section`,`review-reader`);e.setAttribute(`aria-label`,`Changes`),e.tabIndex=-1,e.hidden=!0;let t=E(`div`,`review-reader-bar`),n=E(`p`,`review-reader-status`);n.setAttribute(`role`,`status`);let r=E(`p`,`review-reader-notice`);r.setAttribute(`role`,`status`);let i=E(`div`,`review-reader-actions`),a=C({variant:`primary`,label:`Merge`,action:`merge-session`,onClick:()=>{U&&mv(U)}}),o=C({variant:`danger`,label:`Discard`,action:`discard-session`,onClick:()=>{U&&hv(U)}}),s=C({variant:`secondary`,label:`Close`,action:`close-reader`,onClick:gg});i.append(a,o,s),t.append(n,r,i);let c=E(`div`,`review-reader-body`),l=E(`div`,`review-reader-files`),u=E(`div`,`review-reader-diff`);return c.append(l,u),e.append(t,c),e.addEventListener(`keydown`,mN),q_(e=>{e===U&&vN()}),Hr(()=>{W=null,dN=!1,vN(),hN()}),vv(e),{root:e,status:n,notice:r,mergeButton:a,discardButton:o,closeButton:s,fileColumn:l,diff:u}}function pN(){return H??=fN(),H}function mN(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Nt(e))return;let t=e.key===`j`?1:e.key===`k`?-1:0;if(t===0||!U)return;e.preventDefault();let n=D_(Q_(U)?.files??[],W,t);n&&gN(n)}function hN(){U&&ug(sN,U)}function gN(e){W=e,vN(),H?.fileColumn.querySelector(`.review-reader-file[aria-current="true"]`)?.scrollIntoView({block:`nearest`}),hN()}function _N(e){let t=E_(e,uN);t&&(W=t.path,uN=null),!E_(e,W)&&(W=lN===`overlay`?e[0]?.path??null:null)}function vN(){if(!H||lN===null)return;U=zr();let e=U?Q_(U):null;if(H.closeButton.hidden=lN!==`overlay`,!e){yN(H);return}let t=W!==null;_N(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=lN===`screen`&&W!==null?`diff`:`list`,bN(H.fileColumn,e),wN(H.diff,E_(e.files,W)),t!==(W!==null)&&hN()}function yN(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 bN(e,t){let n=e.scrollTop;if(e.replaceChildren(),t.diffError){e.append(E(`p`,`review-diff-error`,t.diffError));return}if(t.isEmpty){e.append(E(`p`,`review-empty-title`,t.sentence));return}t.totals.files>0&&e.append(xN(t.totals));let r=E(`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?p_(i,e.path):null;n&&n!==a&&r.append(E(`div`,`review-repo-label`,n)),a=n,r.append(SN(e,t))}e.append(r);let o=t.changeMapView?aN(t.changeMapView,{isShowingAll:dN,onShowAll:TN,onOpenFile:EN}):null;o&&e.append(o),e.scrollTop=n}function xN(e){let t=E(`p`,`review-reader-totals`);return t.append(E(`span`,`review-stat-files`,`${e.files} file${e.files===1?``:`s`}`),E(`span`,`review-add`,`+${e.added}`),E(`span`,`review-del`,`-${e.removed}`)),t}function SN(e,t){let n=Ve(`review-reader-file`);n.dataset.path=e.path,n.setAttribute(`role`,`listitem`),n.setAttribute(`aria-current`,String(e.path===W));let r=E(`span`,`review-file-name`);r.append(E(`span`,`review-file-path`,e.path));let i=oN(t.changeMapView?.hintsByOpenPath.get(e.path));if(i.length>0){let e=E(`span`,`review-file-hints`);e.append(...i),r.append(e)}return n.append(r,CN(e)),n.addEventListener(`click`,()=>gN(e.path)),n}function CN(e){let t=E(`span`,`review-file-counts`);return e.binary?(t.append(E(`span`,`review-bin`,`bin`)),t):(t.append(E(`span`,`review-add`,`+${e.added}`),E(`span`,`review-del`,`-${e.removed}`)),t)}function wN(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=E(`div`,`review-reader-diff-head`);if(r.append(E(`span`,`review-file-path`,t.path),CN(t)),e.append(r),t.binary){e.append(E(`div`,`review-file-binary`,`Binary file not shown`));return}let i=E(`div`,`review-file-body`);for(let e of t.hunks){i.append(E(`div`,`review-hunk-head`,e.header));for(let t of e.lines){let e=E(`div`,`review-line review-line-${t.type}`);e.append(E(`span`,`review-line-gutter`,cN[t.type]??` `),E(`span`,`review-line-text`,t.text)),i.append(e)}}e.append(i),e.scrollTop=n}function TN(){dN=!0,vN()}function EN(e){let t=E_(U?Q_(U)?.files??[]:[],e);t&&gN(t.path)}function DN(e,t){let{root:n}=pN();n.parentElement!==e&&e.append(n),lN=t,n.dataset.placement=t,n.hidden=!1}function ON(){H&&(H.root.hidden=!0,H.root.remove(),lN=null)}function kN(){W!==null&&(W=null,vN(),hN())}function AN(e,t){t===`header`&&(vv(e),new MutationObserver(_v).observe(e,{attributes:!0,attributeFilter:[`data-slot-held`]}))}q_(e=>ug(sN,e));var jN={id:sN,label:`Changes`,iconPath:at,isAvailableFor:e=>Q_(e)!==null,hasUnreadFor:()=>!1,mount(e,t,{placement:n,target:r}){DN(e,n),uN=r,vN(),n===`overlay`&&pN().root.focus({preventScroll:!0})},unmount:ON,canStepBack:()=>lN===`screen`&&W!==null,stepBack:kN,attachButton:AN};function MN(){cg(jN),cg(Bg)}var NN=new Set([`terminal`]),PN=new Set([`terminal`,`board`]),FN=new Set([`board`]),IN=e=>e.ui.path,LN=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),RN=null,G=null,zN=null,BN=null,K=null,VN=null,HN=null,UN=null,WN=null,GN=null,KN=null,qN=null,q=null,JN=null,YN=new Map,XN=null,ZN=null,QN=null,J=!1,$N=!1,eP=null,tP=new Map,Y=new Map,nP=new Map,rP=new Map,X=null,iP=``,aP=[],oP=new Set;function sP(){return aM(lP(yP()),oP)}function cP(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 lP(e){return iM(e,IN)}function uP(e){let t=rP.get(e.key),n=nP.get(e.key);return(!t||!n)&&(t=sM({onAdd:Jr}),n=E(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),rP.set(e.key,t),nP.set(e.key,n)),cM(t,e),Rr(n,`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function dP(){return J}function Z(){return j.snapshot().focusedSessionId}function fP(){return J&&q!==null}function pP({rail:e,center:t,resizer:n}){if(RN=e,zN=t,!RN||!zN)return;let r=RN,i=zN;gP(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,mr(Sl)),G=jM({onJump:RP,rowFor:e=>Y.get(e)},Ol());let a=E(`details`,`rail-status-key`);a.append(E(`summary`,`rail-status-key-summary`,`Status key`),Kj()),r.append(G,a),XN=E(`div`,`focus-empty`),XN.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,ZN=XN.querySelector(`.focus-empty-title`),QN=XN.querySelector(`.focus-empty-desc`),K=eN(),K.element.addEventListener(`click`,WP),BN=K.bodyOf(`terminal`),JN=AP(),MN(),VN=bg({style:`header`}),K.trailSlot.append(VN.element),i.append(XN,K.element),AA(()=>{if(!J)return;let e=q!==null;kP(),e&&q===null&&dF()}),r.addEventListener(`keydown`,_P)}var mP={minPx:180,maxPx:480},hP=16;function gP(e){e&&RN&&Bj({resizer:e,column:RN,widthHost:RN,widthProperty:`--rail-width`,bounds:mP,keyStepPx:hP,getStoredWidth:xr,setStoredWidth:er})}function _P(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(),Yr(n);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=vP(),n=t.find(t=>t===e.target)??(X?Y.get(X):null),r=n?t.indexOf(n):-1,i=_n(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&&cP(a.dataset.id),a.focus())}function vP(){return RN?[...RN.querySelectorAll(`button.session-row[data-id], button.session-row[data-board-id]`)]:[]}function yP(){return Sn(ti(bP))}function bP(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function xP(e){let{row:t,refs:n}=on();t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,()=>SP(e)),t.addEventListener(`pointerenter`,()=>{G&&VM(G,e)}),t.addEventListener(`pointerleave`,()=>{G&&VM(G,null)});let{item:r,removeButton:i}=Zt(t,()=>Yr(e),()=>ci(e));r.setAttribute(`role`,`presentation`),i.tabIndex=-1;let a=E(`span`,`session-row-shown`);return a.hidden=!0,a.append(x(ze),E(`span`,`session-row-shown-count`)),n.name.after(a),Object.assign(t,{_refs:n,_row:r,_shownCount:a})}function SP(e){let t=ii(e);t&&wP(t,e)}function CP(e){let t=ii(e);t&&wP(t,e)}function wP(e,t){eF(t),BP(e,t)}function TP(e,t){Wr(e,t===0),Rr(e,`aria-label`,`${t} shown ${t===1?`file`:`files`} not opened`);let n=e.querySelector(`.session-row-shown-count`);n&&Br(n,String(t))}function EP(e,{id:t,ui:n,state:r,name:i},a){let o=tP.get(t)||`none`;e.classList.toggle(`focused`,t===Z()),nn(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a}),TP(e._shownCount,Ng(t));let s=t===X;Rr(e,`aria-selected`,String(s)),Rr(e,`tabindex`,s?`0`:`-1`)}function DP(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||``:Wn(r._refs?.glyph))}Rn(DP),Gn((e,t)=>{if(!J)return;let n=Y.get(e);n&&Br(n._refs.elapsed,Un(t))});var OP=new Map;function kP(e){if(!J)return;let t=RN;if(!t)return;let n=yP(),r=lP(n),i=new Set,a=Cn(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=xP(t),Y.set(t,r));let s=o.get(t)??null;(!e||a||e.has(t)||OP.get(t)!==s)&&EP(r,n,s),OP.set(t,s)}a||si(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===iP;iP=l;for(let e of r.groups){let{header:n,list:r}=uP(e);u||t.append(n,r),s(e.rows,r)}JN&&(!u||JN.header.parentElement!==t)&&t.append(JN.header,JN.list),JN&&MP(JN);for(let[e,t]of[...rP])c.has(e)||(t.header.remove(),nP.get(e)?.remove(),rP.delete(e),nP.delete(e));for(let[e,t]of Y)i.has(e)||(t._row.remove(),Y.delete(e),OP.delete(e),e===X&&(X=null));for(let e of[...tP.keys()])O.has(e)||tP.delete(e);let d=aP;aP=aM(r,oP);let f=Z();if(f&&!Kr(f)){gg(),j.dispatch(`focusSession`,null),X=null;let e=FP(d,f);if(e){let t=!document.activeElement||document.activeElement===document.body;eF(e),t&&BP(O.get(e),e);return}}tF();let p=Z();if(p){let e=O.get(p);e&&e.card.parentElement!==BN&&HP(e,p)}VN?.showSession(q?null:p),YP(),LP(n,a)}function AP(){let e=E(`div`,`session-group-header focus-boards-header`),t=E(`span`,`session-group-count`),n=E(`span`,`session-group-rule`);n.setAttribute(`aria-hidden`,`true`);let r=C({variant:`icon`,size:`small`,label:`New board`,icon:x(Ae),action:`new-board`,onClick:PP});e.append(E(`span`,`session-group-label`,`Boards`),t,n,r);let i=E(`div`,`focus-rail-list focus-board-list`);return i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,`Boards with no session`),{header:e,count:t,list:i}}function jP(e){let{row:t,refs:n}=on();t.dataset.boardId=e,t.addEventListener(`click`,()=>NP(e));let r=E(`div`,`session-row-item`);return r.append(t),Object.assign(t,{_refs:n,_row:r})}function MP(e){let t=DA();q&&!t.some(e=>e.id===q)&&(q=null);let n=oM(t,e=>O.has(e)),r=new Set(n.map(e=>e.id));for(let[e,t]of YN)r.has(e)||(t._row.remove(),YN.delete(e));for(let e of n){let t=YN.get(e.id);t||(t=jP(e.id),YN.set(e.id,t)),ln(t,t._refs,e.title),t.classList.toggle(`focused`,e.id===q)}si(e.list,n.flatMap(e=>YN.get(e.id)?._row??[])),Br(e.count,String(n.length)),Rr(e.count,`aria-label`,`${n.length} ${n.length===1?`board`:`boards`} with no session`)}function NP(e){J&&($P(),q=e,GN=null,cP(null),kP())}function PP(){GP().then(e=>e.createBoardFromDialog(NP),KP)}function FP(e,t){let n=e.filter(e=>e===t||Kr(e));if(n.length<2)return aP.find(e=>Kr(e))??null;let r=n.indexOf(t)===n.length-1;return _n(n,t,r?-1:1)}function IP(){return Cn(yP(),Z())}function LP(e,t){G&&MM(G,Dn(e),t)}function RP(){if(!J)return;G&&KM(G);let e=IP()[0]?.id;e&&zP(e)}function zP(e){J&&(ii(e),Y.get(e)?.scrollIntoView({block:`nearest`}),G&&UM(G,e,()=>VP(e)),eF(e),BP(O.get(e),e))}function BP(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{J&&Z()===t&&e.term?.focus()}))}function VP(e){if(LN?.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=O.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function HP(e,t){if(!BN)return;let n=e.card.querySelector(`:scope > .session-card-header`);uj(e,t,BN,{className:`focus-centered`,onRelease:()=>{n?.classList.remove(`pane-header`),K?.setStripHost(`terminal`,null)}}),n?.classList.add(`pane-header`),n&&UP(n),Fu(e,t,!0)}function UP(e){let t=e.querySelector(`:scope > .session-name`);K?.setStripHost(`terminal`,{parent:e,before:t})}function WP(e){if(!(e.target instanceof Element)||!e.target.closest(`.pane-tab[data-tab="terminal"]`))return;let t=Z(),n=t?O.get(t):null;n&&n.face!==`terminal`&&n._showTerminalFace?.()}function GP(){return HN??=M(()=>import(`./boards-view-B_bSKyat.js`).then(e=>(UN=e,e)),__vite__mapDeps([38,13,5,3,14,22,15,12,33,26,20,39])),HN}function KP(e){HN=null,u(`focus`,`the board pane failed to load: ${d(e)}`)}function qP(e,t,n=!1){!K||KN===e&&qN===t||(KN=e,qN=t,K.showTabs(e,{holdSplit:n}))}function JP(e){qP(FN,null);let t=WN!==null||GN!==e;WN=null,GN=e,GP().then(n=>XP(n,null,t?e:null),KP)}function YP(e=null){if(q){JP(q);return}let t=Z(),n=t?YA(t):[],[r]=n,i=r?PN:NN;if(qP(i,t,PA()&&i===PN&&KN===NN&&qN===t&&e===null),!t||!r){WN=null,GN=null;return}let a=n.some(e=>e.id===GN),o=WN!==t||e!==null||!a;WN=t;let s=o?e??r.id:null;s&&(GN=s),GP().then(e=>XP(e,t,s),KP)}function XP(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 ZP(){J&&(WN||q)&&UN?.reopenSelectedBoard()}function QP(){let e=QA();J&&e?.sessionId&&O.has(e.sessionId)&&(eF(e.sessionId),YP(e.boardId),K?.showTab(`board`))}function $P(){gg();let e=Z();e&&(cj()===e&&dj(),j.dispatch(`focusSession`,null))}function eF(e){J&&O.has(e)&&(iS(e),ni(e),e!==Z()&&($P(),q=null,j.dispatch(`focusSession`,e),X=e,kP()))}function tF(){if(!XN||!ZN||!QN)return;let e=Z(),t=!!q||!!(e&&O.has(e)),n=O.size>0;Wr(XN,t),K&&Wr(K.element,!t),$j(XN,!n),Wr(ZN,!n),Wr(QN,!n),!t&&n&&(Br(ZN,`No session selected`),Br(QN,`Select a session from the rail on the left to focus it here.`))}function nF(e,t){tP.set(D(e),typeof t==`string`&&t?t:`none`),J&&kP()}var rF={placement:`overlay`,sessionId:()=>J&&zN&&!q?Z():null,elementFor:()=>{if(!zN)throw Error(`Focus view is not mounted`);return zN},didShow:()=>{},didHide:()=>{let e=Z();e&&BP(O.get(e),e)}};function iF(e=null){let t=Z();t&&hg(`changes`,t,e)}function aF(e){J&&O.has(e)&&eF(e)}function oF(e){return!J||!O.has(e)?!1:(eF(e),Xy(e))}function sF(e){if(!J)return;let t=sP()[e-1];t&&Kr(t)&&SP(t)}function cF(e){if(!J)return;let t=sP().filter(e=>e===X||Kr(e)),n=_n(t,X,e);n!=null&&Kr(n)&&(CP(n),Y.get(n)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=Z();J&&e&&iS(e)});function lF(){RN&&(J=!0,fg(rF),$P(),X=null,kP(),$N&&eP?zP(eP):$N&&IP().length>0?RP():($N&&G&&KM(G),dF()))}function uF(e,t=null){$N=!0,eP=t;try{e()}finally{$N=!1,eP=null}}function dF(){if(!J||Z()||q)return;let e=$r();e&&eF(e)}function fF(){J&&=($P(),pg(rF),X=null,!1)}var pF=[],mF=new Set;function hF(e){let t=Dt.safeParse(e);if(t.success){pF=t.data;for(let e of mF)e()}}function gF(e){return pF.find(t=>t.agent===e)??null}function _F(e){return mF.add(e),()=>{mF.delete(e)}}var vF=2e3,yF={},bF=null,xF=null,SF=Ce,CF=null,wF=!1,TF=null,EF=[],DF=null,OF=()=>null,kF=()=>{},AF=!1,jF=new Set,MF=new Set;function NF(e){for(let t of MF)t(e)}function PF(e){MF.add(e)}function FF(){return yF}function IF(e){return yF={...yF,...e},yF}function LF(){return{status:bF,journal:xF,request:SF,lastAutoCheckAt:CF,isCheckInFlight:wF,checkSendFailure:TF}}function RF(e){let t=Et(SF,e);t!==SF&&(SF=t,NF({kind:`update`,frame:`request`}))}function zF(){RF(_({type:`update-apply`})?`request-sent`:`request-unsent`)}function BF(){CF=Date.now();let e=_({type:`update-check`});wF=e,TF=e?null:Ee,NF({kind:`update`,frame:`request`})}function VF(e){kF=e}function HF(){kF()}function UF(e){EF=[...e]}function WF(){return EF}function GF(e=null,t=null,n=null){let r=DF!==null&&(DF.sectionId!==null||DF.isLink);e===null&&n===null&&r||(DF={sectionId:e,settingId:t,hashAtRequest:n??location.hash,isLink:n!==null},NF({kind:`activate`}))}function KF(){let e=DF;return DF=null,e}function qF(e){OF=e}function JF(){for(let e of jF)e()}function YF(e){jF.add(e)}function XF(){return no()&&OF()===`section`}function ZF(){XF()&&NF({kind:`return-to-list`})}function QF(e){e&&(yF=e,hF(yF.agentLogins),NF({kind:`broadcast`}))}function $F(){AF||(AF=!0,window.setTimeout(()=>{a(`get-settings`,{}).then(e=>{e.settings&&QF(e.settings)}).catch(()=>{AF=!1})},vF))}function eI(){NF({kind:`status`})}function tI(e){eI()}function nI(e){bF=e,wF=!1,TF=null,SF=Et(SF,`status-frame`),NF({kind:`update`,frame:`status`})}function rI(e){xF=e,SF=Et(SF,`progress-frame`),NF({kind:`update`,frame:`progress`})}function iI(e){if(e.scope!==`update`)return!1;let t=Fe(e.message),n=SF.requested;return SF=Et(SF,`error-frame`,t),wF=!1,n||(TF=t),NF({kind:`update`,frame:`error`}),!0}var aI=200;function oI(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function sI(e){return/^#settings(?:[/?]|$)/.test(e)}function cI(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function lI(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,aI).join(``).trim()}}function uI(e,t,n){let r=E(`a`,`settings-link`,n);return r.href=oI(e,t),r}var dI={teamReview:e=>e?.teamReview?.enabled!==!1,issues:e=>e?.issues?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,benchmarks:e=>e?.benchmarks?.enabled===!0,community:e=>e?.community?.enabled===!0},fI=[{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:`benchmarks`,sectionId:`lanes-benchmarks`,settingId:`benchmarks-enabled`},{rule:`community`,sectionId:`lanes-community`,settingId:`community-enabled`}],pI=null,mI=null,hI=null,gI=()=>!1,_I=new Set,vI=new Set,yI=Tt({getAck:Tr,setAck:Qn,signature:()=>Ke({posthog:pI}),isLooking:()=>gI()});function bI(e){for(let t of vI)t(e)}function xI(){mI?.(yI.refresh())}function SI(){return{latest:pI,archivedLocally:_I,traceOpener:hI}}function CI(e){vI.add(e)}function wI(e){gI=e,xI()}function TI(e){_I.add(e)}function EI(){yI.acknowledge(),xI()}function DI(e){mI=e,xI()}function OI(e){hI=e}function kI(e){pI=e,Je(pI,_I),bI({kind:`status`}),xI()}function AI(e){let t=Oe(pI,e.projectId,e.issueId)?.inFlight===!0;_e(pI,e)&&bI({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function jI(e){let t=Re(pI,e);bI({kind:`investigation-finished`,frame:e,isPatched:t}),t&&xI()}var MI=null,NI=[],PI=()=>!1,FI=null,II=Cr(),LI=Dr(),RI=new Set(LI.split(`|`).filter(Boolean)),zI=new Set;function BI(e){for(let t of zI)t(e)}function VI(){return Hp(NI).map(Vp)}function HI(e){e!==II&&(II=e,Zn(e))}function UI(e){e!==LI&&(LI=e,RI=new Set(e.split(`|`).filter(Boolean)),Xn(e))}function WI(){if(!MI)return;let e=$p({turnEntries:VI(),acknowledged:II,unseen:LI,isLooking:PI()});HI(e.acknowledged),UI(e.unseen),FI?.(e.isShown)}function GI(e){zI.add(e)}function KI(){return MI}function qI(){return NI}function JI(e){PI=e,WI()}function YI(e){FI=e,WI()}function XI(){MI&&(HI(bt(VI())),WI())}function ZI(){return LI}function QI(e){return RI.has(e)}function $I(e){return RI.has(e)?(UI(bt([...RI].filter(t=>t!==e))),!0):!1}function eL(e){let t=Se.safeParse(e);t.success?(MI=t.data,NI=Bp(t.data.entries),WI(),BI({kind:`status`})):u(`community`,`dropped community-status: ${c(t.error.issues)}`)}function tL(e){BI({kind:`connection`,isConnected:e})}function nL(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 iL(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 aL(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 oL(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function sL(e,t,n){t&&e?.refreshOn?.includes(n)&&t.refresh?.(n)}function cL(e,t,n,r){for(let i of e)nL(i.view,t)&&sL(i,r(i.view),n)}function lL(){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 uL(e,t,n){let r=Number(e);return!e||!Number.isFinite(r)||t-r>n}var dL=`glimmervoid:preload-error-reload-at`,fL=3e4,pL=1e3,mL=lL();function hL(e,t){let n=mL.mountedModuleOf(e.view);n?t(n):mL.show(e).then(t).catch(t=>{throw u(`view`,`${e.view} failed to show: ${d(t)}`),t})}function gL(e){return mL.mountedModuleOf(e)}function _L(e){mL.mountEagerViews(e)}function vL(e){let t=()=>{mL.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,pL)}function yL(e){let t=Date.now();uL(e.getItem(dL),t,fL)&&(e.setItem(dL,String(t)),location.reload())}function bL(e){window.addEventListener(`vite:preloadError`,()=>yL(e()))}function xL(e,t){fetch(e,{method:`HEAD`,cache:`no-store`}).then(e=>{e.status===404&&yL(t())}).catch(()=>{})}function SL(e){Um({openTerminal:e.openTerminal,openReviews:e.openReviews}),VF(e.onRestart),qA(e.openReviewFile);let t=[{view:`focus`,label:`Focus`,iconPath:ut,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,refreshOn:[`connected`],module:{mount:()=>pP({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:lF,deactivate:fF,refresh:ZP}},{view:`prs`,label:`Reviews`,iconPath:xt,panelClass:`pr-view`,gate:{fromSettings:dI.teamReview},load:()=>M(()=>import(`./review-queue-panel-D7EPFEjb.js`).then(e=>e.view),__vite__mapDeps([40,12,13,5,3,14,15,4,6,7,41,34,42,43,36,44,29,22,30,31,25,32,23,33,26,45])),refreshOn:[`shown`],attention:{subscribe:zm,acknowledge:Rm},onConnectionChange:e=>{xp(e),_m(e)}},{view:`issues`,label:`Issues`,iconPath:vt,panelClass:`issues-view`,gate:{fromSettings:dI.issues},load:()=>M(()=>import(`./issues-panel-CI002Sa4.js`).then(e=>e.view),__vite__mapDeps([46,13,5,3,14,22,15,12,31,25,32,4,6,7,23,34,43,16,17,44,29,30,33,26,47])),refreshOn:[`shown`],onConnectionChange:zd},{view:`usage`,label:`Usage`,iconPath:rt,panelClass:`usage-view`,gate:{fromSettings:dI.usage},load:()=>M(()=>import(`./usage-panel-D-F5UoXU.js`).then(e=>e.view),__vite__mapDeps([48,13,5,3,49,50])),attention:{subscribe:QT,acknowledge:ZT},onConnectionChange:iE,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,iconPath:ce,panelClass:`radar-view`,gate:{fromSettings:dI.posthog},load:()=>M(()=>import(`./radar-panel-8_2t93G1.js`).then(e=>e.view),__vite__mapDeps([51,12,13,5,3,14,22,15,52,30,31,25,32,4,6,7,23,37,20,49,53])),attention:{subscribe:DI,acknowledge:EI}},{view:`community`,label:`Community`,iconPath:Ye,panelClass:`community-view`,gate:{fromSettings:dI.community},load:()=>M(()=>import(`./community-panel-i92fc4IR.js`).then(e=>e.view),__vite__mapDeps([54,12,13,5,3,14,22,15,41,34,42,43,4,6,7,36,55])),refreshOn:[`shown`],attention:{subscribe:YI,acknowledge:XI},onConnectionChange:tL},{view:`boards`,label:`Boards`,iconPath:We,isPhoneNavScreen:!0,isPhoneOnly:!0,panelClass:`boards-screen`,hasPanelChrome:!1,load:()=>M(()=>import(`./boards-view-B_bSKyat.js`).then(e=>e.view),__vite__mapDeps([38,13,5,3,14,22,15,12,33,26,20,39])),refreshOn:[`shown`,`connected`]},{view:`hooks`,label:`Hooks`,iconPath:Xe,panelClass:`hooks-view`,load:()=>M(()=>import(`./hooks-panel-RR2ZdDf2.js`).then(e=>e.view),__vite__mapDeps([56,12,13,5,3,14,15,57])),refreshOn:[`shown`,`connected`,`hooks-updated`]},{view:`trace`,label:`Trace`,iconPath:de,panelClass:`trace-view`,gate:{subscribe:Cv},load:()=>M(()=>import(`./trace-panel-ws0zMLD_.js`).then(e=>e.view),__vite__mapDeps([58,13,5,3,15,12,4,6,7,59])),refreshOn:[`shown`],onAvailabilityChange:e=>OI(e?vx:null),onConnectionChange:Cx},{view:`benchmarks`,label:`Bench`,iconPath:pt,panelClass:`bench-view`,gate:{fromSettings:dI.benchmarks},load:()=>M(()=>import(`./benchmark-panel-CY0VHbkC.js`).then(e=>e.view),__vite__mapDeps([60,13,5,3,61])),onConnectionChange:Ei},{view:`settings`,label:`Settings`,iconPath:Me,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>M(()=>import(`./settings-panel-BTHxXdtR.js`).then(e=>e.view),__vite__mapDeps([62,12,13,5,3,14,15,4,6,7,10,52,30,22,31,25,32,23,37,20,63,8,45,2,1,64]))}],n=T(document,`#app-main`,`main`),r=t.map(t=>{let r=Ve(`header-tab`,t.label);r.prepend(x(t.iconPath)),r.id=`tab-${t.view}`,r.draggable=!0;let i=`view-${t.view}`;r.setAttribute(`role`,`tab`),r.setAttribute(`aria-controls`,i);let a=t.view===`focus`;r.setAttribute(`aria-selected`,String(a)),r.tabIndex=a?0:-1;let o=document.getElementById(i)??E(`section`);if(o.classList.add(t.panelClass),o.id=i,o.setAttribute(`role`,`tabpanel`),o.setAttribute(`aria-labelledby`,r.id),o.hidden=!0,o.parentElement||n.append(o),r.hidden=t.gate!==void 0||t.isPhoneOnly===!0,o.classList.toggle(`view-panel`,t.hasPanelChrome!==!1),t.attention){let n=E(`span`,`tab-activity`);n.id=`tab-${t.view}-activity`,n.setAttribute(`aria-hidden`,`true`),r.append(n),t.attention.subscribe(r=>{let{isActive:i,level:a}=oL(r);n.classList.toggle(`active`,i),a===null&&n.removeAttribute(`data-attention`),a!==null&&n.setAttribute(`data-attention`,a),e.setPhoneAttention(t.view,r)})}return{...t,tab:r,el:o}});return T(document,`#header-tabs`,`div`).replaceChildren(...r.map(e=>e.tab)),r}function CL(e){return e===`remote`?`remote`:`local`}function wL(e,t){return CL(t)===`local`||e!==`shutdown`}var TL=!1,EL=new Set;function DL({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){let o=zx(),s=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;Vt({title:t,message:s,confirmLabel:n,danger:r||o>0,onConfirm:()=>_({type:e})})}function OL(){DL({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function kL(){DL({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})}function AL(e){TL=wL(`shutdown`,e);for(let e of EL)e.isConnected?e.hidden=!TL:EL.delete(e)}function jL(e){e.hidden=!TL,EL.add(e)}function ML(e){e&&GF(e),!Pj(`settings`)&&$(`settings`,{section:e})}function NL(e){Pj(e)||$(e)}function PL(){Pj(`boards`)||($(`focus`),QP())}function FL(){sI(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}var Q=SL({onRestart:OL,openTerminal:e=>{Nj(e)||($(`focus`),aF(e))},openPlan:e=>{$(`focus`),oF(e)},openReviewFile:(e,t)=>{Rx(e)&&(Nj(e)||($(`focus`),aF(e),iF(t)))},openReviews:()=>zL(`prs`)?(Pj(`prs`)||$(`prs`),!0):!1,setPhoneAttention:Oj});function IL(){return Q.map(e=>e.view)}var LL=IL();function RL(e){return Q.find(t=>t.view===e)}function zL(e){return Q.some(t=>t.view===e&&!t.tab.hidden)}var BL=!0,VL=null;function HL(e){RL(e)?.attention?.acknowledge()}var UL=null;function WL(e){UL=_({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function GL(){UL&&WL(UL)}function KL(e){let t=RL(e);t&&(hL(t,e=>sL(t,e,`shown`)),WL(e))}function qL(e){cL(Q,{isPhoneShellActive:wj(),activeView:An(),phoneScreen:j.snapshot().phoneScreen},e,gL)}function $(e,{section:t,setting:n,persist:r=!0}={}){let i=RL(e);if(!i||!zL(e))return;let a=An();j.dispatch(`setActiveView`,e),BL=r,r&&(VL=null),document.body.dataset.activeView=e,r&&ar(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&&gL(a)?.deactivate?.(),hL(i,r=>{An()===e&&(r.activate?.(),sL(i,r,`shown`),e===`settings`&&t&&GF(t,n??null))}),WL(e),a===`settings`&&e!==`settings`&&FL(),HL(e)}function JL(e,t){let{view:n}=e;e.tab.hidden=!t,Dj(n,t),e.onAvailabilityChange?.(t),!wj()&&(!t&&An()===n&&$(`focus`),t&&VL===n&&$(n))}function YL(e){for(let{view:t,isAvailable:n}of rL(Q,e))JL(t,n)}function XL(e){let t=iL(LL,e);Q.every((e,n)=>e.view===t[n])||(Q.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),T(document,`#header-tabs`,`div`).append(...Q.map(e=>e.tab)),Ej(t))}function ZL(){return Q.filter(e=>!e.tab.hidden)}function QL(e,t){let n=e[t];return $(n.view),n.tab}function $L(e,t){let n=ZL(),r=n.findIndex(t=>t.view===e);return QL(n,ui(r,t,n.length))}function eR(e){Q.some(e=>e.tab===document.activeElement)&&e.focus()}var tR=null;function nR(e){let t=IL();XL(e),a(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&XL(t)}).catch(()=>XL(t))}function rR(e){let t=tR;if(tR=null,!t||t===e)return;let n=IL();nR(aL(n,t,n.indexOf(e)))}function iR({view:e,tab:t}){t.addEventListener(`click`,()=>$(e)),t.addEventListener(`dragstart`,t=>{tR=e,t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),t.addEventListener(`dragover`,n=>{tR&&tR!==e&&(n.preventDefault(),t.dataset.dropTarget=`true`)}),t.addEventListener(`dragleave`,()=>delete t.dataset.dropTarget),t.addEventListener(`drop`,n=>{n.preventDefault(),delete t.dataset.dropTarget,rR(e)}),t.addEventListener(`dragend`,()=>{tR=null}),t.addEventListener(`keydown`,e=>{if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=ZL(),n=t.findIndex(e=>e.view===An()),r=di(e.key,n,t.length,`horizontal`);r!==null&&(e.preventDefault(),QL(t,r).focus())})}function aR(){let e=Ar(),t=sI(location.hash),n=Wv(location.hash);if(t&&(GF(null,null,location.hash),$(`settings`,{persist:!1})),n&&$(`focus`,{persist:!1}),t||n)return;let r=zL(e);r||(VL=e),$(r?e:`focus`,{persist:r})}function oR(){let e=An();$(zL(e)?e:`focus`,{persist:BL})}function sR(){UF(Q),_L(Q);for(let e of Q)e.gate&&(JL(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>JL(e,t)));_x(()=>{zL(`trace`)&&(Pj(`trace`)||$(`trace`))});for(let e of Q)iR(e);aR()}function cR(e){return sI(e)?(GF(null,null,e),Pj(`settings`)||$(`settings`,{persist:!1}),!0):!1}var lR=`No plan is stored for this session yet. It appears here once the agent writes one.`,uR=`Plan`;function dR(e){let t=Wv(e);return t?!Rx(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),wj()?(Mj(t)||Nn({source:uR,sessionId:t,message:lR}),!0):($(`focus`,{persist:!1}),oF(t)||Nn({source:uR,sessionId:t,message:lR}),!0)):!1}function fR(e){return dR(e)?!0:cR(e)}function pR(e){e.newURL===location.href&&fR(location.hash)}function mR(){document.addEventListener(`click`,e=>{if(!wj()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&fR(t.hash)&&e.preventDefault()}),window.addEventListener(`hashchange`,pR)}var hR=null,gR=new Set;function _R(){hR?.setState(ir()?`idle`:`off`)}function vR(e){Er(e),_R();for(let t of gR)t(e)}function yR(e){gR.add(e)}function bR(e){hR=e,_R(),e.element.addEventListener(`click`,()=>vR(!ir()))}var xR=`•`.repeat(8),SR=`[^/\\\\\\s"'\`<>:]+`,CR=RegExp(`(?<![\\w./\\\\-])(?:/home/${SR}|/Users/${SR}|[A-Za-z]:[\\\\/]Users[\\\\/]${SR}|/root(?![\\w.-]))`,`g`);function wR(e){let t=Vs(e);if(t.length===0)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+xR,r=i.end;return n+e.slice(r)}function TR(e){return e.replace(CR,`~`)}function ER(e){return TR(wR(e))}var DR=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,OR=[`title`,`label`],kR=new WeakMap,AR=new WeakMap,jR=null;function MR(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(DR)!==null}function NR(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function PR(e,t){if(t&&e===t.masked)return t;let n=ER(e);return n===e?null:{original:e,masked:n}}function FR(e){let t=NR(e)?null:PR(e.data,kR.get(e));t?(kR.set(e,t),e.data!==t.masked&&(e.data=t.masked)):kR.delete(e)}function IR(e,t){let n=e.getAttribute(t),r=AR.get(e),i=n===null?null:PR(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),AR.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function LR(e){for(let t of OR)IR(e,t)}function RR(e){return e instanceof Element&&e.matches(DR)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function zR(e){LR(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,RR);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&FR(e),e instanceof Element&&LR(e)}function BR(e){MR(e)||(e instanceof Text&&FR(e),e instanceof Element&&zR(e))}function VR(e){e instanceof Element&&!MR(e)&&LR(e)}function HR(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&&BR(e);for(let e of n)e.isConnected&&VR(e)}function UR(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);WR(e);for(let e=t.nextNode();e;e=t.nextNode())WR(e)}function WR(e){if(e instanceof Text){let t=kR.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=AR.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function GR(){if(jR)return;let e=new MutationObserver(t=>{HR(t),e.takeRecords()});zR(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:OR}),jR=e}function KR(){jR&&(jR.disconnect(),jR=null,UR(document.body),kR=new WeakMap,AR=new WeakMap)}function qR(e){e?GR():KR()}function JR(){qR(Ks()),Js(qR)}var YR=$e({label:`Play queued merge celebrations`,icon:x(Te,`1.6`),action:`play-celebrations`,states:[`idle`,`attention`]}),XR=C({variant:`primary`,label:`Session`,icon:x(Ae),action:`add-session`,onClick:ri});XR.id=`btn-add-session-header`;var ZR=$e({label:`Keyboard shortcuts and version`,icon:x(Qe,`1.6`),action:`open-shortcuts-help`,onClick:()=>ML(`browser-shortcuts`),states:[`idle`]}).element,QR=$e({label:`Mute alerts`,icon:x(Ct,`1.6`),action:`toggle-mute`,states:[`idle`,`off`]}),$R=QR.element,ez=C({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-header-status`});ez.id=`header-status-dismiss`;var tz=T(document,`#celebration-tray`,`div`);tz.prepend(YR.element),T(document,`.header-right`,`div`).append(XR,ZR,$R),T(document,`#header-status`,`p`).append(ez);function nz(){bR(QR),JR(),It(document.querySelector(`.header`))}function rz(){af(tz,YR,T(document,`#celebration-tray-count`,`span`))}function iz(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 az(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 oz(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function sz(e,t){return t||oz(e)?!1:az(e)}var cz=C({variant:`primary`,size:`small`,label:`Restart`,action:`restart-to-update`,hidden:!0}),lz=C({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-update-command`}),uz=C({variant:`icon`,size:`small`,label:`Dismiss update notice`,icon:x(gt),action:`dismiss-update-banner`});T(document,`#update-banner-cmd`,`code`).before(cz),T(document,`#update-banner-copy-status`,`span`).before(lz),T(document,`#update-banner`,`div`).append(uz);var dz=C({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-leftovers-command`}),fz=C({variant:`icon`,size:`small`,label:`Dismiss old report notice`,icon:x(gt),action:`dismiss-leftovers-banner`});T(document,`#post-turn-leftovers-copy-status`,`span`).before(dz),T(document,`#post-turn-leftovers-banner`,`div`).append(fz);var pz,mz=null;function hz(e,t,n){e.onclick=()=>{let e=Mt(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var gz=uI(dt,ve,`Update`).href;function _z(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function vz(e){let t=T(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=he(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=_z(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===mz||!a&&pz!==void 0&&s===pz||!a&&s&&vr()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);T(document,`#update-banner-text`,`span`).textContent=i,T(document,`#update-banner-cmd`,`code`).textContent=c;let l=T(document,`#update-banner-update`,`a`);l.href=gz,l.hidden=n!==`link`,cz.hidden=n!==`restart`,cz.onclick=OL;let u=T(document,`#update-banner-cmd`,`code`);u.hidden=n!==`command`,lz.hidden=n!==`command`;let d=T(document,`#update-banner-copy-status`,`span`);d.hidden=n!==`command`,d.textContent=``;let f=T(document,`#update-banner-link`,`a`);f.hidden=!e.releaseUrl,f.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,hz(lz,d,c),uz.onclick=()=>{t.hidden=!0,a?mz=i:(pz=s,nr(s))}}var yz=!1;function bz({repositories:e,command:t}){let n=T(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(yz)return;let r=T(document,`#post-turn-leftovers-copy-status`,`span`);T(document,`#post-turn-leftovers-text`,`span`).textContent=iz(e.length),T(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,hz(dz,r,t),fz.onclick=()=>{yz=!0,n.hidden=!0}}var xz=T(document,`#telemetry-banner`,`div`),Sz=C({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-telemetry-banner`});xz.append(Sz);function Cz(){sr(!0),xz.hidden=!0}function wz(e){xz.hidden=!sz(e,Yn())}function Tz(){let e=T(document,`#telemetry-banner-settings`,`a`);e.href=uI(`privacy`,`telemetry-enabled`,`What's collected`).href,e.addEventListener(`click`,Cz),Sz.addEventListener(`click`,Cz)}function Ez(e){M(()=>import(`./feature-hint-B7CA-mZd.js`).then(t=>t.showFeatureHint(e,{isFeatureEnabled:e=>zL(nt[e]),openView:NL,openSetting:(e,t)=>cR(oI(e,t))}),e=>u(`feature-hint`,`hint card failed to load: ${d(e)}`)),__vite__mapDeps([65,12,13,5,3,4,6,7,63,8,66]))}function Dz(){M(()=>import(`./feature-hint-B7CA-mZd.js`).then(e=>e.showStarHint(),e=>u(`star-hint`,`star card failed to load: ${d(e)}`)),__vite__mapDeps([65,12,13,5,3,4,6,7,63,8,66]))}var Oz=2500;function kz({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}function Az(e){ca(e.isExperimentalBuild===!0&&Fr()),Bx(e),QF(e),YL(e),wz(e),XL(e.viewTabOrder),qs(e.streamerMode===!0)}var jz=Object.freeze({top:[0,1],right:[-1,0],bottom:[0,-1],left:[1,0]}),Mz=160,Nz=950,Pz=900,Fz=980,Iz=450,Lz=720,Rz=260,zz=`cubic-bezier(0.22, 1, 0.36, 1)`,Bz=`cubic-bezier(0.2, 0.8, 0.3, 1)`,Vz=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),Hz=e=>new Promise(t=>{setTimeout(t,e)});function Uz(e){return e!==void 0&&Object.hasOwn(jz,e)}function Wz(e){return[...e.querySelectorAll(`.loading-mark-bracket`)].flatMap(e=>{let t=e instanceof SVGElement?e.dataset.side:void 0;if(!(e instanceof SVGElement)||!Uz(t))return[];let[n,r]=jz[t];return[{bracket:e,dx:n,dy:r}]})}function Gz(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:Cc}],{duration:Mz,easing:`ease-out`})}}function Kz(e){e.animate([{transform:`rotate(0deg)`,easing:`cubic-bezier(0.5, 0, 0.15, 1)`},{transform:`rotate(360deg)`,offset:.86,easing:Bz},{transform:`rotate(354deg)`,offset:.93,easing:Bz},{transform:`rotate(360deg)`}],{duration:Nz})}function qz(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:Pz,easing:`cubic-bezier(0.2, 0.9, 0.3, 1)`})}}function Jz(e,t){e.animate([{transform:`scale(0)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:Fz,easing:zz,fill:`forwards`}),t.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`})}function Yz(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:Lz,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:Lz,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 Xz(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(Vz?.matches||document.hidden||!(t instanceof SVGElement)||!n||!r||!i)return;let a=Wz(t);Gz(a),e.dataset.unlock=`spin`,await Hz(Mz),Kz(n),qz(a),Jz(r,i),await Hz(Fz),e.dataset.unlock=`lit`,await Hz(Iz),e.dataset.unlock=`burst`,Yz(a,r,i),await Hz(Rz)}var Zz=T(document,`#connection-status`,`span`),Qz=T(Zz,`.connection-label`,`span`),$z=T(document,`#loading-screen`,`div`),eB=T(document,`#loading-status`,`div`),tB=T(document,`#loading-detail`,`div`),nB=T(document,`#shutdown-screen`,`div`),rB=T(document,`#shutdown-status`,`div`),iB=!1,aB=null,oB=!1;function sB(){iB||aB===null||kz({hasSnapshot:oB,connectingTerminalCount:Gc(),msSinceConnected:performance.now()-aB})===`reveal`&&lB()}function cB(){oB=!0,sB()}function lB(){iB||(iB=!0,vL(Q),Hg(),rd(),tM(),Xz($z).then(uB,uB))}function uB(){$z.classList.add(`fade-out`);let e=()=>$z.remove();$z.addEventListener(`transitionend`,t=>{t.target===$z&&e()}),setTimeout(e,1e3)}function dB(e,t){Zz.dataset.state=`shutdown`,Qz.textContent=e,rB.textContent=t,nB.classList.add(`active`)}var fB=new Set([`disconnected`,`connecting`]);function pB(e,t,n){Zz.dataset.state=e,Zz.toggleAttribute(`data-reconnected`,n),Qz.textContent=t}function mB(e,t){pB(e,t,e===`connected`&&fB.has(Zz.dataset.state??``))}function hB(e,t){Zz.dataset.state!==`shutdown`&&pB(e===`verified`?`connected`:e,t,!1)}var gB=1e4,_B=`Server`,vB=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,yB=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,bB=null,xB=!1;function SB(){eB.textContent=`Reconnecting to server...`,tB.textContent=yB,tB.hidden=!xB}function CB(){bB=null,xB=!0,iB?Nn({source:_B,message:vB,hidesInStreamerMode:!1}):SB()}function wB(){bB!==null||xB||(bB=window.setTimeout(CB,gB))}function TB(){bB!==null&&window.clearTimeout(bB),bB=null,xB=!1,tB.hidden=!0,Mn(_B)}function EB(){TB(),xL(import.meta.url,()=>window.sessionStorage),GL(),nB.classList.contains(`active`)?location.reload():(eM(),document.body.classList.add(`app-ready`),!iB&&aB===null&&(aB=performance.now(),eB.textContent=`Connecting to sessions...`,setTimeout(lB,Oz)),sB(),qL(`connected`),a(`get-settings`,{}).then(e=>{e.settings&&(Az(e.settings),An()===`settings`&&cR(location.hash))}).catch(()=>{}))}function DB(e,t){if(e===`connecting`||e===`verified`)hB(e,t);else{mB(e,t),nb(e===`connected`);for(let t of Q)t.onConnectionChange?.(e===`connected`);e===`connected`?EB():e===`disconnected`&&nB.classList.contains(`active`)?rB.textContent=`Waiting for server...`:(wB(),iB||SB())}}function OB(){Wc(sB),o(DB)}var kB=14,AB=Object.freeze({idle:wc,failed:`#ef4444`,waiting:`#f59e0b`});function jB({waitingCount:e,failedCount:t}){return e>0?`waiting`:t>0?`failed`:`idle`}function MB(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)">${Tc({frame:Cc,light:AB[e],strokeWidth:kB})}</g></svg>`}function NB(){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 PB=NB(),FB=`idle`;function IB(e){let t=jB(e);t!==FB&&(FB=t,PB.href=`data:image/svg+xml,${encodeURIComponent(MB(t))}`)}function LB(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 RB(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 zB(){Rd(),_p(),kj()}function BB(){kP(),zB()}function VB(){Fg(()=>kP()),Ur(e=>{kP(e),zB()})}var HB=null;function UB(e){let t=LB(HB,e);HB=t.knownBuild,t.reload&&location.reload()}function WB(e){Pn(e),tS(e),zi(e),fv(e),uh(e)}function GB(e){let t=new Set(e.map(e=>e.id));for(let e of[...O.keys()])t.has(e)||WB(e)}function KB(e){GB(e),tI(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){Ri(t.id,t.coherenceHooks),lh(t.id,t.linkedPrs);let e=Rx(t.id);e&&aS(t.id,t.state,t.stateSince),e&&en(t.id,!!t.saneYolo),e||Wx(t.id,t.name,t.state,RB(t)),ng(t.id,t.failureReason),Lx(t.id,t.taskTitle,t.taskTitleIsCustom),Kx(t.id,t.agent),$x(t.id,t.mergeStatus,t.mergeReason),Gx(t.id,t.effectiveBase),Jx(t.id,t.activeAgents,t.awaitingBackgroundTasks),Yx(t.id,t.pendingPromptKind),Xx(t.id,t.unseenOutcome),Zy(t.id,t.hasPlan)}Ux(),IB(A.counts),kP(),dF(),zB(),qB(),dR(location.hash),Fj(),cB()}function qB(){yx([...O].map(([e,t])=>({id:e,name:vn(t)||e})))}function JB(e,t){Zy(e,t?.hasPlan===!0),Xx(e,t?.unseenOutcome)}var YB=new Set([w.DONE,w.FAILED]);function XB(e,t){return e!==void 0&&YB.has(e)&&!YB.has(t)&&t!==w.DORMANT}function ZB(e){let t=O.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;tS(e.id),Wx(e.id,e.session,w.DORMANT,RB({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})),Kx(e.id,t?.agent),JB(e.id,t)}function QB(e,t){let n=O.get(String(e.id))?.currentState;t.to===w.DORMANT&&n!==w.DORMANT?(ZB(e),uv(e.id)):(aS(e.id,t.to,e.timestamp),ng(e.id,e.failureReason),e.saneYolo!==void 0&&en(e.id,e.saneYolo),uv(e.id),XB(n,t.to)&&sl(e.id))}function $B(e){if(Rx(e.id))e.transition&&QB(e,e.transition),e.activeAgents!==void 0&&Jx(e.id,e.activeAgents,e.awaitingBackgroundTasks),e.unseenOutcome!==void 0&&Xx(e.id,e.unseenOutcome),e.pendingPromptKind!==void 0&&Yx(e.id,e.pendingPromptKind),e.unseenOutcome!==void 0&&Ux(),IB(A.counts),qr(e.id),Fv(e.id);else{if(!e.transition)return;Wx(e.id,e.session,e.transition.to,RB({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),IB(A.counts),Rd()}}function eV(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 tV={"session-trace-response":e=>bx(e),"session-trace-changed":e=>xx(e),"session-plan-changed":e=>{Qy(e),zB()},"session-plan-draft":e=>{$y(e)},"session-plan-response":e=>{eb(e)},"session-docs-changed":e=>$h(e),"session-docs-snapshot":e=>eg(e),"session-shown":e=>Kg(e),"session-shown-snapshot":e=>qg(e),"session-coherence-hooks":e=>{Ri(e.id,e.coherenceHooks),BB()},"session-coherence":e=>{Bi(e),BB()},"session-coherence-snapshot":e=>{Vi(e),BB()},"session-coherence-journal-response":e=>Ki(e)},nV={"team-review-status":e=>mm(e),"github-prs":e=>Gd(e),"my-prs-status":vp,"pr-flows-status":yp,"my-pr-merge-result":e=>bp(e),"team-review-action-result":e=>hm(e),"open-team-review-session-result":e=>gm(e),"issues-status":e=>Bd(e),"issue-detail-result":e=>Vd(e),"open-issue-session-result":e=>Hd(e),"set-issue-state-result":e=>Ad(e)},rV={"radar-status":e=>kI(e),"radar-investigation-activity":e=>AI(e),"radar-investigation-finished":e=>jI(e),"community-status":e=>eL(e),"benchmark-status":e=>Di(e),"benchmark-action-result":e=>Oi(e),"usage-sessions":e=>aE(e),"usage-report":e=>{sE(e),eI()},"plan-limits":e=>oE(e),"usage-budget-alert":e=>vy({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0})},iV={snapshot:e=>{UB(e.serverBuild),KB(e.sessions)},"hooks-report":e=>Hh(e),"save-hook-result":()=>Uh(),"delete-hook-result":()=>Uh(),"update-status":e=>{vz(e),nI(e)},"update-progress":e=>rI(e.journal),"post-turn-leftovers":e=>bz(e),"feature-hint":e=>Ez(e.hint),"star-hint":()=>Dz(),error:e=>{let t=iI(e),n=Sx(e),r=tb(e);t||n||r||(e.id?tg(e.id,e.message):Nn({source:_B,message:e.message}))},"settings-updated":e=>{e.settings&&Az(e.settings),eM()},"agent-logins":e=>hF(e.logins),"health-snapshot":e=>{e.stats&&Ah(e.stats)},"client-trust":e=>AL(e.trust),"shutting-down":()=>dB(`Shutting down...`,`Shutting down sessions...`),restarting:()=>dB(`Restarting...`,`Restarting server...`)},aV={"session-status":e=>$B(e),"session-added":e=>{lh(e.id,e.linkedPrs),Rx(e.id)||(Wx(e.id,e.session,e.state,RB(e)),Kx(e.id,e.agent)),IB(A.counts),BB(),qB()},"session-close-confirm":e=>{Xr(e.id)},"session-removed":e=>{WB(e.id),IB(A.counts),BB(),qB()},"session-title":e=>{Lx(e.id,e.taskTitle,e.isCustom),BB()},"session-prs":e=>lh(e.id,e.linkedPrs),"session-renamed":e=>{eS(e.id,e.newName),BB(),qB()},"session-modified":e=>{let t=O.get(String(e.id)),n=zr()===String(e.id);Ri(e.id,null),tS(e.id),fv(e.id),lh(e.id,e.linkedPrs),Wx(e.id,e.session,e.state,RB(e)),n&&ei(String(e.id)),Kx(e.id,e.agent),JB(e.id,t),IB(A.counts),BB(),qB()},"session-git":e=>qx(e.id,!!e.worktree),"session-merge-status":e=>{Qx(e.id,e.mergeStatus,e.reason),nF(e.id,e.mergeStatus),zB()},"debug-state-response":e=>Pv(e),"session-setup-response":e=>uS(e),notify:e=>{_y(e),Fv(e.session)},"session-error":e=>{dv(e.id),!tb(e)&&tg(e.id,e.message)}},oV={"whiteboards-snapshot":e=>FA(e),"whiteboard-patch":e=>IA(e),"whiteboard-removed":e=>LA(e)},sV=`Worktree`,cV=`Worktree warning`,lV=eV([iV,aV,{"session-worktree-blocked":e=>{Nn({source:sV,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=>{Nn({source:cV,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=>{Mn(sV,e.id),Gx(e.id,e.base)},"session-diff":e=>{av(e.id,e)},"session-diff-error":e=>{ov(e.id,e.message)},"change-map":e=>sv(e.id,e.map),"session-changed":e=>cv(e.id)},tV,oV,nV,rV]);function uV(e){let t=lV[e.type];t&&t(e)}function dV(){l(e=>{uV(e),qL(e.type)})}function fV(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 pV(){xj({panels:fV(Q),onScreenShown:e=>{KL(e),e!==`settings`&&FL(),e===`settings`&&!sI(location.hash)&&GF(),HL(e)},canGoBack:e=>e===`settings`&&XF()||e===`prs`&&Jm(),onBack:e=>{e===`settings`&&ZF(),e===`prs`&&Ym()},headerControls:[T(document,`.header-title`,`h1`),T(document,`#status-indicator`,`div`),T(document,`#celebration-tray`,`div`),XR,ZR,$R]}),YF(Aj),qm(Aj)}function mV(e){if(e===`phone`){let e=Z();for(let e of Q)gL(e.view)?.deactivate?.();let t=sI(location.hash);Sj({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}).then(e=>{e&&t&&GF(null,null,location.hash),!e&&no()&&!wj()&&oR()});return}let t=Tj();Cj(),oR(),t&&aF(t)}function hV(){pV(),no()&&mV(`phone`),ro(mV)}function gV(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function _V(e){aF(e),ni(e),requestAnimationFrame(()=>requestAnimationFrame(()=>O.get(e)?.term?.focus()))}function vV(){let e=gV()??zr();e?Gr(e):document.getElementById(`btn-add-session-header`)?.click()}function yV({action:e,step:t}){switch(e){case`merge`:{let e=zr();return!e||fP()?!1:(mv(e),!0)}case`close-session`:{let e=zr();return e?(Yr(e),!0):!1}case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return vV(),!0;case`next-attention`:return no()?!1:dP()?(RP(),!0):(An()===`prs`&&Xm()||uF(()=>$(`focus`)),!0);case`rail-step`:return dP()?(cF(t),!0):!1;case`view-step`:return!no()&&(eR($L(An(),t)),!0);case`session-nth`:return dP()?(sF(t),!0):!1;case`streamer-mode`:return Qs(),!0}}function bV(e){return e.code!==`KeyZ`||e.altKey||e.shiftKey?!1:Sl===`mac`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function xV(){Zr(_V),document.addEventListener(`keydown`,e=>{if(e.repeat||Nt(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1;if(!t&&bV(e)&&!Ht()&&ai()){e.preventDefault(),e.stopImmediatePropagation();return}let n=Sr(e,Sl,{isTerminalFocused:t},Tl());n&&(Ht()||yV(n)&&e.preventDefault())})}function SV(){let e=m(_);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))}),bL(()=>window.sessionStorage)}oa(hr()),sa(()=>{M(()=>import(`./alert-sound-Da6VQFBS.js`).then(e=>e.playNyanJingle(),e=>u(`alert-sound`,`nyan jingle failed to load: ${d(e)}`)),__vite__mapDeps([10,7]))}),id(Ir()),to(),Hl(document),OB(),VB(),eE(_),M(()=>import(`./your-day-tip-BW0Kb-tN.js`).then(e=>e.startYourDayTips({openUsage:()=>NL(`usage`)}),e=>u(`your-day-tip`,`your day tips failed to load: ${d(e)}`)),__vite__mapDeps([67,13,5,3,22,65,12,4,6,7,63,8,66])),Bh(_),gx(_),Ld(_),wi(_),tn(sh),dn(Hi),dn(ih,`links`),dn(aj,`links`),cn(sj),ej(PL),$t({isReadable:Ui,open:Gi}),an(lS),Js(()=>qL(`settings-updated`)),dV(),Tz(),nz(),mR(),rz(),sR(),hV(),xV(),Lj(),SV(),kh(T(document,`#health-footer-mount`,`div`)),xl(Vx),wB(),Yu(),f();var CV=ur();CV&&n().then(()=>tl(CV));export{Kj as $,id as $i,TS as $n,Bm as $r,oT as $t,BF as A,Sf as Ai,lw as An,jg as Ar,Tw as At,hF as B,Md as Bi,qS as Bn,fg as Br,LS as Bt,oI as C,Si as Ca,Wf as Ci,_T as Cn,zy as Cr,XT as Ct,JF as D,zf as Di,IC as Dn,Yv as Dr,JT as Dt,IF as E,Of as Ei,RC as En,Zv as Er,YT as Et,FF as F,Tf as Fi,$S as Fn,mg as Fr,sC as Ft,KM as G,Cd as Gi,iT as Gn,zh as Gr,wC as Gt,MN as H,Dd as Hi,Aw as Hn,Gh as Hr,Mw as Ht,LF as I,lf as Ii,xT as In,dg as Ir,EC as It,cM as J,Pd as Ji,yT as Jn,Vm as Jr,rw as Jt,UM as K,Fd as Ki,dw as Kn,F as Kr,CC as Kt,PF as L,uf as Li,Ww as Ln,hg as Lr,ow as Lt,ZF as M,Cf as Mi,nT as Mn,_g as Mr,HC as Mt,qF as N,Ef as Ni,CT as Nn,gg as Nr,oC as Nt,$F as O,Df as Oi,hT as On,Bv as Or,qT as Ot,WF as P,wf as Pi,wT as Pn,bg as Pr,WS as Pt,qj as Q,wd as Qi,ES as Qn,Wm as Qr,HS as Qt,KF as R,Kd as Ri,Ow as Rn,pg as Rr,aw as Rt,lI as S,Ti as Sa,If as Si,YS as Sn,jy as Sr,rE as St,QF as T,Lf as Ti,gT as Tn,ey as Tr,tE as Tt,jM as U,jd as Ui,kw as Un,Rh as Ur,iC as Ut,_F as V,Od as Vi,JS as Vn,vg as Vr,Sw as Vt,MM as W,Nd as Wi,bT as Wn,Vh as Wr,TC as Wt,aM as X,Ed as Xi,rC as Xn,Lm as Xr,ZS as Xt,iM as Y,Td as Yi,Dw as Yn,Hm as Yr,jw as Yt,$j as Z,kd as Zi,gS as Zn,Ym as Zr,KS as Zt,wI as _,da as _a,Xp as _i,_C as _n,Uy as _r,Wk as _t,jL as a,El as aa,fm as ai,zC as an,dS as ar,RA as at,fI as b,ua as ba,pp as bi,$w as bn,Oy as br,Bk as bt,JI as c,Dl as ca,nm as ci,cC as cn,hx as cr,jA as ct,ZI as d,Js as da,Zp as di,uw as dn,fx as dr,OA as dt,Fu as ea,Km as ei,hC as en,SS as er,Bj as et,QI as f,Ys as fa,Up as fi,gw as fn,dx as fr,JA as ft,SI as g,ro as ga,Hp as gi,xw as gn,Xy as gr,BA as gt,TI as h,no as ha,am as hi,dT as hn,Lb as hr,QA as ht,kL as i,Sl as ia,dm as ii,cT as in,fS as ir,DA as it,HF as j,qf as ji,uT as jn,Pg as jr,tT as jt,zF as k,Rf as ki,sw as kn,Vv as kr,cE as kt,qI as l,Tl as la,Vp as li,lC as ln,px as lr,AA as lt,GI as m,ho as ma,tm as mi,TT as mn,ux as mr,zA as mt,yR as n,Bl as na,Fm as ni,GC as nn,PS as nr,cj as nt,aL as o,kl as oa,em as oi,mw as on,iS as or,VA as ot,$I as p,zo as pa,im as pi,$C as pn,lx as pr,GA as pt,sM as q,Id as qi,vT as qn,Im as qr,sT as qt,OL as r,Pl as ra,Gm as ri,WC as rn,mS as rr,dj as rt,iL as s,Ol as sa,Wp as si,fw as sn,Tx as sr,WA as st,vR as t,Jl as ta,Zm as ti,dC as tn,xS as tr,uj as tt,KI as u,Ks as ua,Yp as ui,bC as un,mx as ur,kA as ut,CI as v,ca as va,hp as vi,gC as vn,Gy as vr,uA as vt,cI as w,Hf as wi,lT as wn,My as wr,nE as wt,uI as x,Ci as xa,Gf as xi,Uw as xn,Ey as xr,$T as xt,dI as y,oa as ya,mp as yi,eT as yn,Ny as yr,Vk as yt,gF as z,qd as zi,aT as zn,lg as zr,IS as zt};
|