glimmervoid 0.52.3-next.892 → 0.52.3-next.893
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/chunks/{main-CASEH9rW.js → main-CluSnNx5.js} +2 -0
- package/dist/client/assets/{agent-core-0lwyGdpQ.js → agent-core-C63CBR1u.js} +2 -2
- package/dist/client/assets/agent-core-C63CBR1u.js.br +0 -0
- package/dist/client/assets/{agent-mark-CtiD1ZyX.js → agent-mark-Cwz5xPAA.js} +1 -1
- package/dist/client/assets/agent-mark-Cwz5xPAA.js.br +0 -0
- package/dist/client/assets/{arena-panel-5b76eNl_.js → arena-panel-DsZW87SB.js} +2 -2
- package/dist/client/assets/arena-panel-DsZW87SB.js.br +0 -0
- package/dist/client/assets/{benchmark-panel-CIWyMfoF.js → benchmark-panel-BIDQyRBO.js} +1 -1
- package/dist/client/assets/benchmark-panel-BIDQyRBO.js.br +0 -0
- package/dist/client/assets/{boards-view-VmPAgQRE.js → boards-view-BiwLooLF.js} +1 -1
- package/dist/client/assets/boards-view-BiwLooLF.js.br +0 -0
- package/dist/client/assets/{community-panel-CqhjpdB4.js → community-panel-CMwSKMoo.js} +1 -1
- package/dist/client/assets/community-panel-CMwSKMoo.js.br +0 -0
- package/dist/client/assets/{dialogs-BhyTHXHo.js → dialogs-Bju6zrjt.js} +1 -1
- package/dist/client/assets/dialogs-Bju6zrjt.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-Bav03W4B.js → doc-editor-ui-nrnC5Ekm.js} +1 -1
- package/dist/client/assets/doc-editor-ui-nrnC5Ekm.js.br +0 -0
- package/dist/client/assets/{feature-hint-JZ0N-gf7.js → feature-hint-Ckkpugl5.js} +1 -1
- package/dist/client/assets/feature-hint-Ckkpugl5.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-om8MDQ1X.js → first-run-checklist-Dh6Cvg_U.js} +1 -1
- package/dist/client/assets/first-run-checklist-Dh6Cvg_U.js.br +0 -0
- package/dist/client/assets/{hooks-panel-BDAAAtd-.js → hooks-panel-CsEtzh3p.js} +1 -1
- package/dist/client/assets/hooks-panel-CsEtzh3p.js.br +0 -0
- package/dist/client/assets/{index-DP80qAV4.js → index-B6oEXRWN.js} +5 -5
- package/dist/client/assets/index-B6oEXRWN.js.br +0 -0
- package/dist/client/assets/{issues-panel-BLaflTII.js → issues-panel-BE4a2m0n.js} +1 -1
- package/dist/client/assets/issues-panel-BE4a2m0n.js.br +0 -0
- package/dist/client/assets/{lane-read-token-step-Bkjp4OkM.js → lane-read-token-step-dr_b7bbq.js} +1 -1
- package/dist/client/assets/lane-read-token-step-dr_b7bbq.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-6t2e1-Ea.js → my-prs-panel-BSOG04bb.js} +1 -1
- package/dist/client/assets/my-prs-panel-BSOG04bb.js.br +0 -0
- package/dist/client/assets/{nyan-cat-Dn8SmAZc.js → nyan-cat-DFntGsFR.js} +1 -1
- package/dist/client/assets/nyan-cat-DFntGsFR.js.br +0 -0
- package/dist/client/assets/{phone-shell-B5Qp4ql6.js → phone-shell-QnJW6JzC.js} +1 -1
- package/dist/client/assets/phone-shell-QnJW6JzC.js.br +0 -0
- package/dist/client/assets/{plan-face-DpMnseaN.js → plan-face-AIPyl9ns.js} +1 -1
- package/dist/client/assets/plan-face-AIPyl9ns.js.br +0 -0
- package/dist/client/assets/{plan-render-Bb53GK3W.js → plan-render-BwV2iOMo.js} +1 -1
- package/dist/client/assets/plan-render-BwV2iOMo.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-wZhnQKpM.js → pr-queue-columns-BBeq-Zzh.js} +1 -1
- package/dist/client/assets/pr-queue-columns-BBeq-Zzh.js.br +0 -0
- package/dist/client/assets/{radar-panel-Bzc5G9d0.js → radar-panel-7-5n1ink.js} +1 -1
- package/dist/client/assets/radar-panel-7-5n1ink.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-BodUCiMo.js → repo-roots-adder-C3cMrHJj.js} +1 -1
- package/dist/client/assets/repo-roots-adder-C3cMrHJj.js.br +0 -0
- package/dist/client/assets/{resume-dialog-BuSL2zL_.js → resume-dialog-C-j9LGui.js} +1 -1
- package/dist/client/assets/resume-dialog-C-j9LGui.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-CfzxFyz7.js → review-queue-panel-I8RK2j4B.js} +1 -1
- package/dist/client/assets/review-queue-panel-I8RK2j4B.js.br +0 -0
- package/dist/client/assets/{session-row-Bmd6V-X4.js → session-row-BUURB6CH.js} +1 -1
- package/dist/client/assets/session-row-BUURB6CH.js.br +0 -0
- package/dist/client/assets/{settings-panel-Bb_nAcBI.js → settings-panel-SaUZ37hZ.js} +2 -2
- package/dist/client/assets/settings-panel-SaUZ37hZ.js.br +0 -0
- package/dist/client/assets/{trace-panel-Bq_awQ92.js → trace-panel-B2myZkUL.js} +1 -1
- package/dist/client/assets/trace-panel-B2myZkUL.js.br +0 -0
- package/dist/client/assets/{usage-panel-C6x7Alhb.js → usage-panel-BBEw22J_.js} +1 -1
- package/dist/client/assets/usage-panel-BBEw22J_.js.br +0 -0
- package/dist/client/assets/{your-day-tip-CUPrvYlw.js → your-day-tip-DbK_G8QL.js} +1 -1
- package/dist/client/assets/your-day-tip-DbK_G8QL.js.br +0 -0
- package/dist/client/index.html +4 -4
- package/dist/client/index.html.br +0 -0
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/agent-core-0lwyGdpQ.js.br +0 -0
- package/dist/client/assets/agent-mark-CtiD1ZyX.js.br +0 -0
- package/dist/client/assets/arena-panel-5b76eNl_.js.br +0 -0
- package/dist/client/assets/benchmark-panel-CIWyMfoF.js.br +0 -0
- package/dist/client/assets/boards-view-VmPAgQRE.js.br +0 -0
- package/dist/client/assets/community-panel-CqhjpdB4.js.br +0 -0
- package/dist/client/assets/dialogs-BhyTHXHo.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-Bav03W4B.js.br +0 -0
- package/dist/client/assets/feature-hint-JZ0N-gf7.js.br +0 -0
- package/dist/client/assets/first-run-checklist-om8MDQ1X.js.br +0 -0
- package/dist/client/assets/hooks-panel-BDAAAtd-.js.br +0 -0
- package/dist/client/assets/index-DP80qAV4.js.br +0 -0
- package/dist/client/assets/issues-panel-BLaflTII.js.br +0 -0
- package/dist/client/assets/lane-read-token-step-Bkjp4OkM.js.br +0 -0
- package/dist/client/assets/my-prs-panel-6t2e1-Ea.js.br +0 -0
- package/dist/client/assets/nyan-cat-Dn8SmAZc.js.br +0 -0
- package/dist/client/assets/phone-shell-B5Qp4ql6.js.br +0 -0
- package/dist/client/assets/plan-face-DpMnseaN.js.br +0 -0
- package/dist/client/assets/plan-render-Bb53GK3W.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-wZhnQKpM.js.br +0 -0
- package/dist/client/assets/radar-panel-Bzc5G9d0.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-BodUCiMo.js.br +0 -0
- package/dist/client/assets/resume-dialog-BuSL2zL_.js.br +0 -0
- package/dist/client/assets/review-queue-panel-CfzxFyz7.js.br +0 -0
- package/dist/client/assets/session-row-Bmd6V-X4.js.br +0 -0
- package/dist/client/assets/settings-panel-Bb_nAcBI.js.br +0 -0
- package/dist/client/assets/trace-panel-Bq_awQ92.js.br +0 -0
- package/dist/client/assets/usage-panel-C6x7Alhb.js.br +0 -0
- package/dist/client/assets/your-day-tip-CUPrvYlw.js.br +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xterm-CJsd_Jt0.js","assets/rolldown-runtime-DK3Fl9T5.js","assets/nyan-cat-
|
|
2
|
-
import{C as e,S as t,T as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,i as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y,v as b,w as ee,x as te,y as x}from"./control-ws-CiuaF_NT.js";import{f as ne,l as re,n as ie,p as ae,s as oe,v as se}from"./zod-gDNZYuWw.js";import{A as ce,At as le,Bt as ue,C as de,Ct as fe,D as pe,Dt as me,E as he,Et as ge,Ft as _e,G as ve,It as ye,J as be,K as xe,Lt as Se,M as S,Mt as Ce,Nt as we,O as Te,Ot as C,Pt as Ee,Qt as De,R as Oe,Rt as ke,S as Ae,T as je,Tt as Me,U as Ne,V as Pe,Vt as Fe,Xt as Ie,Z as Le,Zt as Re,_ as ze,a as Be,b as Ve,c as He,dn as Ue,f as We,g as Ge,h as Ke,i as qe,in as Je,j as Ye,kt as Xe,l as Ze,ln as Qe,nn as $e,on as et,p as tt,q as nt,s as rt,sn as it,st as at,t as w,tn as ot,u as st,un as ct,ut as lt,vn as ut,vt as dt,wt as ft,x as pt,xt as mt,y as ht,yn as gt,yt as _t}from"./button--pTS8HHg.js";import{Dn as vt,En as yt,Ft as bt,Lt as xt,Mn as St,Nn as Ct,Nt as wt,Pn as Tt,S as Et,Tn as Dt,Un as Ot,Y as kt,Yt as At,_ as jt,an as Mt,b as Nt,bt as Pt,dt as Ft,f as It,g as T,h as Lt,in as Rt,mn as zt,n as Bt,nn as Vt,on as E,p as Ht,rn as Ut,s as D,t as Wt,u as Gt,un as Kt,wt as qt,yt as Jt,zn as Yt}from"./dom-helpers-BGfnE93m.js";import{a as Xt,i as Zt,n as Qt,r as $t,t as en}from"./modal-Dd0ta-Iu.js";import{A as tn,C as nn,D as rn,E as an,F as on,I as sn,M as cn,N as ln,O as un,P as dn,S as fn,T as pn,_ as mn,a as hn,b as gn,c as _n,d as vn,f as yn,g as bn,h as xn,i as Sn,j as Cn,k as wn,l as Tn,m as En,n as Dn,o as On,p as kn,r as An,s as jn,t as Mn,u as Nn,v as Pn,w as Fn,x as In,y as Ln}from"./session-row-Bmd6V-X4.js";import{i as Rn,n as zn,t as Bn}from"./agent-mark-CtiD1ZyX.js";import{D as Vn,E as Hn,S as Un,T as Wn,_ as Gn,a as Kn,b as qn,c as Jn,f as Yn,h as Xn,i as O,n as Zn,o as k,r as A,s as Qn,t as j,u as $n,v as er,w as tr,y as nr}from"./card-registry-BydUQIUS.js";import{n as M,t as rr}from"./ui-state-core-Nssh-6QJ.js";import{t as N}from"./preload-helper-BLdHbfdN.js";import{c as ir,i as ar,n as or,o as sr,r as cr,s as lr,t as ur,u as dr}from"./action-status-DCsn95R1.js";import{a as fr,c as pr,i as mr,n as hr,o as gr,r as _r,s as vr,t as yr}from"./session-tick-De9JHrec.js";import{n as br,t as xr}from"./local-store-CVQ5ByvB.js";import{$ as Sr,A as Cr,Ct as wr,D as Tr,E as Er,Et as Dr,F as Or,G as kr,Gt as Ar,I as jr,M as Mr,O as Nr,P as Pr,Q as Fr,Rt as Ir,S as Lr,St as Rr,T as zr,Tt as Br,Ut as Vr,Vt as Hr,X as Ur,_t as Wr,a as Gr,b as Kr,bt as qr,c as Jr,ct as Yr,d as Xr,et as Zr,ft as Qr,gt as $r,h as ei,ht as ti,i as ni,k as ri,l as ii,lt as ai,m as oi,mt as si,ot as ci,p as li,pt as ui,r as di,t as fi,tt as pi,u as mi,vt as hi,w as gi,wt as _i,x as vi,xt as yi,yt as bi,zt as xi}from"./ui-prefs-Cc_48IUB.js";import{A as Si,C as Ci,D as wi,E as Ti,F as Ei,M as Di,N as Oi,O as ki,S as Ai,T as ji,b as Mi,c as Ni,f as Pi,g as Fi,h as Ii,j as Li,k as Ri,l as zi,m as Bi,p as Vi,u as Hi,v as Ui,w as Wi,x as Gi,y as Ki}from"./agent-core-0lwyGdpQ.js";import{n as qi}from"./menu-CsKNBMxw.js";import{t as Ji}from"./pr-status-icon-DwS-fc7J.js";import{n as Yi,t as Xi}from"./roving-keys-core-BDobx2It.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 Zi={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},Qi=null,$i=null,ea=!0,ta=new Map,na=new Map,ra=new Set;function ia(){for(let e of ra)e()}function aa(e){ra.add(e)}function oa(){return{status:Qi,isServerConnected:ea,pendingActionBySuite:ta,outcomeBySuite:na}}function sa(e){$i=e}function ca(e,t){$i?.({type:`benchmark-action`,requestId:d(`benchmark`),suiteId:e,action:t})===!0?(ta.set(e,t),na.set(e,Zi[t]),ia()):(na.set(e,S),ia())}function la(e){if(ea=e,!e){for(let e of ta.keys())na.delete(e);ta.clear()}ia()}function ua(e){Qi=e,ia()}function da(e){ta.delete(e.suiteId);let t=Qi?.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.`};na.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),ia()}function fa({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=$t({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=D(`div`,`coherence-journal-header`),s=D(`h3`,`dialog-title`,t);s.id=n;let c=w({variant:`secondary`,label:`Close`,action:`close-coherence-panel`,onClick:i});return o.append(s,c),a.dialog.append(o,...r),en(a.dialog,s.id),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function pa({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 c({sessionId:c,status:l,body:u,parts:f,paintBeforeRequest:p,buildRequest:m}){a?.close();let h=d(e),g=fa({dialogClass:t,titleText:n,titleId:`${h}-title`,body:u,onCloseRequest:()=>_.close()}),_={sessionId:c,status:l,parts:f,requestId:h,timer:null,close:()=>{o(_),a===_&&(a=null),g.close()}};a=_,p?.(),g.focusClose(),s(m(h))?_.timer=setTimeout(()=>{_.requestId=null,_.timer=null,l.textContent=`${r}: request timed out`},i):(_.requestId=null,l.textContent=`${r}: not connected`)}function l(e){let t=a;return!t||t.sessionId!==e.id||t.requestId===null||t.requestId!==e.requestId?null:(o(t),t)}return{open:c,settleResponse:l,currentPanel:()=>a}}var ma={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 ha(e){return e?.active!==!1||e.reason===kt.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,detailText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:on.broken}]}function ga(e){let t=ot.safeParse(e.kind);return{heading:`${t.success?ma[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function _a(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 va=new Map,ya=new Map,ba=pa({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function xa(e,t){ya.delete(e),t&&ya.set(e,t),Da(e)}function Sa(e){va.delete(e),ya.delete(e);let t=ba.currentPanel();t?.sessionId===e&&t.close()}function Ca(e){let t=va.get(e.id);t&&t.updatedAt>e.updatedAt||(va.set(e.id,e),Da(e.id))}function wa(e){va.clear();for(let[t,n]of Object.entries(e.sessions))va.set(t,n);let t=ba.currentPanel();t&&Da(t.sessionId)}function Ta(e){return ha(ya.get(e)??null).map(t=>({...t,onActivate:()=>Oa(e)}))}function Ea(e){return va.get(e)?.journal.ok===!0}function Da(e){let t=ba.currentPanel();if(!t||t.sessionId!==e)return;let n=_a(ya.get(e)??null,va.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>D(`p`,null,e)))}function Oa(e){let t=D(`div`,`coherence-journal-reading`),n=D(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=D(`div`,`coherence-journal-entries`);ba.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>Da(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function ka(e){let t=ba.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=ga(e),n=D(`article`,`coherence-journal-entry`);return n.append(D(`h4`,null,t.heading),D(`p`,null,t.text)),t.detail&&n.append(D(`p`,null,t.detail)),t.supersedes&&n.append(D(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var Aa=new Set([`waiting`,`monitoring`]);function ja(e){return Object.fromEntries(ue.flatMap(t=>{let n=Aa.has(t)?8:6;return[[`--state-${t}`,e[t]],[`--state-${t}-bg`,`color-mix(in oklab, var(--state-${t}) ${n}%, transparent)`]]}))}function Ma(e){return{...Object.fromEntries(Object.entries(e.chrome).map(([e,t])=>[`--${e}`,t])),...ja(e.states)}}var Na={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:`#008223`,yellow:`#92400e`,brightYellow:`#a16207`,blue:`#1d4ed8`,brightBlue:`#2563eb`,magenta:`#6d28d9`,brightMagenta:`#7c3aed`,cyan:`#0e7490`,brightCyan:`#00799a`}},Pa={dark:{black:`--border`,brightBlack:`--text-muted`,white:`--text`,brightWhite:`--text-head`},light:{black:`--text-head`,brightBlack:`--text-dim`,white:`--text-dim`,brightWhite:`--text`}},Fa=.35;function Ia(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 La(e){if(e.accentAnsiSlot===`none`)return{};let t=`bright${e.accentAnsiSlot[0].toUpperCase()}${e.accentAnsiSlot.slice(1)}`;return{[e.accentAnsiSlot]:`--accent`,[t]:Ia(e.chrome.accent,Fa)}}function Ra(e){return{label:e.label,colors:{...Ma(e),...Rn(e.mode)},terminal:{background:`--bg-card`,foreground:`--text`,cursor:`--accent`,cursorAccent:`--bg-card`,...Pa[e.mode],...Na[e.mode],...La(e)}}}var za={glimmer:Ra({label:`Glimmer`,mode:`dark`,accentAnsiSlot:`magenta`,chrome:{bg:`#0f0d15`,"bg-card":`#1b1721`,"bg-header":`#15121b`,"bg-surface":`#211d29`,border:`#3b3448`,"border-dim":`#2b2636`,"border-hover":`#4b435a`,text:`#cfcbd9`,"text-dim":`#b0aabf`,"text-head":`#efedf6`,"text-muted":`#9e97af`,accent:`#b688fe`,"accent-dim":`#7a4aba`},states:{running:`#22c55e`,waiting:`#f59e0b`,failed:`#f84d4c`,monitoring:`#60a5fa`,done:`#67e8f9`,initializing:`#7b8290`,idle:`#eab308`,starting:`#f472b6`,complete:`#34d399`}}),"glimmer-light":Ra({label:`Glimmer Light`,mode:`light`,accentAnsiSlot:`magenta`,chrome:{bg:`#f5f1fd`,"bg-card":`#fcfbfe`,"bg-header":`#ede9f6`,"bg-surface":`#e5e0f0`,border:`#c4bdd3`,"border-dim":`#d7d0e4`,"border-hover":`#b1a9c2`,text:`#292237`,"text-dim":`#4f4464`,"text-head":`#110c1a`,"text-muted":`#605378`,accent:`#6f2fb7`,"accent-dim":`#541791`},states:{running:`#157838`,waiting:`#a94e08`,failed:`#bf0814`,monitoring:`#0e728d`,done:`#5a697e`,initializing:`#686f7d`,idle:`#995d07`,starting:`#7c3aed`,complete:`#047a55`}}),golgari:Ra({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:Ra({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:Ra({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:Ra({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:Ra({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":Ra({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":Ra({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`}})},Ba=`glimmer`,Va=null,Ha=null,Ua=null,Wa={};function Ga(e){return Object.hasOwn(za,e)?za[e]:Wa[e]}function Ka(e){Wa=Object.fromEntries(e.map(({id:e,palette:t})=>[e,Ra(t)]));let t=Ua??Ba,n=Ga(t)?t:Ba;return n===Ha&&!Object.hasOwn(Wa,n)?!1:(Ja(n),!0)}function qa(e){Ua=e,Ga(e)&&Ja(e)}function Ja(e){let t=Ga(e);if(!t)return;let n=Ha;Ha=e;let r=document.documentElement;r.dataset.theme=e;for(let[e,n]of Object.entries(t.colors))r.style.setProperty(e,n);e===`unicorn`&&n!==null&&n!==`unicorn`&&Va?.()}function Ya(e){Va=e}function Xa(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function Za(){let e=Ga(Ha||Ba);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 Qa(){return{id:Ha,colors:{...Ga(Ha??Ba)?.colors}}}function $a(){return Object.entries({...za,...Wa}).map(([e,t])=>({id:e,label:t.label}))}function eo(){let e=Za();e.background&&e.foreground&&s({type:`terminal-colors`,background:e.background,foreground:e.foreground})}var to=3e4,no=24,ro=null,io=[`Android`,`iPhone`,`iPad`,`Windows`,`Mac OS X`,`Linux`],ao=[/Firefox\/\d+/,/Edg\/\d+/,/Chrome\/\d+/,/Version\/\d+/];function oo(){let e=navigator.userAgent,t=io.find(t=>e.includes(t))??`unknown platform`;return`${ao.map(t=>t.exec(e)?.[0]).find(e=>e!==void 0)?.replace(`Version`,`Safari`)??`unknown browser`} on ${t}`}function so(){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 co(){return[navigator.onLine?`online`:`offline`,...so()].join(` `)}function lo(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 uo(e,t){let n=e.join(` `);if(n.length<=t)return n;let r=t-no,i=lo(e,r/2),a=lo(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 fo(e){return e.marks.some(e=>e.startsWith(`terminal-bytes`))}function po(e){let t=fo(e)&&!e.isCapped?`terminal live`:`terminal not live after ${to/1e3} s`,n=`hidden ${Math.round(e.hiddenForMs/1e3)} s, ${t}, ${oo()}, ${e.networkAtWake}: `,r=n+uo(e.marks,Qe-n.length);return s({type:`client-log`,scope:`wake`,text:r.slice(0,Qe)})}function mo(){let e=ro;e&&(e.isCapped||fo(e))&&po(e)&&(ro=null,clearTimeout(e.capTimer))}function ho(){ro&&(ro.isCapped=!0,mo())}function go(e,t){e.marks.push(`${t}+${Math.round(performance.now()-e.startedAtMs)}`)}function _o(e){ro&&(e===`terminal-bytes`&&fo(ro)||(go(ro,e),(e===`terminal-bytes`||e===`control-opened`)&&mo()))}function vo(e){ro&&go(ro,e===`link`?[`link`,...so()].join(`-`):e)}function yo(e,t){ro||={startedAtMs:performance.now(),hiddenForMs:t,networkAtWake:co(),marks:[],isCapped:!1,capTimer:setTimeout(ho,to)},_o(e)}function bo(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function xo(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 So=null,Co=null;function wo(){return So}function To(){return So?Promise.resolve(So):(Co??=Promise.all([N(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.t),__vite__mapDeps([0,1])),N(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.r),__vite__mapDeps([0,1])),N(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.n),__vite__mapDeps([0,1]))]).then(([e,t,n])=>(So={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},So)).catch(e=>{throw Co=null,e}),Co)}var Eo=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,Do=new Map;function Oo(e){return e.clientWidth>0&&e.clientHeight>0}function ko(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 Ao(e){Do.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,ko(e)}function jo(e){let t=[e],n=M.snapshot().borrowedCardId,r=n?k.get(n):void 0;r&&t.push(r);for(let e of xo([...Do.keys()],Eo,t))Ao(e),e.needsWebGLReload=!0}function Mo(e){e?.term&&bo({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:Oo(e.termWrap)})&&Lo(e,{isForced:!0})}function No(){for(let e of Do.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{Ao(e),e.needsWebGLReload=!0}}}var Po=!1;function Fo(){Po||(Po=!0,requestAnimationFrame(()=>{Po=!1,No()}))}function Io(e){e?.addEventListener(`contextrestored`,Fo)}function Lo(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){Do.delete(e),Do.set(e,!0);return}e.webglAddon&&(ko(e),Do.delete(e));let n=wo();if(!n)return;jo(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,Do.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(Io),r.onAddTextureAtlasCanvas(Io),Io(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!Oo(e.termWrap),Do.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,Do.delete(e)}}var Ro=`(max-width: 768px)`,zo=`(pointer: coarse)`;function Bo({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var Vo=window.matchMedia?.(zo),Ho=window.matchMedia?.(Ro);function Uo(){return Bo({coarse:!!Vo?.matches,narrowWidth:!!Ho?.matches})}function Wo(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function Go(){M.subscribe((e,t)=>{t.includes(`layout`)&&Wo(e.layout)});let e=Uo();Wo(e),M.dispatch(`setLayout`,e);let t=()=>M.dispatch(`setLayout`,Uo());return Vo?.addEventListener?.(`change`,t),Ho?.addEventListener?.(`change`,t),e}function Ko(){return M.snapshot().layout===`phone`}function qo(e){return M.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var Jo=``,Yo=`\x1B`,Xo=`\r`,Zo=new Map([[`deleteContentBackward`,Jo],[`deleteByComposition`,Jo],[`deleteCompositionText`,Jo],[`deleteWordBackward`,Yo],[`deleteSoftLineBackward`,Yo],[`deleteHardLineBackward`,Yo]]);function Qo(e){return Zo.get(e)??``}var $o=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function es(e){return typeof e!=`string`||e===``||!$o.has(e)}function ts(e){return e?e.keyCode===229||e.key===`Process`:!1}function ns(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 Jo.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,Xo)}var rs=`Upload`;async function is(e,t){return or(rs,e),os(e,t)}async function as(e,t){or(rs,e);for(let n of t)await os(e,n)}async function os(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:(sr({source:rs,sessionId:e,message:await ss(r,t.name)}),!1)}catch{return sr({source:rs,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 ss(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 cs=new WeakMap,ls=5e3,us=15e3,ds=`The agent copied text. The browser needs a click before it can reach your clipboard.`,fs=`The clipboard is unavailable in this browser.`;function ps(e,t,n,r){let i=cs.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(()=>ms(e,t),n===`ok`?ls:us)))}function ms(e,t){let n=cs.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function hs(e){let t=e.buffer.active;return t.viewportY<t.baseY}function gs(e,t,{hasNewOutput:n=!1}={}){let r=cs.get(e)?.jumpToLatest;if(!r)return;let i=hs(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function _s(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 vs(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),ps(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function ys(e,t,n,r){let i=Nt(t);i?i.then(()=>{r&&ps(e,`clipboard`,`ok`,r)}).catch(t=>vs(e,n,t)):ps(e,`clipboard`,`error`,fs)}function bs(e,t){let n=cs.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function xs(e){let t=cs.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,ys(e,n,`osc52 write`,`Copied to the clipboard.`))}function Ss(e,t,n){let r=ar(`terminal-notice`),i=D(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=w({variant:`primary`,label:`Copy to clipboard`,onClick:()=>xs(t)});i.append(D(`span`,`terminal-clipboard-prompt-text`,ds),a);let o=D(`div`,`terminal-notices`);o.append(i,r.element);let s=D(`div`,`terminal-jump-latest`);s.hidden=!0,s.append(w({variant:`secondary`,label:`Jump to latest`,onClick:()=>{n.scrollToBottom(),n.focus()}}),D(`span`,`terminal-jump-latest-new-output`));let c=D(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(D(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),cs.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatest:s})}var Cs=1024,ws=`Keys you type now are held and sent once the terminal reconnects.`,Ts=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,Es=!1;function Ds(e){let t=e._inputQueue,n=e.dataWs;if(!Es&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,ms(e,`keys`)}}function Os(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!Es&&!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>=Cs?(ps(e,`keys`,`error`,Ts),!1):(e._inputQueue.push(t),r&&ps(e,`keys`,`busy`,ws),!0)}function ks(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,Ko()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=ns(i,r.value);return i=r.value,e!==``&&(Os(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{Ko()?n(e):a()},!0)};c(`keydown`,e=>{ts(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(!es(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=Qo(e.inputType);r!==``&&(Os(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function As(e){return!!e&&Array.from(e.types).includes(`Files`)}function js(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),as(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{As(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,As(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),as(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function Ms(e){Es=e}var Ns=6,Ps=262144,Fs=16384,Is=()=>{};function Ls(e,t){if(t.length<=Fs)e.push(t);else for(let n=0;n<t.length;n+=Fs)e.push(t.slice(n,n+Fs))}function Rs({budget:e=Ns,maxChunkBytes:t=Ps,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)Ls(l,e),m+=e.length,a.readIdx++;else{m===0&&(Ls(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,Is);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 zs=Rs(),Bs=[];function Vs(e){Bs=[...e]}function Hs(){return Bs}function Us(e){return e.state===`unreachable`&&e.lastError?`unreachable: ${e.lastError}`:e.state===`version-differs`?`version differs: host ${e.hostVersion??`unknown`}, this machine ${e.hubVersion}`:e.state}var Ws=new Map;function Gs(e){return Ws.get(e)??null}function Ks(e,t){Ws.set(e,t)}function qs(e){Ws.delete(e)}function Js(e){return[...Ws].flatMap(([t,n])=>n===e?[t]:[])}function Ys(e){let t=Gs(e);return t?`/hosts/${encodeURIComponent(t)}`:``}function Xs(e){let t=Gs(e);if(!t)return null;let n=Hs(),r=n.findIndex(e=>e.id===t);return{id:t,name:n[r]?.name??t,rank:r===-1?n.length:r}}var Zs=ne().int().min(1).max(500),Qs=ne().int().min(1).max(200);oe(`type`,[ae({type:re(`input`),data:se()}),ae({type:re(`claim`),cols:Zs,rows:Qs}),ae({type:re(`unview`)}),ae({type:re(`pause-output`)}),ae({type:re(`resume-output`)})]);var $s=ae({type:re(`pty-size`),cols:Zs,rows:Qs,seq:ne().int().nonnegative()}),ec=ae({type:re(`output-beat`)}),tc=oe(`type`,[$s,ec]),nc=`history`,rc=`output`,ic=`paused`;ie([`screen`,`deep`]);function ac(e){try{return JSON.parse(e)}catch{return null}}function oc(e){let t=tc.safeParse(ac(e));return t.success?t.data:null}var sc=new Set([1,5,25,100]);function cc(e){return e.isOutputPaused?`${e.history} paused`:e.history}function lc(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function uc(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function dc(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function fc({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&lc(e,n))}function pc({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function mc({isBorrowedCard:e,isTerminalFaceShown:t}){return!e||!t}function hc({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function gc(e,t,n){let r=new URLSearchParams;t&&r.set(nc,`deep`),n&&r.set(rc,ic);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function _c({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:fc({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function vc({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function yc({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!lc(e,t),s=uc(n)?dc(n):null,c=r&&!!s&&!lc(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:fc({authoritative:e,isActiveViewer:r,lastClaim:a})}}function bc(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function xc(e){let t=bc(e);return t===null?null:oc(t)}function Sc(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=xc(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 Cc=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,wc=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,P=`[^\\S\\r\\n]`,Tc=`${Cc}${P}*(?:=>|[:=])${P}*`,Ec=`[?&][A-Za-z0-9_.-]*`,Dc=`[^\\r\\n;&|]{0,200}?`,Oc=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,kc=RegExp(`(${Tc})${wc}`,`gi`),Ac=RegExp(`(\\bBearer${P}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),jc=[/\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],Mc=[RegExp(`((?:^|\\s)--?${Cc}${P}+)${wc}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${P}*=?${P}*)${wc}`,`g`),RegExp(`(-AsPlainText${P}+)${wc}`,`gi`),RegExp(`((?:^|\\s)setx${P}+[^\\s\\r\\n]*${Cc}[^\\s\\r\\n]*${P}+)${wc}`,`gi`)],Nc=[RegExp(`(\\bauthorization${P}*:${P}*Basic${P}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${P}+login\\b${Dc}${P}-p(?:${P}+|=))${wc}`,`gi`),RegExp(`(\\bcurl\\b${Dc}${P}(?:--user|-u)(?:${P}+|=)[^\\s:\\r\\n]+:)${wc}`,`gi`),RegExp(`(\\b${Oc}\\b${Dc}${P}-p)${wc}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi],Pc=[/-----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],Fc=RegExp(`(${Ec}(?:${Cc}|_key)=)[^&#\\s]+`,`gi`),Ic=[kc,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${wc}`,`g`)],Lc=[Ac,...Mc,...Nc,...jc,...Pc];function Rc(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function zc(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 Bc(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 Vc(e){let t=Rc(e,Fc);return Bc([...t,...Ic.flatMap(n=>zc(Rc(e,n),t)),...Lc.flatMap(t=>Rc(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var Hc=`•`.repeat(8),Uc=4;function Wc(e){let t=e.flatMap(e=>[e,...e.split(/\r?\n/)]).map(e=>e.trim());return[...new Set(t.filter(e=>e.length>=Uc))]}function Gc(e,t){let n=[];for(let r of Wc(t))for(let t=e.indexOf(r);t!==-1;t=e.indexOf(r,t+r.length))n.push({start:t,end:t+r.length});return n}function Kc(e,t=[]){let n=Bc([...Vc(e),...Gc(e,t)]);if(n.length===0)return e;let r=``,i=0;for(let t of n)r+=e.slice(i,t.start)+Hc,i=t.end;return r+e.slice(i)}var qc=`glimmervoid-streamer-mode`,Jc=new Set,Yc=xr(qc,!1)===!0;function Xc(e){document.documentElement.toggleAttribute(`data-streamer`,e)}Xc(Yc);function Zc(){return Yc}function Qc(e){if(br(qc,e),e!==Zc()){Yc=e,Xc(e);for(let t of Jc)t(e)}}function $c(e){return Jc.add(e),()=>Jc.delete(e)}async function el(e){try{let t=await c(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:ur});return t.type===`settings-error`?String(t.message):(Qc(e),``)}catch(e){return lr(e,ur)}}var tl=`Streamer mode`;async function nl(){let e=!Zc();e&&Qc(!0);let t=await el(e);t?sr({source:tl,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}):or(tl)}function rl(){nl()}var il=`#808080`,al=new WeakMap;function ol(e,t,n){return`${e}:${t}:${n}`}function sl(e){return ol(e.marker.line,e.x,e.width)}function cl(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function ll(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function ul(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function dl(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 fl(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 pl(e,t,n,r){let i=[];if(Vc(ul(e,t,n)).length===0)return i;let{text:a,cellAt:o}=dl(e,t,n,r);for(let e of Vc(a))fl(i,o.slice(e.start,e.end));return i}function ml(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=ll(e,i);r.push(...pl(e,i,t,n)),i=t+1}return r}function hl(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function gl(e){e.decoration.dispose(),e.marker.dispose()}function _l(e){for(let t of e.masks)gl(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function vl(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function yl(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 bl(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(sl(r),r),r=e.masks.at(-1);return yl(e),n}function xl(e,t){let n={normal:hl(),alternate:hl()},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??il,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(!Zc())return;let t=e.buffer.active,r=n[t.type],i=cl(t,vl(r,t)),a=bl(r,i);for(let e of ml(t,i)){let n=ol(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())gl(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){_l(n.normal),_l(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=>{_l(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=$c(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),al.delete(e)},{once:!0}),al.set(e,d)}function Sl(e){al.get(e)?.()}function Cl({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var wl=`-4 -4 108 108`,Tl=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`}]),El=`M50 39L61 50L50 61L39 50Z`,Dl=11,Ol=`#efedf6`,kl=`#b688fe`;function Al({frame:e,light:t,strokeWidth:n=Dl}){return`<path d="${Tl.map(({d:e})=>e).join(``)}" fill="none" stroke="${e}" stroke-width="${n}" stroke-linejoin="miter" stroke-linecap="butt"/><path d="${El}" fill="${t}"/>`}function jl(e,t){return mc({isBorrowedCard:M.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var Ml=new WeakMap,Nl=new WeakMap,Pl=new WeakSet,Fl=new WeakSet,Il=new WeakSet;function Ll(e,t){if(Ml.has(e)||!hs(t))return;let n=t.buffer.active,r=n.length-n.viewportY;Pl.has(e)?Ml.set(e,r):Nl.set(e,r)}function Rl(e,t,n){let r=e.term;r&&hc({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:Pl.has(e)})&&(Pl.add(e),Fl.add(e),Ml.set(e,r.buffer.active.length-n),fu(t))}var zl=new WeakMap;function Bl(e,t){return document.visibilityState===`visible`&&!jl(e,t)}function Vl(e,t){if(e&&nu(e,t))return;let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=Bl(e,t);zl.get(n)!==r&&(zl.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function Hl(){for(let[e,t]of k)Vl(t,e)}document.addEventListener(`visibilitychange`,Hl),M.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&Hl()});function Ul(e,t){return k.get(e)===t&&!t.dataWs}function Wl(e){return e.querySelector(`:scope > .terminal-connecting`)}function Gl(){let e=ce(`svg`,{class:`loading-mark`,viewBox:wl,"aria-hidden":`true`});for(let{side:t,d:n}of Tl)e.append(ce(`path`,{class:`loading-mark-bracket`,"data-side":t,d:n}));return e}function Kl(e){if(Wl(e))return;let t=D(`div`,`terminal-connecting`);t.append(Gl(),D(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}var ql=new Set,Jl=new WeakSet;function Yl(e){return ql.add(e),()=>ql.delete(e)}function Xl(){let e=0;for(let[t,n]of k)n.card.dataset.link===`connecting`&&Bl(n,t)&&e++;return e}function Zl(e){let t=Cl({hasTerminal:e.term!==null||Jl.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:Es}),n=t===`connecting`&&!Es&&Fl.has(e)?`live`:t;n===`none`?(delete e.card.dataset.link,Ql()):(e.card.dataset.link=n,Ql())}function Ql(){for(let e of ql)e()}function $l(e,t,n){Ll(t,n),zs.unregister(e),t.dataWs=null,Zl(t),t._resetGridClaim?.()}var eu=new WeakMap;function tu(e,t,n,r){$l(e,t,n),clearTimeout(eu.get(t)),eu.delete(t),r===0&&a()?du(e,t,n):eu.set(t,setTimeout(()=>{eu.delete(t),Ul(e,t)&&x().catch(()=>{}).then(()=>{Ul(e,t)&&du(e,t,n)})},r))}function nu(e,t){let n=Il.has(e),r=!e.dataWs&&k.get(t)===e;return!(n||r)||!e.term||!Bl(e,t)?!1:(Il.delete(e),e._dataWsRetryAttempt=0,tu(t,e,e.term,0),!0)}function ru(e,t,n){$l(e,t,n),Il.add(t)}var iu=15e3,au=new Map;function ou(e){if(!a()||au.has(e)||k.get(e)?.dataWs)return;let n=Ys(e)+gc(e,!1,!1),r=new WebSocket(ee(location,te(n)));r.binaryType=`arraybuffer`;let i=[],o=e=>i.push(e),s=()=>su(e,r),c=()=>{r.readyState===WebSocket.CONNECTING&&s()};r.addEventListener(`message`,o),r.addEventListener(`close`,s);let l=setTimeout(c,t),u=setTimeout(s,iu);au.set(e,{socket:r,attachPath:n,bufferedMessages:i,release:()=>{r.removeEventListener(`message`,o),r.removeEventListener(`close`,s),clearTimeout(l),clearTimeout(u)}})}function su(e,t){let n=au.get(e);n?.socket===t&&(au.delete(e),n.release(),t.close())}function cu(e,t){let n=au.get(e);if(!n)return null;let r=n.socket.readyState===WebSocket.CONNECTING||n.socket.readyState===WebSocket.OPEN;return n.attachPath!==t||!r?(su(e,n.socket),null):(au.delete(e),n.release(),n)}var lu=new WeakMap;function uu(e,t,n){if(t.openedAtMs===null)return;let r=Math.round(performance.now()-t.openedAtMs);if(r>=1e3){lu.delete(e);return}let i=(lu.get(e)??0)+1;if(lu.set(e,i),!sc.has(i))return;let a=n.wasClean?`clean`:`unclean`,o=t.hasReceivedBytes?`yes`:`no`;y(`terminal`,`fast close ${i}x, session ${t.sessionId}, code ${n.code}, reason '${n.reason}', ${a}, open ${r} ms, bytes ${o}, attach ${t.attachDescription}`)}function du(e,r,i){Il.delete(r);let a=Ml.get(r);Ml.delete(r);let o=Nl.get(r);Nl.delete(r);let s=a!==void 0,c=a??o,l=!1,u=Bl(r,e),d=Ys(e)+gc(e,s,!u),f=cu(e,d),p=f?.socket??new WebSocket(ee(location,te(d)));zl.set(p,u),p.binaryType=`arraybuffer`,r.dataWs=p,u&&_o(`terminal-connecting`),Zl(r);let m=!1,h=!1,g={sessionId:e,attachDescription:cc({history:s?`deep`:`screen`,isOutputPaused:!u}),openedAtMs:null,hasReceivedBytes:!1},_={hasSeenSize:!1,lastSeq:0},v=setTimeout(()=>{p.readyState===WebSocket.CONNECTING&&(h=!0,u&&_o(`terminal-abandoned`),p.close())},t);zs.register(e,(e,t)=>i.write(e,t));let y=t=>{if(r.dataWs!==p)return;let n=Sc(t.data,_);if(n.kind===`bytes`){g.hasReceivedBytes=!0,gr(r),zl.get(p)&&_o(`terminal-bytes`);let t=l;if(l=!1,zs.enqueue(e,n.data),!t)return;let a=c??0;zs.enqueueAction(e,()=>{i.scrollToLine(Math.max(0,i.buffer.active.length-a))});return}if(n.kind===`beat`){gr(r);return}if(n.kind===`attach-size`){l=c!==void 0,s||Pl.delete(r),_.hasSeenSize=!0,_.lastSeq=n.seq,i.reset(),Sl(i),r.ptySize={cols:n.cols,rows:n.rows},r._syncGrid?.();return}if(n.kind!==`size`)return;_.lastSeq=n.seq;let a={cols:n.cols,rows:n.rows};zs.enqueueAction(e,()=>{r.ptySize=a,r._syncGrid?.()})};p.addEventListener(`message`,y),p.addEventListener(`close`,t=>{if(clearTimeout(v),r.dataWs!==p)return;if(uu(r,g,t),u&&!h&&_o(`terminal-closed`),Fl.delete(r),m||h||Gs(e)||b(),!Bl(r,e)){ru(e,r,i);return}if(h){tu(e,r,i,0);return}let a=n(r._dataWsRetryAttempt||0);r._dataWsRetryAttempt=(r._dataWsRetryAttempt||0)+1,tu(e,r,i,a)});let x=()=>{clearTimeout(v),m=!0,g.openedAtMs=performance.now(),u&&_o(`terminal-opened`),r._dataWsRetryAttempt=0,Fl.delete(r),Zl(r),Vl(r,e),r._syncGrid?.({isActivationEdge:!0}),r._retryOwedGridClaim?.(),r._inputQueue?.length&&setTimeout(()=>{r.dataWs===p&&Ds(r)},50)};p.addEventListener(`open`,x),p.readyState===WebSocket.OPEN&&x();for(let e of f?.bufferedMessages??[])y(e)}function fu(e){let t=A(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,tu(e,t,t.term,0),n?.close()}function pu(){for(let[e,t]of k)t.term&&(Bl(t,e)?fu(e):mu(e,t,t.term))}function mu(e,t,n){let r=t.dataWs;r&&(ru(e,t,n),r.close())}function hu(){for(let[e,t]of k)t.term&&mu(e,t,t.term)}function gu(e,t){let n=e.dataWs;e.dataWs=null,zs.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}var _u=`CommitMono`,vu=[400,700].map(e=>`${e} 14px ${_u}`),yu=`monospace`;function bu(e){return e.trim().replace(/^['"]|['"]$/g,``)}function xu(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>bu(e)!==_u);return r.length>0?r.join(`, `):yu}function Su(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function Cu(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function wu(){return document.fonts?vu.every(e=>document.fonts.check(e)):!1}function Tu(){return xu(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),wu())}function Eu(e){document.fonts&&Su(document.fonts,vu,e)}var Du=()=>!1;function Ou(e){Du=e}function ku(){return Du()}var Au=Ar(navigator.userAgent),ju=`next-attention-keys`,Mu=mi();function Nu(){return Mu}function Pu(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(D(`span`,`shortcut-sep`,`+`)),e.appendChild(D(`kbd`,`kbd`,t))})}function Fu(e){let t=D(`span`,`shortcut-keys`);return Pu(t,e),t}function Iu(){let e=Fu(Vr(`next-attention`,Au,Mu));return e.classList.add(ju),e}function Lu(e){Mu=e;let t=Vr(`next-attention`,Au,e);for(let e of document.querySelectorAll(`.${ju}`))e.replaceChildren(),Pu(e,t)}var Ru=ae({title:se().optional(),iconDataUrl:se().startsWith(`data:image/`).optional()}),zu=new Set([`http:`,`https:`]);function Bu(e){let t;try{t=new URL(e)}catch{return null}return zu.has(t.protocol)?t.href:null}var Vu=/\bElectron\/\d/,Hu=new Set([`localhost`,`127.0.0.1`]);function Uu(e){return Vu.test(e)}function Wu({userAgent:e,pageHostname:t}){return Uu(e)&&Hu.has(t)}function Gu(e){return Bu(e)!==null}var Ku=new Set([0,1]);function qu({button:e,opensInNewTab:t}){return t&&Ku.has(e)}function Ju(){return Wu({userAgent:navigator.userAgent,pageHostname:location.hostname})}function Yu(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function Xu(e){try{let t=await x();return(await fetch(`/open-external`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})})).ok}catch{return!1}}var Zu=500,Qu=new Map;async function $u(e){try{let t=await x(),n=await fetch(`/link-preview`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})});if(!n.ok)return{};let r=Ru.safeParse(await n.json());return r.success?r.data:{}}catch{return{}}}function ed(e){return e.title!==void 0||e.iconDataUrl!==void 0}function td(e){let t=Qu.get(e);if(t)return t;let n=$u(e).then(t=>(!ed(t)&&Qu.get(e)===n&&Qu.delete(e),t));if(Qu.set(e,n),Qu.size>Zu){let e=Qu.keys().next().value;e!==void 0&&Qu.delete(e)}return n}function nd(e){!Ju()||!Gu(e)?Yu(e):Xu(e).then(t=>{t||Yu(e)})}function rd(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&qu({button:e.button,opensInNewTab:t.target===`_blank`})&&Gu(t.href)&&(e.preventDefault(),nd(t.href))}function id(e){Ju()&&(e.addEventListener(`click`,rd,!0),e.addEventListener(`auxclick`,rd,!0))}var ad={phase:`hidden`,isPointerOnLink:!1,isPointerOnPopup:!1},od=`*`,sd=/^[("'<[{]+|[)"'>\]}.,;:!?]+$/g,cd=new Set(`md.ts.tsx.js.jsx.mjs.cjs.json.py.rs.go.sh.txt.yml.yaml.toml.lock.html.css.rb.java.kt.swift.cs.php.sql.log.env.cfg.ini.xml.svg.png.jpg.gif.pdf.zip`.split(`.`)),ld=/^[a-z][a-z0-9+.-]*:\/\//i,ud=/\s/,dd=/\.[a-z]{2,63}$/i,fd=/^www\./;function pd(e){return!e.isPointerOnLink&&!e.isPointerOnPopup}function md(e){let t={...e,isPointerOnLink:!0};return e.phase===`shown`?{state:t,effects:[`cancel-hide`,`schedule-dwell`,`render`]}:e.phase===`pending`?{state:t,effects:[`schedule-dwell`]}:{state:{...t,phase:`pending`},effects:[`schedule-show`,`schedule-dwell`]}}function hd(e){let t={...e,isPointerOnLink:!1};return e.phase===`shown`&&pd(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function gd(e){let t={...e,isPointerOnPopup:!1};return e.phase===`shown`&&pd(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function _d(e,t){switch(t){case`enter-link`:return md(e);case`leave-link`:return hd(e);case`enter-popup`:return{state:{...e,isPointerOnPopup:!0},effects:e.phase===`shown`?[`cancel-hide`]:[]};case`leave-popup`:return gd(e);case`escape`:return e.phase===`hidden`?{state:e,effects:[]}:{state:{...e,phase:`hidden`,isPointerOnPopup:!1},effects:[`cancel-show`,`cancel-hide`,`cancel-dwell`,`remove`]};case`show-timer`:return e.phase===`pending`?e.isPointerOnLink?{state:{...e,phase:`shown`},effects:[`render`]}:{state:{...e,phase:`hidden`},effects:[]}:{state:e,effects:[]};case`hide-timer`:return e.phase!==`shown`||!pd(e)?{state:e,effects:[]}:{state:{...e,phase:`hidden`},effects:[`remove`]};case`dwell-timer`:return e.phase!==`shown`||!e.isPointerOnLink?{state:e,effects:[]}:{state:e,effects:[`fetch-preview`]}}}function vd(e){let{linkRange:t,rows:n,cellWidthPx:r,cellHeightPx:i,popupHeightPx:a,popupWidthPx:o,screenWidthPx:s}=e,c=(t.endRow+1)*i,l=t.startRow*i-a,u=n*i-c,d=t.startRow*i,f=Math.max(0,s-o),p=Math.min(Math.max(0,t.startCol*r),f);return!(u>=a)&&(d>=a||d>u)?{side:`above`,leftPx:p,topPx:Math.max(0,l)}:{side:`below`,leftPx:p,topPx:c}}function yd(e){try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?null:t}catch{return null}}function bd(e,t){let n=e.split(``);for(let e of t)n.fill(od,e.start,e.end);return n.join(``)}function xd(e,t){let n=yd(e);if(!n)return null;let r=n.username?`${n.username}${n.password?`:${n.password}`:``}@`:``,i=`${n.protocol}//${r}`,a=`${n.pathname===`/`&&!n.search&&!n.hash?``:n.pathname}${n.search}${n.hash}`;if(!t)return{scheme:i,host:n.host,rest:a};let o=bd(`${i}${n.host}${a}`,Vc(`${i}${n.host}${a}`)),s=i.length+n.host.length;return{scheme:o.slice(0,i.length),host:o.slice(i.length,s),rest:o.slice(s)}}function Sd(e){let t=e.trim().replace(sd,``);if(t.length===0||ud.test(t))return null;let n=yd(ld.test(t)?t:`https://${t}`);if(!n)return null;let r=n.hostname.replace(/\.$/,``);return!dd.test(r)||!ld.test(t)&&cd.has(r.slice(r.lastIndexOf(`.`)+1).toLowerCase())?null:r}function Cd(e,t){let n=e.replace(fd,``),r=t.replace(fd,``);return n===r||n.endsWith(`.${r}`)||r.endsWith(`.${n}`)}function wd(e,t){let n=yd(t);if(!n)return null;let r=Sd(e);if(!r)return null;let i=n.hostname.replace(/\.$/,``);return Cd(r,i)?null:{textHost:r,targetHost:i}}var Td=100,Ed=150,Dd=600,Od=16,kd=[`mousedown`,`mouseup`,`mousemove`,`click`,`dblclick`,`contextmenu`,`wheel`],Ad=!1;function jd(e){Ad=e}function Md(e){let t=D(`div`,`terminal-link-popup-url`),n=xd(e,Zc());return n?(t.append(D(`span`,`terminal-link-popup-url-dim`,n.scheme),D(`strong`,`terminal-link-popup-host`,n.host),D(`span`,`terminal-link-popup-url-dim`,n.rest)),t):(t.textContent=e,t)}function Nd(e){if(e.linkText===null)return null;let t=wd(e.linkText,e.url);if(!t)return null;let n=D(`div`,`terminal-link-popup-mismatch`);return n.append(`Text says `,D(`strong`,null,t.textHost),`, goes to `,D(`strong`,null,t.targetHost)),n}function Pd(e,t){if(!e||e.url!==t)return null;let{title:n,iconDataUrl:r}=e.preview;if(!n&&!r)return null;let i=D(`div`,`terminal-link-popup-preview`);if(r){let e=D(`img`,`terminal-link-popup-icon`);e.src=r,e.alt=``,e.width=Od,e.height=Od,i.append(e)}return n&&i.append(D(`span`,`terminal-link-popup-title`,n)),i}function Fd(e,t){let n=e.element,r=n?.querySelector(`.xterm-screen`);if(!n||!r)return{enterLink(){},leaveLink(){}};let i=n,a=r,o=t.abortController.signal,s=D(`div`,`xterm-hover terminal-link-popup`);s.hidden=!0,i.append(s);let c=ad,l=null,u=null,d=null,f=null,p=null,m=0;function h(){u!==null&&(clearTimeout(u),u=null)}function g(){d!==null&&(clearTimeout(d),d=null)}function _(){f!==null&&(clearTimeout(f),f=null)}function v(){let e=l?.url;Ad&&e&&td(e).then(t=>{Ad&&(p={url:e,preview:t},c.phase===`shown`&&l?.url===e&&ee())})}function y(e){e.key===`Escape`&&ne(`escape`)}function b(t){let n=a.getBoundingClientRect(),r=i.getBoundingClientRect(),o=e.buffer.active.viewportY;m=o;let c=vd({linkRange:{startRow:t.range.start.y-1-o,startCol:t.range.start.x-1,endRow:t.range.end.y-1-o},rows:e.rows,cellWidthPx:n.width/e.cols,cellHeightPx:n.height/e.rows,popupHeightPx:s.offsetHeight,popupWidthPx:s.offsetWidth,screenWidthPx:n.width});s.dataset.side=c.side,s.style.left=`${n.left-r.left+c.leftPx}px`,s.style.top=`${n.top-r.top+c.topPx}px`}function ee(){let e=l;if(!e)return;let n=D(`div`,`terminal-link-popup-footer`);n.append(D(`span`,`terminal-link-popup-hint`,`Click to open`),w({variant:`secondary`,size:`small`,label:`Copy link`,onClick:()=>ys(t,e.url,`link copy`,`Copied the link.`)}));let r=Nd(e);s.replaceChildren(...[Md(e.url),r,Pd(Ad?p:null,e.url),n].filter(e=>e!==null)),s.hidden=!1,b(e),document.addEventListener(`keydown`,y,{capture:!0,signal:o})}function te(){s.hidden=!0,s.replaceChildren(),document.removeEventListener(`keydown`,y,{capture:!0})}let x={"schedule-show":()=>{h(),u=setTimeout(()=>{u=null,ne(`show-timer`)},Td)},"cancel-show":h,"schedule-hide":()=>{g(),d=setTimeout(()=>{d=null,ne(`hide-timer`)},Ed)},"cancel-hide":g,"schedule-dwell":()=>{_(),f=setTimeout(()=>{f=null,ne(`dwell-timer`)},Dd)},"cancel-dwell":_,"fetch-preview":v,render:ee,remove:te};function ne(e){let t=_d(c,e);c=t.state;for(let e of t.effects)x[e]()}for(let e of kd)s.addEventListener(e,e=>e.stopPropagation(),{signal:o});s.addEventListener(`mouseenter`,()=>ne(`enter-popup`),{signal:o}),s.addEventListener(`mouseleave`,()=>ne(`leave-popup`),{signal:o});let re=e.onScroll(()=>{e.buffer.active.viewportY!==m&&ne(`escape`)}),ie=e.onResize(()=>ne(`escape`));return o.addEventListener(`abort`,()=>{h(),g(),_(),re.dispose(),ie.dispose(),s.remove()},{once:!0}),{enterLink(e){Ko()||(l=e,ne(`enter-link`))},leaveLink(){ne(`leave-link`)}}}var Id=/https?:\/\/[^\s<>"']+/g,Ld=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),Rd={")":`(`,"]":`[`,"}":`{`};function zd(e,t){let n=0;for(let r of e)r===t&&n++;return n}function Bd(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(Ld.has(t)){e=e.slice(0,-1);continue}let n=Rd[t];if(n&&zd(e,n)<zd(e,t))e=e.slice(0,-1);else return e}}function Vd(e){let t=[];for(let n of e.matchAll(Id)){let e=Bd(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var Hd=50;function Ud(e,t){return t.start.y===t.end.y?e.buffer.active.getLine(t.start.y-1)?.translateToString(!0,t.start.x-1,t.end.x)??null:null}function Wd(e,t){return{activate(e,t){nd(t)},hover(n,r,i){t.enterLink({url:r,linkText:Ud(e,i),range:i})},leave(){t.leaveLink()},allowNonHttpProtocols:!1}}function Gd(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<Hd;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<Hd;)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 Kd(e,t){let n=e.registerLinkProvider({provideLinks(n,r){let i=e.buffer?.active;if(!i)return r(void 0);let{text:a,cellAt:o}=Gd(i,n),s=[];for(let{start:e,end:n,url:r}of Vd(a)){let i=o[e],a=o[n-1];if(!i||!a)continue;let c={start:i,end:a};s.push({range:c,text:r,activate(e,t){nd(t)},hover(){t.enterLink({url:r,linkText:null,range:c})},leave(){t.leaveLink()}})}r(s.length?s:void 0)}}),r=qd(e);return{dispose(){r.dispose(),n.dispose()}}}function qd(e){let t=e.element?.querySelector(`.xterm-screen`);if(!t)return{dispose(){}};let n=null,r=e=>{e.isTrusted&&(n={clientX:e.clientX,clientY:e.clientY})},i=()=>{n=null},a=(e,n)=>{t.dispatchEvent(new MouseEvent(`mousemove`,{clientX:e,clientY:n,bubbles:!1}))};t.addEventListener(`mousemove`,r),t.addEventListener(`mouseleave`,i);let o=e.onRender(({start:r,end:i})=>{if(!n||t.classList.contains(`xterm-cursor-pointer`))return;let o=t.getBoundingClientRect(),s=o.height/e.rows;if(!(s>0))return;let c=Math.floor((n.clientY-o.top)/s);if(c<r||c>i)return;let l=c===0?s:-s;a(n.clientX,n.clientY+l),a(n.clientX,n.clientY)});return{dispose(){o.dispose(),t.removeEventListener(`mousemove`,r),t.removeEventListener(`mouseleave`,i)}}}var Jd=10,Yd=1.2,Xd=.005,Zd=4,Qd=.08,$d=5;function ef(e,t){let n=Math.abs(t);return n<Jd?!1:n>Math.abs(e)*Yd}function tf(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 nf(e,t,n){let r=e.length>=Zd?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function rf(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>=Qd))return 0;let o=Math.min(a,$d);return i<0?-o:o}function af({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function of(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)-Xd*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=tf(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function sf(e,t){return e===`alternate`||!!t&&t!==`none`}function cf(e,t){return!(e>0)||!(t>0)?0:e/t}var lf=1;function uf(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function df(e,t){for(let n of e)if(n.identifier===t)return n;return null}function ff(e,t){if(uf(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=()=>sf(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return cf(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:lf,clientX:n,clientY:r,bubbles:!0,cancelable:!0}))},_=()=>{if(d=null,!u)return;if(!e.isConnected||!n()||p()){f();return}let r=t.buffer?.active?.viewportY,{scrollLines:i,state:a}=of(u,performance.now());u=a,i!==0&&t.scrollLines(i),u&&(i!==0&&t.buffer?.active?.viewportY===r?f():d=requestAnimationFrame(_))},v=(e,t,n)=>{u=af({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:m(),pendingPx:n}),u&&(d=requestAnimationFrame(_))};e.addEventListener(`touchstart`,e=>{if(f(),!n()||e.touches.length!==1){h();return}let t=e.touches[0];r=t.identifier,i=t.clientX,a=t.clientY,o=t.clientY,s=!1,c=0,l=[]},{passive:!0}),e.addEventListener(`touchmove`,e=>{if(r===null||!n())return;let u=df(e.touches,r);if(!u)return;if(!s){if(!ef(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=nf([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=nf(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=tf(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=nf(l,o,e.timeStamp);let t=rf(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function pf(e){let t=Hr(e,Au,{isTerminalFocused:!0},Nu());return!t||t.action===`board-split`&&!ku()?!1:Ir(t,document.body.dataset.activeView)}var mf=250,hf=`(max-width: 768px)`,gf=12,_f=14,vf=5e4,yf=!1;function bf(e){yf=e}var xf=!1;window.addEventListener(`blur`,()=>{xf=!0}),window.addEventListener(`focus`,()=>{xf=!1});function Sf(e){let t=document.activeElement;return pc({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:xf,isPhoneLayout:Ko()})}function Cf(e,t,n){let r=window.matchMedia?.(hf).matches?gf:_f,i=new n.Terminal({cursorBlink:yf,fontSize:r,fontFamily:Tu(),theme:Za(),scrollback:vf,allowProposedApi:!0}),a=new n.FitAddon;i.loadAddon(a),Kl(e),i.open(e),Ss(e,t,i);let o=Fd(i,t);i.options.linkHandler=Wd(i,o),Kd(i,o),xl(i,t.abortController.signal),t.term=i,t.fitAddon=a,Ao(t);let s=null,c=null,l=!1,u=null,d=null;function f(){c!==null&&(clearTimeout(c),c=null)}function p(){if(!l)return null;let e=t.fitAddon;if(!e)return null;let n=e.proposeDimensions();return n?{cols:n.cols,rows:n.rows}:null}function m(e){if(!l||!Sf(t.card)||t.dataWs?.readyState!==WebSocket.OPEN)return!1;t.dataWs.send(JSON.stringify({type:`claim`,cols:e.cols,rows:e.rows})),u=e,d=null;let n=fc({authoritative:t.ptySize??null,isActiveViewer:l,lastClaim:u});return t.card.dataset.grid=n?`following`:`exact`,!0}function h(e){f(),d=e,c=setTimeout(()=>{c=null,m(e)},mf)}function g(){d&&c===null&&m(d)}function _({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=yc({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:p(),isActiveViewer:l,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:u});r.resizeTo&&n.resize(r.resizeTo.cols,r.resizeTo.rows),t.card.dataset.grid=r.isFollowing?`following`:`exact`,r.keepsPendingSettle||(f(),d=null),r.sendUnview?(u=null,t.dataWs?.send(JSON.stringify({type:`unview`}))):r.owedClaim&&(e&&m(r.owedClaim)||h(r.owedClaim))}function v(){let e=_c({authoritative:t.ptySize??null,isActiveViewer:l,isDocumentEngaged:Sf(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:u});e!==`none`&&(f(),e===`rebid`&&(u=null),_({isActivationEdge:!0}))}let y=new ResizeObserver(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,_()}))});y.observe(e),t.resizeObserver=y,t._syncGrid=_,t._resetGridClaim=()=>{f(),d=vc({isActiveViewer:l,lastClaim:u,owedClaim:d}),u=null},t._retryOwedGridClaim=g,t._syncGridOnEngagementEdge=v,t._isActiveViewer=()=>l,t._setActiveViewer=e=>{l!==e&&(l=e,f(),d=null,e&&Mo(t),_({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{xf=!1,v()},{signal:t.abortController.signal}),Lo(t);let b=null;i.onScroll(()=>{b===null&&(b=requestAnimationFrame(()=>{b=null,t.term&&(t.term.refresh(0,t.term.rows-1),gs(t,t.term))}))}),i.onWriteParsed(()=>gs(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=_s(r)}catch(e){return vs(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(ys(t,i,`osc52 write`),!0):(bs(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`&&Os(t,`\x1B\r`),!1;if(e.type!==`keydown`)return!0;if(pf(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),ys(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(Os(t,`\x1B`),!1):!0}),ks(e,i,t),ff(e,i)}function wf(){Ms(!0);for(let e of k.values())Zl(e)}function Tf(){Ms(!1);for(let e of k.values())Zl(e),Ds(e)}function Ef(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{Os(e,n),e.unseenOutcome&&s({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{Rl(e,t,n)}),js(e.termWrap,t,e.abortController.signal),Zl(e),queueMicrotask(()=>{Ul(t,e)&&du(t,e,n)}))}function Df(e,t){if(e.term||Jl.has(e))return;let n=wo();if(n){Of(e,t,n);return}Jl.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},Kl(e.termWrap),Zl(e),To().then(n=>{Jl.delete(e),e.term||e.abortController.signal.aborted||k.get(t)!==e||(Of(e,t,n),e._setActiveViewer?.(r))},()=>{Jl.delete(e),Zl(e)})}function Of(e,t,n){Cf(e.termWrap,e,n),Ef(e,t)}function kf(e){e?._syncGridOnEngagementEdge?.()}function Af(e,t){if(!e)return;Df(e,t),Vl(e,t),Mo(e);let n=e.term;n&&(n.refresh(0,n.rows-1),kf(e))}function jf(e,t,n){e&&(n&&Df(e,t),e._setActiveViewer?.(n))}var Mf={isVisible:document.visibilityState===`visible`,isFrozen:!1,isProbing:!1,isReplacing:!1},Nf=document.visibilityState===`visible`?null:Date.now(),Pf=null,Ff=null;function If(){Pf!==null&&window.clearTimeout(Pf),Pf=null}function Lf(e){If();let t=Date.now()+e;Pf=window.setTimeout(()=>{Pf=null,Bf({kind:`heartbeat-due`,lateByMs:Date.now()-t})},e)}function Rf(){Ff!==null&&window.clearTimeout(Ff),Ff=null}function zf(e){switch(e.kind){case`probe-control`:_(e.deadlineMs,e.isAnnounced).then(e=>{Bf({kind:e?`pong`:`pong-missed`})});return;case`replace-control`:o();return;case`close-sockets`:Rf(),v(),hu();return;case`reconnect-shown-terminals`:pu();return;case`hold-input`:wf();return;case`release-input`:Tf();return;case`schedule-heartbeat`:Lf(e.inMs);return;case`cancel-heartbeat`:If();return}}function Bf(t){let n=e(Mf,t);Mf=n.state;for(let e of n.actions)zf(e)}function Vf(){if(document.visibilityState!==`visible`){Nf=Date.now(),Bf({kind:`hidden`});return}let e=Nf===null?0:Date.now()-Nf;Nf=null,yo(`shown`,e),Bf({kind:`shown`,hiddenForMs:e})}function Hf(e){Rf(),_o(`control-${e}`),e===`connecting`?Ff=window.setTimeout(()=>{Ff=null,Bf({kind:`handshake-overdue`})},t):(e===`opened`&&eo(),Bf({kind:e===`opened`?`control-opened`:`control-closed`}))}function Uf(){yo(`resumed`,Nf===null?0:Date.now()-Nf),Bf({kind:`resumed`})}function Wf(){let e=Reflect.get(navigator,`connection`);e instanceof EventTarget&&e.addEventListener(`change`,()=>{vo(`link`),Bf({kind:`network-changed`})})}function Gf(){m(Hf),document.addEventListener(`visibilitychange`,Vf),document.addEventListener(`freeze`,()=>Bf({kind:`frozen`})),document.addEventListener(`resume`,Uf),window.addEventListener(`pagehide`,e=>{e.persisted&&Bf({kind:`frozen`})}),window.addEventListener(`pageshow`,e=>{e.persisted&&Uf()}),window.addEventListener(`online`,()=>{vo(`online`),Bf({kind:`network-changed`})}),window.addEventListener(`offline`,()=>vo(`offline`)),Wf()}var Kf=!1,qf=!1,Jf=!1,Yf=null,Xf=null;function Zf(){return Xf??=N(()=>import(`./nyan-cat-Dn8SmAZc.js`).then(e=>e.r).then(e=>(Yf=e,e),e=>(Xf=null,y(`flying-animals`,`nyan cat failed to load: ${l(e)}`),null)),__vite__mapDeps([2,1,3,4,5,6,7,8])),Xf}function Qf(e){!Jf||e.currentFlightBlockReason(!0)?e.stopNyanCat():e.startNyanCat()}function $f(){qf=!0,ep(zr())}function ep(e){let t=document.documentElement;Kf||(Kf=!0,qo(()=>ep(zr())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>ep(zr()))),Jf=e,e?(t.dataset.flyingAnimals=`true`,Yf?Qf(Yf):qf&&Zf().then(e=>{e&&Qf(e)})):(delete t.dataset.flyingAnimals,Yf?.stopNyanCat())}var tp=45e3,np=`The server did not answer within ${tp/1e3} s.`,rp=`Select the issue to load its description.`,ip=null,ap=null,op=new Map,sp=null,cp=new Map,lp=new Map,up=null,dp=new Map,fp=new Map,pp=new Map,mp=new Map,hp=new Set;function F(e){for(let t of hp)t(e)}function gp(e){return`${e.key}:${e.updatedAt}`}function _p(e){let t=cp.get(e);t&&(cp.delete(e),dp.set(t.issueKey,{text:np,tone:`error`}),F(`detail`))}function vp(e){let t=cp.get(e);return t?(clearTimeout(t.timeoutHandle),cp.delete(e),t):null}function yp(){return{latestStatus:ap,issueByKey:op,selectedKey:ip}}function bp(e){hp.add(e)}function xp(e){ip=e,up&&up.issue.key!==e&&(up=null)}function Sp(){if(ip)return op.get(ip)??(up?.issue.key===ip?up.issue:void 0)}function Cp(e){return up?.issue.key===e.key&&up.isClosed}function wp(e){return[...lp.values()].some(t=>t.issue.key===e.key)}function Tp(e,t){if(wp(e))return;let n=d(`set-issue-state`);sp?.({type:`set-issue-state`,requestId:n,repo:e.repo,issueNumber:e.number,state:t})?(lp.set(n,{issue:e,state:t,timeoutHandle:setTimeout(()=>{lp.delete(n),dp.set(e.key,{text:np,tone:`error`}),F(`detail`)},tp)}),dp.set(e.key,{text:t===`closed`?`Closing issue.`:`Reopening issue.`,tone:`busy`}),F(`detail`)):(dp.set(e.key,{text:S,tone:`error`}),F(`detail`))}function Ep(e){let t=lp.get(e.requestId);if(!t)return;clearTimeout(t.timeoutHandle),lp.delete(e.requestId);let{issue:n,state:r}=t;e.ok?(up={issue:n,isClosed:r===`closed`},dp.set(n.key,{text:r===`closed`?`Closed as completed.`:`Reopened.`,tone:`ok`}),F(`detail`)):(dp.set(n.key,{text:e.error||`Could not ${r===`closed`?`close`:`reopen`} the issue.`,tone:`error`}),F(`detail`))}function Dp(e){return[...cp.values()].some(t=>t.issueKey===e.key)}function Op(e){return dp.get(e.key)}function kp(e){let t=gp(e),n=pp.get(t);return n===``?`No description.`:n??mp.get(t)??`Loading description.`}function Ap(e){let t=gp(e);if(pp.has(t)||[...fp.values()].some(e=>e.cacheKey===t))return;let n=d(`issue-detail`);mp.delete(t),sp?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?fp.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{fp.delete(n),mp.set(t,`${np} ${rp}`),F(`detail`)},tp)}):mp.set(t,`${S} ${rp}`)}function jp(e){let t=e.projectId;if(!t||Dp(e))return;let n=d(`open-issue-session`);sp?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(cp.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>_p(n),tp)}),dp.set(e.key,{text:`Opening session.`,tone:`busy`}),F(`detail`)):(dp.set(e.key,{text:S,tone:`error`}),F(`detail`))}function Mp(e){sp?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function Np(e){sp=e}function Pp(){F(`session-state`)}function Fp(e){if(!e){for(let e of cp.values())clearTimeout(e.timeoutHandle),dp.set(e.issueKey,{text:S,tone:`error`});cp.clear();for(let e of lp.values())clearTimeout(e.timeoutHandle),dp.set(e.issue.key,{text:S,tone:`error`});lp.clear();for(let e of fp.values())clearTimeout(e.timeoutHandle),mp.set(e.cacheKey,`${S} ${rp}`);fp.clear(),F(`status`)}}function Ip(e){let t=ap?.issues.find(e=>e.key===ip);ap=e,op=new Map(e.issues.map(e=>[e.key,e])),up&&!up.isClosed&&op.has(up.issue.key)&&(up=null);let n=e.issues.find(e=>e.key===ip);n&&n.updatedAt!==t?.updatedAt&&Ap(n),F(`status`)}function Lp(e){let t=fp.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),fp.delete(e.requestId),e.ok&&e.body!==null&&pp.set(t.cacheKey,e.body),e.ok&&e.body!==null||mp.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),F(`detail`))}function Rp(e){if(typeof e.requestId!=`string`)return;let t=vp(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`;dp.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=ap?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),F(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;dp.set(n,{text:r,tone:`error`}),F(`detail`)}var zp=new Map,Bp=new Set;function Vp(e){let t=Re.safeParse(e);if(!t.success)y(`reviews`,`dropped github-prs: ${r(t.error.issues)}`);else{zp=new Map(Object.entries(t.data.prs));for(let e of Bp)e()}}function Hp(e){return zp.get(e.toLowerCase())}function Up(e){Bp.add(e)}var Wp=20,Gp=[],Kp=null,qp=!1,Jp=0,Yp=null;function Xp(){return Yp??=N(()=>import(`./celebration-player-C2GC0Ycy.js`),__vite__mapDeps([9,10,6,3,4,5,7])).catch(e=>(Yp=null,y(`merge-celebration`,`celebration player failed to load: ${l(e)}`),null)),Yp}function Zp(e){return qp?`playing`:e?`queued`:`empty`}function Qp(){if(!Kp)return;let e=Gp.length>0,t=Zp(e);Kp.tray.dataset.state=t,Kp.count.textContent=e?String(Gp.length):``,Kp.toggle.element.disabled=t!==`queued`,Kp.toggle.setState(t===`queued`?`attention`:`idle`)}function $p(){let e=Gp.shift();if(qp=e!==void 0,Qp(),!e)return;let t=Jp;Jp+=1,Xp().then(n=>{n?(n.playCelebration(e,t),window.setTimeout($p,n.CELEBRATION_DURATION_MS)):(Gp.unshift(e),qp=!1,Qp())})}function em(e,t,n){Kp={tray:e,toggle:t,count:n},t.element.addEventListener(`click`,()=>{Jp=0,$p()}),Qp()}function tm(e){Gp.push(e),Gp.length>Wp&&Gp.shift(),Qp()}var nm={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},rm=new Set([`FAILURE`,`ERROR`]);function im(e){return nm[e]}function am(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&&rm.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function om(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 sm(e){let t=Ft.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:om(t)}}var cm=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],lm=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],um={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`},dm={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`},fm={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`},pm={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 mm(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 hm(e){return cm[e.rows.reduce((e,{pr:t})=>Math.min(e,cm.indexOf(um[t.stage])),cm.length-1)]}function gm(e){let t=new Map(cm.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of mm(e)){let e=t.get(hm(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return lm.flatMap(e=>t.get(e)??[])}function _m(e,t){return mm(e).find(e=>e.rows.some(e=>e.pr.key===t))?.rows??[]}function vm(e){return e.stackSize<2?null:`Stack ${e.depth+1}/${e.stackHeight}`}function ym(e){return dm[e]}function bm(e){return fm[e]}function xm(e){return pm[e]}function Sm(e){return e?.isKeepMergeableEnabled!==!1}function Cm(e,t){if(!t||!e.keepMergeable||e.isKeepMergeableFixInFlight)return!1;let n=e.keepMergeableAttempt?.outcome;return n!==void 0&&n!==`pushed`&&n!==`stopped`}function wm(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...sm({...n,repo:r}),...e}]})}function Tm(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 Em(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 Dm=3;function Om(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,Dm).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 km(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:bt(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,isAuthorOrgMember:n.isAuthorOrgMember,liveHead:n.headRefOid,prStage:sm(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n)}}var Am=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`];function jm(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 Mm(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function Nm(e){return e.status===`posted`&&Pm(e)}function Pm(e){if(!Mm(e)||xt(e))return!1;let t=zm(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 Fm(e){return Bm(e).length>0||Nm(e)}function Im(e){return Fm(e)?`actionable`:jm(e).band}function Lm(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[jm(t).band].push(t);for(let e of Am)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(Fm(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!Vm(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[Im(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 Am)t.ready.push(...n[e]);return t}function Rm(e,t){return e.commit===t?e.isViewer||qt.has(e.state):!1}function zm(e){return e.liveHead??e.reviewedHead}function Bm(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function Vm(e){return Bm(e).length>0?!0:xt(e)?!1:Pm(e)?!0:!(e.githubReviews??[]).some(t=>Rm(t,zm(e)))}function Hm(e,t){return`${e}#${t}`}var Um=null,Wm={},Gm=[],Km=[],qm={},Jm={},Ym=[],Xm={},Zm={},Qm={},$m=null,eh=new Set,th=new Map,nh=!1,rh=new Set;function ih(e){for(let t of rh)t(e)}function ah(){return[...th].flatMap(([e,t])=>{let n=k.get(e);return!n||t.length===0?[]:[{id:e,title:Kn(n)||e,links:t}]})}function oh(){let e=wm(Um?.prs??[],Hp),t=Em($m,e);$m=e,uh(t),ih({kind:`prs`})}function sh(){nh||(nh=!0,queueMicrotask(()=>{nh=!1,oh()}))}function ch(e){rh.add(e)}function lh(){return{prs:wm(Um?.prs??[],Hp).map(e=>({...e,reviewItems:Jm[e.key]??e.reviewItems})),status:Um,sessionsByPrKey:Tm(ah()),handledByPr:Wm,prFlowWarnings:Gm,prFlowApprovals:Km,sourceRunsByPr:qm,prFlowActions:Ym,actionRunsByPr:Xm,prActionsByPr:Zm,prActionRunsByPr:Qm}}function uh(e){let t=e.filter(e=>!eh.has(e.key));if(t.length!==0){for(let e of t)eh.add(e.key);tm(Om(t))}}function dh(e){th=e,sh()}function fh(){ih({kind:`session-state`})}function ph(e){let t=Jt.safeParse(e);t.success?(Um=t.data,oh()):y(`reviews`,`dropped my-prs-status: ${r(t.error.issues)}`)}function mh(e){let t=At.safeParse(e);t.success?(Wm=t.data.handledByPr,Gm=t.data.warnings,Km=t.data.pendingApprovals,qm=t.data.sourceRunsByPr,Jm=t.data.reviewItemsByPr,Ym=t.data.actions,Xm=t.data.actionRunsByPr,Zm=t.data.prActionsByPr,Qm=t.data.prActionRunsByPr,ih({kind:`prs`})):y(`reviews`,`dropped pr-flows-status: ${r(t.error.issues)}`)}function hh(e){ih({kind:`merge-result`,message:e})}function gh(e){ih({kind:`connection`,isConnected:e})}Up(sh);var _h=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-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-queued`,group:`queued`,kind:null,action:null},{state:`mine-merged`,group:`done`,kind:null,action:null},{state:`review-settled`,group:`done`,kind:null,action:null},{state:`review-discarded`,group:`parked`,kind:null,action:null},{state:`mine-draft`,group:`parked`,kind:null,action:null}].map((e,t)=>[e.state,{...e,rank:t}])),vh={turn:`Your turn`,working:`Agent working`,queued:`Queued`,waiting:`Waiting on others`,done:`Done`,parked:`Parked`,aside:`Set aside`},yh=[`turn`,`working`,`queued`,`waiting`,`done`,`parked`],bh=new Set([`done`,`parked`]),xh=[`queued`,`working`,`turn`,`now`,`waiting`,`done`,`parked`],Sh={...vh,turn:`Ready`,now:`Reviewing now`};function Ch(e){return xh.map(t=>e.find(e=>e.id===t)??{id:t,title:Sh[t],items:[]})}function wh(e,t){let n=new Set(tg(e).map(e=>e.key)),r=t.filter(e=>n.has(e)),i=new Set(r);return{groups:e.flatMap(e=>e.id===`turn`?[{id:`now`,title:Sh.now,items:e.items.filter(e=>i.has(e.key))},{id:`turn`,title:Sh.turn,items:e.items.filter(e=>!i.has(e.key))}]:[e]),pulledKeys:r}}function Th({pulledKeys:e,key:t,turnKeys:n,limit:r}){return e.includes(t)?e.filter(e=>e!==t):r>0&&e.length>=r||!n.includes(t)?[...e]:[...e,t]}function Eh(e,t){return t>0?`${e} / ${t}`:String(e)}var Dh={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`},Oh={settled:`review-settled`,inReview:`review-in-flight`,queued:`review-queued`,posted:`review-posted`,discarded:`review-discarded`},kh=Am.indexOf(`waiting-on-author`);function Ah(e){return e.status===`ready`?jm(e).band===`blocking-others`?`review-direct-ask`:`review-ready`:`review-follow-up`}function jh(e,t){return t===`ready`?Ah(e):t===`attention`?`status`in e&&e.status===`error`?`review-failed`:`review-stale`:Oh[t]}function Mh(e,t,n){let r=e.state===`OPEN`;if(r&&Cm(e,n))return`mine-repair-failed`;if(r&&n&&e.keepMergeable&&e.isKeepMergeableFixInFlight)return`mine-repairing`;let i=Dh[e.stage];return _h.get(i)?.group===`turn`&&e.stage!==`ready`&&t.has(De(e))?`mine-agent-fixing`:i}function Nh(e,t){return t===`ready`||t===`attention`?Am.indexOf(Im(e)):t===`queued`?Am.indexOf(jm(e).band):0}function Ph(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function Fh(e){let t=Bm(e).flatMap(e=>Ph(e.lastReplyAt)??[]);return t.length>0?Math.max(...t):null}function Ih(e,t){if(t===`inReview`)return Ph(e.startedAt)??1/0;if(t===`queued`)return Ph(e.prCreatedAt)??1/0;let n=e,r=t===`posted`?Ph(n.postedAt):null;return Fh(n)??r??Ph(n.reviewedAt)??Ph(n.prCreatedAt)??1/0}function Lh(e){return Ph(e.mergedAt??e.stageSinceMs??e.updatedAt)??1/0}var Rh=864e5,zh=3*Rh;function Bh(e){return e.source===`team`?Ih(e.review,e.kind):Lh(e.pr)}function Vh(e,t,n){if(e===`done`||e===`parked`||!Number.isFinite(t))return null;let r=n-t;return r>zh?`old`:r>=Rh?`aging`:`fresh`}function Hh(e,t){return t>0&&e>t}function Uh(e,t,n,r){let i=_h.get(e);return i?[{item:r(i),row:i,priorityBandRank:t,waitStartMs:n}]:[]}function Wh(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=>Uh(jh(t,e),Nh(t,e),Ih(t,e),({action:n,kind:r})=>({source:`team`,key:`team:${t.key}`,prKey:De(t),kind:e,review:t,action:n,attention:r}))))}function Gh(e,t,n){return gm(e).flatMap(e=>e.rows).flatMap(e=>Uh(Mh(e.pr,t,n),0,Lh(e.pr),({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 Kh(e){return e.row.kind===`failed`?0:e.row.state===`review-direct-ask`?1:e.priorityBandRank>=kh?3:2}function qh(e,t){let n=e.waitStartMs-t.waitStartMs;return e.row.group===`turn`?Kh(e)-Kh(t)||n||e.item.key.localeCompare(t.item.key):e.row.rank-t.row.rank||e.priorityBandRank-t.priorityBandRank||n}function Jh(e,t,n,r){let i=new Map(yh.map(e=>[e,[]]));for(let a of[...Wh(e),...Gh(t,n,r)])i.get(a.row.group)?.push(a);return yh.map(e=>({id:e,title:vh[e],items:(i.get(e)??[]).toSorted(qh).map(e=>e.item)}))}var Yh=[`turn`,`working`,`aside`],Xh=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 Zh(e){return e.status===`ready`&&e.verdict?`ready-${e.verdict}`:e.status}function Qh(e){let t=Date.parse(e.item.createdAt);return Number.isNaN(t)?1/0:t}function $h(e){let t=e.flatMap(e=>{let t=Xh.get(Zh(e));return t?[{row:t,askedAtMs:Qh(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 Yh.map(e=>({id:e,title:vh[e],items:t.filter(t=>t.row.group===e).map(e=>e.item)}))}function eg(e){return`${e.key}@${e.entry.status}:${e.entry.finishedAt??``}`}function tg(e){return e.find(e=>e.id===`turn`)?.items??[]}function ng(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function rg(e,t){return ng(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function ig(e){return e.source===`mine`?Hm(e.pr.repo,e.pr.number):Hm(e.review.repo,e.review.number)}function ag(e,t){return tg(e).map(e=>({id:e.key,kind:e.attention??`waiting`,name:t(e)}))}function og(e){return ag(e,ig)}function sg(e,t){return og(e).filter(e=>e.id!==t)}function cg({capturedOrder:e,actedKey:t,groups:n}){let r=tg(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}var lg=new Set([`turn`,`now`]);function ug(e,t){let n=e.find(e=>lg.has(e.id)&&e.items.some(e=>e.key===t));return n?`${n.items.findIndex(e=>e.key===t)+1} of ${n.items.length} in ${n.title}`:``}function dg(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 fg(e){return tg(e).map(dg)}function pg({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:dt([...i]),unseen:dt([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:dt([...a]),unseen:dt([...o])}}function mg(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 hg(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function gg(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)??t.find(e=>e.watcherProblem)??n[0],isRefreshing:t.some(e=>e.isRefreshing)}}var _g=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`],[`m`,`toggle-pulled`],[`h`,`previous-column`],[`l`,`next-column`],[`ArrowLeft`,`previous-column`],[`ArrowRight`,`next-column`]]);function vg(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`:_g.get(e.key)??null}function yg(e,t,n){let r=e.filter(e=>e.length>0);if(r.length===0)return null;let i=r.findIndex(e=>t!==null&&e.includes(t));if(i===-1)return r[0][0];let a=r[i].indexOf(t??``),o=r[Math.min(r.length-1,Math.max(0,i+n))];return o[Math.min(a,o.length-1)]}function bg(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 xg=null,Sg=null,Cg=new Set;function wg(e){for(let t of Cg)t(e)}function Tg(){Sg=km(xg,Hp),wg({kind:`status`})}function Eg(e){Cg.add(e)}function Dg(){return Sg}function Og(){return Lm(Sg)}function kg(e){let t=wt.safeParse(e);t.success?(xg=t.data,Tg()):y(`reviews`,`dropped team-review-status: ${r(t.error.issues)}`)}function Ag(e){wg({kind:`action-result`,message:e})}function jg(e){wg({kind:`open-session-result`,message:e})}function Mg(e){wg({kind:`connection`,isConnected:e})}Up(Tg);var Ng=[],Pg=null,Fg=null,Ig=null,Lg=!1,Rg=null,zg=Xr(),Bg=li(),Vg=new Set(Bg.split(`|`).filter(Boolean)),Hg=new Set,Ug=new Set;function Wg(e){for(let t of Ug)t(e)}function Gg(e){e!==zg&&(zg=e,Ur(e))}function Kg(e){e!==Bg&&(Bg=e,Vg=new Set(e.split(`|`).filter(Boolean)),Fr(e))}function qg(){return Dg()!==null&&lh().status!==null}function Jg(){if(!qg())return;let e=pg({turnEntries:fg(Ng),acknowledged:zg,unseen:Bg,isLooking:Fg?.isLooking()??!1});Gg(e.acknowledged),Kg(e.unseen),Rg?.(e.isShown)}function Yg(e){Ig=e,Wg({kind:`reveal`})}function Xg(e){Ug.add(e)}function Zg(e){Fg=e,Jg()}function Qg(){let{prs:e,sessionsByPrKey:t,status:n}=lh();return Ng=Jh(Og(),e,new Set(t.keys()),Sm(n)),Jg(),Ng}function $g(){qg()&&(Gg(dt(fg(Ng))),Jg())}function e_(e){Rg=e,Jg()}function t_(){return Bg}function n_(e){return Vg.has(e)}function r_(e){return Vg.has(e)?(Kg(dt([...Vg].filter(t=>t!==e))),!0):!1}function i_(e){Pg=e}function a_(){return Pg}function o_(){let e=Ig;return Ig=null,e}function s_(e){if(e!==Lg){Lg=e;for(let e of Hg)e()}}function c_(e){Hg.add(e)}function l_(){return document.documentElement.dataset.layout===`phone`&&Lg}function u_(){l_()&&Wg({kind:`return-to-queue`})}function d_(){let e=sg(Ng,Fg?.selectedKey()??null)[0]?.id??null;return e?(Yg(e),!0):!1}function f_(e){let t=Ng.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!Pg?.openReviews()?!1:(Yg(t.key),$g(),!0)}Eg(e=>{e.kind===`status`&&Qg()}),ch(e=>{e.kind===`prs`&&Qg()});function p_(){return{groups:Ng}}var m_={OPEN:0,MERGED:1,CLOSED:2};function h_(e){return e?m_[e.state]:m_.OPEN}function g_(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:sn(void 0)};let i=bm(t.stage);return{key:n,text:r,detailText:`${r} ${t.title}`,stateText:ym(t.stage),url:t.url,prTitle:t.title,look:{icon:xm(t.stage),tone:i},tier:sn(i)}}function __(e,t){let n=e.map(e=>{let n=t(De(e));return{link:e,pr:n?sm(n):void 0}});return n.sort((e,t)=>h_(e.pr)-h_(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>g_(e,t))}var v_=new Map;function y_(e){return document.querySelectorAll(`[data-pr-rows-for="${CSS.escape(e)}"]`)}function b_(e){return __(v_.get(e)??[],Hp).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,onActivate:()=>{f_(e.key)||nd(e.url)}}))}function x_(e,t){let n=Be(`session-pr-chip-unlink`);return n.append(Te(st)),n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),Xt({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:()=>{Ki(t,{type:`unlink-session-pr`,id:t,key:e.key})}})}),n}function S_(e,t){let n=gn({...e,text:e.key},{...e,className:`linked-pr-row-link`});e.prTitle&&n.append(D(`span`,`linked-pr-row-title`,e.prTitle)),e.stateText&&n.append(D(`span`,`linked-pr-row-stage`,e.stateText));let r=D(`li`,`linked-pr-row`);return r.append(n,x_(e,t)),r}function C_(e,t){e.dataset.prRowsFor=t;let n=b_(t);In(e,n,e=>S_(e,t),{visibleCount:n.length})}function w_(e){for(let t of e){let e=t.dataset.prRowsFor;e&&C_(t,e)}}function T_(e,t){let n=Pt.shape.links.safeParse(t??[]);v_.set(e,n.success?n.data:[]),w_(y_(e)),_n(e),dh(v_)}function E_(e){v_.delete(e),dh(v_)}Up(()=>{w_(document.querySelectorAll(`[data-pr-rows-for]`)),jn()});function I(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function D_(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function O_(e,t){return e||D_(t)>0}var k_={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},A_=null,j_=!1,M_=!1,N_=null,P_=null,F_=null,I_=`—`;function L_(e){return e==null?I_:mt(e,`GB`)}function R_(e){return e==null?I_:me(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function z_(e){return e==null?I_:`${R_(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function B_(){let e=D(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=D(`div`,`health-summary`),n=Be(`health-toggle`);n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=D(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,D(`span`,`health-toggle-label`,`Health`));let i=D(`div`,`health-stats`);t.append(n,i);let a=D(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{M_=!M_,e.dataset.expanded=String(M_),n.setAttribute(`aria-expanded`,String(M_)),a.hidden=!M_,M_&&(s({type:`request-health-snapshot`}),H_())}),e.append(t,a),N_=e,P_=i,F_=a,e}function V_(){if(!P_||!A_)return;let e=A_,t=D_(e.anomalies);P_.innerHTML=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xterm-CJsd_Jt0.js","assets/rolldown-runtime-DK3Fl9T5.js","assets/nyan-cat-DFntGsFR.js","assets/dom-helpers-BGfnE93m.js","assets/zod-gDNZYuWw.js","assets/ui-prefs-Cc_48IUB.js","assets/alert-sound-core-CmJhj4qI.js","assets/local-store-CVQ5ByvB.js","assets/nyan-geometry-core-C8RryYMH.js","assets/celebration-player-C2GC0Ycy.js","assets/alert-sound-At4lBeip.js","assets/doc-editor-ui-nrnC5Ekm.js","assets/action-status-DCsn95R1.js","assets/button--pTS8HHg.js","assets/control-ws-CiuaF_NT.js","assets/modal-Dd0ta-Iu.js","assets/doc-editor-ui-BLBPYLaH.css","assets/resume-dialog-C-j9LGui.js","assets/card-actions-DsTVEj54.js","assets/card-registry-BydUQIUS.js","assets/plan-face-AIPyl9ns.js","assets/roving-keys-core-BDobx2It.js","assets/ui-state-core-Nssh-6QJ.js","assets/plan-render-BwV2iOMo.js","assets/plan-face-CNqLL3OW.css","assets/phone-shell-QnJW6JzC.js","assets/agent-core-C63CBR1u.js","assets/preload-helper-BLdHbfdN.js","assets/session-tick-De9JHrec.js","assets/session-row-BUURB6CH.js","assets/menu-CsKNBMxw.js","assets/agent-mark-Cwz5xPAA.js","assets/pr-status-icon-DwS-fc7J.js","assets/first-run-checklist-Dh6Cvg_U.js","assets/repo-roots-adder-C3cMrHJj.js","assets/setup-step-BD-OtkiA.js","assets/boards-view-BiwLooLF.js","assets/boards-view-kJv55UPo.css","assets/review-queue-panel-I8RK2j4B.js","assets/lane-read-token-step-dr_b7bbq.js","assets/lane-read-token-step-uxHqFrcY.css","assets/my-prs-panel-BSOG04bb.js","assets/pr-queue-columns-BBeq-Zzh.js","assets/team-review-settings-core-DUdtjvxy.js","assets/issues-panel-BE4a2m0n.js","assets/issues-panel-1vb6hHuv.css","assets/usage-panel-BBEw22J_.js","assets/chart-readout-CBzw78U5.js","assets/usage-panel-DV0ckKqY.css","assets/radar-panel-7-5n1ink.js","assets/dialogs-Bju6zrjt.js","assets/radar-panel-LHOTTm1M.css","assets/community-panel-CMwSKMoo.js","assets/community-panel-DR_-RgSK.css","assets/hooks-panel-CsEtzh3p.js","assets/hooks-panel-BUBv4dvX.css","assets/trace-panel-B2myZkUL.js","assets/trace-panel-D-AIzBSZ.css","assets/arena-panel-DsZW87SB.js","assets/arena-panel-CCEwG0WI.css","assets/settings-panel-SaUZ37hZ.js","assets/flying-animal-preview-YHxGVVuk.js","assets/settings-panel-Bsxgnovj.css","assets/feature-hint-Ckkpugl5.js","assets/feature-hint-Dm-eD9Sz.css","assets/your-day-tip-DbK_G8QL.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{C as e,S as t,T as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,i as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y,v as b,w as ee,x as te,y as x}from"./control-ws-CiuaF_NT.js";import{f as ne,l as re,n as ie,p as ae,s as oe,v as se}from"./zod-gDNZYuWw.js";import{A as ce,At as le,Bt as ue,C as de,Ct as fe,D as pe,Dt as me,E as he,Et as ge,Ft as _e,G as ve,It as ye,J as be,K as xe,Lt as Se,M as S,Mt as Ce,Nt as we,O as Te,Ot as C,Pt as Ee,Qt as De,R as Oe,Rt as ke,S as Ae,T as je,Tt as Me,U as Ne,V as Pe,Vt as Fe,Xt as Ie,Z as Le,Zt as Re,_ as ze,a as Be,b as Ve,c as He,dn as Ue,f as We,g as Ge,h as Ke,i as qe,in as Je,j as Ye,kt as Xe,l as Ze,ln as Qe,nn as $e,on as et,p as tt,q as nt,s as rt,sn as it,st as at,t as w,tn as ot,u as st,un as ct,ut as lt,vn as ut,vt as dt,wt as ft,x as pt,xt as mt,y as ht,yn as gt,yt as _t}from"./button--pTS8HHg.js";import{Dn as vt,En as yt,Ft as bt,Lt as xt,Mn as St,Nn as Ct,Nt as wt,Pn as Tt,S as Et,Tn as Dt,Un as Ot,Y as kt,Yt as At,_ as jt,an as Mt,b as Nt,bt as Pt,dt as Ft,f as It,g as T,h as Lt,in as Rt,mn as zt,n as Bt,nn as Vt,on as E,p as Ht,rn as Ut,s as D,t as Wt,u as Gt,un as Kt,wt as qt,yt as Jt,zn as Yt}from"./dom-helpers-BGfnE93m.js";import{a as Xt,i as Zt,n as Qt,r as $t,t as en}from"./modal-Dd0ta-Iu.js";import{A as tn,C as nn,D as rn,E as an,F as on,I as sn,M as cn,N as ln,O as un,P as dn,S as fn,T as pn,_ as mn,a as hn,b as gn,c as _n,d as vn,f as yn,g as bn,h as xn,i as Sn,j as Cn,k as wn,l as Tn,m as En,n as Dn,o as On,p as kn,r as An,s as jn,t as Mn,u as Nn,v as Pn,w as Fn,x as In,y as Ln}from"./session-row-BUURB6CH.js";import{i as Rn,n as zn,t as Bn}from"./agent-mark-Cwz5xPAA.js";import{D as Vn,E as Hn,S as Un,T as Wn,_ as Gn,a as Kn,b as qn,c as Jn,f as Yn,h as Xn,i as O,n as Zn,o as k,r as A,s as Qn,t as j,u as $n,v as er,w as tr,y as nr}from"./card-registry-BydUQIUS.js";import{n as M,t as rr}from"./ui-state-core-Nssh-6QJ.js";import{t as N}from"./preload-helper-BLdHbfdN.js";import{c as ir,i as ar,n as or,o as sr,r as cr,s as lr,t as ur,u as dr}from"./action-status-DCsn95R1.js";import{a as fr,c as pr,i as mr,n as hr,o as gr,r as _r,s as vr,t as yr}from"./session-tick-De9JHrec.js";import{n as br,t as xr}from"./local-store-CVQ5ByvB.js";import{$ as Sr,A as Cr,Ct as wr,D as Tr,E as Er,Et as Dr,F as Or,G as kr,Gt as Ar,I as jr,M as Mr,O as Nr,P as Pr,Q as Fr,Rt as Ir,S as Lr,St as Rr,T as zr,Tt as Br,Ut as Vr,Vt as Hr,X as Ur,_t as Wr,a as Gr,b as Kr,bt as qr,c as Jr,ct as Yr,d as Xr,et as Zr,ft as Qr,gt as $r,h as ei,ht as ti,i as ni,k as ri,l as ii,lt as ai,m as oi,mt as si,ot as ci,p as li,pt as ui,r as di,t as fi,tt as pi,u as mi,vt as hi,w as gi,wt as _i,x as vi,xt as yi,yt as bi,zt as xi}from"./ui-prefs-Cc_48IUB.js";import{A as Si,C as Ci,D as wi,E as Ti,F as Ei,M as Di,N as Oi,O as ki,S as Ai,T as ji,b as Mi,c as Ni,f as Pi,g as Fi,h as Ii,j as Li,k as Ri,l as zi,m as Bi,p as Vi,u as Hi,v as Ui,w as Wi,x as Gi,y as Ki}from"./agent-core-C63CBR1u.js";import{n as qi}from"./menu-CsKNBMxw.js";import{t as Ji}from"./pr-status-icon-DwS-fc7J.js";import{n as Yi,t as Xi}from"./roving-keys-core-BDobx2It.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 Zi={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},Qi=null,$i=null,ea=!0,ta=new Map,na=new Map,ra=new Set;function ia(){for(let e of ra)e()}function aa(e){ra.add(e)}function oa(){return{status:Qi,isServerConnected:ea,pendingActionBySuite:ta,outcomeBySuite:na}}function sa(e){$i=e}function ca(e,t){$i?.({type:`benchmark-action`,requestId:d(`benchmark`),suiteId:e,action:t})===!0?(ta.set(e,t),na.set(e,Zi[t]),ia()):(na.set(e,S),ia())}function la(e){if(ea=e,!e){for(let e of ta.keys())na.delete(e);ta.clear()}ia()}function ua(e){Qi=e,ia()}function da(e){ta.delete(e.suiteId);let t=Qi?.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.`};na.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),ia()}function fa({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=$t({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=D(`div`,`coherence-journal-header`),s=D(`h3`,`dialog-title`,t);s.id=n;let c=w({variant:`secondary`,label:`Close`,action:`close-coherence-panel`,onClick:i});return o.append(s,c),a.dialog.append(o,...r),en(a.dialog,s.id),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function pa({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 c({sessionId:c,status:l,body:u,parts:f,paintBeforeRequest:p,buildRequest:m}){a?.close();let h=d(e),g=fa({dialogClass:t,titleText:n,titleId:`${h}-title`,body:u,onCloseRequest:()=>_.close()}),_={sessionId:c,status:l,parts:f,requestId:h,timer:null,close:()=>{o(_),a===_&&(a=null),g.close()}};a=_,p?.(),g.focusClose(),s(m(h))?_.timer=setTimeout(()=>{_.requestId=null,_.timer=null,l.textContent=`${r}: request timed out`},i):(_.requestId=null,l.textContent=`${r}: not connected`)}function l(e){let t=a;return!t||t.sessionId!==e.id||t.requestId===null||t.requestId!==e.requestId?null:(o(t),t)}return{open:c,settleResponse:l,currentPanel:()=>a}}var ma={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 ha(e){return e?.active!==!1||e.reason===kt.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,detailText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:on.broken}]}function ga(e){let t=ot.safeParse(e.kind);return{heading:`${t.success?ma[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function _a(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 va=new Map,ya=new Map,ba=pa({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function xa(e,t){ya.delete(e),t&&ya.set(e,t),Da(e)}function Sa(e){va.delete(e),ya.delete(e);let t=ba.currentPanel();t?.sessionId===e&&t.close()}function Ca(e){let t=va.get(e.id);t&&t.updatedAt>e.updatedAt||(va.set(e.id,e),Da(e.id))}function wa(e){va.clear();for(let[t,n]of Object.entries(e.sessions))va.set(t,n);let t=ba.currentPanel();t&&Da(t.sessionId)}function Ta(e){return ha(ya.get(e)??null).map(t=>({...t,onActivate:()=>Oa(e)}))}function Ea(e){return va.get(e)?.journal.ok===!0}function Da(e){let t=ba.currentPanel();if(!t||t.sessionId!==e)return;let n=_a(ya.get(e)??null,va.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>D(`p`,null,e)))}function Oa(e){let t=D(`div`,`coherence-journal-reading`),n=D(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=D(`div`,`coherence-journal-entries`);ba.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>Da(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function ka(e){let t=ba.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=ga(e),n=D(`article`,`coherence-journal-entry`);return n.append(D(`h4`,null,t.heading),D(`p`,null,t.text)),t.detail&&n.append(D(`p`,null,t.detail)),t.supersedes&&n.append(D(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var Aa=new Set([`waiting`,`monitoring`]);function ja(e){return Object.fromEntries(ue.flatMap(t=>{let n=Aa.has(t)?8:6;return[[`--state-${t}`,e[t]],[`--state-${t}-bg`,`color-mix(in oklab, var(--state-${t}) ${n}%, transparent)`]]}))}function Ma(e){return{...Object.fromEntries(Object.entries(e.chrome).map(([e,t])=>[`--${e}`,t])),...ja(e.states)}}var Na={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:`#008223`,yellow:`#92400e`,brightYellow:`#a16207`,blue:`#1d4ed8`,brightBlue:`#2563eb`,magenta:`#6d28d9`,brightMagenta:`#7c3aed`,cyan:`#0e7490`,brightCyan:`#00799a`}},Pa={dark:{black:`--border`,brightBlack:`--text-muted`,white:`--text`,brightWhite:`--text-head`},light:{black:`--text-head`,brightBlack:`--text-dim`,white:`--text-dim`,brightWhite:`--text`}},Fa=.35;function Ia(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 La(e){if(e.accentAnsiSlot===`none`)return{};let t=`bright${e.accentAnsiSlot[0].toUpperCase()}${e.accentAnsiSlot.slice(1)}`;return{[e.accentAnsiSlot]:`--accent`,[t]:Ia(e.chrome.accent,Fa)}}function Ra(e){return{label:e.label,colors:{...Ma(e),...Rn(e.mode)},terminal:{background:`--bg-card`,foreground:`--text`,cursor:`--accent`,cursorAccent:`--bg-card`,...Pa[e.mode],...Na[e.mode],...La(e)}}}var za={glimmer:Ra({label:`Glimmer`,mode:`dark`,accentAnsiSlot:`magenta`,chrome:{bg:`#0f0d15`,"bg-card":`#1b1721`,"bg-header":`#15121b`,"bg-surface":`#211d29`,border:`#3b3448`,"border-dim":`#2b2636`,"border-hover":`#4b435a`,text:`#cfcbd9`,"text-dim":`#b0aabf`,"text-head":`#efedf6`,"text-muted":`#9e97af`,accent:`#b688fe`,"accent-dim":`#7a4aba`},states:{running:`#22c55e`,waiting:`#f59e0b`,failed:`#f84d4c`,monitoring:`#60a5fa`,done:`#67e8f9`,initializing:`#7b8290`,idle:`#eab308`,starting:`#f472b6`,complete:`#34d399`}}),"glimmer-light":Ra({label:`Glimmer Light`,mode:`light`,accentAnsiSlot:`magenta`,chrome:{bg:`#f5f1fd`,"bg-card":`#fcfbfe`,"bg-header":`#ede9f6`,"bg-surface":`#e5e0f0`,border:`#c4bdd3`,"border-dim":`#d7d0e4`,"border-hover":`#b1a9c2`,text:`#292237`,"text-dim":`#4f4464`,"text-head":`#110c1a`,"text-muted":`#605378`,accent:`#6f2fb7`,"accent-dim":`#541791`},states:{running:`#157838`,waiting:`#a94e08`,failed:`#bf0814`,monitoring:`#0e728d`,done:`#5a697e`,initializing:`#686f7d`,idle:`#995d07`,starting:`#7c3aed`,complete:`#047a55`}}),golgari:Ra({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:Ra({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:Ra({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:Ra({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:Ra({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":Ra({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":Ra({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`}})},Ba=`glimmer`,Va=null,Ha=null,Ua=null,Wa={};function Ga(e){return Object.hasOwn(za,e)?za[e]:Wa[e]}function Ka(e){Wa=Object.fromEntries(e.map(({id:e,palette:t})=>[e,Ra(t)]));let t=Ua??Ba,n=Ga(t)?t:Ba;return n===Ha&&!Object.hasOwn(Wa,n)?!1:(Ja(n),!0)}function qa(e){Ua=e,Ga(e)&&Ja(e)}function Ja(e){let t=Ga(e);if(!t)return;let n=Ha;Ha=e;let r=document.documentElement;r.dataset.theme=e;for(let[e,n]of Object.entries(t.colors))r.style.setProperty(e,n);e===`unicorn`&&n!==null&&n!==`unicorn`&&Va?.()}function Ya(e){Va=e}function Xa(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function Za(){let e=Ga(Ha||Ba);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 Qa(){return{id:Ha,colors:{...Ga(Ha??Ba)?.colors}}}function $a(){return Object.entries({...za,...Wa}).map(([e,t])=>({id:e,label:t.label}))}function eo(){let e=Za();e.background&&e.foreground&&s({type:`terminal-colors`,background:e.background,foreground:e.foreground})}var to=3e4,no=24,ro=null,io=[`Android`,`iPhone`,`iPad`,`Windows`,`Mac OS X`,`Linux`],ao=[/Firefox\/\d+/,/Edg\/\d+/,/Chrome\/\d+/,/Version\/\d+/];function oo(){let e=navigator.userAgent,t=io.find(t=>e.includes(t))??`unknown platform`;return`${ao.map(t=>t.exec(e)?.[0]).find(e=>e!==void 0)?.replace(`Version`,`Safari`)??`unknown browser`} on ${t}`}function so(){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 co(){return[navigator.onLine?`online`:`offline`,...so()].join(` `)}function lo(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 uo(e,t){let n=e.join(` `);if(n.length<=t)return n;let r=t-no,i=lo(e,r/2),a=lo(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 fo(e){return e.marks.some(e=>e.startsWith(`terminal-bytes`))}function po(e){let t=fo(e)&&!e.isCapped?`terminal live`:`terminal not live after ${to/1e3} s`,n=`hidden ${Math.round(e.hiddenForMs/1e3)} s, ${t}, ${oo()}, ${e.networkAtWake}: `,r=n+uo(e.marks,Qe-n.length);return s({type:`client-log`,scope:`wake`,text:r.slice(0,Qe)})}function mo(){let e=ro;e&&(e.isCapped||fo(e))&&po(e)&&(ro=null,clearTimeout(e.capTimer))}function ho(){ro&&(ro.isCapped=!0,mo())}function go(e,t){e.marks.push(`${t}+${Math.round(performance.now()-e.startedAtMs)}`)}function _o(e){ro&&(e===`terminal-bytes`&&fo(ro)||(go(ro,e),(e===`terminal-bytes`||e===`control-opened`)&&mo()))}function vo(e){ro&&go(ro,e===`link`?[`link`,...so()].join(`-`):e)}function yo(e,t){ro||={startedAtMs:performance.now(),hiddenForMs:t,networkAtWake:co(),marks:[],isCapped:!1,capTimer:setTimeout(ho,to)},_o(e)}function bo(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function xo(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 So=null,Co=null;function wo(){return So}function To(){return So?Promise.resolve(So):(Co??=Promise.all([N(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.t),__vite__mapDeps([0,1])),N(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.r),__vite__mapDeps([0,1])),N(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.n),__vite__mapDeps([0,1]))]).then(([e,t,n])=>(So={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},So)).catch(e=>{throw Co=null,e}),Co)}var Eo=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,Do=new Map;function Oo(e){return e.clientWidth>0&&e.clientHeight>0}function ko(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 Ao(e){Do.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,ko(e)}function jo(e){let t=[e],n=M.snapshot().borrowedCardId,r=n?k.get(n):void 0;r&&t.push(r);for(let e of xo([...Do.keys()],Eo,t))Ao(e),e.needsWebGLReload=!0}function Mo(e){e?.term&&bo({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:Oo(e.termWrap)})&&Lo(e,{isForced:!0})}function No(){for(let e of Do.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{Ao(e),e.needsWebGLReload=!0}}}var Po=!1;function Fo(){Po||(Po=!0,requestAnimationFrame(()=>{Po=!1,No()}))}function Io(e){e?.addEventListener(`contextrestored`,Fo)}function Lo(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){Do.delete(e),Do.set(e,!0);return}e.webglAddon&&(ko(e),Do.delete(e));let n=wo();if(!n)return;jo(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,Do.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(Io),r.onAddTextureAtlasCanvas(Io),Io(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!Oo(e.termWrap),Do.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,Do.delete(e)}}var Ro=`(max-width: 768px)`,zo=`(pointer: coarse)`;function Bo({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var Vo=window.matchMedia?.(zo),Ho=window.matchMedia?.(Ro);function Uo(){return Bo({coarse:!!Vo?.matches,narrowWidth:!!Ho?.matches})}function Wo(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function Go(){M.subscribe((e,t)=>{t.includes(`layout`)&&Wo(e.layout)});let e=Uo();Wo(e),M.dispatch(`setLayout`,e);let t=()=>M.dispatch(`setLayout`,Uo());return Vo?.addEventListener?.(`change`,t),Ho?.addEventListener?.(`change`,t),e}function Ko(){return M.snapshot().layout===`phone`}function qo(e){return M.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var Jo=``,Yo=`\x1B`,Xo=`\r`,Zo=new Map([[`deleteContentBackward`,Jo],[`deleteByComposition`,Jo],[`deleteCompositionText`,Jo],[`deleteWordBackward`,Yo],[`deleteSoftLineBackward`,Yo],[`deleteHardLineBackward`,Yo]]);function Qo(e){return Zo.get(e)??``}var $o=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function es(e){return typeof e!=`string`||e===``||!$o.has(e)}function ts(e){return e?e.keyCode===229||e.key===`Process`:!1}function ns(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 Jo.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,Xo)}var rs=`Upload`;async function is(e,t){return or(rs,e),os(e,t)}async function as(e,t){or(rs,e);for(let n of t)await os(e,n)}async function os(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:(sr({source:rs,sessionId:e,message:await ss(r,t.name)}),!1)}catch{return sr({source:rs,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 ss(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 cs=new WeakMap,ls=5e3,us=15e3,ds=`The agent copied text. The browser needs a click before it can reach your clipboard.`,fs=`The clipboard is unavailable in this browser.`;function ps(e,t,n,r){let i=cs.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(()=>ms(e,t),n===`ok`?ls:us)))}function ms(e,t){let n=cs.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function hs(e){let t=e.buffer.active;return t.viewportY<t.baseY}function gs(e,t,{hasNewOutput:n=!1}={}){let r=cs.get(e)?.jumpToLatest;if(!r)return;let i=hs(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function _s(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 vs(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),ps(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function ys(e,t,n,r){let i=Nt(t);i?i.then(()=>{r&&ps(e,`clipboard`,`ok`,r)}).catch(t=>vs(e,n,t)):ps(e,`clipboard`,`error`,fs)}function bs(e,t){let n=cs.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function xs(e){let t=cs.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,ys(e,n,`osc52 write`,`Copied to the clipboard.`))}function Ss(e,t,n){let r=ar(`terminal-notice`),i=D(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=w({variant:`primary`,label:`Copy to clipboard`,onClick:()=>xs(t)});i.append(D(`span`,`terminal-clipboard-prompt-text`,ds),a);let o=D(`div`,`terminal-notices`);o.append(i,r.element);let s=D(`div`,`terminal-jump-latest`);s.hidden=!0,s.append(w({variant:`secondary`,label:`Jump to latest`,onClick:()=>{n.scrollToBottom(),n.focus()}}),D(`span`,`terminal-jump-latest-new-output`));let c=D(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(D(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),cs.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatest:s})}var Cs=1024,ws=`Keys you type now are held and sent once the terminal reconnects.`,Ts=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,Es=!1;function Ds(e){let t=e._inputQueue,n=e.dataWs;if(!Es&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,ms(e,`keys`)}}function Os(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!Es&&!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>=Cs?(ps(e,`keys`,`error`,Ts),!1):(e._inputQueue.push(t),r&&ps(e,`keys`,`busy`,ws),!0)}function ks(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,Ko()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=ns(i,r.value);return i=r.value,e!==``&&(Os(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{Ko()?n(e):a()},!0)};c(`keydown`,e=>{ts(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(!es(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=Qo(e.inputType);r!==``&&(Os(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function As(e){return!!e&&Array.from(e.types).includes(`Files`)}function js(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),as(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{As(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,As(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),as(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function Ms(e){Es=e}var Ns=6,Ps=262144,Fs=16384,Is=()=>{};function Ls(e,t){if(t.length<=Fs)e.push(t);else for(let n=0;n<t.length;n+=Fs)e.push(t.slice(n,n+Fs))}function Rs({budget:e=Ns,maxChunkBytes:t=Ps,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)Ls(l,e),m+=e.length,a.readIdx++;else{m===0&&(Ls(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,Is);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 zs=Rs(),Bs=[];function Vs(e){Bs=[...e]}function Hs(){return Bs}function Us(e){return e.state===`unreachable`&&e.lastError?`unreachable: ${e.lastError}`:e.state===`version-differs`?`version differs: host ${e.hostVersion??`unknown`}, this machine ${e.hubVersion}`:e.state}var Ws=new Map;function Gs(e){return Ws.get(e)??null}function Ks(e,t){Ws.set(e,t)}function qs(e){Ws.delete(e)}function Js(e){return[...Ws].flatMap(([t,n])=>n===e?[t]:[])}function Ys(e){let t=Gs(e);return t?`/hosts/${encodeURIComponent(t)}`:``}function Xs(e){let t=Gs(e);if(!t)return null;let n=Hs(),r=n.findIndex(e=>e.id===t);return{id:t,name:n[r]?.name??t,rank:r===-1?n.length:r}}var Zs=ne().int().min(1).max(500),Qs=ne().int().min(1).max(200);oe(`type`,[ae({type:re(`input`),data:se()}),ae({type:re(`claim`),cols:Zs,rows:Qs}),ae({type:re(`unview`)}),ae({type:re(`pause-output`)}),ae({type:re(`resume-output`)})]);var $s=ae({type:re(`pty-size`),cols:Zs,rows:Qs,seq:ne().int().nonnegative()}),ec=ae({type:re(`output-beat`)}),tc=oe(`type`,[$s,ec]),nc=`history`,rc=`output`,ic=`paused`;ie([`screen`,`deep`]);function ac(e){try{return JSON.parse(e)}catch{return null}}function oc(e){let t=tc.safeParse(ac(e));return t.success?t.data:null}var sc=new Set([1,5,25,100]);function cc(e){return e.isOutputPaused?`${e.history} paused`:e.history}function lc(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function uc(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function dc(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function fc({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&lc(e,n))}function pc({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function mc({isBorrowedCard:e,isTerminalFaceShown:t}){return!e||!t}function hc({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function gc(e,t,n){let r=new URLSearchParams;t&&r.set(nc,`deep`),n&&r.set(rc,ic);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function _c({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:fc({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function vc({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function yc({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!lc(e,t),s=uc(n)?dc(n):null,c=r&&!!s&&!lc(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:fc({authoritative:e,isActiveViewer:r,lastClaim:a})}}function bc(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function xc(e){let t=bc(e);return t===null?null:oc(t)}function Sc(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=xc(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 Cc=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,wc=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,P=`[^\\S\\r\\n]`,Tc=`${Cc}${P}*(?:=>|[:=])${P}*`,Ec=`[?&][A-Za-z0-9_.-]*`,Dc=`[^\\r\\n;&|]{0,200}?`,Oc=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,kc=RegExp(`(${Tc})${wc}`,`gi`),Ac=RegExp(`(\\bBearer${P}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),jc=[/\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],Mc=[RegExp(`((?:^|\\s)--?${Cc}${P}+)${wc}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${P}*=?${P}*)${wc}`,`g`),RegExp(`(-AsPlainText${P}+)${wc}`,`gi`),RegExp(`((?:^|\\s)setx${P}+[^\\s\\r\\n]*${Cc}[^\\s\\r\\n]*${P}+)${wc}`,`gi`)],Nc=[RegExp(`(\\bauthorization${P}*:${P}*Basic${P}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${P}+login\\b${Dc}${P}-p(?:${P}+|=))${wc}`,`gi`),RegExp(`(\\bcurl\\b${Dc}${P}(?:--user|-u)(?:${P}+|=)[^\\s:\\r\\n]+:)${wc}`,`gi`),RegExp(`(\\b${Oc}\\b${Dc}${P}-p)${wc}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi],Pc=[/-----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],Fc=RegExp(`(${Ec}(?:${Cc}|_key)=)[^&#\\s]+`,`gi`),Ic=[kc,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${wc}`,`g`)],Lc=[Ac,...Mc,...Nc,...jc,...Pc];function Rc(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function zc(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 Bc(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 Vc(e){let t=Rc(e,Fc);return Bc([...t,...Ic.flatMap(n=>zc(Rc(e,n),t)),...Lc.flatMap(t=>Rc(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var Hc=`•`.repeat(8),Uc=4;function Wc(e){let t=e.flatMap(e=>[e,...e.split(/\r?\n/)]).map(e=>e.trim());return[...new Set(t.filter(e=>e.length>=Uc))]}function Gc(e,t){let n=[];for(let r of Wc(t))for(let t=e.indexOf(r);t!==-1;t=e.indexOf(r,t+r.length))n.push({start:t,end:t+r.length});return n}function Kc(e,t=[]){let n=Bc([...Vc(e),...Gc(e,t)]);if(n.length===0)return e;let r=``,i=0;for(let t of n)r+=e.slice(i,t.start)+Hc,i=t.end;return r+e.slice(i)}var qc=`glimmervoid-streamer-mode`,Jc=new Set,Yc=xr(qc,!1)===!0;function Xc(e){document.documentElement.toggleAttribute(`data-streamer`,e)}Xc(Yc);function Zc(){return Yc}function Qc(e){if(br(qc,e),e!==Zc()){Yc=e,Xc(e);for(let t of Jc)t(e)}}function $c(e){return Jc.add(e),()=>Jc.delete(e)}async function el(e){try{let t=await c(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:ur});return t.type===`settings-error`?String(t.message):(Qc(e),``)}catch(e){return lr(e,ur)}}var tl=`Streamer mode`;async function nl(){let e=!Zc();e&&Qc(!0);let t=await el(e);t?sr({source:tl,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}):or(tl)}function rl(){nl()}var il=`#808080`,al=new WeakMap;function ol(e,t,n){return`${e}:${t}:${n}`}function sl(e){return ol(e.marker.line,e.x,e.width)}function cl(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function ll(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function ul(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function dl(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 fl(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 pl(e,t,n,r){let i=[];if(Vc(ul(e,t,n)).length===0)return i;let{text:a,cellAt:o}=dl(e,t,n,r);for(let e of Vc(a))fl(i,o.slice(e.start,e.end));return i}function ml(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=ll(e,i);r.push(...pl(e,i,t,n)),i=t+1}return r}function hl(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function gl(e){e.decoration.dispose(),e.marker.dispose()}function _l(e){for(let t of e.masks)gl(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function vl(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function yl(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 bl(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(sl(r),r),r=e.masks.at(-1);return yl(e),n}function xl(e,t){let n={normal:hl(),alternate:hl()},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??il,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(!Zc())return;let t=e.buffer.active,r=n[t.type],i=cl(t,vl(r,t)),a=bl(r,i);for(let e of ml(t,i)){let n=ol(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())gl(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){_l(n.normal),_l(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=>{_l(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=$c(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),al.delete(e)},{once:!0}),al.set(e,d)}function Sl(e){al.get(e)?.()}function Cl({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var wl=`-4 -4 108 108`,Tl=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`}]),El=`M50 39L61 50L50 61L39 50Z`,Dl=11,Ol=`#efedf6`,kl=`#b688fe`;function Al({frame:e,light:t,strokeWidth:n=Dl}){return`<path d="${Tl.map(({d:e})=>e).join(``)}" fill="none" stroke="${e}" stroke-width="${n}" stroke-linejoin="miter" stroke-linecap="butt"/><path d="${El}" fill="${t}"/>`}function jl(e,t){return mc({isBorrowedCard:M.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var Ml=new WeakMap,Nl=new WeakMap,Pl=new WeakSet,Fl=new WeakSet,Il=new WeakSet;function Ll(e,t){if(Ml.has(e)||!hs(t))return;let n=t.buffer.active,r=n.length-n.viewportY;Pl.has(e)?Ml.set(e,r):Nl.set(e,r)}function Rl(e,t,n){let r=e.term;r&&hc({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:Pl.has(e)})&&(Pl.add(e),Fl.add(e),Ml.set(e,r.buffer.active.length-n),fu(t))}var zl=new WeakMap;function Bl(e,t){return document.visibilityState===`visible`&&!jl(e,t)}function Vl(e,t){if(e&&nu(e,t))return;let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=Bl(e,t);zl.get(n)!==r&&(zl.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function Hl(){for(let[e,t]of k)Vl(t,e)}document.addEventListener(`visibilitychange`,Hl),M.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&Hl()});function Ul(e,t){return k.get(e)===t&&!t.dataWs}function Wl(e){return e.querySelector(`:scope > .terminal-connecting`)}function Gl(){let e=ce(`svg`,{class:`loading-mark`,viewBox:wl,"aria-hidden":`true`});for(let{side:t,d:n}of Tl)e.append(ce(`path`,{class:`loading-mark-bracket`,"data-side":t,d:n}));return e}function Kl(e){if(Wl(e))return;let t=D(`div`,`terminal-connecting`);t.append(Gl(),D(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}var ql=new Set,Jl=new WeakSet;function Yl(e){return ql.add(e),()=>ql.delete(e)}function Xl(){let e=0;for(let[t,n]of k)n.card.dataset.link===`connecting`&&Bl(n,t)&&e++;return e}function Zl(e){let t=Cl({hasTerminal:e.term!==null||Jl.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:Es}),n=t===`connecting`&&!Es&&Fl.has(e)?`live`:t;n===`none`?(delete e.card.dataset.link,Ql()):(e.card.dataset.link=n,Ql())}function Ql(){for(let e of ql)e()}function $l(e,t,n){Ll(t,n),zs.unregister(e),t.dataWs=null,Zl(t),t._resetGridClaim?.()}var eu=new WeakMap;function tu(e,t,n,r){$l(e,t,n),clearTimeout(eu.get(t)),eu.delete(t),r===0&&a()?du(e,t,n):eu.set(t,setTimeout(()=>{eu.delete(t),Ul(e,t)&&x().catch(()=>{}).then(()=>{Ul(e,t)&&du(e,t,n)})},r))}function nu(e,t){let n=Il.has(e),r=!e.dataWs&&k.get(t)===e;return!(n||r)||!e.term||!Bl(e,t)?!1:(Il.delete(e),e._dataWsRetryAttempt=0,tu(t,e,e.term,0),!0)}function ru(e,t,n){$l(e,t,n),Il.add(t)}var iu=15e3,au=new Map;function ou(e){if(!a()||au.has(e)||k.get(e)?.dataWs)return;let n=Ys(e)+gc(e,!1,!1),r=new WebSocket(ee(location,te(n)));r.binaryType=`arraybuffer`;let i=[],o=e=>i.push(e),s=()=>su(e,r),c=()=>{r.readyState===WebSocket.CONNECTING&&s()};r.addEventListener(`message`,o),r.addEventListener(`close`,s);let l=setTimeout(c,t),u=setTimeout(s,iu);au.set(e,{socket:r,attachPath:n,bufferedMessages:i,release:()=>{r.removeEventListener(`message`,o),r.removeEventListener(`close`,s),clearTimeout(l),clearTimeout(u)}})}function su(e,t){let n=au.get(e);n?.socket===t&&(au.delete(e),n.release(),t.close())}function cu(e,t){let n=au.get(e);if(!n)return null;let r=n.socket.readyState===WebSocket.CONNECTING||n.socket.readyState===WebSocket.OPEN;return n.attachPath!==t||!r?(su(e,n.socket),null):(au.delete(e),n.release(),n)}var lu=new WeakMap;function uu(e,t,n){if(t.openedAtMs===null)return;let r=Math.round(performance.now()-t.openedAtMs);if(r>=1e3){lu.delete(e);return}let i=(lu.get(e)??0)+1;if(lu.set(e,i),!sc.has(i))return;let a=n.wasClean?`clean`:`unclean`,o=t.hasReceivedBytes?`yes`:`no`;y(`terminal`,`fast close ${i}x, session ${t.sessionId}, code ${n.code}, reason '${n.reason}', ${a}, open ${r} ms, bytes ${o}, attach ${t.attachDescription}`)}function du(e,r,i){Il.delete(r);let a=Ml.get(r);Ml.delete(r);let o=Nl.get(r);Nl.delete(r);let s=a!==void 0,c=a??o,l=!1,u=Bl(r,e),d=Ys(e)+gc(e,s,!u),f=cu(e,d),p=f?.socket??new WebSocket(ee(location,te(d)));zl.set(p,u),p.binaryType=`arraybuffer`,r.dataWs=p,u&&_o(`terminal-connecting`),Zl(r);let m=!1,h=!1,g={sessionId:e,attachDescription:cc({history:s?`deep`:`screen`,isOutputPaused:!u}),openedAtMs:null,hasReceivedBytes:!1},_={hasSeenSize:!1,lastSeq:0},v=setTimeout(()=>{p.readyState===WebSocket.CONNECTING&&(h=!0,u&&_o(`terminal-abandoned`),p.close())},t);zs.register(e,(e,t)=>i.write(e,t));let y=t=>{if(r.dataWs!==p)return;let n=Sc(t.data,_);if(n.kind===`bytes`){g.hasReceivedBytes=!0,gr(r),zl.get(p)&&_o(`terminal-bytes`);let t=l;if(l=!1,zs.enqueue(e,n.data),!t)return;let a=c??0;zs.enqueueAction(e,()=>{i.scrollToLine(Math.max(0,i.buffer.active.length-a))});return}if(n.kind===`beat`){gr(r);return}if(n.kind===`attach-size`){l=c!==void 0,s||Pl.delete(r),_.hasSeenSize=!0,_.lastSeq=n.seq,i.reset(),Sl(i),r.ptySize={cols:n.cols,rows:n.rows},r._syncGrid?.();return}if(n.kind!==`size`)return;_.lastSeq=n.seq;let a={cols:n.cols,rows:n.rows};zs.enqueueAction(e,()=>{r.ptySize=a,r._syncGrid?.()})};p.addEventListener(`message`,y),p.addEventListener(`close`,t=>{if(clearTimeout(v),r.dataWs!==p)return;if(uu(r,g,t),u&&!h&&_o(`terminal-closed`),Fl.delete(r),m||h||Gs(e)||b(),!Bl(r,e)){ru(e,r,i);return}if(h){tu(e,r,i,0);return}let a=n(r._dataWsRetryAttempt||0);r._dataWsRetryAttempt=(r._dataWsRetryAttempt||0)+1,tu(e,r,i,a)});let x=()=>{clearTimeout(v),m=!0,g.openedAtMs=performance.now(),u&&_o(`terminal-opened`),r._dataWsRetryAttempt=0,Fl.delete(r),Zl(r),Vl(r,e),r._syncGrid?.({isActivationEdge:!0}),r._retryOwedGridClaim?.(),r._inputQueue?.length&&setTimeout(()=>{r.dataWs===p&&Ds(r)},50)};p.addEventListener(`open`,x),p.readyState===WebSocket.OPEN&&x();for(let e of f?.bufferedMessages??[])y(e)}function fu(e){let t=A(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,tu(e,t,t.term,0),n?.close()}function pu(){for(let[e,t]of k)t.term&&(Bl(t,e)?fu(e):mu(e,t,t.term))}function mu(e,t,n){let r=t.dataWs;r&&(ru(e,t,n),r.close())}function hu(){for(let[e,t]of k)t.term&&mu(e,t,t.term)}function gu(e,t){let n=e.dataWs;e.dataWs=null,zs.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}var _u=`CommitMono`,vu=[400,700].map(e=>`${e} 14px ${_u}`),yu=`monospace`;function bu(e){return e.trim().replace(/^['"]|['"]$/g,``)}function xu(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>bu(e)!==_u);return r.length>0?r.join(`, `):yu}function Su(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function Cu(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function wu(){return document.fonts?vu.every(e=>document.fonts.check(e)):!1}function Tu(){return xu(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),wu())}function Eu(e){document.fonts&&Su(document.fonts,vu,e)}var Du=()=>!1;function Ou(e){Du=e}function ku(){return Du()}var Au=Ar(navigator.userAgent),ju=`next-attention-keys`,Mu=mi();function Nu(){return Mu}function Pu(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(D(`span`,`shortcut-sep`,`+`)),e.appendChild(D(`kbd`,`kbd`,t))})}function Fu(e){let t=D(`span`,`shortcut-keys`);return Pu(t,e),t}function Iu(){let e=Fu(Vr(`next-attention`,Au,Mu));return e.classList.add(ju),e}function Lu(e){Mu=e;let t=Vr(`next-attention`,Au,e);for(let e of document.querySelectorAll(`.${ju}`))e.replaceChildren(),Pu(e,t)}var Ru=ae({title:se().optional(),iconDataUrl:se().startsWith(`data:image/`).optional()}),zu=new Set([`http:`,`https:`]);function Bu(e){let t;try{t=new URL(e)}catch{return null}return zu.has(t.protocol)?t.href:null}var Vu=/\bElectron\/\d/,Hu=new Set([`localhost`,`127.0.0.1`]);function Uu(e){return Vu.test(e)}function Wu({userAgent:e,pageHostname:t}){return Uu(e)&&Hu.has(t)}function Gu(e){return Bu(e)!==null}var Ku=new Set([0,1]);function qu({button:e,opensInNewTab:t}){return t&&Ku.has(e)}function Ju(){return Wu({userAgent:navigator.userAgent,pageHostname:location.hostname})}function Yu(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function Xu(e){try{let t=await x();return(await fetch(`/open-external`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})})).ok}catch{return!1}}var Zu=500,Qu=new Map;async function $u(e){try{let t=await x(),n=await fetch(`/link-preview`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})});if(!n.ok)return{};let r=Ru.safeParse(await n.json());return r.success?r.data:{}}catch{return{}}}function ed(e){return e.title!==void 0||e.iconDataUrl!==void 0}function td(e){let t=Qu.get(e);if(t)return t;let n=$u(e).then(t=>(!ed(t)&&Qu.get(e)===n&&Qu.delete(e),t));if(Qu.set(e,n),Qu.size>Zu){let e=Qu.keys().next().value;e!==void 0&&Qu.delete(e)}return n}function nd(e){!Ju()||!Gu(e)?Yu(e):Xu(e).then(t=>{t||Yu(e)})}function rd(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&qu({button:e.button,opensInNewTab:t.target===`_blank`})&&Gu(t.href)&&(e.preventDefault(),nd(t.href))}function id(e){Ju()&&(e.addEventListener(`click`,rd,!0),e.addEventListener(`auxclick`,rd,!0))}var ad={phase:`hidden`,isPointerOnLink:!1,isPointerOnPopup:!1},od=`*`,sd=/^[("'<[{]+|[)"'>\]}.,;:!?]+$/g,cd=new Set(`md.ts.tsx.js.jsx.mjs.cjs.json.py.rs.go.sh.txt.yml.yaml.toml.lock.html.css.rb.java.kt.swift.cs.php.sql.log.env.cfg.ini.xml.svg.png.jpg.gif.pdf.zip`.split(`.`)),ld=/^[a-z][a-z0-9+.-]*:\/\//i,ud=/\s/,dd=/\.[a-z]{2,63}$/i,fd=/^www\./;function pd(e){return!e.isPointerOnLink&&!e.isPointerOnPopup}function md(e){let t={...e,isPointerOnLink:!0};return e.phase===`shown`?{state:t,effects:[`cancel-hide`,`schedule-dwell`,`render`]}:e.phase===`pending`?{state:t,effects:[`schedule-dwell`]}:{state:{...t,phase:`pending`},effects:[`schedule-show`,`schedule-dwell`]}}function hd(e){let t={...e,isPointerOnLink:!1};return e.phase===`shown`&&pd(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function gd(e){let t={...e,isPointerOnPopup:!1};return e.phase===`shown`&&pd(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function _d(e,t){switch(t){case`enter-link`:return md(e);case`leave-link`:return hd(e);case`enter-popup`:return{state:{...e,isPointerOnPopup:!0},effects:e.phase===`shown`?[`cancel-hide`]:[]};case`leave-popup`:return gd(e);case`escape`:return e.phase===`hidden`?{state:e,effects:[]}:{state:{...e,phase:`hidden`,isPointerOnPopup:!1},effects:[`cancel-show`,`cancel-hide`,`cancel-dwell`,`remove`]};case`show-timer`:return e.phase===`pending`?e.isPointerOnLink?{state:{...e,phase:`shown`},effects:[`render`]}:{state:{...e,phase:`hidden`},effects:[]}:{state:e,effects:[]};case`hide-timer`:return e.phase!==`shown`||!pd(e)?{state:e,effects:[]}:{state:{...e,phase:`hidden`},effects:[`remove`]};case`dwell-timer`:return e.phase!==`shown`||!e.isPointerOnLink?{state:e,effects:[]}:{state:e,effects:[`fetch-preview`]}}}function vd(e){let{linkRange:t,rows:n,cellWidthPx:r,cellHeightPx:i,popupHeightPx:a,popupWidthPx:o,screenWidthPx:s}=e,c=(t.endRow+1)*i,l=t.startRow*i-a,u=n*i-c,d=t.startRow*i,f=Math.max(0,s-o),p=Math.min(Math.max(0,t.startCol*r),f);return!(u>=a)&&(d>=a||d>u)?{side:`above`,leftPx:p,topPx:Math.max(0,l)}:{side:`below`,leftPx:p,topPx:c}}function yd(e){try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?null:t}catch{return null}}function bd(e,t){let n=e.split(``);for(let e of t)n.fill(od,e.start,e.end);return n.join(``)}function xd(e,t){let n=yd(e);if(!n)return null;let r=n.username?`${n.username}${n.password?`:${n.password}`:``}@`:``,i=`${n.protocol}//${r}`,a=`${n.pathname===`/`&&!n.search&&!n.hash?``:n.pathname}${n.search}${n.hash}`;if(!t)return{scheme:i,host:n.host,rest:a};let o=bd(`${i}${n.host}${a}`,Vc(`${i}${n.host}${a}`)),s=i.length+n.host.length;return{scheme:o.slice(0,i.length),host:o.slice(i.length,s),rest:o.slice(s)}}function Sd(e){let t=e.trim().replace(sd,``);if(t.length===0||ud.test(t))return null;let n=yd(ld.test(t)?t:`https://${t}`);if(!n)return null;let r=n.hostname.replace(/\.$/,``);return!dd.test(r)||!ld.test(t)&&cd.has(r.slice(r.lastIndexOf(`.`)+1).toLowerCase())?null:r}function Cd(e,t){let n=e.replace(fd,``),r=t.replace(fd,``);return n===r||n.endsWith(`.${r}`)||r.endsWith(`.${n}`)}function wd(e,t){let n=yd(t);if(!n)return null;let r=Sd(e);if(!r)return null;let i=n.hostname.replace(/\.$/,``);return Cd(r,i)?null:{textHost:r,targetHost:i}}var Td=100,Ed=150,Dd=600,Od=16,kd=[`mousedown`,`mouseup`,`mousemove`,`click`,`dblclick`,`contextmenu`,`wheel`],Ad=!1;function jd(e){Ad=e}function Md(e){let t=D(`div`,`terminal-link-popup-url`),n=xd(e,Zc());return n?(t.append(D(`span`,`terminal-link-popup-url-dim`,n.scheme),D(`strong`,`terminal-link-popup-host`,n.host),D(`span`,`terminal-link-popup-url-dim`,n.rest)),t):(t.textContent=e,t)}function Nd(e){if(e.linkText===null)return null;let t=wd(e.linkText,e.url);if(!t)return null;let n=D(`div`,`terminal-link-popup-mismatch`);return n.append(`Text says `,D(`strong`,null,t.textHost),`, goes to `,D(`strong`,null,t.targetHost)),n}function Pd(e,t){if(!e||e.url!==t)return null;let{title:n,iconDataUrl:r}=e.preview;if(!n&&!r)return null;let i=D(`div`,`terminal-link-popup-preview`);if(r){let e=D(`img`,`terminal-link-popup-icon`);e.src=r,e.alt=``,e.width=Od,e.height=Od,i.append(e)}return n&&i.append(D(`span`,`terminal-link-popup-title`,n)),i}function Fd(e,t){let n=e.element,r=n?.querySelector(`.xterm-screen`);if(!n||!r)return{enterLink(){},leaveLink(){}};let i=n,a=r,o=t.abortController.signal,s=D(`div`,`xterm-hover terminal-link-popup`);s.hidden=!0,i.append(s);let c=ad,l=null,u=null,d=null,f=null,p=null,m=0;function h(){u!==null&&(clearTimeout(u),u=null)}function g(){d!==null&&(clearTimeout(d),d=null)}function _(){f!==null&&(clearTimeout(f),f=null)}function v(){let e=l?.url;Ad&&e&&td(e).then(t=>{Ad&&(p={url:e,preview:t},c.phase===`shown`&&l?.url===e&&ee())})}function y(e){e.key===`Escape`&&ne(`escape`)}function b(t){let n=a.getBoundingClientRect(),r=i.getBoundingClientRect(),o=e.buffer.active.viewportY;m=o;let c=vd({linkRange:{startRow:t.range.start.y-1-o,startCol:t.range.start.x-1,endRow:t.range.end.y-1-o},rows:e.rows,cellWidthPx:n.width/e.cols,cellHeightPx:n.height/e.rows,popupHeightPx:s.offsetHeight,popupWidthPx:s.offsetWidth,screenWidthPx:n.width});s.dataset.side=c.side,s.style.left=`${n.left-r.left+c.leftPx}px`,s.style.top=`${n.top-r.top+c.topPx}px`}function ee(){let e=l;if(!e)return;let n=D(`div`,`terminal-link-popup-footer`);n.append(D(`span`,`terminal-link-popup-hint`,`Click to open`),w({variant:`secondary`,size:`small`,label:`Copy link`,onClick:()=>ys(t,e.url,`link copy`,`Copied the link.`)}));let r=Nd(e);s.replaceChildren(...[Md(e.url),r,Pd(Ad?p:null,e.url),n].filter(e=>e!==null)),s.hidden=!1,b(e),document.addEventListener(`keydown`,y,{capture:!0,signal:o})}function te(){s.hidden=!0,s.replaceChildren(),document.removeEventListener(`keydown`,y,{capture:!0})}let x={"schedule-show":()=>{h(),u=setTimeout(()=>{u=null,ne(`show-timer`)},Td)},"cancel-show":h,"schedule-hide":()=>{g(),d=setTimeout(()=>{d=null,ne(`hide-timer`)},Ed)},"cancel-hide":g,"schedule-dwell":()=>{_(),f=setTimeout(()=>{f=null,ne(`dwell-timer`)},Dd)},"cancel-dwell":_,"fetch-preview":v,render:ee,remove:te};function ne(e){let t=_d(c,e);c=t.state;for(let e of t.effects)x[e]()}for(let e of kd)s.addEventListener(e,e=>e.stopPropagation(),{signal:o});s.addEventListener(`mouseenter`,()=>ne(`enter-popup`),{signal:o}),s.addEventListener(`mouseleave`,()=>ne(`leave-popup`),{signal:o});let re=e.onScroll(()=>{e.buffer.active.viewportY!==m&&ne(`escape`)}),ie=e.onResize(()=>ne(`escape`));return o.addEventListener(`abort`,()=>{h(),g(),_(),re.dispose(),ie.dispose(),s.remove()},{once:!0}),{enterLink(e){Ko()||(l=e,ne(`enter-link`))},leaveLink(){ne(`leave-link`)}}}var Id=/https?:\/\/[^\s<>"']+/g,Ld=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),Rd={")":`(`,"]":`[`,"}":`{`};function zd(e,t){let n=0;for(let r of e)r===t&&n++;return n}function Bd(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(Ld.has(t)){e=e.slice(0,-1);continue}let n=Rd[t];if(n&&zd(e,n)<zd(e,t))e=e.slice(0,-1);else return e}}function Vd(e){let t=[];for(let n of e.matchAll(Id)){let e=Bd(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var Hd=50;function Ud(e,t){return t.start.y===t.end.y?e.buffer.active.getLine(t.start.y-1)?.translateToString(!0,t.start.x-1,t.end.x)??null:null}function Wd(e,t){return{activate(e,t){nd(t)},hover(n,r,i){t.enterLink({url:r,linkText:Ud(e,i),range:i})},leave(){t.leaveLink()},allowNonHttpProtocols:!1}}function Gd(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<Hd;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<Hd;)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 Kd(e,t){let n=e.registerLinkProvider({provideLinks(n,r){let i=e.buffer?.active;if(!i)return r(void 0);let{text:a,cellAt:o}=Gd(i,n),s=[];for(let{start:e,end:n,url:r}of Vd(a)){let i=o[e],a=o[n-1];if(!i||!a)continue;let c={start:i,end:a};s.push({range:c,text:r,activate(e,t){nd(t)},hover(){t.enterLink({url:r,linkText:null,range:c})},leave(){t.leaveLink()}})}r(s.length?s:void 0)}}),r=qd(e);return{dispose(){r.dispose(),n.dispose()}}}function qd(e){let t=e.element?.querySelector(`.xterm-screen`);if(!t)return{dispose(){}};let n=null,r=e=>{e.isTrusted&&(n={clientX:e.clientX,clientY:e.clientY})},i=()=>{n=null},a=(e,n)=>{t.dispatchEvent(new MouseEvent(`mousemove`,{clientX:e,clientY:n,bubbles:!1}))};t.addEventListener(`mousemove`,r),t.addEventListener(`mouseleave`,i);let o=e.onRender(({start:r,end:i})=>{if(!n||t.classList.contains(`xterm-cursor-pointer`))return;let o=t.getBoundingClientRect(),s=o.height/e.rows;if(!(s>0))return;let c=Math.floor((n.clientY-o.top)/s);if(c<r||c>i)return;let l=c===0?s:-s;a(n.clientX,n.clientY+l),a(n.clientX,n.clientY)});return{dispose(){o.dispose(),t.removeEventListener(`mousemove`,r),t.removeEventListener(`mouseleave`,i)}}}var Jd=10,Yd=1.2,Xd=.005,Zd=4,Qd=.08,$d=5;function ef(e,t){let n=Math.abs(t);return n<Jd?!1:n>Math.abs(e)*Yd}function tf(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 nf(e,t,n){let r=e.length>=Zd?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function rf(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>=Qd))return 0;let o=Math.min(a,$d);return i<0?-o:o}function af({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function of(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)-Xd*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=tf(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function sf(e,t){return e===`alternate`||!!t&&t!==`none`}function cf(e,t){return!(e>0)||!(t>0)?0:e/t}var lf=1;function uf(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function df(e,t){for(let n of e)if(n.identifier===t)return n;return null}function ff(e,t){if(uf(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=()=>sf(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return cf(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:lf,clientX:n,clientY:r,bubbles:!0,cancelable:!0}))},_=()=>{if(d=null,!u)return;if(!e.isConnected||!n()||p()){f();return}let r=t.buffer?.active?.viewportY,{scrollLines:i,state:a}=of(u,performance.now());u=a,i!==0&&t.scrollLines(i),u&&(i!==0&&t.buffer?.active?.viewportY===r?f():d=requestAnimationFrame(_))},v=(e,t,n)=>{u=af({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:m(),pendingPx:n}),u&&(d=requestAnimationFrame(_))};e.addEventListener(`touchstart`,e=>{if(f(),!n()||e.touches.length!==1){h();return}let t=e.touches[0];r=t.identifier,i=t.clientX,a=t.clientY,o=t.clientY,s=!1,c=0,l=[]},{passive:!0}),e.addEventListener(`touchmove`,e=>{if(r===null||!n())return;let u=df(e.touches,r);if(!u)return;if(!s){if(!ef(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=nf([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=nf(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=tf(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=nf(l,o,e.timeStamp);let t=rf(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function pf(e){let t=Hr(e,Au,{isTerminalFocused:!0},Nu());return!t||t.action===`board-split`&&!ku()?!1:Ir(t,document.body.dataset.activeView)}var mf=250,hf=`(max-width: 768px)`,gf=12,_f=14,vf=5e4,yf=!1;function bf(e){yf=e}var xf=!1;window.addEventListener(`blur`,()=>{xf=!0}),window.addEventListener(`focus`,()=>{xf=!1});function Sf(e){let t=document.activeElement;return pc({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:xf,isPhoneLayout:Ko()})}function Cf(e,t,n){let r=window.matchMedia?.(hf).matches?gf:_f,i=new n.Terminal({cursorBlink:yf,fontSize:r,fontFamily:Tu(),theme:Za(),scrollback:vf,allowProposedApi:!0}),a=new n.FitAddon;i.loadAddon(a),Kl(e),i.open(e),Ss(e,t,i);let o=Fd(i,t);i.options.linkHandler=Wd(i,o),Kd(i,o),xl(i,t.abortController.signal),t.term=i,t.fitAddon=a,Ao(t);let s=null,c=null,l=!1,u=null,d=null;function f(){c!==null&&(clearTimeout(c),c=null)}function p(){if(!l)return null;let e=t.fitAddon;if(!e)return null;let n=e.proposeDimensions();return n?{cols:n.cols,rows:n.rows}:null}function m(e){if(!l||!Sf(t.card)||t.dataWs?.readyState!==WebSocket.OPEN)return!1;t.dataWs.send(JSON.stringify({type:`claim`,cols:e.cols,rows:e.rows})),u=e,d=null;let n=fc({authoritative:t.ptySize??null,isActiveViewer:l,lastClaim:u});return t.card.dataset.grid=n?`following`:`exact`,!0}function h(e){f(),d=e,c=setTimeout(()=>{c=null,m(e)},mf)}function g(){d&&c===null&&m(d)}function _({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=yc({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:p(),isActiveViewer:l,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:u});r.resizeTo&&n.resize(r.resizeTo.cols,r.resizeTo.rows),t.card.dataset.grid=r.isFollowing?`following`:`exact`,r.keepsPendingSettle||(f(),d=null),r.sendUnview?(u=null,t.dataWs?.send(JSON.stringify({type:`unview`}))):r.owedClaim&&(e&&m(r.owedClaim)||h(r.owedClaim))}function v(){let e=_c({authoritative:t.ptySize??null,isActiveViewer:l,isDocumentEngaged:Sf(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:u});e!==`none`&&(f(),e===`rebid`&&(u=null),_({isActivationEdge:!0}))}let y=new ResizeObserver(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,_()}))});y.observe(e),t.resizeObserver=y,t._syncGrid=_,t._resetGridClaim=()=>{f(),d=vc({isActiveViewer:l,lastClaim:u,owedClaim:d}),u=null},t._retryOwedGridClaim=g,t._syncGridOnEngagementEdge=v,t._isActiveViewer=()=>l,t._setActiveViewer=e=>{l!==e&&(l=e,f(),d=null,e&&Mo(t),_({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{xf=!1,v()},{signal:t.abortController.signal}),Lo(t);let b=null;i.onScroll(()=>{b===null&&(b=requestAnimationFrame(()=>{b=null,t.term&&(t.term.refresh(0,t.term.rows-1),gs(t,t.term))}))}),i.onWriteParsed(()=>gs(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=_s(r)}catch(e){return vs(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(ys(t,i,`osc52 write`),!0):(bs(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`&&Os(t,`\x1B\r`),!1;if(e.type!==`keydown`)return!0;if(pf(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),ys(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(Os(t,`\x1B`),!1):!0}),ks(e,i,t),ff(e,i)}function wf(){Ms(!0);for(let e of k.values())Zl(e)}function Tf(){Ms(!1);for(let e of k.values())Zl(e),Ds(e)}function Ef(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{Os(e,n),e.unseenOutcome&&s({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{Rl(e,t,n)}),js(e.termWrap,t,e.abortController.signal),Zl(e),queueMicrotask(()=>{Ul(t,e)&&du(t,e,n)}))}function Df(e,t){if(e.term||Jl.has(e))return;let n=wo();if(n){Of(e,t,n);return}Jl.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},Kl(e.termWrap),Zl(e),To().then(n=>{Jl.delete(e),e.term||e.abortController.signal.aborted||k.get(t)!==e||(Of(e,t,n),e._setActiveViewer?.(r))},()=>{Jl.delete(e),Zl(e)})}function Of(e,t,n){Cf(e.termWrap,e,n),Ef(e,t)}function kf(e){e?._syncGridOnEngagementEdge?.()}function Af(e,t){if(!e)return;Df(e,t),Vl(e,t),Mo(e);let n=e.term;n&&(n.refresh(0,n.rows-1),kf(e))}function jf(e,t,n){e&&(n&&Df(e,t),e._setActiveViewer?.(n))}var Mf={isVisible:document.visibilityState===`visible`,isFrozen:!1,isProbing:!1,isReplacing:!1},Nf=document.visibilityState===`visible`?null:Date.now(),Pf=null,Ff=null;function If(){Pf!==null&&window.clearTimeout(Pf),Pf=null}function Lf(e){If();let t=Date.now()+e;Pf=window.setTimeout(()=>{Pf=null,Bf({kind:`heartbeat-due`,lateByMs:Date.now()-t})},e)}function Rf(){Ff!==null&&window.clearTimeout(Ff),Ff=null}function zf(e){switch(e.kind){case`probe-control`:_(e.deadlineMs,e.isAnnounced).then(e=>{Bf({kind:e?`pong`:`pong-missed`})});return;case`replace-control`:o();return;case`close-sockets`:Rf(),v(),hu();return;case`reconnect-shown-terminals`:pu();return;case`hold-input`:wf();return;case`release-input`:Tf();return;case`schedule-heartbeat`:Lf(e.inMs);return;case`cancel-heartbeat`:If();return}}function Bf(t){let n=e(Mf,t);Mf=n.state;for(let e of n.actions)zf(e)}function Vf(){if(document.visibilityState!==`visible`){Nf=Date.now(),Bf({kind:`hidden`});return}let e=Nf===null?0:Date.now()-Nf;Nf=null,yo(`shown`,e),Bf({kind:`shown`,hiddenForMs:e})}function Hf(e){Rf(),_o(`control-${e}`),e===`connecting`?Ff=window.setTimeout(()=>{Ff=null,Bf({kind:`handshake-overdue`})},t):(e===`opened`&&eo(),Bf({kind:e===`opened`?`control-opened`:`control-closed`}))}function Uf(){yo(`resumed`,Nf===null?0:Date.now()-Nf),Bf({kind:`resumed`})}function Wf(){let e=Reflect.get(navigator,`connection`);e instanceof EventTarget&&e.addEventListener(`change`,()=>{vo(`link`),Bf({kind:`network-changed`})})}function Gf(){m(Hf),document.addEventListener(`visibilitychange`,Vf),document.addEventListener(`freeze`,()=>Bf({kind:`frozen`})),document.addEventListener(`resume`,Uf),window.addEventListener(`pagehide`,e=>{e.persisted&&Bf({kind:`frozen`})}),window.addEventListener(`pageshow`,e=>{e.persisted&&Uf()}),window.addEventListener(`online`,()=>{vo(`online`),Bf({kind:`network-changed`})}),window.addEventListener(`offline`,()=>vo(`offline`)),Wf()}var Kf=!1,qf=!1,Jf=!1,Yf=null,Xf=null;function Zf(){return Xf??=N(()=>import(`./nyan-cat-DFntGsFR.js`).then(e=>e.r).then(e=>(Yf=e,e),e=>(Xf=null,y(`flying-animals`,`nyan cat failed to load: ${l(e)}`),null)),__vite__mapDeps([2,1,3,4,5,6,7,8])),Xf}function Qf(e){!Jf||e.currentFlightBlockReason(!0)?e.stopNyanCat():e.startNyanCat()}function $f(){qf=!0,ep(zr())}function ep(e){let t=document.documentElement;Kf||(Kf=!0,qo(()=>ep(zr())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>ep(zr()))),Jf=e,e?(t.dataset.flyingAnimals=`true`,Yf?Qf(Yf):qf&&Zf().then(e=>{e&&Qf(e)})):(delete t.dataset.flyingAnimals,Yf?.stopNyanCat())}var tp=45e3,np=`The server did not answer within ${tp/1e3} s.`,rp=`Select the issue to load its description.`,ip=null,ap=null,op=new Map,sp=null,cp=new Map,lp=new Map,up=null,dp=new Map,fp=new Map,pp=new Map,mp=new Map,hp=new Set;function F(e){for(let t of hp)t(e)}function gp(e){return`${e.key}:${e.updatedAt}`}function _p(e){let t=cp.get(e);t&&(cp.delete(e),dp.set(t.issueKey,{text:np,tone:`error`}),F(`detail`))}function vp(e){let t=cp.get(e);return t?(clearTimeout(t.timeoutHandle),cp.delete(e),t):null}function yp(){return{latestStatus:ap,issueByKey:op,selectedKey:ip}}function bp(e){hp.add(e)}function xp(e){ip=e,up&&up.issue.key!==e&&(up=null)}function Sp(){if(ip)return op.get(ip)??(up?.issue.key===ip?up.issue:void 0)}function Cp(e){return up?.issue.key===e.key&&up.isClosed}function wp(e){return[...lp.values()].some(t=>t.issue.key===e.key)}function Tp(e,t){if(wp(e))return;let n=d(`set-issue-state`);sp?.({type:`set-issue-state`,requestId:n,repo:e.repo,issueNumber:e.number,state:t})?(lp.set(n,{issue:e,state:t,timeoutHandle:setTimeout(()=>{lp.delete(n),dp.set(e.key,{text:np,tone:`error`}),F(`detail`)},tp)}),dp.set(e.key,{text:t===`closed`?`Closing issue.`:`Reopening issue.`,tone:`busy`}),F(`detail`)):(dp.set(e.key,{text:S,tone:`error`}),F(`detail`))}function Ep(e){let t=lp.get(e.requestId);if(!t)return;clearTimeout(t.timeoutHandle),lp.delete(e.requestId);let{issue:n,state:r}=t;e.ok?(up={issue:n,isClosed:r===`closed`},dp.set(n.key,{text:r===`closed`?`Closed as completed.`:`Reopened.`,tone:`ok`}),F(`detail`)):(dp.set(n.key,{text:e.error||`Could not ${r===`closed`?`close`:`reopen`} the issue.`,tone:`error`}),F(`detail`))}function Dp(e){return[...cp.values()].some(t=>t.issueKey===e.key)}function Op(e){return dp.get(e.key)}function kp(e){let t=gp(e),n=pp.get(t);return n===``?`No description.`:n??mp.get(t)??`Loading description.`}function Ap(e){let t=gp(e);if(pp.has(t)||[...fp.values()].some(e=>e.cacheKey===t))return;let n=d(`issue-detail`);mp.delete(t),sp?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?fp.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{fp.delete(n),mp.set(t,`${np} ${rp}`),F(`detail`)},tp)}):mp.set(t,`${S} ${rp}`)}function jp(e){let t=e.projectId;if(!t||Dp(e))return;let n=d(`open-issue-session`);sp?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(cp.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>_p(n),tp)}),dp.set(e.key,{text:`Opening session.`,tone:`busy`}),F(`detail`)):(dp.set(e.key,{text:S,tone:`error`}),F(`detail`))}function Mp(e){sp?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function Np(e){sp=e}function Pp(){F(`session-state`)}function Fp(e){if(!e){for(let e of cp.values())clearTimeout(e.timeoutHandle),dp.set(e.issueKey,{text:S,tone:`error`});cp.clear();for(let e of lp.values())clearTimeout(e.timeoutHandle),dp.set(e.issue.key,{text:S,tone:`error`});lp.clear();for(let e of fp.values())clearTimeout(e.timeoutHandle),mp.set(e.cacheKey,`${S} ${rp}`);fp.clear(),F(`status`)}}function Ip(e){let t=ap?.issues.find(e=>e.key===ip);ap=e,op=new Map(e.issues.map(e=>[e.key,e])),up&&!up.isClosed&&op.has(up.issue.key)&&(up=null);let n=e.issues.find(e=>e.key===ip);n&&n.updatedAt!==t?.updatedAt&&Ap(n),F(`status`)}function Lp(e){let t=fp.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),fp.delete(e.requestId),e.ok&&e.body!==null&&pp.set(t.cacheKey,e.body),e.ok&&e.body!==null||mp.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),F(`detail`))}function Rp(e){if(typeof e.requestId!=`string`)return;let t=vp(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`;dp.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=ap?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),F(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;dp.set(n,{text:r,tone:`error`}),F(`detail`)}var zp=new Map,Bp=new Set;function Vp(e){let t=Re.safeParse(e);if(!t.success)y(`reviews`,`dropped github-prs: ${r(t.error.issues)}`);else{zp=new Map(Object.entries(t.data.prs));for(let e of Bp)e()}}function Hp(e){return zp.get(e.toLowerCase())}function Up(e){Bp.add(e)}var Wp=20,Gp=[],Kp=null,qp=!1,Jp=0,Yp=null;function Xp(){return Yp??=N(()=>import(`./celebration-player-C2GC0Ycy.js`),__vite__mapDeps([9,10,6,3,4,5,7])).catch(e=>(Yp=null,y(`merge-celebration`,`celebration player failed to load: ${l(e)}`),null)),Yp}function Zp(e){return qp?`playing`:e?`queued`:`empty`}function Qp(){if(!Kp)return;let e=Gp.length>0,t=Zp(e);Kp.tray.dataset.state=t,Kp.count.textContent=e?String(Gp.length):``,Kp.toggle.element.disabled=t!==`queued`,Kp.toggle.setState(t===`queued`?`attention`:`idle`)}function $p(){let e=Gp.shift();if(qp=e!==void 0,Qp(),!e)return;let t=Jp;Jp+=1,Xp().then(n=>{n?(n.playCelebration(e,t),window.setTimeout($p,n.CELEBRATION_DURATION_MS)):(Gp.unshift(e),qp=!1,Qp())})}function em(e,t,n){Kp={tray:e,toggle:t,count:n},t.element.addEventListener(`click`,()=>{Jp=0,$p()}),Qp()}function tm(e){Gp.push(e),Gp.length>Wp&&Gp.shift(),Qp()}var nm={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},rm=new Set([`FAILURE`,`ERROR`]);function im(e){return nm[e]}function am(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&&rm.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function om(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 sm(e){let t=Ft.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:om(t)}}var cm=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],lm=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],um={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`},dm={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`},fm={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`},pm={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 mm(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 hm(e){return cm[e.rows.reduce((e,{pr:t})=>Math.min(e,cm.indexOf(um[t.stage])),cm.length-1)]}function gm(e){let t=new Map(cm.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of mm(e)){let e=t.get(hm(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return lm.flatMap(e=>t.get(e)??[])}function _m(e,t){return mm(e).find(e=>e.rows.some(e=>e.pr.key===t))?.rows??[]}function vm(e){return e.stackSize<2?null:`Stack ${e.depth+1}/${e.stackHeight}`}function ym(e){return dm[e]}function bm(e){return fm[e]}function xm(e){return pm[e]}function Sm(e){return e?.isKeepMergeableEnabled!==!1}function Cm(e,t){if(!t||!e.keepMergeable||e.isKeepMergeableFixInFlight)return!1;let n=e.keepMergeableAttempt?.outcome;return n!==void 0&&n!==`pushed`&&n!==`stopped`}function wm(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...sm({...n,repo:r}),...e}]})}function Tm(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 Em(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 Dm=3;function Om(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,Dm).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 km(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:bt(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,isAuthorOrgMember:n.isAuthorOrgMember,liveHead:n.headRefOid,prStage:sm(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n)}}var Am=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`];function jm(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 Mm(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function Nm(e){return e.status===`posted`&&Pm(e)}function Pm(e){if(!Mm(e)||xt(e))return!1;let t=zm(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 Fm(e){return Bm(e).length>0||Nm(e)}function Im(e){return Fm(e)?`actionable`:jm(e).band}function Lm(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[jm(t).band].push(t);for(let e of Am)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(Fm(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!Vm(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[Im(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 Am)t.ready.push(...n[e]);return t}function Rm(e,t){return e.commit===t?e.isViewer||qt.has(e.state):!1}function zm(e){return e.liveHead??e.reviewedHead}function Bm(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function Vm(e){return Bm(e).length>0?!0:xt(e)?!1:Pm(e)?!0:!(e.githubReviews??[]).some(t=>Rm(t,zm(e)))}function Hm(e,t){return`${e}#${t}`}var Um=null,Wm={},Gm=[],Km=[],qm={},Jm={},Ym=[],Xm={},Zm={},Qm={},$m=null,eh=new Set,th=new Map,nh=!1,rh=new Set;function ih(e){for(let t of rh)t(e)}function ah(){return[...th].flatMap(([e,t])=>{let n=k.get(e);return!n||t.length===0?[]:[{id:e,title:Kn(n)||e,links:t}]})}function oh(){let e=wm(Um?.prs??[],Hp),t=Em($m,e);$m=e,uh(t),ih({kind:`prs`})}function sh(){nh||(nh=!0,queueMicrotask(()=>{nh=!1,oh()}))}function ch(e){rh.add(e)}function lh(){return{prs:wm(Um?.prs??[],Hp).map(e=>({...e,reviewItems:Jm[e.key]??e.reviewItems})),status:Um,sessionsByPrKey:Tm(ah()),handledByPr:Wm,prFlowWarnings:Gm,prFlowApprovals:Km,sourceRunsByPr:qm,prFlowActions:Ym,actionRunsByPr:Xm,prActionsByPr:Zm,prActionRunsByPr:Qm}}function uh(e){let t=e.filter(e=>!eh.has(e.key));if(t.length!==0){for(let e of t)eh.add(e.key);tm(Om(t))}}function dh(e){th=e,sh()}function fh(){ih({kind:`session-state`})}function ph(e){let t=Jt.safeParse(e);t.success?(Um=t.data,oh()):y(`reviews`,`dropped my-prs-status: ${r(t.error.issues)}`)}function mh(e){let t=At.safeParse(e);t.success?(Wm=t.data.handledByPr,Gm=t.data.warnings,Km=t.data.pendingApprovals,qm=t.data.sourceRunsByPr,Jm=t.data.reviewItemsByPr,Ym=t.data.actions,Xm=t.data.actionRunsByPr,Zm=t.data.prActionsByPr,Qm=t.data.prActionRunsByPr,ih({kind:`prs`})):y(`reviews`,`dropped pr-flows-status: ${r(t.error.issues)}`)}function hh(e){ih({kind:`merge-result`,message:e})}function gh(e){ih({kind:`connection`,isConnected:e})}Up(sh);var _h=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-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-queued`,group:`queued`,kind:null,action:null},{state:`mine-merged`,group:`done`,kind:null,action:null},{state:`review-settled`,group:`done`,kind:null,action:null},{state:`review-discarded`,group:`parked`,kind:null,action:null},{state:`mine-draft`,group:`parked`,kind:null,action:null}].map((e,t)=>[e.state,{...e,rank:t}])),vh={turn:`Your turn`,working:`Agent working`,queued:`Queued`,waiting:`Waiting on others`,done:`Done`,parked:`Parked`,aside:`Set aside`},yh=[`turn`,`working`,`queued`,`waiting`,`done`,`parked`],bh=new Set([`done`,`parked`]),xh=[`queued`,`working`,`turn`,`now`,`waiting`,`done`,`parked`],Sh={...vh,turn:`Ready`,now:`Reviewing now`};function Ch(e){return xh.map(t=>e.find(e=>e.id===t)??{id:t,title:Sh[t],items:[]})}function wh(e,t){let n=new Set(tg(e).map(e=>e.key)),r=t.filter(e=>n.has(e)),i=new Set(r);return{groups:e.flatMap(e=>e.id===`turn`?[{id:`now`,title:Sh.now,items:e.items.filter(e=>i.has(e.key))},{id:`turn`,title:Sh.turn,items:e.items.filter(e=>!i.has(e.key))}]:[e]),pulledKeys:r}}function Th({pulledKeys:e,key:t,turnKeys:n,limit:r}){return e.includes(t)?e.filter(e=>e!==t):r>0&&e.length>=r||!n.includes(t)?[...e]:[...e,t]}function Eh(e,t){return t>0?`${e} / ${t}`:String(e)}var Dh={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`},Oh={settled:`review-settled`,inReview:`review-in-flight`,queued:`review-queued`,posted:`review-posted`,discarded:`review-discarded`},kh=Am.indexOf(`waiting-on-author`);function Ah(e){return e.status===`ready`?jm(e).band===`blocking-others`?`review-direct-ask`:`review-ready`:`review-follow-up`}function jh(e,t){return t===`ready`?Ah(e):t===`attention`?`status`in e&&e.status===`error`?`review-failed`:`review-stale`:Oh[t]}function Mh(e,t,n){let r=e.state===`OPEN`;if(r&&Cm(e,n))return`mine-repair-failed`;if(r&&n&&e.keepMergeable&&e.isKeepMergeableFixInFlight)return`mine-repairing`;let i=Dh[e.stage];return _h.get(i)?.group===`turn`&&e.stage!==`ready`&&t.has(De(e))?`mine-agent-fixing`:i}function Nh(e,t){return t===`ready`||t===`attention`?Am.indexOf(Im(e)):t===`queued`?Am.indexOf(jm(e).band):0}function Ph(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function Fh(e){let t=Bm(e).flatMap(e=>Ph(e.lastReplyAt)??[]);return t.length>0?Math.max(...t):null}function Ih(e,t){if(t===`inReview`)return Ph(e.startedAt)??1/0;if(t===`queued`)return Ph(e.prCreatedAt)??1/0;let n=e,r=t===`posted`?Ph(n.postedAt):null;return Fh(n)??r??Ph(n.reviewedAt)??Ph(n.prCreatedAt)??1/0}function Lh(e){return Ph(e.mergedAt??e.stageSinceMs??e.updatedAt)??1/0}var Rh=864e5,zh=3*Rh;function Bh(e){return e.source===`team`?Ih(e.review,e.kind):Lh(e.pr)}function Vh(e,t,n){if(e===`done`||e===`parked`||!Number.isFinite(t))return null;let r=n-t;return r>zh?`old`:r>=Rh?`aging`:`fresh`}function Hh(e,t){return t>0&&e>t}function Uh(e,t,n,r){let i=_h.get(e);return i?[{item:r(i),row:i,priorityBandRank:t,waitStartMs:n}]:[]}function Wh(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=>Uh(jh(t,e),Nh(t,e),Ih(t,e),({action:n,kind:r})=>({source:`team`,key:`team:${t.key}`,prKey:De(t),kind:e,review:t,action:n,attention:r}))))}function Gh(e,t,n){return gm(e).flatMap(e=>e.rows).flatMap(e=>Uh(Mh(e.pr,t,n),0,Lh(e.pr),({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 Kh(e){return e.row.kind===`failed`?0:e.row.state===`review-direct-ask`?1:e.priorityBandRank>=kh?3:2}function qh(e,t){let n=e.waitStartMs-t.waitStartMs;return e.row.group===`turn`?Kh(e)-Kh(t)||n||e.item.key.localeCompare(t.item.key):e.row.rank-t.row.rank||e.priorityBandRank-t.priorityBandRank||n}function Jh(e,t,n,r){let i=new Map(yh.map(e=>[e,[]]));for(let a of[...Wh(e),...Gh(t,n,r)])i.get(a.row.group)?.push(a);return yh.map(e=>({id:e,title:vh[e],items:(i.get(e)??[]).toSorted(qh).map(e=>e.item)}))}var Yh=[`turn`,`working`,`aside`],Xh=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 Zh(e){return e.status===`ready`&&e.verdict?`ready-${e.verdict}`:e.status}function Qh(e){let t=Date.parse(e.item.createdAt);return Number.isNaN(t)?1/0:t}function $h(e){let t=e.flatMap(e=>{let t=Xh.get(Zh(e));return t?[{row:t,askedAtMs:Qh(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 Yh.map(e=>({id:e,title:vh[e],items:t.filter(t=>t.row.group===e).map(e=>e.item)}))}function eg(e){return`${e.key}@${e.entry.status}:${e.entry.finishedAt??``}`}function tg(e){return e.find(e=>e.id===`turn`)?.items??[]}function ng(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function rg(e,t){return ng(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function ig(e){return e.source===`mine`?Hm(e.pr.repo,e.pr.number):Hm(e.review.repo,e.review.number)}function ag(e,t){return tg(e).map(e=>({id:e.key,kind:e.attention??`waiting`,name:t(e)}))}function og(e){return ag(e,ig)}function sg(e,t){return og(e).filter(e=>e.id!==t)}function cg({capturedOrder:e,actedKey:t,groups:n}){let r=tg(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}var lg=new Set([`turn`,`now`]);function ug(e,t){let n=e.find(e=>lg.has(e.id)&&e.items.some(e=>e.key===t));return n?`${n.items.findIndex(e=>e.key===t)+1} of ${n.items.length} in ${n.title}`:``}function dg(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 fg(e){return tg(e).map(dg)}function pg({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:dt([...i]),unseen:dt([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:dt([...a]),unseen:dt([...o])}}function mg(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 hg(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function gg(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)??t.find(e=>e.watcherProblem)??n[0],isRefreshing:t.some(e=>e.isRefreshing)}}var _g=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`],[`m`,`toggle-pulled`],[`h`,`previous-column`],[`l`,`next-column`],[`ArrowLeft`,`previous-column`],[`ArrowRight`,`next-column`]]);function vg(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`:_g.get(e.key)??null}function yg(e,t,n){let r=e.filter(e=>e.length>0);if(r.length===0)return null;let i=r.findIndex(e=>t!==null&&e.includes(t));if(i===-1)return r[0][0];let a=r[i].indexOf(t??``),o=r[Math.min(r.length-1,Math.max(0,i+n))];return o[Math.min(a,o.length-1)]}function bg(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 xg=null,Sg=null,Cg=new Set;function wg(e){for(let t of Cg)t(e)}function Tg(){Sg=km(xg,Hp),wg({kind:`status`})}function Eg(e){Cg.add(e)}function Dg(){return Sg}function Og(){return Lm(Sg)}function kg(e){let t=wt.safeParse(e);t.success?(xg=t.data,Tg()):y(`reviews`,`dropped team-review-status: ${r(t.error.issues)}`)}function Ag(e){wg({kind:`action-result`,message:e})}function jg(e){wg({kind:`open-session-result`,message:e})}function Mg(e){wg({kind:`connection`,isConnected:e})}Up(Tg);var Ng=[],Pg=null,Fg=null,Ig=null,Lg=!1,Rg=null,zg=Xr(),Bg=li(),Vg=new Set(Bg.split(`|`).filter(Boolean)),Hg=new Set,Ug=new Set;function Wg(e){for(let t of Ug)t(e)}function Gg(e){e!==zg&&(zg=e,Ur(e))}function Kg(e){e!==Bg&&(Bg=e,Vg=new Set(e.split(`|`).filter(Boolean)),Fr(e))}function qg(){return Dg()!==null&&lh().status!==null}function Jg(){if(!qg())return;let e=pg({turnEntries:fg(Ng),acknowledged:zg,unseen:Bg,isLooking:Fg?.isLooking()??!1});Gg(e.acknowledged),Kg(e.unseen),Rg?.(e.isShown)}function Yg(e){Ig=e,Wg({kind:`reveal`})}function Xg(e){Ug.add(e)}function Zg(e){Fg=e,Jg()}function Qg(){let{prs:e,sessionsByPrKey:t,status:n}=lh();return Ng=Jh(Og(),e,new Set(t.keys()),Sm(n)),Jg(),Ng}function $g(){qg()&&(Gg(dt(fg(Ng))),Jg())}function e_(e){Rg=e,Jg()}function t_(){return Bg}function n_(e){return Vg.has(e)}function r_(e){return Vg.has(e)?(Kg(dt([...Vg].filter(t=>t!==e))),!0):!1}function i_(e){Pg=e}function a_(){return Pg}function o_(){let e=Ig;return Ig=null,e}function s_(e){if(e!==Lg){Lg=e;for(let e of Hg)e()}}function c_(e){Hg.add(e)}function l_(){return document.documentElement.dataset.layout===`phone`&&Lg}function u_(){l_()&&Wg({kind:`return-to-queue`})}function d_(){let e=sg(Ng,Fg?.selectedKey()??null)[0]?.id??null;return e?(Yg(e),!0):!1}function f_(e){let t=Ng.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!Pg?.openReviews()?!1:(Yg(t.key),$g(),!0)}Eg(e=>{e.kind===`status`&&Qg()}),ch(e=>{e.kind===`prs`&&Qg()});function p_(){return{groups:Ng}}var m_={OPEN:0,MERGED:1,CLOSED:2};function h_(e){return e?m_[e.state]:m_.OPEN}function g_(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:sn(void 0)};let i=bm(t.stage);return{key:n,text:r,detailText:`${r} ${t.title}`,stateText:ym(t.stage),url:t.url,prTitle:t.title,look:{icon:xm(t.stage),tone:i},tier:sn(i)}}function __(e,t){let n=e.map(e=>{let n=t(De(e));return{link:e,pr:n?sm(n):void 0}});return n.sort((e,t)=>h_(e.pr)-h_(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>g_(e,t))}var v_=new Map;function y_(e){return document.querySelectorAll(`[data-pr-rows-for="${CSS.escape(e)}"]`)}function b_(e){return __(v_.get(e)??[],Hp).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,onActivate:()=>{f_(e.key)||nd(e.url)}}))}function x_(e,t){let n=Be(`session-pr-chip-unlink`);return n.append(Te(st)),n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),Xt({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:()=>{Ki(t,{type:`unlink-session-pr`,id:t,key:e.key})}})}),n}function S_(e,t){let n=gn({...e,text:e.key},{...e,className:`linked-pr-row-link`});e.prTitle&&n.append(D(`span`,`linked-pr-row-title`,e.prTitle)),e.stateText&&n.append(D(`span`,`linked-pr-row-stage`,e.stateText));let r=D(`li`,`linked-pr-row`);return r.append(n,x_(e,t)),r}function C_(e,t){e.dataset.prRowsFor=t;let n=b_(t);In(e,n,e=>S_(e,t),{visibleCount:n.length})}function w_(e){for(let t of e){let e=t.dataset.prRowsFor;e&&C_(t,e)}}function T_(e,t){let n=Pt.shape.links.safeParse(t??[]);v_.set(e,n.success?n.data:[]),w_(y_(e)),_n(e),dh(v_)}function E_(e){v_.delete(e),dh(v_)}Up(()=>{w_(document.querySelectorAll(`[data-pr-rows-for]`)),jn()});function I(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function D_(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function O_(e,t){return e||D_(t)>0}var k_={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},A_=null,j_=!1,M_=!1,N_=null,P_=null,F_=null,I_=`—`;function L_(e){return e==null?I_:mt(e,`GB`)}function R_(e){return e==null?I_:me(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function z_(e){return e==null?I_:`${R_(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function B_(){let e=D(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=D(`div`,`health-summary`),n=Be(`health-toggle`);n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=D(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,D(`span`,`health-toggle-label`,`Health`));let i=D(`div`,`health-stats`);t.append(n,i);let a=D(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{M_=!M_,e.dataset.expanded=String(M_),n.setAttribute(`aria-expanded`,String(M_)),a.hidden=!M_,M_&&(s({type:`request-health-snapshot`}),H_())}),e.append(t,a),N_=e,P_=i,F_=a,e}function V_(){if(!P_||!A_)return;let e=A_,t=D_(e.anomalies);P_.innerHTML=`
|
|
3
3
|
<span class="health-stat"><span class="health-stat-label">Heap</span> ${L_(e.process.heapUsed)}</span>
|
|
4
4
|
<span class="health-stat"><span class="health-stat-label">Memory</span> ${L_(e.process.rss)}</span>
|
|
5
5
|
<span class="health-stat"><span class="health-stat-label">Buffers</span> ${L_(e.process.external)}</span>
|
|
@@ -70,8 +70,8 @@ import{C as e,S as t,T as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h 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 U_(){if(!N_)return;let e=O_(j_,A_?.anomalies),t=N_.hidden;N_.hidden=!e,e&&t&&A_&&(V_(),M_&&H_())}function W_(e){j_=e,U_()}function G_(e){if(N_)return N_;let t=B_();return e.appendChild(t),U_(),t}function K_(e){A_=e,U_(),N_&&!N_.hidden&&(V_(),M_&&H_())}var q_=null,J_=null,Y_=!1,X_=null,Z_=new Set;function Q_(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function $_(){for(let e of Z_)e()}function ev(){return{report:q_,hasReportSendFailed:Y_}}function tv(e){Z_.add(e)}function nv(e){J_=e}function rv(){if(!J_)return;X_=d(`hooks-report`);let e=J_({type:`request-hooks-report`,requestId:X_});e!==!Y_&&(Y_=!e,$_())}function iv(e){Q_(e,X_)&&(q_=e,Y_=!1,$_())}function av(){rv()}var ov=new Map,sv=new Map,cv=new Map,lv=null,uv=`op://vault/item/field`,dv=`or paste the value`;function fv(e,t){return Object.fromEntries([...e].map(([e,n])=>[e,t(n)]).filter(([,e])=>e))}function pv(e,t,n){s(t?{type:`secret-decision`,id:e,isAllowed:t,referenceByName:fv(n.referenceByName,e=>e.value.trim()),valueByName:fv(n.valueByName,e=>e.value),newItemsVault:n.vault.value.trim()}:{type:`secret-decision`,id:e,isAllowed:t})}function mv(){return lv??`vault name`}function hv(e,t,n){let r=D(`input`,`dialog-input ${e}`);return r.type=`text`,r.placeholder=t,r.spellcheck=!1,r.autocomplete=`off`,r.setAttribute(`aria-label`,n),r}function gv(e,t){let n=D(`div`,`secret-request`);n.setAttribute(`role`,`group`),n.setAttribute(`aria-label`,`Secret request`);let r={referenceByName:new Map,valueByName:new Map,vault:hv(`secret-request-vault`,mv(),`Vault for pasted values`)};cv.set(e,r.vault);let i=D(`div`,`secret-request-rows`);for(let e of t){let t=hv(`secret-request-reference`,uv,`Vault reference for ${e}`),n=hv(`secret-request-value`,dv,`Value for ${e}, saved into the vault`);n.type=`password`,n.autocomplete=`new-password`,r.referenceByName.set(e,t),r.valueByName.set(e,n);let a=D(`div`,`secret-request-row`);a.append(D(`code`,`secret-request-name`,e),t,n),i.append(a)}let a=D(`label`,`secret-request-vault-row`);a.append(D(`span`,`secret-request-vault-label`,`Pasted values go into`),r.vault);let o=D(`div`,`secret-request-actions`);return o.append(w({variant:`secondary`,label:`Deny`,onClick:()=>pv(e,!1,r)}),w({variant:`primary`,label:`Allow`,onClick:()=>pv(e,!0,r)})),n.append(D(`span`,`secret-request-text`,`The agent asks for these secrets. Allow saves each vault reference for this project; a pasted value goes into the vault first.`),i,a,o),n}function _v(e){lv=e;for(let e of cv.values())e.placeholder=mv()}function vv(e){let t=sv.get(e),n=ov.get(e);return t!==void 0&&n!==void 0&&t.dataset.names===n.join(` `)}function yv(e){let t=k.get(e);if(t&&vv(e)&&sv.get(e)?.parentElement===t.termWrap)return;sv.get(e)?.remove(),sv.delete(e),cv.delete(e);let n=ov.get(e);if(!n||!t)return;let r=gv(e,n);r.dataset.names=n.join(` `),sv.set(e,r),t.termWrap.append(r)}function bv(e,t){t.length===0?ov.delete(e):ov.set(e,[...t])}function xv(e){_v(e.newItemsVault),bv(e.id,e.names),yv(e.id)}function Sv(e){_v(e.newItemsVault);let t=[...ov.keys()];ov.clear();for(let[t,n]of Object.entries(e.requests))bv(t,n);for(let e of new Set([...t,...ov.keys()]))yv(e)}var Cv=new Map;function wv(e){return Cv.get(e)??[]}function Tv(e){return wv(e).length>0}function Ev(e){let t=A(e)?.btnDocs;t&&(t.hidden=!Tv(e))}var Dv=null,Ov=null;function kv(){return Ov??=N(()=>import(`./doc-editor-ui-Bav03W4B.js`).then(e=>(Dv=e,e),e=>(Ov=null,y(`doc-editor`,`doc editor failed to load: ${l(e)}`),null)),__vite__mapDeps([11,12,13,4,3,14,15,16])),Ov}function Av(e){kv().then(t=>t?.openDocEditor(e))}function jv(e){kv().then(t=>t?.openDocEditorOn(e))}function Mv(e){Dv?.applyDocsToOpenEditor(e)}function Nv(e){Cv.set(e.id,e.docs),e.docs.length===0&&Cv.delete(e.id),Ev(e.id),Mv(e.id)}function Pv(e){let t=[...Cv.keys()];Cv.clear();for(let[t,n]of Object.entries(e.sessions))Cv.set(t,n);for(let e of new Set([...t,...Cv.keys()]))Ev(e),Mv(e)}var Fv=10,Iv={low:0,medium:1,high:2};function Lv(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 Rv(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 zv(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function Bv(e,t){for(let n of e.hotspots)zv(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`});for(let n of e.blastRadius)n.transitiveDependentCount<Fv||zv(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`})}function Vv(e,t){return e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function Hv(e){return e.conflictRisk===null?-1:Iv[e.conflictRisk]}function Uv(e,t){return t.severity-e.severity||Hv(t)-Hv(e)||e.heading.localeCompare(t.heading)||e.groupKey.localeCompare(t.groupKey)}function Wv(e,t){return e===null||t===null?e??t:Iv[t]>Iv[e]?t:e}function Gv(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?(e.lines.push(n),e.conflictRisk=Wv(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(Vv);return n.sort(Uv)}function Kv(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:Lv(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of Rv(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);Bv(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:Gv(r.values()),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function qv(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 Jv(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 Yv(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=Jv(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 Xv(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function Zv(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 Qv({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=ey(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 $v({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?Qv({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 ey(e){return e||`base`}function ty(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function ny(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function ry({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 iy({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function ay(e){if(!e)return[];let t=new Map;for(let n of[...Yv(e.committed?.diff),...Yv(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 oy(e,t){return t===null?null:e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)??null}function sy(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 cy(e){return e!==E.DORMANT&&e!==E.DONE&&e!==E.FAILED}function ly(e,t){return(Rt.includes(e)||e===E.RUNNING)&&t}function uy(e){let{status:t,reason:n,isFetched:r,hasCommits:i,isWorkspace:a,state:o,effectiveBase:s}=e,c=Zv(e.files),l=cy(o),u=ny(t,n,ly(o,i)),d=iy({fetched:r,changedFileCount:c.files,hasCommits:i}),f=$v({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=ry({status:t,hasCommits:i,live:l,state:o});return{sentence:t===`parked`?`${f.text}. ${ty(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 dy=5e3,fy=new Map,py=new Map,my=new Map,hy=new Map,gy=new Map,_y=new Map,vy=new WeakMap,yy=new WeakMap,by=new Set,xy=new Set,Sy=null,Cy=null,wy=null,Ty=null,Ey=null;function Dy(e){return by.add(e),()=>by.delete(e)}function Oy(e){for(let t of by)t(e)}function ky(e){if(!e)return[];let t=vy.get(e);if(t)return t;let n=ay(e);return vy.set(e,n),n}function Ay(e){if(!e)return null;let t=yy.get(e);if(t)return t;let n=Kv(e);return yy.set(e,n),n}function jy(e){return k.get(e)?.card.dataset.workspace!==void 0}function My(e){let t=k.get(e);if(!t)return null;let n=my.get(e)??null,r=ky(n),i=hy.get(e)??null;return{...uy({status:fy.get(e)||`none`,reason:py.get(e)??null,isFetched:my.has(e),hasCommits:n?.hasCommits===!0,hasDiffError:i!==null,isWorkspace:jy(e),state:t.currentState,effectiveBase:t.effectiveBase,isMergeInFlight:_y.has(e),files:r}),sessionId:e,sessionName:t.card.dataset.session||e,files:r,diffError:i,changeMapView:Ay(gy.get(e)),notice:Sy?.sessionId===e?Sy.text:null,isWorkspace:jy(e)}}function Ny(e,t){Sy={sessionId:e,text:t},Cy&&clearTimeout(Cy),Cy=setTimeout(()=>{Sy=null,Oy(e)},dy),Oy(e)}function Py(e){gy.has(e)||gy.set(e,null),s({type:`request-change-map`,id:e})}function Fy(e){s({type:`request-session-diff`,id:e}),Py(e)}function Iy(e,t){let n=fy.get(e);fy.set(e,t),Xv(n,t)&&(my.delete(e),hy.delete(e),gy.delete(e),e===Li()&&Fy(e)),Oy(e)}function Ly(e,t,n=null){let r=t||`none`;py.set(e,n);let i=_y.get(e);i!==void 0&&i!==r&&_y.delete(e),Iy(e,r)}function Ry(e,t,n=null){py.set(e,n),_y.delete(e),Iy(e,t||`none`)}function zy(e,t){let n=O(e);n&&(my.set(n,t),hy.delete(n),Oy(n))}function By(e,t){let n=O(e);n&&(hy.set(n,t),Oy(n))}function Vy(e,t){let n=O(e);if(!n)return;let r=$e.safeParse(t);r.success&&r.data.sessionId===n&&(gy.set(n,r.data),Oy(n))}function Hy(e){let t=O(e);t&&t===Li()&&Fy(t)}function Uy(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function Wy(e){let t=O(e);if(!t||t!==Li())return;let n=!my.has(t)||hy.has(t),r=!gy.has(t)||Uy(gy.get(t));n&&Fy(t),r&&!n&&Py(t),Oy(t)}function Gy(e){let t=O(e);t&&_y.delete(t)&&Oy(t)}function Ky(e){let t=O(e);fy.delete(t),py.delete(t),my.delete(t),hy.delete(t),gy.delete(t),_y.delete(t),t===Li()?Oi(null):Oy(t)}function qy(e,t){_y.has(e)||(s(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(_y.set(e,fy.get(e)||`none`),Oy(e)):Ny(e,`Not connected. The merge was not sent.`))}function Jy(e){let t=My(e);return t?_y.has(e)?(Ny(e,`Merge is already on its way for "${t.sessionName}".`),!1):t.isMergeEnabled?k.get(e)?.currentState===E.RUNNING?(Xt({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:()=>qy(e,!0)}),!0):(qy(e,!1),!0):(Ny(e,t.mergeRefusal??`Nothing to merge in "${t.sessionName}" right now.`),!1):!1}function Yy(e){let t=My(e);t?.isDiscardShown&&Xt({title:`Discard worktree`,message:`Throw away the worktree changes for "${t.sessionName}"? This cannot be undone.`,confirmLabel:`Discard`,danger:!0,onConfirm:()=>s({type:`discard-session-worktree`,id:e})})}function Xy(){return[...xy].some(e=>!e.hasAttribute(`data-slot-held`))}function Zy(){let e=Xy()&&document.visibilityState===`visible`?Li():null;e!==wy&&(Ty&&clearInterval(Ty),Ty=null,wy=e,s({type:`watch-session-changes`,id:e}),e&&(Ty=setInterval(()=>s({type:`watch-session-changes`,id:e}),it)))}function Qy(e){Ey??=$y(),Ey.observe(e)}function $y(){return document.addEventListener(`visibilitychange`,Zy),Di(e=>{e&&Fy(e),Zy()}),new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&xy.add(t.target),t.isIntersecting||xy.delete(t.target);Zy()})}var eb=!1,tb=new Set;function nb(e){eb=!!e,pb();for(let e of tb)e(eb)}function rb(e){return tb.add(e),()=>tb.delete(e)}function ib(){return eb}function ab(){let e=D(`div`,`debug-close`);return e.append(w({variant:`icon`,size:`small`,label:`Close debug overlay`,icon:Te(st)})),e}function ob(e){return e?ft(new Date(e)):`-`}function sb(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function cb(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${sb(e.quietMs)})`:``}function lb(e){let t=`<span class="debug-dim">${ob(e.ts)}</span>`;if(e.kind===`signal`){let n=I([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${I(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=cb(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${I(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=I(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${I(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${I(e.category||`?`)}: <span class="debug-dim">${I(e.from||`?`)} → ${I(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${I(e.kind||`decision`)}</span>`}function ub(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">${I(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">${I(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${ob(e.timestamp)}</span> ${I(e.from)} → ${I(e.to)} <span class="debug-label">${I(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?`${I(a.signal)} (${I(a.source||`?`)}${a.confidence?`/${I(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">${I(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 ${sb(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">${I(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">${lb(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(ab())}function db(e,t){if(e.debugOpen){fb(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(ab()),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`)&&fb(e)}),s({type:`debug-state`,id:t})}function fb(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function pb(){for(let[,e]of k)e.btnDebug.classList.toggle(`visible`,eb),e.btnTrace.classList.toggle(`visible`,eb),eb||e.debugOpen&&fb(e)}function mb(e){let t=typeof e.id==`string`?k.get(e.id):void 0;t?.debugOpen&&ub(t,e.payload)}function hb(e){A(e)?.debugOpen&&s({type:`debug-state`,id:e})}function gb(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:t===Je}}function _b(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 vb(e,t){return{body:t.join(`
|
|
74
|
-
`),tag:`glimmervoid-alert-${e.id}`,renotify:e.isStart}}var yb=4e3;function bb(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function xb(e,t,n,r=yb){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 Sb=`#plan/`;function Cb(e){return`${Sb}${encodeURIComponent(e)}`}function wb(e){if(!e.startsWith(Sb))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var Tb=null;function Eb(){return Tb??=N(()=>import(`./alert-sound-At4lBeip.js`),__vite__mapDeps([10,6])).catch(e=>(Tb=null,y(`alert-sound`,`alert sound failed to load: ${l(e)}`),null)),Tb}function Db(){let e=Kr();Eb().then(t=>t?.playAlertSound(e))}function Ob(){return typeof Notification>`u`?null:Notification}function kb(){return Ob()!==null}function Ab(){let e=Ob();return e?e.permission:`unavailable`}async function jb(){let e=Ob();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function Mb(){return!kb()&&!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.`:kb()?Ab()===`denied`&&Er()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function Nb(){if(!kb()||!Er())return`off`;let e=Ab();return e===`granted`?`on`:e==="default"?`ask`:`off`}function Pb(){return Er()&&Ab()==="default"}function Fb(e=()=>{}){let t=D(`div`,`notification-permission`),n=()=>{let r=Mb();if(t.replaceChildren(),t.hidden=!r&&!Pb(),r){t.append(D(`p`,`notification-permission-hint text-meta text-text-muted`,r));return}let i=w({variant:`secondary`,label:`Enable desktop notifications`});i.addEventListener(`click`,()=>{i.disabled=!0,jb().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var Ib=`Notifications`,Lb=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,Rb=new Map,zb=!1;function Bb(){zb||(zb=!0,sr({source:Ib,message:Lb,hidesInStreamerMode:!1}))}function Vb(e,t){let n=Rb.get(e)??new Set;n.add(t),Rb.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function Hb(e){let t=Rb.get(e);if(t){Rb.delete(e);for(let e of t)e.close()}}function Ub(e){return!kb()||!Er()||document.documentElement.hasAttribute(`data-streamer`)?!1:e||!document.hasFocus()}function Wb(){return Ub(!1)&&Ab()===`granted`}var Gb=null;function Kb(e,t){let n=Ob();if(!n||(Gb=_b(Gb,t,e.message),or(Ib),!xb(window.localStorage,bb(`group-${t.id}`,`${e.session}-${e.category}`),Date.now())))return;let r=t.sessionIds.length===1?k.get(e.session):void 0,i=t.sessionIds.length>1?`${t.sessionIds.length} sessions`:r?Kn(r):`Glimmervoid`;try{let r=new n(i,vb(t,Gb.lines));r.onclick=()=>{window.focus(),e.kind===`plan`&&(window.location.hash=Cb(e.session)),r.close()};for(let e of t.sessionIds)k.has(e)&&Vb(e,r)}catch{}}var qb=null;function Jb(e){return!e||e.id!==qb&&(qb=e.id,!0)}function Yb(e){k.get(e.session)?._isActiveViewer?.()===!0?s({type:`alert-seen`,id:e.session}):Jb(e.group)&&ri()&&Db()}function Xb(e,t){t?Kb(e,t):ex(e)}function Zb(){let e=Reflect.get(navigator,`userAgentData`);return typeof e!=`object`||!e?!1:Reflect.get(e,`platform`)===`macOS`}function Qb(e){!document.hasFocus()&&Wb()&&ex(e)}function $b(e){if(e.category===`answered`){Qb(e);return}if(document.hasFocus()){Yb(e);return}let t=e.group;Wb()&&(Xb(e,t),!Zb())||(Ub(!1)&&Ab()===`denied`&&Bb(),t?.isStart!==!1&&Jb(t)&&ri()&&Db())}function ex({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=Ob();if(!a||!Ub(!!i)||(a.permission===`denied`&&Bb(),a.permission!==`granted`)||(or(Ib),!xb(window.localStorage,bb(e,t),Date.now())))return;let o=typeof e==`string`?e:``,s=k.get(o),c=s?Kn(s):``;try{let i=new a(c||`Glimmervoid`,gb(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=Cb(o)),i.close()},s&&Vb(o,i)}catch{}}var tx=null;function nx(){return tx??=N(()=>import(`./resume-dialog-BuSL2zL_.js`),__vite__mapDeps([17,13,4,3,12,14,18,19,15])).catch(e=>(tx=null,y(`resume-dialog`,`restart dialog failed to load: ${l(e)}`),null)),tx}var rx=null,ix=null;function ax(){return ix??=N(()=>import(`./plan-face-DpMnseaN.js`).then(e=>(rx=e,e),()=>(ix=null,null)),__vite__mapDeps([20,13,4,3,21,15,22,23,24])),ix}function ox(e){let t=D(`section`,`plan-face`);t.hidden=!0;let n=null,r=!1,i=null,a={},o=new Map;function s(s){if(r=!1,e.signal?.aborted)return;if(!s){e.reportProblem(`The plan view did not load. Open the plan again to retry.`),i!==null&&e.showTerminal(),i=null;return}let c=s.createPlanFace(e);t.replaceWith(c.el),c.update(a);for(let e of o.values())c.update({draft:e});o.clear(),n=c,i!==null&&c.show(i)}return{get el(){return n?.el??t},show(e){n?n.show(e):(i=e,r||(r=!0,ax().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 sx=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function cx(e){return e===`approve`||e===`approve-accept-edits`}function lx(e){return(e.state===`decided`||e.state===`closed`)&&cx(e.lastDecision)}function ux(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&lx(n)}function dx(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function fx(e){let t=dx(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 px(e,t){return dx(e,t)?.openRevision?.revision??null}function mx(e,t,n){if(n===null)return null;let r=dx(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function hx(e,t){let n=t-e;return Number.isFinite(n)?fe(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function gx(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 _x(e,t,n){let r=gx(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return sx.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function vx(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 yx(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function bx(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+ct}function xx(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 ${ut} characters, so nothing was sent`:yx(e)>1e4?`the feedback composes more than the ${gt} characters the hook reply carries, so nothing was sent`:bx(e)>Ue?`the decision is larger than one control frame carries, so nothing was sent`:null}function Sx(e){return e?`, ${e}`:``}function Cx(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=vx(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 wx(e,t,n){let r=Cx(e,t,n);return r?`${r}${Sx(e.problem)}`:e.problem??``}function Tx(e){let t=dx(e.state,e.selectedAgentId),n=fx(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:mx(e.state,t?.agentId??null,n),status:wx(e,t,n),actions:_x(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:mx(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:gx(e,t,n)}]}}function Ex(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 Dx({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 Ox({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var kx=e=>Ut.includes(e),Ax=e=>Mt.includes(e);function jx(e){let t=e.currentState;e.btnRestart.classList.toggle(`visible`,kx(t)||Ax(t)||t===E.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,ib()),e.btnPlan.hidden=Ox(e)===`hidden`}function Mx(e){let t=A(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(O(e)),jx(t),Vl(t,O(e)),!0)}function Nx(e,t){let n=A(e);n&&(n.hasPlan=t===!0,jx(n))}function Px(e){let t=A(e.id);t&&(t.planReviewState=Ex(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),jx(t))}function Fx(e){let t=A(e.id);t&&t.planFace.update({draft:e})}function Ix(e){let t=A(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),jx(t))}function Lx(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=A(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function Rx(e){for(let[,t]of k)t.planFace.update({isConnected:e})}var zx=160,Bx=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 Vx(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=zx?t:`${t.slice(0,157)}...`}function Hx(e,t){let n=Bx[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?Vx(r):``}var Ux=5e3;function Wx(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function Gx(e,t){if(!e.toolUseId)return Wx(e.text)??`context`;let n=t.get(e.toolUseId);return n?Hx(n.name,n.input)||n.name:`expansion`}function Kx(e){return e.kind!==`expansion`||e.toolUseId?!1:Wx(e.text)!==null}function qx(e){return e.kind===`prompt`||e.kind===`session`||Kx(e)}function Jx(e){return new TextEncoder().encode(e).byteLength}var Yx={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`};function Xx(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:Vx(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:Vx(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:Vx(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:Vx(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:Vx(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:Gx(e,t)};if(e.kind===`tool_call`){let t=Hx(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:`${Jx(e.content)} bytes`}}function Zx(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function Qx(e,t){let n=Xx(e,t),r=Zx(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:Yx[e.kind],text:`${r}${i}`,tone:o,badges:a}}function $x(e,t){return{record:e,...Qx(e,t)}}function eS(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function tS(e,t){let n=eS(e);return!n||t.has(n)?null:n}function nS(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function rS(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function iS(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=eS(i.record);a&&t.has(a)&&(n.rows[r]=$x(i.record,e.toolCallByUseId))}}function aS(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function oS(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function sS(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=Jx(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function cS(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=tS(i,e.toolCallByUseId);t&&nS(e.unresolvedToolUseCounts,t);let a=$x(i,e.toolCallByUseId);if(qx(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:oS()},sS(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:oS()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),sS(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 lS(e,t){let n=aS();cS(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)||nS(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],iS(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function uS(e){return e.rows.length+ +!!e.head}function dS(e){let t=0;for(let n of e.turns)t+=uS(n);return t}function fS(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=eS(n.record);t&&rS(e.unresolvedToolUseCounts,t)}}function pS(e,t){fS(e,t.head?[t.head,...t.rows]:t.rows)}function mS(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);fS(e,i);for(let e of i)sS(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function hS(e,t=Ux){let n=dS(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=uS(t),pS(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:mS(e,n-t)}}function gS(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 _S(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 vS(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 yS(e,t=Ux){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function bS(e,t=Ux){return!yS(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function xS(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 SS=1e4,CS=null,wS=null,TS=[],ES=null,DS=null,L=null,OS=null,kS=!1,AS=null,jS=()=>!1,MS=new Set;function NS(e){for(let t of MS)t(e)}function PS(){OS&&=(clearTimeout(OS.timeoutHandle),null)}function FS(){OS=null,AS=`The trace did not load within ${Math.round(SS/1e3)} s.`,NS({kind:`rebuild`})}function IS(e){PS(),kS=!1,AS=null,ES=e,L=e?{sessionId:e,grouping:aS(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,NS({kind:`selection-reset`})}function LS(e){let t=_S(TS,DS,ES,e);return DS&&t===DS&&(DS=null),t!==ES&&(IS(t),!0)}function RS(e){if(!CS)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};CS(t)?OS={request:e,timeoutHandle:setTimeout(FS,SS)}:(AS=S,NS({kind:`header`}))}function zS(e=!1){if(!CS)return;let t=vS({selectedSessionId:ES,isPanelVisible:e||jS(),hasPendingRequest:!!OS,hasLoadedOnce:L?.hasLoadedOnce??!1,nextOffset:L?.nextOffset??0});t&&RS(t)}function BS(){kS&&!OS&&(kS=!1,zS())}function VS(){if(!L)return;let e=hS(L.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!L.hasDroppedEarliestRows;t&&(L.hasDroppedEarliestRows=!0),NS({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function HS(e){L&&(NS({kind:`records-appended`,appends:cS(L.grouping,e)}),VS())}function US(e){L&&(NS({kind:`records-prepended`,prepend:lS(L.grouping,e)}),VS())}function WS(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 GS(){return{selectedSessionId:ES,hasPendingRequest:!!OS,hasLoadedOnce:L?.hasLoadedOnce??!1,hasDroppedEarliestRows:L?.hasDroppedEarliestRows??!1,firstOffset:L?.firstOffset??0,residentRowCount:L?dS(L.grouping):0}}function KS(){return{sessionOptions:TS,selectedSessionId:ES,selectedTrace:L,pendingSessionId:OS?.request.id??null,traceFailureText:AS}}function qS(e){MS.add(e)}function JS(e){jS=e}function YS(){if(!CS)return;let e=bS(GS());e&&RS(e)}function XS(e){TS.some(t=>t.id===e)&&e!==ES&&(DS=null,IS(e),zS(),NS({kind:`rebuild`}))}function ZS(){let e=LS(!0);return zS(!0),e}function QS(e){CS=e}function $S(e){wS=e}function eC(e){DS=e,wS?.()}function tC(e){TS=gS(e);let t=LS(jS());t&&zS(),NS({kind:`sessions`,hasSelectionChanged:t})}function nC(e){let t=WS(e);if(!t)return;let n=xS({pendingRequest:OS?.request??null,resident:L?{sessionId:L.sessionId,firstOffset:L.firstOffset,nextOffset:L.nextOffset,hasLoadedOnce:L.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?BS():(PS(),AS&&(AS=null,NS({kind:`header`})),n===`stale`?BS():n===`reset`?(IS(t.id),L&&(L.filePath=t.path),zS(),NS({kind:`rebuild`}),BS()):L&&(L.filePath=t.path,n===`prepend`?(L.firstOffset=t.start,US(t.records),BS()):(n===`seed`&&(L.hasLoadedOnce=!0,L.firstOffset=t.start),L.nextOffset=t.next,HS(t.records),BS())))}function rC(e){let t=e?.id;typeof t==`string`&&t===ES&&jS()&&(OS?kS=!0:zS())}function iC(e){let t=e?.id;if(typeof t!=`string`||OS?.request.id!==t)return!1;PS(),kS=!1;let n=e?.message;return AS=typeof n==`string`&&n?n:`The trace could not be read.`,NS({kind:`rebuild`}),!0}function aC(e){PS(),kS=!1,AS=e?null:S,e?(NS({kind:`header`}),zS()):NS({kind:`rebuild`})}function oC(e,t,n=!1){let r=D(`label`,`dialog-checkbox-label`),i=D(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,D(`span`,null,e)),r}function sC(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function cC(e){let[t,n]=await Promise.all([c(`get-workspace-repos`,{id:e}),c(`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:sC(e),path:e,isMember:!0})),i=new Set(t.repos),a=n?.type===`repo-roots-scanned`?n.directories:[];for(let e of a.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 lC(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:a}=Qt({title:`Workspace repositories`}),o=D(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),s=D(`fieldset`,`dialog-workspace-list`);s.setAttribute(`aria-label`,`Workspace repositories`),s.append(D(`div`,`dialog-hint`,`Loading repositories...`));let l=D(`div`,`dialog-hint`);l.setAttribute(`role`,`status`);let u=D(`div`,`dialog-error`),d=w({variant:`primary`,label:`Save`,disabled:!0});i.append(d),n.append(o,s,l,u,i),a.addEventListener(`click`,r),requestAnimationFrame(()=>a.focus()),cC(e).then(e=>{if(t.isConnected){s.textContent=``;for(let t of e)s.append(oC(t.name,t.path,t.isMember));d.disabled=!1}}).catch(e=>{t.isConnected&&(s.textContent=``,u.textContent=`Could not load repositories: ${zn(e)}`)}),d.addEventListener(`click`,()=>{let n=[...s.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`,c(`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: ${zn(e)}`)}).finally(()=>{l.textContent=``,d.disabled=!1}))})}function uC(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function dC(e,t){Cn(e.taskTitleEl,()=>dn(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),ln(e,t)}),e.nameEl.addEventListener(`click`,()=>{tn(e.nameEl)||Oi(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),ln(e,t))}),e.btnRename.addEventListener(`click`,()=>{uC(e),ln(e,t,{returnsFocusToTerminal:!e.renameTargetEl?.isConnected})}),e.btnRestart.addEventListener(`click`,()=>{uC(e),nx().then(n=>n?.openRestartDialog(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0}))}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{uC(e),lC(t)}),e.btnTrace.addEventListener(`click`,()=>{uC(e),eC(t)}),e.btnDocs.addEventListener(`click`,()=>{uC(e),Av(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=Ox(e);n!==`hidden`&&(n===`face`?Mx(t):location.hash=Cb(t))}),e.btnRemove.addEventListener(`click`,()=>{uC(e),Ii(t)});function n(){for(let[,t]of k)t!==e&&uC(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`)}e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation(),e.sessionMenu.classList.contains(`open`)?uC(e):n()}),qi({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:()=>uC(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&&uC(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),uC(e),db(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&fb(e)},{signal:e.abortController.signal})}var fC=1500,pC=new WeakMap;function mC(e){clearTimeout(pC.get(e)),pC.delete(e)}function hC(e,t){let n=setTimeout(()=>{pC.delete(e),s({type:`dismiss`,id:t,expectedState:E.COMPLETE})},fC);pC.set(e,n)}function gC(e,t,n){let r=document.activeElement;return Ei({previousState:t,nextState:n,isPhoneLayout:Ko(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}var _C=e=>e==null?``:String(e);function vC(e,t,n){let r=A(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&cn(e,r.taskTitle)}}function yC(e){return typeof e==`string`&&k.has(e)}function bC(){return k.size}function xC(e){let t=e||{};t.linkPreviews!=null&&jd(t.linkPreviews),t.cursorBlink!=null&&bf(t.cursorBlink),t.debugMode!=null&&(nb(t.debugMode),W_(t.debugMode));for(let[,e]of k)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function SC(){Cu(k.values(),Tu())}function CC(e){return{state:e.currentState,unseenOutcome:e.unseenOutcome,ownerId:e.ownerId}}function wC(){let e=Vn(j.counts),t=e>0?`(${e}) Glimmervoid`:`Glimmervoid`;document.title!==t&&(document.title=t)}function TC(e,t,n,r={}){if(!Zn)return;let i=O(e),a=_C(n)||E.DORMANT,o=fn(i,_C(t),a,r),c=a===E.DORMANT;Zn.appendChild(o.card);let l;function u(){l.face=`terminal`,l.card.dataset.face=`terminal`,l.termWrap.hidden=!1,l.planFace.hide(),jx(l),Af(l,i)}let d=new AbortController,f=ox({signal:d.signal,requestPlan:(e,t,n)=>s({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>s({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:u,sendDecision:(e,t)=>s({type:`plan-decision`,id:e,...t}),reportProblem:e=>xn(i,e)});l={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:_C(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:d,currentState:a,face:`terminal`,isBorrowed:!1,hasPlan:!1,pendingPromptKind:null,planReviewState:{reviews:[]},planFace:f},l._ensureTerminalReady=()=>Af(l,i),l._showTerminalFace=u,l._showPreferredFace=u,l._setBorrowed=e=>{l.isBorrowed=e,o.card.toggleAttribute(`data-borrowed`,e),jx(l)},o.card.append(f.el);let p=k.get(i);return p&&Hn(j,CC(p)),k.set(i,l),Wn(j,CC(l)),mr(i,l),dC(l,i),jx(l),l.btnDocs.hidden=!Tv(i),yv(i),a===E.RUNNING&&pr(l,!0),c||Df(l,i),wC(),l}function EC(e,t){let n=A(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function DC(e,t){let n=A(e);if(!n)return;n.agent=typeof t==`string`?t:null;let r=n.card.querySelector(`.session-agent-mark`);r&&Bn(r,n.agent),jx(n)}function OC(e,t){let n=A(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function kC(e,t,n=!1){let r=A(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=Gt(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function AC(e,t){let n=A(e);n&&(n.pendingPromptKind=typeof t==`string`?t:null)}function jC(e,t){let n=A(e);n&&(Hn(j,CC(n)),n.unseenOutcome=t??null,Wn(j,CC(n)))}function MC(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function NC(e,t,n=null){let r=A(e),i=_C(t)||`none`;r&&MC(r.card,i),Ly(O(e),i,_C(n)||null)}function PC(e,t,n=null){let r=A(e),i=_C(t)||`none`;r&&MC(r.card,i),Ry(O(e),i,_C(n)||null)}function FC(e,t){let n=A(e);if(!n)return;let r=_C(t);n.card.dataset.session=r,n.nameEl.textContent=r}function IC(e){let t=A(e);t&&(fb(t),Hn(j,CC(t)),k.delete(O(e)),mr(O(e),void 0),rx?.dropPlanBodyCache(O(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),gu(t,O(e)),Ao(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),wC())}function LC(e,t,n){if(!t||!e.term)return;let r=n===E.DONE?`Session complete`:`Session failed`,i=n===E.DONE?`\x1B[34m`:`\x1B[31m`;e.term.write(`\r\n\r\n\x1b[2m${i} ${r}\x1b[0m\r\n\r\n\x1b[2m Open the session actions menu and choose Restart to start a new session.\x1b[0m\r\n`)}function RC(e,t){e.term&&(t===E.DONE||t===E.FAILED)&&(e.term.clear(),e.term.reset())}function zC(e){let t=k.get(e);t&&document.visibilityState===`visible`&&(Ko()||document.hasFocus())&&(kn(e),er({state:t.currentState,unseenOutcome:t.unseenOutcome})&&s({type:`dismiss`,id:e,expectedState:t.currentState}))}function BC(e,t,n){let r=A(e);if(!r)return;let i=_C(t),a=r.currentState;Hn(j,CC(r)),r.currentState=i,Wn(j,CC(r)),mr(O(e),r),i!==E.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(mC(r),r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),pr(r,i===E.RUNNING)),a===E.DORMANT&&i!==E.DORMANT&&Df(r,O(e)),tr({state:i})===`resting`&&Hb(O(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,Gt(i,r.awaitingBackgroundTasks)),jx(r),gC(r,a,i)&&hC(r,O(e));let o=i===E.DONE||i===E.FAILED,s=a!==E.DONE&&a!==E.FAILED&&a!==E.INITIALIZING;o&&s&&(r.card.classList.remove(`completion-flash`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.card.classList.add(`completion-flash`),r.card.addEventListener(`animationend`,()=>r.card.classList.remove(`completion-flash`),{once:!0})})})),(i===E.DONE||i===E.FAILED)&&LC(r,s,i),i===E.INITIALIZING&&RC(r,a),wC()}var VC=pa({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function HC(e){let t=D(`ul`,`session-setup-list`);return t.append(...e.map(e=>D(`li`,null,e))),t}function UC(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=Bt(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[D(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=D(`div`,`session-setup-plugin`);return t.append(D(`h3`,null,e.name)),e.skills.length>0&&t.append(D(`p`,`session-setup-label`,`Skills`),HC(e.skills)),e.agents.length>0&&t.append(D(`p`,`session-setup-label`,`Agents`),HC(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[HC(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=D(`p`,`session-setup-hook`);return t.append(D(`span`,null,e.event),D(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>D(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[HC(t.skills)]:[]),n(`Agents`,t.agents.length>0?[HC(t.agents)]:[])}function WC(e){let t=D(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=D(`div`,`session-setup-sections`);VC.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function GC(e){let t=VC.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;UC(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function KC(e){return fe(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function qC(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${KC(Date.now()-e)} ago`}var JC=e=>`polled ${qC(e)}`;function YC(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=JC){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=hr(a)}}}var XC=80,ZC=Object.freeze([{value:`day`,label:`Today`,days:1},{value:`week`,label:`Last 7 days`,days:7},{value:`month`,label:`Last 30 days`,days:30}]),QC=`week`;function $C(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function ew(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function tw(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${$C(String(Math.abs(t)))}`}function nw(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}$${$C(r)}.${i}`}function rw(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}${ew((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${ew((n/1e6).toFixed(2))}M`:`${t}${ew((n/1e9).toFixed(2))}B`}function iw(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=XC?`warn`:`ok`}var aw=90;function ow(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&C(e.budgetUsd,null)!==null):[]}function sw(e){let t=C(e?.pct,null);return t===null?0:t}function cw(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=C(n.pct,null),i=C(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}function lw(e){return e?.vendor===`codex`||e?.vendor===`kimi`?e.vendor:`claude`}function uw(e,t=null){let n=[],r=iw(cw(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 ow(e)){let e=sw(t);if(e<aw)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return dt(n)}function dw(e,t=``){let n=e?.source;if(n===`fetched`){let e=Xe(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=Xe(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 fw(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 pw(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function mw(e){if(!e||typeof e!=`object`)return``;let t=[],n=pw(e.dirs);if(n!==null&&t.push(`${tw(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${tw(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${tw(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${tw(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 hw(e){return Xe(e?.error,``)}function gw(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}var _w=`Estimated list prices, not a bill.`,vw=`Enable in Settings.`,yw=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],bw=/^(\d{4})-(\d{2})-(\d{2})$/,xw=new Set([`day`,`model`,`label`]),Sw=new Set([`model`,`label`]);function Cw(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${ew(e.toFixed(1))}%`}var ww=`tokens`,Tw=Object.freeze([{value:`tokens`,label:`Tokens`},{value:`cost`,label:`Cost`}]);function Ew(e){return e===`cost`?`cost`:ww}function Dw(e,t){return t===`cost`?nw(e):rw(e)}function Ow(e,t){if(t===`tokens`)return`tokens`;let n=Number(e?.costUSD);return Number.isFinite(n)&&n>0?`costUSD`:`tokens`}function kw(e){return e===`costUSD`?`share of cost`:`share of tokens`}function Aw(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function jw(e){let t=bw.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=yw[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function Mw(e){let t=Nw(e);return t.length===0?``:t.length===1?jw(t[0]):`${jw(t[0])} to ${jw(t[t.length-1])}`}function Nw(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>bw.test(e)).sort()}function Pw(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:Fw(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function Fw(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=Iw(e,n);return bw.test(r)?r:Iw(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function Iw(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function Lw(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:me(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function Rw(e,t){let n=qE(Me(t),-1),[,r,i]=e.yesterday.day.split(`-`).map(Number),a=e.yesterday.day===n?`yesterday`:`${yw[r-1]} ${i}`,o=e.yesterday.sessionCount===1?`session`:`sessions`;return`${a}: ${e.yesterday.sessionCount} ${o}, ${Lw(e.yesterday.activeMs/6e4)}`}function zw(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=yw[n.getMonth()];return r?`${r} ${n.getDate()} ${ge(n)}`:`-`}var Bw=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`}),Vw=`Sessions spawned by Glimmervoid; terminal sessions count as other`,Hw=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function Uw(e){let t=Xe(e,``);return t?Bw[t]||t:Bw.other}function Ww(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function Gw(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function Kw(e){return Ww(e).some(e=>Gw(e.lane))}var qw=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function Jw(e,t,n){let r=cw(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function Yw(e,t,n,r){if(!Array.isArray(t))return null;let i=t.filter(e=>e&&typeof e.lane==`string`),a=i.reduce((e,t)=>e+C(t.costUSD,0),0),o=i.reduce((e,t)=>e+C(t.tokens,0),0),s=i.filter(e=>Gw(e.lane)).map(e=>({lane:String(e.lane),label:Uw(e.lane),tokens:C(e.tokens,0),costUSD:C(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?Aw(c,a):Aw(l,o),d=Jw(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:qw[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function Xw(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:BT.map(e=>Yw(e.key,r[e.key],t,n)).filter(e=>e!==null)}function Zw(e){return e.planPct===null?``:`about ${Cw(e.planPct)} of plan`}function Qw(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?nw(e.costUSD):rw(e.tokens)}`).join(`, `)}var $w=`team-review`;function eT(e){if(!Array.isArray(e?.byLane))return``;let t=Ww(e).find(e=>e.lane===$w),n=C(t?.costUSD,0);if(n<=0)return``;let r=Aw(n,e?.totals?.costUSD),i=r===null?``:`, ${Cw(r)} of this period`;return`PR reviews cost ${nw(n)}${i}.`}function tT(e){let t=C(e,null);return t===null||t<=0?``:`${tw(t)} ${t===1?`session`:`sessions`}`}function nT(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function rT(e){let t=nT(e);if(!t)return``;let n=C(t.savedUSD,0);if(n<=0)return``;let r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e).length,i=r===0?``:`, at least, since ${r} ${r===1?`model has`:`models have`} no price`;return`Prompt caching saved ${nw(n)}${i}, across ${rw(C(t.cacheReadTokens,0))} cache read tokens.`}function iT(e){return e===`monthly`?`this month`:`today`}function aT(e){return`${nw(C(e?.spentUsd,0))} of ${nw(C(e?.budgetUsd,0))}`}function oT(e){return`${iT(e?.scope)} spend against budget`}var sT=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function cT(e){let t=bw.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function lT(e){let t=cT(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Me(t)}function uT(e){let t=bw.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function dT(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 fT(e,t){e.tokens+=C(t?.tokens,0),e.costUSD+=C(t?.costUSD,0),e.input+=C(t?.input,0),e.output+=C(t?.output,0),e.cacheCreate+=C(t?.cacheCreate,0),e.cacheRead+=C(t?.cacheRead,0),e.days+=1,e.sources.add(t?.source===`history`?`history`:`live`);let n=Array.isArray(t?.vendors)?t.vendors:[];for(let t of n)e.vendorSet.add(t);let r=t?.models||[];for(let t of r){t?.vendor&&e.vendorSet.add(t.vendor);let n=ZT(t),r=e.modelByName.get(n)||{key:n,model:t?.model??n,vendor:t?.vendor,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0};r.tokens+=C(t?.tokens,0),r.costUSD+=C(t?.costUSD,0),r.input+=C(t?.input,0),r.output+=C(t?.output,0),r.cacheCreate+=C(t?.cacheCreate,0),r.cacheRead+=C(t?.cacheRead,0),e.modelByName.set(n,r)}}function pT(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 mT(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)||dT(r);fT(i,e),n.set(r,i)}return Array.from(n.values()).map(pT)}function hT(e){return mT(e,lT)}function gT(e){return mT(e,uT)}function _T(e,t){return t===`week`?hT(e):t===`month`?gT(e):Array.isArray(e)?[...e]:[]}var vT=/^(\d{4})-(\d{2})$/;function yT(e,t){if(t===`month`){let t=vT.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=yw[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=jw(e);return t===`-`?t:`week of ${t}`}return jw(e)}function bT(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var xT=16,ST=Object.freeze([.05,.25,.5,.75]),CT=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function wT(e,t){let n=C(e,0),r=C(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<ST.length;e+=1)i>=ST[e]&&(a=e+1);return a}function TT(e,{weeks:t=xT,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>bw.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`&&bw.test(n)?n:Me(o),c=cT(lT(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Me(l),d=[],f=0,p=null;for(let e of r){let t=String(e.day);(p===null||t<p)&&(p=t),t<u||t>s||(f=Math.max(f,C(e.tokens,0)))}for(let e=0;e<t;e+=1)for(let t=0;t<7;t+=1){let n=new Date(l.getFullYear(),l.getMonth(),l.getDate()+e*7+t,12),r=Me(n),a=i.get(r)||null,o=r>s,c=p!==null&&r<p;d.push({day:r,week:e,weekday:t,tokens:C(a?.tokens,0),costUSD:C(a?.costUSD,0),source:a?.source===`history`?`history`:a?`live`:null,noData:o||c||!a&&p===null,tone:wT(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function ET(e){let t=jw(e?.day);if(e?.noData)return`${t}: no data`;let n=C(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${rw(n)} tokens, ${nw(C(e?.costUSD,0))}`}function DT(e){if(!e)return``;let t=C(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${jT(e.ratio)} the ${n} average: ${nw(e.todayUsd)} against ${nw(e.baselineUsd)}.`}function OT(e){return e?`This block is burning ${jT(e.ratio)} the usual rate: ${rw(e.current)} tokens per minute against ${rw(e.baseline)}.`:``}function kT(e){return[DT(e?.daily),OT(e?.burn)].filter(Boolean).join(` `)}function AT(e){return!!(e?.daily||e?.burn)}function jT(e){let t=C(e,null);return t===null?`-`:`${ew(t.toFixed(1))}x`}var MT=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`,kimi:`Kimi`});function NT(e){let t=Xe(e,``);return t?MT[t]||t:MT.claude}function PT(e,t){return IT(t)?NT(e?.vendor):``}function FT(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>C(t[n]?.tokens,0)-C(t[e]?.tokens,0)).map(e=>({vendor:e,label:NT(e),tokens:C(t[e]?.tokens,0),costUSD:C(t[e]?.costUSD,0)}))}function IT(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 LT=`Claude only`;function RT(e){return IT(e)?LT:``}var zT=36e5,BT=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]),VT=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`},{vendor:`kimi`,label:`Kimi Code`}]);function HT(e,t=Date.now()){let n=C(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function UT(e,t=Date.now()){let n=C(e,null);return n===null||n<=0||t-n>zT}function WT(e,t=Date.now()){if(!UT(e,t))return``;let n=HT(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function GT(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 KT(e){let t=Xe(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function qT(e){return hw(e)!==``}function JT(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 YT(e){return typeof e?.id==`string`&&e.id!==``}function XT(e){let t=Xe(e?.label,``);return YT(e)&&t?t:JT(e?.project)||t||`unknown project`}function ZT(e){let t=typeof e==`string`?e:e?.model;return Xe(t,`unknown model`)}function QT(e){return String(e?.day??``)}function $T(e,t,n){if(!xw.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?QT(e):n(e)}function eE(e,t,n,r=XT){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=$T(e,t,r),o=$T(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 tE(e){return Sw.has(e)?`asc`:`desc`}function nE(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:tE(t)}}function rE(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var iE=Object.freeze({key:`lastTs`,dir:`desc`}),aE=Object.freeze({key:`tokens`,dir:`desc`}),oE=Object.freeze({key:`day`,dir:`desc`});function sE(e,t=iE){return eE(e,t.key,t.dir,XT)}function cE(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 lE(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${tw(t)} hidden`}function uE(e,t=aE){return eE(e,t.key,t.dir,ZT)}function dE(e,t=oE){return eE(e,t.key,t.dir,QT)}function fE(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function pE(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 mE=36e5,hE=24*mE,gE=Object.freeze({fiveHour:{lengthMs:5*mE,label:`5-hour`},sevenDay:{lengthMs:7*hE,label:`weekly`}}),_E=10,vE=80,yE=100,bE=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function xE(e,t){return e>=yE?`fail`:e>=vE||t!==null&&t>=vE?`warn`:`ok`}function SE(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 CE(e,t,n,r){let i=cw(n,t);if(!i||i.pct===null||i.resetsAtMs!==null&&i.resetsAtMs<=r)return null;let a=gE[t],o=SE(a.lengthMs,i.resetsAtMs,r),s=o!==null&&o>=_E&&i.pct<yE?i.pct/(o/100):null;return{vendor:e,vendorLabel:VT.find(t=>t.vendor===e)?.label||e,key:t,windowLabel:a.label,usedPct:i.pct,elapsedPct:o,projectedPct:s,resetsAtMs:i.resetsAtMs,tone:xE(i.pct,s)}}function wE(e,t){return VT.flatMap(({vendor:n})=>BT.map(({key:r})=>CE(n,r,e[n],t)).filter(e=>e!==null))}function TE(e,t){let n=C(e,null);if(n===null||n<=0)return``;let r=new Date(n),i=ge(r);return Me(n)===Me(t)?i:n-t<7*hE&&r.getDay()!==new Date(t).getDay()?`${bE[r.getDay()]} ${i}`:`${yw[r.getMonth()]} ${r.getDate()} ${i}`}function EE(e){return`${Math.round(e)}%`}function DE(e){return Math.max(e.usedPct,e.projectedPct??0)}function OE(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 kE(e,t){let n=OE(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 ${EE(100-r.usedPct)} of its ${r.windowLabel} window left.`}function AE(e,t){let n=TE(e,t);return!n||e===null?`until the window resets`:`until ${n}, in ${Lw((e-t)/6e4)}`}function jE(e,t,n){let r=[`${e.vendorLabel} sessions stop answering ${AE(e.resetsAtMs,n)}. Their worktrees and conversations stay intact.`,kE(t,e.vendor)];return{tone:`fail`,headline:`${e.vendorLabel} ${e.windowLabel} limit reached.`,detail:r.filter(Boolean).join(` `)}}function ME(e,t){let n=TE(e.resetsAtMs,t),r=n?`, resets ${n}`:``;if(e.usedPct>=vE)return{tone:`warn`,headline:`${e.vendorLabel} ${e.windowLabel} limit is at ${EE(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 ${EE(e.projectedPct??e.usedPct)}.`}}function NE(e){return{tone:`warn`,headline:`Over your ${iT(e.scope)===`today`?`daily`:`monthly`} budget.`,detail:`${aT(e)} spent ${iT(e.scope)}.`}}function PE(e,t,n,r){let i=e.find(e=>e.tone===`fail`);if(i)return jE(i,e,r);let a=e.filter(e=>e.tone===`warn`).sort((e,t)=>DE(t)-DE(e))[0];if(a)return ME(a,r);let o=t.find(e=>C(e.pct,0)>=100);if(o)return NE(o);if(e.length===0)return{tone:`ok`,headline:n===null?`Nothing spent yet today.`:`${nw(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)=>DE(t)-DE(e))[0],c=TE(s.resetsAtMs,r);return{tone:`ok`,headline:`Every limit has room.`,detail:`Closest is ${s.vendorLabel} ${s.windowLabel} at ${EE(s.usedPct)}${c?`, resets ${c}`:``}.`}}function FE(e){return e.tone===`fail`?`limit reached`:e.projectedPct===null?e.elapsedPct===null?``:`too early to project`:`about ${EE(e.projectedPct)} at reset`}var IE=`report`;function LE(e){return ZC.find(t=>t.value===e)?.label||``}function RE(e,t){return{key:Ow(e,t),dir:`desc`}}function zE(e,t){let n=uE(e?.models,RE(e?.totals,t))[0];if(!n)return null;let r=Ow(e?.totals,t);return{label:ZT(n),sharePct:Aw(n[r],e?.totals?.[r])}}function BE(e,t){let n=sE(e?.sessions,RE(e?.totals,t)),r=n[0];return{count:n.length,topLabel:r?XT(r):``}}function VE(e){let t=Ww(e).filter(e=>Gw(e.lane));return t.length===0?null:t.reduce((e,t)=>e+C(t.costUSD,0),0)}function HE(e){let t=e.filter(e=>C(e.pct,0)>=100).length,n=e.length-t;return t===0?{value:`${n} of ${e.length}`,detail:e.length===1?`under its ceiling`:`all under their ceilings`}:{value:`${n} of ${e.length}`,detail:t===1?`1 over its ceiling`:`${t} over their ceilings`}}function UE(e){return Nw(e).length}function WE(e,t){let n=cT(e);return!n||t<=0?[]:Array.from({length:t},(e,r)=>{let i=new Date(n);return i.setDate(n.getDate()-(t-1-r)),Me(i)})}function GE(e){return ZC.find(t=>t.value===e)?.days??7}function KE(e){return e.reduce((e,t)=>t.resetsAtMs===null?e:e===null?t.resetsAtMs:Math.min(e,t.resetsAtMs),null)}function qE(e,t){let n=cT(e);return n?(n.setDate(n.getDate()+t),Me(n)):``}function JE(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=String(e?.day??``);bw.test(n)&&r.set(n,(r.get(n)??0)+C(e?.[t],0))}return r}function YE(e,t){let n=cT(e);return n?t<=7?bE[n.getDay()]:String(n.getDate()):e}function XE(e,t,n,r){let i=JE(e,r===`cost`?`costUSD`:`tokens`),a=WE(n,t).map(e=>({day:e,label:YE(e,t),value:i.get(e)??0,isToday:e===n})),o=a.reduce((e,t)=>e+t.value,0),s=WE(qE(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 ZE(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 QE(e){return`${Dw(e.average,e.metric)} a day on average`}function $E(e){return IT(e)?FT(e).map(e=>`${e.label} ${nw(e.costUSD)}`).join(`, `):``}function eD(e){return IT(e)?FT(e).map(t=>({...t,sharePct:Aw(t.tokens,e?.tokens)})):[]}function tD(e){let t=e?.totals,n=[{label:`Processed tokens`,value:rw(C(t?.tokens,0))},{label:`Cached input`,value:rw(C(t?.cacheRead,0))},{label:`Uncached input`,value:rw(C(t?.input,0))},{label:`Output`,value:rw(C(t?.output,0))}],r=C(nT(e?.savings)?.savedUSD,0);return r>0&&n.push({label:`Cache savings`,value:nw(r)}),n}function nD(e){let t=(e?.yourDay?.insights??[]).map(e=>({text:e.text,tone:`ok`})),n=e?.anomaly;AT(n)&&t.push({text:kT(n),tone:`warn`});for(let n of[rT(e?.savings),eT(e)])n&&t.push({text:n,tone:`ok`});return t}function rD(e,t,n,r){let i=Ow(t,n),a=e.reduce((e,t)=>Math.max(e,C(t[i],0)),0);return e.map(e=>({row:e,label:r(e),tokens:C(e.tokens,0),costUSD:C(e.costUSD,0),sharePct:Aw(e[i],t?.[i]),barPct:Aw(e[i],a)??0}))}function iD(e,t){return rD(uE(e?.models,RE(e?.totals,t)),e?.totals,t,ZT)}function aD(e,t){return rD(sE(e?.sessions,RE(e?.totals,t)),e?.totals,t,XT)}function oD(e){return[{label:`Input`,tokens:C(e.input,0)},{label:`Output`,tokens:C(e.output,0)},{label:`Cache write`,tokens:C(e.cacheCreate,0)},{label:`Cache read`,tokens:C(e.cacheRead,0)}]}var sD=2e4,cD=`glimmervoid-usage-metric`,lD=null,uD=null,dD={claude:null,codex:null,kimi:null},fD=null,pD=null,mD=null,hD=QC,gD=Ew(xr(cD,null)),_D=!1,vD=null,yD=null,bD=!0,xD=()=>!1,SD=new Set,CD=_t({getAck:gi,setAck:Qr,signature:()=>uw(lD,dD.claude),isLooking:()=>xD()});function wD(e){for(let t of SD)t(e)}function TD(){fD?.(CD.refresh())}function ED(e){_D=e,wD(`refresh-status`),vD&&=(clearTimeout(vD),null),e&&(vD=setTimeout(()=>{vD=null,_D=!1,yD=`Usage did not answer within ${Math.round(sD/1e3)} s. Refresh to try again.`,wD(`refresh-status`)},sD))}function DD(e){let t=ZC.find(t=>t.value===e);return t?t.days:null}function OD(){return{report:lD,sessions:uD,planLimitsByVendor:dD,rangeValue:hD,metric:gD}}function kD(){let e=!bD||!_D&&yD!==null;return bD?_D?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:yD??``,isPending:!1,hasFailure:e}:{text:lD?`${S} The figures below are from before the connection dropped.`:S,isPending:_D,hasFailure:e}}function AD(e){SD.add(e)}function jD(e){xD=e,TD()}function MD(){CD.acknowledge(),TD()}function ND(e){fD=e,TD()}function PD(e){pD?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function FD(e){pD=e}function ID(e){hD=e}function LD(e){gD=e,br(cD,e)}function RD({force:e=!1}={}){if(!pD)return;mD=d(`usage`);let t={type:`request-usage-report`,requestId:mD};e&&(t.force=!0);let n=DD(hD);n!==null&&(t.days=n),yD=null,ED(!0),pD(t)||(yD=S,ED(!1))}function zD(e){bD=e,wD(`refresh-status`)}function BD(e){uD=e,wD(`sessions`)}function VD(e){let t=e;dD={...dD,[lw(t)]:t},wD(`plan-limits`),TD()}function HD(e){gw(e,mD)&&(yD=null,ED(!1),lD=e,wD(`report`),TD())}function UD(){let e=lD?.pricing||(uD?{source:uD.pricingSource}:null),t=fw(e?.fetchedAt),n=[dw(e,t!==null&&t>0?qC(t):``)],r=hw(lD);r&&n.push(r);let i=mw(lD?.scan);return i&&n.push(i),n}var WD=[],GD=[],KD=[],qD=new Map;function JD(){for(let e of[...WD])e()}function YD(e){for(let t of GD)t(e)}function XD(e){return e.type===`whiteboard-result`}async function ZD(e,t){try{let n=await c(e,t,{timeoutMs:ur});return XD(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:lr(e,ur)}}}function QD(){return KD}function $D(e){return WD.push(e),()=>{let t=WD.indexOf(e);t>=0&&WD.splice(t,1)}}function eO(e){GD.push(e)}function tO(){let e=new Map;for(let t of KD)for(let n of t.connectedSessionIds){let r=e.get(n);r?r.push(t):e.set(n,[t])}qD=e}function nO(e){KD=[...e.boards].sort((e,t)=>t.updatedAt-e.updatedAt),tO(),JD()}function rO(e){KD=KD.filter(t=>t.id!==e.boardId),tO(),YD(e.boardId),JD()}async function iO(e){let t=await ZD(`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 aO(e,t){let n=await ZD(`whiteboard-op`,{boardId:e,ops:t});return n.ok?{ok:!0,patch:n.reply.patch??null}:n}async function oO(e){let t={"x-glimmervoid-upload-name":encodeURIComponent(e.name)};e.type&&(t[`content-type`]=e.type);let n=await fetch(yt,{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=zt.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 sO(e){let t=await ZD(`whiteboard-delete`,{boardId:e});return t.ok?{ok:!0}:t}async function cO(e,t){let n=await ZD(`whiteboard-connect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function lO(e,t){let n=await ZD(`whiteboard-disconnect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function uO(e){let t=await ZD(`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 dO=null;function fO(e){dO=e}function pO(e,t){dO?.(e,t)}function mO(e){return qD.get(e)??[]}var hO=null;function gO(e,t){hO={boardId:e,sessionId:t}}function _O(){let e=hO;return hO=null,e}var vO=()=>{};function yO(e){vO=e}function bO(e,t){gO(e,t),vO()}function xO(e,t){let n=e.queuedBySessionId[t]??0;return n===0?``:`${n} queued`}function SO(e,t,n){let r=xO(e,t),i=r?`wait`:`muted`;return{key:`board:${e.id}`,text:n,detailText:e.title,stateText:r,look:{icon:`board`,tone:i},tier:sn(i),className:`session-pr-chip session-board-chip`,ariaLabel:`Open board ${e.title}`,onActivate:()=>bO(e.id,t)}}function CO(e,t){let n=xO(e,t);return SO(e,t,n?`${e.title}, ${n}`:e.title)}function wO(e){return mO(e).map(t=>SO(t,e,t.title))}function TO(e,t,n){let r=CO(e,t),i=Be(`session-pr-chip-unlink`);i.append(Te(st)),i.setAttribute(`aria-label`,`Disconnect board ${e.title}`),i.addEventListener(`click`,r=>{r.stopPropagation(),r.preventDefault(),Xt({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:()=>{lO(e.id,t).then(e=>n(e.ok?null:e.error))}})});let a=D(`span`,`session-pr-chip-item`);return a.append(gn(r,r),i),a}function EO(e){let{dialog:t,close:n,actions:r,btnCancel:i}=Qt({title:`Connect board`}),a=D(`div`,`session-pr-chips dialog-linked-prs`),o=D(`p`,`dialog-message`,`A connected session is told what others changed on the board with its next whiteboard get or prompt.`),s=D(`select`,`dialog-input`);s.setAttribute(`aria-label`,`Board to connect`);let c=ar(`action-status`),l=w({variant:`primary`,label:`Connect`});r.append(l),t.append(a,o,s,c.element,r);function u(e){e&&c.show(`error`,e)}function d(){let t=mO(e);In(a,t.map(t=>CO(t,e)),n=>{let r=t.find(e=>`board:${e.id}`===n.key);return r?TO(r,e,u):gn(n,n)});let n=QD().filter(t=>!t.connectedSessionIds.includes(e));s.replaceChildren(...n.map(e=>{let t=D(`option`,null,e.title);return t.value=e.id,t})),n.length===0&&s.append(D(`option`,null,`No other boards to connect`)),s.disabled=n.length===0,l.disabled=n.length===0}l.addEventListener(`click`,()=>{let t=s.value;t&&(l.disabled=!0,cO(t,e).then(e=>{e.ok?n():(c.show(`error`,e.error),d())}))}),i.addEventListener(`click`,n);let f=$D(()=>{t.isConnected?d():f()});d()}$D(jn);function DO(){return M.snapshot().borrowedCardId}var OO=null;function kO(e,t,n,{className:r,onRelease:i}={}){if(!e?.card||!n)return;let a=DO();a&&a!==t&&AO();let o=e.card;o._cardHostClass&&o._cardHostClass!==r&&o.classList.remove(o._cardHostClass),o._cardHostClass=r||``,r&&o.classList.add(r),Wt(o,n),OO=i??null,M.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function AO(){let e=DO(),t=OO;if(OO=null,t?.(),M.dispatch(`borrowCard`,null),!e)return null;let n=k.get(e);n?._showTerminalFace?.(),n?._setBorrowed?.(!1),n?._setActiveViewer?.(!1);let r=n?.card;return r&&(r._cardHostClass&&r.classList.remove(r._cardHostClass),delete r._cardHostClass,jt(r,Zn)),e}var jO=null,MO=null,NO={},PO=null,FO=null,IO=null,LO=new Map,RO=new Map;function zO(){return MO??=N(()=>import(`./phone-shell-B5Qp4ql6.js`).then(e=>{e.mountPhoneShell(NO),IO&&e.orderPhonePanels(IO);for(let[t,n]of LO)e.setPhoneScreenAvailable(t,n);for(let[t,n]of RO)e.setPhoneScreenAttention(t,n);return jO=e,e},e=>(MO=null,y(`phone-shell`,`phone shell failed to load: ${l(e)}`),null)),__vite__mapDeps([25,3,4,13,19,26,14,15,22,27,12,5,6,7,18,28,29,30,21,31,32])),MO}function BO(e){NO=e}async function VO(e){let t={options:e};PO=t;let n=await zO();if(PO!==t)return!1;if(!n)return PO=null,FO=null,!1;PO=null,n.activatePhoneShell(t.options);let r=FO;return FO=null,r?.(n),!0}function HO(){PO=null,FO=null,jO?.deactivatePhoneShell()}function UO(){return PO!==null||(jO?.isPhoneShellActive()??!1)}function WO(){return PO?PO.options?.sessionId??null:jO?.getPhoneSessionId()??null}function GO(e){IO=e,jO?.orderPhonePanels(e)}function KO(e,t){LO.set(e,t),jO?.setPhoneScreenAvailable(e,t)}function qO(e,t){RO.set(e,t),jO?.setPhoneScreenAttention(e,t)}function JO(){jO?.refreshPhoneBoard()}function YO(){jO?.syncPhoneHistory()}function XO(e){return PO?(FO=t=>{e(t)},!0):jO?e(jO):!1}function ZO(e){return XO(t=>t.showPhonePlan(e))}function QO(e){return XO(t=>t.showPhoneSession(e))}function $O(e){return XO(t=>t.showPhoneScreen(e))}function ek(){let e=WO();e&&A(e)?._isActiveViewer?.()===!0&&zC(e)}function tk(){kf(A(DO())),ek()}function nk(){window.addEventListener(`focus`,tk),window.addEventListener(`blur`,tk),document.addEventListener(`visibilitychange`,tk),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&No()}),window.addEventListener(`pageshow`,e=>{e.persisted&&No()})}function rk(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function ik(e,t,n){return t>0?{minPx:e.minPx,maxPx:Math.max(e.minPx,Math.min(e.maxPx,t-n))}:e}function ak(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function ok({resizer:e,column:t,widthHost:n,widthProperty:r,bounds:i,keyStepPx:a,getStoredWidth:o,setStoredWidth:s,growsLeftward:c=!1,reservePx:l}){let u=c?-1:1;e.setAttribute(`aria-valuemin`,String(i.minPx)),e.setAttribute(`aria-valuemax`,String(i.maxPx));let d=()=>l===void 0?i:ik(i,n.getBoundingClientRect().width,l),f=null,p=t=>{let i=d();e.setAttribute(`aria-valuemax`,String(i.maxPx));let a=rk(t,i);return a===null?null:(f=a,n.style.setProperty(r,`${a}px`),e.setAttribute(`aria-valuenow`,String(a)),a)},m=()=>{let n=o();if(n!==null){p(n);return}let r=Math.round(t.getBoundingClientRect().width);r>0&&e.setAttribute(`aria-valuenow`,String(r))};if(m(),l!==void 0){let r=new ResizeObserver(()=>{e.dataset.dragging!==`true`&&m()});r.observe(n),r.observe(t)}let h=0,g=0;e.addEventListener(`pointerdown`,n=>{n.button===0&&(h=n.clientX,g=t.getBoundingClientRect().width,e.setPointerCapture(n.pointerId),e.dataset.dragging=`true`,n.preventDefault())}),e.addEventListener(`pointermove`,t=>{e.hasPointerCapture(t.pointerId)&&p(g+u*(t.clientX-h))});let _=t=>{e.releasePointerCapture(t.pointerId),delete e.dataset.dragging};e.addEventListener(`pointerup`,t=>{e.hasPointerCapture(t.pointerId)&&(_(t),s(p(g+u*(t.clientX-h))))}),e.addEventListener(`pointercancel`,t=>{e.hasPointerCapture(t.pointerId)&&(_(t),p(g))}),e.addEventListener(`dblclick`,()=>{n.style.removeProperty(r),f=null,e.setAttribute(`aria-valuenow`,String(Math.round(t.getBoundingClientRect().width))),s(null)}),e.addEventListener(`keydown`,e=>{let n=ak(e.key,a);if(n===null)return;e.preventDefault();let r=p((f??t.getBoundingClientRect().width)+u*n);r!==null&&s(r)})}var sk={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.`}},ck=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:Vt[e],meaning:t}),lk=Object.freeze([ck(E.DORMANT,`Not started yet.`),ck(E.STARTING,`Setting up the worktree and booting the agent.`),ck(E.RUNNING,`The agent is mid-turn.`),ck(E.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),ck(E.WAITING,`Waiting on a permission prompt or your answer.`),ck(E.COMPLETE,`Finished a turn you have not looked at yet.`),ck(E.IDLE,`Ready for the next prompt.`),ck(E.DONE,`The agent process ended.`),ck(E.FAILED,`The agent failed to start or crashed. A red line above the terminal says why it could not start; its terminal output shows a crash.`)]);function uk(e,t){let n=D(`section`,`status-legend`),r=D(`dl`,`status-legend-rows`);return r.append(...t),n.append(D(`h2`,`status-legend-title`,e),r),n}function dk(e,t){let n=D(`div`,`status-legend-row`);return n.append(e,D(`dd`,`status-legend-meaning`,t)),n}function fk(){return uk(`Status colors`,lk.map(e=>{let t=D(`dt`,`status-legend-badge`),n=D(`span`,`status-legend-glyph`),r=D(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=dk(t,e.meaning);return On(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function pk(){return uk(`Pull request icons`,Object.keys(sk).map(e=>{let t=sk[e],n=D(`dt`,`status-legend-badge`);return n.append(Ji(e),D(`span`,`status-legend-name`,t.label)),dk(n,t.meaning)}))}var mk=null,hk=null,gk=!1,_k=null;function vk(){return hk??=N(()=>import(`./first-run-checklist-om8MDQ1X.js`).then(e=>(mk=e,e),e=>(hk=null,y(`first-run`,`first-run checklist failed to load: ${l(e)}`),null)),__vite__mapDeps([33,12,13,4,3,14,5,6,7,34,26,15,19,22,27,18,35])),hk}function yk(e,t){_k={host:e,isShown:t},mk?mk.showFirstRunChecklist(e,t):t&&gk&&vk().then(e=>{e&&_k&&e.showFirstRunChecklist(_k.host,_k.isShown)})}function bk(){mk?.refreshFirstRunChecklist()}function xk(){gk=!0,_k&&yk(_k.host,_k.isShown)}var Sk=`removed`,Ck=new Set([E.COMPLETE,E.DONE,E.FAILED,Sk]);function wk(e){return Ck.has(e)}function Tk(e,t){let n=e.filter(e=>wk(t(e))).length;return{settled:n,total:e.length,isAllSettled:e.length>0&&n===e.length}}function Ek(e,t){let n=(e.panel?.verdicts??[]).map(e=>e.contestants[t]?.notes.trim()??``).filter(e=>e!==``);return n.length>0?n.join(`
|
|
73
|
+
`}function U_(){if(!N_)return;let e=O_(j_,A_?.anomalies),t=N_.hidden;N_.hidden=!e,e&&t&&A_&&(V_(),M_&&H_())}function W_(e){j_=e,U_()}function G_(e){if(N_)return N_;let t=B_();return e.appendChild(t),U_(),t}function K_(e){A_=e,U_(),N_&&!N_.hidden&&(V_(),M_&&H_())}var q_=null,J_=null,Y_=!1,X_=null,Z_=new Set;function Q_(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function $_(){for(let e of Z_)e()}function ev(){return{report:q_,hasReportSendFailed:Y_}}function tv(e){Z_.add(e)}function nv(e){J_=e}function rv(){if(!J_)return;X_=d(`hooks-report`);let e=J_({type:`request-hooks-report`,requestId:X_});e!==!Y_&&(Y_=!e,$_())}function iv(e){Q_(e,X_)&&(q_=e,Y_=!1,$_())}function av(){rv()}var ov=new Map,sv=new Map,cv=new Map,lv=null,uv=`op://vault/item/field`,dv=`or paste the value`;function fv(e,t){return Object.fromEntries([...e].map(([e,n])=>[e,t(n)]).filter(([,e])=>e))}function pv(e,t,n){s(t?{type:`secret-decision`,id:e,isAllowed:t,referenceByName:fv(n.referenceByName,e=>e.value.trim()),valueByName:fv(n.valueByName,e=>e.value),newItemsVault:n.vault.value.trim()}:{type:`secret-decision`,id:e,isAllowed:t})}function mv(){return lv??`vault name`}function hv(e,t,n){let r=D(`input`,`dialog-input ${e}`);return r.type=`text`,r.placeholder=t,r.spellcheck=!1,r.autocomplete=`off`,r.setAttribute(`aria-label`,n),r}function gv(e,t){let n=D(`div`,`secret-request`);n.setAttribute(`role`,`group`),n.setAttribute(`aria-label`,`Secret request`);let r={referenceByName:new Map,valueByName:new Map,vault:hv(`secret-request-vault`,mv(),`Vault for pasted values`)};cv.set(e,r.vault);let i=D(`div`,`secret-request-rows`);for(let e of t){let t=hv(`secret-request-reference`,uv,`Vault reference for ${e}`),n=hv(`secret-request-value`,dv,`Value for ${e}, saved into the vault`);n.type=`password`,n.autocomplete=`new-password`,r.referenceByName.set(e,t),r.valueByName.set(e,n);let a=D(`div`,`secret-request-row`);a.append(D(`code`,`secret-request-name`,e),t,n),i.append(a)}let a=D(`label`,`secret-request-vault-row`);a.append(D(`span`,`secret-request-vault-label`,`Pasted values go into`),r.vault);let o=D(`div`,`secret-request-actions`);return o.append(w({variant:`secondary`,label:`Deny`,onClick:()=>pv(e,!1,r)}),w({variant:`primary`,label:`Allow`,onClick:()=>pv(e,!0,r)})),n.append(D(`span`,`secret-request-text`,`The agent asks for these secrets. Allow saves each vault reference for this project; a pasted value goes into the vault first.`),i,a,o),n}function _v(e){lv=e;for(let e of cv.values())e.placeholder=mv()}function vv(e){let t=sv.get(e),n=ov.get(e);return t!==void 0&&n!==void 0&&t.dataset.names===n.join(` `)}function yv(e){let t=k.get(e);if(t&&vv(e)&&sv.get(e)?.parentElement===t.termWrap)return;sv.get(e)?.remove(),sv.delete(e),cv.delete(e);let n=ov.get(e);if(!n||!t)return;let r=gv(e,n);r.dataset.names=n.join(` `),sv.set(e,r),t.termWrap.append(r)}function bv(e,t){t.length===0?ov.delete(e):ov.set(e,[...t])}function xv(e){_v(e.newItemsVault),bv(e.id,e.names),yv(e.id)}function Sv(e){_v(e.newItemsVault);let t=[...ov.keys()];ov.clear();for(let[t,n]of Object.entries(e.requests))bv(t,n);for(let e of new Set([...t,...ov.keys()]))yv(e)}var Cv=new Map;function wv(e){return Cv.get(e)??[]}function Tv(e){return wv(e).length>0}function Ev(e){let t=A(e)?.btnDocs;t&&(t.hidden=!Tv(e))}var Dv=null,Ov=null;function kv(){return Ov??=N(()=>import(`./doc-editor-ui-nrnC5Ekm.js`).then(e=>(Dv=e,e),e=>(Ov=null,y(`doc-editor`,`doc editor failed to load: ${l(e)}`),null)),__vite__mapDeps([11,12,13,4,3,14,15,16])),Ov}function Av(e){kv().then(t=>t?.openDocEditor(e))}function jv(e){kv().then(t=>t?.openDocEditorOn(e))}function Mv(e){Dv?.applyDocsToOpenEditor(e)}function Nv(e){Cv.set(e.id,e.docs),e.docs.length===0&&Cv.delete(e.id),Ev(e.id),Mv(e.id)}function Pv(e){let t=[...Cv.keys()];Cv.clear();for(let[t,n]of Object.entries(e.sessions))Cv.set(t,n);for(let e of new Set([...t,...Cv.keys()]))Ev(e),Mv(e)}var Fv=10,Iv={low:0,medium:1,high:2};function Lv(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 Rv(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 zv(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function Bv(e,t){for(let n of e.hotspots)zv(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`});for(let n of e.blastRadius)n.transitiveDependentCount<Fv||zv(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`})}function Vv(e,t){return e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function Hv(e){return e.conflictRisk===null?-1:Iv[e.conflictRisk]}function Uv(e,t){return t.severity-e.severity||Hv(t)-Hv(e)||e.heading.localeCompare(t.heading)||e.groupKey.localeCompare(t.groupKey)}function Wv(e,t){return e===null||t===null?e??t:Iv[t]>Iv[e]?t:e}function Gv(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?(e.lines.push(n),e.conflictRisk=Wv(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(Vv);return n.sort(Uv)}function Kv(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:Lv(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of Rv(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);Bv(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:Gv(r.values()),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function qv(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 Jv(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 Yv(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=Jv(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 Xv(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function Zv(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 Qv({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=ey(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 $v({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?Qv({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 ey(e){return e||`base`}function ty(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function ny(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function ry({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 iy({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function ay(e){if(!e)return[];let t=new Map;for(let n of[...Yv(e.committed?.diff),...Yv(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 oy(e,t){return t===null?null:e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)??null}function sy(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 cy(e){return e!==E.DORMANT&&e!==E.DONE&&e!==E.FAILED}function ly(e,t){return(Rt.includes(e)||e===E.RUNNING)&&t}function uy(e){let{status:t,reason:n,isFetched:r,hasCommits:i,isWorkspace:a,state:o,effectiveBase:s}=e,c=Zv(e.files),l=cy(o),u=ny(t,n,ly(o,i)),d=iy({fetched:r,changedFileCount:c.files,hasCommits:i}),f=$v({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=ry({status:t,hasCommits:i,live:l,state:o});return{sentence:t===`parked`?`${f.text}. ${ty(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 dy=5e3,fy=new Map,py=new Map,my=new Map,hy=new Map,gy=new Map,_y=new Map,vy=new WeakMap,yy=new WeakMap,by=new Set,xy=new Set,Sy=null,Cy=null,wy=null,Ty=null,Ey=null;function Dy(e){return by.add(e),()=>by.delete(e)}function Oy(e){for(let t of by)t(e)}function ky(e){if(!e)return[];let t=vy.get(e);if(t)return t;let n=ay(e);return vy.set(e,n),n}function Ay(e){if(!e)return null;let t=yy.get(e);if(t)return t;let n=Kv(e);return yy.set(e,n),n}function jy(e){return k.get(e)?.card.dataset.workspace!==void 0}function My(e){let t=k.get(e);if(!t)return null;let n=my.get(e)??null,r=ky(n),i=hy.get(e)??null;return{...uy({status:fy.get(e)||`none`,reason:py.get(e)??null,isFetched:my.has(e),hasCommits:n?.hasCommits===!0,hasDiffError:i!==null,isWorkspace:jy(e),state:t.currentState,effectiveBase:t.effectiveBase,isMergeInFlight:_y.has(e),files:r}),sessionId:e,sessionName:t.card.dataset.session||e,files:r,diffError:i,changeMapView:Ay(gy.get(e)),notice:Sy?.sessionId===e?Sy.text:null,isWorkspace:jy(e)}}function Ny(e,t){Sy={sessionId:e,text:t},Cy&&clearTimeout(Cy),Cy=setTimeout(()=>{Sy=null,Oy(e)},dy),Oy(e)}function Py(e){gy.has(e)||gy.set(e,null),s({type:`request-change-map`,id:e})}function Fy(e){s({type:`request-session-diff`,id:e}),Py(e)}function Iy(e,t){let n=fy.get(e);fy.set(e,t),Xv(n,t)&&(my.delete(e),hy.delete(e),gy.delete(e),e===Li()&&Fy(e)),Oy(e)}function Ly(e,t,n=null){let r=t||`none`;py.set(e,n);let i=_y.get(e);i!==void 0&&i!==r&&_y.delete(e),Iy(e,r)}function Ry(e,t,n=null){py.set(e,n),_y.delete(e),Iy(e,t||`none`)}function zy(e,t){let n=O(e);n&&(my.set(n,t),hy.delete(n),Oy(n))}function By(e,t){let n=O(e);n&&(hy.set(n,t),Oy(n))}function Vy(e,t){let n=O(e);if(!n)return;let r=$e.safeParse(t);r.success&&r.data.sessionId===n&&(gy.set(n,r.data),Oy(n))}function Hy(e){let t=O(e);t&&t===Li()&&Fy(t)}function Uy(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function Wy(e){let t=O(e);if(!t||t!==Li())return;let n=!my.has(t)||hy.has(t),r=!gy.has(t)||Uy(gy.get(t));n&&Fy(t),r&&!n&&Py(t),Oy(t)}function Gy(e){let t=O(e);t&&_y.delete(t)&&Oy(t)}function Ky(e){let t=O(e);fy.delete(t),py.delete(t),my.delete(t),hy.delete(t),gy.delete(t),_y.delete(t),t===Li()?Oi(null):Oy(t)}function qy(e,t){_y.has(e)||(s(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(_y.set(e,fy.get(e)||`none`),Oy(e)):Ny(e,`Not connected. The merge was not sent.`))}function Jy(e){let t=My(e);return t?_y.has(e)?(Ny(e,`Merge is already on its way for "${t.sessionName}".`),!1):t.isMergeEnabled?k.get(e)?.currentState===E.RUNNING?(Xt({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:()=>qy(e,!0)}),!0):(qy(e,!1),!0):(Ny(e,t.mergeRefusal??`Nothing to merge in "${t.sessionName}" right now.`),!1):!1}function Yy(e){let t=My(e);t?.isDiscardShown&&Xt({title:`Discard worktree`,message:`Throw away the worktree changes for "${t.sessionName}"? This cannot be undone.`,confirmLabel:`Discard`,danger:!0,onConfirm:()=>s({type:`discard-session-worktree`,id:e})})}function Xy(){return[...xy].some(e=>!e.hasAttribute(`data-slot-held`))}function Zy(){let e=Xy()&&document.visibilityState===`visible`?Li():null;e!==wy&&(Ty&&clearInterval(Ty),Ty=null,wy=e,s({type:`watch-session-changes`,id:e}),e&&(Ty=setInterval(()=>s({type:`watch-session-changes`,id:e}),it)))}function Qy(e){Ey??=$y(),Ey.observe(e)}function $y(){return document.addEventListener(`visibilitychange`,Zy),Di(e=>{e&&Fy(e),Zy()}),new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&xy.add(t.target),t.isIntersecting||xy.delete(t.target);Zy()})}var eb=!1,tb=new Set;function nb(e){eb=!!e,pb();for(let e of tb)e(eb)}function rb(e){return tb.add(e),()=>tb.delete(e)}function ib(){return eb}function ab(){let e=D(`div`,`debug-close`);return e.append(w({variant:`icon`,size:`small`,label:`Close debug overlay`,icon:Te(st)})),e}function ob(e){return e?ft(new Date(e)):`-`}function sb(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function cb(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${sb(e.quietMs)})`:``}function lb(e){let t=`<span class="debug-dim">${ob(e.ts)}</span>`;if(e.kind===`signal`){let n=I([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${I(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=cb(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${I(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=I(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${I(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${I(e.category||`?`)}: <span class="debug-dim">${I(e.from||`?`)} → ${I(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${I(e.kind||`decision`)}</span>`}function ub(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">${I(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">${I(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${ob(e.timestamp)}</span> ${I(e.from)} → ${I(e.to)} <span class="debug-label">${I(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?`${I(a.signal)} (${I(a.source||`?`)}${a.confidence?`/${I(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">${I(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 ${sb(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">${I(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">${lb(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(ab())}function db(e,t){if(e.debugOpen){fb(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(ab()),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`)&&fb(e)}),s({type:`debug-state`,id:t})}function fb(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function pb(){for(let[,e]of k)e.btnDebug.classList.toggle(`visible`,eb),e.btnTrace.classList.toggle(`visible`,eb),eb||e.debugOpen&&fb(e)}function mb(e){let t=typeof e.id==`string`?k.get(e.id):void 0;t?.debugOpen&&ub(t,e.payload)}function hb(e){A(e)?.debugOpen&&s({type:`debug-state`,id:e})}function gb(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:t===Je}}function _b(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 vb(e,t){return{body:t.join(`
|
|
74
|
+
`),tag:`glimmervoid-alert-${e.id}`,renotify:e.isStart}}var yb=4e3;function bb(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function xb(e,t,n,r=yb){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 Sb=`#plan/`;function Cb(e){return`${Sb}${encodeURIComponent(e)}`}function wb(e){if(!e.startsWith(Sb))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var Tb=null;function Eb(){return Tb??=N(()=>import(`./alert-sound-At4lBeip.js`),__vite__mapDeps([10,6])).catch(e=>(Tb=null,y(`alert-sound`,`alert sound failed to load: ${l(e)}`),null)),Tb}function Db(){let e=Kr();Eb().then(t=>t?.playAlertSound(e))}function Ob(){return typeof Notification>`u`?null:Notification}function kb(){return Ob()!==null}function Ab(){let e=Ob();return e?e.permission:`unavailable`}async function jb(){let e=Ob();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function Mb(){return!kb()&&!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.`:kb()?Ab()===`denied`&&Er()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function Nb(){if(!kb()||!Er())return`off`;let e=Ab();return e===`granted`?`on`:e==="default"?`ask`:`off`}function Pb(){return Er()&&Ab()==="default"}function Fb(e=()=>{}){let t=D(`div`,`notification-permission`),n=()=>{let r=Mb();if(t.replaceChildren(),t.hidden=!r&&!Pb(),r){t.append(D(`p`,`notification-permission-hint text-meta text-text-muted`,r));return}let i=w({variant:`secondary`,label:`Enable desktop notifications`});i.addEventListener(`click`,()=>{i.disabled=!0,jb().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var Ib=`Notifications`,Lb=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,Rb=new Map,zb=!1;function Bb(){zb||(zb=!0,sr({source:Ib,message:Lb,hidesInStreamerMode:!1}))}function Vb(e,t){let n=Rb.get(e)??new Set;n.add(t),Rb.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function Hb(e){let t=Rb.get(e);if(t){Rb.delete(e);for(let e of t)e.close()}}function Ub(e){return!kb()||!Er()||document.documentElement.hasAttribute(`data-streamer`)?!1:e||!document.hasFocus()}function Wb(){return Ub(!1)&&Ab()===`granted`}var Gb=null;function Kb(e,t){let n=Ob();if(!n||(Gb=_b(Gb,t,e.message),or(Ib),!xb(window.localStorage,bb(`group-${t.id}`,`${e.session}-${e.category}`),Date.now())))return;let r=t.sessionIds.length===1?k.get(e.session):void 0,i=t.sessionIds.length>1?`${t.sessionIds.length} sessions`:r?Kn(r):`Glimmervoid`;try{let r=new n(i,vb(t,Gb.lines));r.onclick=()=>{window.focus(),e.kind===`plan`&&(window.location.hash=Cb(e.session)),r.close()};for(let e of t.sessionIds)k.has(e)&&Vb(e,r)}catch{}}var qb=null;function Jb(e){return!e||e.id!==qb&&(qb=e.id,!0)}function Yb(e){k.get(e.session)?._isActiveViewer?.()===!0?s({type:`alert-seen`,id:e.session}):Jb(e.group)&&ri()&&Db()}function Xb(e,t){t?Kb(e,t):ex(e)}function Zb(){let e=Reflect.get(navigator,`userAgentData`);return typeof e!=`object`||!e?!1:Reflect.get(e,`platform`)===`macOS`}function Qb(e){!document.hasFocus()&&Wb()&&ex(e)}function $b(e){if(e.category===`answered`){Qb(e);return}if(document.hasFocus()){Yb(e);return}let t=e.group;Wb()&&(Xb(e,t),!Zb())||(Ub(!1)&&Ab()===`denied`&&Bb(),t?.isStart!==!1&&Jb(t)&&ri()&&Db())}function ex({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=Ob();if(!a||!Ub(!!i)||(a.permission===`denied`&&Bb(),a.permission!==`granted`)||(or(Ib),!xb(window.localStorage,bb(e,t),Date.now())))return;let o=typeof e==`string`?e:``,s=k.get(o),c=s?Kn(s):``;try{let i=new a(c||`Glimmervoid`,gb(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=Cb(o)),i.close()},s&&Vb(o,i)}catch{}}var tx=null;function nx(){return tx??=N(()=>import(`./resume-dialog-C-j9LGui.js`),__vite__mapDeps([17,13,4,3,12,14,18,19,15])).catch(e=>(tx=null,y(`resume-dialog`,`restart dialog failed to load: ${l(e)}`),null)),tx}var rx=null,ix=null;function ax(){return ix??=N(()=>import(`./plan-face-AIPyl9ns.js`).then(e=>(rx=e,e),()=>(ix=null,null)),__vite__mapDeps([20,13,4,3,21,15,22,23,24])),ix}function ox(e){let t=D(`section`,`plan-face`);t.hidden=!0;let n=null,r=!1,i=null,a={},o=new Map;function s(s){if(r=!1,e.signal?.aborted)return;if(!s){e.reportProblem(`The plan view did not load. Open the plan again to retry.`),i!==null&&e.showTerminal(),i=null;return}let c=s.createPlanFace(e);t.replaceWith(c.el),c.update(a);for(let e of o.values())c.update({draft:e});o.clear(),n=c,i!==null&&c.show(i)}return{get el(){return n?.el??t},show(e){n?n.show(e):(i=e,r||(r=!0,ax().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 sx=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function cx(e){return e===`approve`||e===`approve-accept-edits`}function lx(e){return(e.state===`decided`||e.state===`closed`)&&cx(e.lastDecision)}function ux(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&lx(n)}function dx(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function fx(e){let t=dx(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 px(e,t){return dx(e,t)?.openRevision?.revision??null}function mx(e,t,n){if(n===null)return null;let r=dx(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function hx(e,t){let n=t-e;return Number.isFinite(n)?fe(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function gx(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 _x(e,t,n){let r=gx(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return sx.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function vx(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 yx(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function bx(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+ct}function xx(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 ${ut} characters, so nothing was sent`:yx(e)>1e4?`the feedback composes more than the ${gt} characters the hook reply carries, so nothing was sent`:bx(e)>Ue?`the decision is larger than one control frame carries, so nothing was sent`:null}function Sx(e){return e?`, ${e}`:``}function Cx(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=vx(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 wx(e,t,n){let r=Cx(e,t,n);return r?`${r}${Sx(e.problem)}`:e.problem??``}function Tx(e){let t=dx(e.state,e.selectedAgentId),n=fx(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:mx(e.state,t?.agentId??null,n),status:wx(e,t,n),actions:_x(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:mx(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:gx(e,t,n)}]}}function Ex(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 Dx({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 Ox({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var kx=e=>Ut.includes(e),Ax=e=>Mt.includes(e);function jx(e){let t=e.currentState;e.btnRestart.classList.toggle(`visible`,kx(t)||Ax(t)||t===E.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,ib()),e.btnPlan.hidden=Ox(e)===`hidden`}function Mx(e){let t=A(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(O(e)),jx(t),Vl(t,O(e)),!0)}function Nx(e,t){let n=A(e);n&&(n.hasPlan=t===!0,jx(n))}function Px(e){let t=A(e.id);t&&(t.planReviewState=Ex(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),jx(t))}function Fx(e){let t=A(e.id);t&&t.planFace.update({draft:e})}function Ix(e){let t=A(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),jx(t))}function Lx(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=A(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function Rx(e){for(let[,t]of k)t.planFace.update({isConnected:e})}var zx=160,Bx=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 Vx(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=zx?t:`${t.slice(0,157)}...`}function Hx(e,t){let n=Bx[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?Vx(r):``}var Ux=5e3;function Wx(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function Gx(e,t){if(!e.toolUseId)return Wx(e.text)??`context`;let n=t.get(e.toolUseId);return n?Hx(n.name,n.input)||n.name:`expansion`}function Kx(e){return e.kind!==`expansion`||e.toolUseId?!1:Wx(e.text)!==null}function qx(e){return e.kind===`prompt`||e.kind===`session`||Kx(e)}function Jx(e){return new TextEncoder().encode(e).byteLength}var Yx={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`};function Xx(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:Vx(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:Vx(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:Vx(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:Vx(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:Vx(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:Gx(e,t)};if(e.kind===`tool_call`){let t=Hx(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:`${Jx(e.content)} bytes`}}function Zx(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function Qx(e,t){let n=Xx(e,t),r=Zx(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:Yx[e.kind],text:`${r}${i}`,tone:o,badges:a}}function $x(e,t){return{record:e,...Qx(e,t)}}function eS(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function tS(e,t){let n=eS(e);return!n||t.has(n)?null:n}function nS(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function rS(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function iS(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=eS(i.record);a&&t.has(a)&&(n.rows[r]=$x(i.record,e.toolCallByUseId))}}function aS(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function oS(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function sS(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=Jx(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function cS(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=tS(i,e.toolCallByUseId);t&&nS(e.unresolvedToolUseCounts,t);let a=$x(i,e.toolCallByUseId);if(qx(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:oS()},sS(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:oS()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),sS(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 lS(e,t){let n=aS();cS(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)||nS(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],iS(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function uS(e){return e.rows.length+ +!!e.head}function dS(e){let t=0;for(let n of e.turns)t+=uS(n);return t}function fS(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=eS(n.record);t&&rS(e.unresolvedToolUseCounts,t)}}function pS(e,t){fS(e,t.head?[t.head,...t.rows]:t.rows)}function mS(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);fS(e,i);for(let e of i)sS(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function hS(e,t=Ux){let n=dS(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=uS(t),pS(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:mS(e,n-t)}}function gS(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 _S(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 vS(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 yS(e,t=Ux){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function bS(e,t=Ux){return!yS(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function xS(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 SS=1e4,CS=null,wS=null,TS=[],ES=null,DS=null,L=null,OS=null,kS=!1,AS=null,jS=()=>!1,MS=new Set;function NS(e){for(let t of MS)t(e)}function PS(){OS&&=(clearTimeout(OS.timeoutHandle),null)}function FS(){OS=null,AS=`The trace did not load within ${Math.round(SS/1e3)} s.`,NS({kind:`rebuild`})}function IS(e){PS(),kS=!1,AS=null,ES=e,L=e?{sessionId:e,grouping:aS(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,NS({kind:`selection-reset`})}function LS(e){let t=_S(TS,DS,ES,e);return DS&&t===DS&&(DS=null),t!==ES&&(IS(t),!0)}function RS(e){if(!CS)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};CS(t)?OS={request:e,timeoutHandle:setTimeout(FS,SS)}:(AS=S,NS({kind:`header`}))}function zS(e=!1){if(!CS)return;let t=vS({selectedSessionId:ES,isPanelVisible:e||jS(),hasPendingRequest:!!OS,hasLoadedOnce:L?.hasLoadedOnce??!1,nextOffset:L?.nextOffset??0});t&&RS(t)}function BS(){kS&&!OS&&(kS=!1,zS())}function VS(){if(!L)return;let e=hS(L.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!L.hasDroppedEarliestRows;t&&(L.hasDroppedEarliestRows=!0),NS({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function HS(e){L&&(NS({kind:`records-appended`,appends:cS(L.grouping,e)}),VS())}function US(e){L&&(NS({kind:`records-prepended`,prepend:lS(L.grouping,e)}),VS())}function WS(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 GS(){return{selectedSessionId:ES,hasPendingRequest:!!OS,hasLoadedOnce:L?.hasLoadedOnce??!1,hasDroppedEarliestRows:L?.hasDroppedEarliestRows??!1,firstOffset:L?.firstOffset??0,residentRowCount:L?dS(L.grouping):0}}function KS(){return{sessionOptions:TS,selectedSessionId:ES,selectedTrace:L,pendingSessionId:OS?.request.id??null,traceFailureText:AS}}function qS(e){MS.add(e)}function JS(e){jS=e}function YS(){if(!CS)return;let e=bS(GS());e&&RS(e)}function XS(e){TS.some(t=>t.id===e)&&e!==ES&&(DS=null,IS(e),zS(),NS({kind:`rebuild`}))}function ZS(){let e=LS(!0);return zS(!0),e}function QS(e){CS=e}function $S(e){wS=e}function eC(e){DS=e,wS?.()}function tC(e){TS=gS(e);let t=LS(jS());t&&zS(),NS({kind:`sessions`,hasSelectionChanged:t})}function nC(e){let t=WS(e);if(!t)return;let n=xS({pendingRequest:OS?.request??null,resident:L?{sessionId:L.sessionId,firstOffset:L.firstOffset,nextOffset:L.nextOffset,hasLoadedOnce:L.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?BS():(PS(),AS&&(AS=null,NS({kind:`header`})),n===`stale`?BS():n===`reset`?(IS(t.id),L&&(L.filePath=t.path),zS(),NS({kind:`rebuild`}),BS()):L&&(L.filePath=t.path,n===`prepend`?(L.firstOffset=t.start,US(t.records),BS()):(n===`seed`&&(L.hasLoadedOnce=!0,L.firstOffset=t.start),L.nextOffset=t.next,HS(t.records),BS())))}function rC(e){let t=e?.id;typeof t==`string`&&t===ES&&jS()&&(OS?kS=!0:zS())}function iC(e){let t=e?.id;if(typeof t!=`string`||OS?.request.id!==t)return!1;PS(),kS=!1;let n=e?.message;return AS=typeof n==`string`&&n?n:`The trace could not be read.`,NS({kind:`rebuild`}),!0}function aC(e){PS(),kS=!1,AS=e?null:S,e?(NS({kind:`header`}),zS()):NS({kind:`rebuild`})}function oC(e,t,n=!1){let r=D(`label`,`dialog-checkbox-label`),i=D(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,D(`span`,null,e)),r}function sC(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function cC(e){let[t,n]=await Promise.all([c(`get-workspace-repos`,{id:e}),c(`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:sC(e),path:e,isMember:!0})),i=new Set(t.repos),a=n?.type===`repo-roots-scanned`?n.directories:[];for(let e of a.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 lC(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:a}=Qt({title:`Workspace repositories`}),o=D(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),s=D(`fieldset`,`dialog-workspace-list`);s.setAttribute(`aria-label`,`Workspace repositories`),s.append(D(`div`,`dialog-hint`,`Loading repositories...`));let l=D(`div`,`dialog-hint`);l.setAttribute(`role`,`status`);let u=D(`div`,`dialog-error`),d=w({variant:`primary`,label:`Save`,disabled:!0});i.append(d),n.append(o,s,l,u,i),a.addEventListener(`click`,r),requestAnimationFrame(()=>a.focus()),cC(e).then(e=>{if(t.isConnected){s.textContent=``;for(let t of e)s.append(oC(t.name,t.path,t.isMember));d.disabled=!1}}).catch(e=>{t.isConnected&&(s.textContent=``,u.textContent=`Could not load repositories: ${zn(e)}`)}),d.addEventListener(`click`,()=>{let n=[...s.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`,c(`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: ${zn(e)}`)}).finally(()=>{l.textContent=``,d.disabled=!1}))})}function uC(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function dC(e,t){Cn(e.taskTitleEl,()=>dn(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),ln(e,t)}),e.nameEl.addEventListener(`click`,()=>{tn(e.nameEl)||Oi(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),ln(e,t))}),e.btnRename.addEventListener(`click`,()=>{uC(e),ln(e,t,{returnsFocusToTerminal:!e.renameTargetEl?.isConnected})}),e.btnRestart.addEventListener(`click`,()=>{uC(e),nx().then(n=>n?.openRestartDialog(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0}))}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{uC(e),lC(t)}),e.btnTrace.addEventListener(`click`,()=>{uC(e),eC(t)}),e.btnDocs.addEventListener(`click`,()=>{uC(e),Av(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=Ox(e);n!==`hidden`&&(n===`face`?Mx(t):location.hash=Cb(t))}),e.btnRemove.addEventListener(`click`,()=>{uC(e),Ii(t)});function n(){for(let[,t]of k)t!==e&&uC(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`)}e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation(),e.sessionMenu.classList.contains(`open`)?uC(e):n()}),qi({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:()=>uC(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&&uC(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),uC(e),db(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&fb(e)},{signal:e.abortController.signal})}var fC=1500,pC=new WeakMap;function mC(e){clearTimeout(pC.get(e)),pC.delete(e)}function hC(e,t){let n=setTimeout(()=>{pC.delete(e),s({type:`dismiss`,id:t,expectedState:E.COMPLETE})},fC);pC.set(e,n)}function gC(e,t,n){let r=document.activeElement;return Ei({previousState:t,nextState:n,isPhoneLayout:Ko(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}var _C=e=>e==null?``:String(e);function vC(e,t,n){let r=A(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&cn(e,r.taskTitle)}}function yC(e){return typeof e==`string`&&k.has(e)}function bC(){return k.size}function xC(e){let t=e||{};t.linkPreviews!=null&&jd(t.linkPreviews),t.cursorBlink!=null&&bf(t.cursorBlink),t.debugMode!=null&&(nb(t.debugMode),W_(t.debugMode));for(let[,e]of k)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function SC(){Cu(k.values(),Tu())}function CC(e){return{state:e.currentState,unseenOutcome:e.unseenOutcome,ownerId:e.ownerId}}function wC(){let e=Vn(j.counts),t=e>0?`(${e}) Glimmervoid`:`Glimmervoid`;document.title!==t&&(document.title=t)}function TC(e,t,n,r={}){if(!Zn)return;let i=O(e),a=_C(n)||E.DORMANT,o=fn(i,_C(t),a,r),c=a===E.DORMANT;Zn.appendChild(o.card);let l;function u(){l.face=`terminal`,l.card.dataset.face=`terminal`,l.termWrap.hidden=!1,l.planFace.hide(),jx(l),Af(l,i)}let d=new AbortController,f=ox({signal:d.signal,requestPlan:(e,t,n)=>s({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>s({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:u,sendDecision:(e,t)=>s({type:`plan-decision`,id:e,...t}),reportProblem:e=>xn(i,e)});l={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:_C(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:d,currentState:a,face:`terminal`,isBorrowed:!1,hasPlan:!1,pendingPromptKind:null,planReviewState:{reviews:[]},planFace:f},l._ensureTerminalReady=()=>Af(l,i),l._showTerminalFace=u,l._showPreferredFace=u,l._setBorrowed=e=>{l.isBorrowed=e,o.card.toggleAttribute(`data-borrowed`,e),jx(l)},o.card.append(f.el);let p=k.get(i);return p&&Hn(j,CC(p)),k.set(i,l),Wn(j,CC(l)),mr(i,l),dC(l,i),jx(l),l.btnDocs.hidden=!Tv(i),yv(i),a===E.RUNNING&&pr(l,!0),c||Df(l,i),wC(),l}function EC(e,t){let n=A(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function DC(e,t){let n=A(e);if(!n)return;n.agent=typeof t==`string`?t:null;let r=n.card.querySelector(`.session-agent-mark`);r&&Bn(r,n.agent),jx(n)}function OC(e,t){let n=A(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function kC(e,t,n=!1){let r=A(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=Gt(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function AC(e,t){let n=A(e);n&&(n.pendingPromptKind=typeof t==`string`?t:null)}function jC(e,t){let n=A(e);n&&(Hn(j,CC(n)),n.unseenOutcome=t??null,Wn(j,CC(n)))}function MC(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function NC(e,t,n=null){let r=A(e),i=_C(t)||`none`;r&&MC(r.card,i),Ly(O(e),i,_C(n)||null)}function PC(e,t,n=null){let r=A(e),i=_C(t)||`none`;r&&MC(r.card,i),Ry(O(e),i,_C(n)||null)}function FC(e,t){let n=A(e);if(!n)return;let r=_C(t);n.card.dataset.session=r,n.nameEl.textContent=r}function IC(e){let t=A(e);t&&(fb(t),Hn(j,CC(t)),k.delete(O(e)),mr(O(e),void 0),rx?.dropPlanBodyCache(O(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),gu(t,O(e)),Ao(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),wC())}function LC(e,t,n){if(!t||!e.term)return;let r=n===E.DONE?`Session complete`:`Session failed`,i=n===E.DONE?`\x1B[34m`:`\x1B[31m`;e.term.write(`\r\n\r\n\x1b[2m${i} ${r}\x1b[0m\r\n\r\n\x1b[2m Open the session actions menu and choose Restart to start a new session.\x1b[0m\r\n`)}function RC(e,t){e.term&&(t===E.DONE||t===E.FAILED)&&(e.term.clear(),e.term.reset())}function zC(e){let t=k.get(e);t&&document.visibilityState===`visible`&&(Ko()||document.hasFocus())&&(kn(e),er({state:t.currentState,unseenOutcome:t.unseenOutcome})&&s({type:`dismiss`,id:e,expectedState:t.currentState}))}function BC(e,t,n){let r=A(e);if(!r)return;let i=_C(t),a=r.currentState;Hn(j,CC(r)),r.currentState=i,Wn(j,CC(r)),mr(O(e),r),i!==E.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(mC(r),r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),pr(r,i===E.RUNNING)),a===E.DORMANT&&i!==E.DORMANT&&Df(r,O(e)),tr({state:i})===`resting`&&Hb(O(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,Gt(i,r.awaitingBackgroundTasks)),jx(r),gC(r,a,i)&&hC(r,O(e));let o=i===E.DONE||i===E.FAILED,s=a!==E.DONE&&a!==E.FAILED&&a!==E.INITIALIZING;o&&s&&(r.card.classList.remove(`completion-flash`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.card.classList.add(`completion-flash`),r.card.addEventListener(`animationend`,()=>r.card.classList.remove(`completion-flash`),{once:!0})})})),(i===E.DONE||i===E.FAILED)&&LC(r,s,i),i===E.INITIALIZING&&RC(r,a),wC()}var VC=pa({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function HC(e){let t=D(`ul`,`session-setup-list`);return t.append(...e.map(e=>D(`li`,null,e))),t}function UC(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=Bt(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[D(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=D(`div`,`session-setup-plugin`);return t.append(D(`h3`,null,e.name)),e.skills.length>0&&t.append(D(`p`,`session-setup-label`,`Skills`),HC(e.skills)),e.agents.length>0&&t.append(D(`p`,`session-setup-label`,`Agents`),HC(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[HC(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=D(`p`,`session-setup-hook`);return t.append(D(`span`,null,e.event),D(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>D(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[HC(t.skills)]:[]),n(`Agents`,t.agents.length>0?[HC(t.agents)]:[])}function WC(e){let t=D(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=D(`div`,`session-setup-sections`);VC.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function GC(e){let t=VC.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;UC(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function KC(e){return fe(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function qC(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${KC(Date.now()-e)} ago`}var JC=e=>`polled ${qC(e)}`;function YC(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=JC){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=hr(a)}}}var XC=80,ZC=Object.freeze([{value:`day`,label:`Today`,days:1},{value:`week`,label:`Last 7 days`,days:7},{value:`month`,label:`Last 30 days`,days:30}]),QC=`week`;function $C(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function ew(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function tw(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${$C(String(Math.abs(t)))}`}function nw(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}$${$C(r)}.${i}`}function rw(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}${ew((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${ew((n/1e6).toFixed(2))}M`:`${t}${ew((n/1e9).toFixed(2))}B`}function iw(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=XC?`warn`:`ok`}var aw=90;function ow(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&C(e.budgetUsd,null)!==null):[]}function sw(e){let t=C(e?.pct,null);return t===null?0:t}function cw(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=C(n.pct,null),i=C(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}function lw(e){return e?.vendor===`codex`||e?.vendor===`kimi`?e.vendor:`claude`}function uw(e,t=null){let n=[],r=iw(cw(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 ow(e)){let e=sw(t);if(e<aw)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return dt(n)}function dw(e,t=``){let n=e?.source;if(n===`fetched`){let e=Xe(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=Xe(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 fw(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 pw(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function mw(e){if(!e||typeof e!=`object`)return``;let t=[],n=pw(e.dirs);if(n!==null&&t.push(`${tw(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${tw(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${tw(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${tw(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 hw(e){return Xe(e?.error,``)}function gw(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}var _w=`Estimated list prices, not a bill.`,vw=`Enable in Settings.`,yw=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],bw=/^(\d{4})-(\d{2})-(\d{2})$/,xw=new Set([`day`,`model`,`label`]),Sw=new Set([`model`,`label`]);function Cw(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${ew(e.toFixed(1))}%`}var ww=`tokens`,Tw=Object.freeze([{value:`tokens`,label:`Tokens`},{value:`cost`,label:`Cost`}]);function Ew(e){return e===`cost`?`cost`:ww}function Dw(e,t){return t===`cost`?nw(e):rw(e)}function Ow(e,t){if(t===`tokens`)return`tokens`;let n=Number(e?.costUSD);return Number.isFinite(n)&&n>0?`costUSD`:`tokens`}function kw(e){return e===`costUSD`?`share of cost`:`share of tokens`}function Aw(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function jw(e){let t=bw.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=yw[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function Mw(e){let t=Nw(e);return t.length===0?``:t.length===1?jw(t[0]):`${jw(t[0])} to ${jw(t[t.length-1])}`}function Nw(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>bw.test(e)).sort()}function Pw(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:Fw(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function Fw(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=Iw(e,n);return bw.test(r)?r:Iw(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function Iw(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function Lw(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:me(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function Rw(e,t){let n=qE(Me(t),-1),[,r,i]=e.yesterday.day.split(`-`).map(Number),a=e.yesterday.day===n?`yesterday`:`${yw[r-1]} ${i}`,o=e.yesterday.sessionCount===1?`session`:`sessions`;return`${a}: ${e.yesterday.sessionCount} ${o}, ${Lw(e.yesterday.activeMs/6e4)}`}function zw(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=yw[n.getMonth()];return r?`${r} ${n.getDate()} ${ge(n)}`:`-`}var Bw=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`}),Vw=`Sessions spawned by Glimmervoid; terminal sessions count as other`,Hw=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function Uw(e){let t=Xe(e,``);return t?Bw[t]||t:Bw.other}function Ww(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function Gw(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function Kw(e){return Ww(e).some(e=>Gw(e.lane))}var qw=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function Jw(e,t,n){let r=cw(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function Yw(e,t,n,r){if(!Array.isArray(t))return null;let i=t.filter(e=>e&&typeof e.lane==`string`),a=i.reduce((e,t)=>e+C(t.costUSD,0),0),o=i.reduce((e,t)=>e+C(t.tokens,0),0),s=i.filter(e=>Gw(e.lane)).map(e=>({lane:String(e.lane),label:Uw(e.lane),tokens:C(e.tokens,0),costUSD:C(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?Aw(c,a):Aw(l,o),d=Jw(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:qw[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function Xw(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:BT.map(e=>Yw(e.key,r[e.key],t,n)).filter(e=>e!==null)}function Zw(e){return e.planPct===null?``:`about ${Cw(e.planPct)} of plan`}function Qw(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?nw(e.costUSD):rw(e.tokens)}`).join(`, `)}var $w=`team-review`;function eT(e){if(!Array.isArray(e?.byLane))return``;let t=Ww(e).find(e=>e.lane===$w),n=C(t?.costUSD,0);if(n<=0)return``;let r=Aw(n,e?.totals?.costUSD),i=r===null?``:`, ${Cw(r)} of this period`;return`PR reviews cost ${nw(n)}${i}.`}function tT(e){let t=C(e,null);return t===null||t<=0?``:`${tw(t)} ${t===1?`session`:`sessions`}`}function nT(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function rT(e){let t=nT(e);if(!t)return``;let n=C(t.savedUSD,0);if(n<=0)return``;let r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e).length,i=r===0?``:`, at least, since ${r} ${r===1?`model has`:`models have`} no price`;return`Prompt caching saved ${nw(n)}${i}, across ${rw(C(t.cacheReadTokens,0))} cache read tokens.`}function iT(e){return e===`monthly`?`this month`:`today`}function aT(e){return`${nw(C(e?.spentUsd,0))} of ${nw(C(e?.budgetUsd,0))}`}function oT(e){return`${iT(e?.scope)} spend against budget`}var sT=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function cT(e){let t=bw.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function lT(e){let t=cT(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Me(t)}function uT(e){let t=bw.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function dT(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 fT(e,t){e.tokens+=C(t?.tokens,0),e.costUSD+=C(t?.costUSD,0),e.input+=C(t?.input,0),e.output+=C(t?.output,0),e.cacheCreate+=C(t?.cacheCreate,0),e.cacheRead+=C(t?.cacheRead,0),e.days+=1,e.sources.add(t?.source===`history`?`history`:`live`);let n=Array.isArray(t?.vendors)?t.vendors:[];for(let t of n)e.vendorSet.add(t);let r=t?.models||[];for(let t of r){t?.vendor&&e.vendorSet.add(t.vendor);let n=ZT(t),r=e.modelByName.get(n)||{key:n,model:t?.model??n,vendor:t?.vendor,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0};r.tokens+=C(t?.tokens,0),r.costUSD+=C(t?.costUSD,0),r.input+=C(t?.input,0),r.output+=C(t?.output,0),r.cacheCreate+=C(t?.cacheCreate,0),r.cacheRead+=C(t?.cacheRead,0),e.modelByName.set(n,r)}}function pT(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 mT(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)||dT(r);fT(i,e),n.set(r,i)}return Array.from(n.values()).map(pT)}function hT(e){return mT(e,lT)}function gT(e){return mT(e,uT)}function _T(e,t){return t===`week`?hT(e):t===`month`?gT(e):Array.isArray(e)?[...e]:[]}var vT=/^(\d{4})-(\d{2})$/;function yT(e,t){if(t===`month`){let t=vT.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=yw[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=jw(e);return t===`-`?t:`week of ${t}`}return jw(e)}function bT(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var xT=16,ST=Object.freeze([.05,.25,.5,.75]),CT=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function wT(e,t){let n=C(e,0),r=C(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<ST.length;e+=1)i>=ST[e]&&(a=e+1);return a}function TT(e,{weeks:t=xT,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>bw.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`&&bw.test(n)?n:Me(o),c=cT(lT(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Me(l),d=[],f=0,p=null;for(let e of r){let t=String(e.day);(p===null||t<p)&&(p=t),t<u||t>s||(f=Math.max(f,C(e.tokens,0)))}for(let e=0;e<t;e+=1)for(let t=0;t<7;t+=1){let n=new Date(l.getFullYear(),l.getMonth(),l.getDate()+e*7+t,12),r=Me(n),a=i.get(r)||null,o=r>s,c=p!==null&&r<p;d.push({day:r,week:e,weekday:t,tokens:C(a?.tokens,0),costUSD:C(a?.costUSD,0),source:a?.source===`history`?`history`:a?`live`:null,noData:o||c||!a&&p===null,tone:wT(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function ET(e){let t=jw(e?.day);if(e?.noData)return`${t}: no data`;let n=C(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${rw(n)} tokens, ${nw(C(e?.costUSD,0))}`}function DT(e){if(!e)return``;let t=C(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${jT(e.ratio)} the ${n} average: ${nw(e.todayUsd)} against ${nw(e.baselineUsd)}.`}function OT(e){return e?`This block is burning ${jT(e.ratio)} the usual rate: ${rw(e.current)} tokens per minute against ${rw(e.baseline)}.`:``}function kT(e){return[DT(e?.daily),OT(e?.burn)].filter(Boolean).join(` `)}function AT(e){return!!(e?.daily||e?.burn)}function jT(e){let t=C(e,null);return t===null?`-`:`${ew(t.toFixed(1))}x`}var MT=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`,kimi:`Kimi`});function NT(e){let t=Xe(e,``);return t?MT[t]||t:MT.claude}function PT(e,t){return IT(t)?NT(e?.vendor):``}function FT(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>C(t[n]?.tokens,0)-C(t[e]?.tokens,0)).map(e=>({vendor:e,label:NT(e),tokens:C(t[e]?.tokens,0),costUSD:C(t[e]?.costUSD,0)}))}function IT(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 LT=`Claude only`;function RT(e){return IT(e)?LT:``}var zT=36e5,BT=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]),VT=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`},{vendor:`kimi`,label:`Kimi Code`}]);function HT(e,t=Date.now()){let n=C(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function UT(e,t=Date.now()){let n=C(e,null);return n===null||n<=0||t-n>zT}function WT(e,t=Date.now()){if(!UT(e,t))return``;let n=HT(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function GT(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 KT(e){let t=Xe(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function qT(e){return hw(e)!==``}function JT(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 YT(e){return typeof e?.id==`string`&&e.id!==``}function XT(e){let t=Xe(e?.label,``);return YT(e)&&t?t:JT(e?.project)||t||`unknown project`}function ZT(e){let t=typeof e==`string`?e:e?.model;return Xe(t,`unknown model`)}function QT(e){return String(e?.day??``)}function $T(e,t,n){if(!xw.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?QT(e):n(e)}function eE(e,t,n,r=XT){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=$T(e,t,r),o=$T(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 tE(e){return Sw.has(e)?`asc`:`desc`}function nE(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:tE(t)}}function rE(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var iE=Object.freeze({key:`lastTs`,dir:`desc`}),aE=Object.freeze({key:`tokens`,dir:`desc`}),oE=Object.freeze({key:`day`,dir:`desc`});function sE(e,t=iE){return eE(e,t.key,t.dir,XT)}function cE(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 lE(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${tw(t)} hidden`}function uE(e,t=aE){return eE(e,t.key,t.dir,ZT)}function dE(e,t=oE){return eE(e,t.key,t.dir,QT)}function fE(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function pE(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 mE=36e5,hE=24*mE,gE=Object.freeze({fiveHour:{lengthMs:5*mE,label:`5-hour`},sevenDay:{lengthMs:7*hE,label:`weekly`}}),_E=10,vE=80,yE=100,bE=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function xE(e,t){return e>=yE?`fail`:e>=vE||t!==null&&t>=vE?`warn`:`ok`}function SE(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 CE(e,t,n,r){let i=cw(n,t);if(!i||i.pct===null||i.resetsAtMs!==null&&i.resetsAtMs<=r)return null;let a=gE[t],o=SE(a.lengthMs,i.resetsAtMs,r),s=o!==null&&o>=_E&&i.pct<yE?i.pct/(o/100):null;return{vendor:e,vendorLabel:VT.find(t=>t.vendor===e)?.label||e,key:t,windowLabel:a.label,usedPct:i.pct,elapsedPct:o,projectedPct:s,resetsAtMs:i.resetsAtMs,tone:xE(i.pct,s)}}function wE(e,t){return VT.flatMap(({vendor:n})=>BT.map(({key:r})=>CE(n,r,e[n],t)).filter(e=>e!==null))}function TE(e,t){let n=C(e,null);if(n===null||n<=0)return``;let r=new Date(n),i=ge(r);return Me(n)===Me(t)?i:n-t<7*hE&&r.getDay()!==new Date(t).getDay()?`${bE[r.getDay()]} ${i}`:`${yw[r.getMonth()]} ${r.getDate()} ${i}`}function EE(e){return`${Math.round(e)}%`}function DE(e){return Math.max(e.usedPct,e.projectedPct??0)}function OE(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 kE(e,t){let n=OE(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 ${EE(100-r.usedPct)} of its ${r.windowLabel} window left.`}function AE(e,t){let n=TE(e,t);return!n||e===null?`until the window resets`:`until ${n}, in ${Lw((e-t)/6e4)}`}function jE(e,t,n){let r=[`${e.vendorLabel} sessions stop answering ${AE(e.resetsAtMs,n)}. Their worktrees and conversations stay intact.`,kE(t,e.vendor)];return{tone:`fail`,headline:`${e.vendorLabel} ${e.windowLabel} limit reached.`,detail:r.filter(Boolean).join(` `)}}function ME(e,t){let n=TE(e.resetsAtMs,t),r=n?`, resets ${n}`:``;if(e.usedPct>=vE)return{tone:`warn`,headline:`${e.vendorLabel} ${e.windowLabel} limit is at ${EE(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 ${EE(e.projectedPct??e.usedPct)}.`}}function NE(e){return{tone:`warn`,headline:`Over your ${iT(e.scope)===`today`?`daily`:`monthly`} budget.`,detail:`${aT(e)} spent ${iT(e.scope)}.`}}function PE(e,t,n,r){let i=e.find(e=>e.tone===`fail`);if(i)return jE(i,e,r);let a=e.filter(e=>e.tone===`warn`).sort((e,t)=>DE(t)-DE(e))[0];if(a)return ME(a,r);let o=t.find(e=>C(e.pct,0)>=100);if(o)return NE(o);if(e.length===0)return{tone:`ok`,headline:n===null?`Nothing spent yet today.`:`${nw(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)=>DE(t)-DE(e))[0],c=TE(s.resetsAtMs,r);return{tone:`ok`,headline:`Every limit has room.`,detail:`Closest is ${s.vendorLabel} ${s.windowLabel} at ${EE(s.usedPct)}${c?`, resets ${c}`:``}.`}}function FE(e){return e.tone===`fail`?`limit reached`:e.projectedPct===null?e.elapsedPct===null?``:`too early to project`:`about ${EE(e.projectedPct)} at reset`}var IE=`report`;function LE(e){return ZC.find(t=>t.value===e)?.label||``}function RE(e,t){return{key:Ow(e,t),dir:`desc`}}function zE(e,t){let n=uE(e?.models,RE(e?.totals,t))[0];if(!n)return null;let r=Ow(e?.totals,t);return{label:ZT(n),sharePct:Aw(n[r],e?.totals?.[r])}}function BE(e,t){let n=sE(e?.sessions,RE(e?.totals,t)),r=n[0];return{count:n.length,topLabel:r?XT(r):``}}function VE(e){let t=Ww(e).filter(e=>Gw(e.lane));return t.length===0?null:t.reduce((e,t)=>e+C(t.costUSD,0),0)}function HE(e){let t=e.filter(e=>C(e.pct,0)>=100).length,n=e.length-t;return t===0?{value:`${n} of ${e.length}`,detail:e.length===1?`under its ceiling`:`all under their ceilings`}:{value:`${n} of ${e.length}`,detail:t===1?`1 over its ceiling`:`${t} over their ceilings`}}function UE(e){return Nw(e).length}function WE(e,t){let n=cT(e);return!n||t<=0?[]:Array.from({length:t},(e,r)=>{let i=new Date(n);return i.setDate(n.getDate()-(t-1-r)),Me(i)})}function GE(e){return ZC.find(t=>t.value===e)?.days??7}function KE(e){return e.reduce((e,t)=>t.resetsAtMs===null?e:e===null?t.resetsAtMs:Math.min(e,t.resetsAtMs),null)}function qE(e,t){let n=cT(e);return n?(n.setDate(n.getDate()+t),Me(n)):``}function JE(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=String(e?.day??``);bw.test(n)&&r.set(n,(r.get(n)??0)+C(e?.[t],0))}return r}function YE(e,t){let n=cT(e);return n?t<=7?bE[n.getDay()]:String(n.getDate()):e}function XE(e,t,n,r){let i=JE(e,r===`cost`?`costUSD`:`tokens`),a=WE(n,t).map(e=>({day:e,label:YE(e,t),value:i.get(e)??0,isToday:e===n})),o=a.reduce((e,t)=>e+t.value,0),s=WE(qE(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 ZE(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 QE(e){return`${Dw(e.average,e.metric)} a day on average`}function $E(e){return IT(e)?FT(e).map(e=>`${e.label} ${nw(e.costUSD)}`).join(`, `):``}function eD(e){return IT(e)?FT(e).map(t=>({...t,sharePct:Aw(t.tokens,e?.tokens)})):[]}function tD(e){let t=e?.totals,n=[{label:`Processed tokens`,value:rw(C(t?.tokens,0))},{label:`Cached input`,value:rw(C(t?.cacheRead,0))},{label:`Uncached input`,value:rw(C(t?.input,0))},{label:`Output`,value:rw(C(t?.output,0))}],r=C(nT(e?.savings)?.savedUSD,0);return r>0&&n.push({label:`Cache savings`,value:nw(r)}),n}function nD(e){let t=(e?.yourDay?.insights??[]).map(e=>({text:e.text,tone:`ok`})),n=e?.anomaly;AT(n)&&t.push({text:kT(n),tone:`warn`});for(let n of[rT(e?.savings),eT(e)])n&&t.push({text:n,tone:`ok`});return t}function rD(e,t,n,r){let i=Ow(t,n),a=e.reduce((e,t)=>Math.max(e,C(t[i],0)),0);return e.map(e=>({row:e,label:r(e),tokens:C(e.tokens,0),costUSD:C(e.costUSD,0),sharePct:Aw(e[i],t?.[i]),barPct:Aw(e[i],a)??0}))}function iD(e,t){return rD(uE(e?.models,RE(e?.totals,t)),e?.totals,t,ZT)}function aD(e,t){return rD(sE(e?.sessions,RE(e?.totals,t)),e?.totals,t,XT)}function oD(e){return[{label:`Input`,tokens:C(e.input,0)},{label:`Output`,tokens:C(e.output,0)},{label:`Cache write`,tokens:C(e.cacheCreate,0)},{label:`Cache read`,tokens:C(e.cacheRead,0)}]}var sD=2e4,cD=`glimmervoid-usage-metric`,lD=null,uD=null,dD={claude:null,codex:null,kimi:null},fD=null,pD=null,mD=null,hD=QC,gD=Ew(xr(cD,null)),_D=!1,vD=null,yD=null,bD=!0,xD=()=>!1,SD=new Set,CD=_t({getAck:gi,setAck:Qr,signature:()=>uw(lD,dD.claude),isLooking:()=>xD()});function wD(e){for(let t of SD)t(e)}function TD(){fD?.(CD.refresh())}function ED(e){_D=e,wD(`refresh-status`),vD&&=(clearTimeout(vD),null),e&&(vD=setTimeout(()=>{vD=null,_D=!1,yD=`Usage did not answer within ${Math.round(sD/1e3)} s. Refresh to try again.`,wD(`refresh-status`)},sD))}function DD(e){let t=ZC.find(t=>t.value===e);return t?t.days:null}function OD(){return{report:lD,sessions:uD,planLimitsByVendor:dD,rangeValue:hD,metric:gD}}function kD(){let e=!bD||!_D&&yD!==null;return bD?_D?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:yD??``,isPending:!1,hasFailure:e}:{text:lD?`${S} The figures below are from before the connection dropped.`:S,isPending:_D,hasFailure:e}}function AD(e){SD.add(e)}function jD(e){xD=e,TD()}function MD(){CD.acknowledge(),TD()}function ND(e){fD=e,TD()}function PD(e){pD?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function FD(e){pD=e}function ID(e){hD=e}function LD(e){gD=e,br(cD,e)}function RD({force:e=!1}={}){if(!pD)return;mD=d(`usage`);let t={type:`request-usage-report`,requestId:mD};e&&(t.force=!0);let n=DD(hD);n!==null&&(t.days=n),yD=null,ED(!0),pD(t)||(yD=S,ED(!1))}function zD(e){bD=e,wD(`refresh-status`)}function BD(e){uD=e,wD(`sessions`)}function VD(e){let t=e;dD={...dD,[lw(t)]:t},wD(`plan-limits`),TD()}function HD(e){gw(e,mD)&&(yD=null,ED(!1),lD=e,wD(`report`),TD())}function UD(){let e=lD?.pricing||(uD?{source:uD.pricingSource}:null),t=fw(e?.fetchedAt),n=[dw(e,t!==null&&t>0?qC(t):``)],r=hw(lD);r&&n.push(r);let i=mw(lD?.scan);return i&&n.push(i),n}var WD=[],GD=[],KD=[],qD=new Map;function JD(){for(let e of[...WD])e()}function YD(e){for(let t of GD)t(e)}function XD(e){return e.type===`whiteboard-result`}async function ZD(e,t){try{let n=await c(e,t,{timeoutMs:ur});return XD(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:lr(e,ur)}}}function QD(){return KD}function $D(e){return WD.push(e),()=>{let t=WD.indexOf(e);t>=0&&WD.splice(t,1)}}function eO(e){GD.push(e)}function tO(){let e=new Map;for(let t of KD)for(let n of t.connectedSessionIds){let r=e.get(n);r?r.push(t):e.set(n,[t])}qD=e}function nO(e){KD=[...e.boards].sort((e,t)=>t.updatedAt-e.updatedAt),tO(),JD()}function rO(e){KD=KD.filter(t=>t.id!==e.boardId),tO(),YD(e.boardId),JD()}async function iO(e){let t=await ZD(`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 aO(e,t){let n=await ZD(`whiteboard-op`,{boardId:e,ops:t});return n.ok?{ok:!0,patch:n.reply.patch??null}:n}async function oO(e){let t={"x-glimmervoid-upload-name":encodeURIComponent(e.name)};e.type&&(t[`content-type`]=e.type);let n=await fetch(yt,{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=zt.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 sO(e){let t=await ZD(`whiteboard-delete`,{boardId:e});return t.ok?{ok:!0}:t}async function cO(e,t){let n=await ZD(`whiteboard-connect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function lO(e,t){let n=await ZD(`whiteboard-disconnect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function uO(e){let t=await ZD(`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 dO=null;function fO(e){dO=e}function pO(e,t){dO?.(e,t)}function mO(e){return qD.get(e)??[]}var hO=null;function gO(e,t){hO={boardId:e,sessionId:t}}function _O(){let e=hO;return hO=null,e}var vO=()=>{};function yO(e){vO=e}function bO(e,t){gO(e,t),vO()}function xO(e,t){let n=e.queuedBySessionId[t]??0;return n===0?``:`${n} queued`}function SO(e,t,n){let r=xO(e,t),i=r?`wait`:`muted`;return{key:`board:${e.id}`,text:n,detailText:e.title,stateText:r,look:{icon:`board`,tone:i},tier:sn(i),className:`session-pr-chip session-board-chip`,ariaLabel:`Open board ${e.title}`,onActivate:()=>bO(e.id,t)}}function CO(e,t){let n=xO(e,t);return SO(e,t,n?`${e.title}, ${n}`:e.title)}function wO(e){return mO(e).map(t=>SO(t,e,t.title))}function TO(e,t,n){let r=CO(e,t),i=Be(`session-pr-chip-unlink`);i.append(Te(st)),i.setAttribute(`aria-label`,`Disconnect board ${e.title}`),i.addEventListener(`click`,r=>{r.stopPropagation(),r.preventDefault(),Xt({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:()=>{lO(e.id,t).then(e=>n(e.ok?null:e.error))}})});let a=D(`span`,`session-pr-chip-item`);return a.append(gn(r,r),i),a}function EO(e){let{dialog:t,close:n,actions:r,btnCancel:i}=Qt({title:`Connect board`}),a=D(`div`,`session-pr-chips dialog-linked-prs`),o=D(`p`,`dialog-message`,`A connected session is told what others changed on the board with its next whiteboard get or prompt.`),s=D(`select`,`dialog-input`);s.setAttribute(`aria-label`,`Board to connect`);let c=ar(`action-status`),l=w({variant:`primary`,label:`Connect`});r.append(l),t.append(a,o,s,c.element,r);function u(e){e&&c.show(`error`,e)}function d(){let t=mO(e);In(a,t.map(t=>CO(t,e)),n=>{let r=t.find(e=>`board:${e.id}`===n.key);return r?TO(r,e,u):gn(n,n)});let n=QD().filter(t=>!t.connectedSessionIds.includes(e));s.replaceChildren(...n.map(e=>{let t=D(`option`,null,e.title);return t.value=e.id,t})),n.length===0&&s.append(D(`option`,null,`No other boards to connect`)),s.disabled=n.length===0,l.disabled=n.length===0}l.addEventListener(`click`,()=>{let t=s.value;t&&(l.disabled=!0,cO(t,e).then(e=>{e.ok?n():(c.show(`error`,e.error),d())}))}),i.addEventListener(`click`,n);let f=$D(()=>{t.isConnected?d():f()});d()}$D(jn);function DO(){return M.snapshot().borrowedCardId}var OO=null;function kO(e,t,n,{className:r,onRelease:i}={}){if(!e?.card||!n)return;let a=DO();a&&a!==t&&AO();let o=e.card;o._cardHostClass&&o._cardHostClass!==r&&o.classList.remove(o._cardHostClass),o._cardHostClass=r||``,r&&o.classList.add(r),Wt(o,n),OO=i??null,M.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function AO(){let e=DO(),t=OO;if(OO=null,t?.(),M.dispatch(`borrowCard`,null),!e)return null;let n=k.get(e);n?._showTerminalFace?.(),n?._setBorrowed?.(!1),n?._setActiveViewer?.(!1);let r=n?.card;return r&&(r._cardHostClass&&r.classList.remove(r._cardHostClass),delete r._cardHostClass,jt(r,Zn)),e}var jO=null,MO=null,NO={},PO=null,FO=null,IO=null,LO=new Map,RO=new Map;function zO(){return MO??=N(()=>import(`./phone-shell-QnJW6JzC.js`).then(e=>{e.mountPhoneShell(NO),IO&&e.orderPhonePanels(IO);for(let[t,n]of LO)e.setPhoneScreenAvailable(t,n);for(let[t,n]of RO)e.setPhoneScreenAttention(t,n);return jO=e,e},e=>(MO=null,y(`phone-shell`,`phone shell failed to load: ${l(e)}`),null)),__vite__mapDeps([25,3,4,13,19,26,14,15,22,27,12,5,6,7,18,28,29,30,21,31,32])),MO}function BO(e){NO=e}async function VO(e){let t={options:e};PO=t;let n=await zO();if(PO!==t)return!1;if(!n)return PO=null,FO=null,!1;PO=null,n.activatePhoneShell(t.options);let r=FO;return FO=null,r?.(n),!0}function HO(){PO=null,FO=null,jO?.deactivatePhoneShell()}function UO(){return PO!==null||(jO?.isPhoneShellActive()??!1)}function WO(){return PO?PO.options?.sessionId??null:jO?.getPhoneSessionId()??null}function GO(e){IO=e,jO?.orderPhonePanels(e)}function KO(e,t){LO.set(e,t),jO?.setPhoneScreenAvailable(e,t)}function qO(e,t){RO.set(e,t),jO?.setPhoneScreenAttention(e,t)}function JO(){jO?.refreshPhoneBoard()}function YO(){jO?.syncPhoneHistory()}function XO(e){return PO?(FO=t=>{e(t)},!0):jO?e(jO):!1}function ZO(e){return XO(t=>t.showPhonePlan(e))}function QO(e){return XO(t=>t.showPhoneSession(e))}function $O(e){return XO(t=>t.showPhoneScreen(e))}function ek(){let e=WO();e&&A(e)?._isActiveViewer?.()===!0&&zC(e)}function tk(){kf(A(DO())),ek()}function nk(){window.addEventListener(`focus`,tk),window.addEventListener(`blur`,tk),document.addEventListener(`visibilitychange`,tk),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&No()}),window.addEventListener(`pageshow`,e=>{e.persisted&&No()})}function rk(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function ik(e,t,n){return t>0?{minPx:e.minPx,maxPx:Math.max(e.minPx,Math.min(e.maxPx,t-n))}:e}function ak(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function ok({resizer:e,column:t,widthHost:n,widthProperty:r,bounds:i,keyStepPx:a,getStoredWidth:o,setStoredWidth:s,growsLeftward:c=!1,reservePx:l}){let u=c?-1:1;e.setAttribute(`aria-valuemin`,String(i.minPx)),e.setAttribute(`aria-valuemax`,String(i.maxPx));let d=()=>l===void 0?i:ik(i,n.getBoundingClientRect().width,l),f=null,p=t=>{let i=d();e.setAttribute(`aria-valuemax`,String(i.maxPx));let a=rk(t,i);return a===null?null:(f=a,n.style.setProperty(r,`${a}px`),e.setAttribute(`aria-valuenow`,String(a)),a)},m=()=>{let n=o();if(n!==null){p(n);return}let r=Math.round(t.getBoundingClientRect().width);r>0&&e.setAttribute(`aria-valuenow`,String(r))};if(m(),l!==void 0){let r=new ResizeObserver(()=>{e.dataset.dragging!==`true`&&m()});r.observe(n),r.observe(t)}let h=0,g=0;e.addEventListener(`pointerdown`,n=>{n.button===0&&(h=n.clientX,g=t.getBoundingClientRect().width,e.setPointerCapture(n.pointerId),e.dataset.dragging=`true`,n.preventDefault())}),e.addEventListener(`pointermove`,t=>{e.hasPointerCapture(t.pointerId)&&p(g+u*(t.clientX-h))});let _=t=>{e.releasePointerCapture(t.pointerId),delete e.dataset.dragging};e.addEventListener(`pointerup`,t=>{e.hasPointerCapture(t.pointerId)&&(_(t),s(p(g+u*(t.clientX-h))))}),e.addEventListener(`pointercancel`,t=>{e.hasPointerCapture(t.pointerId)&&(_(t),p(g))}),e.addEventListener(`dblclick`,()=>{n.style.removeProperty(r),f=null,e.setAttribute(`aria-valuenow`,String(Math.round(t.getBoundingClientRect().width))),s(null)}),e.addEventListener(`keydown`,e=>{let n=ak(e.key,a);if(n===null)return;e.preventDefault();let r=p((f??t.getBoundingClientRect().width)+u*n);r!==null&&s(r)})}var sk={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.`}},ck=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:Vt[e],meaning:t}),lk=Object.freeze([ck(E.DORMANT,`Not started yet.`),ck(E.STARTING,`Setting up the worktree and booting the agent.`),ck(E.RUNNING,`The agent is mid-turn.`),ck(E.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),ck(E.WAITING,`Waiting on a permission prompt or your answer.`),ck(E.COMPLETE,`Finished a turn you have not looked at yet.`),ck(E.IDLE,`Ready for the next prompt.`),ck(E.DONE,`The agent process ended.`),ck(E.FAILED,`The agent failed to start or crashed. A red line above the terminal says why it could not start; its terminal output shows a crash.`)]);function uk(e,t){let n=D(`section`,`status-legend`),r=D(`dl`,`status-legend-rows`);return r.append(...t),n.append(D(`h2`,`status-legend-title`,e),r),n}function dk(e,t){let n=D(`div`,`status-legend-row`);return n.append(e,D(`dd`,`status-legend-meaning`,t)),n}function fk(){return uk(`Status colors`,lk.map(e=>{let t=D(`dt`,`status-legend-badge`),n=D(`span`,`status-legend-glyph`),r=D(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=dk(t,e.meaning);return On(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function pk(){return uk(`Pull request icons`,Object.keys(sk).map(e=>{let t=sk[e],n=D(`dt`,`status-legend-badge`);return n.append(Ji(e),D(`span`,`status-legend-name`,t.label)),dk(n,t.meaning)}))}var mk=null,hk=null,gk=!1,_k=null;function vk(){return hk??=N(()=>import(`./first-run-checklist-Dh6Cvg_U.js`).then(e=>(mk=e,e),e=>(hk=null,y(`first-run`,`first-run checklist failed to load: ${l(e)}`),null)),__vite__mapDeps([33,12,13,4,3,14,5,6,7,34,26,15,19,22,27,18,35])),hk}function yk(e,t){_k={host:e,isShown:t},mk?mk.showFirstRunChecklist(e,t):t&&gk&&vk().then(e=>{e&&_k&&e.showFirstRunChecklist(_k.host,_k.isShown)})}function bk(){mk?.refreshFirstRunChecklist()}function xk(){gk=!0,_k&&yk(_k.host,_k.isShown)}var Sk=`removed`,Ck=new Set([E.COMPLETE,E.DONE,E.FAILED,Sk]);function wk(e){return Ck.has(e)}function Tk(e,t){let n=e.filter(e=>wk(t(e))).length;return{settled:n,total:e.length,isAllSettled:e.length>0&&n===e.length}}function Ek(e,t){let n=(e.panel?.verdicts??[]).map(e=>e.contestants[t]?.notes.trim()??``).filter(e=>e!==``);return n.length>0?n.join(`
|
|
75
75
|
|
|
76
76
|
`):e.judge?.notes[t]??null}function Dk(e){return e.series?.id??e.id}function Ok(e){let t=e[0]?.spec.contestants.map(e=>e.id)??[],n=e.filter(e=>e.panel!==null);return t.map(e=>{let t=n.flatMap(t=>t.panel?.standing.filter(t=>t.contestantId===e)??[]),r=t.map(e=>e.criteriaPassed);return{contestantId:e,wins:t.filter(e=>e.rank===1).length,roundsJudged:n.length,lowestScore:r.length>0?Math.min(...r):null,highestScore:r.length>0?Math.max(...r):null}})}var kk=[],Ak=null,jk=new Set;function Mk(e){jk.add(e)}function Nk(){return kk}function Pk(e){kk=e.races;for(let e of jk)e()}function Fk(){return Ak}function Ik(e){Ak=e.history;for(let e of jk)e()}function Lk(e){let t=Rk(e.id);if(!t)return null;let n=Tk(Object.values(t.sessionIdByContestant),e=>k.get(e)?.currentState??`removed`);return{key:`race:${t.id}`,label:`${t.spec.title} ${n.settled}/${n.total}`,title:`Race: ${t.spec.title}, ${n.settled} of ${n.total} settled`}}function Rk(e){return kk.find(t=>Object.values(t.sessionIdByContestant).includes(e))??null}var zk=()=>{};function Bk(e){zk=e.openTerminal}function Vk(e){zk(e)}function Hk({onAdd:e}){let t=D(`div`,`session-group-header`),n=D(`span`,`session-group-label`),r=D(`span`,`session-group-count`),i=D(`span`,`session-group-rule`);i.setAttribute(`aria-hidden`,`true`);let a=w({variant:`icon`,size:`small`,label:`Add session to this project`,icon:Te(Ve),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 Uk(e,t,{isHostShown:n=!1}={}){let{header:r,label:i,count:a,addButton:o}=e;ki(r,`path`,t.projectPath??``),ki(r,`label`,t.label),Si(i,n&&t.hostName?`${t.hostName} / ${t.label}`:t.label),Si(a,String(t.rows.length)),Ri(a,t.rows.length===0),Ri(o,t.projectPath===null)}var Wk={waitingCount:0,finishedCount:0,failedCount:0},Gk={failed:Et[E.FAILED],waiting:Et[E.WAITING],finished:Et[E.COMPLETE]},Kk={failed:`failed`,waiting:`needs you`,finished:`finished`},qk=[`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`],Jk=2500,Yk=`cubic-bezier(0.16, 1, 0.3, 1)`,Xk=`cubic-bezier(0.5, 0, 0.2, 1)`,Zk=260,Qk=200,$k=200,eA=300,tA=28,nA=360,rA=420,iA=200,aA=3,oA=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),sA=new WeakMap;function cA(e){let t=sA.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function lA(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function uA(){return oA?.matches??!1}function dA(e){return e.map(e=>({easing:Yk,...e}))}function fA(e,t){let n=D(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${Qn.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${Qn.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${Qn.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${Qn.overflowSlot}px`);let r=D(`span`,`attention-banner-chips`),i=D(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=D(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=D(`span`,`attention-banner-status`);o.append(r,D(`span`,`attention-banner-count`),a);let s=Be(`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),sA.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(()=>mA(n)).observe(r),pA(n,Wk,[]),n}function pA(e,t,n){let r=cA(e);r.tiles=n,Si(Lt(e,`.attention-banner-count`),$n(t));let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&AA(e,r),mA(e)}function mA(e){let t=cA(e),n=Lt(e,`.attention-banner-chips`),r=Lt(n,`.attention-tile-overflow`),i=lA(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():vA(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??gA(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),_A(s,i,a===0),(s.parentElement!==n||hA(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;Ri(r,p===0),Si(r,`+${p}`),wi(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)&&SA(e,null),i){for(let e of d)yA(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?xA(r,a):a!==0&&bA(r,a,n)})}}function hA(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function gA(e,t){let n=D(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=D(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>SA(e,t)),n.addEventListener(`pointerleave`,()=>SA(e,null)),n}function _A(e,{id:t,kind:n,name:r},i){e.dataset.kind=n,e.toggleAttribute(`data-head`,i);let a=n===`waiting`?En(t):null;e.toggleAttribute(`data-passed-on`,a!==null);let o=a===null?`${r}, ${Kk[n]}`:`${r}, ${Kk[n]}, passed on: ${a}`;wi(e,`aria-label`,o),dr(Lt(e,`.attention-tile-icon`),Gk[n])}function vA(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=uA()?[{opacity:1},{opacity:0}]:dA([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:$k,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function yA(e){let t=uA()?[{opacity:0},{opacity:1}]:dA([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:Qk})}function bA(e,t,n){uA()||e.animate(dA([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:eA,delay:n*tA,fill:`backwards`})}function xA(e,t){uA()?e.animate([{opacity:.35},{opacity:1}],{duration:nA,easing:Yk}):e.animate(dA([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:nA})}function SA(e,t){let n=cA(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 CA(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function wA(e,t,n){let r=cA(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!lA(e)){n();return}SA(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=CA(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(TA(o,s),EA(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function TA(e,t){return!t||uA()?[{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 EA(e){return!e||uA()?{duration:iA,fill:`forwards`}:{duration:rA,easing:Xk,fill:`forwards`}}function DA(e){let t=cA(e);e.hasAttribute(`data-empty`)&&kA(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!lA(e))return;let n={duration:Zk};if(t.pressAnimations.push(e.animate(dA([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!uA()){t.pressAnimations.push(e.animate(dA([{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(dA([{transform:`none`},{transform:`translateY(${aA}px)`,offset:.3},{transform:`none`}]),n),r.animate(dA([{transform:`none`},{transform:`translateY(-${aA}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function OA(e){let t=qk.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??qk[0]}function kA(e,t){let n=OA(t.lastAllClearLine);t.lastAllClearLine=n,Lt(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>AA(e,t),Jk)}function AA(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var jA=new WeakMap;function MA(e){let t=jA.get(e);if(!t)throw Error(`attention ledger was not built by buildAttentionLedger`);return t}function NA(e){return e.flatMap(e=>Ln(e.id).map(t=>({sessionId:e.id,seq:t.seq,ts:t.ts,text:`${e.name??``}: ${Gn(t)}`}))).sort((e,t)=>t.ts-e.ts).map(({sessionId:e,seq:t,text:n})=>({sessionId:e,seq:t,text:n}))}function PA(e){let t=D(`div`,`attention-ledger`);t.hidden=!0;let n=w({variant:`quiet`,size:`small`,label:`Answers`,onClick:()=>IA(t)});n.classList.add(`attention-ledger-answers`),n.setAttribute(`aria-expanded`,`false`);let r=D(`ol`,`attention-ledger-list`);return r.hidden=!0,t.append(D(`span`,`attention-ledger-count`),n,r),jA.set(t,{onOpenSession:e,rows:[],openEntries:null}),t}function FA(e,t){let n=MA(e);n.rows=t;let r=(n.openEntries??NA(t)).length;Si(Lt(e,`.attention-ledger-count`),Jn(r)),Ri(e,r===0)}function IA(e){let t=MA(e);if(t.openEntries){LA(e);return}let n=NA(t.rows);t.openEntries=n,Lt(e,`.attention-ledger-answers`).setAttribute(`aria-expanded`,`true`);let r=Lt(e,`.attention-ledger-list`);r.replaceChildren(...n.map(n=>{let r=Be(`attention-ledger-item`,n.text);return r.addEventListener(`click`,()=>{LA(e),t.onOpenSession(n.sessionId)}),RA(r)})),r.hidden=!1;let i=new Map;for(let{sessionId:e,seq:t}of n)i.set(e,Math.max(t,i.get(e)??0));for(let[e,t]of i)yn(e,t)}function LA(e){let t=MA(e);t.openEntries=null,Lt(e,`.attention-ledger-answers`).setAttribute(`aria-expanded`,`false`);let n=Lt(e,`.attention-ledger-list`);n.hidden=!0,n.replaceChildren(),FA(e,t.rows)}function RA(e){let t=D(`li`);return t.append(e),t}var zA=[`terminal`,`board`],BA=.05,VA=`application/x-glimmervoid-board-pane`,HA=`input, textarea, select, button, [contenteditable="true"]`;function UA(){let e=Jr(),t=new Set([`terminal`]),n=!1,r=[],i=D(`div`,`pane-layout`),a=D(`div`,`pane-trail`),o=D(`div`,`pane-divider`);o.setAttribute(`role`,`separator`),o.setAttribute(`aria-label`,`Resize panes`),o.tabIndex=0;let s={terminal:u(`terminal`),board:u(`board`)},c=D(`div`,`pane-title`),l=new Map;s.board.header.append(c),s.terminal.header.append(a),f(s.board.header),p(s.terminal.section);function u(e){let t=D(`section`,`pane-group`);t.dataset.pane=e;let n=D(`div`,`pane-strip pane-header`),r=D(`div`,`pane-body`);return r.id=`focus-pane-${e}`,t.append(n,r),{section:t,header:n,body:r}}function d(e){if(n!==e){n=e,i.toggleAttribute(`data-dragging`,e),e||delete s.terminal.section.dataset.dropZone;for(let t of r)t(e)}}function f(e){e.draggable=!0,e.addEventListener(`dragstart`,e=>{e.target instanceof Element&&e.target.closest(HA)?e.preventDefault():(e.dataTransfer?.setData(VA,`board`),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`),d(!0))}),e.addEventListener(`dragend`,()=>d(!1))}function p(t){let r=e=>{let n=t.getBoundingClientRect();return _i(e.clientX-n.left,e.clientY-n.top,n)};t.addEventListener(`dragover`,e=>{n&&(e.preventDefault(),t.dataset.dropZone=r(e))}),t.addEventListener(`dragleave`,e=>{e.relatedTarget instanceof Node&&t.contains(e.relatedTarget)||delete t.dataset.dropZone}),t.addEventListener(`drop`,t=>{if(!n)return;t.preventDefault();let i=r(t);d(!1),m(Br(e,i))})}function m(t){t!==e&&(e=t,kr(e),_())}function h(e,t){e.children.length===t.length&&t.every((t,n)=>e.children[n]===t)||e.replaceChildren(...t)}function g(e){let{section:t,header:n}=s[e],r=l.get(e);r?(n.parentElement!==r.parent||r.before!==null&&n.nextElementSibling!==r.before)&&r.parent.insertBefore(n,r.before):t.firstElementChild!==n&&t.prepend(n)}function _(){let n=[e.first,e.second].filter(e=>t.has(e)),r=n.length===2;i.dataset.direction=r?e.direction:`single`;for(let e of zA)g(e);let[a,c]=n,l=n.map(e=>s[e].section);h(i,r?l.toSpliced(1,0,o):l);let u=r?e.firstShare:1;a&&(s[a].section.style.flex=`${u} 1 0`),c&&(s[c].section.style.flex=`${1-u} 1 0`),o.setAttribute(`aria-orientation`,e.direction===`row`?`vertical`:`horizontal`),o.setAttribute(`aria-valuenow`,String(Math.round(u*100)))}function v(t){let n=i.getBoundingClientRect();return e.direction===`row`?(t.clientX-n.left)/n.width:(t.clientY-n.top)/n.height}o.addEventListener(`pointerdown`,e=>{e.button===0&&(o.setPointerCapture(e.pointerId),o.dataset.dragging=`true`,e.preventDefault())}),o.addEventListener(`pointermove`,t=>{o.hasPointerCapture(t.pointerId)&&(e=Dr(e,v(t)),_())});let y=t=>{o.hasPointerCapture(t.pointerId)&&(o.releasePointerCapture(t.pointerId),delete o.dataset.dragging,kr(e))};return o.addEventListener(`pointerup`,y),o.addEventListener(`pointercancel`,y),o.addEventListener(`keydown`,t=>{let n={ArrowLeft:-.05,ArrowUp:-.05,ArrowRight:BA,ArrowDown:BA}[t.key];n!==void 0&&(t.preventDefault(),m(Dr(e,e.firstShare+n)))}),_(),{element:i,trailSlot:a,bodyOf:e=>s[e].body,boardTitleSlot:c,setHeaderHost:(e,t)=>{t&&l.set(e,t),t||l.delete(e),_()},showPanes:e=>{t=e,_()},onBoardDrag:e=>{r.push(e)}}}var WA=[],GA=new Set,KA=new WeakSet,qA=null,JA=null;function YA(e){WA.some(t=>t.id===e.id)||(WA.push(e),ZA(e.id,null))}function XA(){return WA}function ZA(e,t){for(let n of GA)n(e,t)}function QA(e){return GA.add(e),()=>GA.delete(e)}function $A(e){e!==qA&&(rj(),qA=e)}function ej(e){qA===e&&(rj(),qA=null)}function tj(e,t){return JA?.page.id===e&&JA.sessionId===t}function nj(e,t,n=null){let r=WA.find(t=>t.id===e);if(!r||!qA||qA.sessionId()!==t||!r.isAvailableFor(t)||tj(e,t)&&n===null)return;rj();let i=qA,a=i.elementFor(r);oj(a),JA={page:r,sessionId:t},r.mount(a,t,{placement:i.placement,target:n}),i.didShow(r),ZA(r.id,t)}function rj(){if(!JA)return;let{page:e,sessionId:t}=JA;JA=null,e.unmount(),qA?.didHide(e),ZA(e.id,t)}function ij(){return JA?.page.canStepBack()??!1}function aj(){return JA?JA.page.canStepBack()?(JA.page.stepBack(),!0):(rj(),!0):!1}function oj(e){KA.has(e)||(KA.add(e),e.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||It(e)||aj()&&e.preventDefault()}))}function sj({style:e}){let t=D(`div`,`session-page-bar session-page-bar-${e}`),n=new Map,r=null;function i(n){let i=e===`header`,a=Te(n.iconPath),o=`${i?`open`:`show`}-${n.id}`,s=w({variant:`icon`,size:i?`small`:void 0,label:n.label,icon:a,action:o});s.addEventListener(`click`,()=>{r&&nj(n.id,r)});let c=D(`span`,`session-page-dot`);c.setAttribute(`aria-hidden`,`true`);let l=D(`span`,`session-page-button`);return l.dataset.page=n.id,l.append(s,c),t.append(l),n.attachButton?.(l,e),{wrap:l,control:s,dot:c}}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 WA)a(e)}return QA((e,t)=>{if(t!==null&&t!==r)return;let n=WA.find(t=>t.id===e);n&&a(n)}),o(),{element:t,showSession(e){r=e,o()}}}var cj=5,lj={high:`High`,medium:`Medium`,low:`Low`};function uj(e,t){let n=Be(`review-look-line`,e.path);return n.append(D(`span`,`review-look-detail`,e.detail)),n.addEventListener(`click`,()=>t(e.openPath)),n}function dj(e,t){let n=D(`div`,`review-look-group`);n.dataset.kind=e.kind;let r=D(`p`,`review-look-text`,e.heading);if(e.conflictRisk){let t=D(`span`,`review-look-risk`,`Conflict risk: ${lj[e.conflictRisk]}`);t.dataset.risk=e.conflictRisk,r.append(` `,t)}n.append(r);for(let r of e.lines)n.append(uj(r,t));return n}function fj(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=D(`section`,`review-look`);if(i.append(D(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=D(`p`,`review-look-error`,`Could not check this change for anything worth a look.`);t.append(` `,e.errors.join(` `)),i.append(t)}let a=t?e.worthALook:e.worthALook.slice(0,cj);if(a.length>0){let e=D(`div`,`review-look-list`);for(let t of a)e.append(dj(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=D(`div`,`review-look-more`),c=w({variant:`quiet`,size:`small`,label:`Show all`,action:`show-all-worth-a-look`,onClick:n});return s.append(D(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function pj(e){return(e??[]).map(e=>D(`span`,`review-file-hint`,e.text))}var mj=`changes`,hj={add:`+`,del:`-`,meta:`\\`},R=null,gj=null,_j=null,vj=null,yj=null,bj=!1;function xj(){let e=D(`section`,`review-reader`);e.setAttribute(`aria-label`,`Changes`),e.tabIndex=-1,e.hidden=!0;let t=D(`div`,`review-reader-bar`),n=D(`p`,`review-reader-status`);n.setAttribute(`role`,`status`);let r=D(`p`,`review-reader-notice`);r.setAttribute(`role`,`status`);let i=D(`div`,`review-reader-actions`),a=w({variant:`primary`,label:`Merge`,action:`merge-session`,onClick:()=>{_j&&Jy(_j)}}),o=w({variant:`danger`,label:`Discard`,action:`discard-session`,onClick:()=>{_j&&Yy(_j)}}),s=w({variant:`secondary`,label:`Close`,action:`close-reader`,onClick:rj});i.append(a,o,s),t.append(n,r,i);let c=D(`div`,`review-reader-body`),l=D(`div`,`review-reader-files`),u=D(`div`,`review-reader-diff`);return c.append(l,u),e.append(t,c),e.addEventListener(`keydown`,Cj),Dy(e=>{e===_j&&Dj()}),Di(()=>{vj=null,bj=!1,Dj(),wj()}),Qy(e),{root:e,status:n,notice:r,mergeButton:a,discardButton:o,closeButton:s,fileColumn:l,diff:u}}function Sj(){return R??=xj(),R}function Cj(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||It(e))return;let t=e.key===`j`?1:e.key===`k`?-1:0;if(t===0||!_j)return;e.preventDefault();let n=sy(My(_j)?.files??[],vj,t);n&&Tj(n)}function wj(){_j&&ZA(mj,_j)}function Tj(e){vj=e,Dj(),R?.fileColumn.querySelector(`.review-reader-file[aria-current="true"]`)?.scrollIntoView({block:`nearest`}),wj()}function Ej(e){let t=oy(e,yj);t&&(vj=t.path,yj=null),oy(e,vj)||(vj=gj===`overlay`?e[0]?.path??null:null)}function Dj(){if(!R||gj===null)return;_j=Li();let e=_j?My(_j):null;if(R.closeButton.hidden=gj!==`overlay`,!e){Oj(R);return}let t=vj!==null;Ej(e.files),R.status.textContent=e.sentence;let n=e.notice??(e.isMergeShown&&!e.isMergeEnabled?e.mergeRefusal:null);R.notice.textContent=n??``,R.notice.hidden=n===null,R.mergeButton.hidden=!e.isMergeShown,R.mergeButton.disabled=!e.isMergeEnabled,R.discardButton.hidden=!e.isDiscardShown,R.root.dataset.level=gj===`screen`&&vj!==null?`diff`:`list`,kj(R.fileColumn,e),Nj(R.diff,oy(e.files,vj)),t!==(vj!==null)&&wj()}function Oj(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 kj(e,t){let n=e.scrollTop;if(e.replaceChildren(),t.diffError){e.append(D(`p`,`review-diff-error`,t.diffError));return}if(t.isEmpty){e.append(D(`p`,`review-empty-title`,t.sentence));return}t.totals.files>0&&e.append(Aj(t.totals));let r=D(`div`,`review-reader-file-list`);r.setAttribute(`role`,`list`);let i=t.changeMapView&&t.changeMapView.repos.length>1?t.changeMapView.repos:[],a=null;for(let e of t.files){let n=i.length>0?qv(i,e.path):null;n&&n!==a&&r.append(D(`div`,`review-repo-label`,n)),a=n,r.append(jj(e,t))}e.append(r);let o=t.changeMapView?fj(t.changeMapView,{isShowingAll:bj,onShowAll:Pj,onOpenFile:Fj}):null;o&&e.append(o),e.scrollTop=n}function Aj(e){let t=D(`p`,`review-reader-totals`);return t.append(D(`span`,`review-stat-files`,`${e.files} file${e.files===1?``:`s`}`),D(`span`,`review-add`,`+${e.added}`),D(`span`,`review-del`,`-${e.removed}`)),t}function jj(e,t){let n=Be(`review-reader-file`);n.dataset.path=e.path,n.setAttribute(`role`,`listitem`),n.setAttribute(`aria-current`,String(e.path===vj));let r=D(`span`,`review-file-name`);r.append(D(`span`,`review-file-path`,e.path));let i=pj(t.changeMapView?.hintsByOpenPath.get(e.path));if(i.length>0){let e=D(`span`,`review-file-hints`);e.append(...i),r.append(e)}return n.append(r,Mj(e)),n.addEventListener(`click`,()=>Tj(e.path)),n}function Mj(e){let t=D(`span`,`review-file-counts`);return e.binary?(t.append(D(`span`,`review-bin`,`bin`)),t):(t.append(D(`span`,`review-add`,`+${e.added}`),D(`span`,`review-del`,`-${e.removed}`)),t)}function Nj(e,t){let n=e.dataset.path===t?.path?e.scrollTop:0;if(e.replaceChildren(),!t){delete e.dataset.path;return}e.dataset.path=t.path;let r=D(`div`,`review-reader-diff-head`);if(r.append(D(`span`,`review-file-path`,t.path),Mj(t)),e.append(r),t.binary){e.append(D(`div`,`review-file-binary`,`Binary file not shown`));return}let i=D(`div`,`review-file-body`);for(let e of t.hunks){i.append(D(`div`,`review-hunk-head`,e.header));for(let t of e.lines){let e=D(`div`,`review-line review-line-${t.type}`);e.append(D(`span`,`review-line-gutter`,hj[t.type]??` `),D(`span`,`review-line-text`,t.text)),i.append(e)}}e.append(i),e.scrollTop=n}function Pj(){bj=!0,Dj()}function Fj(e){let t=oy(_j?My(_j)?.files??[]:[],e);t&&Tj(t.path)}function Ij(e,t){let{root:n}=Sj();n.parentElement!==e&&e.append(n),gj=t,n.dataset.placement=t,n.hidden=!1}function Lj(){R&&(R.root.hidden=!0,R.root.remove(),gj=null)}function Rj(){vj!==null&&(vj=null,Dj(),wj())}function zj(e,t){t===`header`&&(Qy(e),new MutationObserver(Zy).observe(e,{attributes:!0,attributeFilter:[`data-slot-held`]}))}Dy(e=>ZA(mj,e));var Bj={id:mj,label:`Changes`,iconPath:Ze,isAvailableFor:e=>My(e)!==null,hasUnreadFor:()=>!1,mount(e,t,{placement:n,target:r}){Ij(e,n),yj=r,Dj(),n===`overlay`&&Sj().root.focus({preventScroll:!0})},unmount:Lj,canStepBack:()=>gj===`screen`&&vj!==null,stepBack:Rj,attachButton:zj};function Vj(){YA(Bj)}var Hj=`This machine`,Uj=null,Wj=new Map;function Gj(){let e=D(`div`,`rail-host-header`),t=D(`span`,`rail-host-label`),n=D(`span`,`rail-host-state`);return e.append(t,n),{header:e,label:t,stateText:n}}function Kj(e,t,n,r){Si(e.label,t),ki(e.header,`state`,n),Si(e.stateText,r),Ri(e.stateText,r===``)}function qj(e,t,n){t.parentElement===e&&(n?t.nextElementSibling===n:e.lastElementChild===t)||e.insertBefore(t,n)}function Jj(e){for(let[t,n]of[...Wj])e.has(t)||(n.header.remove(),Wj.delete(t))}function Yj(e,{firstGroupHeaderOf:t,trailingNode:n}){let r=Hs();if(Jj(new Set(r.map(e=>e.id))),r.length===0){Uj?.header.remove();return}let i=n;for(let n of r.toReversed()){let r=Wj.get(n.id)??Gj();Wj.set(n.id,r),Kj(r,n.name,n.state,Us(n)),qj(e,r.header,t(n.id)??i),i=r.header}Uj??=Gj(),Kj(Uj,Hj,`local`,``),qj(e,Uj.header,t(null)??i)}var Xj=new Set([`terminal`]),Zj=new Set([`terminal`,`board`]),Qj=new Set([`board`]),$j=e=>e.ui.path,eM=e=>Xs(e.id),tM=`application/x-glimmervoid-board-row`,nM=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),rM=null,iM=null,aM=null,oM=null,sM=null,z=null,cM=null,lM=null,uM=null,dM=null,fM=null,B=null,pM=vi(),mM=null,hM=`terminal`,gM=null,_M=new Map,vM=new Map,yM=null,bM=null,xM=null,V=!1,SM=!1,CM=null,wM=new Map,H=new Map,TM=new Map,EM=new Map,U=null,DM=``,OM=[],kM=new Set;function AM(){return Rr(MM(iN()),kM)}function jM(e){let t=U;if(U=e||null,t&&t!==U){let e=H.get(t);e&&(e.tabIndex=-1,e.setAttribute(`aria-selected`,`false`))}if(U){let e=H.get(U);e&&(e.tabIndex=0,e.setAttribute(`aria-selected`,`true`))}}function MM(e){return $r(e,$j,Lk,eM)}function NM(e,t){let n=e.find(e=>e.hostId===t);return n?EM.get(n.key)?.header??null:null}function PM(e){let t=EM.get(e.key),n=TM.get(e.key);return t&&n||(t=Hk({onAdd:Pi}),n=D(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),EM.set(e.key,t),TM.set(e.key,n)),Uk(t,e),wi(n,`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function FM(){return V}function W(){return M.snapshot().focusedSessionId}function IM(){return V&&B!==null}function LM({rail:e,center:t,resizer:n}){if(rM=e,oM=t,!rM||!oM)return;let r=rM,i=oM;tN(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,xi(Au)),iM=fA({onJump:jN,rowFor:e=>H.get(e)},Iu());let a=D(`details`,`rail-section rail-status-key`);a.append(D(`summary`,`rail-section-summary`,`Status key`),fk()),yN(a,Nr(),Zr),aM=PA(qN),r.append(iM,aM,a),yM=D(`div`,`focus-empty`),yM.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,bM=yM.querySelector(`.focus-empty-title`),xM=yM.querySelector(`.focus-empty-desc`),z=UA(),sM=z.bodyOf(`terminal`),z.bodyOf(`board`).tabIndex=-1,z.onBoardDrag(GM);let o=w({variant:`secondary`,size:`small`,label:`New board`,action:`new-board`,onClick:DN});o.classList.add(`rail-new-board`),r.append(o),gM=D(`div`,`rail-unsplit-slot`,`Drop here to unsplit`),Vj(),cM=sj({style:`header`}),z.trailSlot.append(cM.element),i.append(yM,z.element),i.addEventListener(`focusin`,UM),Mk(()=>{V&&G()}),$D(()=>{if(!V)return;let e=B!==null;G(),e&&B===null&&iP()}),r.addEventListener(`keydown`,nN),r.addEventListener(`dragover`,qM),r.addEventListener(`drop`,JM)}function RM(){let e=QD(),t=yi(pM,e);BM(mM?qr(t,e,mM,zM):t),mM=ti(e)}$D(RM);function zM(e){return k.has(e)}function BM(e){e!==pM&&(pM=e,Yr(e))}function VM(){return Wr(pM,QD(),zM)}function HM(e){return e?VM()[e]??null:null}function UM(e){let t=e.target instanceof Element?e.target.closest(`.pane-group`)?.dataset.pane:void 0;if(t!==`terminal`&&t!==`board`||t===hM)return;hM=t;let n=W(),r=n?H.get(n):void 0;n&&r&&hN(r,n,mN())}function WM(){return z?.element.hasAttribute(`data-dragging`)===!0}function GM(){if(!gM)return;let e=W(),t=e&&HM(e)?H.get(e)?._row:void 0;!WM()||!t?(gM.removeAttribute(`data-over`),gM.remove()):t.nextElementSibling!==gM&&t.after(gM)}function KM(){return WM()&&gM?.isConnected===!0}function qM(e){KM()&&(e.preventDefault(),gM?.toggleAttribute(`data-over`,!0))}function JM(e){let t=W();KM()&&t&&(e.preventDefault(),hM=`terminal`,BM(si(pM,t)),G(),NN(k.get(t),t))}function YM(e){if(!V||!e||B)return null;let t=VM();if(Object.hasOwn(t,e))return{sessionId:e,boardIdToOpen:null};let n=hi(t,mO(e));return n?{sessionId:e,boardIdToOpen:n.id}:null}Ou(()=>YM(W())!==null);function XM(){let e=YM(W());return e?e.boardIdToOpen?(BM(bi(pM,e.sessionId,e.boardIdToOpen)),G(),!0):(hM=`terminal`,BM(si(pM,e.sessionId)),G(),NN(k.get(e.sessionId),e.sessionId),!0):!1}function ZM(e,t){let n=QD().find(e=>e.id===t);n&&k.has(e)&&(n.connectedSessionIds.includes(e)||cO(t,e).then(QM),BM(bi(pM,e,t)),W()===e?G():qN(e))}function QM(e){e.ok||y(`focus`,`connecting a dropped board failed: ${e.error}`)}var $M={minPx:280,maxPx:480},eN=16;function tN(e){e&&rM&&ok({resizer:e,column:rM,widthHost:rM,widthProperty:`--rail-width`,bounds:$M,keyStepPx:eN,getStoredWidth:ei,setStoredWidth:pi})}function nN(e){if(e.key===`Delete`||e.key===`Backspace`){let t=e.target instanceof HTMLElement?e.target:null,n=t?.dataset.id;if(!n||H.get(n)!==t)return;e.preventDefault(),Ii(n);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=rN(),n=t.find(t=>t===e.target)??(U?H.get(U):null),r=n?t.indexOf(n):-1,i=Un(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&&jM(a.dataset.id),a.focus())}function rN(){return rM?[...rM.querySelectorAll(`button.session-row[data-id], button.session-row[data-board-id]`)].filter(e=>!e.closest(`details:not([open])`)):[]}function iN(){return qn(Vi(aN))}function aN(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function oN(e){let{row:t,refs:n}=Dn();t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,t=>uN(e,sN(t.target))),t.addEventListener(`pointerenter`,()=>{iM&&SA(iM,e)}),t.addEventListener(`pointerleave`,()=>{iM&&SA(iM,null)});let{item:r,removeButton:i}=Tn(t,()=>Ii(e),()=>Ci(e));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,lN(r,e),Object.assign(t,{_refs:n,_row:r})}function sN(e){return(e instanceof Element?e.closest(`[data-member]`)?.dataset.member:void 0)===`board`?`board`:`terminal`}function cN(e){return e.dataTransfer?.types.includes(tM)===!0}function lN(e,t){e.addEventListener(`dragover`,t=>{cN(t)&&(t.preventDefault(),e.toggleAttribute(`data-board-drop`,!0))}),e.addEventListener(`dragleave`,t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||e.removeAttribute(`data-board-drop`)}),e.addEventListener(`drop`,n=>{e.removeAttribute(`data-board-drop`);let r=n.dataTransfer?.getData(tM);r&&(n.preventDefault(),ZM(t,r))})}function uN(e,t=`terminal`){let n=Bi(e);if(!n)return;hM=t===`board`&&HM(e)?`board`:`terminal`,qN(e);let r=H.get(e);r&&hN(r,e,mN()),hM===`board`?dN(e):NN(n,e)}function dN(e){requestAnimationFrame(()=>requestAnimationFrame(()=>{V&&W()===e&&z?.bodyOf(`board`).focus({preventScroll:!0})}))}function fN(e){let t=Bi(e);t&&pN(t,e)}function pN(e,t){qN(t),NN(e,t)}function mN(){return new Map(QD().map(e=>[e.id,e.title]))}function hN(e,t,n){let r=HM(t),i=r?n.get(r)??null:null,a=r&&i!==null?{id:r,title:i}:null;hn(e,a,t===W()&&a!==null?hM:null)}function gN(e,{id:t,ui:n,state:r,name:i},a){let o=wM.get(t)||`none`;e.classList.toggle(`focused`,t===W()),Sn(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a});let s=t===U;wi(e,`aria-selected`,String(s)),wi(e,`tabindex`,s?`0`:`-1`)}function _N(e,t){if(!V)return;let n=e?.card?.dataset.id,r=n?H.get(n):null;r&&(t===`flag`?r.dataset.activity=e._activity||``:vr(r._refs?.glyph))}fr(_N),yr((e,t)=>{if(!V)return;let n=H.get(e);n&&Si(n._refs.elapsed,_r(t))});var vN=new Map;function G(e){if(!V)return;let t=rM;if(!t)return;let n=iN(),r=MM(n),i=QD();B&&!i.some(e=>e.id===B)&&(B=null);let a=ui(i,VM()),o=wr(r,a.keys()),s=new Map(i.map(e=>[e.id,e.title])),c=new Set,l=new Set,u=nr(n,W()),d=new Map(u.map(({id:e},t)=>[e,t+1])),f=(t,n,r)=>{let i=`${t.map(e=>e.id).join(`,`)}|${r.map(e=>e.dataset.boardNode).join(`,`)}`,a=n._lastOrderKey===i&&n.childElementCount===t.length+r.length;for(let n of t){let{id:t}=n;l.add(t);let r=H.get(t),i=!r;r||(r=oN(t),H.set(t,r));let a=d.get(t)??null;(!e||i||e.has(t)||vN.get(t)!==a)&&gN(r,n,a),hN(r,t,s),vN.set(t,a)}a||ji(n,[...t.flatMap(({id:e})=>H.get(e)?._row??[]),...r]),n._lastOrderKey=i},p=new Set(o.order),m=o.groups.map(e=>e.key).join(`
|
|
77
|
-
`),h=m===DM;DM=m;let g=t.querySelector(`:scope > .rail-new-board`);for(let e of o.groups){let{header:n,list:r}=PM(e);h||t.insertBefore(n,g),h||t.insertBefore(r,g);let i=e.hostId===null?a.get(e.key):void 0;f(e.rows,r,i?wN(e.key,i,c):[])}TN(c,p),Yj(t,{firstGroupHeaderOf:e=>NM(o.groups,e),trailingNode:g});for(let[e,t]of[...EM])p.has(e)||(t.header.remove(),TM.get(e)?.remove(),EM.delete(e),TM.delete(e));for(let[e,t]of H)l.has(e)||(t._row.remove(),H.delete(e),vN.delete(e),e===U&&(U=null));for(let e of[...wM.keys()])k.has(e)||wM.delete(e);let _=OM;OM=Rr(r,kM);let v=W();if(v&&!zi(v)){rj(),M.dispatch(`focusSession`,null),U=null;let e=ON(_,v);if(e){let t=!document.activeElement||document.activeElement===document.body;qN(e),t&&NN(k.get(e),e);return}}JN();let y=W();if(y){let e=k.get(y);e&&e.card.parentElement!==sM&&FN(e,y)}cM?.showSession(B?null:y),BN(),GM(),AN(n,u)}function yN(e,t,n){e.open=t,e.addEventListener(`toggle`,()=>n(e.open))}function bN(e){let{row:t,refs:n}=Dn();t.dataset.boardId=e,t.draggable=!0,t.addEventListener(`click`,()=>EN(e)),t.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(tM,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`link`)});let r=D(`div`,`session-row-item`);return r.dataset.boardNode=e,r.append(t),Object.assign(t,{_refs:n,_row:r})}function xN(e){let t=D(`details`,`focus-board-archive`);t.dataset.boardNode=`archive:${e}`;let n=D(`div`,`focus-board-archive-list`);return t.append(D(`summary`,`focus-board-archive-summary`,`Archived`),n),{details:t,list:n}}function SN(e){let t=e.connectedSessionIds.map(e=>k.get(e)).find(e=>e!==void 0);return t?aN(t):null}function CN(e,t){let n=_M.get(e.id);return n||(n=bN(e.id),_M.set(e.id,n)),An(n,n._refs,e.title,SN(e)),n.classList.toggle(`focused`,e.id===B),t.add(e.id),n._row}function wN(e,t,n){let r=t.active.map(e=>CN(e,n));if(t.archived.length===0)return r;let i=vM.get(e)??xN(e);return vM.set(e,i),ji(i.list,t.archived.map(e=>CN(e,n))),[...r,i.details]}function TN(e,t){for(let[t,n]of _M)e.has(t)||(n._row.remove(),_M.delete(t));for(let[e,n]of vM)t.has(e)&&n.list.childElementCount>0||(n.details.remove(),vM.delete(e))}function EN(e){V&&(KN(),B=e,jM(null),G())}function DN(){LN().then(e=>e.createBoardFromDialog(EN),RN)}function ON(e,t){let n=e.filter(e=>e===t||zi(e));if(n.length<2)return OM.find(e=>zi(e))??null;let r=n.indexOf(t)===n.length-1;return Un(n,t,r?-1:1)}function kN(){return nr(iN(),W())}function AN(e,t){iM&&(pA(iM,Yn(e),t),aM&&FA(aM,e))}function jN(){if(!V)return;iM&&DA(iM);let e=kN()[0]?.id;e&&MN(e)}function MN(e){V&&(Bi(e),H.get(e)?.scrollIntoView({block:`nearest`}),iM&&wA(iM,e,()=>PN(e)),qN(e),NN(k.get(e),e))}function NN(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{V&&W()===t&&e.term?.focus()}))}function PN(e){if(nM?.matches||document.hidden)return;let t=H.get(e);t?.animate&&(t.animate([{transform:`scale(1)`},{transform:`scale(1.045)`,offset:.3},{transform:`scale(1)`}],{duration:360,easing:`cubic-bezier(0.22, 1, 0.36, 1)`}),t._row.animate([{boxShadow:`0 0 0 3px var(--accent)`},{boxShadow:`0 0 0 3px transparent`}],{duration:700,easing:`ease-out`}));let n=k.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function FN(e,t){if(!sM)return;let n=e.card.querySelector(`:scope > .session-card-header`);kO(e,t,sM,{className:`focus-centered`,onRelease:()=>{n?.classList.remove(`pane-header`),z?.setHeaderHost(`terminal`,null)}}),n?.classList.add(`pane-header`),n&&IN(n),jf(e,t,!0)}function IN(e){let t=e.querySelector(`:scope > .session-name`);z?.setHeaderHost(`terminal`,{parent:e,before:t})}function LN(){return lM??=N(()=>import(`./boards-view-VmPAgQRE.js`).then(e=>(uM=e,e.onBoardPicked(HN),e)),__vite__mapDeps([36,3,4,12,13,14,30,21,15,19,23,37])),lM}function RN(e){lM=null,y(`focus`,`the board pane failed to load: ${l(e)}`)}function zN(e){z&&fM!==e&&(fM=e,z.showPanes(e))}function BN(){if(B){zN(Qj),VN(null,B);return}let e=W(),t=HM(e);!e||!t?(zN(Xj),dM=null):(zN(Zj),VN(e,t))}function VN(e,t){let n=`${e??``}\n${t}`,r=dM!==n;dM=n,LN().then(n=>UN(n,e,r?t:null),RN)}function HN(e){if(!V)return;if(B){B=e,dM=`\n${e}`,G();return}let t=W();t&&(BM(bi(pM,t,e)),dM=`${t}\n${e}`,G())}function UN(e,t,n){if(!z||W()!==t)return;let r=z.bodyOf(`board`),i=e.mountBoardHost();i.parentElement!==r&&r.replaceChildren(i),e.placeBoardTitle(z.boardTitleSlot),n&&e.showBoardBeside(n,t)}function WN(){V&&dM!==null&&uM?.reopenSelectedBoard()}function GN(){let e=_O();V&&e?.sessionId&&k.has(e.sessionId)&&ZM(e.sessionId,e.boardId)}function KN(){rj();let e=W();e&&(DO()===e&&AO(),M.dispatch(`focusSession`,null))}function qN(e){V&&k.has(e)&&(zC(e),Ui(e),e!==W()&&(KN(),B=null,M.dispatch(`focusSession`,e),U=e,G()))}function JN(){if(!yM||!bM||!xM)return;let e=W(),t=!!B||!!(e&&k.has(e)),n=k.size>0;Ri(yM,t),z&&Ri(z.element,!t),yk(yM,!n),Ri(bM,!n),Ri(xM,!n),!t&&n&&(Si(bM,`No session selected`),Si(xM,`Select a session from the rail on the left to focus it here.`))}function YN(e,t){wM.set(O(e),typeof t==`string`&&t?t:`none`),V&&G()}var XN={placement:`overlay`,sessionId:()=>V&&oM&&!B?W():null,elementFor:()=>{if(!oM)throw Error(`Focus view is not mounted`);return oM},didShow:()=>{},didHide:()=>{let e=W();e&&NN(k.get(e),e)}};function ZN(e=null){let t=W();t&&nj(`changes`,t,e)}function QN(e){V&&k.has(e)&&qN(e)}function $N(e){return!V||!k.has(e)?!1:(qN(e),Mx(e))}function eP(e){if(!V)return;let t=AM()[e-1];t&&zi(t)&&uN(t)}function tP(e){if(!V)return;let t=AM().filter(e=>e===U||zi(e)),n=Un(t,U,e);n!=null&&zi(n)&&(fN(n),H.get(n)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=W();V&&e&&zC(e)});function nP(){rM&&(V=!0,$A(XN),KN(),U=null,G(),SM&&CM?MN(CM):SM&&kN().length>0?jN():(SM&&iM&&DA(iM),iP()))}function rP(e,t=null){SM=!0,CM=t;try{e()}finally{SM=!1,CM=null}}function iP(){if(!V||W()||B)return;let e=Ni();e&&qN(e)}function aP(){V&&=(KN(),ej(XN),U=null,!1)}var oP=[],sP=new Set;function cP(e){let t=et.safeParse(e);if(t.success){oP=t.data;for(let e of sP)e()}}function lP(e){return oP.find(t=>t.agent===e)??null}function uP(e){return sP.add(e),()=>{sP.delete(e)}}var dP=2e3,fP={},pP=null,mP=null,hP=Ye,gP=null,_P=!1,vP=null,yP=[],bP=null,xP=()=>null,SP=()=>{},CP=!1,wP=new Set,TP=new Set;function EP(e){for(let t of TP)t(e)}function DP(e){TP.add(e)}function OP(){return fP}function kP(e){return fP={...fP,...e},fP}function AP(){return{status:pP,journal:mP,request:hP,lastAutoCheckAt:gP,isCheckInFlight:_P,checkSendFailure:vP}}function jP(e){let t=Oe(hP,e);t!==hP&&(hP=t,EP({kind:`update`,frame:`request`}))}function MP(){jP(s({type:`update-apply`})?`request-sent`:`request-unsent`)}function NP(){gP=Date.now();let e=s({type:`update-check`});_P=e,vP=e?null:S,EP({kind:`update`,frame:`request`})}function PP(e){SP=e}function FP(){SP()}function IP(e){yP=[...e]}function LP(){return yP}function RP(e=null,t=null,n=null){let r=bP!==null&&(bP.sectionId!==null||bP.isLink);e===null&&n===null&&r||(bP={sectionId:e,settingId:t,hashAtRequest:n??location.hash,isLink:n!==null},EP({kind:`activate`}))}function zP(){let e=bP;return bP=null,e}function BP(e){xP=e}function VP(){for(let e of wP)e()}function HP(e){wP.add(e)}function UP(){return Ko()&&xP()===`section`}function WP(){UP()&&EP({kind:`return-to-list`})}function GP(e){e&&(fP=e,cP(fP.agentLogins),EP({kind:`broadcast`}))}function KP(){CP||(CP=!0,window.setTimeout(()=>{c(`get-settings`,{}).then(e=>{e.settings&&GP(e.settings)}).catch(()=>{CP=!1})},dP))}function qP(){EP({kind:`status`})}function JP(e){qP()}function YP(e){pP=e,_P=!1,vP=null,hP=Oe(hP,`status-frame`),EP({kind:`update`,frame:`status`})}function XP(e){mP=e,hP=Oe(hP,`progress-frame`),EP({kind:`update`,frame:`progress`})}function ZP(e){if(e.scope!==`update`)return!1;let t=Ne(e.message),n=hP.requested;return hP=Oe(hP,`error-frame`,t),_P=!1,n||(vP=t),EP({kind:`update`,frame:`error`}),!0}var QP=200;function $P(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function eF(e){return/^#settings(?:[/?]|$)/.test(e)}function tF(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function nF(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,QP).join(``).trim()}}function rF(e,t,n){let r=D(`a`,`settings-link`,n);return r.href=$P(e,t),r}var iF={teamReview:e=>e?.teamReview?.enabled!==!1,issues:e=>e?.issues?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,community:e=>e?.community?.enabled===!0},aF=[{rule:`teamReview`,sectionId:`lanes-team-review`,settingId:`team-review-enabled`},{rule:`issues`,sectionId:`lanes-issues`,settingId:`issues-enabled`},{rule:`usage`,sectionId:`machine-usage`,settingId:`usage-enabled`},{rule:`posthog`,sectionId:`lanes-posthog`,settingId:`posthog-enabled`},{rule:`community`,sectionId:`lanes-community`,settingId:`community-enabled`}],oF=null,sF=null,cF=null,lF=()=>!1,uF=new Set,dF=new Set,fF=_t({getAck:oi,setAck:Sr,signature:()=>at({posthog:oF}),isLooking:()=>lF()});function pF(e){for(let t of dF)t(e)}function mF(){sF?.(fF.refresh())}function hF(){return{latest:oF,archivedLocally:uF,traceOpener:cF}}function gF(e){dF.add(e)}function _F(e){lF=e,mF()}function vF(e){uF.add(e)}function yF(){fF.acknowledge(),mF()}function bF(e){sF=e,mF()}function xF(e){cF=e}function SF(e){oF=e,lt(oF,uF),pF({kind:`status`}),mF()}function CF(e){let t=Le(oF,e.projectId,e.issueId)?.inFlight===!0;nt(oF,e)&&pF({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function wF(e){let t=be(oF,e);pF({kind:`investigation-finished`,frame:e,isPatched:t}),t&&mF()}var TF=null,EF=[],DF=()=>!1,OF=null,kF=di(),AF=ni(),jF=new Set(AF.split(`|`).filter(Boolean)),MF=new Set;function NF(e){for(let t of MF)t(e)}function PF(){return tg(EF).map(eg)}function FF(e){e!==kF&&(kF=e,Pr(e))}function IF(e){e!==AF&&(AF=e,jF=new Set(e.split(`|`).filter(Boolean)),Or(e))}function LF(){if(!TF)return;let e=pg({turnEntries:PF(),acknowledged:kF,unseen:AF,isLooking:DF()});FF(e.acknowledged),IF(e.unseen),OF?.(e.isShown)}function RF(e){MF.add(e)}function zF(){return TF}function BF(){return EF}function VF(e){DF=e,LF()}function HF(e){OF=e,LF()}function UF(){TF&&(FF(dt(PF())),LF())}function WF(){return AF}function GF(e){return jF.has(e)}function KF(e){return jF.has(e)?(IF(dt([...jF].filter(t=>t!==e))),!0):!1}function qF(e){let t=Ie.safeParse(e);t.success?(TF=t.data,EF=$h(t.data.entries),LF(),NF({kind:`status`})):y(`community`,`dropped community-status: ${r(t.error.issues)}`)}function JF(e){NF({kind:`connection`,isConnected:e})}function YF({source:e,className:t,title:n,allowsScripts:r}){let i=D(`iframe`,t);return i.setAttribute(`sandbox`,r?`allow-scripts allow-forms`:``),i.setAttribute(`allow`,``),i.referrerPolicy=`no-referrer`,i.title=n,e.kind===`srcdoc`&&(i.srcdoc=e.html),e.kind===`url`&&(i.src=e.url),i}var XF=`panel-action`,ZF=524288,QF=[`key`,`prKey`,`repo`,`number`,`action`,`actionId`,`itemKey`,`fingerprint`],$F=900;function eI(e){let t=le.options.find(t=>t.shape.type.value===e);return new Set(Object.keys(t?.shape??{}).filter(e=>e!==`type`&&e!==`requestId`))}function tI(e){return e.map(e=>`${e.path.map(String).join(`.`)||`request`}: ${e.message}`).join(`; `)}function nI(e,t){let n=_e.safeParse(t);if(!n.success)return{ok:!1,error:`not sent: ${tI(n.error.issues)}`};if(!e.includes(`reviews`))return{ok:!1,error:`${n.data.type} not sent: this panel does not list reviews under acts in pack.json`};let r=le.safeParse({...n.data,requestId:XF});if(!r.success)return{ok:!1,error:`${n.data.type} not sent: ${tI(r.error.issues)}`};let i=eI(r.data.type),a=Object.fromEntries(Object.entries(r.data).filter(([e])=>i.has(e))),o=new TextEncoder().encode(JSON.stringify(a)).length;return o>524288?{ok:!1,error:`${r.data.type} not sent: the request is ${o} bytes, over the ${ZF} byte limit`}:{ok:!0,type:r.data.type,payload:a}}function rI(e,t,n){return`${e} sent ${t} ${QF.flatMap(e=>{let t=n[e];return typeof t==`string`||typeof t==`number`?[`${e}=${t}`]:[]}).join(` `)}`.trim().slice(0,$F)}var iI=`[^/\\\\\\s"'\`<>:]+`,aI=RegExp(`(?<![\\w./\\\\-])(?:/home/${iI}|/Users/${iI}|[A-Za-z]:[\\\\/]Users[\\\\/]${iI}|/root(?![\\w.-]))`,`g`);function oI(e){return e.replace(aI,`~`)}function sI(e){return oI(Kc(e))}var cI=1e3,lI=12e4,uI=new Map,dI=null;function fI(e){return Zc()?sI(e):e}var pI={sessions:()=>({sessions:[...k].map(([e,t])=>({id:e,name:fI(Kn(t)),agent:t.agent??null,state:t.currentState,stateSinceMs:t.stateSince,taskTitle:t.taskTitle===null?null:fI(t.taskTitle)}))}),focus:()=>({sessionId:M.snapshot().focusedSessionId,view:M.snapshot().activeView,isStreamerMode:Zc()}),theme:()=>Qa(),usage:()=>({planLimits:Object.entries(OD().planLimitsByVendor).flatMap(([e,t])=>t===null||e!==`claude`&&e!==`codex`&&e!==`kimi`?[]:[{vendor:e,fiveHour:cw(t,`fiveHour`),sevenDay:cw(t,`sevenDay`)}])}),attention:()=>{let e=Yn([...k.values()].map(e=>({state:e.currentState,unseenOutcome:e.unseenOutcome??null})));return{waiting:e.waitingCount,finished:e.finishedCount,failed:e.failedCount}},reviews:()=>p_()};function mI(e,t){e.frame.contentWindow?.postMessage(t,`*`)}function hI(e,t){let n=t.get(e);if(n)return n;let r=pI[e](),i={data:r,dataJson:JSON.stringify(r)};return t.set(e,i),i}function gI(e,t,n=new Map){let{data:r,dataJson:i}=hI(t,n);e.lastSentJsonByTopic.get(t)!==i&&(e.lastSentJsonByTopic.set(t,i),mI(e,we.parse({v:1,kind:`topic`,topic:t,data:r})))}function _I(){let e=!1,t=new Map;for(let n of uI.values()){for(let e of n.subscribedTopics)gI(n,e,t);e||=n.subscribedTopics.size>0}e||dI===null||(clearInterval(dI),dI=null)}var vI=new Map;async function yI(e,t){let n=await c(e,t).catch(e=>zn(e));return typeof n==`string`?{ok:!1,error:n}:n.type===`pack-data-result`?n.ok&&n.data?{ok:!0,data:n.data}:{ok:!1,error:n.error??`the pack store did not answer`}:{ok:!1,error:`unexpected ${n.type} reply`}}function bI(e,t){mI(e,{v:1,kind:`store`,data:vI.get(e.packName)??{},error:t})}async function xI(e){let t=await yI(`pack-data-get`,{pack:e.packName});t.ok&&vI.set(e.packName,t.data),bI(e,t.ok?null:t.error)}async function SI(e,t,n){let r=ke(e.packName,Se(vI.get(e.packName)??{},t,n));if(r!==null){bI(e,r);return}let i=await yI(`pack-data-set`,{pack:e.packName,key:t,value:n});if(!i.ok)bI(e,i.error);else{vI.set(e.packName,i.data);for(let t of uI.values())t.packName===e.packName&&bI(t,null)}}function CI(e,t){e.subscribedTopics=new Set(t.filter(t=>e.grantedTopics.has(t))),e.lastSentJsonByTopic.clear(),mI(e,{v:1,kind:`hello`,granted:[...e.subscribedTopics]}),xI(e);for(let t of e.subscribedTopics)gI(e,t);dI??=setInterval(_I,cI)}function wI(e,t,n,r,i=!1){mI(e,{v:1,kind:`action-result`,id:t,ok:r===null,timedOut:i,result:n,error:r})}function TI(e,t){return t.ok===!1?typeof t.error==`string`&&t.error!==``?t.error:`${e} was refused`:null}async function EI(e,t,n){let r=nI(e.acts,n);if(!r.ok){wI(e,t,null,r.error);return}s({type:`client-log`,scope:`packs`,text:rI(e.viewId,r.type,r.payload)});let i=await c(r.type,r.payload,{timeoutMs:lI}).catch(e=>zn(e));if(i===`Request timed out`){wI(e,t,null,`${r.type} got no answer within ${lI/1e3} s; it may still run, so check before sending it again`,!0);return}if(typeof i==`string`){wI(e,t,null,`${r.type} failed: ${i}`);return}let a={...i};wI(e,t,a,TI(r.type,a))}function DI(e){let t=[...uI.values()].find(t=>t.frame.contentWindow!==null&&t.frame.contentWindow===e.source);if(!t)return;let n=Ee.safeParse(e.data);if(n.success){EI(t,n.data.id,n.data.request);return}let r=ye.safeParse(e.data);r.success&&(r.data.kind===`store-set`?SI(t,r.data.key,r.data.value):r.data.kind===`subscribe`&&CI(t,r.data.topics))}function OI(e,t,n){uI.size===0&&window.addEventListener(`message`,DI),uI.set(e,{viewId:e,frame:t,packName:n.pack,acts:n.acts,grantedTopics:new Set(n.reads),subscribedTopics:new Set,lastSentJsonByTopic:new Map})}var kI=null,AI=new Set;function jI(){return kI}function MI(e){return AI.add(e),()=>AI.delete(e)}function NI(e){let t=Ce.safeParse(e);if(!t.success)y(`settings`,`dropped packs-status: ${r(t.error.issues)}`);else{kI=t.data,Ka(t.data.themes)&&eo();for(let e of AI)e()}}var PI=`about:blank`,FI={pack:``,reads:[],acts:[]},II=new Map,LI=new Map;function RI(e){let t=D(`img`,`pack-tab-icon`);return t.src=e,t.alt=``,t.decoding=`async`,t.referrerPolicy=`no-referrer`,t}function zI(e){return LI.set(e.viewId,e),{mount(t){let n=LI.get(e.viewId);t.replaceChildren(BI(e.viewId,n?.entryUrl??PI,e.label,n??FI))}}}function BI(e,t,n,r){let i=YF({source:{kind:`url`,url:t},className:`pack-panel-frame`,title:n,allowsScripts:!0});return II.set(e,i),OI(e,i,r),i}function VI(e,t,n,r){let i=II.get(e);i&&i.getAttribute(`src`)!==t&&i.replaceWith(BI(e,t,n,r))}function HI(e){LI.set(e.viewId,e),VI(e.viewId,e.entryUrl,e.label,e)}function UI(e){LI.delete(e),VI(e,PI,II.get(e)?.title??``,FI)}function WI(e){let t=()=>e(jI()?.panels??[]);MI(t),t()}function GI(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function KI(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function qI(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 JI(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 YI(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function XI(e,t,n){t&&e?.refreshOn?.includes(n)&&t.refresh?.(n)}function ZI(e,t,n,r){for(let i of e)GI(i.view,t)&&XI(i,r(i.view),n)}function QI(){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 $I(e,t,n){let r=Number(e);return!e||!Number.isFinite(r)||t-r>n}var eL=`glimmervoid:preload-error-reload-at`,tL=3e4,nL=1e3,rL=QI();function iL(e,t){let n=rL.mountedModuleOf(e.view);n?t(n):rL.show(e).then(t).catch(t=>{throw y(`view`,`${e.view} failed to show: ${l(t)}`),t})}function aL(e){return rL.mountedModuleOf(e)}function oL(e){rL.mountEagerViews(e)}function sL(e){let t=()=>{rL.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,nL)}function cL(e){let t=Date.now();$I(e.getItem(eL),t,tL)&&(e.setItem(eL,String(t)),location.reload())}function lL(e){window.addEventListener(`vite:preloadError`,()=>cL(e()))}function uL(e,t){fetch(e,{method:`HEAD`,cache:`no-store`}).then(e=>{e.status===404&&cL(t())}).catch(()=>{})}function dL(e,t,n){let r=T(document,`#app-main`,`main`),i=Be(`header-tab`,e.label);i.prepend(t),i.id=`tab-${e.view}`,i.draggable=!0;let a=`view-${e.view}`;i.setAttribute(`role`,`tab`),i.setAttribute(`aria-controls`,a);let o=e.view===`focus`;i.setAttribute(`aria-selected`,String(o)),i.tabIndex=o?0:-1;let s=document.getElementById(a)??D(`section`);if(s.classList.add(e.panelClass),s.id=a,s.setAttribute(`role`,`tabpanel`),s.setAttribute(`aria-labelledby`,i.id),s.hidden=!0,s.parentElement||r.append(s),i.hidden=e.gate!==void 0||e.isPhoneOnly===!0,s.classList.toggle(`view-panel`,e.hasPanelChrome!==!1),e.attention){let t=D(`span`,`tab-activity`);t.id=`tab-${e.view}-activity`,t.setAttribute(`aria-hidden`,`true`),i.append(t),e.attention.subscribe(r=>{let{isActive:i,level:a}=YI(r);t.classList.toggle(`active`,i),a===null&&t.removeAttribute(`data-attention`),a!==null&&t.setAttribute(`data-attention`,a),n(e.view,r)})}return{...e,tab:i,el:s}}function fL(e){return e.iconUrl?RI(e.iconUrl):Te(He)}function pL(e){return dL({view:e.viewId,label:e.label,iconPath:``,panelClass:`pack-panel-view`,hasPanelChrome:!1,module:zI(e)},fL(e),()=>{})}function mL(e,t){e.tab.replaceChildren(fL(t),t.label)}function hL(e){i_({openTerminal:e.openTerminal,openReviews:e.openReviews}),Bk({openTerminal:e.openTerminal}),PP(e.onRestart),fO(e.openReviewFile);let t=[{view:`focus`,label:`Focus`,iconPath:tt,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,refreshOn:[`connected`],module:{mount:()=>LM({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:nP,deactivate:aP,refresh:WN}},{view:`prs`,label:`Reviews`,iconPath:Ae,panelClass:`pr-view`,gate:{fromSettings:iF.teamReview},load:()=>N(()=>import(`./review-queue-panel-CfzxFyz7.js`).then(e=>e.view),__vite__mapDeps([38,39,14,13,4,3,12,32,40,15,41,29,26,19,22,27,5,6,7,18,30,21,31,28,42,35,43])),refreshOn:[`shown`],attention:{subscribe:e_,acknowledge:$g},onConnectionChange:e=>{gh(e),Mg(e)}},{view:`issues`,label:`Issues`,iconPath:ze,panelClass:`issues-view`,gate:{fromSettings:iF.issues},load:()=>N(()=>import(`./issues-panel-BLaflTII.js`).then(e=>e.view),__vite__mapDeps([44,13,4,3,12,14,32,41,29,26,15,19,22,27,5,6,7,18,30,21,31,28,42,23,45])),refreshOn:[`shown`],onConnectionChange:Fp},{view:`usage`,label:`Usage`,iconPath:pe,panelClass:`usage-view`,gate:{fromSettings:iF.usage},load:()=>N(()=>import(`./usage-panel-C6x7Alhb.js`).then(e=>e.view),__vite__mapDeps([46,3,4,13,47,48])),attention:{subscribe:ND,acknowledge:MD},onConnectionChange:zD,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,iconPath:pt,panelClass:`radar-view`,gate:{fromSettings:iF.posthog},load:()=>N(()=>import(`./radar-panel-Bzc5G9d0.js`).then(e=>e.view),__vite__mapDeps([49,13,4,3,47,50,12,14,34,26,15,19,22,27,5,6,7,18,31,28,51])),attention:{subscribe:bF,acknowledge:yF}},{view:`community`,label:`Community`,iconPath:We,panelClass:`community-view`,gate:{fromSettings:iF.community},load:()=>N(()=>import(`./community-panel-CqhjpdB4.js`).then(e=>e.view),__vite__mapDeps([52,13,4,3,39,14,12,32,40,42,5,6,7,19,15,35,53])),refreshOn:[`shown`],attention:{subscribe:HF,acknowledge:UF},onConnectionChange:JF},{view:`boards`,label:`Boards`,iconPath:He,isPhoneNavScreen:!0,isPhoneOnly:!0,panelClass:`boards-screen`,hasPanelChrome:!1,load:()=>N(()=>import(`./boards-view-VmPAgQRE.js`).then(e=>e.view),__vite__mapDeps([36,3,4,12,13,14,30,21,15,19,23,37])),refreshOn:[`shown`,`connected`]},{view:`hooks`,label:`Hooks`,iconPath:Ge,panelClass:`hooks-view`,load:()=>N(()=>import(`./hooks-panel-BDAAAtd-.js`).then(e=>e.view),__vite__mapDeps([54,14,13,4,3,12,15,55])),refreshOn:[`shown`,`connected`,`hooks-updated`]},{view:`trace`,label:`Trace`,iconPath:je,panelClass:`trace-view`,gate:{subscribe:rb},load:()=>N(()=>import(`./trace-panel-Bq_awQ92.js`).then(e=>e.view),__vite__mapDeps([56,3,4,13,12,14,5,6,7,57])),refreshOn:[`shown`],onAvailabilityChange:e=>xF(e?eC:null),onConnectionChange:aC},{view:`benchmarks`,label:`Arena`,iconPath:rt,panelClass:`bench-view`,load:()=>N(()=>import(`./arena-panel-5b76eNl_.js`).then(e=>e.view),__vite__mapDeps([58,13,4,3,14,19,28,15,27,59])),onConnectionChange:la},{view:`settings`,label:`Settings`,iconPath:de,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>N(()=>import(`./settings-panel-Bb_nAcBI.js`).then(e=>e.view),__vite__mapDeps([60,3,4,5,6,7,2,1,8,61,13,10,50,12,14,34,26,15,19,22,27,18,31,28,41,29,30,21,32,43,62]))}].map(t=>dL(t,Te(t.iconPath),e.setPhoneAttention));return T(document,`#header-tabs`,`div`).replaceChildren(...t.map(e=>e.tab)),t}function gL(e){return e===`remote`?`remote`:`local`}function _L(e,t){return gL(t)===`local`||e!==`shutdown`}var vL=!1,yL=new Set;function bL({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){let o=bC(),c=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;Xt({title:t,message:c,confirmLabel:n,danger:r||o>0,onConfirm:()=>s({type:e})})}function xL(){bL({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function SL(){bL({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})}function CL(e){vL=_L(`shutdown`,e);for(let e of yL)e.isConnected?e.hidden=!vL:yL.delete(e)}function wL(e){e.hidden=!vL,yL.add(e)}function TL(e){e&&RP(e),$O(`settings`)||q(`settings`,{section:e})}function EL(e){$O(e)||q(e)}function DL(){$O(`boards`)||(q(`focus`),GN())}function OL(){eF(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}var K=hL({onRestart:xL,openTerminal:e=>{QO(e)||(q(`focus`),QN(e))},openPlan:e=>{q(`focus`),$N(e)},openReviewFile:(e,t)=>{yC(e)&&(QO(e)||(q(`focus`),QN(e),ZN(t)))},openReviews:()=>ML(`prs`)?($O(`prs`)||q(`prs`),!0):!1,setPhoneAttention:qO});function kL(){return K.map(e=>e.view)}var AL=kL();function jL(e){return K.find(t=>t.view===e)}function ML(e){return K.some(t=>t.view===e&&!t.tab.hidden)}var NL=!0,PL=null;function FL(e){jL(e)?.attention?.acknowledge()}var IL=null;function LL(e){IL=s({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function RL(){IL&&LL(IL)}function zL(e){let t=jL(e);t&&(iL(t,e=>XI(t,e,`shown`)),LL(e))}function BL(e){ZI(K,{isPhoneShellActive:UO(),activeView:rr(),phoneScreen:M.snapshot().phoneScreen},e,aL)}function q(e,{section:t,setting:n,persist:r=!0}={}){let i=jL(e);if(!i||!ML(e))return;let a=rr();M.dispatch(`setActiveView`,e),NL=r,r&&(PL=null),document.body.dataset.activeView=e,r&&Mr(e);for(let t of K){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&&aL(a)?.deactivate?.(),iL(i,r=>{rr()===e&&(r.activate?.(),XI(i,r,`shown`),e===`settings`&&t&&RP(t,n??null))}),LL(e),a===`settings`&&e!==`settings`&&OL(),FL(e)}function VL(e,t){let{view:n}=e;e.tab.hidden=!t,KO(n,t),e.onAvailabilityChange?.(t),UO()||(!t&&rr()===n&&q(`focus`),t&&PL===n&&q(n))}function HL(e){for(let{view:t,isAvailable:n}of KI(K,e))VL(t,n)}var UL;function WL(e){UL=e;let t=qI(AL,e);K.every((e,n)=>e.view===t[n])||(K.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),T(document,`#header-tabs`,`div`).append(...K.map(e=>e.tab)),GO(t))}function GL(){return K.filter(e=>!e.tab.hidden)}function KL(e,t){let n=e[t];return q(n.view),n.tab}function qL(e,t){let n=GL(),r=n.findIndex(t=>t.view===e);return KL(n,Yi(r,t,n.length))}function JL(e){K.some(e=>e.tab===document.activeElement)&&e.focus()}var YL=null;function XL(e){let t=kL();WL(e),c(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&WL(t)}).catch(()=>WL(t))}function ZL(e){let t=YL;if(YL=null,!t||t===e)return;let n=kL();XL(JI(n,t,n.indexOf(e)))}function QL({view:e,tab:t}){t.addEventListener(`click`,()=>q(e)),t.addEventListener(`dragstart`,t=>{YL=e,t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),t.addEventListener(`dragover`,n=>{YL&&YL!==e&&(n.preventDefault(),t.dataset.dropTarget=`true`)}),t.addEventListener(`dragleave`,()=>delete t.dataset.dropTarget),t.addEventListener(`drop`,n=>{n.preventDefault(),delete t.dataset.dropTarget,ZL(e)}),t.addEventListener(`dragend`,()=>{YL=null}),t.addEventListener(`keydown`,e=>{if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=GL(),n=t.findIndex(e=>e.view===rr()),r=Xi(e.key,n,t.length,`horizontal`);r!==null&&(e.preventDefault(),KL(t,r).focus())})}var $L=`pack:`,eR=new Map;function tR(e){let t=pL(e);return K.push(t),AL.push(t.view),T(document,`#header-tabs`,`div`).append(t.tab),QL(t),t}function nR(e){let t=new Set(e.map(e=>e.viewId));for(let e of K)e.view.startsWith($L)&&!t.has(e.view)&&(UI(e.view),VL(e,!1));for(let t of e){let e=jL(t.viewId)??tR(t),n=eR.get(t.viewId);n&&(n.label!==t.label||n.iconUrl!==t.iconUrl)&&mL(e,t),eR.set(t.viewId,t),HI(t),VL(e,!0)}WL(UL)}function rR(){let e=fi(),t=eF(location.hash),n=wb(location.hash);if(t&&(RP(null,null,location.hash),q(`settings`,{persist:!1})),n&&q(`focus`,{persist:!1}),t||n)return;let r=ML(e);r||(PL=e),q(r?e:`focus`,{persist:r})}function iR(){let e=rr();q(ML(e)?e:`focus`,{persist:NL})}function aR(){IP(K),oL(K);for(let e of K)e.gate&&(VL(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>VL(e,t)));$S(()=>{ML(`trace`)&&($O(`trace`)||q(`trace`))});for(let e of K)QL(e);rR(),WI(nR)}function oR(e){return eF(e)?(RP(null,null,e),$O(`settings`)||q(`settings`,{persist:!1}),!0):!1}var sR=`No plan is stored for this session yet. It appears here once the agent writes one.`,cR=`Plan`;function lR(e){let t=wb(e);return t?!yC(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),UO()?(ZO(t)||sr({source:cR,sessionId:t,message:sR}),!0):(q(`focus`,{persist:!1}),$N(t)||sr({source:cR,sessionId:t,message:sR}),!0)):!1}function uR(e){return lR(e)?!0:oR(e)}function dR(e){e.newURL===location.href&&uR(location.hash)}function fR(){document.addEventListener(`click`,e=>{if(!UO()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&uR(t.hash)&&e.preventDefault()}),window.addEventListener(`hashchange`,dR)}var pR=null,mR=new Set;function hR(){pR?.setState(ri()?`idle`:`off`)}function gR(e){ci(e),hR();for(let t of mR)t(e)}function _R(e){mR.add(e)}function vR(e){pR=e,hR(),e.element.addEventListener(`click`,()=>gR(!ri()))}var yR=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,bR=[`title`,`label`],xR=new WeakMap,SR=new WeakMap,CR=null;function wR(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(yR)!==null}function TR(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function ER(e,t){if(t&&e===t.masked)return t;let n=sI(e);return n===e?null:{original:e,masked:n}}function DR(e){let t=TR(e)?null:ER(e.data,xR.get(e));t?(xR.set(e,t),e.data!==t.masked&&(e.data=t.masked)):xR.delete(e)}function OR(e,t){let n=e.getAttribute(t),r=SR.get(e),i=n===null?null:ER(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),SR.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function kR(e){for(let t of bR)OR(e,t)}function AR(e){return e instanceof Element&&e.matches(yR)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function jR(e){kR(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,AR);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&DR(e),e instanceof Element&&kR(e)}function MR(e){wR(e)||(e instanceof Text&&DR(e),e instanceof Element&&jR(e))}function NR(e){e instanceof Element&&!wR(e)&&kR(e)}function PR(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&&MR(e);for(let e of n)e.isConnected&&NR(e)}function FR(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);IR(e);for(let e=t.nextNode();e;e=t.nextNode())IR(e)}function IR(e){if(e instanceof Text){let t=xR.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=SR.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function LR(){if(CR)return;let e=new MutationObserver(t=>{PR(t),e.takeRecords()});jR(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:bR}),CR=e}function RR(){CR&&(CR.disconnect(),CR=null,FR(document.body),xR=new WeakMap,SR=new WeakMap)}function zR(e){e?LR():RR()}function BR(){zR(Zc()),$c(zR)}var VR=qe({label:`Play queued merge celebrations`,icon:Te(he,`1.6`),action:`play-celebrations`,states:[`idle`,`attention`]}),HR=w({variant:`primary`,label:`Session`,icon:Te(Ve),action:`add-session`,onClick:Hi});HR.id=`btn-add-session-header`;var UR=qe({label:`Keyboard shortcuts and version`,icon:Te(Ke,`1.6`),action:`open-shortcuts-help`,onClick:()=>TL(`browser-shortcuts`),states:[`idle`]}).element,WR=qe({label:`Mute alerts`,icon:Te(ht,`1.6`),action:`toggle-mute`,states:[`idle`,`off`]}),GR=WR.element,KR=w({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-header-status`});KR.id=`header-status-dismiss`;var qR=T(document,`#celebration-tray`,`div`);qR.prepend(VR.element),T(document,`.header-right`,`div`).append(HR,UR,GR),T(document,`#header-status`,`p`).append(KR);function JR(){vR(WR),BR(),Ht(document.querySelector(`.header`))}function YR(){em(qR,VR,T(document,`#celebration-tray-count`,`span`))}function XR(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 ZR(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 QR(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function $R(e,t){return t||QR(e)?!1:ZR(e)}var ez=w({variant:`primary`,size:`small`,label:`Restart`,action:`restart-to-update`,hidden:!0}),tz=w({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-update-command`}),nz=w({variant:`icon`,size:`small`,label:`Dismiss update notice`,icon:Te(st),action:`dismiss-update-banner`});T(document,`#update-banner-cmd`,`code`).before(ez),T(document,`#update-banner-copy-status`,`span`).before(tz),T(document,`#update-banner`,`div`).append(nz);var rz=w({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-leftovers-command`}),iz=w({variant:`icon`,size:`small`,label:`Dismiss old report notice`,icon:Te(st),action:`dismiss-leftovers-banner`});T(document,`#post-turn-leftovers-copy-status`,`span`).before(rz),T(document,`#post-turn-leftovers-banner`,`div`).append(iz);var az,oz=null;function sz(e,t,n){e.onclick=()=>{let e=Nt(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var cz=rF(xe,ve,`Update`).href;function lz(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function uz(e){let t=T(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=Pe(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=lz(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===oz||!a&&az!==void 0&&s===az||!a&&s&&Gr()===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=cz,l.hidden=n!==`link`,ez.hidden=n!==`restart`,ez.onclick=xL;let u=T(document,`#update-banner-cmd`,`code`);u.hidden=n!==`command`,tz.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,sz(tz,d,c),nz.onclick=()=>{t.hidden=!0,a?oz=i:(az=s,jr(s))}}var dz=!1;function fz({repositories:e,command:t}){let n=T(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(dz)return;let r=T(document,`#post-turn-leftovers-copy-status`,`span`);T(document,`#post-turn-leftovers-text`,`span`).textContent=XR(e.length),T(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,sz(rz,r,t),iz.onclick=()=>{dz=!0,n.hidden=!0}}var pz=T(document,`#telemetry-banner`,`div`),mz=w({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-telemetry-banner`});pz.append(mz);function hz(){ai(!0),pz.hidden=!0}function gz(e){pz.hidden=!$R(e,Cr())}function _z(){let e=T(document,`#telemetry-banner-settings`,`a`);e.href=rF(`privacy`,`telemetry-enabled`,`What's collected`).href,e.addEventListener(`click`,hz),mz.addEventListener(`click`,hz)}function vz(e){N(()=>import(`./feature-hint-JZ0N-gf7.js`).then(t=>t.showFeatureHint(e,{isFeatureEnabled:e=>ML(Fe[e]),openView:EL,openSetting:(e,t)=>oR($P(e,t))}),e=>y(`feature-hint`,`hint card failed to load: ${l(e)}`)),__vite__mapDeps([63,13,4,3,61,5,6,7,8,14,64]))}function yz(){N(()=>import(`./feature-hint-JZ0N-gf7.js`).then(e=>e.showStarHint(),e=>y(`star-hint`,`star card failed to load: ${l(e)}`)),__vite__mapDeps([63,13,4,3,61,5,6,7,8,14,64]))}var bz=2500;function xz({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}function Sz(e){Xa(e.isExperimentalBuild===!0&&Tr()),xC(e),GP(e),HL(e),gz(e),WL(e.viewTabOrder),Qc(e.streamerMode===!0)}var Cz=Object.freeze({top:[0,1],right:[-1,0],bottom:[0,-1],left:[1,0]}),wz=160,Tz=950,Ez=900,Dz=980,Oz=450,kz=720,Az=260,jz=`cubic-bezier(0.22, 1, 0.36, 1)`,Mz=`cubic-bezier(0.2, 0.8, 0.3, 1)`,Nz=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),Pz=e=>new Promise(t=>{setTimeout(t,e)});function Fz(e){return e!==void 0&&Object.hasOwn(Cz,e)}function Iz(e){return[...e.querySelectorAll(`[data-side]`)].flatMap(e=>{let t=e instanceof SVGElement?e.dataset.side:void 0;if(!(e instanceof SVGElement)||!Fz(t))return[];let[n,r]=Cz[t];return[{bracket:e,dx:n,dy:r}]})}function Lz(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:Ol}],{duration:wz,easing:`ease-out`})}}function Rz(e){e.animate([{transform:`rotate(0deg)`,easing:`cubic-bezier(0.5, 0, 0.15, 1)`},{transform:`rotate(360deg)`,offset:.86,easing:Mz},{transform:`rotate(354deg)`,offset:.93,easing:Mz},{transform:`rotate(360deg)`}],{duration:Tz})}function zz(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:Ez,easing:`cubic-bezier(0.2, 0.9, 0.3, 1)`})}}function Bz(e,t){e.animate([{transform:`scale(0)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:Dz,easing:jz,fill:`forwards`}),t.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`})}function Vz(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:kz,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:kz,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`})}function Hz({mark:e,dial:t,light:n,halo:r}){return Nz?.matches||document.hidden?Promise.resolve():(Rz(t),zz(Iz(e)),n.animate([{transform:`scale(1)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:Dz,easing:jz}),r.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`}),Pz(Dz))}async function Uz(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(Nz?.matches||document.hidden||!(t instanceof SVGElement)||!n||!r||!i)return;let a=Iz(t);Lz(a),e.dataset.unlock=`spin`,await Pz(wz),Rz(n),zz(a),Bz(r,i),await Pz(Dz),e.dataset.unlock=`lit`,await Pz(Oz),e.dataset.unlock=`burst`,Vz(a,r,i),await Pz(Az)}var Wz=T(document,`#connection-status`,`span`),Gz=T(Wz,`.connection-label`,`span`),Kz=T(document,`#loading-screen`,`div`),qz=T(document,`#loading-status`,`div`),Jz=T(document,`#loading-detail`,`div`),Yz=T(document,`#shutdown-screen`,`div`),Xz=T(document,`#shutdown-status`,`div`),Zz=!1,Qz=null,$z=!1;function eB(){Zz||Qz===null||xz({hasSnapshot:$z,connectingTerminalCount:Xl(),msSinceConnected:performance.now()-Qz})===`reveal`&&nB()}function tB(){$z=!0,eB()}function nB(){Zz||(Zz=!0,sL(K),$f(),xk(),Uz(Kz).then(rB,rB))}function rB(){Kz.classList.add(`fade-out`);let e=()=>Kz.remove();Kz.addEventListener(`transitionend`,t=>{t.target===Kz&&e()}),setTimeout(e,1e3)}function iB(e,t){Wz.dataset.state=`shutdown`,Gz.textContent=e,Xz.textContent=t,Yz.classList.add(`active`)}var aB=new Set([`disconnected`,`connecting`]);function oB(e,t,n){Wz.dataset.state=e,Wz.toggleAttribute(`data-reconnected`,n),Gz.textContent=t}function sB(e,t){oB(e,t,e===`connected`&&aB.has(Wz.dataset.state??``))}function cB(e,t){Wz.dataset.state!==`shutdown`&&oB(e===`verified`?`connected`:e,t,!1)}var lB=1e4,uB=`Server`,dB=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,fB=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,pB=null,mB=!1;function hB(){qz.textContent=`Reconnecting to server...`,Jz.textContent=fB,Jz.hidden=!mB}function gB(){pB=null,mB=!0,Zz?sr({source:uB,message:dB,hidesInStreamerMode:!1}):hB()}function _B(){pB!==null||mB||(pB=window.setTimeout(gB,lB))}function vB(){pB!==null&&window.clearTimeout(pB),pB=null,mB=!1,Jz.hidden=!0,or(uB)}function yB(){vB(),uL(import.meta.url,()=>window.sessionStorage),RL(),Yz.classList.contains(`active`)?location.reload():(bk(),document.body.classList.add(`app-ready`),!Zz&&Qz===null&&(Qz=performance.now(),qz.textContent=`Connecting to sessions...`,setTimeout(nB,bz)),eB(),BL(`connected`),c(`get-settings`,{}).then(e=>{e.settings&&(Sz(e.settings),rr()===`settings`&&oR(location.hash))}).catch(()=>{}))}function bB(e,t){if(e===`connecting`||e===`verified`)cB(e,t);else{sB(e,t),Rx(e===`connected`);for(let t of K)t.onConnectionChange?.(e===`connected`);e===`connected`?yB():e===`disconnected`&&Yz.classList.contains(`active`)?Xz.textContent=`Waiting for server...`:(_B(),Zz||hB())}}function xB(){Yl(eB),h(bB)}var SB=14,CB=Object.freeze({idle:kl,failed:`#ef4444`,waiting:`#f59e0b`});function wB({waitingCount:e,failedCount:t}){return e>0?`waiting`:t>0?`failed`:`idle`}function TB(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)">${Al({frame:Ol,light:CB[e],strokeWidth:SB})}</g></svg>`}function EB(){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 DB=EB(),OB=`idle`;function kB(e){let t=wB(e);t!==OB&&(OB=t,DB.href=`data:image/svg+xml,${encodeURIComponent(TB(t))}`)}function AB(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 jB(e){return{skipPerms:e.skipPerms??e.dangerouslySkipPermissions??!1,saneYolo:e.saneYolo===!0,isQuestionManagerOn:e.isQuestionManagerOn??null,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 MB(){Pp(),fh(),JO()}function NB(){G(),MB()}function PB(){Ti(e=>{G(e),MB()})}var FB=null;function IB(e){let t=AB(FB,e);FB=t.knownBuild,t.reload&&location.reload()}function LB(e){cr(e),IC(e),Sa(e),Ky(e),E_(e),vn(e),qs(e)}function RB(e){for(let t of Js(e))LB(t)}function zB(e,t){let n=new Set(e.map(e=>e.id));for(let e of[...k.keys()])Gs(e)===t&&(n.has(e)||LB(e))}function BB(e,t=null){if(t)for(let n of e)Ks(n.id,t);zB(e,t),t||JP(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)yC(t.id)&&HB(t),yC(t.id)||TC(t.id,t.name,t.state,jB(t)),xa(t.id,t.coherenceHooks),T_(t.id,t.linkedPrs),Pn(t.id,t.failureReason),vC(t.id,t.taskTitle,t.taskTitleIsCustom),DC(t.id,t.agent),PC(t.id,t.mergeStatus,t.mergeReason),EC(t.id,t.effectiveBase),kC(t.id,t.activeAgents,t.awaitingBackgroundTasks),AC(t.id,t.pendingPromptKind),jC(t.id,t.unseenOutcome),bn(t.id,t.auditLog,t.managerSeenSeq),Nx(t.id,t.hasPlan);wC(),kB(j.counts),G(),iP(),MB(),WB(),lR(location.hash),ek(),tB()}function VB(e,t){let n=e.dataset.skipPerms!==void 0;return(e.dataset.path??``)!==t.path||n!==t.dangerouslySkipPermissions}function HB(e){let t=k.get(e.id)?.card;t&&VB(t,e)?UB(e.id,e.name,e.state,e,e.linkedPrs):(BC(e.id,e.state,e.stateSince),wn(e.id,!!e.saneYolo),un(e.id,e.isQuestionManagerOn),t&&t.dataset.session!==e.name&&FC(e.id,e.name),OC(e.id,e.isWorktree))}function UB(e,t,n,r,i){let a=k.get(e),o=Li()===e;xa(e,null),IC(e),Ky(e),vn(e),T_(e,i),TC(e,t,n,jB(r)),o&&Oi(e),GB(e,a)}function WB(){tC([...k].map(([e,t])=>({id:e,name:Kn(t)||e})))}function GB(e,t){Nx(e,t?.hasPlan===!0),jC(e,t?.unseenOutcome)}var KB=new Set([E.DONE,E.FAILED]);function qB(e,t){return e!==void 0&&KB.has(e)&&!KB.has(t)&&t!==E.DORMANT}function JB(e){let t=k.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;IC(e.id),TC(e.id,e.session,E.DORMANT,jB({skipPerms:i,saneYolo:a,isQuestionManagerOn:e.isQuestionManagerOn??nn(r),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})),DC(e.id,t?.agent),GB(e.id,t)}function YB(e,t){let n=k.get(String(e.id))?.currentState;t.to===E.DORMANT&&n!==E.DORMANT?(JB(e),Wy(e.id)):(BC(e.id,t.to,e.timestamp),Pn(e.id,e.failureReason),e.saneYolo!==void 0&&wn(e.id,e.saneYolo),Wy(e.id),qB(n,t.to)&&fu(e.id))}function XB(e){if(yC(e.id))e.transition&&YB(e,e.transition),e.activeAgents!==void 0&&kC(e.id,e.activeAgents,e.awaitingBackgroundTasks),e.unseenOutcome!==void 0&&jC(e.id,e.unseenOutcome),e.pendingPromptKind!==void 0&&AC(e.id,e.pendingPromptKind),e.managerSeenSeq!==void 0&&mn(e.id,e.managerSeenSeq),e.isQuestionManagerOn!==void 0&&un(e.id,e.isQuestionManagerOn),e.unseenOutcome!==void 0&&wC(),kB(j.counts),Wi(e.id),hb(e.id);else{if(!e.transition)return;TC(e.id,e.session,e.transition.to,jB({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),kB(j.counts),Pp()}}function ZB(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 QB=`Secrets agents may read from your vault, per project. Revoking one makes the next request ask again.`,$B=null,eV=null;function tV(e,t){let n=D(`article`,`settings-view-setting`),r=D(`div`,`settings-view-setting-text`),i=D(`div`,`settings-view-setting-heading`);i.append(D(`h2`,`settings-view-setting-title`,t.name)),r.append(i,D(`p`,`settings-view-setting-description`,t.isAllowed?`Reads ${t.reference??`no reference yet`}`:`Denied`));let a=D(`div`,`settings-view-setting-control`);return a.append(w({variant:`secondary`,label:`Revoke`,action:`secret-revoke`,onClick:()=>{s({type:`secret-revoke`,project:e,name:t.name})}})),n.append(r,a),n}function nV(e){return[D(`h2`,`settings-view-subsection-title`,e.project),...e.approvals.map(t=>tV(e.project,t))]}function rV(){let e=D(`p`,`settings-view-section-description`,QB);return $B?$B.length===0?[e,D(`p`,`settings-view-setting-description`,`No approvals yet. An agent that runs glimmervoid need asks on its session card first.`)]:[e,...$B.flatMap(nV)]:[e,D(`p`,`settings-view-setting-description`,`Waiting for the server to list approvals.`)]}function iV(){eV?.isConnected&&eV.replaceChildren(...rV())}function aV(e){$B=e.projects,iV()}function oV(e){eV=D(`div`,`settings-view-stack`),e.appendChild(eV),iV()}var sV={"session-trace-response":e=>nC(e),"session-trace-changed":e=>rC(e),"session-plan-changed":e=>{Px(e),MB()},"session-plan-draft":e=>{Fx(e)},"session-plan-response":e=>{Ix(e)},"session-docs-changed":e=>Nv(e),"session-docs-snapshot":e=>Pv(e),"session-secret-request":e=>xv(e),"secret-requests-snapshot":e=>Sv(e),"secret-approvals":e=>aV(e),"session-manager-decision":e=>{Nn(e.id,e.decision),NB()},"session-coherence-hooks":e=>{xa(e.id,e.coherenceHooks),NB()},"session-coherence":e=>{Ca(e),NB()},"session-coherence-snapshot":e=>{wa(e),NB()},"session-coherence-journal-response":e=>ka(e)},cV={"team-review-status":e=>kg(e),"github-prs":e=>Vp(e),"my-prs-status":ph,"pr-flows-status":mh,"packs-status":NI,"my-pr-merge-result":e=>hh(e),"team-review-action-result":e=>Ag(e),"open-team-review-session-result":e=>jg(e),"issues-status":e=>Ip(e),"issue-detail-result":e=>Lp(e),"open-issue-session-result":e=>Rp(e),"set-issue-state-result":e=>Ep(e)},lV={"radar-status":e=>SF(e),"radar-investigation-activity":e=>CF(e),"radar-investigation-finished":e=>wF(e),"community-status":e=>qF(e),"benchmark-status":e=>ua(e),"benchmark-action-result":e=>da(e),"race-status":e=>Pk(e),"race-history":e=>Ik(e),"usage-sessions":e=>BD(e),"usage-report":e=>{HD(e),qP()},"plan-limits":e=>VD(e),"usage-budget-alert":e=>ex({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0})},uV=3e3,dV=null,fV=null,pV=ar(`settings-hosts-status`);function mV(e){let t=e.hostVersion?`, build ${e.hostVersion}`:``;return`${e.sshTarget} port ${e.dashboardPort}: ${Us(e)}${t}`}async function hV(e){let t=await ir(`remove-host`,{id:e.id},pV,{busyText:`Removing ${e.name}.`});t?.type===`host-change-result`&&(t.ok?pV.show(`ok`,`Removed ${e.name}. Its sessions keep running there.`):pV.show(`error`,`Not removed: ${t.error??`the server refused the change.`}`))}function gV(e){Xt({title:`Remove ${e.name}?`,message:`This dashboard stops linking the host and its sessions leave the sidebar. They keep running on the host.`,confirmLabel:`Remove`,danger:!0,onConfirm:()=>{hV(e)}})}function _V(e){let t=D(`div`,`settings-host-row`);t.dataset.state=e.state;let n=D(`div`,`settings-readonly`);return n.append(D(`span`,`settings-host-name`,`${e.name} (${e.id})`),D(`span`,null,mV(e))),t.append(n,w({variant:`secondary`,label:`Remove`,action:`remove-host`,onClick:()=>gV(e)})),t}function vV(){if(!dV)return;let e=Hs();e.length===0?dV.replaceChildren(D(`div`,`settings-readonly`,`No hosts linked yet. Add one below.`)):dV.replaceChildren(...e.map(_V))}function yV(e,t,n){let r=D(`label`,`settings-host-field`),i=D(`input`,`settings-view-input`);return i.type=t===`dashboardPort`?`number`:`text`,i.name=t,i.placeholder=n,i.autocomplete=`off`,i.spellcheck=!1,r.append(D(`span`,null,e),i),{field:r,input:i}}async function bV(e,t,n){let r=e.id.value.trim(),i={id:r,name:e.name.value.trim()||r,sshTarget:e.sshTarget.value.trim(),dashboardPort:e.dashboardPort.value.trim()?Number(e.dashboardPort.value):uV};t.disabled=!0;let a=await ir(`add-host`,{host:i},n,{busyText:`Adding ${i.name}.`});if(t.disabled=!1,a?.type===`host-change-result`){if(!a.ok)n.show(`error`,`Not added: ${a.error??`the server refused the change.`}`);else{for(let t of Object.values(e))t.value=``;n.show(`ok`,`Added ${i.name}. Linking now; its state shows above.`)}}}function xV(){let e=D(`form`,`settings-host-form`),t=yV(`Id`,`id`,`devbox`),n=yV(`Name`,`name`,`Same as the id`),r=yV(`Ssh target`,`sshTarget`,`me@devbox or a ~/.ssh/config alias`),i=yV(`Dashboard port`,`dashboardPort`,String(uV)),a=ar(`settings-hosts-status`),o=w({variant:`secondary`,label:`Add host`,action:`add-host`});o.type=`submit`,e.addEventListener(`submit`,e=>{e.preventDefault(),bV({id:t.input,name:n.input,sshTarget:r.input,dashboardPort:i.input},o,a)});let s=D(`div`,`settings-telegram-test`);s.append(o,a.element);let c=D(`div`,`settings-host-fields`);return c.append(t.field,n.field,r.field,i.field),e.append(c,s),e}function SV(){let e=D(`div`,`settings-view-status-block settings-hosts`);return dV=D(`div`,`settings-host-list`),vV(),fV??=xV(),e.append(dV,pV.element,fV),e}function CV(){dV?.isConnected&&vV()}var wV=new Map,TV=()=>{},EV={connect:()=>{},abandon:()=>{},reconnectNow:()=>{},send:()=>!1,request:()=>Promise.reject(Error(S))};function DV(e){return typeof e.id==`string`?e.id:typeof e.sessionId==`string`?e.sessionId:null}f(e=>{let t=DV(e),n=t?Gs(t):null;return n?wV.get(n)??EV:null},()=>[...wV.values()]);function OV(e,t,n,r){return(wV.get(e)??EV).request(t,n,r)}function kV(e){TV=e}function AV(e){let t=g({pathPrefix:`/hosts/${encodeURIComponent(e)}`,isLocal:!1,onMessage:t=>{t.type===`session-added`&&Ks(t.id,e),TV(e,t)}});return t.connect(),t}function jV(e){let t=new Set(e.filter(e=>e.state===`connected`).map(e=>e.id)),n=[];for(let[e,r]of[...wV])t.has(e)||(r.abandon(),wV.delete(e),n.push(e));for(let e of t)wV.has(e)||wV.set(e,AV(e));return n}var MV={snapshot:e=>{IB(e.serverBuild),BB(e.sessions)},"hooks-report":e=>iv(e),"save-hook-result":()=>av(),"delete-hook-result":()=>av(),"update-status":e=>{uz(e),YP(e)},"update-progress":e=>XP(e.journal),"post-turn-leftovers":e=>fz(e),"feature-hint":e=>vz(e.hint),"star-hint":()=>yz(),error:e=>{let t=ZP(e),n=iC(e),r=Lx(e);t||n||r||(e.id?xn(e.id,e.message):sr({source:uB,message:e.message}))},"settings-updated":e=>{e.settings&&Sz(e.settings),bk()},"agent-logins":e=>cP(e.logins),"health-snapshot":e=>{e.stats&&K_(e.stats)},"client-trust":e=>CL(e.trust),"shutting-down":()=>iB(`Shutting down...`,`Shutting down sessions...`),restarting:()=>iB(`Restarting...`,`Restarting server...`),"hosts-status":e=>{Vs(e.hosts),CV();for(let t of jV(e.hosts))RB(t);NB()}},NV={"session-status":e=>XB(e),"session-added":e=>{T_(e.id,e.linkedPrs),yC(e.id)||(TC(e.id,e.session,e.state,jB(e)),DC(e.id,e.agent)),kB(j.counts),NB(),WB()},"session-close-confirm":e=>{Fi(e.id)},"session-removed":e=>{LB(e.id),kB(j.counts),NB(),WB()},"session-title":e=>{vC(e.id,e.taskTitle,e.isCustom),NB()},"session-prs":e=>T_(e.id,e.linkedPrs),"session-renamed":e=>{FC(e.id,e.newName),NB(),WB()},"session-modified":e=>{UB(e.id,e.session,e.state,e,e.linkedPrs),DC(e.id,e.agent),kB(j.counts),NB(),WB()},"session-git":e=>OC(e.id,!!e.worktree),"session-merge-status":e=>{NC(e.id,e.mergeStatus,e.reason),YN(e.id,e.mergeStatus),MB()},"debug-state-response":e=>mb(e),"session-setup-response":e=>GC(e),notify:e=>{$b(e),hb(e.session)},"session-error":e=>{Gy(e.id),Lx(e)||xn(e.id,e.message)}},PV=16,FV=new WeakMap;function IV(e){return e?.kind===`box`?Ct(e)?.asset??null:null}function LV(e,t,n){if(t===null)return;let r=(e.assetRefCount.get(t)??0)+n;r>0?e.assetRefCount.set(t,r):e.assetRefCount.delete(t)}function RV(e){return e.kind===`box`?e.near?[e.near.of]:[]:e.kind===`wire`?[e.from,e.to]:e.kind===`note`?[e.on]:e.kind===`frame`?e.contains:[]}function zV(e,t,n){t.kind===`box`&&t.step!==null&&(n?e.stepBoxIds.add(t.id):e.stepBoxIds.delete(t.id))}function BV(e){return e.kind===`note`?e.ref!==null:e.kind===`box`&&(e.refs.length>0||St(e).some(e=>e.ref!==null))}function VV(e,t){BV(t)?e.anchoredIds.add(t.id):e.anchoredIds.delete(t.id)}function HV(e,t,n){for(let r of new Set(RV(t))){let i=e.dependentIdsByBoxId.get(r);i?i instanceof Set?i.add(t.id):i.length<PV?e.dependentIdsByBoxId.set(r,i.concat(t.id)):e.dependentIdsByBoxId.set(r,new Set([...i,t.id])):e.dependentIdsByBoxId.set(n.storedIdOf(r)??r,[t.id])}}function UV(e,t){for(let n of new Set(RV(t))){let r=e.dependentIdsByBoxId.get(n);r instanceof Set?(r.delete(t.id),r.size===0&&e.dependentIdsByBoxId.delete(n)):r?.includes(t.id)&&(r.length===1?e.dependentIdsByBoxId.delete(n):e.dependentIdsByBoxId.set(n,r.filter(e=>e!==t.id)))}}function WV(e,t){return{...t,id:e.storedIdOf(t.id)??t.id}}function GV(e,t,n){e.elementCount+=1,LV(e,IV(t),1),HV(e,t,n),zV(e,t,!0),VV(e,t)}function KV(e,t){--e.elementCount,LV(e,IV(t),-1),UV(e,t),zV(e,t,!1),e.anchoredIds.delete(t.id)}function qV(e){let t=FV.get(e);if(t)return t;let n={elementCount:0,assetRefCount:new Map,dependentIdsByBoxId:new Map,stepBoxIds:new Set,anchoredIds:new Set};for(let t of e.values())GV(n,t,e);return FV.set(e,n),n}function JV(e){return{elementCount:e.elementCount,assetRefCount:new Map(e.assetRefCount),dependentIdsByBoxId:new Map([...e.dependentIdsByBoxId].map(([e,t])=>[e,t instanceof Set?new Set(t):t])),stepBoxIds:new Set(e.stepBoxIds),anchoredIds:new Set(e.anchoredIds)}}function YV(e){let t=e.copy(),n=FV.get(e);return n&&FV.set(t,JV(n)),t}function XV(e,t){let n=FV.get(e),r=e.get(t.id);if(e.put(t),!n)return;let i=WV(e,t);r?(LV(n,IV(r),-1),LV(n,IV(t),1),UV(n,r),HV(n,i,e),zV(n,r,!1),zV(n,i,!0),VV(n,i)):GV(n,i,e)}function ZV(e,t){QV(e,t.id),XV(e,t)}function QV(e,t){let n=e.get(t);if(!n)return;e.remove(t);let r=FV.get(e);r&&KV(r,n)}var $V=26,eH=97;function tH(e){return e.step!==null}function nH(e){return[...qV(e.elements).stepBoxIds].flatMap(t=>{let n=e.elements.get(t);return n?.kind===`box`&&tH(n)?[n]:[]})}function rH(e,t,n){return[...qV(e.elements).dependentIdsByBoxId.get(t)??[]].flatMap(r=>{let i=e.elements.get(r);return i?.kind===`wire`&&i.to===t&&i.from!==t&&n.has(i.from)?[i]:[]})}function iH(e,t){let n=new Map;for(let r of t){let i=rH(e,r,t).map(e=>e.from);i.length>0&&n.set(r,i)}return n}function aH(e){let t=String.fromCharCode(eH+e%$V),n=Math.floor(e/$V);return n===0?t:`${t}${n+1}`}function oH(e,t){let n=new Map,r=new Set;function i(e){let a=n.get(e);if(a!==void 0)return a;if(r.has(e))return 0;r.add(e);let o=1+Math.max(0,...(t.get(e)??[]).map(i));return r.delete(e),n.set(e,o),o}for(let t of e)i(t);return n}function sH(e){let t=nH(e),n=iH(e,new Set(t.map(e=>e.id))),r=oH(t.map(e=>e.id),n),i=new Map;for(let e of t){let t=r.get(e.id)??1;i.set(t,[...i.get(t)??[],e])}let a=new Map,o=[];for(let e of[...i.keys()].sort((e,t)=>e-t)){let t=(i.get(e)??[]).sort((e,t)=>e.title.localeCompare(t.title)||e.id.localeCompare(t.id));for(let[n,r]of t.entries())a.set(r.id,t.length===1?String(e):`${e}${aH(n)}`),o.push(r)}return o.map(e=>({boxId:e.id,title:e.title,status:e.step.status,level:r.get(e.id)??1,label:a.get(e.id)??``,afterLabels:(n.get(e.id)??[]).flatMap(e=>a.get(e)??[]),linkedBoardId:e.step.linkedBoardId}))}function cH(e){let t=lH(e.length);return e.forEach((e,n)=>{uH(t,n,e.x,e.y,e.x+e.width,e.y+e.height)}),t}function lH(e){return{count:e,lefts:new Float64Array(e),tops:new Float64Array(e),rights:new Float64Array(e),bottoms:new Float64Array(e)}}function uH(e,t,n,r,i,a){e.lefts[t]=Math.min(n,i),e.rights[t]=Math.max(n,i),e.tops[t]=Math.min(r,a),e.bottoms[t]=Math.max(r,a)}function dH(e){e.sort();let t=0;for(let n=0;n<e.length;n+=1){let r=e[n]??0;t>0&&e[t-1]===r||(e[t]=r,t+=1)}return e.subarray(0,t)}function fH(e){let t=e.reduce((e,t)=>e+t.count*2,0),n=new Float64Array(t),r=0;for(let t of e)n.set(t.tops,r),n.set(t.bottoms,r+t.count),r+=t.count*2;return dH(n)}function pH(e,t){let n=0,r=e.length-1;for(;n<r;){let i=n+r>>1;(e[i]??0)<t?n=i+1:r=i}return n}function mH(e){let t=1;for(;t<e;)t*=2;return t}function hH(e,t,n){let r=0;for(let i of e)t[i]===1&&(e[r]=i,r+=1,n&&n(i));e.length=r}function gH(e,t){let n=mH(t.length),r=new Int32Array(e.count),i=new Int32Array(e.count);for(let n=0;n<e.count;n+=1)r[n]=pH(t,e.tops[n]??0),i[n]=pH(t,e.bottoms[n]??0);let a=new Uint8Array(e.count),o=Array.from({length:n*2},()=>[]),s=Array.from({length:n},()=>[]),c=new Int32Array(n*2),l=(e,t)=>{for(let r=e+n;r>=1;r>>=1)c[r]=(c[r]??0)+t},u=e=>{a[e]=1;let t=r[e]??0,c=t+n,u=(i[e]??0)+n+1;for(;c<u;)c&1&&(o[c]?.push(e),c+=1),u&1&&(--u,o[u]?.push(e)),c>>=1,u>>=1;s[t]?.push(e),l(t,1)},d=e=>{a[e]===1&&(a[e]=0,l(r[e]??0,-1))},f=(e,t,r,i,o,l)=>{if((c[e]??0)===0||r<i||t>o)return;if(e>=n){hH(s[e-n]??[],a,l);return}let u=t+r>>1;f(e*2,t,u,i,o,l),f(e*2+1,u+1,r,i,o,l)};return{insert:u,remove:d,forEachMeeting:(e,r,i)=>{let s=pH(t,e);for(let e=s+n;e>=1;e>>=1)hH(o[e]??[],a,i);let c=pH(t,r);c>s&&f(1,0,n-1,s+1,c,i)}}}function _H(e){let t=new Int32Array(e.length);for(let e=0;e<t.length;e+=1)t[e]=e;return t.sort((t,n)=>(e[t]??0)-(e[n]??0))}function vH(e){let t=fH(e);return e.map(e=>({rects:e,index:gH(e,t),closingOrder:_H(e.rights),nextClosing:0}))}function yH(e,t){for(;e.nextClosing<e.closingOrder.length;){let n=e.closingOrder[e.nextClosing]??0;if((e.rects.rights[n]??0)>=t)return;e.index.remove(n),e.nextClosing+=1}}function bH(e,t){let[n]=vH([e]);if(n)for(let r of _H(e.lefts))yH(n,e.lefts[r]??0),n.index.forEachMeeting(e.tops[r]??0,e.bottoms[r]??0,e=>t(e,r)),n.index.insert(r)}function xH(e,t,n){let[r,i]=vH([e,t]);if(!r||!i)return;let a=_H(e.lefts),o=_H(t.lefts),s=0,c=0;for(;s<a.length||c<o.length;){let l=a[s]??-1,u=o[c]??-1,d=u<0||l>=0&&(e.lefts[l]??0)<=(t.lefts[u]??0),f=d?e.lefts[l]??0:t.lefts[u]??0;yH(r,f),yH(i,f),d?(i.index.forEachMeeting(e.tops[l]??0,e.bottoms[l]??0,e=>n(l,e)),r.index.insert(l),s+=1):(r.index.forEachMeeting(t.tops[u]??0,t.bottoms[u]??0,e=>n(e,u)),i.index.insert(u),c+=1)}}function SH(e,t,n){let r=new Int32Array(t+1);for(let t of n)r[(e[t]??0)+1]=(r[(e[t]??0)+1]??0)+1;for(let e=0;e<t;e+=1)r[e+1]=(r[e+1]??0)+(r[e]??0);let i=new Int32Array(n.length);for(let t of n){let n=e[t]??0;i[r[n]??0]=t,r[n]=(r[n]??0)+1}return i}function CH(e,t,n,r){let i=new Int32Array(e.length);for(let e=0;e<i.length;e+=1)i[e]=e;return SH(Int32Array.from(e),n,SH(Int32Array.from(t),r,i))}function wH(e,t,n,r){return Array.from(CH(e,t,n,r),n=>[e[n]??0,t[n]??0])}function TH(e){let t=[],n=[];return bH(cH(e),(e,r)=>{t.push(Math.min(e,r)),n.push(Math.max(e,r))}),wH(t,n,e.length,e.length)}var EH=10,DH=4,OH=14,kH=2,AH=160;function jH(e,t){return t?e.y:e.x}function MH(e,t){return t?e.x:e.y}function NH(e,t){let n=[];return e.forEach((e,r)=>{for(let i=0;i+1<e.length;i+=1){let a=e[i],o=e[i+1];if(!a||!o||jH(a,t)!==jH(o,t)||MH(a,t)===MH(o,t))continue;let s=i===0||i+2===e.length;n.push({wire:r,index:i,line:jH(a,t),low:Math.min(MH(a,t),MH(o,t)),high:Math.max(MH(a,t),MH(o,t)),isFixed:s})}}),n.sort((e,t)=>e.line-t.line||e.low-t.low)}function PH(e,t){let n=[],r=new Map,i=new Map,a=new Map;for(let o of e){let e=t[o.wire];if(!e)continue;let s=r.get(o.wire)??i.get(e.exitKey)??(e.busKey===null?void 0:a.get(e.busKey)),c=s??{members:[],low:o.low,high:o.high,isPinned:!1,offset:0};s||n.push(c),c.members.push(o),c.low=Math.min(c.low,o.low),c.high=Math.max(c.high,o.high),c.isPinned||=o.isFixed,r.set(o.wire,c),i.has(e.exitKey)||i.set(e.exitKey,c),e.busKey!==null&&!a.has(e.busKey)&&a.set(e.busKey,c)}return n}function FH(e,t){let n=[],r=0;for(;r<e.length;){let i=e[r];if(!i)break;let a=r+1,o=i.high;for(;a<e.length;a+=1){let t=e[a];if(!t||t.line!==i.line||t.low>o)break;o=Math.max(o,t.high)}let s=e.slice(r,a);if(r=a,s.length<2)continue;let c=PH(s,t);c.length>1&&n.push({line:i.line,low:i.low,high:o,bundles:c})}return n}function IH(e,t,n,r){let i=e[t.index],a=e[t.index+1];if(!i||!a)return 0;let o=MH(i,r)<MH(a,r)===n?e[t.index-1]:e[t.index+2];return o?Math.sign(jH(o,r)-t.line):0}function LH(e,t,n,r){let i=n[e.wire]??[],a=n[t.wire]??[],o=IH(i,e,!0,r),s=IH(a,t,!0,r);if(o!==0&&s!==0&&o!==s)return o;if(o!==0&&o===s&&e.low!==t.low)return o<0?t.low-e.low:e.low-t.low;let c=IH(i,e,!1,r),l=IH(a,t,!1,r);return c!==0&&l!==0&&c!==l?c:c!==0&&c===l&&e.high!==t.high?c<0?e.high-t.high:t.high-e.high:e.wire-t.wire}function RH(e,t){let n=e.pending[t]??-1;if(!(n<0)){for(let r of[t*2,t*2+1])e.maxima[r]=n,e.pending[r]=n;e.pending[t]=-1}}function zH(e,t,n,r,i,a){if(a<n||r<i)return-1;if(i<=n&&r<=a)return e.maxima[t]??-1;RH(e,t);let o=n+r>>1;return Math.max(zH(e,t*2,n,o,i,a),zH(e,t*2+1,o+1,r,i,a))}function BH(e,t,n,r,i,a,o){if(a<n||r<i)return;if(i<=n&&r<=a){e.maxima[t]=o,e.pending[t]=o;return}RH(e,t);let s=n+r>>1;BH(e,t*2,n,s,i,a,o),BH(e,t*2+1,s+1,r,i,a,o),e.maxima[t]=Math.max(e.maxima[t*2]??-1,e.maxima[t*2+1]??-1)}function VH(e,t){let n=0,r=e.length-1;for(;n<r;){let i=n+r>>1;(e[i]??0)<t&&(n=i+1),(e[i]??0)>=t&&(r=i)}return n}function HH(e){let t=dH(Float64Array.from(e.flatMap(e=>[e.low,e.high]))),n=t.length,r={maxima:new Int32Array(n*4).fill(-1),pending:new Int32Array(n*4).fill(-1)},i=0;for(let a of e){let e=VH(t,a.low),o=VH(t,a.high);a.offset=zH(r,1,0,n-1,e,o)+1,BH(r,1,0,n-1,e,o,a.offset),i=Math.max(i,a.offset+1)}return i}function UH(e){let t=new Set(e.flatMap(e=>e.isPinned?[e.offset]:[]));if(t.size>1)return;let[n]=t;return n??null}function WH(e,t,n,r){let i=t*EH+DH+OH,a=r?{x:e.low,y:e.line-AH,width:e.high-e.low,height:320}:{x:e.line-AH,y:e.low,width:320,height:e.high-e.low},o=e.line-AH,s=e.line+AH,c=!1,l=!1;for(let t of n(a)){let n=r?t.x:t.y,i=n+(r?t.width:t.height);if(n>=e.high||i<=e.low)continue;let a=r?t.y:t.x,u=a+(r?t.height:t.width);u<=e.line&&u+DH>o&&(o=u+DH,c=!0),a>=e.line&&a-DH<s&&(s=a-DH,l=!0)}let u=c&&l;return u?{low:o,high:s,isBetweenObstacles:u}:{low:Math.max(o,e.line-i),high:Math.min(s,e.line+i),isBetweenObstacles:u}}function GH(e,t,n,r){if(n!==null){let i=n>0?(e-r.low)/n:1/0,a=t-1-n>0?(r.high-e)/(t-1-n):1/0,o=Math.min(EH,i,a);return o<kH?null:{firstTrack:e-n*o,spacing:o}}let i=Math.min(EH,(r.high-r.low)/(t-1));if(i<kH)return null;let a=(t-1)*i,o=r.isBetweenObstacles?(r.low+r.high)/2:e;return{firstTrack:Math.max(r.low,Math.min(o-a/2,r.high-a)),spacing:i}}function KH(e,t,n,r){for(let i of e.members){let e=n[i.wire]??[];for(let n of[i.index,i.index+1]){let i=e[n];i&&(e[n]=r?{x:i.x,y:t}:{x:t,y:i.y})}}}function qH(e,t,n,r){return e.members.every(e=>{let i=n[e.wire];if(!i||!e.isFixed)return!0;let a=e.index===0,o=e.index+2===(r[e.wire]?.length??0),s=!a||t>=i.startSlack.low&&t<=i.startSlack.high,c=!o||t>=i.endSlack.low&&t<=i.endSlack.high;return s&&c})}function JH(e,t,n,r){let i=FH(NH(t,r),e),a=i.map(e=>(e.bundles.sort((e,n)=>{let[i]=e.members,[a]=n.members;return i&&a?LH(i,a,t,r):0}),HH(e.bundles)));i.forEach((i,o)=>{let s=a[o]??1;if(s<2)return;let c=UH(i.bundles),l=WH(i,s,n,r),u=GH(i.line,s,c??null,l);if(!u)return;let d=e=>Math.round(u.firstTrack+e.offset*u.spacing);if(c!==void 0||i.bundles.every(n=>qH(n,d(n),e,t)))for(let e of i.bundles)KH(e,d(e),t,r)})}function YH(e,t){let n=e.map(e=>e.points.map(e=>({x:e.x,y:e.y})));return JH(e,n,t,!0),JH(e,n,t,!1),n}var XH=1<<20,ZH=1<<21,QH=64,$H=256;function eU(e,t=QH){let n=Math.max(1,t);return{cellSize:e,slotsByCell:new Map,minX:new Float64Array(n),minY:new Float64Array(n),maxX:new Float64Array(n),maxY:new Float64Array(n),isStored:new Uint8Array(n),visitStamp:new Uint32Array(n),currentStamp:0,oversizedSlots:new Set}}function tU(e,t,n){let r=n(t);return r.set(e),r}function nU(e,t){if(t<e.minX.length)return;let n=Math.max(t+1,e.minX.length*2);e.minX=tU(e.minX,n,e=>new Float64Array(e)),e.minY=tU(e.minY,n,e=>new Float64Array(e)),e.maxX=tU(e.maxX,n,e=>new Float64Array(e)),e.maxY=tU(e.maxY,n,e=>new Float64Array(e)),e.isStored=tU(e.isStored,n,e=>new Uint8Array(e)),e.visitStamp=tU(e.visitStamp,n,e=>new Uint32Array(e))}function rU(e,t){return Math.floor(t/e.cellSize)}function iU(e,t){return(e+XH)*ZH+(t+XH)}function aU(e,t,n,r,i){return(rU(e,r)-rU(e,t)+1)*(rU(e,i)-rU(e,n)+1)}function oU(e,t,n,r,i){return!(aU(e,t,n,r,i)<=$H)}function sU(e,t,n,r,i,a){let o=rU(e,t),s=rU(e,r),c=rU(e,n),l=rU(e,i);for(let e=o;e<=s;e+=1)for(let t=c;t<=l;t+=1)a(iU(e,t))}function cU(e,t){t>=e.isStored.length||e.isStored[t]===0||(e.isStored[t]=0,e.oversizedSlots.delete(t)||sU(e,e.minX[t]??0,e.minY[t]??0,e.maxX[t]??0,e.maxY[t]??0,n=>{let r=e.slotsByCell.get(n);if(!r)return;let i=r.indexOf(t);i!==-1&&(r[i]=r[r.length-1]??t,r.pop(),r.length===0&&e.slotsByCell.delete(n))}))}function lU(e,t,n){cU(e,t),nU(e,t),e.minX[t]=n.x,e.minY[t]=n.y,e.maxX[t]=n.x+n.width,e.maxY[t]=n.y+n.height,e.isStored[t]=1,oU(e,n.x,n.y,n.x+n.width,n.y+n.height)?e.oversizedSlots.add(t):sU(e,n.x,n.y,n.x+n.width,n.y+n.height,n=>{let r=e.slotsByCell.get(n);r?r.push(t):e.slotsByCell.set(n,[t])})}function uU(e){return e.currentStamp+=1,e.currentStamp<4294967295||(e.visitStamp.fill(0),e.currentStamp=1),e.currentStamp}function dU(e,t,n){return(e.minX[t]??0)<=n.x+n.width&&n.x<=(e.maxX[t]??0)&&(e.minY[t]??0)<=n.y+n.height&&n.y<=(e.maxY[t]??0)}function fU(e,t,n){for(let r=0;r<e.isStored.length;r+=1)if(e.isStored[r]===1&&dU(e,r,t)&&n(r)===!0)return}function pU(e,t,n){let r=t.x+t.width,i=t.y+t.height;if(oU(e,t.x,t.y,r,i)){fU(e,t,n);return}let a=uU(e);for(let r of e.oversizedSlots)if(e.visitStamp[r]=a,dU(e,r,t)&&n(r)===!0)return;let o=rU(e,t.x),s=rU(e,r),c=rU(e,t.y),l=rU(e,i);for(let r=o;r<=s;r+=1)for(let i=c;i<=l;i+=1){let o=e.slotsByCell.get(iU(r,i));if(o){for(let r of o)if(e.visitStamp[r]!==a&&(e.visitStamp[r]=a,dU(e,r,t)&&n(r)===!0))return}}}function mU(e,t,n=()=>!0){let r=!1;return pU(e,t,e=>n(e)?(r=!0,!0):!1),r}function hU(e,t){let n=eU(t,e.length);for(let[t,r]of e.entries())lU(n,t,r);return n}var gU=1,_U=42,vU=42,yU=4,J=0,Y=1,bU=2,xU=3,SU=1024,CU=32,wU=-2,TU=1,EU=2,DU=-1;function OU(){return{values:new Float64Array(64),length:0}}function kU(e,t){if(e.length===e.values.length){let t=new Float64Array(e.values.length*2);t.set(e.values),e.values=t}e.values[e.length]=t,e.length+=1}function AU(e){return e.values.subarray(0,e.length)}function jU(){return{lines:OU(),starts:OU(),ends:OU()}}function MU(e,t,n,r){r<n||(kU(e.lines,t),kU(e.starts,n),kU(e.ends,r))}function X(){return{alongs:OU(),acrosses:OU()}}function NU(e,t,n){return kU(e.alongs,t),kU(e.acrosses,n),e.alongs.length-1}function PU(e,t){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let t of[...e.hardRects,...e.softRects])n=Math.min(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.x+t.width),a=Math.max(a,t.y+t.height);for(let e of t)n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x),a=Math.max(a,e.y);if(n===1/0)return null;let o=e.contentTop+yU;return{left:Math.round(n-_U),top:Math.max(Math.round(r-_U),o),right:Math.round(i+_U),bottom:Math.round(a+_U)}}function FU(e){let t=lH(e.length);return e.forEach((e,n)=>{uH(t,n,e.x-gU,e.y-gU,e.x+e.width+gU,e.y+e.height+gU)}),t}function IU(e,t){return t===J?{starts:e.lefts,lows:e.tops,highs:e.bottoms}:t===Y?{starts:e.rights.map(e=>-e),lows:e.tops,highs:e.bottoms}:t===bU?{starts:e.tops,lows:e.lefts,highs:e.rights}:{starts:e.bottoms.map(e=>-e),lows:e.lefts,highs:e.rights}}function LU(e){let t=new Int32Array(e.length);for(let e=0;e<t.length;e+=1)t[e]=e;return t.sort((t,n)=>(e[n]??0)-(e[t]??0))}function RU(e,t,n){let r=t===J||t===Y,i=r?e.tops:e.lefts,a=r?e.bottoms:e.rights,o=Float64Array.from(n).sort(),s=[];for(let t=0;t<e.count;t+=1){let e=aW(o,0,o.length,i[t]??0);e<o.length&&(o[e]??0)<=(a[t]??0)&&s.push(t)}let c=lH(s.length);return s.forEach((t,n)=>{uH(c,n,e.lefts[t]??0,e.tops[t]??0,e.rights[t]??0,e.bottoms[t]??0)}),c}function zU(e,t,n){let r=IU(e,t),i=t===Y||t===xU,a=new Float64Array(n.alongs.length);for(let t=0;t<a.length;t+=1){let o=i?-(n.alongs.values[t]??0):n.alongs.values[t]??0,s=n.acrosses.values[t]??0,c=1/0;for(let t=0;t<e.count;t+=1){let e=r.starts[t]??0;e>=o&&e<c&&(r.lows[t]??0)<s&&s<(r.highs[t]??0)&&(c=e)}a[t]=i?-c:c}return a}function BU(e,t,n){if(n.alongs.length*e.count<=ZU)return zU(e,t,n);let r=n.alongs.length*XU<e.count?RU(e,t,AU(n.acrosses)):e,i=IU(r,t),a=t===Y||t===xU,o=AU(n.alongs).map(e=>a?-e:e),s=AU(n.acrosses),c=new Float64Array(r.count*2+s.length);c.set(i.lows,0),c.set(i.highs,r.count),c.set(s,r.count*2);let l=dH(c),u=mH(l.length),d=new Float64Array(u*2).fill(1/0),f=new Float64Array(o.length).fill(1/0),p=LU(i.starts),m=0;for(let e of LU(o)){let t=o[e]??0;for(;m<p.length;m+=1){let e=p[m]??0,n=i.starts[e]??0;if(n<t)break;let r=pH(l,i.lows[e]??0)+1+u,a=pH(l,i.highs[e]??0)+u;for(;r<a;)r&1&&(d[r]=Math.min(d[r]??1/0,n),r+=1),a&1&&(--a,d[a]=Math.min(d[a]??1/0,n)),r>>=1,a>>=1}let n=1/0;for(let t=pH(l,s[e]??0)+u;t>=1;t>>=1)n=Math.min(n,d[t]??1/0);f[e]=a?-n:n}return f}function VU(e,t,n){let r=new Uint8Array(t.length);for(let i=0;i<t.length;i+=1){let a=t[i]??0,o=n[i]??0;for(let t=0;t<e.count&&r[i]===0;t+=1)(e.lefts[t]??0)<a&&a<(e.rights[t]??0)&&(e.tops[t]??0)<o&&o<(e.bottoms[t]??0)&&(r[i]=1)}return r}function HU(e,t,n){if(t.length*e.count<=ZU)return VU(e,t,n);let r=new Uint8Array(t.length),i=lH(t.length);for(let e=0;e<t.length;e+=1)uH(i,e,t[e]??0,n[e]??0,t[e]??0,n[e]??0);return xH(i,e,(i,a)=>{let o=t[i]??0,s=n[i]??0;(e.lefts[a]??0)<o&&o<(e.rights[a]??0)&&(e.tops[a]??0)<s&&s<(e.bottoms[a]??0)&&(r[i]=1)}),r}function UU(e,t){let n={xs:OU(),ys:OU(),awayDirections:OU()};for(let r of e){let e=Math.round(r.x-14),i=Math.round(r.x+r.width+14),a=Math.max(Math.round(r.y-14),t.top),o=Math.round(r.y+r.height+14);for(let[t,r,s,c]of[[e,a,Y,xU],[i,a,J,xU],[e,o,Y,bU],[i,o,J,bU]])kU(n.xs,t),kU(n.ys,r),kU(n.awayDirections,s*4+c)}return n}function WU(e,t){return{rays:t,hits:t.map((t,n)=>BU(e,n,t))}}function GU(e,t,n){return t===J?Math.min(e,n.right):t===Y?Math.max(e,n.left):t===bU?Math.min(e,n.bottom):Math.max(e,n.top)}function KU(e,t,n){if(!Number.isFinite(t))return null;let r=n===J||n===bU?t+gU-14:t-gU+14;return Math.abs(r-e)<=vU?null:Math.round((e+r)/2)}function qU(e,t,n,r,i){let a=[];for(let e=0;e<i.count;e+=1)(i.tops[e]??0)<t&&t<(i.bottoms[e]??0)&&a.push([i.lefts[e]??0,i.rights[e]??0]);a.sort((e,t)=>e[0]-t[0]);let o=n;for(let[n,i]of a)n>o&&MU(e,t,o,Math.min(n,r)),o=Math.max(o,i);MU(e,t,o,r)}function JU(e,t){let n=jU(),r=jU(),i=[X(),X(),X(),X()],a=t.map(e=>{let t=e.outwardDirection===J||e.outwardDirection===Y;return NU(i[e.outwardDirection]??X(),t?e.x:e.y,t?e.y:e.x)}),o=WU(e.blockers,i);return t.forEach((t,i)=>{let s=GU(o.hits[t.outwardDirection]?.[a[i]??0]??1/0,t.outwardDirection,e.frame);t.outwardDirection===J||t.outwardDirection===Y?(MU(n,t.y,Math.min(t.x,s),Math.max(t.x,s)),MU(r,t.x,t.y,t.y)):(MU(r,t.x,Math.min(t.y,s),Math.max(t.y,s)),MU(n,t.y,t.x,t.x))}),{horizontal:n,vertical:r}}var YU=12,XU=4,ZU=4096;function QU(e,t){let n=UU([...e.hardRects,...e.softRects],t),r=n.xs.length;return{count:r,xs:AU(n.xs),ys:AU(n.ys),awayDirections:AU(n.awayDirections),rows:new Float64Array(r*YU).fill(NaN)}}function $U(e,t,n,r,i,a){let o=t*YU+n*3;e[o]=r,e[o+1]=i,e[o+2]=a}function eW(e,t,n,r){let i=Float64Array.from(t,t=>e.xs[t]??0),a=Float64Array.from(t,t=>e.ys[t]??0),o=HU(n,i,a),s=[X(),X(),X(),X()],c=new Int32Array(t.length*4).fill(-1);for(let e=0;e<t.length;e+=1){if(o[e]===1)continue;let t=i[e]??0,n=a[e]??0;for(let r=0;r<4;r+=1){let i=s[r];if(!i)continue;let a=r===J||r===Y;c[e*4+r]=NU(i,a?t:n,a?n:t)}}let l=WU(n,s),u=(e,t,n)=>GU(e.hits[t]?.[n]??1/0,t,r),d=[X(),X(),X(),X()],f=[],p=[];for(let n=0;n<t.length;n+=1){let s=t[n]??0;if(e.rows.fill(NaN,s*YU,(s+1)*YU),o[n]===1)continue;let m=i[n]??0,h=a[n]??0,g=e=>c[n*4+e]??-1;$U(e.rows,s,0,h,u(l,Y,g(Y)),u(l,J,g(J))),$U(e.rows,s,1,m,u(l,xU,g(xU)),u(l,bU,g(bU)));let _=e.awayDirections[s]??0,v=Math.floor(_/4),y=_%4,b=KU(m,l.hits[v]?.[g(v)]??1/0,v);b!==null&&f.push(s,NU(d[xU]??X(),h,b),NU(d[bU]??X(),h,b),b);let ee=KU(h,l.hits[y]?.[g(y)]??1/0,y);ee!==null&&ee>=r.top&&p.push(s,NU(d[Y]??X(),m,ee),NU(d[J]??X(),m,ee),ee)}let m=WU(n,d);for(let t=0;t<f.length;t+=4)$U(e.rows,f[t]??0,2,f[t+3]??0,u(m,xU,f[t+1]??0),u(m,bU,f[t+2]??0));for(let t=0;t<p.length;t+=4)$U(e.rows,p[t]??0,3,p[t+3]??0,u(m,Y,p[t+1]??0),u(m,J,p[t+2]??0))}function tW(e,t,n){let r=jU(),i=jU(),a=[r,i,i,r];for(let t=0;t<e.count;t+=1)for(let n=0;n<4;n+=1){let r=t*YU+n*3,i=e.rows[r]??NaN,o=a[n];!Number.isNaN(i)&&o&&MU(o,i,e.rows[r+1]??0,e.rows[r+2]??0)}return qU(r,t.top,t.left,t.right,n),MU(r,t.bottom,t.left,t.right),MU(i,t.left,t.top,t.bottom),MU(i,t.right,t.top,t.bottom),{horizontal:r,vertical:i}}function nW(e,t,n,r){let i=e.lines[t]??0,a=n.lines[r]??0;return i<a||i===a&&(e.starts[t]??0)<=(n.starts[r]??0)}function rW(e,t){if(t.count===0)return e;let n=e.count+t.count,r={lines:new Float64Array(n),starts:new Float64Array(n),ends:new Float64Array(n)},i=0,a=0,o=0;for(;a<e.count||o<t.count;){let n=o>=t.count||a<e.count&&nW(e,a,t,o),s=n?e:t,c=n?a:o;n&&(a+=1),n||(o+=1);let l=s.lines[c]??0,u=s.starts[c]??0,d=s.ends[c]??0,f=i-1;i>0&&r.lines[f]===l&&u<=(r.ends[f]??0)?r.ends[f]=Math.max(r.ends[f]??0,d):(r.lines[i]=l,r.starts[i]=u,r.ends[i]=d,i+=1)}return{count:i,lines:r.lines.subarray(0,i),starts:r.starts.subarray(0,i),ends:r.ends.subarray(0,i)}}function iW(e){let t=AU(e.lines),n=AU(e.starts),r=AU(e.ends),i=new Int32Array(t.length);for(let e=0;e<i.length;e+=1)i[e]=e;i.sort((e,r)=>(t[e]??0)-(t[r]??0)||(n[e]??0)-(n[r]??0));let a={lines:new Float64Array(t.length),starts:new Float64Array(t.length),ends:new Float64Array(t.length)},o=0;for(let e of i){let i=t[e]??0,s=n[e]??0,c=r[e]??0,l=o-1;o>0&&a.lines[l]===i&&s<=(a.ends[l]??0)?a.ends[l]=Math.max(a.ends[l]??0,c):(a.lines[o]=i,a.starts[o]=s,a.ends[o]=c,o+=1)}return{count:o,lines:a.lines.subarray(0,o),starts:a.starts.subarray(0,o),ends:a.ends.subarray(0,o)}}function aW(e,t,n,r){let i=t,a=n;for(;i<a;){let t=i+a>>1;(e[t]??0)<r?i=t+1:a=t}return i}function oW(e,t,n,r){let i=t,a=n;for(;i<a;){let t=i+a>>1;(e[t]??0)<=r?i=t+1:a=t}return i}function sW(e,t,n,r){let i=t+e,a=n+e+1;for(;i<a;)i&1&&(r(i),i+=1),a&1&&(--a,r(a)),i>>=1,a>>=1}function cW(e){for(let t=1;t<e.length;t+=1)e[t]=(e[t]??0)+(e[t-1]??0);return e}function lW(e){return dH(Float64Array.from(e.lines))}function uW(e,t){let n=mH(Math.max(t.length,1)),r=new Int32Array(e.count),i=new Int32Array(e.count),a=new Int32Array(n*2+1);for(let o=0;o<e.count;o+=1)r[o]=aW(t,0,t.length,e.starts[o]??0),i[o]=oW(t,0,t.length,e.ends[o]??0)-1,sW(n,r[o]??0,i[o]??-1,e=>{a[e+1]=(a[e+1]??0)+1});cW(a);let o=a.slice(),s=a[n*2]??0,c=new Float64Array(s),l=new Int32Array(s);for(let t=0;t<e.count;t+=1)sW(n,r[t]??0,i[t]??-1,n=>{let r=o[n]??0;c[r]=e.lines[t]??0,l[r]=t,o[n]=r+1});return{acrossValues:t,capacity:n,offsets:a,lines:c,pieces:l}}function dW(e,t,n,r){let i=aW(e.acrossValues,0,e.acrossValues.length,t);if(e.acrossValues[i]!==t)return-1;let a=-1,o=r?1/0:-1/0;for(let t=i+e.capacity;t>=1;t>>=1){let i=e.offsets[t]??0,s=e.offsets[t+1]??0,c=r?oW(e.lines,i,s,n):aW(e.lines,i,s,n)-1;if(c<i||c>=s)continue;let l=e.lines[c]??0;(r?l<o:l>o)&&(o=l,a=e.pieces[c]??-1)}return a}function fW(e,t){let n=Float64Array.from(e,e=>t?e.y:e.x),r=Float64Array.from(e,e=>t?e.y+e.height:e.x+e.width),i=Float64Array.from(e,e=>t?e.x:e.y),a=Float64Array.from(e,e=>t?e.x+e.width:e.y+e.height),o=new Float64Array(e.length*2);o.set(n,0),o.set(r,e.length);let s=dH(o),c=mH(Math.max(s.length*2-1,1)),l=e=>[aW(s,0,s.length,n[e]??0)*2+1,aW(s,0,s.length,r[e]??0)*2-1],u=new Int32Array(c*2+1),d=Int32Array.from(e.keys()).sort((e,t)=>(i[e]??0)-(i[t]??0));for(let e of d){let[t,n]=l(e);sW(c,t,n,e=>{u[e+1]=(u[e+1]??0)+1})}cW(u);let f=u.slice(),p=u[c*2]??0,m=new Float64Array(p),h=new Float64Array(p);for(let e of d){let[t,n]=l(e);sW(c,t,n,t=>{let n=f[t]??0,r=n===(u[t]??0);m[n]=i[e]??0,h[n]=r?a[e]??0:Math.max(h[n-1]??0,a[e]??0),f[t]=n+1})}return{boundaries:s,capacity:c,offsets:u,alongLows:m,reachMaxima:h}}function pW(e,t){let n=aW(e,0,e.length,t);return e[n]===t?n*2:n===0||n===e.length?-1:n*2-1}function mW(e,t,n,r){let i=pW(e.boundaries,t);if(i<0)return!1;for(let t=i+e.capacity;t>=1;t>>=1){let i=e.offsets[t]??0,a=aW(e.alongLows,i,e.offsets[t+1]??0,r);if(a>i&&(e.reachMaxima[a-1]??0)>n)return!0}return!1}function hW(e,t){let n=Int32Array.from({length:e.count+t.count},(e,t)=>t),r=e=>{let t=e;for(;n[t]!==t;){let e=n[n[t]??t]??t;n[t]=e,t=e}return t},i=(e,t)=>{n[r(e)]=r(t)},a=lW(e),o=mH(Math.max(a.length,1)),s=new Int32Array(o*2),c=new Int32Array(o*2).fill(-1),l=t=>aW(a,0,a.length,e.lines[t]??0)+o,u=e=>{let t=l(e);s[t]=1,c[t]=e;for(let e=t>>1;e>=1;e>>=1)s[e]=(s[e]??0)+1,c[e]=-1},d=e=>{let t=l(e);s[t]=0;for(let e=t>>1;e>=1;e>>=1)s[e]=(s[e]??0)-1},f=(e,t,n,r,a,o)=>{if((s[e]??0)===0||n<r||t>a)return;let l=r<=t&&n<=a,u=c[e]??-1;if(l&&u>=0){i(u,o);return}let d=t+n>>1;f(e*2,t,d,r,a,o),f(e*2+1,d+1,n,r,a,o),l&&(c[e]=o)},p=Int32Array.from({length:e.count},(e,t)=>t).sort((t,n)=>(e.starts[t]??0)-(e.starts[n]??0)),m=Int32Array.from({length:e.count},(e,t)=>t).sort((t,n)=>(e.ends[t]??0)-(e.ends[n]??0)),h=0,g=0;for(let n=0;n<t.count;n+=1){let r=t.lines[n]??0;for(;;){let t=p[h]??-1,n=m[g]??-1,i=t>=0?e.starts[t]??0:1/0,a=n>=0?e.ends[n]??0:1/0;if(a<r&&a<i)d(n),g+=1;else{if(i>r)break;u(t),h+=1}}let i=aW(a,0,a.length,t.starts[n]??0),s=oW(a,0,a.length,t.ends[n]??0)-1;f(1,0,o-1,i,s,e.count+n)}return Int32Array.from(n.keys(),e=>r(e))}function gW(e,t,n){let r=0,i=e.count;for(;r<i;){let a=r+i>>1,o=e.lines[a]??0;o<t||o===t&&(e.starts[a]??0)<=n?r=a+1:i=a}let a=r-1;return a<0||e.lines[a]!==t||(e.ends[a]??0)<n?-1:a}function _W(e){return{horizontalPieces:new Int32Array(e),verticalPieces:new Int32Array(e),neighbors:new Int32Array(e*4).fill(wU),softSteps:new Uint8Array(e*4)}}function vW(e,t){let n=e.xs.length*2,r=_W(n);r.horizontalPieces.set(t.horizontalPieces),r.verticalPieces.set(t.verticalPieces),r.neighbors.set(t.neighbors),r.softSteps.set(t.softSteps);let i=new Float64Array(n),a=new Float64Array(n);return i.set(e.xs),a.set(e.ys),e.xs=i,e.ys=a,r}function yW(e,t,n){let r=Math.imul(e,2654435761)^Math.imul(t,2246822507);return r=Math.imul(r^r>>>16,2146121005),(r^r>>>15)&n}function bW(e,t){let n=PU(e,t);if(!n)return null;let r=FU(e.hardRects),i=QU(e,n);return eW(i,Array.from({length:i.count},(e,t)=>t),r,n),xW(e,n,r,i)}function xW(e,t,n,r){let i=tW(r,t,n);return{input:e,frame:t,blockers:n,corners:r,horizontal:iW(i.horizontal),vertical:iW(i.vertical),softAlongX:fW(e.softRects,!0),softAlongY:fW(e.softRects,!1)}}function SW(e){return bW(e,[])}function CW(e,t){return e.left===t.left&&e.top===t.top&&e.right===t.right&&e.bottom===t.bottom}function wW(e,t){let n=PU(e.input,t),r=n&&!CW(n,e.frame)?bW(e.input,t):e;if(!r)return null;let{softAlongX:i,softAlongY:a}=r,o=JU(r,t),s=rW(r.horizontal,iW(o.horizontal)),c=rW(r.vertical,iW(o.vertical)),l=uW(c,lW(s)),u=uW(s,lW(c)),d=hW(s,c),f=_W(SU),p=new Int32Array(SU*2).fill(DU),m=(e,t)=>{let n=p.length-1;for(let r=yW(e,t,n);;r=r+1&n){let n=p[r]??DU;if(n===DU||f.horizontalPieces[n]===e&&f.verticalPieces[n]===t)return r}},h=()=>{p=new Int32Array(p.length*2).fill(DU);for(let e=0;e<x.nodeCount;e+=1)p[m(f.horizontalPieces[e]??0,f.verticalPieces[e]??0)]=e},g=(e,t)=>{let n=p[m(e,t)]??DU;if(n!==DU)return n;let r=x.nodeCount;return r===x.xs.length&&(f=vW(x,f)),(r+1)*2>p.length&&h(),x.xs[r]=c.lines[t]??0,x.ys[r]=s.lines[e]??0,f.horizontalPieces[r]=e,f.verticalPieces[r]=t,p[m(e,t)]=r,x.nodeCount+=1,r},_=(e,t)=>{let n=t===J||t===bU,r=x.xs[e]??0,i=x.ys[e]??0;if(t===J||t===Y){let t=f.horizontalPieces[e]??0,a=dW(l,i,r,n),o=c.lines[a]??NaN;return a<0||o<(s.starts[t]??0)||o>(s.ends[t]??0)?-1:g(t,a)}let a=f.verticalPieces[e]??0,o=dW(u,r,i,n),d=s.lines[o]??NaN;return o<0||d<(c.starts[a]??0)||d>(c.ends[a]??0)?-1:g(o,a)},v=(e,t)=>{let n=f.neighbors[e*4+t]??wU;if(n!==wU)return n;let r=_(e,t);return f.neighbors[e*4+t]=r,r>=0&&(f.neighbors[r*4+(t^1)]=e),r},y=(e,t)=>{let n=f.softSteps[e*4+t]??0;if(n!==0)return n===EU;let r=v(e,t),o=t===J||t===Y,[s,c,l]=o?[x.ys[e]??0,x.xs[e]??0,x.xs[r]??0]:[x.xs[e]??0,x.ys[e]??0,x.ys[r]??0],u=r>=0&&mW(o?i:a,s,Math.min(c,l),Math.max(c,l)),d=u?EU:TU;return f.softSteps[e*4+t]=d,r>=0&&(f.softSteps[r*4+(t^1)]=d),u},b=(e,t)=>{let n=gW(s,t,e),r=gW(c,e,t);return n<0||r<0?-1:g(n,r)},ee=e=>d[f.horizontalPieces[e]??0]??-1,te=(s.count+c.count)*CU,x={nodeCount:0,xs:new Float64Array(SU),ys:new Float64Array(SU),neighborOf:v,isSoftStep:y,nodeAt:b,componentOf:ee,beginSearch:()=>{x.nodeCount<=te||(p.fill(DU),f.neighbors.fill(wU,0,x.nodeCount*4),f.softSteps.fill(0,0,x.nodeCount*4),x.nodeCount=0)},pieceExtentOf:(e,t)=>{let n=t?s:c,r=(t?f.horizontalPieces[e]:f.verticalPieces[e])??0;return[n.starts[r]??0,n.ends[r]??0]}};return x}var TW=30,EW=60,DW=512,OW=3,kW=400,AW=6,jW=1,MW=1e6,NW=4096,PW=200,FW=240,IW=2,LW=3e3,RW=[960,3840],zW=512,BW=64,VW=14,HW=8,UW=6.6,WW=5,GW=10,KW=2,qW=[.5,.35,.65,.2,.8],JW=256,YW=0,XW=1,ZW=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}],Z={right:0,left:1,bottom:2,top:3},QW={left:0,right:1,top:2,bottom:3},$W=[1,0,3,2],eG=1;function tG(e){return e===`left`||e===`right`}function nG(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function rG(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function iG(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);return{x:t,y:n,width:r-t,height:i-n}}function aG(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 oG(e){return e.from.y===e.to.y}function sG(e,t){let n=t.x+t.width,r=t.y+t.height;if(oG(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 cG(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 lG(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 uG(e){return e.slice(1).flatMap((t,n)=>{let r=e[n];return r?[{from:r,to:t}]:[]})}function dG(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function fG(e){return{count:e.length,messageAt:t=>e[t]??``}}function pG(e){let t=e.reduce((e,t)=>e+t.count,0),n=t<=vt.layoutWarnings?t:vt.layoutWarnings-1,r=[];for(let t of e)for(let e=0;e<t.count&&r.length<n;e+=1)r.push(t.messageAt(e));return t===n?r:[...r,`and ${t-n} more`]}function mG(e,t){return t.x>=e.x+e.width||t.x+t.width<=e.x}function hG(e,t,n){if(e.id===t.id)return{exitSide:`right`,entrySide:`top`};if(n)return{exitSide:`bottom`,entrySide:`bottom`};let r=nG(e),i=nG(t);return mG(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 gG=[`right`,`left`,`bottom`,`top`];function _G(e,t){let n=e.outputPort??zG(e.from,t.exitSide,1)[0]??nG(e.from),r=zG(e.to,t.entrySide,1)[0]??nG(e.to);if(!WG(t.exitSide,t.entrySide))return{...e,...t,start:n,end:r};let i=GG(r,t.entrySide,e.to,n),a=i===r&&!e.outputPort?GG(n,t.exitSide,e.from,r):n;return{...e,...t,start:a,end:i}}function vG(e,t){return lG(t.map(t=>({x:e.xs[t>>2]??0,y:e.ys[t>>2]??0})))}function yG(e,t,n,r,i){return t.map(t=>({side:t,point:t===n?r:zG(e,t,1)[0]??nG(e),direction:i[t],bias:t===n?0:jW}))}function bG(e){return[e,...gG.filter(t=>t!==e)]}function xG(e,t){let{wire:n,from:r,to:i}=e;if(n.back||r.id===i.id)return null;let a=e.outputPort||n.fromSide?[e.exitSide]:bG(t.exitSide),o=n.toSide?[n.toSide]:bG(t.entrySide);if(a.length<2&&o.length<2)return null;let s=_G(e,{exitSide:a[0]??t.exitSide,entrySide:o[0]??t.entrySide});return{plan:e,exits:e.outputPort?[{side:e.exitSide,point:e.outputPort,direction:Z[e.exitSide],bias:0}]:yG(r,a,a[0]??t.exitSide,s.start,Z),entries:yG(i,o,o[0]??t.entrySide,s.end,QW)}}function SG(e){return e.flatMap(e=>[...e.exits.map(e=>({x:e.point.x,y:e.point.y,outwardDirection:e.direction})),...e.entries.map(e=>({x:e.point.x,y:e.point.y,outwardDirection:$W[e.direction]??0}))])}function CG(e,t,n,r){e.plan.exitSide=t.side,e.plan.entrySide=n.side,e.plan.found={exitSide:t.side,entrySide:n.side,start:t.point,end:n.point,points:r}}function wG(e,t){let n={x:t.point.x-e.point.x,y:t.point.y-e.point.y};if(n.x!==0&&n.y!==0)return!1;let r=n.x>0?Z.right:n.x<0?Z.left:n.y>0?Z.bottom:Z.top;return(n.x!==0||n.y!==0)&&e.direction===r&&t.direction===r}function TG(e){return e===Z.right||e===Z.left}function EG(e,t){return t.x>e.x?Z.right:t.x<e.x?Z.left:t.y>e.y?Z.bottom:Z.top}function DG(e,t){if(TG(e.direction)===TG(t.direction))return null;let n=TG(e.direction)?{x:t.point.x,y:e.point.y}:{x:e.point.x,y:t.point.y};return DK(n,e.point)||DK(n,t.point)||EG(e.point,n)!==e.direction||EG(n,t.point)!==t.direction?null:[e.point,n,t.point]}function OG(e,t,n){return uG([...e]).every(e=>{let r=yq(e.from,e.to),i=n.obstaclesIn?.(rG(r,eG));return i!==void 0&&!i.hardRects.some(e=>e!==t.from&&e!==t.to&&cG(rG(e,eG),r))})}function kG(e){return uG([...e]).reduce((e,t)=>e+zK(t),0)}function AG(e,t,n,r){let i=yq(e.from,e.to),a=n.obstaclesIn?.(rG(i,eG));if(!a||a.hardRects.some(e=>e!==t.from&&e!==t.to&&cG(rG(e,eG),i))||a.softRects.some(e=>cG(e,i)))return!1;let o=yK(r,i);return!(oG(e)?o.verticals:o.horizontals).some(t=>WK(e,t))}function jG(e,t){return wG(e,t)?[e.point,t.point]:DG(e,t)}function MG(e){return e.exits.flatMap(t=>e.entries.flatMap(e=>{let n=jG(t,e);return n?[{exit:t,entry:e,points:n,bends:n.length-2,cost:kG(n)+t.bias+e.bias}]:[]}))}function NG(e,t,n){let r=MG(e).filter(n=>OG(n.points,e.plan,t)),i=Math.min(...r.map(e=>e.bends)),a=r.filter(e=>e.bends===i),o=Math.min(...a.map(e=>e.cost)),s=a.filter(e=>e.cost===o),[c]=s;return!c||s.length>1||c.bends>0&&!uG(c.points).every(r=>AG(r,e.plan,t,n))?null:{exit:c.exit,entry:c.entry,points:c.points}}function PG(e,t,n){let r=sK(),i=_K();for(let a of e){let e=NG(a,t,i);if(e){CG(a,e.exit,e.entry,e.points),vK(i,uG(e.points));continue}let o=tK(a.plan,n),s=QG(t,o),c=s?$G(SG([a]),t,o,s):null,l=c?xK(c,a.exits,a.entries,null,MW,r,yK(i,o)):null;if(lK(r),!c||!l)continue;let u=vG(c,l.states);CG(a,l.exit,l.entry,u),vK(i,uG(u))}}function FG(e,t,n,r){let i=e.flatMap(e=>{if(r.cleanIds.has(e.wire.id))return[];let n=xG(e,t.get(e)??{exitSide:e.exitSide,entrySide:e.entrySide});return n?[n]:[]});i.length>0&&PG(i,n,r)}function IG(e,t,n){let r=(e,t)=>`${e.to.id}|${e.styleKey}|${t}`,i=new Map;for(let e of t)e.entrySide===n.get(e)?.entrySide&&i.set(r(e,e.entrySide),(i.get(r(e,e.entrySide))??0)+1);for(let t of e){let e=n.get(t);e&&t.entrySide!==e.entrySide&&!t.wire.toSide&&(i.get(r(t,e.entrySide))??0)!==0&&(t.exitSide=t.outputPort||t.wire.fromSide?t.exitSide:e.exitSide,t.entrySide=e.entrySide)}}function LG(e,t,n){let r=t.boxesById.get(e.from),i=t.boxesById.get(e.to);if(!r||!i)return null;let a=hG(r,i,e.back),o=r.outputs.find(t=>t.id===e.fromOutput),s={wire:e,from:r,to:i,styleKey:`${e.dashed||e.back}|${e.tone}`,exitSide:o?`right`:e.fromSide??a.exitSide,entrySide:e.toSide??a.entrySide,busKey:null,exitKey:``,outputPort:o?.port??null,start:o?.port??nG(r),end:nG(i),found:null};return n&&(s.exitSide=n.exitSide,s.entrySide=n.entrySide),{plan:s,facing:a}}function RG(e,t){let n=new Map,r=e.wires.flatMap(r=>{let i=LG(r,e,t.cleanIds.has(r.id)?t.routeById.get(r.id):void 0);return i?(n.set(i.plan,i.facing),[i.plan]):[]}),i=(e.contextWires??[]).flatMap(r=>{let i=LG(r,e,t.routeById.get(r.id));return i?(n.set(i.plan,i.facing),[i.plan]):[]});FG(r,n,e,t),IG(r,[...r,...i],n);let a=[...r,...i];for(let e of a){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 o=e=>`${e.to.id}|${e.entrySide}|${e.styleKey}`,s=new Map;for(let e of a)s.set(o(e),(s.get(o(e))??0)+1);for(let e of a)(s.get(o(e))??0)>1&&(e.busKey=o(e));return{plans:r,contextPlans:i}}function zG(e,t,n){let r=Array.from({length:n},(e,t)=>t);if(tG(t)){let i=Math.round(t===`left`?e.x:e.x+e.width),a=Math.min(VW,(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+HW,Math.min(o,e.y+e.height-HW-(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)*VW/2;return r.map(e=>({x:Math.round(a+e*VW),y:i}))}function BG(e,t){let n=tG(t)?e.height:e.width;return Math.max(1,Math.floor((n-16)/VW)+1)}function VG(e,t=null){let n=e.flatMap(e=>[...e.outputPort?[]:[{box:e.from,side:e.exitSide,groupKey:`exit|${e.styleKey}`,wireId:e.wire.id,farPoint:nG(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??nG(e.from),assign:t=>{e.end=t}}]);return aG(t?n.filter(e=>t.has(e.box.id)):n,e=>`${e.box.id}|${e.side}`)}function HG(e){return new Map([...e.entries()].map(([e,t])=>[e,[...aG(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+(tG(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 UG(e,t){for(let[n,r]of e){let e=r[0],i=t.get(n)??[];if(!e)continue;let a=zG(e.box,e.side,i.length);for(let e of r){let t=a[i.indexOf(e.groupKey)];t&&e.assign(t)}}}function WG(e,t){return e===`right`&&t===`left`||e===`left`&&t===`right`||e===`bottom`&&t===`top`||e===`top`&&t===`bottom`}function GG(e,t,n,r){return tG(t)?r.y>=n.y+HW&&r.y<=n.y+n.height-HW?{x:e.x,y:r.y}:e:r.x>=n.x+HW&&r.x<=n.x+n.width-HW?{x:r.x,y:e.y}:e}function KG(e,t){let n=(e,n)=>(t.get(`${e.id}|${n}`)?.length??0)===1,r=new Map([...aG(e,e=>e.exitKey)].map(([e,t])=>[e,t.length]));for(let t of e){if(t.from.id===t.to.id||!WG(t.exitSide,t.entrySide))continue;let e=t.busKey===null&&n(t.to,t.entrySide)?GG(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=GG(t.start,t.exitSide,t.from,t.end)):t.end=e}}function qG(e,t){return[...e.entries()].flatMap(([e,n])=>{let r=n[0],i=t.get(e)?.length??0;return!r||i<=BG(r.box,r.side)?[]:[`box ${r.box.id} has ${i} wires on its ${r.side} side, more than fit`]})}function JG(e){return e.flatMap(e=>[{x:e.start.x,y:e.start.y,outwardDirection:Z[e.exitSide]},{x:e.end.x,y:e.end.y,outwardDirection:Z[e.entrySide]}])}function YG(e){let t=[...e.boxesById.values()],n=hU(t,zW),r=hU(e.softObstacles,zW);return i=>{let a=[],o=[];return pU(n,i,e=>{let n=t[e];n&&a.push(n)}),pU(r,i,t=>{let n=e.softObstacles[t];n&&o.push(n)}),{hardRects:a,softRects:o}}}function XG(e){return e.obstaclesIn?e:{...e,obstaclesIn:YG(e)}}function ZG(e){let t=e.x-IW,n=e.y-IW,r=e.width+4,i=e.height+4;return[{x:t,y:n,width:r,height:IW},{x:t,y:e.y+e.height,width:r,height:IW},{x:t,y:n,width:IW,height:i},{x:e.x+e.width,y:n,width:IW,height:i}]}function QG(e,t){let n=e.obstaclesIn?.(t)??null;return n&&n.hardRects.length<=LW?n:null}function $G(e,t,n,r){let i=SW({hardRects:[...r.hardRects,...ZG(n)],softRects:r.softRects,contentTop:t.contentTop});return i?wW(i,e):null}function eK(e,t,n,r){let i=e.from.id===e.to.id?[e.from]:[e.from,e.to],a=r.hardRects.filter(t=>t!==e.from&&t!==e.to),o=SW({hardRects:[...i,...ZG(n)],softRects:[...r.softRects,...a],contentTop:t.contentTop});return o?wW(o,JG([e])):null}function tK(e,t,n=FW){let r=(t.routeById.get(e.wire.id)?.points??[]).map(e=>({x:e.x,y:e.y,width:0,height:0}));return rG(iG([e.from,e.to,...r])??e.from,n)}function nK(){return{states:new Int32Array(1024),priorities:new Float64Array(1024),tieBreaks:new Float64Array(1024),size:0,lastPoppedPriority:0}}function rK(e,t,n){let r=e.priorities[t]??0,i=e.priorities[n]??0;return r<i||r===i&&(e.tieBreaks[t]??0)<(e.tieBreaks[n]??0)}function iK(e,t,n){let r=e.states[t]??0,i=e.priorities[t]??0,a=e.tieBreaks[t]??0;e.states[t]=e.states[n]??0,e.priorities[t]=e.priorities[n]??0,e.tieBreaks[t]=e.tieBreaks[n]??0,e.states[n]=r,e.priorities[n]=i,e.tieBreaks[n]=a}function aK(e,t,n,r){if(e.size===e.states.length){let t=new Int32Array(e.size*2),n=new Float64Array(e.size*2),r=new Float64Array(e.size*2);t.set(e.states),n.set(e.priorities),r.set(e.tieBreaks),e.states=t,e.priorities=n,e.tieBreaks=r}e.states[e.size]=t,e.priorities[e.size]=n,e.tieBreaks[e.size]=r;let i=e.size;for(e.size+=1;i>0;){let t=i-1>>1;if(!rK(e,i,t))return;iK(e,t,i),i=t}}function oK(e){if(e.size===0)return-1;let t=e.states[0]??-1;if(e.lastPoppedPriority=e.priorities[0]??0,--e.size,e.size===0)return t;iK(e,0,e.size);let n=0;for(;;){let r=n*2+1,i=r+1,a=n;if(r<e.size&&rK(e,r,a)&&(a=r),i<e.size&&rK(e,i,a)&&(a=i),a===n)return t;iK(e,a,n),n=a}}function sK(){return{bestCost:new Float64Array(NW).fill(1/0),cameFrom:new Int32Array(NW).fill(-1),touchedStates:[],heap:nK()}}function cK(e,t){if(t<=e.bestCost.length)return;let n=Math.max(t,e.bestCost.length*2),r=new Float64Array(n).fill(1/0),i=new Int32Array(n).fill(-1);r.set(e.bestCost),i.set(e.cameFrom),e.bestCost=r,e.cameFrom=i}function lK(e){for(let t of e.touchedStates)e.bestCost[t]=1/0,e.cameFrom[t]=-1;e.touchedStates.length=0,e.heap.size=0}function uK(e,t,n,r,i){let a={side:t.exitSide,point:t.start,direction:Z[t.exitSide],bias:0},o={side:t.entrySide,point:t.end,direction:QW[t.entrySide],bias:0},s=xK(e,[a],[o],n,TW,r,i)?.states??null;return lK(r),s}function dK(e,t,n,r){let i=e.xs[t]??0,a=e.ys[t]??0,o=e.xs[n]??0,s=e.ys[n]??0;return a===s?r.y<a&&a<r.y+r.height&&Math.min(i,o)<r.x+r.width&&Math.max(i,o)>r.x:r.x<i&&i<r.x+r.width&&Math.min(a,s)<r.y+r.height&&Math.max(a,s)>r.y}function fK(e){return e===YW||e===XW}function pK(e,t,n,r){if(e===$W[t.direction])return 2;let i=fK(t.direction),a=i?n:r,o=i?r:n,s=i?t.point.y:t.point.x,c=t.approachStart<=a&&a<=t.approachEnd,l=ZW[e]??{x:0,y:0};if(e===t.direction){let e=i?(t.point.x-n)*l.x:(t.point.y-r)*l.y;return o===s&&c&&e>=0?0:2}let u=(s-o)*(i?l.y:l.x);return c&&u>=0?1:3}function mK(e,t){return t.flatMap(t=>{let n=e.nodeAt(t.point.x,t.point.y);if(n<0)return[];let[r,i]=e.pieceExtentOf(n,fK(t.direction));return[{...t,node:n,component:e.componentOf(n),approachStart:r,approachEnd:i}]})}function hK(e,t){for(let n of e)if(n.node===t)return n;return null}var gK={horizontals:[],verticals:[]};function _K(){return{grid:eU(DW),segments:[]}}function vK(e,t){for(let n of t)lU(e.grid,e.segments.length,yq(n.from,n.to)),e.segments.push(n)}function yK(e,t){let n={horizontals:[],verticals:[]};return pU(e.grid,t,t=>{let r=e.segments[t];r&&(oG(r)?n.horizontals:n.verticals).push(r)}),n}function bK(e,t,n,r){let i=t.xs[n]??0,a=t.ys[n]??0,o=t.xs[r]??0,s=t.ys[r]??0,c=0;if(a===s){for(let t of e.verticals)UK(t.from.x,i,o)&&UK(a,t.from.y,t.to.y)&&(c+=1);return c}for(let t of e.horizontals)UK(t.from.y,a,s)&&UK(i,t.from.x,t.to.x)&&(c+=1);return c}function xK(e,t,n,r,i,a,o=gK){e.beginSearch();let s=mK(e,n),c=mK(e,t).filter(e=>s.some(t=>t.component===e.component)),l=s.filter(e=>c.some(t=>t.component===e.component));if(c.length===0||l.length===0)return null;let{touchedStates:u,heap:d}=a;cK(a,e.nodeCount*4);let f=(t,n)=>{let r=e.xs[t]??0,a=e.ys[t]??0,o=1/0;for(let e of l)o=Math.min(o,Math.abs(e.point.x-r)+Math.abs(e.point.y-a)+pK(n,e,r,a)*i+e.bias);return o};for(let e of c){let t=e.node*4+e.direction;a.bestCost[t]=e.bias,u.push(t),aK(d,t,e.bias+f(e.node,e.direction),-e.bias)}for(;;){let t=oK(d);if(t<0)return null;let n=t>>2,s=t&3,p=hK(l,n);if(p&&s===p.direction){let e=SK(a.cameFrom,t),n=hK(c,(e[0]??0)>>2);return n?{states:e,exit:n,entry:p}:null}let m=a.bestCost[t]??1/0;if(d.lastPoppedPriority>m+f(n,s)+1e-6)continue;let h=hK(c,n);for(let c=0;c<4;c+=1){if(h&&c!==h.direction||c===$W[s])continue;let p=e.neighborOf(n,c);if(p<0)continue;let g=hK(l,p);if(g&&c!==g.direction)continue;cK(a,e.nodeCount*4);let _=Math.abs((e.xs[p]??0)-(e.xs[n]??0))+Math.abs((e.ys[p]??0)-(e.ys[n]??0)),v=r!==null&&dK(e,n,p,r),y=_+(c===s?0:i)+bK(o,e,n,p)*EW+(e.isSoftStep(n,c)?_*OW:0)+(v?kW:0),b=p*4+c,ee=m+Math.max(y,1)+(g?.bias??0);ee>=(a.bestCost[b]??1/0)||(a.bestCost[b]=ee,a.cameFrom[b]=t,u.push(b),aK(d,b,ee+f(p,c),-ee))}}}function SK(e,t){let n=[];for(let r=t;r!==-1;r=e[r]??-1)n.push(r);return n.reverse()}function CK(e,t){let n=ZW[Z[t]]??{x:0,y:0};return{x:e.x+n.x*14,y:e.y+n.y*14}}function wK(e){let t=CK(e.start,e.exitSide),n=CK(e.end,e.entrySide);return lG([e.start,t,{x:n.x,y:t.y},n,e.end])}function TK(e,t){if(!e.wire.back)return null;let n=iG([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 EK(e,t,n){let r=e&&n?vG(e,n):wK(t);return{plan:t,points:r,segments:uG(r),routedPoints:r,states:n}}function DK(e,t){return e.x===t.x&&e.y===t.y}function OK(e,t){if(!t.cleanIds.has(e.wire.id))return null;let n=t.routeById.get(e.wire.id);return!n||n.exitSide!==e.exitSide||n.entrySide!==e.entrySide||!DK(n.start,e.start)||!DK(n.end,e.end)?null:{plan:e,points:n.points,segments:uG(n.points),routedPoints:n.points,states:n.isRouted?[]:null}}function kK(e,t,n,r,i,a=FW){let o=tK(e,n,a),s=QG(t,o);if(!s)return null;let c=$G(JG([e]),t,o,s),l=c?uK(c,e,TK(e,t.loopFrames),r,yK(i,o)):null;return l?EK(c,e,l):null}function AK(e,t,n,r,i){let a=tK(e,n),o=t.obstaclesIn?.(a)??null,s=o?eK(e,t,a,o):null;return EK(s,e,s?uK(s,e,TK(e,t.loopFrames),r,yK(i,a)):null)}function jK(e,t,n,r,i){let a=n.isPreview?[]:RW;for(let o of a){let a=kK(e,t,n,r,i,o);if(a)return a}return AK(e,t,n,r,i)}function MK(e){let{found:t}=e;return!t||t.exitSide!==e.exitSide||t.entrySide!==e.entrySide||!DK(t.start,e.start)||!DK(t.end,e.end)?null:{plan:e,points:t.points,segments:uG(t.points),routedPoints:t.points,states:[]}}function NK(e,t,n,r,i){let a=OK(e,n)??MK(e)??kK(e,t,n,r,i)??jK(e,t,n,r,i);return vK(i,a.segments),a}function PK(e,t,n,r){let i=tG(t)?n.y:n.x;if(r)return{low:i,high:i};let a=(tG(t)?e.y:e.x)+HW,o=(tG(t)?e.y+e.height:e.x+e.width)-HW;return{low:Math.max(a,i-VW/2),high:Math.min(o,i+VW/2)}}function FK(e,t,n){let r=sK(),i=_K(),a=e.map(e=>NK(e,t,n,r,i));if(n.isPreview)return a;let o=YH(a.map(e=>({points:e.points,exitKey:e.plan.exitKey,busKey:e.plan.busKey,startSlack:PK(e.plan.from,e.plan.exitSide,e.plan.start,e.plan.outputPort!==null),endSlack:PK(e.plan.to,e.plan.entrySide,e.plan.end,!1)})),e=>t.obstaclesIn?.(e).hardRects??[]);return a.map((e,t)=>{let n=lG(o[t]??e.points);return{...e,points:n,segments:uG(n)}})}function IK(e){return Math.max(0,e.points.length-2)}function LK(e){return Math.ceil(e.length*UW)}function RK(e,t){return{x:e.x-t/2,y:e.y-GW,width:t,height:13}}function zK(e){return Math.abs(e.from.x-e.to.x)+Math.abs(e.from.y-e.to.y)}function BK(e,t){if(!oG(e))return[];let n=e.from.y;return[Math.min(e.from.x,e.to.x)+WW+t/2,Math.max(e.from.x,e.to.x)-WW-t/2].flatMap(e=>[{x:e,y:n-WW},{x:e,y:n+WW+GW}])}function VK(e,t){let n=[...e].sort((e,t)=>zK(t)-zK(e));return[...e.slice(0,1),...n].flatMap(e=>[...qW.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 oG(e)?[{x:r,y:i-WW},{x:r,y:i+WW+GW}]:[{x:r+WW+t/2,y:i+GW/2},{x:r-WW-t/2,y:i+GW/2}]}),...BK(e,t)])}function HK(e,t,n){let r=new Map,i=e.flatMap(e=>e.segments),a=hU(i.map(e=>yq(e.from,e.to)),JW),o=[...t.boxesById.values(),...t.softObstacles],s=hU(o,JW),c=[],l=eU(JW);for(let u of e){let e=u.plan.wire.label;if(!e)continue;let d=LK(e),f=VK(u.segments,d),p=f.find(e=>{let n=RK(e,d);if(n.y<t.contentTop)return!1;let r=rG(n,KW);return mU(a,r,e=>{let t=i[e];return t!==void 0&&sG(t,r)})||mU(s,n,e=>{let t=o[e];return t!==void 0&&cG(n,t)})?!1:!mU(l,n,e=>{let t=c[e];return t!==void 0&&cG(n,t)})}),m=p??f[0]??nG(u.plan.from);p||n.push(`wire ${u.plan.wire.id} label "${e}" has no clear spot`);let h=RK(m,d);r.set(u.plan.wire.id,{at:{x:Math.round(m.x),y:Math.round(m.y)},bounds:h}),lU(l,c.length,h),c.push(h)}return r}function UK(e,t,n){return e>Math.min(t,n)+.5&&e<Math.max(t,n)-.5}function WK(e,t){if(oG(e)===oG(t))return!1;let n=oG(e)?e:t,r=n===e?t:e;return UK(r.from.x,n.from.x,n.to.x)&&UK(n.from.y,r.from.y,r.to.y)}function GK(e,t){if(oG(e)!==oG(t))return!1;let n=oG(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 KK(e,t){return e.plan.busKey!==null&&e.plan.busKey===t.plan.busKey||e.plan.exitKey===t.plan.exitKey}function qK(e){let t=e.flatMap(e=>e.segments),n=lH(t.length),r=new Int32Array(t.length),i=0;return e.forEach((e,t)=>{for(let a of e.segments)uH(n,i,a.from.x,a.from.y,a.to.x,a.to.y),r[i]=t,i+=1}),{rects:n,segments:t,wireIndexByPiece:r}}function JK(e,t,n,r,i){let a=n.wireIndexByPiece[r]??0,o=n.wireIndexByPiece[i]??0;if(a===o)return;let s=Math.min(a,o)*t.length+Math.max(a,o);if(e.get(s)===!0)return;let c=t[a],l=t[o],u=n.segments[r],d=n.segments[i];c&&l&&u&&d&&!KK(c,l)&&(WK(u,d)?e.set(s,!0):GK(u,d)&&e.set(s,!1))}function YK(){return{firsts:[],seconds:[],isCrossings:[]}}function XK(e,t,n){for(let[r,i]of t)e.firsts.push(Math.floor(r/n)),e.seconds.push(r%n),e.isCrossings.push(i);return e}function ZK(e,t){let n=[];return e.wireIndexByPiece.forEach((e,r)=>{t.isChangedByWire[e]&&n.push(r)}),n}function QK(e,t){let n=lH(t.length);return t.forEach((t,r)=>{uH(n,r,e.lefts[t]??0,e.tops[t]??0,e.rights[t]??0,e.bottoms[t]??0)}),n}function $K(e,t,n,r){let i=YK();return e.firsts.forEach((a,o)=>{let s=t[a]??-1,c=n[e.seconds[o]??0]??-1;s<0||c<0||!r(s,c)||(i.firsts.push(Math.min(s,c)),i.seconds.push(Math.max(s,c)),i.isCrossings.push(e.isCrossings[o]===!0))}),i}function eq(e,t,n){let r=new Map;if(!n)return bH(t.rects,(n,i)=>JK(r,e,t,n,i)),XK(YK(),r,e.length);let i=ZK(t,n);return xH(QK(t.rects,i),t.rects,(a,o)=>{let s=i[a]??0,c=t.wireIndexByPiece[s]??0,l=t.wireIndexByPiece[o]??0;n.isChangedByWire[l]&&l<c||JK(r,e,t,s,o)}),XK($K(n.previous.wirePairs,n.wireIndexByPrevious,n.wireIndexByPrevious,(e,t)=>!n.isChangedByWire[e]&&!n.isChangedByWire[t]),r,e.length)}function tq(e,t,n,r){let i=CH(e.firsts,e.seconds,t,n);return{count:i.length,messageAt:t=>{let n=i[t]??0;return r(e.firsts[n]??0,e.seconds[n]??0,e.isCrossings[n]===!0)}}}var nq=new WeakMap;function rq(e){let t=nq.get(e);if(t)return t;let n=[...e.boxesById.values()];return nq.set(e,n),n}function iq(e){return`box ${e.id}`}function aq(e,t,n,r,i,a,o){let s=n.wireIndexByPiece[a]??0,c=s*r.length+o;if(e.has(c))return;let l=t[s],u=r[o],d=i[o],f=n.segments[a];l&&u&&d&&f&&u.id!==l.plan.from.id&&u.id!==l.plan.to.id&&sG(f,d)&&e.set(c,!0)}function oq(e,t,n,r){let i=n.map(e=>rG(e,-2)),a=cH(i),o=new Map;if(!r)return xH(t.rects,a,(r,a)=>aq(o,e,t,n,i,r,a)),XK(YK(),o,n.length);let s=ZK(t,r);xH(QK(t.rects,s),a,(r,a)=>aq(o,e,t,n,i,s[r]??0,a));let c=n.map(e=>r.changedSolidKeys.has(iq(e))),l=n.flatMap((e,t)=>c[t]?[t]:[]);xH(t.rects,QK(a,l),(r,a)=>aq(o,e,t,n,i,r,l[a]??0));let u=new Map(n.map((e,t)=>[iq(e),t])),d=r.previous.solidKeys.map(e=>u.get(e)??-1),f=YK();return r.previous.runsThroughPairs.firsts.forEach((e,t)=>{let n=r.wireIndexByPrevious[e]??-1,i=d[r.previous.runsThroughPairs.seconds[t]??0]??-1;n<0||i<0||r.isChangedByWire[n]||c[i]||(f.firsts.push(n),f.seconds.push(i),f.isCrossings.push(!0))}),XK(f,o,n.length)}function sq(e){return JSON.stringify([e.points,e.plan.exitKey,e.plan.busKey,e.plan.from.id,e.plan.to.id])}function cq(e,t,n,r){if(!r||!n||n.size>BW)return null;let i=e.map((e,n)=>r.wireSignatureById.get(e.plan.wire.id)!==t[n]);if(i.filter(Boolean).length>PW)return null;let a=new Map(e.map((e,t)=>[e.plan.wire.id,t]));return{previous:r,isChangedByWire:i,wireIndexByPrevious:r.wireIds.map(e=>a.get(e)??-1),changedSolidKeys:n}}function lq(e,t,n,r,i){let a=qK(e),o=rq(t),s=e.map(sq),c=cq(e,s,n,i),l=oq(e,a,o,c),u=eq(e,a,c);r&&(r.warningPairs={wireIds:e.map(e=>e.plan.wire.id),wireSignatureById:new Map(e.map((e,t)=>[e.plan.wire.id,s[t]??``])),solidKeys:o.map(iq),wirePairs:u,runsThroughPairs:l});let d=t=>e[t]?.plan.wire.id;return[tq(l,e.length,o.length,(e,t)=>`wire ${d(e)} runs through ${o[t]?.kind} ${o[t]?.id}`),tq(u,e.length,e.length,(e,t,n)=>`wire ${d(e)} ${n?`crosses`:`overlaps`} wire ${d(t)}`)]}function uq(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=IK(e);return t>AW?[`wire ${e.plan.wire.id} bends ${t} times`]:[]})}function dq(e,t){return oG(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 fq(e,t){if(!t||t===e)return null;let n=e.points.find(e=>t.segments.some(t=>dq(e,t)));return!n||n.x===e.plan.end.x&&n.y===e.plan.end.y?null:n}function pq(e,t,n,r,i){return UG(n,r),KG([...e.plans,...e.contextPlans],r),FK(e.plans,t,i)}function mq(e){let t=new Map,n=e=>`${e.x},${e.y},${e.width},${e.height}`;for(let n of e.boxesById.values())t.set(`box ${n.id}`,n);for(let r of e.softObstacles)t.set(`soft ${n(r)}`,r);for(let r of e.loopFrames)t.set(`loop ${n(r)}`,r);return t}function hq(e,t){let n=(e,t)=>e!==void 0&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,r={keys:new Set,rects:[]};for(let[i,a]of e)n(t.get(i),a)||(r.keys.add(i),r.rects.push(a));for(let[i,a]of t)n(e.get(i),a)||(r.keys.add(i),r.rects.push(a));return r}function gq(e,t,n){t.length>BW?xH(cH(e),cH(t),n):e.forEach((e,r)=>{t.some(t=>e.x<=t.x+t.width&&t.x<=e.x+e.width&&e.y<=t.y+t.height&&t.y<=e.y+e.height)&&n(r)})}function _q(e,t){return e.storedWireKeyOf?.(t)??JSON.stringify(t)}function vq(e,t,n){if(!t||!n)return{routeById:t?.routeById??new Map,cleanIds:new Set,isPreview:!1};let r=n.rects.map(e=>rG(e,14)),i=e.wires.flatMap(n=>{let r=t.routeById.get(n.id);return r&&r.wireKey===_q(e,n)?[{wire:n,remembered:r}]:[]}),a=i.flatMap(({wire:e,remembered:t})=>uG(t.points).map(t=>({wireId:e.id,rect:yq(t.from,t.to)}))),o=new Set;gq(a.map(e=>e.rect),r,e=>{let t=a[e];t&&o.add(t.wireId)});let s=new Set(i.map(({wire:e})=>e.id).filter(e=>!o.has(e)));return{routeById:t.routeById,cleanIds:s,isPreview:!1}}function yq(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}}function bq(e,t,n){let r=new Map(n.map(t=>[t.plan.wire.id,{wireKey:_q(e,t.plan.wire),exitSide:t.plan.exitSide,entrySide:t.plan.entrySide,start:t.plan.start,end:t.plan.end,points:t.routedPoints,isRouted:t.states!==null}]));return{contentTop:e.contentTop,rectByKey:t,routeById:r,warningPairs:null}}function xq(e,t){let n=new Map;for(let t of[...e].sort((e,t)=>e.plan.wire.id.localeCompare(t.plan.wire.id)))t.plan.busKey&&!n.has(t.plan.busKey)&&n.set(t.plan.busKey,t);return e.map(e=>{let{plan:r,points:i}=e,a=r.busKey?n.get(r.busKey):void 0;return{kind:`wire`,id:r.wire.id,path:dG(i),start:i[0]??r.start,end:i[i.length-1]??r.end,label:r.wire.label,labelAt:t.get(r.wire.id)?.at??nG(r.from),isDashed:r.wire.dashed||r.wire.back,isBack:r.wire.back,tone:r.wire.tone,hasArrowhead:a===void 0||a===e,joinAt:fq(e,a)}})}function Sq(e){let t=XG(e),n={routeById:new Map,cleanIds:new Set,isPreview:!0},r=RG(t,n),i=VG(r.plans),a=pq(r,t,i,HG(i),n);return xq(a,HK(a,t,[]))}function Cq(e,t){let n=XG(e),r=mq(n),i=t&&t.contentTop===n.contentTop?hq(t.rectByKey,r):null,a=vq(n,t,i),o=RG(n,a),s=n.contextWires?new Set(o.plans.flatMap(e=>[e.from.id,e.to.id])):null,c=VG([...o.plans,...o.contextPlans],s),l=HG(c),u=pq(o,n,c,l,a),d=[],f=HK(u,n,d),p=xq(u,f),m=[...f.values()].map(e=>e.bounds),h=bq(n,r,u),g=u.flatMap(e=>e.points).map(e=>({x:e.x,y:e.y,width:0,height:0}));return{wires:p,segments:u.flatMap(e=>e.segments),collectWarnings:()=>[fG(uq(u)),...lq(u,n,i?.keys??null,h,t?.warningPairs??null),fG([...qG(c,l),...d])],extent:iG([...g,...m]),memory:h,portEndsById:new Map([...o.plans,...o.contextPlans].map(e=>[e.wire.id,{start:e.start,end:e.end,busKey:e.busKey}]))}}function wq(e){let t=e.match(/-?\d+(\.\d+)?(e-?\d+)?/gi)?.map(Number)??[],n=[];for(let e=0;e+1<t.length;e+=2)n.push({x:t[e]??0,y:t[e+1]??0});return n}var Q=40,Tq=220,Eq=90,Dq=30,Oq=18,kq=12,Aq=20,jq=18,Mq=28,Nq=12,Pq=2,Fq=20,Iq=26,Lq=18,Rq=26,zq=170,Bq=21,Vq=17,Hq=10,Uq=22,Wq=24,Gq=8,Kq=40,qq=18,Jq=8,Yq=320,Xq=256,Zq=160;function Qq(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 $q(e,t,n){let r=e.icon?n-3:n,i=e.muted?2:0,a=e.style===`numbered`?`${t}.`:e.style===`kv`?e.key:null,o=(t,n,r,i)=>({text:t,muted:e.muted,style:e.style,marker:n===0?i:null,indentChars:r,isFirstRow:n===0,icon:e.icon});if(a&&a.length+1>Nq){let t=Qq(e.text,r-i-Pq).map(e=>o(e,1,Pq,null));return[o(``,0,0,a),...t]}let s=e.style===`item`?Pq:a?a.length+1:0;return Qq(e.text,r-i-s-+(e.style===`code`)).map((e,t)=>o(e,t,s,a))}function eJ(e,t=Iq){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,$q(e,n,t)))}function tJ(e){return e.shape===`icon`?Zq:e.shape===`device`?Yt[e.device].defaultBoxWidth:Tq}function nJ(e){return e.width??tJ(e)}function rJ(e,t){return Math.floor(e*(t-24)/196)}function iJ(e){let t=e.icon?2:0;return e.shape===`icon`?{lines:[],media:null,device:null,fit:`fit`,glyphRoom:56,titleIconChars:0}:e.shape===`device`?{lines:[],media:e.media,device:e.device,fit:e.fit,glyphRoom:0,titleIconChars:t}:{lines:e.lines,media:e.media,device:null,fit:`fit`,glyphRoom:0,titleIconChars:t}}function aJ(e,t){let{screen:n,bezel:r,toolbarHeight:i,base:a}=Yt[e],o=Ot(e),s=t/o.width;return{width:t,height:Math.round(o.height*s),scale:s,screen:{x:Math.round(((a?.overhang??0)+r.side)*s),y:Math.round((r.top+i)*s),width:Math.round(n.width*s),height:Math.round(n.height*s)}}}function oJ(e,t){let n=t-24,r=Math.round(Yq*t/Tq),i=Math.min(r,Math.max(1,Math.round(n*e.height/e.width)));return{width:n,height:i,scale:1,screen:{x:0,y:0,width:n,height:i}}}function sJ(e,t){return e.device?aJ(e.device,t-24):e.media?oJ(e.media,t):null}function cJ(e,t,n,r){let{media:i}=e;return!i||!r?null:{kind:i.kind,asset:i.asset,mime:i.mime,hasPreview:i.hasPreview,alt:i.alt,fit:e.fit,x:t.x+kq+r.screen.x,y:t.y+n+r.screen.y,width:r.screen.width,height:r.screen.height}}function lJ(e,t,n,r){if(!e.device||!r)return null;let i=t.x+kq,a=t.y+n,o={x:i+r.screen.x,y:a+r.screen.y,width:r.screen.width,height:r.screen.height};return{name:e.device,scale:r.scale,x:i,y:a,width:r.width,height:r.height,screen:o}}var uJ=new WeakMap,dJ=new WeakMap;function fJ(e){let t=uJ.get(e);if(t)return t;let n=mJ(e);return uJ.set(e,n),n}function pJ(e,t){let n=iJ(e),r=rJ(Fq,t);return{titleLines:Qq(e.title,r-n.titleIconChars),wasLines:e.change===`relabeled`&&e.was?Qq(e.was,r):[],bodyLines:eJ(n.lines,rJ(Iq,t))}}function mJ(e){let t=iJ(e),n=e.step?qq:0,r=+!!e.step?.linkedBoardId,i=nJ(e),{titleLines:a,wasLines:o,bodyLines:s}=pJ(e,i),c=kq+n+t.glyphRoom+(o.length+a.length)*Aq+(s.length+r)*jq,l=sJ(t,i),u=l?l.height+Jq:0,d=c+kq+u,f=e.shape===`decision`?e.outputs:[];return{headerHeight:d,outputs:f,content:t,artTop:c+Jq,art:l,height:d+f.length*Mq}}function hJ(e,t){switch(t.kind){case`box`:e.box.push(t);return;case`frame`:e.frame.push(t);return;case`wire`:e.wire.push(t);return;case`note`:e.note.push(t);return}}function gJ(e){let t={box:[],frame:[],wire:[],note:[]};for(let n of e.elements.values())hJ(t,n);return{...e,elementsByKind:t,planStepById:new Map(sH(e).map(e=>[e.boxId,e]))}}function _J(e,t){return e.elementsByKind[t]}function vJ(e){return Qq(e.text,Bq)}function yJ(e){let t=dJ.get(e);if(t)return t;let n={height:24+(vJ(e).length+1)*Vq};return dJ.set(e,n),n}function bJ(e){let t=new Map;for(let n of _J(e,`note`)){let e=t.get(n.on),r=yJ(n).height;t.set(n.on,e===void 0?r:e+Hq+r)}return t}function xJ(e,t){return t.step?{label:e.get(t.id)?.label??``,status:t.step.status,linkedBoardId:t.step.linkedBoardId}:null}function SJ(e,t,n){let r=fJ(t),i=nJ(t);return{kind:`box`,id:t.id,x:n.x,y:n.y,width:i,height:r.height,icon:t.icon,change:t.change,shape:t.shape,headerHeight:r.headerHeight,media:cJ(r.content,n,r.artTop,r.art),device:lJ(r.content,n,r.artTop,r.art),step:xJ(e,t),outputs:r.outputs.map((e,t)=>({id:e.id,label:e.label,port:{x:n.x+i,y:n.y+r.headerHeight+t*Mq+Mq/2}}))}}function CJ(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 wJ(e,t,n,r){let i=CJ(r,n,{width:nJ(t),height:fJ(t).height});return SJ(e,t,{x:Math.round(i.x),y:Math.round(i.y)})}function TJ(e,t){let n=[...e.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0);return{x:e.size>0?n+Eq:Q,y:t}}function EJ(e,t,n,r){let i=_J(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.get(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=u?wJ(e.planStepById,i,i.near,u):SJ(e.planStepById,i,TJ(n,t));return n.set(i.id,d),d};for(let e of i)o(e,new Set)}function DJ(e){return e.shape===`panel`&&e.step===null&&e.near===null&&e.at===null}function OJ(e,t,n,r){let i=_J(e,`box`).filter(DJ).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id));if(i.length===0)return;let a=[...r.values()].reduce((e,t)=>Math.max(e,t.x+t.width+(n.has(t.id)?146:0)),-1/0),o=r.size>0?Math.round(a+Eq):Q,s=t;for(let t of i){let i=SJ(e.planStepById,t,{x:o,y:s});r.set(t.id,i),s+=Math.max(i.height,(n.get(t.id)??0)-Gq)+Dq}}function kJ(e,t,n,r){let i=new Map,a=[];for(let t of _J(e,`box`)){let n=r.get(t.id);n&&i.set(t.id,SJ(e.planStepById,t,n))}for(let t of _J(e,`box`))t.at&&i.set(t.id,SJ(e.planStepById,t,t.at));EJ(e,t,i,a),OJ(e,t,n,i);for(let n of _J(e,`box`))i.has(n.id)||i.set(n.id,SJ(e.planStepById,n,TJ(i,t)));return{boxesById:i,warnings:a}}function AJ(e,t){let n=iG(e.contains.flatMap(e=>t.get(e)??[]));return n?{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,x:n.x-Lq,y:n.y-Lq-Rq,width:n.width+36,height:n.height+36+Rq}:null}function jJ(e,t){return _J(e,`frame`).flatMap(e=>AJ(e,t)??[])}function MJ(e){return{x:e.x,y:e.y,width:e.width,height:Rq}}function NJ(e){return e.resolvedBy?`resolved by ${e.resolvedBy}`:e.author?`from ${e.author}`:``}function PJ(e,t,n){let{height:r}=yJ(e);return{kind:`note`,id:e.id,x:t.x+t.width-Wq,y:n,width:zq,height:r,byline:NJ(e),isResolved:e.resolvedBy!==null}}function FJ(e,t){let n=new Map;return _J(e,`note`).flatMap(e=>{let r=t.get(e.on);if(!r)return[];let i=PJ(e,r,n.get(e.on)??r.y-Gq);return n.set(e.on,i.y+i.height+Hq),[i]})}function IJ(e){return{x:0,y:0,width:Q,height:e}}function LJ(e){return e?{x:Math.min(0,e.x-Q),y:Math.min(0,e.y-Q),width:e.width+80,height:e.height+80}:{x:0,y:0,width:80,height:80}}function RJ(e,t,n){return LJ(iG([...e.flatMap(e=>e.kind===`wire`?[]:[e]),...t?[t]:[],IJ(n)]))}function zJ(e,t){return`box ${e} overlaps box ${t}`}function BJ(e,t){return`box ${e} covers the title of frame ${t}`}function VJ(e,t,n){let r=[...e.values()],i=TH(r).flatMap(([e,t])=>{let n=r[e],i=r[t];return n&&i&&cG(n,i)?[zJ(n.id,i.id)]:[]}),a=new Map(_J(n,`frame`).map(e=>[e.id,new Set(e.contains)])),o=hU(r,Xq),s=t.flatMap(e=>{let t=MJ(e),n=[];return pU(o,t,i=>{let o=r[i];o&&!a.get(e.id)?.has(o.id)&&cG(o,t)&&n.push(i)}),n.sort((e,t)=>e-t).map(t=>BJ(r[t]?.id??``,e.id))});return[...i,...s]}function HJ(e,t,n){let{boxesById:r,warnings:i}=kJ(e,t.boxesTop,t.stackHeightByBoxId,t.stepBandPositions),a=jJ(e,r),o=FJ(e,r);return{boxesById:r,frames:a,notes:o,routing:Cq({wires:_J(e,`wire`),boxesById:r,softObstacles:[...o,...a.map(MJ)],loopFrames:a.filter(e=>e.isLoop),contentTop:t.contentTop,storedWireKeyOf:t=>e.elements.bodyOf(t.id)},n),collectPlacementWarnings:()=>[...i,...VJ(r,a,e)]}}function UJ(e){return e.step!==null&&e.near===null&&e.at===null}function WJ(e){let t=new Map;for(let n of e.elements.values())n.kind===`box`&&UJ(n)&&t.set(n.id,n);let n=new Map;if(t.size===0)return{positionById:n,bottom:Q,columns:[]};let r=new Map;for(let n of sH(e)){let e=t.get(n.boxId);e&&r.set(n.level,[...r.get(n.level)??[],e])}let i=Q,a=Q,o=[];for(let e of[...r.keys()].sort((e,t)=>e-t)){let t=r.get(e)??[],s=70,c=s;for(let e of t)n.set(e.id,{x:i,y:s}),s+=fJ(e).height,c=s,a=Math.max(a,s),s+=Dq;t.length>0&&o.push({x:i,bottom:c,boxCount:t.length}),i+=Math.max(...t.map(nJ))+Eq}return{positionById:n,bottom:a+Kq,columns:o}}function GJ(e){return e>Q?e-Oq:-1/0}function KJ(e,t){let n=(e?.columns??[]).flatMap(e=>{let n=t.filter(t=>t.x===e.x);return n.length>=e.boxCount?[]:[e.bottom-n.reduce((e,t)=>e+t.height+Dq,0)]});return n.length===0?0:Math.max(Q,...n)+Kq-Q}function qJ(e,t){if(t===0)return e;let n=[...e.elements.values()].map(e=>e.kind!==`box`||!e.at?e:{...e,at:{x:e.at.x,y:e.at.y+t}});return{...e,elements:Tt(n)}}var JJ={plain:null,fail:`failure path`,join:`joins`};function YJ(e,t,n){return`${e}|${t}|${n}`}function XJ(e,t,n){let r=[JJ[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var ZJ={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function QJ(e){return Kt.flatMap(t=>t===`none`||!e.has(t)?[]:[{label:ZJ[t],swatch:{kind:`change`,change:t}}])}function $J(e){return e?Dt.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}})):[]}function eY(e){return tY(e.legend,_J(e,`wire`),new Set(_J(e,`box`).map(e=>e.change)),e.planStepById.size>0)}function tY(e,t,n,r){let i=new Map(e.map(e=>[YJ(e.tone,e.dashed||e.back,e.back),e.label])),a=new Set,o=[...t].flatMap(e=>{let t=e.dashed||e.back,n=YJ(e.tone,t,e.back),r=i.get(n)??XJ(e.tone,t,e.back);return a.has(n)||r===null?[]:(a.add(n),[{key:n,label:r,swatch:{kind:`wire`,tone:e.tone,isDashed:t,isBack:e.back}}])}).sort((e,t)=>e.key.localeCompare(t.key)),s=e.filter(e=>!a.has(YJ(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[...o.map(({label:e,swatch:t})=>({label:e,swatch:t})),...s,...QJ(n),...$J(r)]}function nY(e,t){return t?.kind===`box`?{...e,...pJ(t,e.width)}:{...e,titleLines:[],wasLines:[],bodyLines:[]}}function rY(e,t){return{...e,lines:t?.kind===`note`?vJ(t):[]}}function iY(e,t){switch(e.kind){case`box`:return nY(e,t);case`note`:return rY(e,t);default:return e}}function aY(e,t){return{...e,elements:e.elements.map(e=>iY(e,t.elements.get(e.id)))}}function oY(e){return aY(sY(e,null).layout,e)}function sY(e,t){let{positionById:n,bottom:r,columns:i}=WJ(e),a=r-Q,o=gJ(qJ(e,a)),s=bJ(o),c=r,l=HJ(o,{boxesTop:c,contentTop:GJ(r),stackHeightByBoxId:s,stepBandPositions:n},t?.route??null),u={route:l.routing.memory},d=[...l.frames,...l.routing.wires,...l.boxesById.values(),...l.notes],f=cY(o.caption,RJ(d,l.routing.extent,c),eY(o),n.size>0?i:[],a),p=[...l.routing.collectWarnings(),fG(l.collectPlacementWarnings())];return{layout:{elements:d,...f,warnings:pG(p)},memory:u,warningLists:p}}function cY(e,t,n,r,i){let a=t.y+t.height,o=n.map((e,t)=>({...e,x:Q,y:a+t*Uq})),s=a+o.length*Uq+(o.length>0?12:0),c=e?{text:e,x:Q,y:s}:null,l=o.length*Uq+(c?30:0)+(o.length>0?12:0);return{legend:o,caption:c,pinnedOffsetY:i,plan:r.length>0?{titleAt:{x:Q,y:56},columns:[...r]}:null,bounds:{...t,height:t.height+l}}}function lY(e){return JSON.stringify(e)}function uY(e,t,n){let r=e.outputs.map(e=>({...e,port:{x:e.port.x+t,y:e.port.y+n}})),i=e.media?{...e.media,x:e.media.x+t,y:e.media.y+n}:null,a=e.device?{...e.device,x:e.device.x+t,y:e.device.y+n,screen:{...e.device.screen,x:e.device.screen.x+t,y:e.device.screen.y+n}}:null;return{...e,x:e.x+t,y:e.y+n,outputs:r,media:i,device:a}}function dY(e,t){let n=new Set(t),r=!0;for(;r;){r=!1;for(let t of e.elements.values()){let e=t.kind===`box`?t.near?.of:t.kind===`note`?t.on:void 0;!n.has(t.id)&&e&&n.has(e)&&(n.add(t.id),r=!0)}}return n}function fY(e,t,n){let r=dY(e,n),i=new Map,a=[],o=[],s=[];for(let e of t.elements)e.kind===`box`&&i.set(e.id,e),e.kind===`note`&&r.has(e.id)&&o.push(e),e.kind===`note`&&!r.has(e.id)&&a.push(e),e.kind===`frame`&&a.push(MJ(e)),e.kind===`frame`&&e.isLoop&&s.push(e);let c=[...r].flatMap(e=>i.get(e)??[]),l=[...e.elements.values()].flatMap(e=>e.kind===`wire`&&(r.has(e.from)||r.has(e.to))?[e]:[]),u=GJ(t.pinnedOffsetY+Q);return(e,t)=>{let n=c.map(n=>uY(n,e,t));for(let e of n)i.set(e.id,e);let r=o.map(n=>({...n,x:n.x+e,y:n.y+t}));return[...n,...r,...Sq({wires:l,boxesById:i,softObstacles:[...a,...r],loopFrames:s,contentTop:u})]}}var pY=2048,mY=.3,hY=.12,gY=.5,_Y=6,vY=256,yY=30,bY=12,xY=28;function SY(e){return e>=mY?`full`:e>=hY?`titles`:`blocks`}function CY(e){return`${e.lod}:${e.level}:${e.chunkX}:${e.chunkY}`}function wY(e){return pY*2**e.level}function TY(e){let t=wY(e);return{x:e.chunkX*t,y:e.chunkY*t,width:t,height:t}}function EY(e,t){let n=wY({level:t});return{firstX:Math.floor(e.x/n),lastX:Math.floor((e.x+e.width)/n),firstY:Math.floor(e.y/n),lastY:Math.floor((e.y+e.height)/n)}}function DY(e){return(e.lastX-e.firstX+1)*(e.lastY-e.firstY+1)}function OY(e,t){if(t!==`blocks`)return 0;let n=Math.max(e.width,e.height),r=0;for(;pY*2**r*_Y<n&&r<yY;)r+=1;return r}function kY(e,t){let n={x:e.x-e.width*gY,y:e.y-e.height*gY,width:e.width*2,height:e.height*2},r=OY(e,t);for(;DY(EY(n,r))>vY&&r<yY;)r+=1;let i=EY(n,r);if(DY(i)>vY)return[];let a=[];for(let e=i.firstY;e<=i.lastY;e+=1)for(let n=i.firstX;n<=i.lastX;n+=1)a.push({chunkX:n,chunkY:e,lod:t,level:r});return a}function AY(e,t){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let t of e)n=Math.min(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.x),a=Math.max(a,t.y);return n>i?{x:0,y:0,width:0,height:0}:{x:n-t,y:r-t,width:i-n+t*2,height:a-r+t*2}}function jY(e){if(e.kind===`wire`){let t=[...wq(e.path),e.start,e.end];if(e.label){let n=LK(e.label)/2+bY;t.push({x:e.labelAt.x-n,y:e.labelAt.y-24},{x:e.labelAt.x+n,y:e.labelAt.y+bY})}return AY(t,bY)}return e.kind===`frame`?{...MY(e),width:Math.max(e.width,xY+LK(e.title))}:MY(e)}function MY(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}var NY=100,PY=[],$=null,FY=null;function IY(){for(let e of PY)e()}function LY(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 RY(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function zY(e){FY!==null&&clearTimeout(FY),FY=null,e.sentTileIds=new Set(kY(e.view,e.lod).map(CY)),KY(e,t=>t.key.lod===e.lod&&!LY(t.rect,e.view))&&IY(),s({type:`whiteboard-view`,boardId:e.boardId,view:e.view,lod:e.lod,knownVersion:e.version})}function BY(e){FY===null&&(FY=setTimeout(()=>{FY=null,$===e&&zY(e)},NY))}function VY(e,t){for(let n of e.tiles.values())n.elementIds.delete(t)}function HY(e){let t=new Set;for(let n of e.tiles.values())for(let e of n.elementIds)t.add(e);for(let n of[...e.elementById.keys()])t.has(n)||e.elementById.delete(n)}function UY(e){return kY(e.view,e.lod).every(t=>e.tiles.has(CY(t))||e.sentTileIds.has(CY(t)))}function WY(e,t,n){return{boardId:e,version:null,head:null,elementCount:0,chrome:null,lod:n,view:t,sentTileIds:new Set,tiles:new Map,elementById:new Map,assembled:null}}function GY(e,t,n){let r=SY(n),i=$?.boardId!==e,a=i||!$?WY(e,t,r):$,o=a.lod!==r;$=a,a.view=t,a.lod=r,i||o||a.version===null||!UY(a)?zY(a):BY(a)}function KY(e,t){let n=!1;for(let[r,i]of[...e.tiles])!e.sentTileIds.has(r)&&t(i)&&(e.tiles.delete(r),n=!0);return n?(HY(e),e.assembled=null,!0):!1}function qY(e,t){let n=new Set;for(let r of t.elements)e.elementById.set(r.element.id,r),n.add(r.element.id);e.tiles.set(CY(t.key),{key:t.key,rect:TY(t.key),elementIds:n,raster:t.raster?RY(t.raster):null})}function JY(e){let t=$;if(t&&t.boardId===e.boardId&&(e.chrome&&(t.tiles.clear(),t.elementById.clear(),t.chrome=e.chrome),t.chrome)){t.head=e.head,t.elementCount=e.elementCount,t.version=e.version;for(let n of e.tiles)qY(t,n);KY(t,()=>!0),t.assembled=null,IY()}}function YY(e,t){VY(e,t.element.id);let n=jY(t.element),r=!1;for(let i of e.tiles.values())i.key.lod!==`blocks`&&LY(i.rect,n)&&(i.elementIds.add(t.element.id),r=!0);r?e.elementById.set(t.element.id,t):e.elementById.delete(t.element.id)}function XY(e){let t=$;if(t&&t.boardId===e.boardId){if(t.version!==e.fromVersion)t.version=null,zY(t);else{for(let n of e.diff.removedIds)VY(t,n),t.elementById.delete(n);for(let n of e.diff.changed)YY(t,n);for(let n of e.diff.rasters){let e=t.tiles.get(CY(n.key));e&&(e.raster=n.raster?RY(n.raster):null)}e.diff.chrome&&(t.chrome=e.diff.chrome),t.head=e.head,t.elementCount=e.elementCount,t.version=e.toVersion,t.assembled=null,IY()}}}function ZY(e){let t=$;if(!t||t.boardId!==e||t.version===null||!t.chrome||!t.head)return null;if(t.assembled)return t.assembled;let n=[...t.elementById.values()].sort((e,t)=>e.paintOrder-t.paintOrder),r=Tt(n.flatMap(({record:e})=>e??[])),i=[...t.tiles].flatMap(([e,t])=>t.raster?[{id:e,rect:t.rect,raster:t.raster}]:[]),a={...t.chrome,elements:n.map(({element:e})=>e),warnings:[]};return t.assembled={version:t.version,lod:t.lod,layout:a,blocks:i,board:{...t.head,elements:r},elementCount:t.elementCount},t.assembled}function QY(e){if(!$||$.version===null)return;let t=e.get($.boardId);t===void 0?eX($.boardId):t!==$.version&&($.version=null,zY($))}function $Y(){$&&($.version=null,zY($))}function eX(e){$?.boardId===e&&(FY!==null&&clearTimeout(FY),FY=null,$=null,IY())}function tX(e){PY.push(e)}var nX={"whiteboards-snapshot":e=>{nO(e),QY(new Map(e.boards.map(e=>[e.id,e.version])))},"whiteboard-removed":e=>{eX(e.boardId),rO(e)},"whiteboard-tiles":e=>JY(e),"whiteboard-tile-diff":e=>XY(e)},rX=`Worktree`,iX=`Worktree warning`,aX=ZB([MV,NV,{"session-worktree-blocked":e=>{sr({source:rX,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=>{sr({source:iX,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=>{or(rX,e.id),EC(e.id,e.base)},"session-diff":e=>{zy(e.id,e)},"session-diff-error":e=>{By(e.id,e.message)},"change-map":e=>Vy(e.id,e.map),"session-changed":e=>Hy(e.id)},sV,nX,cV,lV]),oX=new Set([...Object.keys(NV),...Object.keys(sV)]);function sX(e){let t=aX[e.type];t&&t(e)}function cX(){i(e=>{sX(e),BL(e.type)}),kV((e,t)=>{if(t.type===`snapshot`){BB(t.sessions,e);return}let n=t.type===`error`&&typeof t.id==`string`;(oX.has(t.type)||n)&&(sX(t),BL(t.type))})}function lX(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 uX(){BO({panels:lX(K),onScreenShown:e=>{zL(e),e!==`settings`&&OL(),e===`settings`&&!eF(location.hash)&&RP(),FL(e)},canGoBack:e=>e===`settings`&&UP()||e===`prs`&&l_(),onBack:e=>{e===`settings`&&WP(),e===`prs`&&u_()},headerControls:[T(document,`.header-title`,`h1`),T(document,`#status-indicator`,`div`),T(document,`#celebration-tray`,`div`),HR,UR,GR]}),HP(YO),c_(YO)}function dX(e){if(e===`phone`){let e=W();for(let e of K)aL(e.view)?.deactivate?.();let t=eF(location.hash);VO({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}).then(e=>{e&&t&&RP(null,null,location.hash),!e&&Ko()&&!UO()&&iR()});return}let t=WO();HO(),iR(),t&&QN(t)}function fX(){uX(),Ko()&&dX(`phone`),qo(dX)}function pX(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function mX(e){QN(e),Ui(e),requestAnimationFrame(()=>requestAnimationFrame(()=>k.get(e)?.term?.focus()))}function hX(){let e=pX()??Li();e?Gi(e):document.getElementById(`btn-add-session-header`)?.click()}function gX({action:e,step:t}){switch(e){case`merge`:{let e=Li();return!e||IM()?!1:(Jy(e),!0)}case`close-session`:{let e=Li();return e?(Ii(e),!0):!1}case`board-split`:return FM()&&XM();case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return hX(),!0;case`next-attention`:return Ko()?!1:FM()?(jN(),!0):(rr()===`prs`&&d_()||rP(()=>q(`focus`)),!0);case`rail-step`:return FM()?(tP(t),!0):!1;case`view-step`:return!Ko()&&(JL(qL(rr(),t)),!0);case`session-nth`:return FM()?(eP(t),!0):!1;case`streamer-mode`:return rl(),!0}}function _X(e){return e.code!==`KeyZ`||e.altKey||e.shiftKey?!1:Au===`mac`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function vX(){Mi(mX),document.addEventListener(`keydown`,e=>{if(e.repeat||It(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1;if(!t&&_X(e)&&!Zt()&&Ai()){e.preventDefault(),e.stopImmediatePropagation();return}let n=Hr(e,Au,{isTerminalFocused:t},Nu());n&&(Zt()||gX(n)&&e.preventDefault())})}function yX(){let e=u(s);window.addEventListener(`error`,t=>{e(t.error),y(`uncaught`,l(t.error??t.message))}),window.addEventListener(`unhandledrejection`,t=>{e(t.reason),y(`unhandled-rejection`,l(t.reason))}),lL(()=>window.sessionStorage)}qa(Lr()),Ya(()=>{N(()=>import(`./alert-sound-At4lBeip.js`).then(e=>e.playNyanJingle(),e=>y(`alert-sound`,`nyan jingle failed to load: ${l(e)}`)),__vite__mapDeps([10,6]))}),ep(zr()),Go(),id(document),xB(),PB(),FD(s),N(()=>import(`./your-day-tip-CUPrvYlw.js`).then(e=>e.startYourDayTips({openUsage:()=>EL(`usage`)}),e=>y(`your-day-tip`,`your day tips failed to load: ${l(e)}`)),__vite__mapDeps([65,13,4,3,63,61,5,6,7,8,14,64,19])),nv(s),QS(s),Np(s),sa(s),rn(C_),Mn(Ta),Mn(b_,`links`),Mn(wO,`links`),pn(EO),yO(DL),Fn({isReadable:Ea,open:Oa}),an(WC),$c(()=>BL(`settings-updated`)),cX(),_z(),JR(),fR(),YR(),aR(),fX(),vX(),nk(),yX(),G_(T(document,`#health-footer-mount`,`div`)),Eu(SC),_B(),Gf(),p();var bX=ii();bX&&x().then(()=>ou(bX));export{KP as $,Iu as $a,Eh as $i,GT as $n,JS as $r,QD as $t,jI as A,Up as Aa,Qg as Ai,pE as An,dE as Ar,FA as At,vF as B,xp as Ba,bh as Bi,Cw as Bn,sw as Br,Mk as Bt,gR as C,vm as Ca,rv as Ci,Hw as Cn,Pw as Cr,aj as Ct,wL as D,im as Da,qg as Di,_w as Dn,BE as Dr,lA as Dt,SL as E,bm as Ea,Zg as Ei,BT as En,lE as Er,PA as Et,zF as F,kp as Fa,f_ as Fi,HE as Fn,$E as Fr,Uk as Ft,aF as G,jf as Ga,gg as Gi,TT as Gn,YC as Gr,Ek as Gt,_F as H,Tp as Ha,Ch as Hi,Xw as Hn,rw as Hr,Tk as Ht,WF as I,yp as Ia,Xg as Ii,RT as In,eD as Ir,Vk as It,$P as J,Gu as Ja,cg as Ji,YT as Jn,zC as Jr,fk as Jt,rF as K,Vd as Ka,eg as Ki,UE as Kn,qC as Kr,yk as Kt,GF as L,jp as La,o_ as Li,fE as Ln,cE as Lr,Lk as Lt,YF as M,wp as Ma,a_ as Mi,oT as Mn,tD as Mr,DA as Mt,VF as N,Cp as Na,t_ as Ni,aT as Nn,zE as Nr,wA as Nt,JI as O,am as Oa,n_ as Oi,vw as On,Ow as Or,dA as Ot,BF as P,Dp as Pa,s_ as Pi,iT as Pn,KT as Pr,Hk as Pt,VP as Q,Lu as Qa,vg as Qi,tT as Qn,XS as Qr,AO as Qt,KF as R,Mp as Ra,Eg as Ri,Mw as Rn,Rw as Rr,Fk as Rt,Hz as S,Hm as Sa,ev as Si,Tw as Sn,aD as Sr,$A as St,xL as T,ym as Ta,I as Ti,VT as Tn,TE as Tr,fA as Tt,gF as U,bp as Ua,mg as Ui,Kw as Un,nw as Ur,Dk as Ut,hF as V,Sp as Va,Vh as Vi,VE as Vn,ow as Vr,Sk as Vt,iF as W,ep as Wa,rg as Wi,ET as Wn,hw as Wr,Ok as Wt,GP as X,Au as Xa,ng as Xi,Uw as Xn,ZS as Xr,kO as Xt,tF as Y,Bu as Ya,dg as Yi,qT as Yn,oC as Yr,ok as Yt,kP as Z,Pu as Za,Bh as Zi,Ww as Zn,YS as Zr,DO as Zt,QV as _,Cm as _a,bb as _i,UD as _n,$a as _o,HT as _r,tj as _t,fY as a,Th as aa,Tx as ai,uO as an,Zc as ao,Qw as ar,LP as at,SV as b,Nm as ba,wv as bi,CT as bn,aa as bo,LE as br,ej as bt,DJ as c,Ph as ca,ux as ci,oO as cn,Xs as co,PE as cr,DP as ct,KJ as d,ch as da,xx as di,jD as dn,is as do,QE as dr,cP as dt,hg as ea,qS as ei,iO as en,Fu as eo,ZT as er,MP as et,wq as f,Bm as fa,mx as fi,LD as fn,Ko as fo,WE as fr,uP as ft,YV as g,Mm as ga,kb as gi,OD as gn,qa as go,XE as gr,sj as gt,ZV as h,Lm as ha,jb as hi,kD as hn,Xa as ho,_T as hr,rj as ht,ZY as i,Ih as ia,Mx as ii,pO as in,wl as io,nE as ir,BP as it,MI as j,Op as ja,u_ as ji,zw as jn,uE as jr,uA as jt,qI as k,Hp as ka,r_ as ki,rE as kn,kw as kr,pA as kt,oY as l,uh as la,cx as li,PD as ln,Hs as lo,wE as lr,zP as lt,hU as m,zm as ma,Nb as mi,AD as mn,eo as mo,yT as mr,ij as mt,$Y as n,yg as na,KS as ni,eO as nn,Tl as no,oD as nr,FP as nt,lY as o,tg as oa,Dx as oi,aO as on,$c as oo,Zw as or,OP as ot,pU as p,jm as pa,Fb as pi,ID as pn,qo as po,ZE as pr,Vj as pt,nF as q,nd as qa,Hh as qi,bT as qn,KC as qr,pk as qt,GY as r,bg as ra,yS as ri,$D as rn,El as ro,KE as rr,WP as rt,UJ as s,ug as sa,hx as si,_O as sn,el as so,FE as sr,AP as st,tX as t,wh as ta,GS as ti,sO as tn,Nu as to,PT as tr,NP as tt,uY as u,lh as ua,px as ui,RD as un,Os as uo,Aw as ur,lP as ut,XV as v,Pm as va,xb as vi,oE as vn,oa as vo,WT as vr,QA as vt,_R as w,xm as wa,tv as wi,sT as wn,nD as wr,Yk as wt,oV as x,_m as xa,jv as xi,Vw as xn,iD as xr,XA as xt,OV as y,Sm as ya,Mv as yi,IE as yn,ca as yo,GE as yr,nj as yt,RF as z,Ap as za,Dg as zi,Dw as zn,ZC as zr,Nk as zt};
|
|
77
|
+
`),h=m===DM;DM=m;let g=t.querySelector(`:scope > .rail-new-board`);for(let e of o.groups){let{header:n,list:r}=PM(e);h||t.insertBefore(n,g),h||t.insertBefore(r,g);let i=e.hostId===null?a.get(e.key):void 0;f(e.rows,r,i?wN(e.key,i,c):[])}TN(c,p),Yj(t,{firstGroupHeaderOf:e=>NM(o.groups,e),trailingNode:g});for(let[e,t]of[...EM])p.has(e)||(t.header.remove(),TM.get(e)?.remove(),EM.delete(e),TM.delete(e));for(let[e,t]of H)l.has(e)||(t._row.remove(),H.delete(e),vN.delete(e),e===U&&(U=null));for(let e of[...wM.keys()])k.has(e)||wM.delete(e);let _=OM;OM=Rr(r,kM);let v=W();if(v&&!zi(v)){rj(),M.dispatch(`focusSession`,null),U=null;let e=ON(_,v);if(e){let t=!document.activeElement||document.activeElement===document.body;qN(e),t&&NN(k.get(e),e);return}}JN();let y=W();if(y){let e=k.get(y);e&&e.card.parentElement!==sM&&FN(e,y)}cM?.showSession(B?null:y),BN(),GM(),AN(n,u)}function yN(e,t,n){e.open=t,e.addEventListener(`toggle`,()=>n(e.open))}function bN(e){let{row:t,refs:n}=Dn();t.dataset.boardId=e,t.draggable=!0,t.addEventListener(`click`,()=>EN(e)),t.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(tM,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`link`)});let r=D(`div`,`session-row-item`);return r.dataset.boardNode=e,r.append(t),Object.assign(t,{_refs:n,_row:r})}function xN(e){let t=D(`details`,`focus-board-archive`);t.dataset.boardNode=`archive:${e}`;let n=D(`div`,`focus-board-archive-list`);return t.append(D(`summary`,`focus-board-archive-summary`,`Archived`),n),{details:t,list:n}}function SN(e){let t=e.connectedSessionIds.map(e=>k.get(e)).find(e=>e!==void 0);return t?aN(t):null}function CN(e,t){let n=_M.get(e.id);return n||(n=bN(e.id),_M.set(e.id,n)),An(n,n._refs,e.title,SN(e)),n.classList.toggle(`focused`,e.id===B),t.add(e.id),n._row}function wN(e,t,n){let r=t.active.map(e=>CN(e,n));if(t.archived.length===0)return r;let i=vM.get(e)??xN(e);return vM.set(e,i),ji(i.list,t.archived.map(e=>CN(e,n))),[...r,i.details]}function TN(e,t){for(let[t,n]of _M)e.has(t)||(n._row.remove(),_M.delete(t));for(let[e,n]of vM)t.has(e)&&n.list.childElementCount>0||(n.details.remove(),vM.delete(e))}function EN(e){V&&(KN(),B=e,jM(null),G())}function DN(){LN().then(e=>e.createBoardFromDialog(EN),RN)}function ON(e,t){let n=e.filter(e=>e===t||zi(e));if(n.length<2)return OM.find(e=>zi(e))??null;let r=n.indexOf(t)===n.length-1;return Un(n,t,r?-1:1)}function kN(){return nr(iN(),W())}function AN(e,t){iM&&(pA(iM,Yn(e),t),aM&&FA(aM,e))}function jN(){if(!V)return;iM&&DA(iM);let e=kN()[0]?.id;e&&MN(e)}function MN(e){V&&(Bi(e),H.get(e)?.scrollIntoView({block:`nearest`}),iM&&wA(iM,e,()=>PN(e)),qN(e),NN(k.get(e),e))}function NN(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{V&&W()===t&&e.term?.focus()}))}function PN(e){if(nM?.matches||document.hidden)return;let t=H.get(e);t?.animate&&(t.animate([{transform:`scale(1)`},{transform:`scale(1.045)`,offset:.3},{transform:`scale(1)`}],{duration:360,easing:`cubic-bezier(0.22, 1, 0.36, 1)`}),t._row.animate([{boxShadow:`0 0 0 3px var(--accent)`},{boxShadow:`0 0 0 3px transparent`}],{duration:700,easing:`ease-out`}));let n=k.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function FN(e,t){if(!sM)return;let n=e.card.querySelector(`:scope > .session-card-header`);kO(e,t,sM,{className:`focus-centered`,onRelease:()=>{n?.classList.remove(`pane-header`),z?.setHeaderHost(`terminal`,null)}}),n?.classList.add(`pane-header`),n&&IN(n),jf(e,t,!0)}function IN(e){let t=e.querySelector(`:scope > .session-name`);z?.setHeaderHost(`terminal`,{parent:e,before:t})}function LN(){return lM??=N(()=>import(`./boards-view-BiwLooLF.js`).then(e=>(uM=e,e.onBoardPicked(HN),e)),__vite__mapDeps([36,3,4,12,13,14,30,21,15,19,23,37])),lM}function RN(e){lM=null,y(`focus`,`the board pane failed to load: ${l(e)}`)}function zN(e){z&&fM!==e&&(fM=e,z.showPanes(e))}function BN(){if(B){zN(Qj),VN(null,B);return}let e=W(),t=HM(e);!e||!t?(zN(Xj),dM=null):(zN(Zj),VN(e,t))}function VN(e,t){let n=`${e??``}\n${t}`,r=dM!==n;dM=n,LN().then(n=>UN(n,e,r?t:null),RN)}function HN(e){if(!V)return;if(B){B=e,dM=`\n${e}`,G();return}let t=W();t&&(BM(bi(pM,t,e)),dM=`${t}\n${e}`,G())}function UN(e,t,n){if(!z||W()!==t)return;let r=z.bodyOf(`board`),i=e.mountBoardHost();i.parentElement!==r&&r.replaceChildren(i),e.placeBoardTitle(z.boardTitleSlot),n&&e.showBoardBeside(n,t)}function WN(){V&&dM!==null&&uM?.reopenSelectedBoard()}function GN(){let e=_O();V&&e?.sessionId&&k.has(e.sessionId)&&ZM(e.sessionId,e.boardId)}function KN(){rj();let e=W();e&&(DO()===e&&AO(),M.dispatch(`focusSession`,null))}function qN(e){V&&k.has(e)&&(zC(e),Ui(e),e!==W()&&(KN(),B=null,M.dispatch(`focusSession`,e),U=e,G()))}function JN(){if(!yM||!bM||!xM)return;let e=W(),t=!!B||!!(e&&k.has(e)),n=k.size>0;Ri(yM,t),z&&Ri(z.element,!t),yk(yM,!n),Ri(bM,!n),Ri(xM,!n),!t&&n&&(Si(bM,`No session selected`),Si(xM,`Select a session from the rail on the left to focus it here.`))}function YN(e,t){wM.set(O(e),typeof t==`string`&&t?t:`none`),V&&G()}var XN={placement:`overlay`,sessionId:()=>V&&oM&&!B?W():null,elementFor:()=>{if(!oM)throw Error(`Focus view is not mounted`);return oM},didShow:()=>{},didHide:()=>{let e=W();e&&NN(k.get(e),e)}};function ZN(e=null){let t=W();t&&nj(`changes`,t,e)}function QN(e){V&&k.has(e)&&qN(e)}function $N(e){return!V||!k.has(e)?!1:(qN(e),Mx(e))}function eP(e){if(!V)return;let t=AM()[e-1];t&&zi(t)&&uN(t)}function tP(e){if(!V)return;let t=AM().filter(e=>e===U||zi(e)),n=Un(t,U,e);n!=null&&zi(n)&&(fN(n),H.get(n)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=W();V&&e&&zC(e)});function nP(){rM&&(V=!0,$A(XN),KN(),U=null,G(),SM&&CM?MN(CM):SM&&kN().length>0?jN():(SM&&iM&&DA(iM),iP()))}function rP(e,t=null){SM=!0,CM=t;try{e()}finally{SM=!1,CM=null}}function iP(){if(!V||W()||B)return;let e=Ni();e&&qN(e)}function aP(){V&&=(KN(),ej(XN),U=null,!1)}var oP=[],sP=new Set;function cP(e){let t=et.safeParse(e);if(t.success){oP=t.data;for(let e of sP)e()}}function lP(e){return oP.find(t=>t.agent===e)??null}function uP(e){return sP.add(e),()=>{sP.delete(e)}}var dP=2e3,fP={},pP=null,mP=null,hP=Ye,gP=null,_P=!1,vP=null,yP=[],bP=null,xP=()=>null,SP=()=>{},CP=!1,wP=new Set,TP=new Set;function EP(e){for(let t of TP)t(e)}function DP(e){TP.add(e)}function OP(){return fP}function kP(e){return fP={...fP,...e},fP}function AP(){return{status:pP,journal:mP,request:hP,lastAutoCheckAt:gP,isCheckInFlight:_P,checkSendFailure:vP}}function jP(e){let t=Oe(hP,e);t!==hP&&(hP=t,EP({kind:`update`,frame:`request`}))}function MP(){jP(s({type:`update-apply`})?`request-sent`:`request-unsent`)}function NP(){gP=Date.now();let e=s({type:`update-check`});_P=e,vP=e?null:S,EP({kind:`update`,frame:`request`})}function PP(e){SP=e}function FP(){SP()}function IP(e){yP=[...e]}function LP(){return yP}function RP(e=null,t=null,n=null){let r=bP!==null&&(bP.sectionId!==null||bP.isLink);e===null&&n===null&&r||(bP={sectionId:e,settingId:t,hashAtRequest:n??location.hash,isLink:n!==null},EP({kind:`activate`}))}function zP(){let e=bP;return bP=null,e}function BP(e){xP=e}function VP(){for(let e of wP)e()}function HP(e){wP.add(e)}function UP(){return Ko()&&xP()===`section`}function WP(){UP()&&EP({kind:`return-to-list`})}function GP(e){e&&(fP=e,cP(fP.agentLogins),EP({kind:`broadcast`}))}function KP(){CP||(CP=!0,window.setTimeout(()=>{c(`get-settings`,{}).then(e=>{e.settings&&GP(e.settings)}).catch(()=>{CP=!1})},dP))}function qP(){EP({kind:`status`})}function JP(e){qP()}function YP(e){pP=e,_P=!1,vP=null,hP=Oe(hP,`status-frame`),EP({kind:`update`,frame:`status`})}function XP(e){mP=e,hP=Oe(hP,`progress-frame`),EP({kind:`update`,frame:`progress`})}function ZP(e){if(e.scope!==`update`)return!1;let t=Ne(e.message),n=hP.requested;return hP=Oe(hP,`error-frame`,t),_P=!1,n||(vP=t),EP({kind:`update`,frame:`error`}),!0}var QP=200;function $P(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function eF(e){return/^#settings(?:[/?]|$)/.test(e)}function tF(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function nF(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,QP).join(``).trim()}}function rF(e,t,n){let r=D(`a`,`settings-link`,n);return r.href=$P(e,t),r}var iF={teamReview:e=>e?.teamReview?.enabled!==!1,issues:e=>e?.issues?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,community:e=>e?.community?.enabled===!0},aF=[{rule:`teamReview`,sectionId:`lanes-team-review`,settingId:`team-review-enabled`},{rule:`issues`,sectionId:`lanes-issues`,settingId:`issues-enabled`},{rule:`usage`,sectionId:`machine-usage`,settingId:`usage-enabled`},{rule:`posthog`,sectionId:`lanes-posthog`,settingId:`posthog-enabled`},{rule:`community`,sectionId:`lanes-community`,settingId:`community-enabled`}],oF=null,sF=null,cF=null,lF=()=>!1,uF=new Set,dF=new Set,fF=_t({getAck:oi,setAck:Sr,signature:()=>at({posthog:oF}),isLooking:()=>lF()});function pF(e){for(let t of dF)t(e)}function mF(){sF?.(fF.refresh())}function hF(){return{latest:oF,archivedLocally:uF,traceOpener:cF}}function gF(e){dF.add(e)}function _F(e){lF=e,mF()}function vF(e){uF.add(e)}function yF(){fF.acknowledge(),mF()}function bF(e){sF=e,mF()}function xF(e){cF=e}function SF(e){oF=e,lt(oF,uF),pF({kind:`status`}),mF()}function CF(e){let t=Le(oF,e.projectId,e.issueId)?.inFlight===!0;nt(oF,e)&&pF({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function wF(e){let t=be(oF,e);pF({kind:`investigation-finished`,frame:e,isPatched:t}),t&&mF()}var TF=null,EF=[],DF=()=>!1,OF=null,kF=di(),AF=ni(),jF=new Set(AF.split(`|`).filter(Boolean)),MF=new Set;function NF(e){for(let t of MF)t(e)}function PF(){return tg(EF).map(eg)}function FF(e){e!==kF&&(kF=e,Pr(e))}function IF(e){e!==AF&&(AF=e,jF=new Set(e.split(`|`).filter(Boolean)),Or(e))}function LF(){if(!TF)return;let e=pg({turnEntries:PF(),acknowledged:kF,unseen:AF,isLooking:DF()});FF(e.acknowledged),IF(e.unseen),OF?.(e.isShown)}function RF(e){MF.add(e)}function zF(){return TF}function BF(){return EF}function VF(e){DF=e,LF()}function HF(e){OF=e,LF()}function UF(){TF&&(FF(dt(PF())),LF())}function WF(){return AF}function GF(e){return jF.has(e)}function KF(e){return jF.has(e)?(IF(dt([...jF].filter(t=>t!==e))),!0):!1}function qF(e){let t=Ie.safeParse(e);t.success?(TF=t.data,EF=$h(t.data.entries),LF(),NF({kind:`status`})):y(`community`,`dropped community-status: ${r(t.error.issues)}`)}function JF(e){NF({kind:`connection`,isConnected:e})}function YF({source:e,className:t,title:n,allowsScripts:r}){let i=D(`iframe`,t);return i.setAttribute(`sandbox`,r?`allow-scripts allow-forms`:``),i.setAttribute(`allow`,``),i.referrerPolicy=`no-referrer`,i.title=n,e.kind===`srcdoc`&&(i.srcdoc=e.html),e.kind===`url`&&(i.src=e.url),i}var XF=`panel-action`,ZF=524288,QF=[`key`,`prKey`,`repo`,`number`,`action`,`actionId`,`itemKey`,`fingerprint`],$F=900;function eI(e){let t=le.options.find(t=>t.shape.type.value===e);return new Set(Object.keys(t?.shape??{}).filter(e=>e!==`type`&&e!==`requestId`))}function tI(e){return e.map(e=>`${e.path.map(String).join(`.`)||`request`}: ${e.message}`).join(`; `)}function nI(e,t){let n=_e.safeParse(t);if(!n.success)return{ok:!1,error:`not sent: ${tI(n.error.issues)}`};if(!e.includes(`reviews`))return{ok:!1,error:`${n.data.type} not sent: this panel does not list reviews under acts in pack.json`};let r=le.safeParse({...n.data,requestId:XF});if(!r.success)return{ok:!1,error:`${n.data.type} not sent: ${tI(r.error.issues)}`};let i=eI(r.data.type),a=Object.fromEntries(Object.entries(r.data).filter(([e])=>i.has(e))),o=new TextEncoder().encode(JSON.stringify(a)).length;return o>524288?{ok:!1,error:`${r.data.type} not sent: the request is ${o} bytes, over the ${ZF} byte limit`}:{ok:!0,type:r.data.type,payload:a}}function rI(e,t,n){return`${e} sent ${t} ${QF.flatMap(e=>{let t=n[e];return typeof t==`string`||typeof t==`number`?[`${e}=${t}`]:[]}).join(` `)}`.trim().slice(0,$F)}var iI=`[^/\\\\\\s"'\`<>:]+`,aI=RegExp(`(?<![\\w./\\\\-])(?:/home/${iI}|/Users/${iI}|[A-Za-z]:[\\\\/]Users[\\\\/]${iI}|/root(?![\\w.-]))`,`g`);function oI(e){return e.replace(aI,`~`)}function sI(e){return oI(Kc(e))}var cI=1e3,lI=12e4,uI=new Map,dI=null;function fI(e){return Zc()?sI(e):e}var pI={sessions:()=>({sessions:[...k].map(([e,t])=>({id:e,name:fI(Kn(t)),agent:t.agent??null,state:t.currentState,stateSinceMs:t.stateSince,taskTitle:t.taskTitle===null?null:fI(t.taskTitle)}))}),focus:()=>({sessionId:M.snapshot().focusedSessionId,view:M.snapshot().activeView,isStreamerMode:Zc()}),theme:()=>Qa(),usage:()=>({planLimits:Object.entries(OD().planLimitsByVendor).flatMap(([e,t])=>t===null||e!==`claude`&&e!==`codex`&&e!==`kimi`?[]:[{vendor:e,fiveHour:cw(t,`fiveHour`),sevenDay:cw(t,`sevenDay`)}])}),attention:()=>{let e=Yn([...k.values()].map(e=>({state:e.currentState,unseenOutcome:e.unseenOutcome??null})));return{waiting:e.waitingCount,finished:e.finishedCount,failed:e.failedCount}},reviews:()=>p_()};function mI(e,t){e.frame.contentWindow?.postMessage(t,`*`)}function hI(e,t){let n=t.get(e);if(n)return n;let r=pI[e](),i={data:r,dataJson:JSON.stringify(r)};return t.set(e,i),i}function gI(e,t,n=new Map){let{data:r,dataJson:i}=hI(t,n);e.lastSentJsonByTopic.get(t)!==i&&(e.lastSentJsonByTopic.set(t,i),mI(e,we.parse({v:1,kind:`topic`,topic:t,data:r})))}function _I(){let e=!1,t=new Map;for(let n of uI.values()){for(let e of n.subscribedTopics)gI(n,e,t);e||=n.subscribedTopics.size>0}e||dI===null||(clearInterval(dI),dI=null)}var vI=new Map;async function yI(e,t){let n=await c(e,t).catch(e=>zn(e));return typeof n==`string`?{ok:!1,error:n}:n.type===`pack-data-result`?n.ok&&n.data?{ok:!0,data:n.data}:{ok:!1,error:n.error??`the pack store did not answer`}:{ok:!1,error:`unexpected ${n.type} reply`}}function bI(e,t){mI(e,{v:1,kind:`store`,data:vI.get(e.packName)??{},error:t})}async function xI(e){let t=await yI(`pack-data-get`,{pack:e.packName});t.ok&&vI.set(e.packName,t.data),bI(e,t.ok?null:t.error)}async function SI(e,t,n){let r=ke(e.packName,Se(vI.get(e.packName)??{},t,n));if(r!==null){bI(e,r);return}let i=await yI(`pack-data-set`,{pack:e.packName,key:t,value:n});if(!i.ok)bI(e,i.error);else{vI.set(e.packName,i.data);for(let t of uI.values())t.packName===e.packName&&bI(t,null)}}function CI(e,t){e.subscribedTopics=new Set(t.filter(t=>e.grantedTopics.has(t))),e.lastSentJsonByTopic.clear(),mI(e,{v:1,kind:`hello`,granted:[...e.subscribedTopics]}),xI(e);for(let t of e.subscribedTopics)gI(e,t);dI??=setInterval(_I,cI)}function wI(e,t,n,r,i=!1){mI(e,{v:1,kind:`action-result`,id:t,ok:r===null,timedOut:i,result:n,error:r})}function TI(e,t){return t.ok===!1?typeof t.error==`string`&&t.error!==``?t.error:`${e} was refused`:null}async function EI(e,t,n){let r=nI(e.acts,n);if(!r.ok){wI(e,t,null,r.error);return}s({type:`client-log`,scope:`packs`,text:rI(e.viewId,r.type,r.payload)});let i=await c(r.type,r.payload,{timeoutMs:lI}).catch(e=>zn(e));if(i===`Request timed out`){wI(e,t,null,`${r.type} got no answer within ${lI/1e3} s; it may still run, so check before sending it again`,!0);return}if(typeof i==`string`){wI(e,t,null,`${r.type} failed: ${i}`);return}let a={...i};wI(e,t,a,TI(r.type,a))}function DI(e){let t=[...uI.values()].find(t=>t.frame.contentWindow!==null&&t.frame.contentWindow===e.source);if(!t)return;let n=Ee.safeParse(e.data);if(n.success){EI(t,n.data.id,n.data.request);return}let r=ye.safeParse(e.data);r.success&&(r.data.kind===`store-set`?SI(t,r.data.key,r.data.value):r.data.kind===`subscribe`&&CI(t,r.data.topics))}function OI(e,t,n){uI.size===0&&window.addEventListener(`message`,DI),uI.set(e,{viewId:e,frame:t,packName:n.pack,acts:n.acts,grantedTopics:new Set(n.reads),subscribedTopics:new Set,lastSentJsonByTopic:new Map})}var kI=null,AI=new Set;function jI(){return kI}function MI(e){return AI.add(e),()=>AI.delete(e)}function NI(e){let t=Ce.safeParse(e);if(!t.success)y(`settings`,`dropped packs-status: ${r(t.error.issues)}`);else{kI=t.data,Ka(t.data.themes)&&eo();for(let e of AI)e()}}var PI=`about:blank`,FI={pack:``,reads:[],acts:[]},II=new Map,LI=new Map;function RI(e){let t=D(`img`,`pack-tab-icon`);return t.src=e,t.alt=``,t.decoding=`async`,t.referrerPolicy=`no-referrer`,t}function zI(e){return LI.set(e.viewId,e),{mount(t){let n=LI.get(e.viewId);t.replaceChildren(BI(e.viewId,n?.entryUrl??PI,e.label,n??FI))}}}function BI(e,t,n,r){let i=YF({source:{kind:`url`,url:t},className:`pack-panel-frame`,title:n,allowsScripts:!0});return II.set(e,i),OI(e,i,r),i}function VI(e,t,n,r){let i=II.get(e);i&&i.getAttribute(`src`)!==t&&i.replaceWith(BI(e,t,n,r))}function HI(e){LI.set(e.viewId,e),VI(e.viewId,e.entryUrl,e.label,e)}function UI(e){LI.delete(e),VI(e,PI,II.get(e)?.title??``,FI)}function WI(e){let t=()=>e(jI()?.panels??[]);MI(t),t()}function GI(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function KI(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function qI(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 JI(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 YI(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function XI(e,t,n){t&&e?.refreshOn?.includes(n)&&t.refresh?.(n)}function ZI(e,t,n,r){for(let i of e)GI(i.view,t)&&XI(i,r(i.view),n)}function QI(){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 $I(e,t,n){let r=Number(e);return!e||!Number.isFinite(r)||t-r>n}var eL=`glimmervoid:preload-error-reload-at`,tL=3e4,nL=1e3,rL=QI();function iL(e,t){let n=rL.mountedModuleOf(e.view);n?t(n):rL.show(e).then(t).catch(t=>{throw y(`view`,`${e.view} failed to show: ${l(t)}`),t})}function aL(e){return rL.mountedModuleOf(e)}function oL(e){rL.mountEagerViews(e)}function sL(e){let t=()=>{rL.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,nL)}function cL(e){let t=Date.now();$I(e.getItem(eL),t,tL)&&(e.setItem(eL,String(t)),location.reload())}function lL(e){window.addEventListener(`vite:preloadError`,()=>cL(e()))}function uL(e,t){fetch(e,{method:`HEAD`,cache:`no-store`}).then(e=>{e.status===404&&cL(t())}).catch(()=>{})}function dL(e,t,n){let r=T(document,`#app-main`,`main`),i=Be(`header-tab`,e.label);i.prepend(t),i.id=`tab-${e.view}`,i.draggable=!0;let a=`view-${e.view}`;i.setAttribute(`role`,`tab`),i.setAttribute(`aria-controls`,a);let o=e.view===`focus`;i.setAttribute(`aria-selected`,String(o)),i.tabIndex=o?0:-1;let s=document.getElementById(a)??D(`section`);if(s.classList.add(e.panelClass),s.id=a,s.setAttribute(`role`,`tabpanel`),s.setAttribute(`aria-labelledby`,i.id),s.hidden=!0,s.parentElement||r.append(s),i.hidden=e.gate!==void 0||e.isPhoneOnly===!0,s.classList.toggle(`view-panel`,e.hasPanelChrome!==!1),e.attention){let t=D(`span`,`tab-activity`);t.id=`tab-${e.view}-activity`,t.setAttribute(`aria-hidden`,`true`),i.append(t),e.attention.subscribe(r=>{let{isActive:i,level:a}=YI(r);t.classList.toggle(`active`,i),a===null&&t.removeAttribute(`data-attention`),a!==null&&t.setAttribute(`data-attention`,a),n(e.view,r)})}return{...e,tab:i,el:s}}function fL(e){return e.iconUrl?RI(e.iconUrl):Te(He)}function pL(e){return dL({view:e.viewId,label:e.label,iconPath:``,panelClass:`pack-panel-view`,hasPanelChrome:!1,module:zI(e)},fL(e),()=>{})}function mL(e,t){e.tab.replaceChildren(fL(t),t.label)}function hL(e){i_({openTerminal:e.openTerminal,openReviews:e.openReviews}),Bk({openTerminal:e.openTerminal}),PP(e.onRestart),fO(e.openReviewFile);let t=[{view:`focus`,label:`Focus`,iconPath:tt,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,refreshOn:[`connected`],module:{mount:()=>LM({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:nP,deactivate:aP,refresh:WN}},{view:`prs`,label:`Reviews`,iconPath:Ae,panelClass:`pr-view`,gate:{fromSettings:iF.teamReview},load:()=>N(()=>import(`./review-queue-panel-I8RK2j4B.js`).then(e=>e.view),__vite__mapDeps([38,39,14,13,4,3,12,32,40,15,41,29,26,19,22,27,5,6,7,18,30,21,31,28,42,35,43])),refreshOn:[`shown`],attention:{subscribe:e_,acknowledge:$g},onConnectionChange:e=>{gh(e),Mg(e)}},{view:`issues`,label:`Issues`,iconPath:ze,panelClass:`issues-view`,gate:{fromSettings:iF.issues},load:()=>N(()=>import(`./issues-panel-BE4a2m0n.js`).then(e=>e.view),__vite__mapDeps([44,13,4,3,12,14,32,41,29,26,15,19,22,27,5,6,7,18,30,21,31,28,42,23,45])),refreshOn:[`shown`],onConnectionChange:Fp},{view:`usage`,label:`Usage`,iconPath:pe,panelClass:`usage-view`,gate:{fromSettings:iF.usage},load:()=>N(()=>import(`./usage-panel-BBEw22J_.js`).then(e=>e.view),__vite__mapDeps([46,3,4,13,47,48])),attention:{subscribe:ND,acknowledge:MD},onConnectionChange:zD,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,iconPath:pt,panelClass:`radar-view`,gate:{fromSettings:iF.posthog},load:()=>N(()=>import(`./radar-panel-7-5n1ink.js`).then(e=>e.view),__vite__mapDeps([49,13,4,3,47,50,12,14,34,26,15,19,22,27,5,6,7,18,31,28,51])),attention:{subscribe:bF,acknowledge:yF}},{view:`community`,label:`Community`,iconPath:We,panelClass:`community-view`,gate:{fromSettings:iF.community},load:()=>N(()=>import(`./community-panel-CMwSKMoo.js`).then(e=>e.view),__vite__mapDeps([52,13,4,3,39,14,12,32,40,42,5,6,7,19,15,35,53])),refreshOn:[`shown`],attention:{subscribe:HF,acknowledge:UF},onConnectionChange:JF},{view:`boards`,label:`Boards`,iconPath:He,isPhoneNavScreen:!0,isPhoneOnly:!0,panelClass:`boards-screen`,hasPanelChrome:!1,load:()=>N(()=>import(`./boards-view-BiwLooLF.js`).then(e=>e.view),__vite__mapDeps([36,3,4,12,13,14,30,21,15,19,23,37])),refreshOn:[`shown`,`connected`]},{view:`hooks`,label:`Hooks`,iconPath:Ge,panelClass:`hooks-view`,load:()=>N(()=>import(`./hooks-panel-CsEtzh3p.js`).then(e=>e.view),__vite__mapDeps([54,14,13,4,3,12,15,55])),refreshOn:[`shown`,`connected`,`hooks-updated`]},{view:`trace`,label:`Trace`,iconPath:je,panelClass:`trace-view`,gate:{subscribe:rb},load:()=>N(()=>import(`./trace-panel-B2myZkUL.js`).then(e=>e.view),__vite__mapDeps([56,3,4,13,12,14,5,6,7,57])),refreshOn:[`shown`],onAvailabilityChange:e=>xF(e?eC:null),onConnectionChange:aC},{view:`benchmarks`,label:`Arena`,iconPath:rt,panelClass:`bench-view`,load:()=>N(()=>import(`./arena-panel-DsZW87SB.js`).then(e=>e.view),__vite__mapDeps([58,13,4,3,14,19,28,15,27,59])),onConnectionChange:la},{view:`settings`,label:`Settings`,iconPath:de,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>N(()=>import(`./settings-panel-SaUZ37hZ.js`).then(e=>e.view),__vite__mapDeps([60,3,4,5,6,7,2,1,8,61,13,10,50,12,14,34,26,15,19,22,27,18,31,28,41,29,30,21,32,43,62]))}].map(t=>dL(t,Te(t.iconPath),e.setPhoneAttention));return T(document,`#header-tabs`,`div`).replaceChildren(...t.map(e=>e.tab)),t}function gL(e){return e===`remote`?`remote`:`local`}function _L(e,t){return gL(t)===`local`||e!==`shutdown`}var vL=!1,yL=new Set;function bL({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){let o=bC(),c=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;Xt({title:t,message:c,confirmLabel:n,danger:r||o>0,onConfirm:()=>s({type:e})})}function xL(){bL({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function SL(){bL({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})}function CL(e){vL=_L(`shutdown`,e);for(let e of yL)e.isConnected?e.hidden=!vL:yL.delete(e)}function wL(e){e.hidden=!vL,yL.add(e)}function TL(e){e&&RP(e),$O(`settings`)||q(`settings`,{section:e})}function EL(e){$O(e)||q(e)}function DL(){$O(`boards`)||(q(`focus`),GN())}function OL(){eF(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}var K=hL({onRestart:xL,openTerminal:e=>{QO(e)||(q(`focus`),QN(e))},openPlan:e=>{q(`focus`),$N(e)},openReviewFile:(e,t)=>{yC(e)&&(QO(e)||(q(`focus`),QN(e),ZN(t)))},openReviews:()=>ML(`prs`)?($O(`prs`)||q(`prs`),!0):!1,setPhoneAttention:qO});function kL(){return K.map(e=>e.view)}var AL=kL();function jL(e){return K.find(t=>t.view===e)}function ML(e){return K.some(t=>t.view===e&&!t.tab.hidden)}var NL=!0,PL=null;function FL(e){jL(e)?.attention?.acknowledge()}var IL=null;function LL(e){IL=s({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function RL(){IL&&LL(IL)}function zL(e){let t=jL(e);t&&(iL(t,e=>XI(t,e,`shown`)),LL(e))}function BL(e){ZI(K,{isPhoneShellActive:UO(),activeView:rr(),phoneScreen:M.snapshot().phoneScreen},e,aL)}function q(e,{section:t,setting:n,persist:r=!0}={}){let i=jL(e);if(!i||!ML(e))return;let a=rr();M.dispatch(`setActiveView`,e),NL=r,r&&(PL=null),document.body.dataset.activeView=e,r&&Mr(e);for(let t of K){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&&aL(a)?.deactivate?.(),iL(i,r=>{rr()===e&&(r.activate?.(),XI(i,r,`shown`),e===`settings`&&t&&RP(t,n??null))}),LL(e),a===`settings`&&e!==`settings`&&OL(),FL(e)}function VL(e,t){let{view:n}=e;e.tab.hidden=!t,KO(n,t),e.onAvailabilityChange?.(t),UO()||(!t&&rr()===n&&q(`focus`),t&&PL===n&&q(n))}function HL(e){for(let{view:t,isAvailable:n}of KI(K,e))VL(t,n)}var UL;function WL(e){UL=e;let t=qI(AL,e);K.every((e,n)=>e.view===t[n])||(K.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),T(document,`#header-tabs`,`div`).append(...K.map(e=>e.tab)),GO(t))}function GL(){return K.filter(e=>!e.tab.hidden)}function KL(e,t){let n=e[t];return q(n.view),n.tab}function qL(e,t){let n=GL(),r=n.findIndex(t=>t.view===e);return KL(n,Yi(r,t,n.length))}function JL(e){K.some(e=>e.tab===document.activeElement)&&e.focus()}var YL=null;function XL(e){let t=kL();WL(e),c(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&WL(t)}).catch(()=>WL(t))}function ZL(e){let t=YL;if(YL=null,!t||t===e)return;let n=kL();XL(JI(n,t,n.indexOf(e)))}function QL({view:e,tab:t}){t.addEventListener(`click`,()=>q(e)),t.addEventListener(`dragstart`,t=>{YL=e,t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),t.addEventListener(`dragover`,n=>{YL&&YL!==e&&(n.preventDefault(),t.dataset.dropTarget=`true`)}),t.addEventListener(`dragleave`,()=>delete t.dataset.dropTarget),t.addEventListener(`drop`,n=>{n.preventDefault(),delete t.dataset.dropTarget,ZL(e)}),t.addEventListener(`dragend`,()=>{YL=null}),t.addEventListener(`keydown`,e=>{if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=GL(),n=t.findIndex(e=>e.view===rr()),r=Xi(e.key,n,t.length,`horizontal`);r!==null&&(e.preventDefault(),KL(t,r).focus())})}var $L=`pack:`,eR=new Map;function tR(e){let t=pL(e);return K.push(t),AL.push(t.view),T(document,`#header-tabs`,`div`).append(t.tab),QL(t),t}function nR(e){let t=new Set(e.map(e=>e.viewId));for(let e of K)e.view.startsWith($L)&&!t.has(e.view)&&(UI(e.view),VL(e,!1));for(let t of e){let e=jL(t.viewId)??tR(t),n=eR.get(t.viewId);n&&(n.label!==t.label||n.iconUrl!==t.iconUrl)&&mL(e,t),eR.set(t.viewId,t),HI(t),VL(e,!0)}WL(UL)}function rR(){let e=fi(),t=eF(location.hash),n=wb(location.hash);if(t&&(RP(null,null,location.hash),q(`settings`,{persist:!1})),n&&q(`focus`,{persist:!1}),t||n)return;let r=ML(e);r||(PL=e),q(r?e:`focus`,{persist:r})}function iR(){let e=rr();q(ML(e)?e:`focus`,{persist:NL})}function aR(){IP(K),oL(K);for(let e of K)e.gate&&(VL(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>VL(e,t)));$S(()=>{ML(`trace`)&&($O(`trace`)||q(`trace`))});for(let e of K)QL(e);rR(),WI(nR)}function oR(e){return eF(e)?(RP(null,null,e),$O(`settings`)||q(`settings`,{persist:!1}),!0):!1}var sR=`No plan is stored for this session yet. It appears here once the agent writes one.`,cR=`Plan`;function lR(e){let t=wb(e);return t?!yC(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),UO()?(ZO(t)||sr({source:cR,sessionId:t,message:sR}),!0):(q(`focus`,{persist:!1}),$N(t)||sr({source:cR,sessionId:t,message:sR}),!0)):!1}function uR(e){return lR(e)?!0:oR(e)}function dR(e){e.newURL===location.href&&uR(location.hash)}function fR(){document.addEventListener(`click`,e=>{if(!UO()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&uR(t.hash)&&e.preventDefault()}),window.addEventListener(`hashchange`,dR)}var pR=null,mR=new Set;function hR(){pR?.setState(ri()?`idle`:`off`)}function gR(e){ci(e),hR();for(let t of mR)t(e)}function _R(e){mR.add(e)}function vR(e){pR=e,hR(),e.element.addEventListener(`click`,()=>gR(!ri()))}var yR=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,bR=[`title`,`label`],xR=new WeakMap,SR=new WeakMap,CR=null;function wR(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(yR)!==null}function TR(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function ER(e,t){if(t&&e===t.masked)return t;let n=sI(e);return n===e?null:{original:e,masked:n}}function DR(e){let t=TR(e)?null:ER(e.data,xR.get(e));t?(xR.set(e,t),e.data!==t.masked&&(e.data=t.masked)):xR.delete(e)}function OR(e,t){let n=e.getAttribute(t),r=SR.get(e),i=n===null?null:ER(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),SR.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function kR(e){for(let t of bR)OR(e,t)}function AR(e){return e instanceof Element&&e.matches(yR)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function jR(e){kR(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,AR);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&DR(e),e instanceof Element&&kR(e)}function MR(e){wR(e)||(e instanceof Text&&DR(e),e instanceof Element&&jR(e))}function NR(e){e instanceof Element&&!wR(e)&&kR(e)}function PR(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&&MR(e);for(let e of n)e.isConnected&&NR(e)}function FR(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);IR(e);for(let e=t.nextNode();e;e=t.nextNode())IR(e)}function IR(e){if(e instanceof Text){let t=xR.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=SR.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function LR(){if(CR)return;let e=new MutationObserver(t=>{PR(t),e.takeRecords()});jR(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:bR}),CR=e}function RR(){CR&&(CR.disconnect(),CR=null,FR(document.body),xR=new WeakMap,SR=new WeakMap)}function zR(e){e?LR():RR()}function BR(){zR(Zc()),$c(zR)}var VR=qe({label:`Play queued merge celebrations`,icon:Te(he,`1.6`),action:`play-celebrations`,states:[`idle`,`attention`]}),HR=w({variant:`primary`,label:`Session`,icon:Te(Ve),action:`add-session`,onClick:Hi});HR.id=`btn-add-session-header`;var UR=qe({label:`Keyboard shortcuts and version`,icon:Te(Ke,`1.6`),action:`open-shortcuts-help`,onClick:()=>TL(`browser-shortcuts`),states:[`idle`]}).element,WR=qe({label:`Mute alerts`,icon:Te(ht,`1.6`),action:`toggle-mute`,states:[`idle`,`off`]}),GR=WR.element,KR=w({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-header-status`});KR.id=`header-status-dismiss`;var qR=T(document,`#celebration-tray`,`div`);qR.prepend(VR.element),T(document,`.header-right`,`div`).append(HR,UR,GR),T(document,`#header-status`,`p`).append(KR);function JR(){vR(WR),BR(),Ht(document.querySelector(`.header`))}function YR(){em(qR,VR,T(document,`#celebration-tray-count`,`span`))}function XR(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 ZR(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 QR(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function $R(e,t){return t||QR(e)?!1:ZR(e)}var ez=w({variant:`primary`,size:`small`,label:`Restart`,action:`restart-to-update`,hidden:!0}),tz=w({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-update-command`}),nz=w({variant:`icon`,size:`small`,label:`Dismiss update notice`,icon:Te(st),action:`dismiss-update-banner`});T(document,`#update-banner-cmd`,`code`).before(ez),T(document,`#update-banner-copy-status`,`span`).before(tz),T(document,`#update-banner`,`div`).append(nz);var rz=w({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-leftovers-command`}),iz=w({variant:`icon`,size:`small`,label:`Dismiss old report notice`,icon:Te(st),action:`dismiss-leftovers-banner`});T(document,`#post-turn-leftovers-copy-status`,`span`).before(rz),T(document,`#post-turn-leftovers-banner`,`div`).append(iz);var az,oz=null;function sz(e,t,n){e.onclick=()=>{let e=Nt(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var cz=rF(xe,ve,`Update`).href;function lz(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function uz(e){let t=T(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=Pe(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=lz(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===oz||!a&&az!==void 0&&s===az||!a&&s&&Gr()===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=cz,l.hidden=n!==`link`,ez.hidden=n!==`restart`,ez.onclick=xL;let u=T(document,`#update-banner-cmd`,`code`);u.hidden=n!==`command`,tz.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,sz(tz,d,c),nz.onclick=()=>{t.hidden=!0,a?oz=i:(az=s,jr(s))}}var dz=!1;function fz({repositories:e,command:t}){let n=T(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(dz)return;let r=T(document,`#post-turn-leftovers-copy-status`,`span`);T(document,`#post-turn-leftovers-text`,`span`).textContent=XR(e.length),T(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,sz(rz,r,t),iz.onclick=()=>{dz=!0,n.hidden=!0}}var pz=T(document,`#telemetry-banner`,`div`),mz=w({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-telemetry-banner`});pz.append(mz);function hz(){ai(!0),pz.hidden=!0}function gz(e){pz.hidden=!$R(e,Cr())}function _z(){let e=T(document,`#telemetry-banner-settings`,`a`);e.href=rF(`privacy`,`telemetry-enabled`,`What's collected`).href,e.addEventListener(`click`,hz),mz.addEventListener(`click`,hz)}function vz(e){N(()=>import(`./feature-hint-Ckkpugl5.js`).then(t=>t.showFeatureHint(e,{isFeatureEnabled:e=>ML(Fe[e]),openView:EL,openSetting:(e,t)=>oR($P(e,t))}),e=>y(`feature-hint`,`hint card failed to load: ${l(e)}`)),__vite__mapDeps([63,13,4,3,61,5,6,7,8,14,64]))}function yz(){N(()=>import(`./feature-hint-Ckkpugl5.js`).then(e=>e.showStarHint(),e=>y(`star-hint`,`star card failed to load: ${l(e)}`)),__vite__mapDeps([63,13,4,3,61,5,6,7,8,14,64]))}var bz=2500;function xz({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}function Sz(e){Xa(e.isExperimentalBuild===!0&&Tr()),xC(e),GP(e),HL(e),gz(e),WL(e.viewTabOrder),Qc(e.streamerMode===!0)}var Cz=Object.freeze({top:[0,1],right:[-1,0],bottom:[0,-1],left:[1,0]}),wz=160,Tz=950,Ez=900,Dz=980,Oz=450,kz=720,Az=260,jz=`cubic-bezier(0.22, 1, 0.36, 1)`,Mz=`cubic-bezier(0.2, 0.8, 0.3, 1)`,Nz=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),Pz=e=>new Promise(t=>{setTimeout(t,e)});function Fz(e){return e!==void 0&&Object.hasOwn(Cz,e)}function Iz(e){return[...e.querySelectorAll(`[data-side]`)].flatMap(e=>{let t=e instanceof SVGElement?e.dataset.side:void 0;if(!(e instanceof SVGElement)||!Fz(t))return[];let[n,r]=Cz[t];return[{bracket:e,dx:n,dy:r}]})}function Lz(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:Ol}],{duration:wz,easing:`ease-out`})}}function Rz(e){e.animate([{transform:`rotate(0deg)`,easing:`cubic-bezier(0.5, 0, 0.15, 1)`},{transform:`rotate(360deg)`,offset:.86,easing:Mz},{transform:`rotate(354deg)`,offset:.93,easing:Mz},{transform:`rotate(360deg)`}],{duration:Tz})}function zz(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:Ez,easing:`cubic-bezier(0.2, 0.9, 0.3, 1)`})}}function Bz(e,t){e.animate([{transform:`scale(0)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:Dz,easing:jz,fill:`forwards`}),t.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`})}function Vz(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:kz,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:kz,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`})}function Hz({mark:e,dial:t,light:n,halo:r}){return Nz?.matches||document.hidden?Promise.resolve():(Rz(t),zz(Iz(e)),n.animate([{transform:`scale(1)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:Dz,easing:jz}),r.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`}),Pz(Dz))}async function Uz(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(Nz?.matches||document.hidden||!(t instanceof SVGElement)||!n||!r||!i)return;let a=Iz(t);Lz(a),e.dataset.unlock=`spin`,await Pz(wz),Rz(n),zz(a),Bz(r,i),await Pz(Dz),e.dataset.unlock=`lit`,await Pz(Oz),e.dataset.unlock=`burst`,Vz(a,r,i),await Pz(Az)}var Wz=T(document,`#connection-status`,`span`),Gz=T(Wz,`.connection-label`,`span`),Kz=T(document,`#loading-screen`,`div`),qz=T(document,`#loading-status`,`div`),Jz=T(document,`#loading-detail`,`div`),Yz=T(document,`#shutdown-screen`,`div`),Xz=T(document,`#shutdown-status`,`div`),Zz=!1,Qz=null,$z=!1;function eB(){Zz||Qz===null||xz({hasSnapshot:$z,connectingTerminalCount:Xl(),msSinceConnected:performance.now()-Qz})===`reveal`&&nB()}function tB(){$z=!0,eB()}function nB(){Zz||(Zz=!0,sL(K),$f(),xk(),Uz(Kz).then(rB,rB))}function rB(){Kz.classList.add(`fade-out`);let e=()=>Kz.remove();Kz.addEventListener(`transitionend`,t=>{t.target===Kz&&e()}),setTimeout(e,1e3)}function iB(e,t){Wz.dataset.state=`shutdown`,Gz.textContent=e,Xz.textContent=t,Yz.classList.add(`active`)}var aB=new Set([`disconnected`,`connecting`]);function oB(e,t,n){Wz.dataset.state=e,Wz.toggleAttribute(`data-reconnected`,n),Gz.textContent=t}function sB(e,t){oB(e,t,e===`connected`&&aB.has(Wz.dataset.state??``))}function cB(e,t){Wz.dataset.state!==`shutdown`&&oB(e===`verified`?`connected`:e,t,!1)}var lB=1e4,uB=`Server`,dB=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,fB=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,pB=null,mB=!1;function hB(){qz.textContent=`Reconnecting to server...`,Jz.textContent=fB,Jz.hidden=!mB}function gB(){pB=null,mB=!0,Zz?sr({source:uB,message:dB,hidesInStreamerMode:!1}):hB()}function _B(){pB!==null||mB||(pB=window.setTimeout(gB,lB))}function vB(){pB!==null&&window.clearTimeout(pB),pB=null,mB=!1,Jz.hidden=!0,or(uB)}function yB(){vB(),uL(import.meta.url,()=>window.sessionStorage),RL(),Yz.classList.contains(`active`)?location.reload():(bk(),document.body.classList.add(`app-ready`),!Zz&&Qz===null&&(Qz=performance.now(),qz.textContent=`Connecting to sessions...`,setTimeout(nB,bz)),eB(),BL(`connected`),c(`get-settings`,{}).then(e=>{e.settings&&(Sz(e.settings),rr()===`settings`&&oR(location.hash))}).catch(()=>{}))}function bB(e,t){if(e===`connecting`||e===`verified`)cB(e,t);else{sB(e,t),Rx(e===`connected`);for(let t of K)t.onConnectionChange?.(e===`connected`);e===`connected`?yB():e===`disconnected`&&Yz.classList.contains(`active`)?Xz.textContent=`Waiting for server...`:(_B(),Zz||hB())}}function xB(){Yl(eB),h(bB)}var SB=14,CB=Object.freeze({idle:kl,failed:`#ef4444`,waiting:`#f59e0b`});function wB({waitingCount:e,failedCount:t}){return e>0?`waiting`:t>0?`failed`:`idle`}function TB(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)">${Al({frame:Ol,light:CB[e],strokeWidth:SB})}</g></svg>`}function EB(){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 DB=EB(),OB=`idle`;function kB(e){let t=wB(e);t!==OB&&(OB=t,DB.href=`data:image/svg+xml,${encodeURIComponent(TB(t))}`)}function AB(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 jB(e){return{skipPerms:e.skipPerms??e.dangerouslySkipPermissions??!1,saneYolo:e.saneYolo===!0,isQuestionManagerOn:e.isQuestionManagerOn??null,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 MB(){Pp(),fh(),JO()}function NB(){G(),MB()}function PB(){Ti(e=>{G(e),MB()})}var FB=null;function IB(e){let t=AB(FB,e);FB=t.knownBuild,t.reload&&location.reload()}function LB(e){cr(e),IC(e),Sa(e),Ky(e),E_(e),vn(e),qs(e)}function RB(e){for(let t of Js(e))LB(t)}function zB(e,t){let n=new Set(e.map(e=>e.id));for(let e of[...k.keys()])Gs(e)===t&&(n.has(e)||LB(e))}function BB(e,t=null){if(t)for(let n of e)Ks(n.id,t);zB(e,t),t||JP(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)yC(t.id)&&HB(t),yC(t.id)||TC(t.id,t.name,t.state,jB(t)),xa(t.id,t.coherenceHooks),T_(t.id,t.linkedPrs),Pn(t.id,t.failureReason),vC(t.id,t.taskTitle,t.taskTitleIsCustom),DC(t.id,t.agent),PC(t.id,t.mergeStatus,t.mergeReason),EC(t.id,t.effectiveBase),kC(t.id,t.activeAgents,t.awaitingBackgroundTasks),AC(t.id,t.pendingPromptKind),jC(t.id,t.unseenOutcome),bn(t.id,t.auditLog,t.managerSeenSeq),Nx(t.id,t.hasPlan);wC(),kB(j.counts),G(),iP(),MB(),WB(),lR(location.hash),ek(),tB()}function VB(e,t){let n=e.dataset.skipPerms!==void 0;return(e.dataset.path??``)!==t.path||n!==t.dangerouslySkipPermissions}function HB(e){let t=k.get(e.id)?.card;t&&VB(t,e)?UB(e.id,e.name,e.state,e,e.linkedPrs):(BC(e.id,e.state,e.stateSince),wn(e.id,!!e.saneYolo),un(e.id,e.isQuestionManagerOn),t&&t.dataset.session!==e.name&&FC(e.id,e.name),OC(e.id,e.isWorktree))}function UB(e,t,n,r,i){let a=k.get(e),o=Li()===e;xa(e,null),IC(e),Ky(e),vn(e),T_(e,i),TC(e,t,n,jB(r)),o&&Oi(e),GB(e,a)}function WB(){tC([...k].map(([e,t])=>({id:e,name:Kn(t)||e})))}function GB(e,t){Nx(e,t?.hasPlan===!0),jC(e,t?.unseenOutcome)}var KB=new Set([E.DONE,E.FAILED]);function qB(e,t){return e!==void 0&&KB.has(e)&&!KB.has(t)&&t!==E.DORMANT}function JB(e){let t=k.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;IC(e.id),TC(e.id,e.session,E.DORMANT,jB({skipPerms:i,saneYolo:a,isQuestionManagerOn:e.isQuestionManagerOn??nn(r),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})),DC(e.id,t?.agent),GB(e.id,t)}function YB(e,t){let n=k.get(String(e.id))?.currentState;t.to===E.DORMANT&&n!==E.DORMANT?(JB(e),Wy(e.id)):(BC(e.id,t.to,e.timestamp),Pn(e.id,e.failureReason),e.saneYolo!==void 0&&wn(e.id,e.saneYolo),Wy(e.id),qB(n,t.to)&&fu(e.id))}function XB(e){if(yC(e.id))e.transition&&YB(e,e.transition),e.activeAgents!==void 0&&kC(e.id,e.activeAgents,e.awaitingBackgroundTasks),e.unseenOutcome!==void 0&&jC(e.id,e.unseenOutcome),e.pendingPromptKind!==void 0&&AC(e.id,e.pendingPromptKind),e.managerSeenSeq!==void 0&&mn(e.id,e.managerSeenSeq),e.isQuestionManagerOn!==void 0&&un(e.id,e.isQuestionManagerOn),e.unseenOutcome!==void 0&&wC(),kB(j.counts),Wi(e.id),hb(e.id);else{if(!e.transition)return;TC(e.id,e.session,e.transition.to,jB({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),kB(j.counts),Pp()}}function ZB(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 QB=`Secrets agents may read from your vault, per project. Revoking one makes the next request ask again.`,$B=null,eV=null;function tV(e,t){let n=D(`article`,`settings-view-setting`),r=D(`div`,`settings-view-setting-text`),i=D(`div`,`settings-view-setting-heading`);i.append(D(`h2`,`settings-view-setting-title`,t.name)),r.append(i,D(`p`,`settings-view-setting-description`,t.isAllowed?`Reads ${t.reference??`no reference yet`}`:`Denied`));let a=D(`div`,`settings-view-setting-control`);return a.append(w({variant:`secondary`,label:`Revoke`,action:`secret-revoke`,onClick:()=>{s({type:`secret-revoke`,project:e,name:t.name})}})),n.append(r,a),n}function nV(e){return[D(`h2`,`settings-view-subsection-title`,e.project),...e.approvals.map(t=>tV(e.project,t))]}function rV(){let e=D(`p`,`settings-view-section-description`,QB);return $B?$B.length===0?[e,D(`p`,`settings-view-setting-description`,`No approvals yet. An agent that runs glimmervoid need asks on its session card first.`)]:[e,...$B.flatMap(nV)]:[e,D(`p`,`settings-view-setting-description`,`Waiting for the server to list approvals.`)]}function iV(){eV?.isConnected&&eV.replaceChildren(...rV())}function aV(e){$B=e.projects,iV()}function oV(e){eV=D(`div`,`settings-view-stack`),e.appendChild(eV),iV()}var sV={"session-trace-response":e=>nC(e),"session-trace-changed":e=>rC(e),"session-plan-changed":e=>{Px(e),MB()},"session-plan-draft":e=>{Fx(e)},"session-plan-response":e=>{Ix(e)},"session-docs-changed":e=>Nv(e),"session-docs-snapshot":e=>Pv(e),"session-secret-request":e=>xv(e),"secret-requests-snapshot":e=>Sv(e),"secret-approvals":e=>aV(e),"session-manager-decision":e=>{Nn(e.id,e.decision),NB()},"session-coherence-hooks":e=>{xa(e.id,e.coherenceHooks),NB()},"session-coherence":e=>{Ca(e),NB()},"session-coherence-snapshot":e=>{wa(e),NB()},"session-coherence-journal-response":e=>ka(e)},cV={"team-review-status":e=>kg(e),"github-prs":e=>Vp(e),"my-prs-status":ph,"pr-flows-status":mh,"packs-status":NI,"my-pr-merge-result":e=>hh(e),"team-review-action-result":e=>Ag(e),"open-team-review-session-result":e=>jg(e),"issues-status":e=>Ip(e),"issue-detail-result":e=>Lp(e),"open-issue-session-result":e=>Rp(e),"set-issue-state-result":e=>Ep(e)},lV={"radar-status":e=>SF(e),"radar-investigation-activity":e=>CF(e),"radar-investigation-finished":e=>wF(e),"community-status":e=>qF(e),"benchmark-status":e=>ua(e),"benchmark-action-result":e=>da(e),"race-status":e=>Pk(e),"race-history":e=>Ik(e),"usage-sessions":e=>BD(e),"usage-report":e=>{HD(e),qP()},"plan-limits":e=>VD(e),"usage-budget-alert":e=>ex({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0})},uV=3e3,dV=null,fV=null,pV=ar(`settings-hosts-status`);function mV(e){let t=e.hostVersion?`, build ${e.hostVersion}`:``;return`${e.sshTarget} port ${e.dashboardPort}: ${Us(e)}${t}`}async function hV(e){let t=await ir(`remove-host`,{id:e.id},pV,{busyText:`Removing ${e.name}.`});t?.type===`host-change-result`&&(t.ok?pV.show(`ok`,`Removed ${e.name}. Its sessions keep running there.`):pV.show(`error`,`Not removed: ${t.error??`the server refused the change.`}`))}function gV(e){Xt({title:`Remove ${e.name}?`,message:`This dashboard stops linking the host and its sessions leave the sidebar. They keep running on the host.`,confirmLabel:`Remove`,danger:!0,onConfirm:()=>{hV(e)}})}function _V(e){let t=D(`div`,`settings-host-row`);t.dataset.state=e.state;let n=D(`div`,`settings-readonly`);return n.append(D(`span`,`settings-host-name`,`${e.name} (${e.id})`),D(`span`,null,mV(e))),t.append(n,w({variant:`secondary`,label:`Remove`,action:`remove-host`,onClick:()=>gV(e)})),t}function vV(){if(!dV)return;let e=Hs();e.length===0?dV.replaceChildren(D(`div`,`settings-readonly`,`No hosts linked yet. Add one below.`)):dV.replaceChildren(...e.map(_V))}function yV(e,t,n){let r=D(`label`,`settings-host-field`),i=D(`input`,`settings-view-input`);return i.type=t===`dashboardPort`?`number`:`text`,i.name=t,i.placeholder=n,i.autocomplete=`off`,i.spellcheck=!1,r.append(D(`span`,null,e),i),{field:r,input:i}}async function bV(e,t,n){let r=e.id.value.trim(),i={id:r,name:e.name.value.trim()||r,sshTarget:e.sshTarget.value.trim(),dashboardPort:e.dashboardPort.value.trim()?Number(e.dashboardPort.value):uV};t.disabled=!0;let a=await ir(`add-host`,{host:i},n,{busyText:`Adding ${i.name}.`});if(t.disabled=!1,a?.type===`host-change-result`){if(!a.ok)n.show(`error`,`Not added: ${a.error??`the server refused the change.`}`);else{for(let t of Object.values(e))t.value=``;n.show(`ok`,`Added ${i.name}. Linking now; its state shows above.`)}}}function xV(){let e=D(`form`,`settings-host-form`),t=yV(`Id`,`id`,`devbox`),n=yV(`Name`,`name`,`Same as the id`),r=yV(`Ssh target`,`sshTarget`,`me@devbox or a ~/.ssh/config alias`),i=yV(`Dashboard port`,`dashboardPort`,String(uV)),a=ar(`settings-hosts-status`),o=w({variant:`secondary`,label:`Add host`,action:`add-host`});o.type=`submit`,e.addEventListener(`submit`,e=>{e.preventDefault(),bV({id:t.input,name:n.input,sshTarget:r.input,dashboardPort:i.input},o,a)});let s=D(`div`,`settings-telegram-test`);s.append(o,a.element);let c=D(`div`,`settings-host-fields`);return c.append(t.field,n.field,r.field,i.field),e.append(c,s),e}function SV(){let e=D(`div`,`settings-view-status-block settings-hosts`);return dV=D(`div`,`settings-host-list`),vV(),fV??=xV(),e.append(dV,pV.element,fV),e}function CV(){dV?.isConnected&&vV()}var wV=new Map,TV=()=>{},EV={connect:()=>{},abandon:()=>{},reconnectNow:()=>{},send:()=>!1,request:()=>Promise.reject(Error(S))};function DV(e){return typeof e.id==`string`?e.id:typeof e.sessionId==`string`?e.sessionId:null}f(e=>{let t=DV(e),n=t?Gs(t):null;return n?wV.get(n)??EV:null},()=>[...wV.values()]);function OV(e,t,n,r){return(wV.get(e)??EV).request(t,n,r)}function kV(e){TV=e}function AV(e){let t=g({pathPrefix:`/hosts/${encodeURIComponent(e)}`,isLocal:!1,onMessage:t=>{t.type===`session-added`&&Ks(t.id,e),TV(e,t)}});return t.connect(),t}function jV(e){let t=new Set(e.filter(e=>e.state===`connected`).map(e=>e.id)),n=[];for(let[e,r]of[...wV])t.has(e)||(r.abandon(),wV.delete(e),n.push(e));for(let e of t)wV.has(e)||wV.set(e,AV(e));return n}var MV={snapshot:e=>{IB(e.serverBuild),BB(e.sessions)},"hooks-report":e=>iv(e),"save-hook-result":()=>av(),"delete-hook-result":()=>av(),"update-status":e=>{uz(e),YP(e)},"update-progress":e=>XP(e.journal),"post-turn-leftovers":e=>fz(e),"feature-hint":e=>vz(e.hint),"star-hint":()=>yz(),error:e=>{let t=ZP(e),n=iC(e),r=Lx(e);t||n||r||(e.id?xn(e.id,e.message):sr({source:uB,message:e.message}))},"settings-updated":e=>{e.settings&&Sz(e.settings),bk()},"agent-logins":e=>cP(e.logins),"health-snapshot":e=>{e.stats&&K_(e.stats)},"client-trust":e=>CL(e.trust),"shutting-down":()=>iB(`Shutting down...`,`Shutting down sessions...`),restarting:()=>iB(`Restarting...`,`Restarting server...`),"hosts-status":e=>{Vs(e.hosts),CV();for(let t of jV(e.hosts))RB(t);NB()}},NV={"session-status":e=>XB(e),"session-added":e=>{T_(e.id,e.linkedPrs),yC(e.id)||(TC(e.id,e.session,e.state,jB(e)),DC(e.id,e.agent)),kB(j.counts),NB(),WB()},"session-close-confirm":e=>{Fi(e.id)},"session-removed":e=>{LB(e.id),kB(j.counts),NB(),WB()},"session-title":e=>{vC(e.id,e.taskTitle,e.isCustom),NB()},"session-prs":e=>T_(e.id,e.linkedPrs),"session-renamed":e=>{FC(e.id,e.newName),NB(),WB()},"session-modified":e=>{UB(e.id,e.session,e.state,e,e.linkedPrs),DC(e.id,e.agent),kB(j.counts),NB(),WB()},"session-git":e=>OC(e.id,!!e.worktree),"session-merge-status":e=>{NC(e.id,e.mergeStatus,e.reason),YN(e.id,e.mergeStatus),MB()},"debug-state-response":e=>mb(e),"session-setup-response":e=>GC(e),notify:e=>{$b(e),hb(e.session)},"session-error":e=>{Gy(e.id),Lx(e)||xn(e.id,e.message)}},PV=16,FV=new WeakMap;function IV(e){return e?.kind===`box`?Ct(e)?.asset??null:null}function LV(e,t,n){if(t===null)return;let r=(e.assetRefCount.get(t)??0)+n;r>0?e.assetRefCount.set(t,r):e.assetRefCount.delete(t)}function RV(e){return e.kind===`box`?e.near?[e.near.of]:[]:e.kind===`wire`?[e.from,e.to]:e.kind===`note`?[e.on]:e.kind===`frame`?e.contains:[]}function zV(e,t,n){t.kind===`box`&&t.step!==null&&(n?e.stepBoxIds.add(t.id):e.stepBoxIds.delete(t.id))}function BV(e){return e.kind===`note`?e.ref!==null:e.kind===`box`&&(e.refs.length>0||St(e).some(e=>e.ref!==null))}function VV(e,t){BV(t)?e.anchoredIds.add(t.id):e.anchoredIds.delete(t.id)}function HV(e,t,n){for(let r of new Set(RV(t))){let i=e.dependentIdsByBoxId.get(r);i?i instanceof Set?i.add(t.id):i.length<PV?e.dependentIdsByBoxId.set(r,i.concat(t.id)):e.dependentIdsByBoxId.set(r,new Set([...i,t.id])):e.dependentIdsByBoxId.set(n.storedIdOf(r)??r,[t.id])}}function UV(e,t){for(let n of new Set(RV(t))){let r=e.dependentIdsByBoxId.get(n);r instanceof Set?(r.delete(t.id),r.size===0&&e.dependentIdsByBoxId.delete(n)):r?.includes(t.id)&&(r.length===1?e.dependentIdsByBoxId.delete(n):e.dependentIdsByBoxId.set(n,r.filter(e=>e!==t.id)))}}function WV(e,t){return{...t,id:e.storedIdOf(t.id)??t.id}}function GV(e,t,n){e.elementCount+=1,LV(e,IV(t),1),HV(e,t,n),zV(e,t,!0),VV(e,t)}function KV(e,t){--e.elementCount,LV(e,IV(t),-1),UV(e,t),zV(e,t,!1),e.anchoredIds.delete(t.id)}function qV(e){let t=FV.get(e);if(t)return t;let n={elementCount:0,assetRefCount:new Map,dependentIdsByBoxId:new Map,stepBoxIds:new Set,anchoredIds:new Set};for(let t of e.values())GV(n,t,e);return FV.set(e,n),n}function JV(e){return{elementCount:e.elementCount,assetRefCount:new Map(e.assetRefCount),dependentIdsByBoxId:new Map([...e.dependentIdsByBoxId].map(([e,t])=>[e,t instanceof Set?new Set(t):t])),stepBoxIds:new Set(e.stepBoxIds),anchoredIds:new Set(e.anchoredIds)}}function YV(e){let t=e.copy(),n=FV.get(e);return n&&FV.set(t,JV(n)),t}function XV(e,t){let n=FV.get(e),r=e.get(t.id);if(e.put(t),!n)return;let i=WV(e,t);r?(LV(n,IV(r),-1),LV(n,IV(t),1),UV(n,r),HV(n,i,e),zV(n,r,!1),zV(n,i,!0),VV(n,i)):GV(n,i,e)}function ZV(e,t){QV(e,t.id),XV(e,t)}function QV(e,t){let n=e.get(t);if(!n)return;e.remove(t);let r=FV.get(e);r&&KV(r,n)}var $V=26,eH=97;function tH(e){return e.step!==null}function nH(e){return[...qV(e.elements).stepBoxIds].flatMap(t=>{let n=e.elements.get(t);return n?.kind===`box`&&tH(n)?[n]:[]})}function rH(e,t,n){return[...qV(e.elements).dependentIdsByBoxId.get(t)??[]].flatMap(r=>{let i=e.elements.get(r);return i?.kind===`wire`&&i.to===t&&i.from!==t&&n.has(i.from)?[i]:[]})}function iH(e,t){let n=new Map;for(let r of t){let i=rH(e,r,t).map(e=>e.from);i.length>0&&n.set(r,i)}return n}function aH(e){let t=String.fromCharCode(eH+e%$V),n=Math.floor(e/$V);return n===0?t:`${t}${n+1}`}function oH(e,t){let n=new Map,r=new Set;function i(e){let a=n.get(e);if(a!==void 0)return a;if(r.has(e))return 0;r.add(e);let o=1+Math.max(0,...(t.get(e)??[]).map(i));return r.delete(e),n.set(e,o),o}for(let t of e)i(t);return n}function sH(e){let t=nH(e),n=iH(e,new Set(t.map(e=>e.id))),r=oH(t.map(e=>e.id),n),i=new Map;for(let e of t){let t=r.get(e.id)??1;i.set(t,[...i.get(t)??[],e])}let a=new Map,o=[];for(let e of[...i.keys()].sort((e,t)=>e-t)){let t=(i.get(e)??[]).sort((e,t)=>e.title.localeCompare(t.title)||e.id.localeCompare(t.id));for(let[n,r]of t.entries())a.set(r.id,t.length===1?String(e):`${e}${aH(n)}`),o.push(r)}return o.map(e=>({boxId:e.id,title:e.title,status:e.step.status,level:r.get(e.id)??1,label:a.get(e.id)??``,afterLabels:(n.get(e.id)??[]).flatMap(e=>a.get(e)??[]),linkedBoardId:e.step.linkedBoardId}))}function cH(e){let t=lH(e.length);return e.forEach((e,n)=>{uH(t,n,e.x,e.y,e.x+e.width,e.y+e.height)}),t}function lH(e){return{count:e,lefts:new Float64Array(e),tops:new Float64Array(e),rights:new Float64Array(e),bottoms:new Float64Array(e)}}function uH(e,t,n,r,i,a){e.lefts[t]=Math.min(n,i),e.rights[t]=Math.max(n,i),e.tops[t]=Math.min(r,a),e.bottoms[t]=Math.max(r,a)}function dH(e){e.sort();let t=0;for(let n=0;n<e.length;n+=1){let r=e[n]??0;t>0&&e[t-1]===r||(e[t]=r,t+=1)}return e.subarray(0,t)}function fH(e){let t=e.reduce((e,t)=>e+t.count*2,0),n=new Float64Array(t),r=0;for(let t of e)n.set(t.tops,r),n.set(t.bottoms,r+t.count),r+=t.count*2;return dH(n)}function pH(e,t){let n=0,r=e.length-1;for(;n<r;){let i=n+r>>1;(e[i]??0)<t?n=i+1:r=i}return n}function mH(e){let t=1;for(;t<e;)t*=2;return t}function hH(e,t,n){let r=0;for(let i of e)t[i]===1&&(e[r]=i,r+=1,n&&n(i));e.length=r}function gH(e,t){let n=mH(t.length),r=new Int32Array(e.count),i=new Int32Array(e.count);for(let n=0;n<e.count;n+=1)r[n]=pH(t,e.tops[n]??0),i[n]=pH(t,e.bottoms[n]??0);let a=new Uint8Array(e.count),o=Array.from({length:n*2},()=>[]),s=Array.from({length:n},()=>[]),c=new Int32Array(n*2),l=(e,t)=>{for(let r=e+n;r>=1;r>>=1)c[r]=(c[r]??0)+t},u=e=>{a[e]=1;let t=r[e]??0,c=t+n,u=(i[e]??0)+n+1;for(;c<u;)c&1&&(o[c]?.push(e),c+=1),u&1&&(--u,o[u]?.push(e)),c>>=1,u>>=1;s[t]?.push(e),l(t,1)},d=e=>{a[e]===1&&(a[e]=0,l(r[e]??0,-1))},f=(e,t,r,i,o,l)=>{if((c[e]??0)===0||r<i||t>o)return;if(e>=n){hH(s[e-n]??[],a,l);return}let u=t+r>>1;f(e*2,t,u,i,o,l),f(e*2+1,u+1,r,i,o,l)};return{insert:u,remove:d,forEachMeeting:(e,r,i)=>{let s=pH(t,e);for(let e=s+n;e>=1;e>>=1)hH(o[e]??[],a,i);let c=pH(t,r);c>s&&f(1,0,n-1,s+1,c,i)}}}function _H(e){let t=new Int32Array(e.length);for(let e=0;e<t.length;e+=1)t[e]=e;return t.sort((t,n)=>(e[t]??0)-(e[n]??0))}function vH(e){let t=fH(e);return e.map(e=>({rects:e,index:gH(e,t),closingOrder:_H(e.rights),nextClosing:0}))}function yH(e,t){for(;e.nextClosing<e.closingOrder.length;){let n=e.closingOrder[e.nextClosing]??0;if((e.rects.rights[n]??0)>=t)return;e.index.remove(n),e.nextClosing+=1}}function bH(e,t){let[n]=vH([e]);if(n)for(let r of _H(e.lefts))yH(n,e.lefts[r]??0),n.index.forEachMeeting(e.tops[r]??0,e.bottoms[r]??0,e=>t(e,r)),n.index.insert(r)}function xH(e,t,n){let[r,i]=vH([e,t]);if(!r||!i)return;let a=_H(e.lefts),o=_H(t.lefts),s=0,c=0;for(;s<a.length||c<o.length;){let l=a[s]??-1,u=o[c]??-1,d=u<0||l>=0&&(e.lefts[l]??0)<=(t.lefts[u]??0),f=d?e.lefts[l]??0:t.lefts[u]??0;yH(r,f),yH(i,f),d?(i.index.forEachMeeting(e.tops[l]??0,e.bottoms[l]??0,e=>n(l,e)),r.index.insert(l),s+=1):(r.index.forEachMeeting(t.tops[u]??0,t.bottoms[u]??0,e=>n(e,u)),i.index.insert(u),c+=1)}}function SH(e,t,n){let r=new Int32Array(t+1);for(let t of n)r[(e[t]??0)+1]=(r[(e[t]??0)+1]??0)+1;for(let e=0;e<t;e+=1)r[e+1]=(r[e+1]??0)+(r[e]??0);let i=new Int32Array(n.length);for(let t of n){let n=e[t]??0;i[r[n]??0]=t,r[n]=(r[n]??0)+1}return i}function CH(e,t,n,r){let i=new Int32Array(e.length);for(let e=0;e<i.length;e+=1)i[e]=e;return SH(Int32Array.from(e),n,SH(Int32Array.from(t),r,i))}function wH(e,t,n,r){return Array.from(CH(e,t,n,r),n=>[e[n]??0,t[n]??0])}function TH(e){let t=[],n=[];return bH(cH(e),(e,r)=>{t.push(Math.min(e,r)),n.push(Math.max(e,r))}),wH(t,n,e.length,e.length)}var EH=10,DH=4,OH=14,kH=2,AH=160;function jH(e,t){return t?e.y:e.x}function MH(e,t){return t?e.x:e.y}function NH(e,t){let n=[];return e.forEach((e,r)=>{for(let i=0;i+1<e.length;i+=1){let a=e[i],o=e[i+1];if(!a||!o||jH(a,t)!==jH(o,t)||MH(a,t)===MH(o,t))continue;let s=i===0||i+2===e.length;n.push({wire:r,index:i,line:jH(a,t),low:Math.min(MH(a,t),MH(o,t)),high:Math.max(MH(a,t),MH(o,t)),isFixed:s})}}),n.sort((e,t)=>e.line-t.line||e.low-t.low)}function PH(e,t){let n=[],r=new Map,i=new Map,a=new Map;for(let o of e){let e=t[o.wire];if(!e)continue;let s=r.get(o.wire)??i.get(e.exitKey)??(e.busKey===null?void 0:a.get(e.busKey)),c=s??{members:[],low:o.low,high:o.high,isPinned:!1,offset:0};s||n.push(c),c.members.push(o),c.low=Math.min(c.low,o.low),c.high=Math.max(c.high,o.high),c.isPinned||=o.isFixed,r.set(o.wire,c),i.has(e.exitKey)||i.set(e.exitKey,c),e.busKey!==null&&!a.has(e.busKey)&&a.set(e.busKey,c)}return n}function FH(e,t){let n=[],r=0;for(;r<e.length;){let i=e[r];if(!i)break;let a=r+1,o=i.high;for(;a<e.length;a+=1){let t=e[a];if(!t||t.line!==i.line||t.low>o)break;o=Math.max(o,t.high)}let s=e.slice(r,a);if(r=a,s.length<2)continue;let c=PH(s,t);c.length>1&&n.push({line:i.line,low:i.low,high:o,bundles:c})}return n}function IH(e,t,n,r){let i=e[t.index],a=e[t.index+1];if(!i||!a)return 0;let o=MH(i,r)<MH(a,r)===n?e[t.index-1]:e[t.index+2];return o?Math.sign(jH(o,r)-t.line):0}function LH(e,t,n,r){let i=n[e.wire]??[],a=n[t.wire]??[],o=IH(i,e,!0,r),s=IH(a,t,!0,r);if(o!==0&&s!==0&&o!==s)return o;if(o!==0&&o===s&&e.low!==t.low)return o<0?t.low-e.low:e.low-t.low;let c=IH(i,e,!1,r),l=IH(a,t,!1,r);return c!==0&&l!==0&&c!==l?c:c!==0&&c===l&&e.high!==t.high?c<0?e.high-t.high:t.high-e.high:e.wire-t.wire}function RH(e,t){let n=e.pending[t]??-1;if(!(n<0)){for(let r of[t*2,t*2+1])e.maxima[r]=n,e.pending[r]=n;e.pending[t]=-1}}function zH(e,t,n,r,i,a){if(a<n||r<i)return-1;if(i<=n&&r<=a)return e.maxima[t]??-1;RH(e,t);let o=n+r>>1;return Math.max(zH(e,t*2,n,o,i,a),zH(e,t*2+1,o+1,r,i,a))}function BH(e,t,n,r,i,a,o){if(a<n||r<i)return;if(i<=n&&r<=a){e.maxima[t]=o,e.pending[t]=o;return}RH(e,t);let s=n+r>>1;BH(e,t*2,n,s,i,a,o),BH(e,t*2+1,s+1,r,i,a,o),e.maxima[t]=Math.max(e.maxima[t*2]??-1,e.maxima[t*2+1]??-1)}function VH(e,t){let n=0,r=e.length-1;for(;n<r;){let i=n+r>>1;(e[i]??0)<t&&(n=i+1),(e[i]??0)>=t&&(r=i)}return n}function HH(e){let t=dH(Float64Array.from(e.flatMap(e=>[e.low,e.high]))),n=t.length,r={maxima:new Int32Array(n*4).fill(-1),pending:new Int32Array(n*4).fill(-1)},i=0;for(let a of e){let e=VH(t,a.low),o=VH(t,a.high);a.offset=zH(r,1,0,n-1,e,o)+1,BH(r,1,0,n-1,e,o,a.offset),i=Math.max(i,a.offset+1)}return i}function UH(e){let t=new Set(e.flatMap(e=>e.isPinned?[e.offset]:[]));if(t.size>1)return;let[n]=t;return n??null}function WH(e,t,n,r){let i=t*EH+DH+OH,a=r?{x:e.low,y:e.line-AH,width:e.high-e.low,height:320}:{x:e.line-AH,y:e.low,width:320,height:e.high-e.low},o=e.line-AH,s=e.line+AH,c=!1,l=!1;for(let t of n(a)){let n=r?t.x:t.y,i=n+(r?t.width:t.height);if(n>=e.high||i<=e.low)continue;let a=r?t.y:t.x,u=a+(r?t.height:t.width);u<=e.line&&u+DH>o&&(o=u+DH,c=!0),a>=e.line&&a-DH<s&&(s=a-DH,l=!0)}let u=c&&l;return u?{low:o,high:s,isBetweenObstacles:u}:{low:Math.max(o,e.line-i),high:Math.min(s,e.line+i),isBetweenObstacles:u}}function GH(e,t,n,r){if(n!==null){let i=n>0?(e-r.low)/n:1/0,a=t-1-n>0?(r.high-e)/(t-1-n):1/0,o=Math.min(EH,i,a);return o<kH?null:{firstTrack:e-n*o,spacing:o}}let i=Math.min(EH,(r.high-r.low)/(t-1));if(i<kH)return null;let a=(t-1)*i,o=r.isBetweenObstacles?(r.low+r.high)/2:e;return{firstTrack:Math.max(r.low,Math.min(o-a/2,r.high-a)),spacing:i}}function KH(e,t,n,r){for(let i of e.members){let e=n[i.wire]??[];for(let n of[i.index,i.index+1]){let i=e[n];i&&(e[n]=r?{x:i.x,y:t}:{x:t,y:i.y})}}}function qH(e,t,n,r){return e.members.every(e=>{let i=n[e.wire];if(!i||!e.isFixed)return!0;let a=e.index===0,o=e.index+2===(r[e.wire]?.length??0),s=!a||t>=i.startSlack.low&&t<=i.startSlack.high,c=!o||t>=i.endSlack.low&&t<=i.endSlack.high;return s&&c})}function JH(e,t,n,r){let i=FH(NH(t,r),e),a=i.map(e=>(e.bundles.sort((e,n)=>{let[i]=e.members,[a]=n.members;return i&&a?LH(i,a,t,r):0}),HH(e.bundles)));i.forEach((i,o)=>{let s=a[o]??1;if(s<2)return;let c=UH(i.bundles),l=WH(i,s,n,r),u=GH(i.line,s,c??null,l);if(!u)return;let d=e=>Math.round(u.firstTrack+e.offset*u.spacing);if(c!==void 0||i.bundles.every(n=>qH(n,d(n),e,t)))for(let e of i.bundles)KH(e,d(e),t,r)})}function YH(e,t){let n=e.map(e=>e.points.map(e=>({x:e.x,y:e.y})));return JH(e,n,t,!0),JH(e,n,t,!1),n}var XH=1<<20,ZH=1<<21,QH=64,$H=256;function eU(e,t=QH){let n=Math.max(1,t);return{cellSize:e,slotsByCell:new Map,minX:new Float64Array(n),minY:new Float64Array(n),maxX:new Float64Array(n),maxY:new Float64Array(n),isStored:new Uint8Array(n),visitStamp:new Uint32Array(n),currentStamp:0,oversizedSlots:new Set}}function tU(e,t,n){let r=n(t);return r.set(e),r}function nU(e,t){if(t<e.minX.length)return;let n=Math.max(t+1,e.minX.length*2);e.minX=tU(e.minX,n,e=>new Float64Array(e)),e.minY=tU(e.minY,n,e=>new Float64Array(e)),e.maxX=tU(e.maxX,n,e=>new Float64Array(e)),e.maxY=tU(e.maxY,n,e=>new Float64Array(e)),e.isStored=tU(e.isStored,n,e=>new Uint8Array(e)),e.visitStamp=tU(e.visitStamp,n,e=>new Uint32Array(e))}function rU(e,t){return Math.floor(t/e.cellSize)}function iU(e,t){return(e+XH)*ZH+(t+XH)}function aU(e,t,n,r,i){return(rU(e,r)-rU(e,t)+1)*(rU(e,i)-rU(e,n)+1)}function oU(e,t,n,r,i){return!(aU(e,t,n,r,i)<=$H)}function sU(e,t,n,r,i,a){let o=rU(e,t),s=rU(e,r),c=rU(e,n),l=rU(e,i);for(let e=o;e<=s;e+=1)for(let t=c;t<=l;t+=1)a(iU(e,t))}function cU(e,t){t>=e.isStored.length||e.isStored[t]===0||(e.isStored[t]=0,e.oversizedSlots.delete(t)||sU(e,e.minX[t]??0,e.minY[t]??0,e.maxX[t]??0,e.maxY[t]??0,n=>{let r=e.slotsByCell.get(n);if(!r)return;let i=r.indexOf(t);i!==-1&&(r[i]=r[r.length-1]??t,r.pop(),r.length===0&&e.slotsByCell.delete(n))}))}function lU(e,t,n){cU(e,t),nU(e,t),e.minX[t]=n.x,e.minY[t]=n.y,e.maxX[t]=n.x+n.width,e.maxY[t]=n.y+n.height,e.isStored[t]=1,oU(e,n.x,n.y,n.x+n.width,n.y+n.height)?e.oversizedSlots.add(t):sU(e,n.x,n.y,n.x+n.width,n.y+n.height,n=>{let r=e.slotsByCell.get(n);r?r.push(t):e.slotsByCell.set(n,[t])})}function uU(e){return e.currentStamp+=1,e.currentStamp<4294967295||(e.visitStamp.fill(0),e.currentStamp=1),e.currentStamp}function dU(e,t,n){return(e.minX[t]??0)<=n.x+n.width&&n.x<=(e.maxX[t]??0)&&(e.minY[t]??0)<=n.y+n.height&&n.y<=(e.maxY[t]??0)}function fU(e,t,n){for(let r=0;r<e.isStored.length;r+=1)if(e.isStored[r]===1&&dU(e,r,t)&&n(r)===!0)return}function pU(e,t,n){let r=t.x+t.width,i=t.y+t.height;if(oU(e,t.x,t.y,r,i)){fU(e,t,n);return}let a=uU(e);for(let r of e.oversizedSlots)if(e.visitStamp[r]=a,dU(e,r,t)&&n(r)===!0)return;let o=rU(e,t.x),s=rU(e,r),c=rU(e,t.y),l=rU(e,i);for(let r=o;r<=s;r+=1)for(let i=c;i<=l;i+=1){let o=e.slotsByCell.get(iU(r,i));if(o){for(let r of o)if(e.visitStamp[r]!==a&&(e.visitStamp[r]=a,dU(e,r,t)&&n(r)===!0))return}}}function mU(e,t,n=()=>!0){let r=!1;return pU(e,t,e=>n(e)?(r=!0,!0):!1),r}function hU(e,t){let n=eU(t,e.length);for(let[t,r]of e.entries())lU(n,t,r);return n}var gU=1,_U=42,vU=42,yU=4,J=0,Y=1,bU=2,xU=3,SU=1024,CU=32,wU=-2,TU=1,EU=2,DU=-1;function OU(){return{values:new Float64Array(64),length:0}}function kU(e,t){if(e.length===e.values.length){let t=new Float64Array(e.values.length*2);t.set(e.values),e.values=t}e.values[e.length]=t,e.length+=1}function AU(e){return e.values.subarray(0,e.length)}function jU(){return{lines:OU(),starts:OU(),ends:OU()}}function MU(e,t,n,r){r<n||(kU(e.lines,t),kU(e.starts,n),kU(e.ends,r))}function X(){return{alongs:OU(),acrosses:OU()}}function NU(e,t,n){return kU(e.alongs,t),kU(e.acrosses,n),e.alongs.length-1}function PU(e,t){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let t of[...e.hardRects,...e.softRects])n=Math.min(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.x+t.width),a=Math.max(a,t.y+t.height);for(let e of t)n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x),a=Math.max(a,e.y);if(n===1/0)return null;let o=e.contentTop+yU;return{left:Math.round(n-_U),top:Math.max(Math.round(r-_U),o),right:Math.round(i+_U),bottom:Math.round(a+_U)}}function FU(e){let t=lH(e.length);return e.forEach((e,n)=>{uH(t,n,e.x-gU,e.y-gU,e.x+e.width+gU,e.y+e.height+gU)}),t}function IU(e,t){return t===J?{starts:e.lefts,lows:e.tops,highs:e.bottoms}:t===Y?{starts:e.rights.map(e=>-e),lows:e.tops,highs:e.bottoms}:t===bU?{starts:e.tops,lows:e.lefts,highs:e.rights}:{starts:e.bottoms.map(e=>-e),lows:e.lefts,highs:e.rights}}function LU(e){let t=new Int32Array(e.length);for(let e=0;e<t.length;e+=1)t[e]=e;return t.sort((t,n)=>(e[n]??0)-(e[t]??0))}function RU(e,t,n){let r=t===J||t===Y,i=r?e.tops:e.lefts,a=r?e.bottoms:e.rights,o=Float64Array.from(n).sort(),s=[];for(let t=0;t<e.count;t+=1){let e=aW(o,0,o.length,i[t]??0);e<o.length&&(o[e]??0)<=(a[t]??0)&&s.push(t)}let c=lH(s.length);return s.forEach((t,n)=>{uH(c,n,e.lefts[t]??0,e.tops[t]??0,e.rights[t]??0,e.bottoms[t]??0)}),c}function zU(e,t,n){let r=IU(e,t),i=t===Y||t===xU,a=new Float64Array(n.alongs.length);for(let t=0;t<a.length;t+=1){let o=i?-(n.alongs.values[t]??0):n.alongs.values[t]??0,s=n.acrosses.values[t]??0,c=1/0;for(let t=0;t<e.count;t+=1){let e=r.starts[t]??0;e>=o&&e<c&&(r.lows[t]??0)<s&&s<(r.highs[t]??0)&&(c=e)}a[t]=i?-c:c}return a}function BU(e,t,n){if(n.alongs.length*e.count<=ZU)return zU(e,t,n);let r=n.alongs.length*XU<e.count?RU(e,t,AU(n.acrosses)):e,i=IU(r,t),a=t===Y||t===xU,o=AU(n.alongs).map(e=>a?-e:e),s=AU(n.acrosses),c=new Float64Array(r.count*2+s.length);c.set(i.lows,0),c.set(i.highs,r.count),c.set(s,r.count*2);let l=dH(c),u=mH(l.length),d=new Float64Array(u*2).fill(1/0),f=new Float64Array(o.length).fill(1/0),p=LU(i.starts),m=0;for(let e of LU(o)){let t=o[e]??0;for(;m<p.length;m+=1){let e=p[m]??0,n=i.starts[e]??0;if(n<t)break;let r=pH(l,i.lows[e]??0)+1+u,a=pH(l,i.highs[e]??0)+u;for(;r<a;)r&1&&(d[r]=Math.min(d[r]??1/0,n),r+=1),a&1&&(--a,d[a]=Math.min(d[a]??1/0,n)),r>>=1,a>>=1}let n=1/0;for(let t=pH(l,s[e]??0)+u;t>=1;t>>=1)n=Math.min(n,d[t]??1/0);f[e]=a?-n:n}return f}function VU(e,t,n){let r=new Uint8Array(t.length);for(let i=0;i<t.length;i+=1){let a=t[i]??0,o=n[i]??0;for(let t=0;t<e.count&&r[i]===0;t+=1)(e.lefts[t]??0)<a&&a<(e.rights[t]??0)&&(e.tops[t]??0)<o&&o<(e.bottoms[t]??0)&&(r[i]=1)}return r}function HU(e,t,n){if(t.length*e.count<=ZU)return VU(e,t,n);let r=new Uint8Array(t.length),i=lH(t.length);for(let e=0;e<t.length;e+=1)uH(i,e,t[e]??0,n[e]??0,t[e]??0,n[e]??0);return xH(i,e,(i,a)=>{let o=t[i]??0,s=n[i]??0;(e.lefts[a]??0)<o&&o<(e.rights[a]??0)&&(e.tops[a]??0)<s&&s<(e.bottoms[a]??0)&&(r[i]=1)}),r}function UU(e,t){let n={xs:OU(),ys:OU(),awayDirections:OU()};for(let r of e){let e=Math.round(r.x-14),i=Math.round(r.x+r.width+14),a=Math.max(Math.round(r.y-14),t.top),o=Math.round(r.y+r.height+14);for(let[t,r,s,c]of[[e,a,Y,xU],[i,a,J,xU],[e,o,Y,bU],[i,o,J,bU]])kU(n.xs,t),kU(n.ys,r),kU(n.awayDirections,s*4+c)}return n}function WU(e,t){return{rays:t,hits:t.map((t,n)=>BU(e,n,t))}}function GU(e,t,n){return t===J?Math.min(e,n.right):t===Y?Math.max(e,n.left):t===bU?Math.min(e,n.bottom):Math.max(e,n.top)}function KU(e,t,n){if(!Number.isFinite(t))return null;let r=n===J||n===bU?t+gU-14:t-gU+14;return Math.abs(r-e)<=vU?null:Math.round((e+r)/2)}function qU(e,t,n,r,i){let a=[];for(let e=0;e<i.count;e+=1)(i.tops[e]??0)<t&&t<(i.bottoms[e]??0)&&a.push([i.lefts[e]??0,i.rights[e]??0]);a.sort((e,t)=>e[0]-t[0]);let o=n;for(let[n,i]of a)n>o&&MU(e,t,o,Math.min(n,r)),o=Math.max(o,i);MU(e,t,o,r)}function JU(e,t){let n=jU(),r=jU(),i=[X(),X(),X(),X()],a=t.map(e=>{let t=e.outwardDirection===J||e.outwardDirection===Y;return NU(i[e.outwardDirection]??X(),t?e.x:e.y,t?e.y:e.x)}),o=WU(e.blockers,i);return t.forEach((t,i)=>{let s=GU(o.hits[t.outwardDirection]?.[a[i]??0]??1/0,t.outwardDirection,e.frame);t.outwardDirection===J||t.outwardDirection===Y?(MU(n,t.y,Math.min(t.x,s),Math.max(t.x,s)),MU(r,t.x,t.y,t.y)):(MU(r,t.x,Math.min(t.y,s),Math.max(t.y,s)),MU(n,t.y,t.x,t.x))}),{horizontal:n,vertical:r}}var YU=12,XU=4,ZU=4096;function QU(e,t){let n=UU([...e.hardRects,...e.softRects],t),r=n.xs.length;return{count:r,xs:AU(n.xs),ys:AU(n.ys),awayDirections:AU(n.awayDirections),rows:new Float64Array(r*YU).fill(NaN)}}function $U(e,t,n,r,i,a){let o=t*YU+n*3;e[o]=r,e[o+1]=i,e[o+2]=a}function eW(e,t,n,r){let i=Float64Array.from(t,t=>e.xs[t]??0),a=Float64Array.from(t,t=>e.ys[t]??0),o=HU(n,i,a),s=[X(),X(),X(),X()],c=new Int32Array(t.length*4).fill(-1);for(let e=0;e<t.length;e+=1){if(o[e]===1)continue;let t=i[e]??0,n=a[e]??0;for(let r=0;r<4;r+=1){let i=s[r];if(!i)continue;let a=r===J||r===Y;c[e*4+r]=NU(i,a?t:n,a?n:t)}}let l=WU(n,s),u=(e,t,n)=>GU(e.hits[t]?.[n]??1/0,t,r),d=[X(),X(),X(),X()],f=[],p=[];for(let n=0;n<t.length;n+=1){let s=t[n]??0;if(e.rows.fill(NaN,s*YU,(s+1)*YU),o[n]===1)continue;let m=i[n]??0,h=a[n]??0,g=e=>c[n*4+e]??-1;$U(e.rows,s,0,h,u(l,Y,g(Y)),u(l,J,g(J))),$U(e.rows,s,1,m,u(l,xU,g(xU)),u(l,bU,g(bU)));let _=e.awayDirections[s]??0,v=Math.floor(_/4),y=_%4,b=KU(m,l.hits[v]?.[g(v)]??1/0,v);b!==null&&f.push(s,NU(d[xU]??X(),h,b),NU(d[bU]??X(),h,b),b);let ee=KU(h,l.hits[y]?.[g(y)]??1/0,y);ee!==null&&ee>=r.top&&p.push(s,NU(d[Y]??X(),m,ee),NU(d[J]??X(),m,ee),ee)}let m=WU(n,d);for(let t=0;t<f.length;t+=4)$U(e.rows,f[t]??0,2,f[t+3]??0,u(m,xU,f[t+1]??0),u(m,bU,f[t+2]??0));for(let t=0;t<p.length;t+=4)$U(e.rows,p[t]??0,3,p[t+3]??0,u(m,Y,p[t+1]??0),u(m,J,p[t+2]??0))}function tW(e,t,n){let r=jU(),i=jU(),a=[r,i,i,r];for(let t=0;t<e.count;t+=1)for(let n=0;n<4;n+=1){let r=t*YU+n*3,i=e.rows[r]??NaN,o=a[n];!Number.isNaN(i)&&o&&MU(o,i,e.rows[r+1]??0,e.rows[r+2]??0)}return qU(r,t.top,t.left,t.right,n),MU(r,t.bottom,t.left,t.right),MU(i,t.left,t.top,t.bottom),MU(i,t.right,t.top,t.bottom),{horizontal:r,vertical:i}}function nW(e,t,n,r){let i=e.lines[t]??0,a=n.lines[r]??0;return i<a||i===a&&(e.starts[t]??0)<=(n.starts[r]??0)}function rW(e,t){if(t.count===0)return e;let n=e.count+t.count,r={lines:new Float64Array(n),starts:new Float64Array(n),ends:new Float64Array(n)},i=0,a=0,o=0;for(;a<e.count||o<t.count;){let n=o>=t.count||a<e.count&&nW(e,a,t,o),s=n?e:t,c=n?a:o;n&&(a+=1),n||(o+=1);let l=s.lines[c]??0,u=s.starts[c]??0,d=s.ends[c]??0,f=i-1;i>0&&r.lines[f]===l&&u<=(r.ends[f]??0)?r.ends[f]=Math.max(r.ends[f]??0,d):(r.lines[i]=l,r.starts[i]=u,r.ends[i]=d,i+=1)}return{count:i,lines:r.lines.subarray(0,i),starts:r.starts.subarray(0,i),ends:r.ends.subarray(0,i)}}function iW(e){let t=AU(e.lines),n=AU(e.starts),r=AU(e.ends),i=new Int32Array(t.length);for(let e=0;e<i.length;e+=1)i[e]=e;i.sort((e,r)=>(t[e]??0)-(t[r]??0)||(n[e]??0)-(n[r]??0));let a={lines:new Float64Array(t.length),starts:new Float64Array(t.length),ends:new Float64Array(t.length)},o=0;for(let e of i){let i=t[e]??0,s=n[e]??0,c=r[e]??0,l=o-1;o>0&&a.lines[l]===i&&s<=(a.ends[l]??0)?a.ends[l]=Math.max(a.ends[l]??0,c):(a.lines[o]=i,a.starts[o]=s,a.ends[o]=c,o+=1)}return{count:o,lines:a.lines.subarray(0,o),starts:a.starts.subarray(0,o),ends:a.ends.subarray(0,o)}}function aW(e,t,n,r){let i=t,a=n;for(;i<a;){let t=i+a>>1;(e[t]??0)<r?i=t+1:a=t}return i}function oW(e,t,n,r){let i=t,a=n;for(;i<a;){let t=i+a>>1;(e[t]??0)<=r?i=t+1:a=t}return i}function sW(e,t,n,r){let i=t+e,a=n+e+1;for(;i<a;)i&1&&(r(i),i+=1),a&1&&(--a,r(a)),i>>=1,a>>=1}function cW(e){for(let t=1;t<e.length;t+=1)e[t]=(e[t]??0)+(e[t-1]??0);return e}function lW(e){return dH(Float64Array.from(e.lines))}function uW(e,t){let n=mH(Math.max(t.length,1)),r=new Int32Array(e.count),i=new Int32Array(e.count),a=new Int32Array(n*2+1);for(let o=0;o<e.count;o+=1)r[o]=aW(t,0,t.length,e.starts[o]??0),i[o]=oW(t,0,t.length,e.ends[o]??0)-1,sW(n,r[o]??0,i[o]??-1,e=>{a[e+1]=(a[e+1]??0)+1});cW(a);let o=a.slice(),s=a[n*2]??0,c=new Float64Array(s),l=new Int32Array(s);for(let t=0;t<e.count;t+=1)sW(n,r[t]??0,i[t]??-1,n=>{let r=o[n]??0;c[r]=e.lines[t]??0,l[r]=t,o[n]=r+1});return{acrossValues:t,capacity:n,offsets:a,lines:c,pieces:l}}function dW(e,t,n,r){let i=aW(e.acrossValues,0,e.acrossValues.length,t);if(e.acrossValues[i]!==t)return-1;let a=-1,o=r?1/0:-1/0;for(let t=i+e.capacity;t>=1;t>>=1){let i=e.offsets[t]??0,s=e.offsets[t+1]??0,c=r?oW(e.lines,i,s,n):aW(e.lines,i,s,n)-1;if(c<i||c>=s)continue;let l=e.lines[c]??0;(r?l<o:l>o)&&(o=l,a=e.pieces[c]??-1)}return a}function fW(e,t){let n=Float64Array.from(e,e=>t?e.y:e.x),r=Float64Array.from(e,e=>t?e.y+e.height:e.x+e.width),i=Float64Array.from(e,e=>t?e.x:e.y),a=Float64Array.from(e,e=>t?e.x+e.width:e.y+e.height),o=new Float64Array(e.length*2);o.set(n,0),o.set(r,e.length);let s=dH(o),c=mH(Math.max(s.length*2-1,1)),l=e=>[aW(s,0,s.length,n[e]??0)*2+1,aW(s,0,s.length,r[e]??0)*2-1],u=new Int32Array(c*2+1),d=Int32Array.from(e.keys()).sort((e,t)=>(i[e]??0)-(i[t]??0));for(let e of d){let[t,n]=l(e);sW(c,t,n,e=>{u[e+1]=(u[e+1]??0)+1})}cW(u);let f=u.slice(),p=u[c*2]??0,m=new Float64Array(p),h=new Float64Array(p);for(let e of d){let[t,n]=l(e);sW(c,t,n,t=>{let n=f[t]??0,r=n===(u[t]??0);m[n]=i[e]??0,h[n]=r?a[e]??0:Math.max(h[n-1]??0,a[e]??0),f[t]=n+1})}return{boundaries:s,capacity:c,offsets:u,alongLows:m,reachMaxima:h}}function pW(e,t){let n=aW(e,0,e.length,t);return e[n]===t?n*2:n===0||n===e.length?-1:n*2-1}function mW(e,t,n,r){let i=pW(e.boundaries,t);if(i<0)return!1;for(let t=i+e.capacity;t>=1;t>>=1){let i=e.offsets[t]??0,a=aW(e.alongLows,i,e.offsets[t+1]??0,r);if(a>i&&(e.reachMaxima[a-1]??0)>n)return!0}return!1}function hW(e,t){let n=Int32Array.from({length:e.count+t.count},(e,t)=>t),r=e=>{let t=e;for(;n[t]!==t;){let e=n[n[t]??t]??t;n[t]=e,t=e}return t},i=(e,t)=>{n[r(e)]=r(t)},a=lW(e),o=mH(Math.max(a.length,1)),s=new Int32Array(o*2),c=new Int32Array(o*2).fill(-1),l=t=>aW(a,0,a.length,e.lines[t]??0)+o,u=e=>{let t=l(e);s[t]=1,c[t]=e;for(let e=t>>1;e>=1;e>>=1)s[e]=(s[e]??0)+1,c[e]=-1},d=e=>{let t=l(e);s[t]=0;for(let e=t>>1;e>=1;e>>=1)s[e]=(s[e]??0)-1},f=(e,t,n,r,a,o)=>{if((s[e]??0)===0||n<r||t>a)return;let l=r<=t&&n<=a,u=c[e]??-1;if(l&&u>=0){i(u,o);return}let d=t+n>>1;f(e*2,t,d,r,a,o),f(e*2+1,d+1,n,r,a,o),l&&(c[e]=o)},p=Int32Array.from({length:e.count},(e,t)=>t).sort((t,n)=>(e.starts[t]??0)-(e.starts[n]??0)),m=Int32Array.from({length:e.count},(e,t)=>t).sort((t,n)=>(e.ends[t]??0)-(e.ends[n]??0)),h=0,g=0;for(let n=0;n<t.count;n+=1){let r=t.lines[n]??0;for(;;){let t=p[h]??-1,n=m[g]??-1,i=t>=0?e.starts[t]??0:1/0,a=n>=0?e.ends[n]??0:1/0;if(a<r&&a<i)d(n),g+=1;else{if(i>r)break;u(t),h+=1}}let i=aW(a,0,a.length,t.starts[n]??0),s=oW(a,0,a.length,t.ends[n]??0)-1;f(1,0,o-1,i,s,e.count+n)}return Int32Array.from(n.keys(),e=>r(e))}function gW(e,t,n){let r=0,i=e.count;for(;r<i;){let a=r+i>>1,o=e.lines[a]??0;o<t||o===t&&(e.starts[a]??0)<=n?r=a+1:i=a}let a=r-1;return a<0||e.lines[a]!==t||(e.ends[a]??0)<n?-1:a}function _W(e){return{horizontalPieces:new Int32Array(e),verticalPieces:new Int32Array(e),neighbors:new Int32Array(e*4).fill(wU),softSteps:new Uint8Array(e*4)}}function vW(e,t){let n=e.xs.length*2,r=_W(n);r.horizontalPieces.set(t.horizontalPieces),r.verticalPieces.set(t.verticalPieces),r.neighbors.set(t.neighbors),r.softSteps.set(t.softSteps);let i=new Float64Array(n),a=new Float64Array(n);return i.set(e.xs),a.set(e.ys),e.xs=i,e.ys=a,r}function yW(e,t,n){let r=Math.imul(e,2654435761)^Math.imul(t,2246822507);return r=Math.imul(r^r>>>16,2146121005),(r^r>>>15)&n}function bW(e,t){let n=PU(e,t);if(!n)return null;let r=FU(e.hardRects),i=QU(e,n);return eW(i,Array.from({length:i.count},(e,t)=>t),r,n),xW(e,n,r,i)}function xW(e,t,n,r){let i=tW(r,t,n);return{input:e,frame:t,blockers:n,corners:r,horizontal:iW(i.horizontal),vertical:iW(i.vertical),softAlongX:fW(e.softRects,!0),softAlongY:fW(e.softRects,!1)}}function SW(e){return bW(e,[])}function CW(e,t){return e.left===t.left&&e.top===t.top&&e.right===t.right&&e.bottom===t.bottom}function wW(e,t){let n=PU(e.input,t),r=n&&!CW(n,e.frame)?bW(e.input,t):e;if(!r)return null;let{softAlongX:i,softAlongY:a}=r,o=JU(r,t),s=rW(r.horizontal,iW(o.horizontal)),c=rW(r.vertical,iW(o.vertical)),l=uW(c,lW(s)),u=uW(s,lW(c)),d=hW(s,c),f=_W(SU),p=new Int32Array(SU*2).fill(DU),m=(e,t)=>{let n=p.length-1;for(let r=yW(e,t,n);;r=r+1&n){let n=p[r]??DU;if(n===DU||f.horizontalPieces[n]===e&&f.verticalPieces[n]===t)return r}},h=()=>{p=new Int32Array(p.length*2).fill(DU);for(let e=0;e<x.nodeCount;e+=1)p[m(f.horizontalPieces[e]??0,f.verticalPieces[e]??0)]=e},g=(e,t)=>{let n=p[m(e,t)]??DU;if(n!==DU)return n;let r=x.nodeCount;return r===x.xs.length&&(f=vW(x,f)),(r+1)*2>p.length&&h(),x.xs[r]=c.lines[t]??0,x.ys[r]=s.lines[e]??0,f.horizontalPieces[r]=e,f.verticalPieces[r]=t,p[m(e,t)]=r,x.nodeCount+=1,r},_=(e,t)=>{let n=t===J||t===bU,r=x.xs[e]??0,i=x.ys[e]??0;if(t===J||t===Y){let t=f.horizontalPieces[e]??0,a=dW(l,i,r,n),o=c.lines[a]??NaN;return a<0||o<(s.starts[t]??0)||o>(s.ends[t]??0)?-1:g(t,a)}let a=f.verticalPieces[e]??0,o=dW(u,r,i,n),d=s.lines[o]??NaN;return o<0||d<(c.starts[a]??0)||d>(c.ends[a]??0)?-1:g(o,a)},v=(e,t)=>{let n=f.neighbors[e*4+t]??wU;if(n!==wU)return n;let r=_(e,t);return f.neighbors[e*4+t]=r,r>=0&&(f.neighbors[r*4+(t^1)]=e),r},y=(e,t)=>{let n=f.softSteps[e*4+t]??0;if(n!==0)return n===EU;let r=v(e,t),o=t===J||t===Y,[s,c,l]=o?[x.ys[e]??0,x.xs[e]??0,x.xs[r]??0]:[x.xs[e]??0,x.ys[e]??0,x.ys[r]??0],u=r>=0&&mW(o?i:a,s,Math.min(c,l),Math.max(c,l)),d=u?EU:TU;return f.softSteps[e*4+t]=d,r>=0&&(f.softSteps[r*4+(t^1)]=d),u},b=(e,t)=>{let n=gW(s,t,e),r=gW(c,e,t);return n<0||r<0?-1:g(n,r)},ee=e=>d[f.horizontalPieces[e]??0]??-1,te=(s.count+c.count)*CU,x={nodeCount:0,xs:new Float64Array(SU),ys:new Float64Array(SU),neighborOf:v,isSoftStep:y,nodeAt:b,componentOf:ee,beginSearch:()=>{x.nodeCount<=te||(p.fill(DU),f.neighbors.fill(wU,0,x.nodeCount*4),f.softSteps.fill(0,0,x.nodeCount*4),x.nodeCount=0)},pieceExtentOf:(e,t)=>{let n=t?s:c,r=(t?f.horizontalPieces[e]:f.verticalPieces[e])??0;return[n.starts[r]??0,n.ends[r]??0]}};return x}var TW=30,EW=60,DW=512,OW=3,kW=400,AW=6,jW=1,MW=1e6,NW=4096,PW=200,FW=240,IW=2,LW=3e3,RW=[960,3840],zW=512,BW=64,VW=14,HW=8,UW=6.6,WW=5,GW=10,KW=2,qW=[.5,.35,.65,.2,.8],JW=256,YW=0,XW=1,ZW=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}],Z={right:0,left:1,bottom:2,top:3},QW={left:0,right:1,top:2,bottom:3},$W=[1,0,3,2],eG=1;function tG(e){return e===`left`||e===`right`}function nG(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function rG(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function iG(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);return{x:t,y:n,width:r-t,height:i-n}}function aG(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 oG(e){return e.from.y===e.to.y}function sG(e,t){let n=t.x+t.width,r=t.y+t.height;if(oG(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 cG(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 lG(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 uG(e){return e.slice(1).flatMap((t,n)=>{let r=e[n];return r?[{from:r,to:t}]:[]})}function dG(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function fG(e){return{count:e.length,messageAt:t=>e[t]??``}}function pG(e){let t=e.reduce((e,t)=>e+t.count,0),n=t<=vt.layoutWarnings?t:vt.layoutWarnings-1,r=[];for(let t of e)for(let e=0;e<t.count&&r.length<n;e+=1)r.push(t.messageAt(e));return t===n?r:[...r,`and ${t-n} more`]}function mG(e,t){return t.x>=e.x+e.width||t.x+t.width<=e.x}function hG(e,t,n){if(e.id===t.id)return{exitSide:`right`,entrySide:`top`};if(n)return{exitSide:`bottom`,entrySide:`bottom`};let r=nG(e),i=nG(t);return mG(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 gG=[`right`,`left`,`bottom`,`top`];function _G(e,t){let n=e.outputPort??zG(e.from,t.exitSide,1)[0]??nG(e.from),r=zG(e.to,t.entrySide,1)[0]??nG(e.to);if(!WG(t.exitSide,t.entrySide))return{...e,...t,start:n,end:r};let i=GG(r,t.entrySide,e.to,n),a=i===r&&!e.outputPort?GG(n,t.exitSide,e.from,r):n;return{...e,...t,start:a,end:i}}function vG(e,t){return lG(t.map(t=>({x:e.xs[t>>2]??0,y:e.ys[t>>2]??0})))}function yG(e,t,n,r,i){return t.map(t=>({side:t,point:t===n?r:zG(e,t,1)[0]??nG(e),direction:i[t],bias:t===n?0:jW}))}function bG(e){return[e,...gG.filter(t=>t!==e)]}function xG(e,t){let{wire:n,from:r,to:i}=e;if(n.back||r.id===i.id)return null;let a=e.outputPort||n.fromSide?[e.exitSide]:bG(t.exitSide),o=n.toSide?[n.toSide]:bG(t.entrySide);if(a.length<2&&o.length<2)return null;let s=_G(e,{exitSide:a[0]??t.exitSide,entrySide:o[0]??t.entrySide});return{plan:e,exits:e.outputPort?[{side:e.exitSide,point:e.outputPort,direction:Z[e.exitSide],bias:0}]:yG(r,a,a[0]??t.exitSide,s.start,Z),entries:yG(i,o,o[0]??t.entrySide,s.end,QW)}}function SG(e){return e.flatMap(e=>[...e.exits.map(e=>({x:e.point.x,y:e.point.y,outwardDirection:e.direction})),...e.entries.map(e=>({x:e.point.x,y:e.point.y,outwardDirection:$W[e.direction]??0}))])}function CG(e,t,n,r){e.plan.exitSide=t.side,e.plan.entrySide=n.side,e.plan.found={exitSide:t.side,entrySide:n.side,start:t.point,end:n.point,points:r}}function wG(e,t){let n={x:t.point.x-e.point.x,y:t.point.y-e.point.y};if(n.x!==0&&n.y!==0)return!1;let r=n.x>0?Z.right:n.x<0?Z.left:n.y>0?Z.bottom:Z.top;return(n.x!==0||n.y!==0)&&e.direction===r&&t.direction===r}function TG(e){return e===Z.right||e===Z.left}function EG(e,t){return t.x>e.x?Z.right:t.x<e.x?Z.left:t.y>e.y?Z.bottom:Z.top}function DG(e,t){if(TG(e.direction)===TG(t.direction))return null;let n=TG(e.direction)?{x:t.point.x,y:e.point.y}:{x:e.point.x,y:t.point.y};return DK(n,e.point)||DK(n,t.point)||EG(e.point,n)!==e.direction||EG(n,t.point)!==t.direction?null:[e.point,n,t.point]}function OG(e,t,n){return uG([...e]).every(e=>{let r=yq(e.from,e.to),i=n.obstaclesIn?.(rG(r,eG));return i!==void 0&&!i.hardRects.some(e=>e!==t.from&&e!==t.to&&cG(rG(e,eG),r))})}function kG(e){return uG([...e]).reduce((e,t)=>e+zK(t),0)}function AG(e,t,n,r){let i=yq(e.from,e.to),a=n.obstaclesIn?.(rG(i,eG));if(!a||a.hardRects.some(e=>e!==t.from&&e!==t.to&&cG(rG(e,eG),i))||a.softRects.some(e=>cG(e,i)))return!1;let o=yK(r,i);return!(oG(e)?o.verticals:o.horizontals).some(t=>WK(e,t))}function jG(e,t){return wG(e,t)?[e.point,t.point]:DG(e,t)}function MG(e){return e.exits.flatMap(t=>e.entries.flatMap(e=>{let n=jG(t,e);return n?[{exit:t,entry:e,points:n,bends:n.length-2,cost:kG(n)+t.bias+e.bias}]:[]}))}function NG(e,t,n){let r=MG(e).filter(n=>OG(n.points,e.plan,t)),i=Math.min(...r.map(e=>e.bends)),a=r.filter(e=>e.bends===i),o=Math.min(...a.map(e=>e.cost)),s=a.filter(e=>e.cost===o),[c]=s;return!c||s.length>1||c.bends>0&&!uG(c.points).every(r=>AG(r,e.plan,t,n))?null:{exit:c.exit,entry:c.entry,points:c.points}}function PG(e,t,n){let r=sK(),i=_K();for(let a of e){let e=NG(a,t,i);if(e){CG(a,e.exit,e.entry,e.points),vK(i,uG(e.points));continue}let o=tK(a.plan,n),s=QG(t,o),c=s?$G(SG([a]),t,o,s):null,l=c?xK(c,a.exits,a.entries,null,MW,r,yK(i,o)):null;if(lK(r),!c||!l)continue;let u=vG(c,l.states);CG(a,l.exit,l.entry,u),vK(i,uG(u))}}function FG(e,t,n,r){let i=e.flatMap(e=>{if(r.cleanIds.has(e.wire.id))return[];let n=xG(e,t.get(e)??{exitSide:e.exitSide,entrySide:e.entrySide});return n?[n]:[]});i.length>0&&PG(i,n,r)}function IG(e,t,n){let r=(e,t)=>`${e.to.id}|${e.styleKey}|${t}`,i=new Map;for(let e of t)e.entrySide===n.get(e)?.entrySide&&i.set(r(e,e.entrySide),(i.get(r(e,e.entrySide))??0)+1);for(let t of e){let e=n.get(t);e&&t.entrySide!==e.entrySide&&!t.wire.toSide&&(i.get(r(t,e.entrySide))??0)!==0&&(t.exitSide=t.outputPort||t.wire.fromSide?t.exitSide:e.exitSide,t.entrySide=e.entrySide)}}function LG(e,t,n){let r=t.boxesById.get(e.from),i=t.boxesById.get(e.to);if(!r||!i)return null;let a=hG(r,i,e.back),o=r.outputs.find(t=>t.id===e.fromOutput),s={wire:e,from:r,to:i,styleKey:`${e.dashed||e.back}|${e.tone}`,exitSide:o?`right`:e.fromSide??a.exitSide,entrySide:e.toSide??a.entrySide,busKey:null,exitKey:``,outputPort:o?.port??null,start:o?.port??nG(r),end:nG(i),found:null};return n&&(s.exitSide=n.exitSide,s.entrySide=n.entrySide),{plan:s,facing:a}}function RG(e,t){let n=new Map,r=e.wires.flatMap(r=>{let i=LG(r,e,t.cleanIds.has(r.id)?t.routeById.get(r.id):void 0);return i?(n.set(i.plan,i.facing),[i.plan]):[]}),i=(e.contextWires??[]).flatMap(r=>{let i=LG(r,e,t.routeById.get(r.id));return i?(n.set(i.plan,i.facing),[i.plan]):[]});FG(r,n,e,t),IG(r,[...r,...i],n);let a=[...r,...i];for(let e of a){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 o=e=>`${e.to.id}|${e.entrySide}|${e.styleKey}`,s=new Map;for(let e of a)s.set(o(e),(s.get(o(e))??0)+1);for(let e of a)(s.get(o(e))??0)>1&&(e.busKey=o(e));return{plans:r,contextPlans:i}}function zG(e,t,n){let r=Array.from({length:n},(e,t)=>t);if(tG(t)){let i=Math.round(t===`left`?e.x:e.x+e.width),a=Math.min(VW,(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+HW,Math.min(o,e.y+e.height-HW-(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)*VW/2;return r.map(e=>({x:Math.round(a+e*VW),y:i}))}function BG(e,t){let n=tG(t)?e.height:e.width;return Math.max(1,Math.floor((n-16)/VW)+1)}function VG(e,t=null){let n=e.flatMap(e=>[...e.outputPort?[]:[{box:e.from,side:e.exitSide,groupKey:`exit|${e.styleKey}`,wireId:e.wire.id,farPoint:nG(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??nG(e.from),assign:t=>{e.end=t}}]);return aG(t?n.filter(e=>t.has(e.box.id)):n,e=>`${e.box.id}|${e.side}`)}function HG(e){return new Map([...e.entries()].map(([e,t])=>[e,[...aG(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+(tG(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 UG(e,t){for(let[n,r]of e){let e=r[0],i=t.get(n)??[];if(!e)continue;let a=zG(e.box,e.side,i.length);for(let e of r){let t=a[i.indexOf(e.groupKey)];t&&e.assign(t)}}}function WG(e,t){return e===`right`&&t===`left`||e===`left`&&t===`right`||e===`bottom`&&t===`top`||e===`top`&&t===`bottom`}function GG(e,t,n,r){return tG(t)?r.y>=n.y+HW&&r.y<=n.y+n.height-HW?{x:e.x,y:r.y}:e:r.x>=n.x+HW&&r.x<=n.x+n.width-HW?{x:r.x,y:e.y}:e}function KG(e,t){let n=(e,n)=>(t.get(`${e.id}|${n}`)?.length??0)===1,r=new Map([...aG(e,e=>e.exitKey)].map(([e,t])=>[e,t.length]));for(let t of e){if(t.from.id===t.to.id||!WG(t.exitSide,t.entrySide))continue;let e=t.busKey===null&&n(t.to,t.entrySide)?GG(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=GG(t.start,t.exitSide,t.from,t.end)):t.end=e}}function qG(e,t){return[...e.entries()].flatMap(([e,n])=>{let r=n[0],i=t.get(e)?.length??0;return!r||i<=BG(r.box,r.side)?[]:[`box ${r.box.id} has ${i} wires on its ${r.side} side, more than fit`]})}function JG(e){return e.flatMap(e=>[{x:e.start.x,y:e.start.y,outwardDirection:Z[e.exitSide]},{x:e.end.x,y:e.end.y,outwardDirection:Z[e.entrySide]}])}function YG(e){let t=[...e.boxesById.values()],n=hU(t,zW),r=hU(e.softObstacles,zW);return i=>{let a=[],o=[];return pU(n,i,e=>{let n=t[e];n&&a.push(n)}),pU(r,i,t=>{let n=e.softObstacles[t];n&&o.push(n)}),{hardRects:a,softRects:o}}}function XG(e){return e.obstaclesIn?e:{...e,obstaclesIn:YG(e)}}function ZG(e){let t=e.x-IW,n=e.y-IW,r=e.width+4,i=e.height+4;return[{x:t,y:n,width:r,height:IW},{x:t,y:e.y+e.height,width:r,height:IW},{x:t,y:n,width:IW,height:i},{x:e.x+e.width,y:n,width:IW,height:i}]}function QG(e,t){let n=e.obstaclesIn?.(t)??null;return n&&n.hardRects.length<=LW?n:null}function $G(e,t,n,r){let i=SW({hardRects:[...r.hardRects,...ZG(n)],softRects:r.softRects,contentTop:t.contentTop});return i?wW(i,e):null}function eK(e,t,n,r){let i=e.from.id===e.to.id?[e.from]:[e.from,e.to],a=r.hardRects.filter(t=>t!==e.from&&t!==e.to),o=SW({hardRects:[...i,...ZG(n)],softRects:[...r.softRects,...a],contentTop:t.contentTop});return o?wW(o,JG([e])):null}function tK(e,t,n=FW){let r=(t.routeById.get(e.wire.id)?.points??[]).map(e=>({x:e.x,y:e.y,width:0,height:0}));return rG(iG([e.from,e.to,...r])??e.from,n)}function nK(){return{states:new Int32Array(1024),priorities:new Float64Array(1024),tieBreaks:new Float64Array(1024),size:0,lastPoppedPriority:0}}function rK(e,t,n){let r=e.priorities[t]??0,i=e.priorities[n]??0;return r<i||r===i&&(e.tieBreaks[t]??0)<(e.tieBreaks[n]??0)}function iK(e,t,n){let r=e.states[t]??0,i=e.priorities[t]??0,a=e.tieBreaks[t]??0;e.states[t]=e.states[n]??0,e.priorities[t]=e.priorities[n]??0,e.tieBreaks[t]=e.tieBreaks[n]??0,e.states[n]=r,e.priorities[n]=i,e.tieBreaks[n]=a}function aK(e,t,n,r){if(e.size===e.states.length){let t=new Int32Array(e.size*2),n=new Float64Array(e.size*2),r=new Float64Array(e.size*2);t.set(e.states),n.set(e.priorities),r.set(e.tieBreaks),e.states=t,e.priorities=n,e.tieBreaks=r}e.states[e.size]=t,e.priorities[e.size]=n,e.tieBreaks[e.size]=r;let i=e.size;for(e.size+=1;i>0;){let t=i-1>>1;if(!rK(e,i,t))return;iK(e,t,i),i=t}}function oK(e){if(e.size===0)return-1;let t=e.states[0]??-1;if(e.lastPoppedPriority=e.priorities[0]??0,--e.size,e.size===0)return t;iK(e,0,e.size);let n=0;for(;;){let r=n*2+1,i=r+1,a=n;if(r<e.size&&rK(e,r,a)&&(a=r),i<e.size&&rK(e,i,a)&&(a=i),a===n)return t;iK(e,a,n),n=a}}function sK(){return{bestCost:new Float64Array(NW).fill(1/0),cameFrom:new Int32Array(NW).fill(-1),touchedStates:[],heap:nK()}}function cK(e,t){if(t<=e.bestCost.length)return;let n=Math.max(t,e.bestCost.length*2),r=new Float64Array(n).fill(1/0),i=new Int32Array(n).fill(-1);r.set(e.bestCost),i.set(e.cameFrom),e.bestCost=r,e.cameFrom=i}function lK(e){for(let t of e.touchedStates)e.bestCost[t]=1/0,e.cameFrom[t]=-1;e.touchedStates.length=0,e.heap.size=0}function uK(e,t,n,r,i){let a={side:t.exitSide,point:t.start,direction:Z[t.exitSide],bias:0},o={side:t.entrySide,point:t.end,direction:QW[t.entrySide],bias:0},s=xK(e,[a],[o],n,TW,r,i)?.states??null;return lK(r),s}function dK(e,t,n,r){let i=e.xs[t]??0,a=e.ys[t]??0,o=e.xs[n]??0,s=e.ys[n]??0;return a===s?r.y<a&&a<r.y+r.height&&Math.min(i,o)<r.x+r.width&&Math.max(i,o)>r.x:r.x<i&&i<r.x+r.width&&Math.min(a,s)<r.y+r.height&&Math.max(a,s)>r.y}function fK(e){return e===YW||e===XW}function pK(e,t,n,r){if(e===$W[t.direction])return 2;let i=fK(t.direction),a=i?n:r,o=i?r:n,s=i?t.point.y:t.point.x,c=t.approachStart<=a&&a<=t.approachEnd,l=ZW[e]??{x:0,y:0};if(e===t.direction){let e=i?(t.point.x-n)*l.x:(t.point.y-r)*l.y;return o===s&&c&&e>=0?0:2}let u=(s-o)*(i?l.y:l.x);return c&&u>=0?1:3}function mK(e,t){return t.flatMap(t=>{let n=e.nodeAt(t.point.x,t.point.y);if(n<0)return[];let[r,i]=e.pieceExtentOf(n,fK(t.direction));return[{...t,node:n,component:e.componentOf(n),approachStart:r,approachEnd:i}]})}function hK(e,t){for(let n of e)if(n.node===t)return n;return null}var gK={horizontals:[],verticals:[]};function _K(){return{grid:eU(DW),segments:[]}}function vK(e,t){for(let n of t)lU(e.grid,e.segments.length,yq(n.from,n.to)),e.segments.push(n)}function yK(e,t){let n={horizontals:[],verticals:[]};return pU(e.grid,t,t=>{let r=e.segments[t];r&&(oG(r)?n.horizontals:n.verticals).push(r)}),n}function bK(e,t,n,r){let i=t.xs[n]??0,a=t.ys[n]??0,o=t.xs[r]??0,s=t.ys[r]??0,c=0;if(a===s){for(let t of e.verticals)UK(t.from.x,i,o)&&UK(a,t.from.y,t.to.y)&&(c+=1);return c}for(let t of e.horizontals)UK(t.from.y,a,s)&&UK(i,t.from.x,t.to.x)&&(c+=1);return c}function xK(e,t,n,r,i,a,o=gK){e.beginSearch();let s=mK(e,n),c=mK(e,t).filter(e=>s.some(t=>t.component===e.component)),l=s.filter(e=>c.some(t=>t.component===e.component));if(c.length===0||l.length===0)return null;let{touchedStates:u,heap:d}=a;cK(a,e.nodeCount*4);let f=(t,n)=>{let r=e.xs[t]??0,a=e.ys[t]??0,o=1/0;for(let e of l)o=Math.min(o,Math.abs(e.point.x-r)+Math.abs(e.point.y-a)+pK(n,e,r,a)*i+e.bias);return o};for(let e of c){let t=e.node*4+e.direction;a.bestCost[t]=e.bias,u.push(t),aK(d,t,e.bias+f(e.node,e.direction),-e.bias)}for(;;){let t=oK(d);if(t<0)return null;let n=t>>2,s=t&3,p=hK(l,n);if(p&&s===p.direction){let e=SK(a.cameFrom,t),n=hK(c,(e[0]??0)>>2);return n?{states:e,exit:n,entry:p}:null}let m=a.bestCost[t]??1/0;if(d.lastPoppedPriority>m+f(n,s)+1e-6)continue;let h=hK(c,n);for(let c=0;c<4;c+=1){if(h&&c!==h.direction||c===$W[s])continue;let p=e.neighborOf(n,c);if(p<0)continue;let g=hK(l,p);if(g&&c!==g.direction)continue;cK(a,e.nodeCount*4);let _=Math.abs((e.xs[p]??0)-(e.xs[n]??0))+Math.abs((e.ys[p]??0)-(e.ys[n]??0)),v=r!==null&&dK(e,n,p,r),y=_+(c===s?0:i)+bK(o,e,n,p)*EW+(e.isSoftStep(n,c)?_*OW:0)+(v?kW:0),b=p*4+c,ee=m+Math.max(y,1)+(g?.bias??0);ee>=(a.bestCost[b]??1/0)||(a.bestCost[b]=ee,a.cameFrom[b]=t,u.push(b),aK(d,b,ee+f(p,c),-ee))}}}function SK(e,t){let n=[];for(let r=t;r!==-1;r=e[r]??-1)n.push(r);return n.reverse()}function CK(e,t){let n=ZW[Z[t]]??{x:0,y:0};return{x:e.x+n.x*14,y:e.y+n.y*14}}function wK(e){let t=CK(e.start,e.exitSide),n=CK(e.end,e.entrySide);return lG([e.start,t,{x:n.x,y:t.y},n,e.end])}function TK(e,t){if(!e.wire.back)return null;let n=iG([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 EK(e,t,n){let r=e&&n?vG(e,n):wK(t);return{plan:t,points:r,segments:uG(r),routedPoints:r,states:n}}function DK(e,t){return e.x===t.x&&e.y===t.y}function OK(e,t){if(!t.cleanIds.has(e.wire.id))return null;let n=t.routeById.get(e.wire.id);return!n||n.exitSide!==e.exitSide||n.entrySide!==e.entrySide||!DK(n.start,e.start)||!DK(n.end,e.end)?null:{plan:e,points:n.points,segments:uG(n.points),routedPoints:n.points,states:n.isRouted?[]:null}}function kK(e,t,n,r,i,a=FW){let o=tK(e,n,a),s=QG(t,o);if(!s)return null;let c=$G(JG([e]),t,o,s),l=c?uK(c,e,TK(e,t.loopFrames),r,yK(i,o)):null;return l?EK(c,e,l):null}function AK(e,t,n,r,i){let a=tK(e,n),o=t.obstaclesIn?.(a)??null,s=o?eK(e,t,a,o):null;return EK(s,e,s?uK(s,e,TK(e,t.loopFrames),r,yK(i,a)):null)}function jK(e,t,n,r,i){let a=n.isPreview?[]:RW;for(let o of a){let a=kK(e,t,n,r,i,o);if(a)return a}return AK(e,t,n,r,i)}function MK(e){let{found:t}=e;return!t||t.exitSide!==e.exitSide||t.entrySide!==e.entrySide||!DK(t.start,e.start)||!DK(t.end,e.end)?null:{plan:e,points:t.points,segments:uG(t.points),routedPoints:t.points,states:[]}}function NK(e,t,n,r,i){let a=OK(e,n)??MK(e)??kK(e,t,n,r,i)??jK(e,t,n,r,i);return vK(i,a.segments),a}function PK(e,t,n,r){let i=tG(t)?n.y:n.x;if(r)return{low:i,high:i};let a=(tG(t)?e.y:e.x)+HW,o=(tG(t)?e.y+e.height:e.x+e.width)-HW;return{low:Math.max(a,i-VW/2),high:Math.min(o,i+VW/2)}}function FK(e,t,n){let r=sK(),i=_K(),a=e.map(e=>NK(e,t,n,r,i));if(n.isPreview)return a;let o=YH(a.map(e=>({points:e.points,exitKey:e.plan.exitKey,busKey:e.plan.busKey,startSlack:PK(e.plan.from,e.plan.exitSide,e.plan.start,e.plan.outputPort!==null),endSlack:PK(e.plan.to,e.plan.entrySide,e.plan.end,!1)})),e=>t.obstaclesIn?.(e).hardRects??[]);return a.map((e,t)=>{let n=lG(o[t]??e.points);return{...e,points:n,segments:uG(n)}})}function IK(e){return Math.max(0,e.points.length-2)}function LK(e){return Math.ceil(e.length*UW)}function RK(e,t){return{x:e.x-t/2,y:e.y-GW,width:t,height:13}}function zK(e){return Math.abs(e.from.x-e.to.x)+Math.abs(e.from.y-e.to.y)}function BK(e,t){if(!oG(e))return[];let n=e.from.y;return[Math.min(e.from.x,e.to.x)+WW+t/2,Math.max(e.from.x,e.to.x)-WW-t/2].flatMap(e=>[{x:e,y:n-WW},{x:e,y:n+WW+GW}])}function VK(e,t){let n=[...e].sort((e,t)=>zK(t)-zK(e));return[...e.slice(0,1),...n].flatMap(e=>[...qW.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 oG(e)?[{x:r,y:i-WW},{x:r,y:i+WW+GW}]:[{x:r+WW+t/2,y:i+GW/2},{x:r-WW-t/2,y:i+GW/2}]}),...BK(e,t)])}function HK(e,t,n){let r=new Map,i=e.flatMap(e=>e.segments),a=hU(i.map(e=>yq(e.from,e.to)),JW),o=[...t.boxesById.values(),...t.softObstacles],s=hU(o,JW),c=[],l=eU(JW);for(let u of e){let e=u.plan.wire.label;if(!e)continue;let d=LK(e),f=VK(u.segments,d),p=f.find(e=>{let n=RK(e,d);if(n.y<t.contentTop)return!1;let r=rG(n,KW);return mU(a,r,e=>{let t=i[e];return t!==void 0&&sG(t,r)})||mU(s,n,e=>{let t=o[e];return t!==void 0&&cG(n,t)})?!1:!mU(l,n,e=>{let t=c[e];return t!==void 0&&cG(n,t)})}),m=p??f[0]??nG(u.plan.from);p||n.push(`wire ${u.plan.wire.id} label "${e}" has no clear spot`);let h=RK(m,d);r.set(u.plan.wire.id,{at:{x:Math.round(m.x),y:Math.round(m.y)},bounds:h}),lU(l,c.length,h),c.push(h)}return r}function UK(e,t,n){return e>Math.min(t,n)+.5&&e<Math.max(t,n)-.5}function WK(e,t){if(oG(e)===oG(t))return!1;let n=oG(e)?e:t,r=n===e?t:e;return UK(r.from.x,n.from.x,n.to.x)&&UK(n.from.y,r.from.y,r.to.y)}function GK(e,t){if(oG(e)!==oG(t))return!1;let n=oG(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 KK(e,t){return e.plan.busKey!==null&&e.plan.busKey===t.plan.busKey||e.plan.exitKey===t.plan.exitKey}function qK(e){let t=e.flatMap(e=>e.segments),n=lH(t.length),r=new Int32Array(t.length),i=0;return e.forEach((e,t)=>{for(let a of e.segments)uH(n,i,a.from.x,a.from.y,a.to.x,a.to.y),r[i]=t,i+=1}),{rects:n,segments:t,wireIndexByPiece:r}}function JK(e,t,n,r,i){let a=n.wireIndexByPiece[r]??0,o=n.wireIndexByPiece[i]??0;if(a===o)return;let s=Math.min(a,o)*t.length+Math.max(a,o);if(e.get(s)===!0)return;let c=t[a],l=t[o],u=n.segments[r],d=n.segments[i];c&&l&&u&&d&&!KK(c,l)&&(WK(u,d)?e.set(s,!0):GK(u,d)&&e.set(s,!1))}function YK(){return{firsts:[],seconds:[],isCrossings:[]}}function XK(e,t,n){for(let[r,i]of t)e.firsts.push(Math.floor(r/n)),e.seconds.push(r%n),e.isCrossings.push(i);return e}function ZK(e,t){let n=[];return e.wireIndexByPiece.forEach((e,r)=>{t.isChangedByWire[e]&&n.push(r)}),n}function QK(e,t){let n=lH(t.length);return t.forEach((t,r)=>{uH(n,r,e.lefts[t]??0,e.tops[t]??0,e.rights[t]??0,e.bottoms[t]??0)}),n}function $K(e,t,n,r){let i=YK();return e.firsts.forEach((a,o)=>{let s=t[a]??-1,c=n[e.seconds[o]??0]??-1;s<0||c<0||!r(s,c)||(i.firsts.push(Math.min(s,c)),i.seconds.push(Math.max(s,c)),i.isCrossings.push(e.isCrossings[o]===!0))}),i}function eq(e,t,n){let r=new Map;if(!n)return bH(t.rects,(n,i)=>JK(r,e,t,n,i)),XK(YK(),r,e.length);let i=ZK(t,n);return xH(QK(t.rects,i),t.rects,(a,o)=>{let s=i[a]??0,c=t.wireIndexByPiece[s]??0,l=t.wireIndexByPiece[o]??0;n.isChangedByWire[l]&&l<c||JK(r,e,t,s,o)}),XK($K(n.previous.wirePairs,n.wireIndexByPrevious,n.wireIndexByPrevious,(e,t)=>!n.isChangedByWire[e]&&!n.isChangedByWire[t]),r,e.length)}function tq(e,t,n,r){let i=CH(e.firsts,e.seconds,t,n);return{count:i.length,messageAt:t=>{let n=i[t]??0;return r(e.firsts[n]??0,e.seconds[n]??0,e.isCrossings[n]===!0)}}}var nq=new WeakMap;function rq(e){let t=nq.get(e);if(t)return t;let n=[...e.boxesById.values()];return nq.set(e,n),n}function iq(e){return`box ${e.id}`}function aq(e,t,n,r,i,a,o){let s=n.wireIndexByPiece[a]??0,c=s*r.length+o;if(e.has(c))return;let l=t[s],u=r[o],d=i[o],f=n.segments[a];l&&u&&d&&f&&u.id!==l.plan.from.id&&u.id!==l.plan.to.id&&sG(f,d)&&e.set(c,!0)}function oq(e,t,n,r){let i=n.map(e=>rG(e,-2)),a=cH(i),o=new Map;if(!r)return xH(t.rects,a,(r,a)=>aq(o,e,t,n,i,r,a)),XK(YK(),o,n.length);let s=ZK(t,r);xH(QK(t.rects,s),a,(r,a)=>aq(o,e,t,n,i,s[r]??0,a));let c=n.map(e=>r.changedSolidKeys.has(iq(e))),l=n.flatMap((e,t)=>c[t]?[t]:[]);xH(t.rects,QK(a,l),(r,a)=>aq(o,e,t,n,i,r,l[a]??0));let u=new Map(n.map((e,t)=>[iq(e),t])),d=r.previous.solidKeys.map(e=>u.get(e)??-1),f=YK();return r.previous.runsThroughPairs.firsts.forEach((e,t)=>{let n=r.wireIndexByPrevious[e]??-1,i=d[r.previous.runsThroughPairs.seconds[t]??0]??-1;n<0||i<0||r.isChangedByWire[n]||c[i]||(f.firsts.push(n),f.seconds.push(i),f.isCrossings.push(!0))}),XK(f,o,n.length)}function sq(e){return JSON.stringify([e.points,e.plan.exitKey,e.plan.busKey,e.plan.from.id,e.plan.to.id])}function cq(e,t,n,r){if(!r||!n||n.size>BW)return null;let i=e.map((e,n)=>r.wireSignatureById.get(e.plan.wire.id)!==t[n]);if(i.filter(Boolean).length>PW)return null;let a=new Map(e.map((e,t)=>[e.plan.wire.id,t]));return{previous:r,isChangedByWire:i,wireIndexByPrevious:r.wireIds.map(e=>a.get(e)??-1),changedSolidKeys:n}}function lq(e,t,n,r,i){let a=qK(e),o=rq(t),s=e.map(sq),c=cq(e,s,n,i),l=oq(e,a,o,c),u=eq(e,a,c);r&&(r.warningPairs={wireIds:e.map(e=>e.plan.wire.id),wireSignatureById:new Map(e.map((e,t)=>[e.plan.wire.id,s[t]??``])),solidKeys:o.map(iq),wirePairs:u,runsThroughPairs:l});let d=t=>e[t]?.plan.wire.id;return[tq(l,e.length,o.length,(e,t)=>`wire ${d(e)} runs through ${o[t]?.kind} ${o[t]?.id}`),tq(u,e.length,e.length,(e,t,n)=>`wire ${d(e)} ${n?`crosses`:`overlaps`} wire ${d(t)}`)]}function uq(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=IK(e);return t>AW?[`wire ${e.plan.wire.id} bends ${t} times`]:[]})}function dq(e,t){return oG(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 fq(e,t){if(!t||t===e)return null;let n=e.points.find(e=>t.segments.some(t=>dq(e,t)));return!n||n.x===e.plan.end.x&&n.y===e.plan.end.y?null:n}function pq(e,t,n,r,i){return UG(n,r),KG([...e.plans,...e.contextPlans],r),FK(e.plans,t,i)}function mq(e){let t=new Map,n=e=>`${e.x},${e.y},${e.width},${e.height}`;for(let n of e.boxesById.values())t.set(`box ${n.id}`,n);for(let r of e.softObstacles)t.set(`soft ${n(r)}`,r);for(let r of e.loopFrames)t.set(`loop ${n(r)}`,r);return t}function hq(e,t){let n=(e,t)=>e!==void 0&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,r={keys:new Set,rects:[]};for(let[i,a]of e)n(t.get(i),a)||(r.keys.add(i),r.rects.push(a));for(let[i,a]of t)n(e.get(i),a)||(r.keys.add(i),r.rects.push(a));return r}function gq(e,t,n){t.length>BW?xH(cH(e),cH(t),n):e.forEach((e,r)=>{t.some(t=>e.x<=t.x+t.width&&t.x<=e.x+e.width&&e.y<=t.y+t.height&&t.y<=e.y+e.height)&&n(r)})}function _q(e,t){return e.storedWireKeyOf?.(t)??JSON.stringify(t)}function vq(e,t,n){if(!t||!n)return{routeById:t?.routeById??new Map,cleanIds:new Set,isPreview:!1};let r=n.rects.map(e=>rG(e,14)),i=e.wires.flatMap(n=>{let r=t.routeById.get(n.id);return r&&r.wireKey===_q(e,n)?[{wire:n,remembered:r}]:[]}),a=i.flatMap(({wire:e,remembered:t})=>uG(t.points).map(t=>({wireId:e.id,rect:yq(t.from,t.to)}))),o=new Set;gq(a.map(e=>e.rect),r,e=>{let t=a[e];t&&o.add(t.wireId)});let s=new Set(i.map(({wire:e})=>e.id).filter(e=>!o.has(e)));return{routeById:t.routeById,cleanIds:s,isPreview:!1}}function yq(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}}function bq(e,t,n){let r=new Map(n.map(t=>[t.plan.wire.id,{wireKey:_q(e,t.plan.wire),exitSide:t.plan.exitSide,entrySide:t.plan.entrySide,start:t.plan.start,end:t.plan.end,points:t.routedPoints,isRouted:t.states!==null}]));return{contentTop:e.contentTop,rectByKey:t,routeById:r,warningPairs:null}}function xq(e,t){let n=new Map;for(let t of[...e].sort((e,t)=>e.plan.wire.id.localeCompare(t.plan.wire.id)))t.plan.busKey&&!n.has(t.plan.busKey)&&n.set(t.plan.busKey,t);return e.map(e=>{let{plan:r,points:i}=e,a=r.busKey?n.get(r.busKey):void 0;return{kind:`wire`,id:r.wire.id,path:dG(i),start:i[0]??r.start,end:i[i.length-1]??r.end,label:r.wire.label,labelAt:t.get(r.wire.id)?.at??nG(r.from),isDashed:r.wire.dashed||r.wire.back,isBack:r.wire.back,tone:r.wire.tone,hasArrowhead:a===void 0||a===e,joinAt:fq(e,a)}})}function Sq(e){let t=XG(e),n={routeById:new Map,cleanIds:new Set,isPreview:!0},r=RG(t,n),i=VG(r.plans),a=pq(r,t,i,HG(i),n);return xq(a,HK(a,t,[]))}function Cq(e,t){let n=XG(e),r=mq(n),i=t&&t.contentTop===n.contentTop?hq(t.rectByKey,r):null,a=vq(n,t,i),o=RG(n,a),s=n.contextWires?new Set(o.plans.flatMap(e=>[e.from.id,e.to.id])):null,c=VG([...o.plans,...o.contextPlans],s),l=HG(c),u=pq(o,n,c,l,a),d=[],f=HK(u,n,d),p=xq(u,f),m=[...f.values()].map(e=>e.bounds),h=bq(n,r,u),g=u.flatMap(e=>e.points).map(e=>({x:e.x,y:e.y,width:0,height:0}));return{wires:p,segments:u.flatMap(e=>e.segments),collectWarnings:()=>[fG(uq(u)),...lq(u,n,i?.keys??null,h,t?.warningPairs??null),fG([...qG(c,l),...d])],extent:iG([...g,...m]),memory:h,portEndsById:new Map([...o.plans,...o.contextPlans].map(e=>[e.wire.id,{start:e.start,end:e.end,busKey:e.busKey}]))}}function wq(e){let t=e.match(/-?\d+(\.\d+)?(e-?\d+)?/gi)?.map(Number)??[],n=[];for(let e=0;e+1<t.length;e+=2)n.push({x:t[e]??0,y:t[e+1]??0});return n}var Q=40,Tq=220,Eq=90,Dq=30,Oq=18,kq=12,Aq=20,jq=18,Mq=28,Nq=12,Pq=2,Fq=20,Iq=26,Lq=18,Rq=26,zq=170,Bq=21,Vq=17,Hq=10,Uq=22,Wq=24,Gq=8,Kq=40,qq=18,Jq=8,Yq=320,Xq=256,Zq=160;function Qq(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 $q(e,t,n){let r=e.icon?n-3:n,i=e.muted?2:0,a=e.style===`numbered`?`${t}.`:e.style===`kv`?e.key:null,o=(t,n,r,i)=>({text:t,muted:e.muted,style:e.style,marker:n===0?i:null,indentChars:r,isFirstRow:n===0,icon:e.icon});if(a&&a.length+1>Nq){let t=Qq(e.text,r-i-Pq).map(e=>o(e,1,Pq,null));return[o(``,0,0,a),...t]}let s=e.style===`item`?Pq:a?a.length+1:0;return Qq(e.text,r-i-s-+(e.style===`code`)).map((e,t)=>o(e,t,s,a))}function eJ(e,t=Iq){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,$q(e,n,t)))}function tJ(e){return e.shape===`icon`?Zq:e.shape===`device`?Yt[e.device].defaultBoxWidth:Tq}function nJ(e){return e.width??tJ(e)}function rJ(e,t){return Math.floor(e*(t-24)/196)}function iJ(e){let t=e.icon?2:0;return e.shape===`icon`?{lines:[],media:null,device:null,fit:`fit`,glyphRoom:56,titleIconChars:0}:e.shape===`device`?{lines:[],media:e.media,device:e.device,fit:e.fit,glyphRoom:0,titleIconChars:t}:{lines:e.lines,media:e.media,device:null,fit:`fit`,glyphRoom:0,titleIconChars:t}}function aJ(e,t){let{screen:n,bezel:r,toolbarHeight:i,base:a}=Yt[e],o=Ot(e),s=t/o.width;return{width:t,height:Math.round(o.height*s),scale:s,screen:{x:Math.round(((a?.overhang??0)+r.side)*s),y:Math.round((r.top+i)*s),width:Math.round(n.width*s),height:Math.round(n.height*s)}}}function oJ(e,t){let n=t-24,r=Math.round(Yq*t/Tq),i=Math.min(r,Math.max(1,Math.round(n*e.height/e.width)));return{width:n,height:i,scale:1,screen:{x:0,y:0,width:n,height:i}}}function sJ(e,t){return e.device?aJ(e.device,t-24):e.media?oJ(e.media,t):null}function cJ(e,t,n,r){let{media:i}=e;return!i||!r?null:{kind:i.kind,asset:i.asset,mime:i.mime,hasPreview:i.hasPreview,alt:i.alt,fit:e.fit,x:t.x+kq+r.screen.x,y:t.y+n+r.screen.y,width:r.screen.width,height:r.screen.height}}function lJ(e,t,n,r){if(!e.device||!r)return null;let i=t.x+kq,a=t.y+n,o={x:i+r.screen.x,y:a+r.screen.y,width:r.screen.width,height:r.screen.height};return{name:e.device,scale:r.scale,x:i,y:a,width:r.width,height:r.height,screen:o}}var uJ=new WeakMap,dJ=new WeakMap;function fJ(e){let t=uJ.get(e);if(t)return t;let n=mJ(e);return uJ.set(e,n),n}function pJ(e,t){let n=iJ(e),r=rJ(Fq,t);return{titleLines:Qq(e.title,r-n.titleIconChars),wasLines:e.change===`relabeled`&&e.was?Qq(e.was,r):[],bodyLines:eJ(n.lines,rJ(Iq,t))}}function mJ(e){let t=iJ(e),n=e.step?qq:0,r=+!!e.step?.linkedBoardId,i=nJ(e),{titleLines:a,wasLines:o,bodyLines:s}=pJ(e,i),c=kq+n+t.glyphRoom+(o.length+a.length)*Aq+(s.length+r)*jq,l=sJ(t,i),u=l?l.height+Jq:0,d=c+kq+u,f=e.shape===`decision`?e.outputs:[];return{headerHeight:d,outputs:f,content:t,artTop:c+Jq,art:l,height:d+f.length*Mq}}function hJ(e,t){switch(t.kind){case`box`:e.box.push(t);return;case`frame`:e.frame.push(t);return;case`wire`:e.wire.push(t);return;case`note`:e.note.push(t);return}}function gJ(e){let t={box:[],frame:[],wire:[],note:[]};for(let n of e.elements.values())hJ(t,n);return{...e,elementsByKind:t,planStepById:new Map(sH(e).map(e=>[e.boxId,e]))}}function _J(e,t){return e.elementsByKind[t]}function vJ(e){return Qq(e.text,Bq)}function yJ(e){let t=dJ.get(e);if(t)return t;let n={height:24+(vJ(e).length+1)*Vq};return dJ.set(e,n),n}function bJ(e){let t=new Map;for(let n of _J(e,`note`)){let e=t.get(n.on),r=yJ(n).height;t.set(n.on,e===void 0?r:e+Hq+r)}return t}function xJ(e,t){return t.step?{label:e.get(t.id)?.label??``,status:t.step.status,linkedBoardId:t.step.linkedBoardId}:null}function SJ(e,t,n){let r=fJ(t),i=nJ(t);return{kind:`box`,id:t.id,x:n.x,y:n.y,width:i,height:r.height,icon:t.icon,change:t.change,shape:t.shape,headerHeight:r.headerHeight,media:cJ(r.content,n,r.artTop,r.art),device:lJ(r.content,n,r.artTop,r.art),step:xJ(e,t),outputs:r.outputs.map((e,t)=>({id:e.id,label:e.label,port:{x:n.x+i,y:n.y+r.headerHeight+t*Mq+Mq/2}}))}}function CJ(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 wJ(e,t,n,r){let i=CJ(r,n,{width:nJ(t),height:fJ(t).height});return SJ(e,t,{x:Math.round(i.x),y:Math.round(i.y)})}function TJ(e,t){let n=[...e.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0);return{x:e.size>0?n+Eq:Q,y:t}}function EJ(e,t,n,r){let i=_J(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.get(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=u?wJ(e.planStepById,i,i.near,u):SJ(e.planStepById,i,TJ(n,t));return n.set(i.id,d),d};for(let e of i)o(e,new Set)}function DJ(e){return e.shape===`panel`&&e.step===null&&e.near===null&&e.at===null}function OJ(e,t,n,r){let i=_J(e,`box`).filter(DJ).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id));if(i.length===0)return;let a=[...r.values()].reduce((e,t)=>Math.max(e,t.x+t.width+(n.has(t.id)?146:0)),-1/0),o=r.size>0?Math.round(a+Eq):Q,s=t;for(let t of i){let i=SJ(e.planStepById,t,{x:o,y:s});r.set(t.id,i),s+=Math.max(i.height,(n.get(t.id)??0)-Gq)+Dq}}function kJ(e,t,n,r){let i=new Map,a=[];for(let t of _J(e,`box`)){let n=r.get(t.id);n&&i.set(t.id,SJ(e.planStepById,t,n))}for(let t of _J(e,`box`))t.at&&i.set(t.id,SJ(e.planStepById,t,t.at));EJ(e,t,i,a),OJ(e,t,n,i);for(let n of _J(e,`box`))i.has(n.id)||i.set(n.id,SJ(e.planStepById,n,TJ(i,t)));return{boxesById:i,warnings:a}}function AJ(e,t){let n=iG(e.contains.flatMap(e=>t.get(e)??[]));return n?{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,x:n.x-Lq,y:n.y-Lq-Rq,width:n.width+36,height:n.height+36+Rq}:null}function jJ(e,t){return _J(e,`frame`).flatMap(e=>AJ(e,t)??[])}function MJ(e){return{x:e.x,y:e.y,width:e.width,height:Rq}}function NJ(e){return e.resolvedBy?`resolved by ${e.resolvedBy}`:e.author?`from ${e.author}`:``}function PJ(e,t,n){let{height:r}=yJ(e);return{kind:`note`,id:e.id,x:t.x+t.width-Wq,y:n,width:zq,height:r,byline:NJ(e),isResolved:e.resolvedBy!==null}}function FJ(e,t){let n=new Map;return _J(e,`note`).flatMap(e=>{let r=t.get(e.on);if(!r)return[];let i=PJ(e,r,n.get(e.on)??r.y-Gq);return n.set(e.on,i.y+i.height+Hq),[i]})}function IJ(e){return{x:0,y:0,width:Q,height:e}}function LJ(e){return e?{x:Math.min(0,e.x-Q),y:Math.min(0,e.y-Q),width:e.width+80,height:e.height+80}:{x:0,y:0,width:80,height:80}}function RJ(e,t,n){return LJ(iG([...e.flatMap(e=>e.kind===`wire`?[]:[e]),...t?[t]:[],IJ(n)]))}function zJ(e,t){return`box ${e} overlaps box ${t}`}function BJ(e,t){return`box ${e} covers the title of frame ${t}`}function VJ(e,t,n){let r=[...e.values()],i=TH(r).flatMap(([e,t])=>{let n=r[e],i=r[t];return n&&i&&cG(n,i)?[zJ(n.id,i.id)]:[]}),a=new Map(_J(n,`frame`).map(e=>[e.id,new Set(e.contains)])),o=hU(r,Xq),s=t.flatMap(e=>{let t=MJ(e),n=[];return pU(o,t,i=>{let o=r[i];o&&!a.get(e.id)?.has(o.id)&&cG(o,t)&&n.push(i)}),n.sort((e,t)=>e-t).map(t=>BJ(r[t]?.id??``,e.id))});return[...i,...s]}function HJ(e,t,n){let{boxesById:r,warnings:i}=kJ(e,t.boxesTop,t.stackHeightByBoxId,t.stepBandPositions),a=jJ(e,r),o=FJ(e,r);return{boxesById:r,frames:a,notes:o,routing:Cq({wires:_J(e,`wire`),boxesById:r,softObstacles:[...o,...a.map(MJ)],loopFrames:a.filter(e=>e.isLoop),contentTop:t.contentTop,storedWireKeyOf:t=>e.elements.bodyOf(t.id)},n),collectPlacementWarnings:()=>[...i,...VJ(r,a,e)]}}function UJ(e){return e.step!==null&&e.near===null&&e.at===null}function WJ(e){let t=new Map;for(let n of e.elements.values())n.kind===`box`&&UJ(n)&&t.set(n.id,n);let n=new Map;if(t.size===0)return{positionById:n,bottom:Q,columns:[]};let r=new Map;for(let n of sH(e)){let e=t.get(n.boxId);e&&r.set(n.level,[...r.get(n.level)??[],e])}let i=Q,a=Q,o=[];for(let e of[...r.keys()].sort((e,t)=>e-t)){let t=r.get(e)??[],s=70,c=s;for(let e of t)n.set(e.id,{x:i,y:s}),s+=fJ(e).height,c=s,a=Math.max(a,s),s+=Dq;t.length>0&&o.push({x:i,bottom:c,boxCount:t.length}),i+=Math.max(...t.map(nJ))+Eq}return{positionById:n,bottom:a+Kq,columns:o}}function GJ(e){return e>Q?e-Oq:-1/0}function KJ(e,t){let n=(e?.columns??[]).flatMap(e=>{let n=t.filter(t=>t.x===e.x);return n.length>=e.boxCount?[]:[e.bottom-n.reduce((e,t)=>e+t.height+Dq,0)]});return n.length===0?0:Math.max(Q,...n)+Kq-Q}function qJ(e,t){if(t===0)return e;let n=[...e.elements.values()].map(e=>e.kind!==`box`||!e.at?e:{...e,at:{x:e.at.x,y:e.at.y+t}});return{...e,elements:Tt(n)}}var JJ={plain:null,fail:`failure path`,join:`joins`};function YJ(e,t,n){return`${e}|${t}|${n}`}function XJ(e,t,n){let r=[JJ[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var ZJ={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function QJ(e){return Kt.flatMap(t=>t===`none`||!e.has(t)?[]:[{label:ZJ[t],swatch:{kind:`change`,change:t}}])}function $J(e){return e?Dt.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}})):[]}function eY(e){return tY(e.legend,_J(e,`wire`),new Set(_J(e,`box`).map(e=>e.change)),e.planStepById.size>0)}function tY(e,t,n,r){let i=new Map(e.map(e=>[YJ(e.tone,e.dashed||e.back,e.back),e.label])),a=new Set,o=[...t].flatMap(e=>{let t=e.dashed||e.back,n=YJ(e.tone,t,e.back),r=i.get(n)??XJ(e.tone,t,e.back);return a.has(n)||r===null?[]:(a.add(n),[{key:n,label:r,swatch:{kind:`wire`,tone:e.tone,isDashed:t,isBack:e.back}}])}).sort((e,t)=>e.key.localeCompare(t.key)),s=e.filter(e=>!a.has(YJ(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[...o.map(({label:e,swatch:t})=>({label:e,swatch:t})),...s,...QJ(n),...$J(r)]}function nY(e,t){return t?.kind===`box`?{...e,...pJ(t,e.width)}:{...e,titleLines:[],wasLines:[],bodyLines:[]}}function rY(e,t){return{...e,lines:t?.kind===`note`?vJ(t):[]}}function iY(e,t){switch(e.kind){case`box`:return nY(e,t);case`note`:return rY(e,t);default:return e}}function aY(e,t){return{...e,elements:e.elements.map(e=>iY(e,t.elements.get(e.id)))}}function oY(e){return aY(sY(e,null).layout,e)}function sY(e,t){let{positionById:n,bottom:r,columns:i}=WJ(e),a=r-Q,o=gJ(qJ(e,a)),s=bJ(o),c=r,l=HJ(o,{boxesTop:c,contentTop:GJ(r),stackHeightByBoxId:s,stepBandPositions:n},t?.route??null),u={route:l.routing.memory},d=[...l.frames,...l.routing.wires,...l.boxesById.values(),...l.notes],f=cY(o.caption,RJ(d,l.routing.extent,c),eY(o),n.size>0?i:[],a),p=[...l.routing.collectWarnings(),fG(l.collectPlacementWarnings())];return{layout:{elements:d,...f,warnings:pG(p)},memory:u,warningLists:p}}function cY(e,t,n,r,i){let a=t.y+t.height,o=n.map((e,t)=>({...e,x:Q,y:a+t*Uq})),s=a+o.length*Uq+(o.length>0?12:0),c=e?{text:e,x:Q,y:s}:null,l=o.length*Uq+(c?30:0)+(o.length>0?12:0);return{legend:o,caption:c,pinnedOffsetY:i,plan:r.length>0?{titleAt:{x:Q,y:56},columns:[...r]}:null,bounds:{...t,height:t.height+l}}}function lY(e){return JSON.stringify(e)}function uY(e,t,n){let r=e.outputs.map(e=>({...e,port:{x:e.port.x+t,y:e.port.y+n}})),i=e.media?{...e.media,x:e.media.x+t,y:e.media.y+n}:null,a=e.device?{...e.device,x:e.device.x+t,y:e.device.y+n,screen:{...e.device.screen,x:e.device.screen.x+t,y:e.device.screen.y+n}}:null;return{...e,x:e.x+t,y:e.y+n,outputs:r,media:i,device:a}}function dY(e,t){let n=new Set(t),r=!0;for(;r;){r=!1;for(let t of e.elements.values()){let e=t.kind===`box`?t.near?.of:t.kind===`note`?t.on:void 0;!n.has(t.id)&&e&&n.has(e)&&(n.add(t.id),r=!0)}}return n}function fY(e,t,n){let r=dY(e,n),i=new Map,a=[],o=[],s=[];for(let e of t.elements)e.kind===`box`&&i.set(e.id,e),e.kind===`note`&&r.has(e.id)&&o.push(e),e.kind===`note`&&!r.has(e.id)&&a.push(e),e.kind===`frame`&&a.push(MJ(e)),e.kind===`frame`&&e.isLoop&&s.push(e);let c=[...r].flatMap(e=>i.get(e)??[]),l=[...e.elements.values()].flatMap(e=>e.kind===`wire`&&(r.has(e.from)||r.has(e.to))?[e]:[]),u=GJ(t.pinnedOffsetY+Q);return(e,t)=>{let n=c.map(n=>uY(n,e,t));for(let e of n)i.set(e.id,e);let r=o.map(n=>({...n,x:n.x+e,y:n.y+t}));return[...n,...r,...Sq({wires:l,boxesById:i,softObstacles:[...a,...r],loopFrames:s,contentTop:u})]}}var pY=2048,mY=.3,hY=.12,gY=.5,_Y=6,vY=256,yY=30,bY=12,xY=28;function SY(e){return e>=mY?`full`:e>=hY?`titles`:`blocks`}function CY(e){return`${e.lod}:${e.level}:${e.chunkX}:${e.chunkY}`}function wY(e){return pY*2**e.level}function TY(e){let t=wY(e);return{x:e.chunkX*t,y:e.chunkY*t,width:t,height:t}}function EY(e,t){let n=wY({level:t});return{firstX:Math.floor(e.x/n),lastX:Math.floor((e.x+e.width)/n),firstY:Math.floor(e.y/n),lastY:Math.floor((e.y+e.height)/n)}}function DY(e){return(e.lastX-e.firstX+1)*(e.lastY-e.firstY+1)}function OY(e,t){if(t!==`blocks`)return 0;let n=Math.max(e.width,e.height),r=0;for(;pY*2**r*_Y<n&&r<yY;)r+=1;return r}function kY(e,t){let n={x:e.x-e.width*gY,y:e.y-e.height*gY,width:e.width*2,height:e.height*2},r=OY(e,t);for(;DY(EY(n,r))>vY&&r<yY;)r+=1;let i=EY(n,r);if(DY(i)>vY)return[];let a=[];for(let e=i.firstY;e<=i.lastY;e+=1)for(let n=i.firstX;n<=i.lastX;n+=1)a.push({chunkX:n,chunkY:e,lod:t,level:r});return a}function AY(e,t){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let t of e)n=Math.min(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.x),a=Math.max(a,t.y);return n>i?{x:0,y:0,width:0,height:0}:{x:n-t,y:r-t,width:i-n+t*2,height:a-r+t*2}}function jY(e){if(e.kind===`wire`){let t=[...wq(e.path),e.start,e.end];if(e.label){let n=LK(e.label)/2+bY;t.push({x:e.labelAt.x-n,y:e.labelAt.y-24},{x:e.labelAt.x+n,y:e.labelAt.y+bY})}return AY(t,bY)}return e.kind===`frame`?{...MY(e),width:Math.max(e.width,xY+LK(e.title))}:MY(e)}function MY(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}var NY=100,PY=[],$=null,FY=null;function IY(){for(let e of PY)e()}function LY(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 RY(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function zY(e){FY!==null&&clearTimeout(FY),FY=null,e.sentTileIds=new Set(kY(e.view,e.lod).map(CY)),KY(e,t=>t.key.lod===e.lod&&!LY(t.rect,e.view))&&IY(),s({type:`whiteboard-view`,boardId:e.boardId,view:e.view,lod:e.lod,knownVersion:e.version})}function BY(e){FY===null&&(FY=setTimeout(()=>{FY=null,$===e&&zY(e)},NY))}function VY(e,t){for(let n of e.tiles.values())n.elementIds.delete(t)}function HY(e){let t=new Set;for(let n of e.tiles.values())for(let e of n.elementIds)t.add(e);for(let n of[...e.elementById.keys()])t.has(n)||e.elementById.delete(n)}function UY(e){return kY(e.view,e.lod).every(t=>e.tiles.has(CY(t))||e.sentTileIds.has(CY(t)))}function WY(e,t,n){return{boardId:e,version:null,head:null,elementCount:0,chrome:null,lod:n,view:t,sentTileIds:new Set,tiles:new Map,elementById:new Map,assembled:null}}function GY(e,t,n){let r=SY(n),i=$?.boardId!==e,a=i||!$?WY(e,t,r):$,o=a.lod!==r;$=a,a.view=t,a.lod=r,i||o||a.version===null||!UY(a)?zY(a):BY(a)}function KY(e,t){let n=!1;for(let[r,i]of[...e.tiles])!e.sentTileIds.has(r)&&t(i)&&(e.tiles.delete(r),n=!0);return n?(HY(e),e.assembled=null,!0):!1}function qY(e,t){let n=new Set;for(let r of t.elements)e.elementById.set(r.element.id,r),n.add(r.element.id);e.tiles.set(CY(t.key),{key:t.key,rect:TY(t.key),elementIds:n,raster:t.raster?RY(t.raster):null})}function JY(e){let t=$;if(t&&t.boardId===e.boardId&&(e.chrome&&(t.tiles.clear(),t.elementById.clear(),t.chrome=e.chrome),t.chrome)){t.head=e.head,t.elementCount=e.elementCount,t.version=e.version;for(let n of e.tiles)qY(t,n);KY(t,()=>!0),t.assembled=null,IY()}}function YY(e,t){VY(e,t.element.id);let n=jY(t.element),r=!1;for(let i of e.tiles.values())i.key.lod!==`blocks`&&LY(i.rect,n)&&(i.elementIds.add(t.element.id),r=!0);r?e.elementById.set(t.element.id,t):e.elementById.delete(t.element.id)}function XY(e){let t=$;if(t&&t.boardId===e.boardId){if(t.version!==e.fromVersion)t.version=null,zY(t);else{for(let n of e.diff.removedIds)VY(t,n),t.elementById.delete(n);for(let n of e.diff.changed)YY(t,n);for(let n of e.diff.rasters){let e=t.tiles.get(CY(n.key));e&&(e.raster=n.raster?RY(n.raster):null)}e.diff.chrome&&(t.chrome=e.diff.chrome),t.head=e.head,t.elementCount=e.elementCount,t.version=e.toVersion,t.assembled=null,IY()}}}function ZY(e){let t=$;if(!t||t.boardId!==e||t.version===null||!t.chrome||!t.head)return null;if(t.assembled)return t.assembled;let n=[...t.elementById.values()].sort((e,t)=>e.paintOrder-t.paintOrder),r=Tt(n.flatMap(({record:e})=>e??[])),i=[...t.tiles].flatMap(([e,t])=>t.raster?[{id:e,rect:t.rect,raster:t.raster}]:[]),a={...t.chrome,elements:n.map(({element:e})=>e),warnings:[]};return t.assembled={version:t.version,lod:t.lod,layout:a,blocks:i,board:{...t.head,elements:r},elementCount:t.elementCount},t.assembled}function QY(e){if(!$||$.version===null)return;let t=e.get($.boardId);t===void 0?eX($.boardId):t!==$.version&&($.version=null,zY($))}function $Y(){$&&($.version=null,zY($))}function eX(e){$?.boardId===e&&(FY!==null&&clearTimeout(FY),FY=null,$=null,IY())}function tX(e){PY.push(e)}var nX={"whiteboards-snapshot":e=>{nO(e),QY(new Map(e.boards.map(e=>[e.id,e.version])))},"whiteboard-removed":e=>{eX(e.boardId),rO(e)},"whiteboard-tiles":e=>JY(e),"whiteboard-tile-diff":e=>XY(e)},rX=`Worktree`,iX=`Worktree warning`,aX=ZB([MV,NV,{"session-worktree-blocked":e=>{sr({source:rX,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=>{sr({source:iX,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=>{or(rX,e.id),EC(e.id,e.base)},"session-diff":e=>{zy(e.id,e)},"session-diff-error":e=>{By(e.id,e.message)},"change-map":e=>Vy(e.id,e.map),"session-changed":e=>Hy(e.id)},sV,nX,cV,lV]),oX=new Set([...Object.keys(NV),...Object.keys(sV)]);function sX(e){let t=aX[e.type];t&&t(e)}function cX(){i(e=>{sX(e),BL(e.type)}),kV((e,t)=>{if(t.type===`snapshot`){BB(t.sessions,e);return}let n=t.type===`error`&&typeof t.id==`string`;(oX.has(t.type)||n)&&(sX(t),BL(t.type))})}function lX(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 uX(){BO({panels:lX(K),onScreenShown:e=>{zL(e),e!==`settings`&&OL(),e===`settings`&&!eF(location.hash)&&RP(),FL(e)},canGoBack:e=>e===`settings`&&UP()||e===`prs`&&l_(),onBack:e=>{e===`settings`&&WP(),e===`prs`&&u_()},headerControls:[T(document,`.header-title`,`h1`),T(document,`#status-indicator`,`div`),T(document,`#celebration-tray`,`div`),HR,UR,GR]}),HP(YO),c_(YO)}function dX(e){if(e===`phone`){let e=W();for(let e of K)aL(e.view)?.deactivate?.();let t=eF(location.hash);VO({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}).then(e=>{e&&t&&RP(null,null,location.hash),!e&&Ko()&&!UO()&&iR()});return}let t=WO();HO(),iR(),t&&QN(t)}function fX(){uX(),Ko()&&dX(`phone`),qo(dX)}function pX(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function mX(e){QN(e),Ui(e),requestAnimationFrame(()=>requestAnimationFrame(()=>k.get(e)?.term?.focus()))}function hX(){let e=pX()??Li();e?Gi(e):document.getElementById(`btn-add-session-header`)?.click()}function gX({action:e,step:t}){switch(e){case`merge`:{let e=Li();return!e||IM()?!1:(Jy(e),!0)}case`close-session`:{let e=Li();return e?(Ii(e),!0):!1}case`board-split`:return FM()&&XM();case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return hX(),!0;case`next-attention`:return Ko()?!1:FM()?(jN(),!0):(rr()===`prs`&&d_()||rP(()=>q(`focus`)),!0);case`rail-step`:return FM()?(tP(t),!0):!1;case`view-step`:return!Ko()&&(JL(qL(rr(),t)),!0);case`session-nth`:return FM()?(eP(t),!0):!1;case`streamer-mode`:return rl(),!0}}function _X(e){return e.code!==`KeyZ`||e.altKey||e.shiftKey?!1:Au===`mac`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function vX(){Mi(mX),document.addEventListener(`keydown`,e=>{if(e.repeat||It(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1;if(!t&&_X(e)&&!Zt()&&Ai()){e.preventDefault(),e.stopImmediatePropagation();return}let n=Hr(e,Au,{isTerminalFocused:t},Nu());n&&(Zt()||gX(n)&&e.preventDefault())})}function yX(){let e=u(s);window.addEventListener(`error`,t=>{e(t.error),y(`uncaught`,l(t.error??t.message))}),window.addEventListener(`unhandledrejection`,t=>{e(t.reason),y(`unhandled-rejection`,l(t.reason))}),lL(()=>window.sessionStorage)}qa(Lr()),Ya(()=>{N(()=>import(`./alert-sound-At4lBeip.js`).then(e=>e.playNyanJingle(),e=>y(`alert-sound`,`nyan jingle failed to load: ${l(e)}`)),__vite__mapDeps([10,6]))}),ep(zr()),Go(),id(document),xB(),PB(),FD(s),N(()=>import(`./your-day-tip-DbK_G8QL.js`).then(e=>e.startYourDayTips({openUsage:()=>EL(`usage`)}),e=>y(`your-day-tip`,`your day tips failed to load: ${l(e)}`)),__vite__mapDeps([65,13,4,3,63,61,5,6,7,8,14,64,19])),nv(s),QS(s),Np(s),sa(s),rn(C_),Mn(Ta),Mn(b_,`links`),Mn(wO,`links`),pn(EO),yO(DL),Fn({isReadable:Ea,open:Oa}),an(WC),$c(()=>BL(`settings-updated`)),cX(),_z(),JR(),fR(),YR(),aR(),fX(),vX(),nk(),yX(),G_(T(document,`#health-footer-mount`,`div`)),Eu(SC),_B(),Gf(),p();var bX=ii();bX&&x().then(()=>ou(bX));export{KP as $,Iu as $a,Eh as $i,GT as $n,JS as $r,QD as $t,jI as A,Up as Aa,Qg as Ai,pE as An,dE as Ar,FA as At,vF as B,xp as Ba,bh as Bi,Cw as Bn,sw as Br,Mk as Bt,gR as C,vm as Ca,rv as Ci,Hw as Cn,Pw as Cr,aj as Ct,wL as D,im as Da,qg as Di,_w as Dn,BE as Dr,lA as Dt,SL as E,bm as Ea,Zg as Ei,BT as En,lE as Er,PA as Et,zF as F,kp as Fa,f_ as Fi,HE as Fn,$E as Fr,Uk as Ft,aF as G,jf as Ga,gg as Gi,TT as Gn,YC as Gr,Ek as Gt,_F as H,Tp as Ha,Ch as Hi,Xw as Hn,rw as Hr,Tk as Ht,WF as I,yp as Ia,Xg as Ii,RT as In,eD as Ir,Vk as It,$P as J,Gu as Ja,cg as Ji,YT as Jn,zC as Jr,fk as Jt,rF as K,Vd as Ka,eg as Ki,UE as Kn,qC as Kr,yk as Kt,GF as L,jp as La,o_ as Li,fE as Ln,cE as Lr,Lk as Lt,YF as M,wp as Ma,a_ as Mi,oT as Mn,tD as Mr,DA as Mt,VF as N,Cp as Na,t_ as Ni,aT as Nn,zE as Nr,wA as Nt,JI as O,am as Oa,n_ as Oi,vw as On,Ow as Or,dA as Ot,BF as P,Dp as Pa,s_ as Pi,iT as Pn,KT as Pr,Hk as Pt,VP as Q,Lu as Qa,vg as Qi,tT as Qn,XS as Qr,AO as Qt,KF as R,Mp as Ra,Eg as Ri,Mw as Rn,Rw as Rr,Fk as Rt,Hz as S,Hm as Sa,ev as Si,Tw as Sn,aD as Sr,$A as St,xL as T,ym as Ta,I as Ti,VT as Tn,TE as Tr,fA as Tt,gF as U,bp as Ua,mg as Ui,Kw as Un,nw as Ur,Dk as Ut,hF as V,Sp as Va,Vh as Vi,VE as Vn,ow as Vr,Sk as Vt,iF as W,ep as Wa,rg as Wi,ET as Wn,hw as Wr,Ok as Wt,GP as X,Au as Xa,ng as Xi,Uw as Xn,ZS as Xr,kO as Xt,tF as Y,Bu as Ya,dg as Yi,qT as Yn,oC as Yr,ok as Yt,kP as Z,Pu as Za,Bh as Zi,Ww as Zn,YS as Zr,DO as Zt,QV as _,Cm as _a,bb as _i,UD as _n,$a as _o,HT as _r,tj as _t,fY as a,Th as aa,Tx as ai,uO as an,Zc as ao,Qw as ar,LP as at,SV as b,Nm as ba,wv as bi,CT as bn,aa as bo,LE as br,ej as bt,DJ as c,Ph as ca,ux as ci,oO as cn,Xs as co,PE as cr,DP as ct,KJ as d,ch as da,xx as di,jD as dn,is as do,QE as dr,cP as dt,hg as ea,qS as ei,iO as en,Fu as eo,ZT as er,MP as et,wq as f,Bm as fa,mx as fi,LD as fn,Ko as fo,WE as fr,uP as ft,YV as g,Mm as ga,kb as gi,OD as gn,qa as go,XE as gr,sj as gt,ZV as h,Lm as ha,jb as hi,kD as hn,Xa as ho,_T as hr,rj as ht,ZY as i,Ih as ia,Mx as ii,pO as in,wl as io,nE as ir,BP as it,MI as j,Op as ja,u_ as ji,zw as jn,uE as jr,uA as jt,qI as k,Hp as ka,r_ as ki,rE as kn,kw as kr,pA as kt,oY as l,uh as la,cx as li,PD as ln,Hs as lo,wE as lr,zP as lt,hU as m,zm as ma,Nb as mi,AD as mn,eo as mo,yT as mr,ij as mt,$Y as n,yg as na,KS as ni,eO as nn,Tl as no,oD as nr,FP as nt,lY as o,tg as oa,Dx as oi,aO as on,$c as oo,Zw as or,OP as ot,pU as p,jm as pa,Fb as pi,ID as pn,qo as po,ZE as pr,Vj as pt,nF as q,nd as qa,Hh as qi,bT as qn,KC as qr,pk as qt,GY as r,bg as ra,yS as ri,$D as rn,El as ro,KE as rr,WP as rt,UJ as s,ug as sa,hx as si,_O as sn,el as so,FE as sr,AP as st,tX as t,wh as ta,GS as ti,sO as tn,Nu as to,PT as tr,NP as tt,uY as u,lh as ua,px as ui,RD as un,Os as uo,Aw as ur,lP as ut,XV as v,Pm as va,xb as vi,oE as vn,oa as vo,WT as vr,QA as vt,_R as w,xm as wa,tv as wi,sT as wn,nD as wr,Yk as wt,oV as x,_m as xa,jv as xi,Vw as xn,iD as xr,XA as xt,OV as y,Sm as ya,Mv as yi,IE as yn,ca as yo,GE as yr,nj as yt,RF as z,Ap as za,Dg as zi,Dw as zn,ZC as zr,Nk as zt};
|