glimmervoid 0.53.2-next.968 → 0.53.2-next.969

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/bin/binary-main.js +1 -1
  2. package/dist/bin/glimmervoid.js +39 -20
  3. package/dist/chunks/{adapters-Bvg4IsdW.js → adapters-BpRMaOqW.js} +42 -43
  4. package/dist/chunks/{adapters-BKAruwl6.js → adapters-D3Vpgj4x.js} +1 -1
  5. package/dist/chunks/{agent-api-cli-BxM3JxWj.js → agent-api-cli-CXVV57k-.js} +1 -1
  6. package/dist/chunks/agent-api-cli-Q4K2h2B1.js +1 -0
  7. package/dist/chunks/{agent-api-core-BGpJNhH5.js → agent-api-core-rEEiI8Pd.js} +2 -2
  8. package/dist/chunks/{agent-setup-cli-CZ82pLNW.js → agent-setup-cli-T5QkEnun.js} +1 -1
  9. package/dist/chunks/{board-store-client-DNlvZvGx.js → board-store-client-DZPYuiZo.js} +1 -1
  10. package/dist/chunks/{config-CHKlCDpY.js → config-K4Ajx_x7.js} +1 -2
  11. package/dist/chunks/{config-store-CQpMnLFi.js → config-store-CAzc6z1i.js} +50 -67
  12. package/dist/chunks/config-store-xEFhZ57s.js +1 -0
  13. package/dist/chunks/{control-messages-DkKr9vbw.js → control-messages-B6l3aVFK.js} +5 -4
  14. package/dist/chunks/{grok-BTD32YhV.js → grok-myTC9O74.js} +1 -1
  15. package/dist/chunks/{host-cli-CtHOXwr5.js → host-cli-BFLDVJ4m.js} +3 -3
  16. package/dist/chunks/{host-registry-core-BZJqNz7o.js → host-registry-core-BgHHO4VK.js} +1 -1
  17. package/dist/chunks/{kimi-bJFSfqLq.js → kimi-DJ6HUYC6.js} +1 -1
  18. package/dist/chunks/kimi-DftdHIcL.js +1 -0
  19. package/dist/chunks/{main-COJdeh96.js → main-u7J8_QOC.js} +136 -318
  20. package/dist/chunks/{native-probes-Dhs6LeOq.js → native-probes-SNVdVUU7.js} +2 -2
  21. package/dist/chunks/{pack-agent-D-Uh314s.js → pack-agent-c_74clVP.js} +1 -1
  22. package/dist/chunks/{packs-cli-Cf5nsDBr.js → packs-cli-BDOP5FaV.js} +3 -3
  23. package/dist/chunks/{pair-cli-CXd8czCK.js → pair-cli-Dqy4a3Pi.js} +2 -2
  24. package/dist/chunks/{path-doctor-CHyvHUpg.js → path-doctor-R9RhGNdk.js} +37 -1
  25. package/dist/chunks/{pr-flows-cli-H-G7ndCk.js → pr-flows-cli-D_B5T3Wp.js} +2 -2
  26. package/dist/chunks/{remote-config-CX87T8kk.js → remote-config-Ch63m7CJ.js} +1 -1
  27. package/dist/chunks/{runtime-paths-DrDchzfV.js → runtime-paths-BhtVY5Kw.js} +1 -1
  28. package/dist/chunks/{runtime-paths-DCVulpER.js → runtime-paths-Cef9baZq.js} +1 -1
  29. package/dist/chunks/settings-cli-C3Et1vDZ.js +1 -0
  30. package/dist/chunks/{settings-cli-D5FDGWpl.js → settings-cli-Csw0REjR.js} +4 -4
  31. package/dist/chunks/{settings-readout-core-CawQ72Tn.js → settings-readout-core-DAFEnqa5.js} +2 -2
  32. package/dist/chunks/{ssh-sign-cli-pSVnAjqf.js → ssh-sign-cli-CJpFuHst.js} +1 -1
  33. package/dist/client/assets/{action-status-rETkOMJb.js → action-status-CYnvXmb6.js} +1 -1
  34. package/dist/client/assets/action-status-CYnvXmb6.js.br +0 -0
  35. package/dist/client/assets/{agent-core-BmzljZal.js → agent-core-5pahO20g.js} +2 -2
  36. package/dist/client/assets/agent-core-5pahO20g.js.br +0 -0
  37. package/dist/client/assets/{agent-mark-vCo0zsWP.js → agent-mark-BQ6GWoMr.js} +1 -1
  38. package/dist/client/assets/agent-mark-BQ6GWoMr.js.br +0 -0
  39. package/dist/client/assets/{arena-panel-azL51Ses.js → arena-panel-ESQaDRzw.js} +2 -2
  40. package/dist/client/assets/arena-panel-ESQaDRzw.js.br +0 -0
  41. package/dist/client/assets/{benchmark-panel-8mimXsjK.js → benchmark-panel-C-5-_mw9.js} +1 -1
  42. package/dist/client/assets/benchmark-panel-C-5-_mw9.js.br +0 -0
  43. package/dist/client/assets/{boards-view-DIh7lkLS.js → boards-view-C2KW_DGj.js} +1 -1
  44. package/dist/client/assets/boards-view-C2KW_DGj.js.br +0 -0
  45. package/dist/client/assets/button-CMQWs0VA.js +1 -0
  46. package/dist/client/assets/button-CMQWs0VA.js.br +0 -0
  47. package/dist/client/assets/{card-actions-tzD2Tm0H.js → card-actions-CELKX1cn.js} +1 -1
  48. package/dist/client/assets/{community-panel-oPNEjWVB.js → community-panel-C0yACNBn.js} +1 -1
  49. package/dist/client/assets/community-panel-C0yACNBn.js.br +0 -0
  50. package/dist/client/assets/{control-ws-DEfwcMni.js → control-ws-7yhbi9n0.js} +1 -1
  51. package/dist/client/assets/control-ws-7yhbi9n0.js.br +0 -0
  52. package/dist/client/assets/{dialogs-BJQhXF-i.js → dialogs-D7hBCR1a.js} +1 -1
  53. package/dist/client/assets/dialogs-D7hBCR1a.js.br +0 -0
  54. package/dist/client/assets/{doc-editor-ui-qzAOMLgj.js → doc-editor-ui-DsshrSMT.js} +1 -1
  55. package/dist/client/assets/doc-editor-ui-DsshrSMT.js.br +0 -0
  56. package/dist/client/assets/{feature-hint-DYaAH_FS.js → feature-hint-DeKRVPni.js} +1 -1
  57. package/dist/client/assets/feature-hint-DeKRVPni.js.br +0 -0
  58. package/dist/client/assets/{first-run-checklist-B-J9-hZq.js → first-run-checklist-BlWuVccS.js} +1 -1
  59. package/dist/client/assets/first-run-checklist-BlWuVccS.js.br +0 -0
  60. package/dist/client/assets/{hooks-panel-leiYaWxz.js → hooks-panel-BHe0NfgP.js} +1 -1
  61. package/dist/client/assets/hooks-panel-BHe0NfgP.js.br +0 -0
  62. package/dist/client/assets/{index-CCAFwpgb.js → index-C5JAyqA-.js} +6 -6
  63. package/dist/client/assets/index-C5JAyqA-.js.br +0 -0
  64. package/dist/client/assets/{issues-panel-I6N9hEcg.js → issues-panel-Dgy6w2wP.js} +1 -1
  65. package/dist/client/assets/issues-panel-Dgy6w2wP.js.br +0 -0
  66. package/dist/client/assets/{lane-read-token-step-nbabpx3_.js → lane-read-token-step-smGOCQpS.js} +1 -1
  67. package/dist/client/assets/lane-read-token-step-smGOCQpS.js.br +0 -0
  68. package/dist/client/assets/{menu-DzZGGGGN.js → menu-D8rPo2sW.js} +1 -1
  69. package/dist/client/assets/menu-D8rPo2sW.js.br +0 -0
  70. package/dist/client/assets/{modal-CjIIQMho.js → modal-CrCrVLFZ.js} +1 -1
  71. package/dist/client/assets/modal-CrCrVLFZ.js.br +0 -0
  72. package/dist/client/assets/{my-prs-panel-8vwDuQYH.js → my-prs-panel-CrDSZpdN.js} +1 -1
  73. package/dist/client/assets/my-prs-panel-CrDSZpdN.js.br +0 -0
  74. package/dist/client/assets/{nyan-cat-CyLs6Ah3.js → nyan-cat-Y4DKSNpt.js} +1 -1
  75. package/dist/client/assets/nyan-cat-Y4DKSNpt.js.br +0 -0
  76. package/dist/client/assets/{phone-shell-6J_LT8oK.js → phone-shell-BfUzchP7.js} +1 -1
  77. package/dist/client/assets/phone-shell-BfUzchP7.js.br +0 -0
  78. package/dist/client/assets/{plan-face-VwtdBhdq.js → plan-face-p_Q4xZ-H.js} +2 -2
  79. package/dist/client/assets/plan-face-p_Q4xZ-H.js.br +0 -0
  80. package/dist/client/assets/{plan-render-BeX_KU2k.js → plan-render-Bi_AbHKi.js} +1 -1
  81. package/dist/client/assets/plan-render-Bi_AbHKi.js.br +0 -0
  82. package/dist/client/assets/{pr-queue-columns-BwjW6ZSu.js → pr-queue-columns-BM9haK7M.js} +1 -1
  83. package/dist/client/assets/pr-queue-columns-BM9haK7M.js.br +0 -0
  84. package/dist/client/assets/{pr-status-icon-dpJOgyIo.js → pr-status-icon-wvSUvmPS.js} +1 -1
  85. package/dist/client/assets/pr-status-icon-wvSUvmPS.js.br +0 -0
  86. package/dist/client/assets/{radar-panel-U8kArKZ3.js → radar-panel-CutSh8oR.js} +1 -1
  87. package/dist/client/assets/radar-panel-CutSh8oR.js.br +0 -0
  88. package/dist/client/assets/{repo-roots-adder-C57e0__D.js → repo-roots-adder-CRwLG3jd.js} +1 -1
  89. package/dist/client/assets/repo-roots-adder-CRwLG3jd.js.br +0 -0
  90. package/dist/client/assets/{resume-dialog-DRD_GKrw.js → resume-dialog-Ct0dtFpq.js} +1 -1
  91. package/dist/client/assets/resume-dialog-Ct0dtFpq.js.br +0 -0
  92. package/dist/client/assets/{review-queue-panel-DAk2WHrm.js → review-queue-panel-CyUV0h31.js} +1 -1
  93. package/dist/client/assets/review-queue-panel-CyUV0h31.js.br +0 -0
  94. package/dist/client/assets/{session-row-U1g9MCRj.js → session-row-B54nJze6.js} +1 -1
  95. package/dist/client/assets/session-row-B54nJze6.js.br +0 -0
  96. package/dist/client/assets/{session-tick-DxsZqUxX.js → session-tick-BCeOQ9qf.js} +1 -1
  97. package/dist/client/assets/session-tick-BCeOQ9qf.js.br +0 -0
  98. package/dist/client/assets/settings-panel-mMlTwl2_.js +4 -0
  99. package/dist/client/assets/settings-panel-mMlTwl2_.js.br +0 -0
  100. package/dist/client/assets/{setup-step-B9ALtknc.js → setup-step-CR1WGQhX.js} +1 -1
  101. package/dist/client/assets/setup-step-CR1WGQhX.js.br +0 -0
  102. package/dist/client/assets/{trace-panel-CHusMzMn.js → trace-panel-CxF4QOxU.js} +1 -1
  103. package/dist/client/assets/trace-panel-CxF4QOxU.js.br +0 -0
  104. package/dist/client/assets/{usage-panel-CuIScVal.js → usage-panel-CrAJMOkk.js} +1 -1
  105. package/dist/client/assets/usage-panel-CrAJMOkk.js.br +0 -0
  106. package/dist/client/assets/{whiteboard-undo-core-DFpJR7c5.js → whiteboard-undo-core-D1P82mGD.js} +1 -1
  107. package/dist/client/assets/whiteboard-undo-core-D1P82mGD.js.br +0 -0
  108. package/dist/client/assets/{your-day-tip-_pFQLziL.js → your-day-tip-Cjr_jrYW.js} +1 -1
  109. package/dist/client/assets/your-day-tip-Cjr_jrYW.js.br +0 -0
  110. package/dist/client/index.html +12 -12
  111. package/dist/client/index.html.br +0 -0
  112. package/dist/scripts/postinstall-path-check.js +1 -1
  113. package/dist/server/index.js +2 -2
  114. package/dist/server/whiteboard/layout-worker.js +1 -1
  115. package/dist/session/hook-tool-relay.js +1 -1
  116. package/package.json +1 -1
  117. package/dist/chunks/agent-api-cli-ly6UBwlj.js +0 -1
  118. package/dist/chunks/config-store-BCB2IgBC.js +0 -1
  119. package/dist/chunks/kimi-BsXxRPQ_.js +0 -1
  120. package/dist/chunks/settings-cli-O5kaFTNh.js +0 -1
  121. package/dist/client/assets/action-status-rETkOMJb.js.br +0 -0
  122. package/dist/client/assets/agent-core-BmzljZal.js.br +0 -0
  123. package/dist/client/assets/agent-mark-vCo0zsWP.js.br +0 -0
  124. package/dist/client/assets/arena-panel-azL51Ses.js.br +0 -0
  125. package/dist/client/assets/benchmark-panel-8mimXsjK.js.br +0 -0
  126. package/dist/client/assets/boards-view-DIh7lkLS.js.br +0 -0
  127. package/dist/client/assets/button-CfhUK7Jn.js +0 -1
  128. package/dist/client/assets/button-CfhUK7Jn.js.br +0 -0
  129. package/dist/client/assets/community-panel-oPNEjWVB.js.br +0 -0
  130. package/dist/client/assets/control-ws-DEfwcMni.js.br +0 -0
  131. package/dist/client/assets/dialogs-BJQhXF-i.js.br +0 -0
  132. package/dist/client/assets/doc-editor-ui-qzAOMLgj.js.br +0 -0
  133. package/dist/client/assets/feature-hint-DYaAH_FS.js.br +0 -0
  134. package/dist/client/assets/first-run-checklist-B-J9-hZq.js.br +0 -0
  135. package/dist/client/assets/hooks-panel-leiYaWxz.js.br +0 -0
  136. package/dist/client/assets/index-CCAFwpgb.js.br +0 -0
  137. package/dist/client/assets/issues-panel-I6N9hEcg.js.br +0 -0
  138. package/dist/client/assets/lane-read-token-step-nbabpx3_.js.br +0 -0
  139. package/dist/client/assets/menu-DzZGGGGN.js.br +0 -0
  140. package/dist/client/assets/modal-CjIIQMho.js.br +0 -0
  141. package/dist/client/assets/my-prs-panel-8vwDuQYH.js.br +0 -0
  142. package/dist/client/assets/nyan-cat-CyLs6Ah3.js.br +0 -0
  143. package/dist/client/assets/phone-shell-6J_LT8oK.js.br +0 -0
  144. package/dist/client/assets/plan-face-VwtdBhdq.js.br +0 -0
  145. package/dist/client/assets/plan-render-BeX_KU2k.js.br +0 -0
  146. package/dist/client/assets/pr-queue-columns-BwjW6ZSu.js.br +0 -0
  147. package/dist/client/assets/pr-status-icon-dpJOgyIo.js.br +0 -0
  148. package/dist/client/assets/radar-panel-U8kArKZ3.js.br +0 -0
  149. package/dist/client/assets/repo-roots-adder-C57e0__D.js.br +0 -0
  150. package/dist/client/assets/resume-dialog-DRD_GKrw.js.br +0 -0
  151. package/dist/client/assets/review-queue-panel-DAk2WHrm.js.br +0 -0
  152. package/dist/client/assets/session-row-U1g9MCRj.js.br +0 -0
  153. package/dist/client/assets/session-tick-DxsZqUxX.js.br +0 -0
  154. package/dist/client/assets/settings-panel-CMQPJBaI.js +0 -4
  155. package/dist/client/assets/settings-panel-CMQPJBaI.js.br +0 -0
  156. package/dist/client/assets/setup-step-B9ALtknc.js.br +0 -0
  157. package/dist/client/assets/trace-panel-CHusMzMn.js.br +0 -0
  158. package/dist/client/assets/usage-panel-CuIScVal.js.br +0 -0
  159. package/dist/client/assets/whiteboard-undo-core-DFpJR7c5.js.br +0 -0
  160. package/dist/client/assets/your-day-tip-_pFQLziL.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-CyLs6Ah3.js","assets/dom-helpers-1xKy7VX6.js","assets/zod-CeKr261e.js","assets/ui-prefs-D3kfa1nO.js","assets/alert-sound-core-CmJhj4qI.js","assets/local-store-CVQ5ByvB.js","assets/nyan-geometry-core-C8RryYMH.js","assets/celebration-player-k9KDERaX.js","assets/alert-sound-At4lBeip.js","assets/doc-editor-ui-qzAOMLgj.js","assets/action-status-rETkOMJb.js","assets/button-CfhUK7Jn.js","assets/control-ws-DEfwcMni.js","assets/modal-CjIIQMho.js","assets/plan-render-BeX_KU2k.js","assets/whiteboard-undo-core-DFpJR7c5.js","assets/doc-editor-ui-D7opSzf1.css","assets/resume-dialog-DRD_GKrw.js","assets/card-actions-tzD2Tm0H.js","assets/card-registry-BM0Py2ky.js","assets/plan-face-VwtdBhdq.js","assets/roving-keys-core-BDobx2It.js","assets/ui-state-core-Nssh-6QJ.js","assets/plan-face-CNqLL3OW.css","assets/phone-shell-6J_LT8oK.js","assets/agent-core-BmzljZal.js","assets/preload-helper-BLdHbfdN.js","assets/session-tick-DxsZqUxX.js","assets/session-row-U1g9MCRj.js","assets/menu-DzZGGGGN.js","assets/agent-mark-vCo0zsWP.js","assets/pr-status-icon-dpJOgyIo.js","assets/first-run-checklist-B-J9-hZq.js","assets/repo-roots-adder-C57e0__D.js","assets/setup-step-B9ALtknc.js","assets/boards-view-DIh7lkLS.js","assets/boards-view-CfBtlabY.css","assets/review-queue-panel-DAk2WHrm.js","assets/lane-read-token-step-nbabpx3_.js","assets/lane-read-token-step-uxHqFrcY.css","assets/my-prs-panel-8vwDuQYH.js","assets/pr-queue-columns-BwjW6ZSu.js","assets/team-review-settings-core-BtFK1LdQ.js","assets/issues-panel-I6N9hEcg.js","assets/issues-panel-1vb6hHuv.css","assets/usage-panel-CuIScVal.js","assets/chart-readout-DxD0pyUY.js","assets/usage-panel-DV0ckKqY.css","assets/radar-panel-U8kArKZ3.js","assets/dialogs-BJQhXF-i.js","assets/radar-panel-LHOTTm1M.css","assets/community-panel-oPNEjWVB.js","assets/community-panel-DR_-RgSK.css","assets/hooks-panel-leiYaWxz.js","assets/hooks-panel-BUBv4dvX.css","assets/trace-panel-CHusMzMn.js","assets/trace-panel-D-AIzBSZ.css","assets/arena-panel-azL51Ses.js","assets/arena-panel-CCEwG0WI.css","assets/settings-panel-CMQPJBaI.js","assets/flying-animal-preview-C9Ds134f.js","assets/settings-panel-vHjG4OTM.css","assets/feature-hint-DYaAH_FS.js","assets/feature-hint-Dm-eD9Sz.css","assets/your-day-tip-_pFQLziL.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 ee,w as te,x as ne,y as b}from"./control-ws-DEfwcMni.js";import{f as re,l as ie,n as ae,p as oe,s as se,v as ce}from"./zod-CeKr261e.js";import{A as le,At as ue,Bt as de,C as fe,Ct as pe,D as me,Dt as he,E as ge,Et as _e,Ft as ve,G as ye,It as be,J as xe,K as Se,Lt as Ce,M as x,Mt as we,Nt as Te,O as Ee,Ot as S,Pt as De,Qt as Oe,R as ke,Rt as Ae,S as je,T as Me,Tt as Ne,U as Pe,V as Fe,Vt as Ie,Xt as Le,Z as Re,Zt as ze,_ as Be,a as Ve,b as He,c as Ue,cn as We,f as Ge,g as Ke,gn as qe,h as Je,hn as Ye,i as Xe,in as Ze,j as Qe,kt as $e,l as et,nn as tt,on as nt,p as rt,q as it,rn as at,s as ot,sn as st,st as ct,t as C,tn as lt,u as ut,ut as dt,vt as ft,wt as pt,x as mt,xt as ht,y as gt,yt as _t}from"./button-CfhUK7Jn.js";import{$ as vt,$t as yt,Bn as bt,Ct as xt,Gn as St,Jn as Ct,Lt as wt,Ot as Tt,Pn as Et,S as Dt,Vn as Ot,Vt as kt,X as At,Xn as jt,Yn as Mt,_ as Nt,_n as Pt,ar as Ft,b as It,cn as Lt,f as Rt,g as w,h as zt,ht as Bt,ln as Vt,n as Ht,on as Ut,p as Wt,s as T,sn as Gt,t as Kt,tr as qt,u as Jt,un as E,wt as Yt,xn as Xt,zn as Zt,zt as Qt}from"./dom-helpers-1xKy7VX6.js";import{a as $t,i as en,n as tn,r as nn,t as rn}from"./modal-CjIIQMho.js";import{A as an,C as on,D as sn,E as cn,F as ln,I as un,L as dn,M as fn,N as pn,O as mn,P as hn,R as gn,S as _n,T as vn,_ as yn,a as bn,b as xn,c as Sn,d as Cn,f as wn,g as Tn,h as En,i as Dn,j as On,k as kn,l as An,m as jn,n as Mn,o as Nn,p as Pn,r as Fn,s as In,t as Ln,u as Rn,v as zn,w as Bn,x as Vn,y as Hn}from"./session-row-U1g9MCRj.js";import{i as Un,n as Wn,t as Gn}from"./agent-mark-vCo0zsWP.js";import{A as Kn,B as qn,D as Jn,E as Yn,F as Xn,I as Zn,L as Qn,N as $n,O as er,P as tr,R as nr,S as rr,_ as ir,a as ar,b as or,c as sr,f as cr,g as lr,i as D,j as ur,k as dr,n as fr,o as O,p as pr,r as k,s as mr,t as hr,u as gr,w as _r,x as vr,y as yr,z as br}from"./card-registry-BM0Py2ky.js";import{n as A,t as xr}from"./ui-state-core-Nssh-6QJ.js";import{t as j}from"./preload-helper-BLdHbfdN.js";import{c as Sr,i as Cr,n as wr,o as Tr,r as Er,s as Dr,t as Or,u as kr}from"./action-status-rETkOMJb.js";import{a as Ar,c as jr,i as Mr,n as Nr,o as Pr,r as Fr,s as Ir,t as Lr}from"./session-tick-DxsZqUxX.js";import{n as Rr,t as zr}from"./local-store-CVQ5ByvB.js";import{$ as Br,A as Vr,Ct as Hr,D as Ur,E as Wr,Et as Gr,F as Kr,G as qr,Gt as Jr,I as Yr,M as Xr,O as Zr,P as Qr,Q as $r,Rt as ei,S as ti,St as ni,T as ri,Tt as ii,Ut as ai,Vt as oi,X as si,_t as ci,a as li,b as ui,bt as di,c as fi,ct as pi,d as mi,et as hi,ft as gi,gt as _i,h as vi,ht as yi,i as bi,k as xi,l as Si,lt as Ci,m as wi,mt as Ti,ot as Ei,p as Di,pt as Oi,r as ki,t as Ai,tt as ji,u as Mi,vt as Ni,w as Pi,wt as Fi,x as Ii,xt as Li,yt as Ri,zt as zi}from"./ui-prefs-D3kfa1nO.js";import{A as Bi,C as Vi,D as Hi,E as Ui,F as Wi,M as Gi,N as Ki,O as qi,S as Ji,T as Yi,b as Xi,c as Zi,f as Qi,g as $i,h as ea,j as ta,k as na,l as ra,m as ia,p as aa,u as oa,v as sa,w as ca,x as la,y as ua}from"./agent-core-BmzljZal.js";import{n as da}from"./menu-DzZGGGGN.js";import{t as fa}from"./pr-status-icon-dpJOgyIo.js";import{n as pa,t as ma}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 ha={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},ga=null,_a=null,va=!0,ya=new Map,ba=new Map,xa=new Set;function Sa(){for(let e of xa)e()}function Ca(e){xa.add(e)}function wa(){return{status:ga,isServerConnected:va,pendingActionBySuite:ya,outcomeBySuite:ba}}function Ta(e){_a=e}function Ea(e,t){_a?.({type:`benchmark-action`,requestId:d(`benchmark`),suiteId:e,action:t})===!0?(ya.set(e,t),ba.set(e,ha[t]),Sa()):(ba.set(e,x),Sa())}function Da(e){if(va=e,!e){for(let e of ya.keys())ba.delete(e);ya.clear()}Sa()}function Oa(e){ga=e,Sa()}function ka(e){ya.delete(e.suiteId);let t=ga?.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.`};ba.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),Sa()}function Aa({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=nn({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=T(`div`,`coherence-journal-header`),s=T(`h3`,`dialog-title`,t);s.id=n;let c=C({variant:`secondary`,label:`Close`,action:`close-coherence-panel`,onClick:i});return o.append(s,c),a.dialog.append(o,...r),rn(a.dialog,s.id),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function ja({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=Aa({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 Na(e){return e?.active!==!1||e.reason===At.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,detailText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:dn.broken}]}function Pa(e){let t=lt.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 Fa(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 Ia=new Map,La=new Map,Ra=ja({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function za(e,t){La.delete(e),t&&La.set(e,t),Ga(e)}function Ba(e){Ia.delete(e),La.delete(e);let t=Ra.currentPanel();t?.sessionId===e&&t.close()}function Va(e){let t=Ia.get(e.id);t&&t.updatedAt>e.updatedAt||(Ia.set(e.id,e),Ga(e.id))}function Ha(e){Ia.clear();for(let[t,n]of Object.entries(e.sessions))Ia.set(t,n);let t=Ra.currentPanel();t&&Ga(t.sessionId)}function Ua(e){return Na(La.get(e)??null).map(t=>({...t,onActivate:()=>Ka(e)}))}function Wa(e){return Ia.get(e)?.journal.ok===!0}function Ga(e){let t=Ra.currentPanel();if(!t||t.sessionId!==e)return;let n=Fa(La.get(e)??null,Ia.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>T(`p`,null,e)))}function Ka(e){let t=T(`div`,`coherence-journal-reading`),n=T(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=T(`div`,`coherence-journal-entries`);Ra.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>Ga(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function qa(e){let t=Ra.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=Pa(e),n=T(`article`,`coherence-journal-entry`);return n.append(T(`h4`,null,t.heading),T(`p`,null,t.text)),t.detail&&n.append(T(`p`,null,t.detail)),t.supersedes&&n.append(T(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var Ja=new Set([`waiting`,`monitoring`]);function Ya(e){return Object.fromEntries(de.flatMap(t=>{let n=Ja.has(t)?8:6;return[[`--state-${t}`,e[t]],[`--state-${t}-bg`,`color-mix(in oklab, var(--state-${t}) ${n}%, transparent)`]]}))}function Xa(e){return{...Object.fromEntries(Object.entries(e.chrome).map(([e,t])=>[`--${e}`,t])),...Ya(e.states)}}var Za={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`}},Qa={dark:{black:`--border`,brightBlack:`--text-muted`,white:`--text`,brightWhite:`--text-head`},light:{black:`--text-head`,brightBlack:`--text-dim`,white:`--text-dim`,brightWhite:`--text`}},$a=.35;function eo(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 to(e){if(e.accentAnsiSlot===`none`)return{};let t=`bright${e.accentAnsiSlot[0].toUpperCase()}${e.accentAnsiSlot.slice(1)}`;return{[e.accentAnsiSlot]:`--accent`,[t]:eo(e.chrome.accent,$a)}}function no(e){return{label:e.label,colors:{...Xa(e),...Un(e.mode)},terminal:{background:`--bg-card`,foreground:`--text`,cursor:`--accent`,cursorAccent:`--bg-card`,...Qa[e.mode],...Za[e.mode],...to(e)}}}var ro={glimmer:no({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":no({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:no({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:no({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:no({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:no({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:no({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":no({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":no({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`}})},io=`glimmer`,ao=null,oo=null,so=null,co={};function lo(e){return Object.hasOwn(ro,e)?ro[e]:co[e]}function uo(e){co=Object.fromEntries(e.map(({id:e,palette:t})=>[e,no(t)]));let t=so??io,n=lo(t)?t:io;return n===oo&&!Object.hasOwn(co,n)?!1:(po(n),!0)}function fo(e){so=e,lo(e)&&po(e)}function po(e){let t=lo(e);if(!t)return;let n=oo;oo=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`&&ao?.()}function mo(e){ao=e}function ho(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function go(){let e=lo(oo||io);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 _o(){return{id:oo,colors:{...lo(oo??io)?.colors}}}function vo(){return Object.entries({...ro,...co}).map(([e,t])=>({id:e,label:t.label}))}function yo(){let e=go();e.background&&e.foreground&&s({type:`terminal-colors`,background:e.background,foreground:e.foreground})}var bo=3e4,xo=24,So=null,Co=[`Android`,`iPhone`,`iPad`,`Windows`,`Mac OS X`,`Linux`],wo=[/Firefox\/\d+/,/Edg\/\d+/,/Chrome\/\d+/,/Version\/\d+/];function To(){let e=navigator.userAgent,t=Co.find(t=>e.includes(t))??`unknown platform`;return`${wo.map(t=>t.exec(e)?.[0]).find(e=>e!==void 0)?.replace(`Version`,`Safari`)??`unknown browser`} on ${t}`}function Eo(){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 Do(){return[navigator.onLine?`online`:`offline`,...Eo()].join(` `)}function Oo(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 ko(e,t){let n=e.join(` `);if(n.length<=t)return n;let r=t-xo,i=Oo(e,r/2),a=Oo(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 Ao(e){return e.marks.some(e=>e.startsWith(`terminal-bytes`))}function jo(e){let t=Ao(e)&&!e.isCapped?`terminal live`:`terminal not live after ${bo/1e3} s`,n=`hidden ${Math.round(e.hiddenForMs/1e3)} s, ${t}, ${To()}, ${e.networkAtWake}: `,r=n+ko(e.marks,nt-n.length);return s({type:`client-log`,scope:`wake`,text:r.slice(0,nt)})}function Mo(){let e=So;e&&(e.isCapped||Ao(e))&&jo(e)&&(So=null,clearTimeout(e.capTimer))}function No(){So&&(So.isCapped=!0,Mo())}function Po(e,t){e.marks.push(`${t}+${Math.round(performance.now()-e.startedAtMs)}`)}function Fo(e){So&&(e===`terminal-bytes`&&Ao(So)||(Po(So,e),(e===`terminal-bytes`||e===`control-opened`)&&Mo()))}function Io(e){So&&Po(So,e===`link`?[`link`,...Eo()].join(`-`):e)}function Lo(e,t){So||={startedAtMs:performance.now(),hiddenForMs:t,networkAtWake:Do(),marks:[],isCapped:!1,capTimer:setTimeout(No,bo)},Fo(e)}function Ro(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function zo(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 Bo=null,Vo=null;function Ho(){return Bo}function Uo(){return Bo?Promise.resolve(Bo):(Vo??=Promise.all([j(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.t),__vite__mapDeps([0,1])),j(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.r),__vite__mapDeps([0,1])),j(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.n),__vite__mapDeps([0,1]))]).then(([e,t,n])=>(Bo={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},Bo)).catch(e=>{throw Vo=null,e}),Vo)}var Wo=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,Go=new Map;function Ko(e){return e.clientWidth>0&&e.clientHeight>0}function qo(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 Jo(e){Go.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,qo(e)}function Yo(e){let t=[e],n=A.snapshot().borrowedCardId,r=n?O.get(n):void 0;r&&t.push(r);for(let e of zo([...Go.keys()],Wo,t))Jo(e),e.needsWebGLReload=!0}function Xo(e){e?.term&&Ro({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:Ko(e.termWrap)})&&ts(e,{isForced:!0})}function Zo(){for(let e of Go.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{Jo(e),e.needsWebGLReload=!0}}}var Qo=!1;function $o(){Qo||(Qo=!0,requestAnimationFrame(()=>{Qo=!1,Zo()}))}function es(e){e?.addEventListener(`contextrestored`,$o)}function ts(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){Go.delete(e),Go.set(e,!0);return}e.webglAddon&&(qo(e),Go.delete(e));let n=Ho();if(!n)return;Yo(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,Go.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(es),r.onAddTextureAtlasCanvas(es),es(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!Ko(e.termWrap),Go.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,Go.delete(e)}}var ns=`(max-width: 768px)`,rs=`(pointer: coarse)`;function is({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var as=window.matchMedia?.(rs),os=window.matchMedia?.(ns);function ss(){return is({coarse:!!as?.matches,narrowWidth:!!os?.matches})}function cs(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function ls(){A.subscribe((e,t)=>{t.includes(`layout`)&&cs(e.layout)});let e=ss();cs(e),A.dispatch(`setLayout`,e);let t=()=>A.dispatch(`setLayout`,ss());return as?.addEventListener?.(`change`,t),os?.addEventListener?.(`change`,t),e}function us(){return A.snapshot().layout===`phone`}function ds(e){return A.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var fs=``,ps=`\x1B`,ms=`\r`,hs=new Map([[`deleteContentBackward`,fs],[`deleteByComposition`,fs],[`deleteCompositionText`,fs],[`deleteWordBackward`,ps],[`deleteSoftLineBackward`,ps],[`deleteHardLineBackward`,ps]]);function gs(e){return hs.get(e)??``}var _s=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function vs(e){return typeof e!=`string`||e===``||!_s.has(e)}function ys(e){return e?e.keyCode===229||e.key===`Process`:!1}function bs(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 fs.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,ms)}var xs=`Upload`;async function Ss(e,t){return wr(xs,e),ws(e,t)}async function Cs(e,t){wr(xs,e);for(let n of t)await ws(e,n)}async function ws(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:(Tr({source:xs,sessionId:e,message:await Ts(r,t.name)}),!1)}catch{return Tr({source:xs,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 Ts(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 Es=new WeakMap,Ds=5e3,Os=15e3,ks=`The agent copied text. The browser needs a click before it can reach your clipboard.`,As=`The clipboard is unavailable in this browser.`;function js(e,t,n,r){let i=Es.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`?Ds:Os)))}function Ms(e,t){let n=Es.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function Ns(e){let t=e.buffer.active;return t.viewportY<t.baseY}function Ps(e,t,{hasNewOutput:n=!1}={}){let r=Es.get(e)?.jumpToLatest;if(!r)return;let i=Ns(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function Fs(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 Is(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),js(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function Ls(e,t,n,r){let i=It(t);i?i.then(()=>{r&&js(e,`clipboard`,`ok`,r)}).catch(t=>Is(e,n,t)):js(e,`clipboard`,`error`,As)}function Rs(e,t){let n=Es.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function zs(e){let t=Es.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,Ls(e,n,`osc52 write`,`Copied to the clipboard.`))}function Bs(e,t,n){let r=Cr(`terminal-notice`),i=T(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=C({variant:`primary`,label:`Copy to clipboard`,onClick:()=>zs(t)});i.append(T(`span`,`terminal-clipboard-prompt-text`,ks),a);let o=T(`div`,`terminal-notices`);o.append(i,r.element);let s=T(`div`,`terminal-jump-latest`);s.hidden=!0,s.append(C({variant:`secondary`,label:`Jump to latest`,onClick:()=>{n.scrollToBottom(),n.focus()}}),T(`span`,`terminal-jump-latest-new-output`));let c=T(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(T(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),Es.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatest:s})}var Vs=1024,Hs=`Keys you type now are held and sent once the terminal reconnects.`,Us=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,Ws=!1;function Gs(e){let t=e._inputQueue,n=e.dataWs;if(!Ws&&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 Ks(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!Ws&&!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>=Vs?(js(e,`keys`,`error`,Us),!1):(e._inputQueue.push(t),r&&js(e,`keys`,`busy`,Hs),!0)}function qs(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,us()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=bs(i,r.value);return i=r.value,e!==``&&(Ks(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{us()?n(e):a()},!0)};c(`keydown`,e=>{ys(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(!vs(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=gs(e.inputType);r!==``&&(Ks(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function Js(e){return!!e&&Array.from(e.types).includes(`Files`)}function Ys(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),Cs(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{Js(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,Js(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),Cs(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function Xs(e){Ws=e}var Zs=6,Qs=262144,$s=16384,ec=()=>{};function tc(e,t){if(t.length<=$s)e.push(t);else for(let n=0;n<t.length;n+=$s)e.push(t.slice(n,n+$s))}function nc({budget:e=Zs,maxChunkBytes:t=Qs,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)tc(l,e),m+=e.length,a.readIdx++;else{m===0&&(tc(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,ec);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 rc=nc(),ic=[];function ac(e){ic=[...e]}function oc(){return ic}function sc(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 cc=new Map;function lc(e){return cc.get(e)??null}function uc(e,t){cc.set(e,t)}function dc(e){cc.delete(e)}function fc(e){return[...cc].flatMap(([t,n])=>n===e?[t]:[])}function pc(e){let t=lc(e);return t?`/hosts/${encodeURIComponent(t)}`:``}function mc(e){let t=lc(e);if(!t)return null;let n=oc(),r=n.findIndex(e=>e.id===t);return{id:t,name:n[r]?.name??t,rank:r===-1?n.length:r}}var hc=re().int().min(1).max(500),gc=re().int().min(1).max(200);se(`type`,[oe({type:ie(`input`),data:ce()}),oe({type:ie(`claim`),cols:hc,rows:gc}),oe({type:ie(`unview`)}),oe({type:ie(`pause-output`)}),oe({type:ie(`resume-output`)})]);var _c=oe({type:ie(`pty-size`),cols:hc,rows:gc,seq:re().int().nonnegative()}),vc=oe({type:ie(`output-beat`)}),yc=se(`type`,[_c,vc]),bc=`history`,xc=`output`,Sc=`paused`;ae([`screen`,`deep`]);function Cc(e){try{return JSON.parse(e)}catch{return null}}function wc(e){let t=yc.safeParse(Cc(e));return t.success?t.data:null}var Tc=new Set([1,5,25,100]);function Ec(e){return e.isOutputPaused?`${e.history} paused`:e.history}function Dc(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function Oc(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function kc(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function Ac({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&Dc(e,n))}function jc({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 Nc({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function Pc(e,t,n){let r=new URLSearchParams;t&&r.set(bc,`deep`),n&&r.set(xc,Sc);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function Fc({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:Ac({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function Ic({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function Lc({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!Dc(e,t),s=Oc(n)?kc(n):null,c=r&&!!s&&!Dc(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:Ac({authoritative:e,isActiveViewer:r,lastClaim:a})}}function Rc(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function zc(e){let t=Rc(e);return t===null?null:wc(t)}function Bc(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=zc(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 Vc=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,Hc=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,M=`[^\\S\\r\\n]`,Uc=`${Vc}${M}*(?:=>|[:=])${M}*`,Wc=`[?&][A-Za-z0-9_.-]*`,Gc=`[^\\r\\n;&|]{0,200}?`,Kc=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,qc=RegExp(`(${Uc})${Hc}`,`gi`),Jc=RegExp(`(\\bBearer${M}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),Yc=[/\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],Xc=[RegExp(`((?:^|\\s)--?${Vc}${M}+)${Hc}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${M}*=?${M}*)${Hc}`,`g`),RegExp(`(-AsPlainText${M}+)${Hc}`,`gi`),RegExp(`((?:^|\\s)setx${M}+[^\\s\\r\\n]*${Vc}[^\\s\\r\\n]*${M}+)${Hc}`,`gi`)],Zc=[RegExp(`(\\bauthorization${M}*:${M}*Basic${M}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${M}+login\\b${Gc}${M}-p(?:${M}+|=))${Hc}`,`gi`),RegExp(`(\\bcurl\\b${Gc}${M}(?:--user|-u)(?:${M}+|=)[^\\s:\\r\\n]+:)${Hc}`,`gi`),RegExp(`(\\b${Kc}\\b${Gc}${M}-p)${Hc}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi],Qc=[/-----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],$c=RegExp(`(${Wc}(?:${Vc}|_key)=)[^&#\\s]+`,`gi`),el=[qc,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${Hc}`,`g`)],tl=[Jc,...Xc,...Zc,...Yc,...Qc];function nl(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function rl(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 il(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 al(e){let t=nl(e,$c);return il([...t,...el.flatMap(n=>rl(nl(e,n),t)),...tl.flatMap(t=>nl(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var ol=`•`.repeat(8),sl=4;function cl(e){let t=e.flatMap(e=>[e,...e.split(/\r?\n/)]).map(e=>e.trim());return[...new Set(t.filter(e=>e.length>=sl))]}function ll(e,t){let n=[];for(let r of cl(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 ul(e,t=[]){let n=il([...al(e),...ll(e,t)]);if(n.length===0)return e;let r=``,i=0;for(let t of n)r+=e.slice(i,t.start)+ol,i=t.end;return r+e.slice(i)}var dl=`glimmervoid-streamer-mode`,fl=new Set,pl=zr(dl,!1)===!0;function ml(e){document.documentElement.toggleAttribute(`data-streamer`,e)}ml(pl);function hl(){return pl}function gl(e){if(Rr(dl,e),e!==hl()){pl=e,ml(e);for(let t of fl)t(e)}}function _l(e){return fl.add(e),()=>fl.delete(e)}async function vl(e){try{let t=await c(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:Or});return t.type===`settings-error`?String(t.message):(gl(e),``)}catch(e){return Dr(e,Or)}}var yl=`Streamer mode`;async function bl(){let e=!hl();e&&gl(!0);let t=await vl(e);t?Tr({source:yl,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}):wr(yl)}function xl(){bl()}var Sl=`#808080`,Cl=new WeakMap;function wl(e,t,n){return`${e}:${t}:${n}`}function Tl(e){return wl(e.marker.line,e.x,e.width)}function El(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function Dl(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function Ol(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function kl(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 Al(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 jl(e,t,n,r){let i=[];if(al(Ol(e,t,n)).length===0)return i;let{text:a,cellAt:o}=kl(e,t,n,r);for(let e of al(a))Al(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=Dl(e,i);r.push(...jl(e,i,t,n)),i=t+1}return r}function Nl(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function Pl(e){e.decoration.dispose(),e.marker.dispose()}function Fl(e){for(let t of e.masks)Pl(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function Il(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function Ll(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 Rl(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(Tl(r),r),r=e.masks.at(-1);return Ll(e),n}function zl(e,t){let n={normal:Nl(),alternate:Nl()},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??Sl,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(!hl())return;let t=e.buffer.active,r=n[t.type],i=El(t,Il(r,t)),a=Rl(r,i);for(let e of Ml(t,i)){let n=wl(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())Pl(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){Fl(n.normal),Fl(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=>{Fl(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=_l(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),Cl.delete(e)},{once:!0}),Cl.set(e,d)}function Bl(e){Cl.get(e)?.()}function Vl({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var Hl=`-4 -4 108 108`,Ul=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`}]),Wl=`M50 39L61 50L50 61L39 50Z`,Gl=11,Kl=`#efedf6`,ql=`#b688fe`;function Jl({frame:e,light:t,strokeWidth:n=Gl}){return`<path d="${Ul.map(({d:e})=>e).join(``)}" fill="none" stroke="${e}" stroke-width="${n}" stroke-linejoin="miter" stroke-linecap="butt"/><path d="${Wl}" fill="${t}"/>`}function Yl(e,t){return Mc({isBorrowedCard:A.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var Xl=new WeakMap,Zl=new WeakMap,Ql=new WeakSet,$l=new WeakSet,eu=new WeakSet;function tu(e,t){if(Xl.has(e)||!Ns(t))return;let n=t.buffer.active,r=n.length-n.viewportY;Ql.has(e)?Xl.set(e,r):Zl.set(e,r)}function nu(e,t,n){let r=e.term;r&&Nc({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:Ql.has(e)})&&(Ql.add(e),$l.add(e),Xl.set(e,r.buffer.active.length-n),Au(t))}var ru=new WeakMap;function iu(e,t){return document.visibilityState===`visible`&&!Yl(e,t)}function au(e,t){if(e&&bu(e,t))return;let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=iu(e,t);ru.get(n)!==r&&(ru.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function ou(){for(let[e,t]of O)au(t,e)}document.addEventListener(`visibilitychange`,ou),A.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&ou()});function su(e,t){return O.get(e)===t&&!t.dataWs}function cu(e){return e.querySelector(`:scope > .terminal-connecting`)}function lu(){let e=le(`svg`,{class:`loading-mark`,viewBox:Hl,"aria-hidden":`true`});for(let{side:t,d:n}of Ul)e.append(le(`path`,{class:`loading-mark-bracket`,"data-side":t,d:n}));return e}function uu(e){if(cu(e))return;let t=T(`div`,`terminal-connecting`);t.append(lu(),T(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}var du=new Set,fu=new WeakSet;function pu(e){return du.add(e),()=>du.delete(e)}function mu(){let e=0;for(let[t,n]of O)n.card.dataset.link===`connecting`&&iu(n,t)&&e++;return e}function hu(e){let t=Vl({hasTerminal:e.term!==null||fu.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:Ws}),n=t===`connecting`&&!Ws&&$l.has(e)?`live`:t;n===`none`?(delete e.card.dataset.link,gu()):(e.card.dataset.link=n,gu())}function gu(){for(let e of du)e()}function _u(e,t,n){tu(t,n),rc.unregister(e),t.dataWs=null,hu(t),t._resetGridClaim?.()}var vu=new WeakMap;function yu(e,t,n,r){_u(e,t,n),clearTimeout(vu.get(t)),vu.delete(t),r===0&&a()?ku(e,t,n):vu.set(t,setTimeout(()=>{vu.delete(t),su(e,t)&&b().catch(()=>{}).then(()=>{su(e,t)&&ku(e,t,n)})},r))}function bu(e,t){let n=eu.has(e),r=!e.dataWs&&O.get(t)===e;return!(n||r)||!e.term||!iu(e,t)?!1:(eu.delete(e),e._dataWsRetryAttempt=0,yu(t,e,e.term,0),!0)}function xu(e,t,n){_u(e,t,n),eu.add(t)}var Su=15e3,Cu=new Map;function wu(e){if(!a()||Cu.has(e)||O.get(e)?.dataWs)return;let n=pc(e)+Pc(e,!1,!1),r=new WebSocket(te(location,ne(n)));r.binaryType=`arraybuffer`;let i=[],o=e=>i.push(e),s=()=>Tu(e,r),c=()=>{r.readyState===WebSocket.CONNECTING&&s()};r.addEventListener(`message`,o),r.addEventListener(`close`,s);let l=setTimeout(c,t),u=setTimeout(s,Su);Cu.set(e,{socket:r,attachPath:n,bufferedMessages:i,release:()=>{r.removeEventListener(`message`,o),r.removeEventListener(`close`,s),clearTimeout(l),clearTimeout(u)}})}function Tu(e,t){let n=Cu.get(e);n?.socket===t&&(Cu.delete(e),n.release(),t.close())}function Eu(e,t){let n=Cu.get(e);if(!n)return null;let r=n.socket.readyState===WebSocket.CONNECTING||n.socket.readyState===WebSocket.OPEN;return n.attachPath!==t||!r?(Tu(e,n.socket),null):(Cu.delete(e),n.release(),n)}var Du=new WeakMap;function Ou(e,t,n){if(t.openedAtMs===null)return;let r=Math.round(performance.now()-t.openedAtMs);if(r>=1e3){Du.delete(e);return}let i=(Du.get(e)??0)+1;if(Du.set(e,i),!Tc.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 ku(e,r,i){eu.delete(r);let a=Xl.get(r);Xl.delete(r);let o=Zl.get(r);Zl.delete(r);let s=a!==void 0,c=a??o,l=!1,u=iu(r,e),d=pc(e)+Pc(e,s,!u),f=Eu(e,d),p=f?.socket??new WebSocket(te(location,ne(d)));ru.set(p,u),p.binaryType=`arraybuffer`,r.dataWs=p,u&&Fo(`terminal-connecting`),hu(r);let m=!1,h=!1,g={sessionId:e,attachDescription:Ec({history:s?`deep`:`screen`,isOutputPaused:!u}),openedAtMs:null,hasReceivedBytes:!1},_={hasSeenSize:!1,lastSeq:0},v=setTimeout(()=>{p.readyState===WebSocket.CONNECTING&&(h=!0,u&&Fo(`terminal-abandoned`),p.close())},t);rc.register(e,(e,t)=>i.write(e,t));let y=t=>{if(r.dataWs!==p)return;let n=Bc(t.data,_);if(n.kind===`bytes`){g.hasReceivedBytes=!0,Pr(r),ru.get(p)&&Fo(`terminal-bytes`);let t=l;if(l=!1,rc.enqueue(e,n.data),!t)return;let a=c??0;rc.enqueueAction(e,()=>{i.scrollToLine(Math.max(0,i.buffer.active.length-a))});return}if(n.kind===`beat`){Pr(r);return}if(n.kind===`attach-size`){l=c!==void 0,s||Ql.delete(r),_.hasSeenSize=!0,_.lastSeq=n.seq,i.reset(),Bl(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};rc.enqueueAction(e,()=>{r.ptySize=a,r._syncGrid?.()})};p.addEventListener(`message`,y),p.addEventListener(`close`,t=>{if(clearTimeout(v),r.dataWs!==p)return;if(Ou(r,g,t),u&&!h&&Fo(`terminal-closed`),$l.delete(r),m||h||lc(e)||ee(),!iu(r,e)){xu(e,r,i);return}if(h){yu(e,r,i,0);return}let a=n(r._dataWsRetryAttempt||0);r._dataWsRetryAttempt=(r._dataWsRetryAttempt||0)+1,yu(e,r,i,a)});let b=()=>{clearTimeout(v),m=!0,g.openedAtMs=performance.now(),u&&Fo(`terminal-opened`),r._dataWsRetryAttempt=0,$l.delete(r),hu(r),au(r,e),r._syncGrid?.({isActivationEdge:!0}),r._retryOwedGridClaim?.(),r._inputQueue?.length&&setTimeout(()=>{r.dataWs===p&&Gs(r)},50)};p.addEventListener(`open`,b),p.readyState===WebSocket.OPEN&&b();for(let e of f?.bufferedMessages??[])y(e)}function Au(e){let t=k(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,yu(e,t,t.term,0),n?.close()}function ju(){for(let[e,t]of O)t.term&&(iu(t,e)?Au(e):Mu(e,t,t.term))}function Mu(e,t,n){let r=t.dataWs;r&&(xu(e,t,n),r.close())}function Nu(){for(let[e,t]of O)t.term&&Mu(e,t,t.term)}function Pu(e,t){let n=e.dataWs;e.dataWs=null,rc.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}var Fu=`CommitMono`,Iu=[400,700].map(e=>`${e} 14px ${Fu}`),Lu=`monospace`;function Ru(e){return e.trim().replace(/^['"]|['"]$/g,``)}function zu(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>Ru(e)!==Fu);return r.length>0?r.join(`, `):Lu}function Bu(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function Vu(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function Hu(){return document.fonts?Iu.every(e=>document.fonts.check(e)):!1}function Uu(){return zu(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),Hu())}function Wu(e){document.fonts&&Bu(document.fonts,Iu,e)}var Gu=()=>!1;function Ku(e){Gu=e}function qu(){return Gu()}var Ju=Jr(navigator.userAgent),Yu=`next-attention-keys`,Xu=Mi();function Zu(){return Xu}function Qu(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(T(`span`,`shortcut-sep`,`+`)),e.appendChild(T(`kbd`,`kbd`,t))})}function $u(e){let t=T(`span`,`shortcut-keys`);return Qu(t,e),t}function ed(){let e=$u(ai(`next-attention`,Ju,Xu));return e.classList.add(Yu),e}function td(e){Xu=e;let t=ai(`next-attention`,Ju,e);for(let e of document.querySelectorAll(`.${Yu}`))e.replaceChildren(),Qu(e,t)}var nd=oe({title:ce().optional(),iconDataUrl:ce().startsWith(`data:image/`).optional()}),rd=new Set([`http:`,`https:`]);function id(e){let t;try{t=new URL(e)}catch{return null}return rd.has(t.protocol)?t.href:null}var ad=/\bElectron\/\d/,od=new Set([`localhost`,`127.0.0.1`]);function sd(e){return ad.test(e)}function cd({userAgent:e,pageHostname:t}){return sd(e)&&od.has(t)}function ld(e){return id(e)!==null}var ud=new Set([0,1]);function dd({button:e,opensInNewTab:t}){return t&&ud.has(e)}function fd(){return cd({userAgent:navigator.userAgent,pageHostname:location.hostname})}function pd(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function md(e){try{let t=await b();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 hd=500,gd=new Map;async function _d(e){try{let t=await b(),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=nd.safeParse(await n.json());return r.success?r.data:{}}catch{return{}}}function vd(e){return e.title!==void 0||e.iconDataUrl!==void 0}function yd(e){let t=gd.get(e);if(t)return t;let n=_d(e).then(t=>(!vd(t)&&gd.get(e)===n&&gd.delete(e),t));if(gd.set(e,n),gd.size>hd){let e=gd.keys().next().value;e!==void 0&&gd.delete(e)}return n}function bd(e){!fd()||!ld(e)?pd(e):md(e).then(t=>{t||pd(e)})}function xd(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&dd({button:e.button,opensInNewTab:t.target===`_blank`})&&ld(t.href)&&(e.preventDefault(),bd(t.href))}function Sd(e){fd()&&(e.addEventListener(`click`,xd,!0),e.addEventListener(`auxclick`,xd,!0))}var Cd={phase:`hidden`,isPointerOnLink:!1,isPointerOnPopup:!1},wd=`*`,Td=/^[("'<[{]+|[)"'>\]}.,;:!?]+$/g,Ed=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(`.`)),Dd=/^[a-z][a-z0-9+.-]*:\/\//i,Od=/\s/,kd=/\.[a-z]{2,63}$/i,Ad=/^www\./;function jd(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 Nd(e){let t={...e,isPointerOnLink:!1};return e.phase===`shown`&&jd(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function Pd(e){let t={...e,isPointerOnPopup:!1};return e.phase===`shown`&&jd(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function Fd(e,t){switch(t){case`enter-link`:return Md(e);case`leave-link`:return Nd(e);case`enter-popup`:return{state:{...e,isPointerOnPopup:!0},effects:e.phase===`shown`?[`cancel-hide`]:[]};case`leave-popup`:return Pd(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`||!jd(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 Id(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 Ld(e){try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?null:t}catch{return null}}function Rd(e,t){let n=e.split(``);for(let e of t)n.fill(wd,e.start,e.end);return n.join(``)}function zd(e,t){let n=Ld(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=Rd(`${i}${n.host}${a}`,al(`${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 Bd(e){let t=e.trim().replace(Td,``);if(t.length===0||Od.test(t))return null;let n=Ld(Dd.test(t)?t:`https://${t}`);if(!n)return null;let r=n.hostname.replace(/\.$/,``);return!kd.test(r)||!Dd.test(t)&&Ed.has(r.slice(r.lastIndexOf(`.`)+1).toLowerCase())?null:r}function Vd(e,t){let n=e.replace(Ad,``),r=t.replace(Ad,``);return n===r||n.endsWith(`.${r}`)||r.endsWith(`.${n}`)}function Hd(e,t){let n=Ld(t);if(!n)return null;let r=Bd(e);if(!r)return null;let i=n.hostname.replace(/\.$/,``);return Vd(r,i)?null:{textHost:r,targetHost:i}}var Ud=100,Wd=150,Gd=600,Kd=16,qd=[`mousedown`,`mouseup`,`mousemove`,`click`,`dblclick`,`contextmenu`,`wheel`],Jd=!1;function Yd(e){Jd=e}function Xd(e){let t=T(`div`,`terminal-link-popup-url`),n=zd(e,hl());return n?(t.append(T(`span`,`terminal-link-popup-url-dim`,n.scheme),T(`strong`,`terminal-link-popup-host`,n.host),T(`span`,`terminal-link-popup-url-dim`,n.rest)),t):(t.textContent=e,t)}function Zd(e){if(e.linkText===null)return null;let t=Hd(e.linkText,e.url);if(!t)return null;let n=T(`div`,`terminal-link-popup-mismatch`);return n.append(`Text says `,T(`strong`,null,t.textHost),`, goes to `,T(`strong`,null,t.targetHost)),n}function Qd(e,t){if(!e||e.url!==t)return null;let{title:n,iconDataUrl:r}=e.preview;if(!n&&!r)return null;let i=T(`div`,`terminal-link-popup-preview`);if(r){let e=T(`img`,`terminal-link-popup-icon`);e.src=r,e.alt=``,e.width=Kd,e.height=Kd,i.append(e)}return n&&i.append(T(`span`,`terminal-link-popup-title`,n)),i}function $d(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=T(`div`,`xterm-hover terminal-link-popup`);s.hidden=!0,i.append(s);let c=Cd,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;Jd&&e&&yd(e).then(t=>{Jd&&(p={url:e,preview:t},c.phase===`shown`&&l?.url===e&&te())})}function y(e){e.key===`Escape`&&re(`escape`)}function ee(t){let n=a.getBoundingClientRect(),r=i.getBoundingClientRect(),o=e.buffer.active.viewportY;m=o;let c=Id({linkRange:{startRow:t.range.start.y-1-o,startCol:t.range.start.x-1,endRow:t.range.end.y-1-o},rows:e.rows,cellWidthPx:n.width/e.cols,cellHeightPx:n.height/e.rows,popupHeightPx:s.offsetHeight,popupWidthPx:s.offsetWidth,screenWidthPx:n.width});s.dataset.side=c.side,s.style.left=`${n.left-r.left+c.leftPx}px`,s.style.top=`${n.top-r.top+c.topPx}px`}function te(){let e=l;if(!e)return;let n=T(`div`,`terminal-link-popup-footer`);n.append(T(`span`,`terminal-link-popup-hint`,`Click to open`),C({variant:`secondary`,size:`small`,label:`Copy link`,onClick:()=>Ls(t,e.url,`link copy`,`Copied the link.`)}));let r=Zd(e);s.replaceChildren(...[Xd(e.url),r,Qd(Jd?p:null,e.url),n].filter(e=>e!==null)),s.hidden=!1,ee(e),document.addEventListener(`keydown`,y,{capture:!0,signal:o})}function ne(){s.hidden=!0,s.replaceChildren(),document.removeEventListener(`keydown`,y,{capture:!0})}let b={"schedule-show":()=>{h(),u=setTimeout(()=>{u=null,re(`show-timer`)},Ud)},"cancel-show":h,"schedule-hide":()=>{g(),d=setTimeout(()=>{d=null,re(`hide-timer`)},Wd)},"cancel-hide":g,"schedule-dwell":()=>{_(),f=setTimeout(()=>{f=null,re(`dwell-timer`)},Gd)},"cancel-dwell":_,"fetch-preview":v,render:te,remove:ne};function re(e){let t=Fd(c,e);c=t.state;for(let e of t.effects)b[e]()}for(let e of qd)s.addEventListener(e,e=>e.stopPropagation(),{signal:o});s.addEventListener(`mouseenter`,()=>re(`enter-popup`),{signal:o}),s.addEventListener(`mouseleave`,()=>re(`leave-popup`),{signal:o});let ie=e.onScroll(()=>{e.buffer.active.viewportY!==m&&re(`escape`)}),ae=e.onResize(()=>re(`escape`));return o.addEventListener(`abort`,()=>{h(),g(),_(),ie.dispose(),ae.dispose(),s.remove()},{once:!0}),{enterLink(e){us()||(l=e,re(`enter-link`))},leaveLink(){re(`leave-link`)}}}var ef=/https?:\/\/[^\s<>"']+/g,tf=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),nf={")":`(`,"]":`[`,"}":`{`};function rf(e,t){let n=0;for(let r of e)r===t&&n++;return n}function af(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(tf.has(t)){e=e.slice(0,-1);continue}let n=nf[t];if(n&&rf(e,n)<rf(e,t))e=e.slice(0,-1);else return e}}function of(e){let t=[];for(let n of e.matchAll(ef)){let e=af(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var sf=50;function cf(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 lf(e,t){return{activate(e,t){bd(t)},hover(n,r,i){t.enterLink({url:r,linkText:cf(e,i),range:i})},leave(){t.leaveLink()},allowNonHttpProtocols:!1}}function uf(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<sf;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<sf;)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 df(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}=uf(i,n),s=[];for(let{start:e,end:n,url:r}of of(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){bd(t)},hover(){t.enterLink({url:r,linkText:null,range:c})},leave(){t.leaveLink()}})}r(s.length?s:void 0)}}),r=ff(e);return{dispose(){r.dispose(),n.dispose()}}}function ff(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 pf=10,mf=1.2,hf=.005,gf=4,_f=.08,vf=5;function yf(e,t){let n=Math.abs(t);return n<pf?!1:n>Math.abs(e)*mf}function bf(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 xf(e,t,n){let r=e.length>=gf?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function Sf(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>=_f))return 0;let o=Math.min(a,vf);return i<0?-o:o}function Cf({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function wf(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)-hf*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=bf(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function Tf(e,t){return e===`alternate`||!!t&&t!==`none`}function Ef(e,t){return!(e>0)||!(t>0)?0:e/t}var Df=1;function Of(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function kf(e,t){for(let n of e)if(n.identifier===t)return n;return null}function Af(e,t){if(Of(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=()=>Tf(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return Ef(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:Df,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}=wf(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=Cf({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=kf(e.touches,r);if(!u)return;if(!s){if(!yf(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=xf([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=xf(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=bf(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=xf(l,o,e.timeStamp);let t=Sf(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function jf(e){let t=oi(e,Ju,{isTerminalFocused:!0},Zu());return!t||t.action===`board-split`&&!qu()?!1:ei(t,document.body.dataset.activeView)}var Mf=250,Nf=`(max-width: 768px)`,Pf=12,Ff=14,If=5e4,Lf=!1;function Rf(e){Lf=e}var zf=!1;window.addEventListener(`blur`,()=>{zf=!0}),window.addEventListener(`focus`,()=>{zf=!1});function Bf(e){let t=document.activeElement;return jc({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:zf,isPhoneLayout:us()})}function Vf(e,t,n){let r=window.matchMedia?.(Nf).matches?Pf:Ff,i=new n.Terminal({cursorBlink:Lf,fontSize:r,fontFamily:Uu(),theme:go(),scrollback:If,allowProposedApi:!0}),a=new n.FitAddon;i.loadAddon(a),uu(e),i.open(e),Bs(e,t,i);let o=$d(i,t);i.options.linkHandler=lf(i,o),df(i,o),zl(i,t.abortController.signal),t.term=i,t.fitAddon=a,Jo(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||!Bf(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=Ac({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=Lc({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=Fc({authoritative:t.ptySize??null,isActiveViewer:l,isDocumentEngaged:Bf(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=Ic({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&&Xo(t),_({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{zf=!1,v()},{signal:t.abortController.signal}),ts(t);let ee=null;i.onScroll(()=>{ee===null&&(ee=requestAnimationFrame(()=>{ee=null,t.term&&(t.term.refresh(0,t.term.rows-1),Ps(t,t.term))}))}),i.onWriteParsed(()=>Ps(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=Fs(r)}catch(e){return Is(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(Ls(t,i,`osc52 write`),!0):(Rs(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`&&Ks(t,`\x1B\r`),!1;if(e.type!==`keydown`)return!0;if(jf(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),Ls(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(Ks(t,`\x1B`),!1):!0}),qs(e,i,t),Af(e,i)}function Hf(){Xs(!0);for(let e of O.values())hu(e)}function Uf(){Xs(!1);for(let e of O.values())hu(e),Gs(e)}function Wf(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{Ks(e,n),e.unseenOutcome&&s({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{nu(e,t,n)}),Ys(e.termWrap,t,e.abortController.signal),hu(e),queueMicrotask(()=>{su(t,e)&&ku(t,e,n)}))}function Gf(e,t){if(e.term||fu.has(e))return;let n=Ho();if(n){Kf(e,t,n);return}fu.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},uu(e.termWrap),hu(e),Uo().then(n=>{fu.delete(e),e.term||e.abortController.signal.aborted||O.get(t)!==e||(Kf(e,t,n),e._setActiveViewer?.(r))},()=>{fu.delete(e),hu(e)})}function Kf(e,t,n){Vf(e.termWrap,e,n),Wf(e,t)}function qf(e){e?._syncGridOnEngagementEdge?.()}function Jf(e,t){if(!e)return;Gf(e,t),au(e,t),Xo(e);let n=e.term;n&&(n.refresh(0,n.rows-1),qf(e))}function Yf(e,t,n){e&&(n&&Gf(e,t),e._setActiveViewer?.(n))}var Xf={isVisible:document.visibilityState===`visible`,isFrozen:!1,isProbing:!1,isReplacing:!1},Zf=document.visibilityState===`visible`?null:Date.now(),Qf=null,$f=null;function ep(){Qf!==null&&window.clearTimeout(Qf),Qf=null}function tp(e){ep();let t=Date.now()+e;Qf=window.setTimeout(()=>{Qf=null,ip({kind:`heartbeat-due`,lateByMs:Date.now()-t})},e)}function np(){$f!==null&&window.clearTimeout($f),$f=null}function rp(e){switch(e.kind){case`probe-control`:_(e.deadlineMs,e.isAnnounced).then(e=>{ip({kind:e?`pong`:`pong-missed`})});return;case`replace-control`:o();return;case`close-sockets`:np(),v(),Nu();return;case`reconnect-shown-terminals`:ju();return;case`hold-input`:Hf();return;case`release-input`:Uf();return;case`schedule-heartbeat`:tp(e.inMs);return;case`cancel-heartbeat`:ep();return}}function ip(t){let n=e(Xf,t);Xf=n.state;for(let e of n.actions)rp(e)}function ap(){if(document.visibilityState!==`visible`){Zf=Date.now(),ip({kind:`hidden`});return}let e=Zf===null?0:Date.now()-Zf;Zf=null,Lo(`shown`,e),ip({kind:`shown`,hiddenForMs:e})}function op(e){np(),Fo(`control-${e}`),e===`connecting`?$f=window.setTimeout(()=>{$f=null,ip({kind:`handshake-overdue`})},t):(e===`opened`&&yo(),ip({kind:e===`opened`?`control-opened`:`control-closed`}))}function sp(){Lo(`resumed`,Zf===null?0:Date.now()-Zf),ip({kind:`resumed`})}function cp(){let e=Reflect.get(navigator,`connection`);e instanceof EventTarget&&e.addEventListener(`change`,()=>{Io(`link`),ip({kind:`network-changed`})})}function lp(){m(op),document.addEventListener(`visibilitychange`,ap),document.addEventListener(`freeze`,()=>ip({kind:`frozen`})),document.addEventListener(`resume`,sp),window.addEventListener(`pagehide`,e=>{e.persisted&&ip({kind:`frozen`})}),window.addEventListener(`pageshow`,e=>{e.persisted&&sp()}),window.addEventListener(`online`,()=>{Io(`online`),ip({kind:`network-changed`})}),window.addEventListener(`offline`,()=>Io(`offline`)),cp()}var up=!1,dp=!1,fp=!1,pp=null,mp=null;function hp(){return mp??=j(()=>import(`./nyan-cat-CyLs6Ah3.js`).then(e=>e.r).then(e=>(pp=e,e),e=>(mp=null,y(`flying-animals`,`nyan cat failed to load: ${l(e)}`),null)),__vite__mapDeps([2,1,3,4,5,6,7,8])),mp}function gp(e){!fp||e.currentFlightBlockReason(!0)?e.stopNyanCat():e.startNyanCat()}function _p(){dp=!0,vp(ri())}function vp(e){let t=document.documentElement;up||(up=!0,ds(()=>vp(ri())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>vp(ri()))),fp=e,e?(t.dataset.flyingAnimals=`true`,pp?gp(pp):dp&&hp().then(e=>{e&&gp(e)})):(delete t.dataset.flyingAnimals,pp?.stopNyanCat())}var yp=45e3,bp=`The server did not answer within ${yp/1e3} s.`,xp=`Select the issue to load its description.`,Sp=null,Cp=null,wp=new Map,Tp=null,Ep=new Map,Dp=new Map,Op=null,kp=new Map,Ap=new Map,jp=new Map,Mp=new Map,Np=new Set;function N(e){for(let t of Np)t(e)}function Pp(e){return`${e.key}:${e.updatedAt}`}function Fp(e){let t=Ep.get(e);t&&(Ep.delete(e),kp.set(t.issueKey,{text:bp,tone:`error`}),N(`detail`))}function Ip(e){let t=Ep.get(e);return t?(clearTimeout(t.timeoutHandle),Ep.delete(e),t):null}function Lp(){return{latestStatus:Cp,issueByKey:wp,selectedKey:Sp}}function Rp(e){Np.add(e)}function zp(e){Sp=e,Op&&Op.issue.key!==e&&(Op=null)}function Bp(){if(Sp)return wp.get(Sp)??(Op?.issue.key===Sp?Op.issue:void 0)}function Vp(e){return Op?.issue.key===e.key&&Op.isClosed}function Hp(e){return[...Dp.values()].some(t=>t.issue.key===e.key)}function Up(e,t){if(Hp(e))return;let n=d(`set-issue-state`);Tp?.({type:`set-issue-state`,requestId:n,repo:e.repo,issueNumber:e.number,state:t})?(Dp.set(n,{issue:e,state:t,timeoutHandle:setTimeout(()=>{Dp.delete(n),kp.set(e.key,{text:bp,tone:`error`}),N(`detail`)},yp)}),kp.set(e.key,{text:t===`closed`?`Closing issue.`:`Reopening issue.`,tone:`busy`}),N(`detail`)):(kp.set(e.key,{text:x,tone:`error`}),N(`detail`))}function Wp(e){let t=Dp.get(e.requestId);if(!t)return;clearTimeout(t.timeoutHandle),Dp.delete(e.requestId);let{issue:n,state:r}=t;e.ok?(Op={issue:n,isClosed:r===`closed`},kp.set(n.key,{text:r===`closed`?`Closed as completed.`:`Reopened.`,tone:`ok`}),N(`detail`)):(kp.set(n.key,{text:e.error||`Could not ${r===`closed`?`close`:`reopen`} the issue.`,tone:`error`}),N(`detail`))}function Gp(e){return[...Ep.values()].some(t=>t.issueKey===e.key)}function Kp(e){return kp.get(e.key)}function qp(e){let t=Pp(e),n=jp.get(t);return n===``?`No description.`:n??Mp.get(t)??`Loading description.`}function Jp(e){let t=Pp(e);if(jp.has(t)||[...Ap.values()].some(e=>e.cacheKey===t))return;let n=d(`issue-detail`);Mp.delete(t),Tp?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?Ap.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{Ap.delete(n),Mp.set(t,`${bp} ${xp}`),N(`detail`)},yp)}):Mp.set(t,`${x} ${xp}`)}function Yp(e){let t=e.projectId;if(!t||Gp(e))return;let n=d(`open-issue-session`);Tp?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(Ep.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>Fp(n),yp)}),kp.set(e.key,{text:`Opening session.`,tone:`busy`}),N(`detail`)):(kp.set(e.key,{text:x,tone:`error`}),N(`detail`))}function Xp(e){Tp?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function Zp(e){Tp=e}function Qp(){N(`session-state`)}function $p(e){if(!e){for(let e of Ep.values())clearTimeout(e.timeoutHandle),kp.set(e.issueKey,{text:x,tone:`error`});Ep.clear();for(let e of Dp.values())clearTimeout(e.timeoutHandle),kp.set(e.issue.key,{text:x,tone:`error`});Dp.clear();for(let e of Ap.values())clearTimeout(e.timeoutHandle),Mp.set(e.cacheKey,`${x} ${xp}`);Ap.clear(),N(`status`)}}function em(e){let t=Cp?.issues.find(e=>e.key===Sp);Cp=e,wp=new Map(e.issues.map(e=>[e.key,e])),Op&&!Op.isClosed&&wp.has(Op.issue.key)&&(Op=null);let n=e.issues.find(e=>e.key===Sp);n&&n.updatedAt!==t?.updatedAt&&Jp(n),N(`status`)}function tm(e){let t=Ap.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),Ap.delete(e.requestId),e.ok&&e.body!==null&&jp.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.`),N(`detail`))}function nm(e){if(typeof e.requestId!=`string`)return;let t=Ip(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`;kp.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=Cp?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),N(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;kp.set(n,{text:r,tone:`error`}),N(`detail`)}var rm=new Map,im=new Set;function am(e){let t=ze.safeParse(e);if(!t.success)y(`reviews`,`dropped github-prs: ${r(t.error.issues)}`);else{rm=new Map(Object.entries(t.data.prs));for(let e of im)e()}}function om(e){return rm.get(e.toLowerCase())}function sm(e){im.add(e)}var cm=20,lm=[],um=null,dm=!1,fm=0,pm=null;function mm(){return pm??=j(()=>import(`./celebration-player-k9KDERaX.js`),__vite__mapDeps([9,10,6,3,4,5,7])).catch(e=>(pm=null,y(`merge-celebration`,`celebration player failed to load: ${l(e)}`),null)),pm}function hm(e){return dm?`playing`:e?`queued`:`empty`}function gm(){if(!um)return;let e=lm.length>0,t=hm(e);um.tray.dataset.state=t,um.count.textContent=e?String(lm.length):``,um.toggle.element.disabled=t!==`queued`,um.toggle.setState(t===`queued`?`attention`:`idle`)}function _m(){let e=lm.shift();if(dm=e!==void 0,gm(),!e)return;let t=fm;fm+=1,mm().then(n=>{n?(n.playCelebration(e,t),window.setTimeout(_m,n.CELEBRATION_DURATION_MS)):(lm.unshift(e),dm=!1,gm())})}function vm(e,t,n){um={tray:e,toggle:t,count:n},t.element.addEventListener(`click`,()=>{fm=0,_m()}),gm()}function ym(e){lm.push(e),lm.length>cm&&lm.shift(),gm()}var bm={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},xm=new Set([`FAILURE`,`ERROR`]);function Sm(e){return bm[e]}function Cm(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&&xm.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function wm(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 Tm(e){let t=Bt.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:wm(t)}}var Em=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],Dm=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],Om={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`},km={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`},Am={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`},jm={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 Nm(e){return Em[e.rows.reduce((e,{pr:t})=>Math.min(e,Em.indexOf(Om[t.stage])),Em.length-1)]}function Pm(e){let t=new Map(Em.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of Mm(e)){let e=t.get(Nm(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return Dm.flatMap(e=>t.get(e)??[])}function Fm(e,t){return Mm(e).find(e=>e.rows.some(e=>e.pr.key===t))?.rows??[]}function Im(e){return e.stackSize<2?null:`Stack ${e.depth+1}/${e.stackHeight}`}function Lm(e){return km[e]}function Rm(e){return Am[e]}function zm(e){return jm[e]}function Bm(e){return e?.isKeepMergeableEnabled!==!1}function Vm(e,t){if(!t||!e.keepMergeable||e.isKeepMergeableFixInFlight)return!1;let n=e.keepMergeableAttempt?.outcome;return n!==void 0&&n!==`pushed`&&n!==`stopped`}function Hm(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...Tm({...n,repo:r}),...e}]})}function Um(e){let t=new Map;for(let n of e)for(let e of n.links){let r=Oe(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 Wm(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 Gm=3;function Km(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,Gm).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 qm(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:Qt(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,isAuthorOrgMember:n.isAuthorOrgMember,liveHead:n.headRefOid,prStage:Tm(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n)}}var Jm=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`];function Ym(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 Xm(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function Zm(e){return e.status===`posted`&&Qm(e)}function Qm(e){if(!Xm(e)||kt(e))return!1;let t=rh(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 $m(e){return ih(e).length>0||Zm(e)}function eh(e){return $m(e)?`actionable`:Ym(e).band}function th(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[Ym(t).band].push(t);for(let e of Jm)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($m(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!ah(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[eh(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 Jm)t.ready.push(...n[e]);return t}function nh(e,t){return e.commit===t?e.isViewer||Tt.has(e.state):!1}function rh(e){return e.liveHead??e.reviewedHead}function ih(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function ah(e){return ih(e).length>0?!0:kt(e)?!1:Qm(e)?!0:!(e.githubReviews??[]).some(t=>nh(t,rh(e)))}function oh(e,t){return`${e}#${t}`}var sh=null,ch={},lh=[],uh=[],dh={},fh={},ph=[],mh={},hh={},gh={},_h=null,vh=new Set,yh=new Map,bh=!1,xh=new Set;function Sh(e){for(let t of xh)t(e)}function Ch(){return[...yh].flatMap(([e,t])=>{let n=O.get(e);return!n||t.length===0?[]:[{id:e,title:ar(n)||e,links:t}]})}function wh(){let e=Hm(sh?.prs??[],om),t=Wm(_h,e);_h=e,Oh(t),Sh({kind:`prs`})}function Th(){bh||(bh=!0,queueMicrotask(()=>{bh=!1,wh()}))}function Eh(e){xh.add(e)}function Dh(){return{prs:Hm(sh?.prs??[],om).map(e=>({...e,reviewItems:fh[e.key]??e.reviewItems})),status:sh,sessionsByPrKey:Um(Ch()),handledByPr:ch,prFlowWarnings:lh,prFlowApprovals:uh,sourceRunsByPr:dh,prFlowActions:ph,actionRunsByPr:mh,prActionsByPr:hh,prActionRunsByPr:gh}}function Oh(e){let t=e.filter(e=>!vh.has(e.key));if(t.length!==0){for(let e of t)vh.add(e.key);ym(Km(t))}}function kh(e){yh=e,Th()}function Ah(){Sh({kind:`session-state`})}function jh(e){let t=xt.safeParse(e);t.success?(sh=t.data,wh()):y(`reviews`,`dropped my-prs-status: ${r(t.error.issues)}`)}function Mh(e){let t=yt.safeParse(e);t.success?(ch=t.data.handledByPr,lh=t.data.warnings,uh=t.data.pendingApprovals,dh=t.data.sourceRunsByPr,fh=t.data.reviewItemsByPr,ph=t.data.actions,mh=t.data.actionRunsByPr,hh=t.data.prActionsByPr,gh=t.data.prActionRunsByPr,Sh({kind:`prs`})):y(`reviews`,`dropped pr-flows-status: ${r(t.error.issues)}`)}function Nh(e){Sh({kind:`merge-result`,message:e})}function Ph(e){Sh({kind:`connection`,isConnected:e})}sm(Th);var Fh=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}])),Ih={turn:`Your turn`,working:`Agent working`,queued:`Queued`,waiting:`Waiting on others`,done:`Done`,parked:`Parked`,aside:`Set aside`},Lh=[`turn`,`working`,`queued`,`waiting`,`done`,`parked`],Rh=new Set([`done`,`parked`]),zh=[`queued`,`working`,`turn`,`now`,`waiting`,`done`,`parked`],Bh={...Ih,turn:`Ready`,now:`Reviewing now`};function Vh(e){return zh.map(t=>e.find(e=>e.id===t)??{id:t,title:Bh[t],items:[]})}function Hh(e,t){let n=new Set(yg(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:Bh.now,items:e.items.filter(e=>i.has(e.key))},{id:`turn`,title:Bh.turn,items:e.items.filter(e=>!i.has(e.key))}]:[e]),pulledKeys:r}}function Uh({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 Wh(e,t){return t>0?`${e} / ${t}`:String(e)}var Gh={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`},Kh={settled:`review-settled`,inReview:`review-in-flight`,queued:`review-queued`,posted:`review-posted`,discarded:`review-discarded`},qh=Jm.indexOf(`waiting-on-author`);function Jh(e){return e.status===`ready`?Ym(e).band===`blocking-others`?`review-direct-ask`:`review-ready`:`review-follow-up`}function Yh(e,t){return t===`ready`?Jh(e):t===`attention`?`status`in e&&e.status===`error`?`review-failed`:`review-stale`:Kh[t]}function Xh(e,t,n){let r=e.state===`OPEN`;if(r&&Vm(e,n))return`mine-repair-failed`;if(r&&n&&e.keepMergeable&&e.isKeepMergeableFixInFlight)return`mine-repairing`;let i=Gh[e.stage];return Fh.get(i)?.group===`turn`&&e.stage!==`ready`&&t.has(Oe(e))?`mine-agent-fixing`:i}function Zh(e,t){return t===`ready`||t===`attention`?Jm.indexOf(eh(e)):t===`queued`?Jm.indexOf(Ym(e).band):0}function Qh(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function $h(e){let t=ih(e).flatMap(e=>Qh(e.lastReplyAt)??[]);return t.length>0?Math.max(...t):null}function eg(e,t){if(t===`inReview`)return Qh(e.startedAt)??1/0;if(t===`queued`)return Qh(e.prCreatedAt)??1/0;let n=e,r=t===`posted`?Qh(n.postedAt):null;return $h(n)??r??Qh(n.reviewedAt)??Qh(n.prCreatedAt)??1/0}function tg(e){return Qh(e.mergedAt??e.stageSinceMs??e.updatedAt)??1/0}var ng=864e5,rg=3*ng;function ig(e){return e.source===`team`?eg(e.review,e.kind):tg(e.pr)}function ag(e,t,n){if(e===`done`||e===`parked`||!Number.isFinite(t))return null;let r=n-t;return r>rg?`old`:r>=ng?`aging`:`fresh`}function og(e,t){return t>0&&e>t}function sg(e,t,n,r){let i=Fh.get(e);return i?[{item:r(i),row:i,priorityBandRank:t,waitStartMs:n}]:[]}function cg(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=>sg(Yh(t,e),Zh(t,e),eg(t,e),({action:n,kind:r})=>({source:`team`,key:`team:${t.key}`,prKey:Oe(t),kind:e,review:t,action:n,attention:r}))))}function lg(e,t,n){return Pm(e).flatMap(e=>e.rows).flatMap(e=>sg(Xh(e.pr,t,n),0,tg(e.pr),({action:t,kind:n})=>({source:`mine`,key:`mine:${e.pr.key}`,prKey:Oe(e.pr),pr:e.pr,stackRow:e,action:t,attention:n})))}function ug(e){return e.row.kind===`failed`?0:e.row.state===`review-direct-ask`?1:e.priorityBandRank>=qh?3:2}function dg(e,t){let n=e.waitStartMs-t.waitStartMs;return e.row.group===`turn`?ug(e)-ug(t)||n||e.item.key.localeCompare(t.item.key):e.row.rank-t.row.rank||e.priorityBandRank-t.priorityBandRank||n}function fg(e,t,n,r){let i=new Map(Lh.map(e=>[e,[]]));for(let a of[...cg(e),...lg(t,n,r)])i.get(a.row.group)?.push(a);return Lh.map(e=>({id:e,title:Ih[e],items:(i.get(e)??[]).toSorted(dg).map(e=>e.item)}))}var pg=[`turn`,`working`,`aside`],mg=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 hg(e){return e.status===`ready`&&e.verdict?`ready-${e.verdict}`:e.status}function gg(e){let t=Date.parse(e.item.createdAt);return Number.isNaN(t)?1/0:t}function _g(e){let t=e.flatMap(e=>{let t=mg.get(hg(e));return t?[{row:t,askedAtMs:gg(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 pg.map(e=>({id:e,title:Ih[e],items:t.filter(t=>t.row.group===e).map(e=>e.item)}))}function vg(e){return`${e.key}@${e.entry.status}:${e.entry.finishedAt??``}`}function yg(e){return e.find(e=>e.id===`turn`)?.items??[]}function bg(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function xg(e,t){return bg(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function Sg(e){return e.source===`mine`?oh(e.pr.repo,e.pr.number):oh(e.review.repo,e.review.number)}function Cg(e,t){return yg(e).map(e=>({id:e.key,kind:e.attention??`waiting`,name:t(e)}))}function wg(e){return Cg(e,Sg)}function Tg(e,t){return wg(e).filter(e=>e.id!==t)}function Eg({capturedOrder:e,actedKey:t,groups:n}){let r=yg(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 Dg=new Set([`turn`,`now`]);function Og(e,t){let n=e.find(e=>Dg.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 kg(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 Ag(e){return yg(e).map(kg)}function jg({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:ft([...i]),unseen:ft([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:ft([...a]),unseen:ft([...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 Ng(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function Pg(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 Fg=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 Ig(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`:Fg.get(e.key)??null}function Lg(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 Rg(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 zg=null,Bg=null,Vg=new Set;function Hg(e){for(let t of Vg)t(e)}function Ug(){Bg=qm(zg,om),Hg({kind:`status`})}function Wg(e){Vg.add(e)}function Gg(){return Bg}function Kg(){return th(Bg)}function qg(e){let t=wt.safeParse(e);t.success?(zg=t.data,Ug()):y(`reviews`,`dropped team-review-status: ${r(t.error.issues)}`)}function Jg(e){Hg({kind:`action-result`,message:e})}function Yg(e){Hg({kind:`open-session-result`,message:e})}function Xg(e){Hg({kind:`connection`,isConnected:e})}sm(Ug);var Zg=[],Qg=null,$g=null,e_=null,t_=!1,n_=null,r_=mi(),i_=Di(),a_=new Set(i_.split(`|`).filter(Boolean)),o_=new Set,s_=new Set;function c_(e){for(let t of s_)t(e)}function l_(e){e!==r_&&(r_=e,si(e))}function u_(e){e!==i_&&(i_=e,a_=new Set(e.split(`|`).filter(Boolean)),$r(e))}function d_(){return Gg()!==null&&Dh().status!==null}function f_(){if(!d_())return;let e=jg({turnEntries:Ag(Zg),acknowledged:r_,unseen:i_,isLooking:$g?.isLooking()??!1});l_(e.acknowledged),u_(e.unseen),n_?.(e.isShown)}function p_(e){e_=e,c_({kind:`reveal`})}function m_(e){s_.add(e)}function h_(e){$g=e,f_()}function g_(){let{prs:e,sessionsByPrKey:t,status:n}=Dh();return Zg=fg(Kg(),e,new Set(t.keys()),Bm(n)),f_(),Zg}function __(){d_()&&(l_(ft(Ag(Zg))),f_())}function v_(e){n_=e,f_()}function y_(){return i_}function b_(e){return a_.has(e)}function x_(e){return a_.has(e)?(u_(ft([...a_].filter(t=>t!==e))),!0):!1}function S_(e){Qg=e}function C_(){return Qg}function w_(){let e=e_;return e_=null,e}function T_(e){if(e!==t_){t_=e;for(let e of o_)e()}}function E_(e){o_.add(e)}function D_(){return document.documentElement.dataset.layout===`phone`&&t_}function O_(){D_()&&c_({kind:`return-to-queue`})}function k_(){let e=Tg(Zg,$g?.selectedKey()??null)[0]?.id??null;return e?(p_(e),!0):!1}function A_(e){let t=Zg.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!Qg?.openReviews()?!1:(p_(t.key),__(),!0)}Wg(e=>{e.kind===`status`&&g_()}),Eh(e=>{e.kind===`prs`&&g_()});function j_(){return{groups:Zg}}var M_={OPEN:0,MERGED:1,CLOSED:2};function N_(e){return e?M_[e.state]:M_.OPEN}function P_(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:gn(void 0)};let i=Rm(t.stage);return{key:n,text:r,detailText:`${r} ${t.title}`,stateText:Lm(t.stage),url:t.url,prTitle:t.title,look:{icon:zm(t.stage),tone:i},tier:gn(i)}}function F_(e,t){let n=e.map(e=>{let n=t(Oe(e));return{link:e,pr:n?Tm(n):void 0}});return n.sort((e,t)=>N_(e.pr)-N_(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>P_(e,t))}var I_=new Map;function L_(e){return document.querySelectorAll(`[data-pr-rows-for="${CSS.escape(e)}"]`)}function R_(e){return F_(I_.get(e)??[],om).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,onActivate:()=>{A_(e.key)||bd(e.url)}}))}function z_(e,t){let n=Ve(`session-pr-chip-unlink`);return n.append(Ee(ut)),n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),$t({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:()=>{ua(t,{type:`unlink-session-pr`,id:t,key:e.key})}})}),n}function B_(e,t){let n=_n({...e,text:e.key},{...e,className:`linked-pr-row-link`});e.prTitle&&n.append(T(`span`,`linked-pr-row-title`,e.prTitle)),e.stateText&&n.append(T(`span`,`linked-pr-row-stage`,e.stateText));let r=T(`li`,`linked-pr-row`);return r.append(n,z_(e,t)),r}function V_(e,t){e.dataset.prRowsFor=t;let n=R_(t);on(e,n,e=>B_(e,t),{visibleCount:n.length})}function H_(e){for(let t of e){let e=t.dataset.prRowsFor;e&&V_(t,e)}}function U_(e,t){let n=Yt.shape.links.safeParse(t??[]);I_.set(e,n.success?n.data:[]),H_(L_(e)),Sn(e),kh(I_)}function W_(e){I_.delete(e),kh(I_)}sm(()=>{H_(document.querySelectorAll(`[data-pr-rows-for]`)),In()});function P(e){return String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function G_(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function K_(e,t){return e||G_(t)>0}var q_={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},J_=null,Y_=!1,X_=!1,Z_=null,Q_=null,$_=null,ev=`—`;function tv(e){return e==null?ev:ht(e,`GB`)}function nv(e){return e==null?ev:he(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function rv(e){return e==null?ev:`${nv(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function iv(){let e=T(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=T(`div`,`health-summary`),n=Ve(`health-toggle`);n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=T(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,T(`span`,`health-toggle-label`,`Health`));let i=T(`div`,`health-stats`);t.append(n,i);let a=T(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{X_=!X_,e.dataset.expanded=String(X_),n.setAttribute(`aria-expanded`,String(X_)),a.hidden=!X_,X_&&(s({type:`request-health-snapshot`}),ov())}),e.append(t,a),Z_=e,Q_=i,$_=a,e}function av(){if(!Q_||!J_)return;let e=J_,t=G_(e.anomalies);Q_.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-Y4DKSNpt.js","assets/dom-helpers-1xKy7VX6.js","assets/zod-CeKr261e.js","assets/ui-prefs-D3kfa1nO.js","assets/alert-sound-core-CmJhj4qI.js","assets/local-store-CVQ5ByvB.js","assets/nyan-geometry-core-C8RryYMH.js","assets/celebration-player-k9KDERaX.js","assets/alert-sound-At4lBeip.js","assets/doc-editor-ui-DsshrSMT.js","assets/action-status-CYnvXmb6.js","assets/button-CMQWs0VA.js","assets/control-ws-7yhbi9n0.js","assets/modal-CrCrVLFZ.js","assets/plan-render-Bi_AbHKi.js","assets/whiteboard-undo-core-D1P82mGD.js","assets/doc-editor-ui-D7opSzf1.css","assets/resume-dialog-Ct0dtFpq.js","assets/card-actions-CELKX1cn.js","assets/card-registry-BM0Py2ky.js","assets/plan-face-p_Q4xZ-H.js","assets/roving-keys-core-BDobx2It.js","assets/ui-state-core-Nssh-6QJ.js","assets/plan-face-CNqLL3OW.css","assets/phone-shell-BfUzchP7.js","assets/agent-core-5pahO20g.js","assets/preload-helper-BLdHbfdN.js","assets/session-tick-BCeOQ9qf.js","assets/session-row-B54nJze6.js","assets/menu-D8rPo2sW.js","assets/agent-mark-BQ6GWoMr.js","assets/pr-status-icon-wvSUvmPS.js","assets/first-run-checklist-BlWuVccS.js","assets/repo-roots-adder-CRwLG3jd.js","assets/setup-step-CR1WGQhX.js","assets/boards-view-C2KW_DGj.js","assets/boards-view-CfBtlabY.css","assets/review-queue-panel-CyUV0h31.js","assets/lane-read-token-step-smGOCQpS.js","assets/lane-read-token-step-uxHqFrcY.css","assets/my-prs-panel-CrDSZpdN.js","assets/pr-queue-columns-BM9haK7M.js","assets/team-review-settings-core-BtFK1LdQ.js","assets/issues-panel-Dgy6w2wP.js","assets/issues-panel-1vb6hHuv.css","assets/usage-panel-CrAJMOkk.js","assets/chart-readout-DxD0pyUY.js","assets/usage-panel-DV0ckKqY.css","assets/radar-panel-CutSh8oR.js","assets/dialogs-D7hBCR1a.js","assets/radar-panel-LHOTTm1M.css","assets/community-panel-C0yACNBn.js","assets/community-panel-DR_-RgSK.css","assets/hooks-panel-BHe0NfgP.js","assets/hooks-panel-BUBv4dvX.css","assets/trace-panel-CxF4QOxU.js","assets/trace-panel-D-AIzBSZ.css","assets/arena-panel-ESQaDRzw.js","assets/arena-panel-CCEwG0WI.css","assets/settings-panel-mMlTwl2_.js","assets/flying-animal-preview-C9Ds134f.js","assets/settings-panel-vHjG4OTM.css","assets/feature-hint-DeKRVPni.js","assets/feature-hint-Dm-eD9Sz.css","assets/your-day-tip-Cjr_jrYW.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 ee,w as te,x as ne,y as b}from"./control-ws-7yhbi9n0.js";import{f as re,l as ie,n as ae,p as oe,s as se,v as ce}from"./zod-CeKr261e.js";import{A as le,At as ue,Bt as de,C as fe,Ct as pe,D as me,Dt as he,E as ge,Et as _e,Ft as ve,G as ye,It as be,J as xe,K as Se,Lt as Ce,M as x,Mt as we,Nt as Te,O as Ee,Ot as S,Pt as De,Qt as Oe,R as ke,Rt as Ae,S as je,T as Me,Tt as Ne,U as Pe,V as Fe,Vt as Ie,Xt as Le,Z as Re,Zt as ze,_ as Be,a as Ve,b as He,c as Ue,cn as We,f as Ge,g as Ke,h as qe,hn as Je,i as Ye,in as Xe,j as Ze,kt as Qe,l as $e,mn as et,nn as tt,on as nt,p as rt,q as it,rn as at,s as ot,sn as st,st as ct,t as C,tn as lt,u as ut,ut as dt,vt as ft,wt as pt,x as mt,xt as ht,y as gt,yt as _t}from"./button-CMQWs0VA.js";import{$ as vt,$t as yt,Bn as bt,Ct as xt,Gn as St,Jn as Ct,Lt as wt,Ot as Tt,Pn as Et,S as Dt,Vn as Ot,Vt as kt,X as At,Xn as jt,Yn as Mt,_ as Nt,_n as Pt,ar as Ft,b as It,cn as Lt,f as Rt,g as w,h as zt,ht as Bt,ln as Vt,n as Ht,on as Ut,p as Wt,s as T,sn as Gt,t as Kt,tr as qt,u as Jt,un as E,wt as Yt,xn as Xt,zn as Zt,zt as Qt}from"./dom-helpers-1xKy7VX6.js";import{a as $t,i as en,n as tn,r as nn,t as rn}from"./modal-CrCrVLFZ.js";import{A as an,C as on,D as sn,E as cn,F as ln,I as un,L as dn,M as fn,N as pn,O as mn,P as hn,R as gn,S as _n,T as vn,_ as yn,a as bn,b as xn,c as Sn,d as Cn,f as wn,g as Tn,h as En,i as Dn,j as On,k as kn,l as An,m as jn,n as Mn,o as Nn,p as Pn,r as Fn,s as In,t as Ln,u as Rn,v as zn,w as Bn,x as Vn,y as Hn}from"./session-row-B54nJze6.js";import{i as Un,n as Wn,t as Gn}from"./agent-mark-BQ6GWoMr.js";import{A as Kn,B as qn,D as Jn,E as Yn,F as Xn,I as Zn,L as Qn,N as $n,O as er,P as tr,R as nr,S as rr,_ as ir,a as ar,b as or,c as sr,f as cr,g as lr,i as D,j as ur,k as dr,n as fr,o as O,p as pr,r as k,s as mr,t as hr,u as gr,w as _r,x as vr,y as yr,z as br}from"./card-registry-BM0Py2ky.js";import{n as A,t as xr}from"./ui-state-core-Nssh-6QJ.js";import{t as j}from"./preload-helper-BLdHbfdN.js";import{c as Sr,i as Cr,n as wr,o as Tr,r as Er,s as Dr,t as Or,u as kr}from"./action-status-CYnvXmb6.js";import{a as Ar,c as jr,i as Mr,n as Nr,o as Pr,r as Fr,s as Ir,t as Lr}from"./session-tick-BCeOQ9qf.js";import{n as Rr,t as zr}from"./local-store-CVQ5ByvB.js";import{$ as Br,A as Vr,Ct as Hr,D as Ur,E as Wr,Et as Gr,F as Kr,G as qr,Gt as Jr,I as Yr,M as Xr,O as Zr,P as Qr,Q as $r,Rt as ei,S as ti,St as ni,T as ri,Tt as ii,Ut as ai,Vt as oi,X as si,_t as ci,a as li,b as ui,bt as di,c as fi,ct as pi,d as mi,et as hi,ft as gi,gt as _i,h as vi,ht as yi,i as bi,k as xi,l as Si,lt as Ci,m as wi,mt as Ti,ot as Ei,p as Di,pt as Oi,r as ki,t as Ai,tt as ji,u as Mi,vt as Ni,w as Pi,wt as Fi,x as Ii,xt as Li,yt as Ri,zt as zi}from"./ui-prefs-D3kfa1nO.js";import{A as Bi,C as Vi,D as Hi,E as Ui,F as Wi,M as Gi,N as Ki,O as qi,S as Ji,T as Yi,b as Xi,c as Zi,f as Qi,g as $i,h as ea,j as ta,k as na,l as ra,m as ia,p as aa,u as oa,v as sa,w as ca,x as la,y as ua}from"./agent-core-5pahO20g.js";import{n as da}from"./menu-D8rPo2sW.js";import{t as fa}from"./pr-status-icon-wvSUvmPS.js";import{n as pa,t as ma}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 ha={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},ga=null,_a=null,va=!0,ya=new Map,ba=new Map,xa=new Set;function Sa(){for(let e of xa)e()}function Ca(e){xa.add(e)}function wa(){return{status:ga,isServerConnected:va,pendingActionBySuite:ya,outcomeBySuite:ba}}function Ta(e){_a=e}function Ea(e,t){_a?.({type:`benchmark-action`,requestId:d(`benchmark`),suiteId:e,action:t})===!0?(ya.set(e,t),ba.set(e,ha[t]),Sa()):(ba.set(e,x),Sa())}function Da(e){if(va=e,!e){for(let e of ya.keys())ba.delete(e);ya.clear()}Sa()}function Oa(e){ga=e,Sa()}function ka(e){ya.delete(e.suiteId);let t=ga?.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.`};ba.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),Sa()}function Aa({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=nn({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=T(`div`,`coherence-journal-header`),s=T(`h3`,`dialog-title`,t);s.id=n;let c=C({variant:`secondary`,label:`Close`,action:`close-coherence-panel`,onClick:i});return o.append(s,c),a.dialog.append(o,...r),rn(a.dialog,s.id),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function ja({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=Aa({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 Na(e){return e?.active!==!1||e.reason===At.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,detailText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:dn.broken}]}function Pa(e){let t=lt.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 Fa(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 Ia=new Map,La=new Map,Ra=ja({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function za(e,t){La.delete(e),t&&La.set(e,t),Ga(e)}function Ba(e){Ia.delete(e),La.delete(e);let t=Ra.currentPanel();t?.sessionId===e&&t.close()}function Va(e){let t=Ia.get(e.id);t&&t.updatedAt>e.updatedAt||(Ia.set(e.id,e),Ga(e.id))}function Ha(e){Ia.clear();for(let[t,n]of Object.entries(e.sessions))Ia.set(t,n);let t=Ra.currentPanel();t&&Ga(t.sessionId)}function Ua(e){return Na(La.get(e)??null).map(t=>({...t,onActivate:()=>Ka(e)}))}function Wa(e){return Ia.get(e)?.journal.ok===!0}function Ga(e){let t=Ra.currentPanel();if(!t||t.sessionId!==e)return;let n=Fa(La.get(e)??null,Ia.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>T(`p`,null,e)))}function Ka(e){let t=T(`div`,`coherence-journal-reading`),n=T(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=T(`div`,`coherence-journal-entries`);Ra.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>Ga(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function qa(e){let t=Ra.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=Pa(e),n=T(`article`,`coherence-journal-entry`);return n.append(T(`h4`,null,t.heading),T(`p`,null,t.text)),t.detail&&n.append(T(`p`,null,t.detail)),t.supersedes&&n.append(T(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var Ja=new Set([`waiting`,`monitoring`]);function Ya(e){return Object.fromEntries(de.flatMap(t=>{let n=Ja.has(t)?8:6;return[[`--state-${t}`,e[t]],[`--state-${t}-bg`,`color-mix(in oklab, var(--state-${t}) ${n}%, transparent)`]]}))}function Xa(e){return{...Object.fromEntries(Object.entries(e.chrome).map(([e,t])=>[`--${e}`,t])),...Ya(e.states)}}var Za={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`}},Qa={dark:{black:`--border`,brightBlack:`--text-muted`,white:`--text`,brightWhite:`--text-head`},light:{black:`--text-head`,brightBlack:`--text-dim`,white:`--text-dim`,brightWhite:`--text`}},$a=.35;function eo(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 to(e){if(e.accentAnsiSlot===`none`)return{};let t=`bright${e.accentAnsiSlot[0].toUpperCase()}${e.accentAnsiSlot.slice(1)}`;return{[e.accentAnsiSlot]:`--accent`,[t]:eo(e.chrome.accent,$a)}}function no(e){return{label:e.label,colors:{...Xa(e),...Un(e.mode)},terminal:{background:`--bg-card`,foreground:`--text`,cursor:`--accent`,cursorAccent:`--bg-card`,...Qa[e.mode],...Za[e.mode],...to(e)}}}var ro={glimmer:no({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":no({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:no({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:no({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:no({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:no({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:no({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":no({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":no({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`}})},io=`glimmer`,ao=null,oo=null,so=null,co={};function lo(e){return Object.hasOwn(ro,e)?ro[e]:co[e]}function uo(e){co=Object.fromEntries(e.map(({id:e,palette:t})=>[e,no(t)]));let t=so??io,n=lo(t)?t:io;return n===oo&&!Object.hasOwn(co,n)?!1:(po(n),!0)}function fo(e){so=e,lo(e)&&po(e)}function po(e){let t=lo(e);if(!t)return;let n=oo;oo=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`&&ao?.()}function mo(e){ao=e}function ho(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function go(){let e=lo(oo||io);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 _o(){return{id:oo,colors:{...lo(oo??io)?.colors}}}function vo(){return Object.entries({...ro,...co}).map(([e,t])=>({id:e,label:t.label}))}function yo(){let e=go();e.background&&e.foreground&&s({type:`terminal-colors`,background:e.background,foreground:e.foreground})}var bo=3e4,xo=24,So=null,Co=[`Android`,`iPhone`,`iPad`,`Windows`,`Mac OS X`,`Linux`],wo=[/Firefox\/\d+/,/Edg\/\d+/,/Chrome\/\d+/,/Version\/\d+/];function To(){let e=navigator.userAgent,t=Co.find(t=>e.includes(t))??`unknown platform`;return`${wo.map(t=>t.exec(e)?.[0]).find(e=>e!==void 0)?.replace(`Version`,`Safari`)??`unknown browser`} on ${t}`}function Eo(){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 Do(){return[navigator.onLine?`online`:`offline`,...Eo()].join(` `)}function Oo(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 ko(e,t){let n=e.join(` `);if(n.length<=t)return n;let r=t-xo,i=Oo(e,r/2),a=Oo(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 Ao(e){return e.marks.some(e=>e.startsWith(`terminal-bytes`))}function jo(e){let t=Ao(e)&&!e.isCapped?`terminal live`:`terminal not live after ${bo/1e3} s`,n=`hidden ${Math.round(e.hiddenForMs/1e3)} s, ${t}, ${To()}, ${e.networkAtWake}: `,r=n+ko(e.marks,nt-n.length);return s({type:`client-log`,scope:`wake`,text:r.slice(0,nt)})}function Mo(){let e=So;e&&(e.isCapped||Ao(e))&&jo(e)&&(So=null,clearTimeout(e.capTimer))}function No(){So&&(So.isCapped=!0,Mo())}function Po(e,t){e.marks.push(`${t}+${Math.round(performance.now()-e.startedAtMs)}`)}function Fo(e){So&&(e===`terminal-bytes`&&Ao(So)||(Po(So,e),(e===`terminal-bytes`||e===`control-opened`)&&Mo()))}function Io(e){So&&Po(So,e===`link`?[`link`,...Eo()].join(`-`):e)}function Lo(e,t){So||={startedAtMs:performance.now(),hiddenForMs:t,networkAtWake:Do(),marks:[],isCapped:!1,capTimer:setTimeout(No,bo)},Fo(e)}function Ro(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function zo(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 Bo=null,Vo=null;function Ho(){return Bo}function Uo(){return Bo?Promise.resolve(Bo):(Vo??=Promise.all([j(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.t),__vite__mapDeps([0,1])),j(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.r),__vite__mapDeps([0,1])),j(()=>import(`./xterm-CJsd_Jt0.js`).then(e=>e.n),__vite__mapDeps([0,1]))]).then(([e,t,n])=>(Bo={Terminal:e.Terminal,FitAddon:t.FitAddon,WebglAddon:n.WebglAddon},Bo)).catch(e=>{throw Vo=null,e}),Vo)}var Wo=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,Go=new Map;function Ko(e){return e.clientWidth>0&&e.clientHeight>0}function qo(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 Jo(e){Go.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,qo(e)}function Yo(e){let t=[e],n=A.snapshot().borrowedCardId,r=n?O.get(n):void 0;r&&t.push(r);for(let e of zo([...Go.keys()],Wo,t))Jo(e),e.needsWebGLReload=!0}function Xo(e){e?.term&&Ro({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:Ko(e.termWrap)})&&ts(e,{isForced:!0})}function Zo(){for(let e of Go.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{Jo(e),e.needsWebGLReload=!0}}}var Qo=!1;function $o(){Qo||(Qo=!0,requestAnimationFrame(()=>{Qo=!1,Zo()}))}function es(e){e?.addEventListener(`contextrestored`,$o)}function ts(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){Go.delete(e),Go.set(e,!0);return}e.webglAddon&&(qo(e),Go.delete(e));let n=Ho();if(!n)return;Yo(e);let r=new n.WebglAddon;r.onContextLoss(()=>{r.dispose(),e.webglAddon=null,Go.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(es),r.onAddTextureAtlasCanvas(es),es(r.textureAtlas),e.webglAddon=r,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!Ko(e.termWrap),Go.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,Go.delete(e)}}var ns=`(max-width: 768px)`,rs=`(pointer: coarse)`;function is({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var as=window.matchMedia?.(rs),os=window.matchMedia?.(ns);function ss(){return is({coarse:!!as?.matches,narrowWidth:!!os?.matches})}function cs(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function ls(){A.subscribe((e,t)=>{t.includes(`layout`)&&cs(e.layout)});let e=ss();cs(e),A.dispatch(`setLayout`,e);let t=()=>A.dispatch(`setLayout`,ss());return as?.addEventListener?.(`change`,t),os?.addEventListener?.(`change`,t),e}function us(){return A.snapshot().layout===`phone`}function ds(e){return A.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var fs=``,ps=`\x1B`,ms=`\r`,hs=new Map([[`deleteContentBackward`,fs],[`deleteByComposition`,fs],[`deleteCompositionText`,fs],[`deleteWordBackward`,ps],[`deleteSoftLineBackward`,ps],[`deleteHardLineBackward`,ps]]);function gs(e){return hs.get(e)??``}var _s=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function vs(e){return typeof e!=`string`||e===``||!_s.has(e)}function ys(e){return e?e.keyCode===229||e.key===`Process`:!1}function bs(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 fs.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,ms)}var xs=`Upload`;async function Ss(e,t){return wr(xs,e),ws(e,t)}async function Cs(e,t){wr(xs,e);for(let n of t)await ws(e,n)}async function ws(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:(Tr({source:xs,sessionId:e,message:await Ts(r,t.name)}),!1)}catch{return Tr({source:xs,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 Ts(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 Es=new WeakMap,Ds=5e3,Os=15e3,ks=`The agent copied text. The browser needs a click before it can reach your clipboard.`,As=`The clipboard is unavailable in this browser.`;function js(e,t,n,r){let i=Es.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`?Ds:Os)))}function Ms(e,t){let n=Es.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function Ns(e){let t=e.buffer.active;return t.viewportY<t.baseY}function Ps(e,t,{hasNewOutput:n=!1}={}){let r=Es.get(e)?.jumpToLatest;if(!r)return;let i=Ns(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function Fs(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 Is(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),js(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function Ls(e,t,n,r){let i=It(t);i?i.then(()=>{r&&js(e,`clipboard`,`ok`,r)}).catch(t=>Is(e,n,t)):js(e,`clipboard`,`error`,As)}function Rs(e,t){let n=Es.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function zs(e){let t=Es.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,Ls(e,n,`osc52 write`,`Copied to the clipboard.`))}function Bs(e,t,n){let r=Cr(`terminal-notice`),i=T(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=C({variant:`primary`,label:`Copy to clipboard`,onClick:()=>zs(t)});i.append(T(`span`,`terminal-clipboard-prompt-text`,ks),a);let o=T(`div`,`terminal-notices`);o.append(i,r.element);let s=T(`div`,`terminal-jump-latest`);s.hidden=!0,s.append(C({variant:`secondary`,label:`Jump to latest`,onClick:()=>{n.scrollToBottom(),n.focus()}}),T(`span`,`terminal-jump-latest-new-output`));let c=T(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(T(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),Es.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatest:s})}var Vs=1024,Hs=`Keys you type now are held and sent once the terminal reconnects.`,Us=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,Ws=!1;function Gs(e){let t=e._inputQueue,n=e.dataWs;if(!Ws&&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 Ks(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!Ws&&!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>=Vs?(js(e,`keys`,`error`,Us),!1):(e._inputQueue.push(t),r&&js(e,`keys`,`busy`,Hs),!0)}function qs(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,us()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=bs(i,r.value);return i=r.value,e!==``&&(Ks(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{us()?n(e):a()},!0)};c(`keydown`,e=>{ys(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(!vs(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=gs(e.inputType);r!==``&&(Ks(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function Js(e){return!!e&&Array.from(e.types).includes(`Files`)}function Ys(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),Cs(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{Js(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,Js(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),Cs(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function Xs(e){Ws=e}var Zs=6,Qs=262144,$s=16384,ec=()=>{};function tc(e,t){if(t.length<=$s)e.push(t);else for(let n=0;n<t.length;n+=$s)e.push(t.slice(n,n+$s))}function nc({budget:e=Zs,maxChunkBytes:t=Qs,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)tc(l,e),m+=e.length,a.readIdx++;else{m===0&&(tc(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,ec);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 rc=nc(),ic=[];function ac(e){ic=[...e]}function oc(){return ic}function sc(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 cc=new Map;function lc(e){return cc.get(e)??null}function uc(e,t){cc.set(e,t)}function dc(e){cc.delete(e)}function fc(e){return[...cc].flatMap(([t,n])=>n===e?[t]:[])}function pc(e){let t=lc(e);return t?`/hosts/${encodeURIComponent(t)}`:``}function mc(e){let t=lc(e);if(!t)return null;let n=oc(),r=n.findIndex(e=>e.id===t);return{id:t,name:n[r]?.name??t,rank:r===-1?n.length:r}}var hc=re().int().min(1).max(500),gc=re().int().min(1).max(200);se(`type`,[oe({type:ie(`input`),data:ce()}),oe({type:ie(`claim`),cols:hc,rows:gc}),oe({type:ie(`unview`)}),oe({type:ie(`pause-output`)}),oe({type:ie(`resume-output`)})]);var _c=oe({type:ie(`pty-size`),cols:hc,rows:gc,seq:re().int().nonnegative()}),vc=oe({type:ie(`output-beat`)}),yc=se(`type`,[_c,vc]),bc=`history`,xc=`output`,Sc=`paused`;ae([`screen`,`deep`]);function Cc(e){try{return JSON.parse(e)}catch{return null}}function wc(e){let t=yc.safeParse(Cc(e));return t.success?t.data:null}var Tc=new Set([1,5,25,100]);function Ec(e){return e.isOutputPaused?`${e.history} paused`:e.history}function Dc(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function Oc(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function kc(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function Ac({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&Dc(e,n))}function jc({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 Nc({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function Pc(e,t,n){let r=new URLSearchParams;t&&r.set(bc,`deep`),n&&r.set(xc,Sc);let i=`/terminals/${encodeURIComponent(e)}`,a=r.toString();return a?`${i}?${a}`:i}function Fc({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:Ac({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function Ic({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function Lc({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!Dc(e,t),s=Oc(n)?kc(n):null,c=r&&!!s&&!Dc(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:Ac({authoritative:e,isActiveViewer:r,lastClaim:a})}}function Rc(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function zc(e){let t=Rc(e);return t===null?null:wc(t)}function Bc(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=zc(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 Vc=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,Hc=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,M=`[^\\S\\r\\n]`,Uc=`${Vc}${M}*(?:=>|[:=])${M}*`,Wc=`[?&][A-Za-z0-9_.-]*`,Gc=`[^\\r\\n;&|]{0,200}?`,Kc=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,qc=RegExp(`(${Uc})${Hc}`,`gi`),Jc=RegExp(`(\\bBearer${M}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),Yc=[/\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],Xc=[RegExp(`((?:^|\\s)--?${Vc}${M}+)${Hc}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${M}*=?${M}*)${Hc}`,`g`),RegExp(`(-AsPlainText${M}+)${Hc}`,`gi`),RegExp(`((?:^|\\s)setx${M}+[^\\s\\r\\n]*${Vc}[^\\s\\r\\n]*${M}+)${Hc}`,`gi`)],Zc=[RegExp(`(\\bauthorization${M}*:${M}*Basic${M}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${M}+login\\b${Gc}${M}-p(?:${M}+|=))${Hc}`,`gi`),RegExp(`(\\bcurl\\b${Gc}${M}(?:--user|-u)(?:${M}+|=)[^\\s:\\r\\n]+:)${Hc}`,`gi`),RegExp(`(\\b${Kc}\\b${Gc}${M}-p)${Hc}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi],Qc=[/-----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],$c=RegExp(`(${Wc}(?:${Vc}|_key)=)[^&#\\s]+`,`gi`),el=[qc,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${Hc}`,`g`)],tl=[Jc,...Xc,...Zc,...Yc,...Qc];function nl(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function rl(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 il(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 al(e){let t=nl(e,$c);return il([...t,...el.flatMap(n=>rl(nl(e,n),t)),...tl.flatMap(t=>nl(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var ol=`•`.repeat(8),sl=4;function cl(e){let t=e.flatMap(e=>[e,...e.split(/\r?\n/)]).map(e=>e.trim());return[...new Set(t.filter(e=>e.length>=sl))]}function ll(e,t){let n=[];for(let r of cl(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 ul(e,t=[]){let n=il([...al(e),...ll(e,t)]);if(n.length===0)return e;let r=``,i=0;for(let t of n)r+=e.slice(i,t.start)+ol,i=t.end;return r+e.slice(i)}var dl=`glimmervoid-streamer-mode`,fl=new Set,pl=zr(dl,!1)===!0;function ml(e){document.documentElement.toggleAttribute(`data-streamer`,e)}ml(pl);function hl(){return pl}function gl(e){if(Rr(dl,e),e!==hl()){pl=e,ml(e);for(let t of fl)t(e)}}function _l(e){return fl.add(e),()=>fl.delete(e)}async function vl(e){try{let t=await c(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:Or});return t.type===`settings-error`?String(t.message):(gl(e),``)}catch(e){return Dr(e,Or)}}var yl=`Streamer mode`;async function bl(){let e=!hl();e&&gl(!0);let t=await vl(e);t?Tr({source:yl,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}):wr(yl)}function xl(){bl()}var Sl=`#808080`,Cl=new WeakMap;function wl(e,t,n){return`${e}:${t}:${n}`}function Tl(e){return wl(e.marker.line,e.x,e.width)}function El(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function Dl(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function Ol(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function kl(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 Al(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 jl(e,t,n,r){let i=[];if(al(Ol(e,t,n)).length===0)return i;let{text:a,cellAt:o}=kl(e,t,n,r);for(let e of al(a))Al(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=Dl(e,i);r.push(...jl(e,i,t,n)),i=t+1}return r}function Nl(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function Pl(e){e.decoration.dispose(),e.marker.dispose()}function Fl(e){for(let t of e.masks)Pl(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function Il(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function Ll(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 Rl(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(Tl(r),r),r=e.masks.at(-1);return Ll(e),n}function zl(e,t){let n={normal:Nl(),alternate:Nl()},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??Sl,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(!hl())return;let t=e.buffer.active,r=n[t.type],i=El(t,Il(r,t)),a=Rl(r,i);for(let e of Ml(t,i)){let n=wl(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())Pl(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){Fl(n.normal),Fl(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=>{Fl(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=_l(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),Cl.delete(e)},{once:!0}),Cl.set(e,d)}function Bl(e){Cl.get(e)?.()}function Vl({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var Hl=`-4 -4 108 108`,Ul=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`}]),Wl=`M50 39L61 50L50 61L39 50Z`,Gl=11,Kl=`#efedf6`,ql=`#b688fe`;function Jl({frame:e,light:t,strokeWidth:n=Gl}){return`<path d="${Ul.map(({d:e})=>e).join(``)}" fill="none" stroke="${e}" stroke-width="${n}" stroke-linejoin="miter" stroke-linecap="butt"/><path d="${Wl}" fill="${t}"/>`}function Yl(e,t){return Mc({isBorrowedCard:A.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var Xl=new WeakMap,Zl=new WeakMap,Ql=new WeakSet,$l=new WeakSet,eu=new WeakSet;function tu(e,t){if(Xl.has(e)||!Ns(t))return;let n=t.buffer.active,r=n.length-n.viewportY;Ql.has(e)?Xl.set(e,r):Zl.set(e,r)}function nu(e,t,n){let r=e.term;r&&Nc({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:Ql.has(e)})&&(Ql.add(e),$l.add(e),Xl.set(e,r.buffer.active.length-n),Au(t))}var ru=new WeakMap;function iu(e,t){return document.visibilityState===`visible`&&!Yl(e,t)}function au(e,t){if(e&&bu(e,t))return;let n=e?.dataWs;if(!e||n?.readyState!==WebSocket.OPEN)return;let r=iu(e,t);ru.get(n)!==r&&(ru.set(n,r),n.send(JSON.stringify({type:r?`resume-output`:`pause-output`})))}function ou(){for(let[e,t]of O)au(t,e)}document.addEventListener(`visibilitychange`,ou),A.subscribe((e,t)=>{t.includes(`borrowedCardId`)&&ou()});function su(e,t){return O.get(e)===t&&!t.dataWs}function cu(e){return e.querySelector(`:scope > .terminal-connecting`)}function lu(){let e=le(`svg`,{class:`loading-mark`,viewBox:Hl,"aria-hidden":`true`});for(let{side:t,d:n}of Ul)e.append(le(`path`,{class:`loading-mark-bracket`,"data-side":t,d:n}));return e}function uu(e){if(cu(e))return;let t=T(`div`,`terminal-connecting`);t.append(lu(),T(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}var du=new Set,fu=new WeakSet;function pu(e){return du.add(e),()=>du.delete(e)}function mu(){let e=0;for(let[t,n]of O)n.card.dataset.link===`connecting`&&iu(n,t)&&e++;return e}function hu(e){let t=Vl({hasTerminal:e.term!==null||fu.has(e),isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:Ws}),n=t===`connecting`&&!Ws&&$l.has(e)?`live`:t;n===`none`?(delete e.card.dataset.link,gu()):(e.card.dataset.link=n,gu())}function gu(){for(let e of du)e()}function _u(e,t,n){tu(t,n),rc.unregister(e),t.dataWs=null,hu(t),t._resetGridClaim?.()}var vu=new WeakMap;function yu(e,t,n,r){_u(e,t,n),clearTimeout(vu.get(t)),vu.delete(t),r===0&&a()?ku(e,t,n):vu.set(t,setTimeout(()=>{vu.delete(t),su(e,t)&&b().catch(()=>{}).then(()=>{su(e,t)&&ku(e,t,n)})},r))}function bu(e,t){let n=eu.has(e),r=!e.dataWs&&O.get(t)===e;return!(n||r)||!e.term||!iu(e,t)?!1:(eu.delete(e),e._dataWsRetryAttempt=0,yu(t,e,e.term,0),!0)}function xu(e,t,n){_u(e,t,n),eu.add(t)}var Su=15e3,Cu=new Map;function wu(e){if(!a()||Cu.has(e)||O.get(e)?.dataWs)return;let n=pc(e)+Pc(e,!1,!1),r=new WebSocket(te(location,ne(n)));r.binaryType=`arraybuffer`;let i=[],o=e=>i.push(e),s=()=>Tu(e,r),c=()=>{r.readyState===WebSocket.CONNECTING&&s()};r.addEventListener(`message`,o),r.addEventListener(`close`,s);let l=setTimeout(c,t),u=setTimeout(s,Su);Cu.set(e,{socket:r,attachPath:n,bufferedMessages:i,release:()=>{r.removeEventListener(`message`,o),r.removeEventListener(`close`,s),clearTimeout(l),clearTimeout(u)}})}function Tu(e,t){let n=Cu.get(e);n?.socket===t&&(Cu.delete(e),n.release(),t.close())}function Eu(e,t){let n=Cu.get(e);if(!n)return null;let r=n.socket.readyState===WebSocket.CONNECTING||n.socket.readyState===WebSocket.OPEN;return n.attachPath!==t||!r?(Tu(e,n.socket),null):(Cu.delete(e),n.release(),n)}var Du=new WeakMap;function Ou(e,t,n){if(t.openedAtMs===null)return;let r=Math.round(performance.now()-t.openedAtMs);if(r>=1e3){Du.delete(e);return}let i=(Du.get(e)??0)+1;if(Du.set(e,i),!Tc.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 ku(e,r,i){eu.delete(r);let a=Xl.get(r);Xl.delete(r);let o=Zl.get(r);Zl.delete(r);let s=a!==void 0,c=a??o,l=!1,u=iu(r,e),d=pc(e)+Pc(e,s,!u),f=Eu(e,d),p=f?.socket??new WebSocket(te(location,ne(d)));ru.set(p,u),p.binaryType=`arraybuffer`,r.dataWs=p,u&&Fo(`terminal-connecting`),hu(r);let m=!1,h=!1,g={sessionId:e,attachDescription:Ec({history:s?`deep`:`screen`,isOutputPaused:!u}),openedAtMs:null,hasReceivedBytes:!1},_={hasSeenSize:!1,lastSeq:0},v=setTimeout(()=>{p.readyState===WebSocket.CONNECTING&&(h=!0,u&&Fo(`terminal-abandoned`),p.close())},t);rc.register(e,(e,t)=>i.write(e,t));let y=t=>{if(r.dataWs!==p)return;let n=Bc(t.data,_);if(n.kind===`bytes`){g.hasReceivedBytes=!0,Pr(r),ru.get(p)&&Fo(`terminal-bytes`);let t=l;if(l=!1,rc.enqueue(e,n.data),!t)return;let a=c??0;rc.enqueueAction(e,()=>{i.scrollToLine(Math.max(0,i.buffer.active.length-a))});return}if(n.kind===`beat`){Pr(r);return}if(n.kind===`attach-size`){l=c!==void 0,s||Ql.delete(r),_.hasSeenSize=!0,_.lastSeq=n.seq,i.reset(),Bl(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};rc.enqueueAction(e,()=>{r.ptySize=a,r._syncGrid?.()})};p.addEventListener(`message`,y),p.addEventListener(`close`,t=>{if(clearTimeout(v),r.dataWs!==p)return;if(Ou(r,g,t),u&&!h&&Fo(`terminal-closed`),$l.delete(r),m||h||lc(e)||ee(),!iu(r,e)){xu(e,r,i);return}if(h){yu(e,r,i,0);return}let a=n(r._dataWsRetryAttempt||0);r._dataWsRetryAttempt=(r._dataWsRetryAttempt||0)+1,yu(e,r,i,a)});let b=()=>{clearTimeout(v),m=!0,g.openedAtMs=performance.now(),u&&Fo(`terminal-opened`),r._dataWsRetryAttempt=0,$l.delete(r),hu(r),au(r,e),r._syncGrid?.({isActivationEdge:!0}),r._retryOwedGridClaim?.(),r._inputQueue?.length&&setTimeout(()=>{r.dataWs===p&&Gs(r)},50)};p.addEventListener(`open`,b),p.readyState===WebSocket.OPEN&&b();for(let e of f?.bufferedMessages??[])y(e)}function Au(e){let t=k(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,yu(e,t,t.term,0),n?.close()}function ju(){for(let[e,t]of O)t.term&&(iu(t,e)?Au(e):Mu(e,t,t.term))}function Mu(e,t,n){let r=t.dataWs;r&&(xu(e,t,n),r.close())}function Nu(){for(let[e,t]of O)t.term&&Mu(e,t,t.term)}function Pu(e,t){let n=e.dataWs;e.dataWs=null,rc.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}var Fu=`CommitMono`,Iu=[400,700].map(e=>`${e} 14px ${Fu}`),Lu=`monospace`;function Ru(e){return e.trim().replace(/^['"]|['"]$/g,``)}function zu(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>Ru(e)!==Fu);return r.length>0?r.join(`, `):Lu}function Bu(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function Vu(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function Hu(){return document.fonts?Iu.every(e=>document.fonts.check(e)):!1}function Uu(){return zu(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),Hu())}function Wu(e){document.fonts&&Bu(document.fonts,Iu,e)}var Gu=()=>!1;function Ku(e){Gu=e}function qu(){return Gu()}var Ju=Jr(navigator.userAgent),Yu=`next-attention-keys`,Xu=Mi();function Zu(){return Xu}function Qu(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(T(`span`,`shortcut-sep`,`+`)),e.appendChild(T(`kbd`,`kbd`,t))})}function $u(e){let t=T(`span`,`shortcut-keys`);return Qu(t,e),t}function ed(){let e=$u(ai(`next-attention`,Ju,Xu));return e.classList.add(Yu),e}function td(e){Xu=e;let t=ai(`next-attention`,Ju,e);for(let e of document.querySelectorAll(`.${Yu}`))e.replaceChildren(),Qu(e,t)}var nd=oe({title:ce().optional(),iconDataUrl:ce().startsWith(`data:image/`).optional()}),rd=new Set([`http:`,`https:`]);function id(e){let t;try{t=new URL(e)}catch{return null}return rd.has(t.protocol)?t.href:null}var ad=/\bElectron\/\d/,od=new Set([`localhost`,`127.0.0.1`]);function sd(e){return ad.test(e)}function cd({userAgent:e,pageHostname:t}){return sd(e)&&od.has(t)}function ld(e){return id(e)!==null}var ud=new Set([0,1]);function dd({button:e,opensInNewTab:t}){return t&&ud.has(e)}function fd(){return cd({userAgent:navigator.userAgent,pageHostname:location.hostname})}function pd(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function md(e){try{let t=await b();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 hd=500,gd=new Map;async function _d(e){try{let t=await b(),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=nd.safeParse(await n.json());return r.success?r.data:{}}catch{return{}}}function vd(e){return e.title!==void 0||e.iconDataUrl!==void 0}function yd(e){let t=gd.get(e);if(t)return t;let n=_d(e).then(t=>(!vd(t)&&gd.get(e)===n&&gd.delete(e),t));if(gd.set(e,n),gd.size>hd){let e=gd.keys().next().value;e!==void 0&&gd.delete(e)}return n}function bd(e){!fd()||!ld(e)?pd(e):md(e).then(t=>{t||pd(e)})}function xd(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&dd({button:e.button,opensInNewTab:t.target===`_blank`})&&ld(t.href)&&(e.preventDefault(),bd(t.href))}function Sd(e){fd()&&(e.addEventListener(`click`,xd,!0),e.addEventListener(`auxclick`,xd,!0))}var Cd={phase:`hidden`,isPointerOnLink:!1,isPointerOnPopup:!1},wd=`*`,Td=/^[("'<[{]+|[)"'>\]}.,;:!?]+$/g,Ed=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(`.`)),Dd=/^[a-z][a-z0-9+.-]*:\/\//i,Od=/\s/,kd=/\.[a-z]{2,63}$/i,Ad=/^www\./;function jd(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 Nd(e){let t={...e,isPointerOnLink:!1};return e.phase===`shown`&&jd(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function Pd(e){let t={...e,isPointerOnPopup:!1};return e.phase===`shown`&&jd(t)?{state:t,effects:[`schedule-hide`]}:{state:t,effects:[]}}function Fd(e,t){switch(t){case`enter-link`:return Md(e);case`leave-link`:return Nd(e);case`enter-popup`:return{state:{...e,isPointerOnPopup:!0},effects:e.phase===`shown`?[`cancel-hide`]:[]};case`leave-popup`:return Pd(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`||!jd(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 Id(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 Ld(e){try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?null:t}catch{return null}}function Rd(e,t){let n=e.split(``);for(let e of t)n.fill(wd,e.start,e.end);return n.join(``)}function zd(e,t){let n=Ld(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=Rd(`${i}${n.host}${a}`,al(`${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 Bd(e){let t=e.trim().replace(Td,``);if(t.length===0||Od.test(t))return null;let n=Ld(Dd.test(t)?t:`https://${t}`);if(!n)return null;let r=n.hostname.replace(/\.$/,``);return!kd.test(r)||!Dd.test(t)&&Ed.has(r.slice(r.lastIndexOf(`.`)+1).toLowerCase())?null:r}function Vd(e,t){let n=e.replace(Ad,``),r=t.replace(Ad,``);return n===r||n.endsWith(`.${r}`)||r.endsWith(`.${n}`)}function Hd(e,t){let n=Ld(t);if(!n)return null;let r=Bd(e);if(!r)return null;let i=n.hostname.replace(/\.$/,``);return Vd(r,i)?null:{textHost:r,targetHost:i}}var Ud=100,Wd=150,Gd=600,Kd=16,qd=[`mousedown`,`mouseup`,`mousemove`,`click`,`dblclick`,`contextmenu`,`wheel`],Jd=!1;function Yd(e){Jd=e}function Xd(e){let t=T(`div`,`terminal-link-popup-url`),n=zd(e,hl());return n?(t.append(T(`span`,`terminal-link-popup-url-dim`,n.scheme),T(`strong`,`terminal-link-popup-host`,n.host),T(`span`,`terminal-link-popup-url-dim`,n.rest)),t):(t.textContent=e,t)}function Zd(e){if(e.linkText===null)return null;let t=Hd(e.linkText,e.url);if(!t)return null;let n=T(`div`,`terminal-link-popup-mismatch`);return n.append(`Text says `,T(`strong`,null,t.textHost),`, goes to `,T(`strong`,null,t.targetHost)),n}function Qd(e,t){if(!e||e.url!==t)return null;let{title:n,iconDataUrl:r}=e.preview;if(!n&&!r)return null;let i=T(`div`,`terminal-link-popup-preview`);if(r){let e=T(`img`,`terminal-link-popup-icon`);e.src=r,e.alt=``,e.width=Kd,e.height=Kd,i.append(e)}return n&&i.append(T(`span`,`terminal-link-popup-title`,n)),i}function $d(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=T(`div`,`xterm-hover terminal-link-popup`);s.hidden=!0,i.append(s);let c=Cd,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;Jd&&e&&yd(e).then(t=>{Jd&&(p={url:e,preview:t},c.phase===`shown`&&l?.url===e&&te())})}function y(e){e.key===`Escape`&&re(`escape`)}function ee(t){let n=a.getBoundingClientRect(),r=i.getBoundingClientRect(),o=e.buffer.active.viewportY;m=o;let c=Id({linkRange:{startRow:t.range.start.y-1-o,startCol:t.range.start.x-1,endRow:t.range.end.y-1-o},rows:e.rows,cellWidthPx:n.width/e.cols,cellHeightPx:n.height/e.rows,popupHeightPx:s.offsetHeight,popupWidthPx:s.offsetWidth,screenWidthPx:n.width});s.dataset.side=c.side,s.style.left=`${n.left-r.left+c.leftPx}px`,s.style.top=`${n.top-r.top+c.topPx}px`}function te(){let e=l;if(!e)return;let n=T(`div`,`terminal-link-popup-footer`);n.append(T(`span`,`terminal-link-popup-hint`,`Click to open`),C({variant:`secondary`,size:`small`,label:`Copy link`,onClick:()=>Ls(t,e.url,`link copy`,`Copied the link.`)}));let r=Zd(e);s.replaceChildren(...[Xd(e.url),r,Qd(Jd?p:null,e.url),n].filter(e=>e!==null)),s.hidden=!1,ee(e),document.addEventListener(`keydown`,y,{capture:!0,signal:o})}function ne(){s.hidden=!0,s.replaceChildren(),document.removeEventListener(`keydown`,y,{capture:!0})}let b={"schedule-show":()=>{h(),u=setTimeout(()=>{u=null,re(`show-timer`)},Ud)},"cancel-show":h,"schedule-hide":()=>{g(),d=setTimeout(()=>{d=null,re(`hide-timer`)},Wd)},"cancel-hide":g,"schedule-dwell":()=>{_(),f=setTimeout(()=>{f=null,re(`dwell-timer`)},Gd)},"cancel-dwell":_,"fetch-preview":v,render:te,remove:ne};function re(e){let t=Fd(c,e);c=t.state;for(let e of t.effects)b[e]()}for(let e of qd)s.addEventListener(e,e=>e.stopPropagation(),{signal:o});s.addEventListener(`mouseenter`,()=>re(`enter-popup`),{signal:o}),s.addEventListener(`mouseleave`,()=>re(`leave-popup`),{signal:o});let ie=e.onScroll(()=>{e.buffer.active.viewportY!==m&&re(`escape`)}),ae=e.onResize(()=>re(`escape`));return o.addEventListener(`abort`,()=>{h(),g(),_(),ie.dispose(),ae.dispose(),s.remove()},{once:!0}),{enterLink(e){us()||(l=e,re(`enter-link`))},leaveLink(){re(`leave-link`)}}}var ef=/https?:\/\/[^\s<>"']+/g,tf=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),nf={")":`(`,"]":`[`,"}":`{`};function rf(e,t){let n=0;for(let r of e)r===t&&n++;return n}function af(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(tf.has(t)){e=e.slice(0,-1);continue}let n=nf[t];if(n&&rf(e,n)<rf(e,t))e=e.slice(0,-1);else return e}}function of(e){let t=[];for(let n of e.matchAll(ef)){let e=af(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var sf=50;function cf(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 lf(e,t){return{activate(e,t){bd(t)},hover(n,r,i){t.enterLink({url:r,linkText:cf(e,i),range:i})},leave(){t.leaveLink()},allowNonHttpProtocols:!1}}function uf(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<sf;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<sf;)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 df(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}=uf(i,n),s=[];for(let{start:e,end:n,url:r}of of(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){bd(t)},hover(){t.enterLink({url:r,linkText:null,range:c})},leave(){t.leaveLink()}})}r(s.length?s:void 0)}}),r=ff(e);return{dispose(){r.dispose(),n.dispose()}}}function ff(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 pf=10,mf=1.2,hf=.005,gf=4,_f=.08,vf=5;function yf(e,t){let n=Math.abs(t);return n<pf?!1:n>Math.abs(e)*mf}function bf(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 xf(e,t,n){let r=e.length>=gf?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function Sf(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>=_f))return 0;let o=Math.min(a,vf);return i<0?-o:o}function Cf({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function wf(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)-hf*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=bf(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function Tf(e,t){return e===`alternate`||!!t&&t!==`none`}function Ef(e,t){return!(e>0)||!(t>0)?0:e/t}var Df=1;function Of(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function kf(e,t){for(let n of e)if(n.identifier===t)return n;return null}function Af(e,t){if(Of(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=()=>Tf(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return Ef(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:Df,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}=wf(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=Cf({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=kf(e.touches,r);if(!u)return;if(!s){if(!yf(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=xf([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=xf(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=bf(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=xf(l,o,e.timeStamp);let t=Sf(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function jf(e){let t=oi(e,Ju,{isTerminalFocused:!0},Zu());return!t||t.action===`board-split`&&!qu()?!1:ei(t,document.body.dataset.activeView)}var Mf=250,Nf=`(max-width: 768px)`,Pf=12,Ff=14,If=5e4,Lf=!1;function Rf(e){Lf=e}var zf=!1;window.addEventListener(`blur`,()=>{zf=!0}),window.addEventListener(`focus`,()=>{zf=!1});function Bf(e){let t=document.activeElement;return jc({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:zf,isPhoneLayout:us()})}function Vf(e,t,n){let r=window.matchMedia?.(Nf).matches?Pf:Ff,i=new n.Terminal({cursorBlink:Lf,fontSize:r,fontFamily:Uu(),theme:go(),scrollback:If,allowProposedApi:!0}),a=new n.FitAddon;i.loadAddon(a),uu(e),i.open(e),Bs(e,t,i);let o=$d(i,t);i.options.linkHandler=lf(i,o),df(i,o),zl(i,t.abortController.signal),t.term=i,t.fitAddon=a,Jo(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||!Bf(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=Ac({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=Lc({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=Fc({authoritative:t.ptySize??null,isActiveViewer:l,isDocumentEngaged:Bf(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=Ic({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&&Xo(t),_({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{zf=!1,v()},{signal:t.abortController.signal}),ts(t);let ee=null;i.onScroll(()=>{ee===null&&(ee=requestAnimationFrame(()=>{ee=null,t.term&&(t.term.refresh(0,t.term.rows-1),Ps(t,t.term))}))}),i.onWriteParsed(()=>Ps(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=Fs(r)}catch(e){return Is(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(Ls(t,i,`osc52 write`),!0):(Rs(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`&&Ks(t,`\x1B\r`),!1;if(e.type!==`keydown`)return!0;if(jf(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&i.hasSelection()){let e=i.getSelection();return i.clearSelection(),Ls(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(Ks(t,`\x1B`),!1):!0}),qs(e,i,t),Af(e,i)}function Hf(){Xs(!0);for(let e of O.values())hu(e)}function Uf(){Xs(!1);for(let e of O.values())hu(e),Gs(e)}function Wf(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{Ks(e,n),e.unseenOutcome&&s({type:`dismiss`,id:t,expectedState:e.currentState})}),n.onScroll(n=>{nu(e,t,n)}),Ys(e.termWrap,t,e.abortController.signal),hu(e),queueMicrotask(()=>{su(t,e)&&ku(t,e,n)}))}function Gf(e,t){if(e.term||fu.has(e))return;let n=Ho();if(n){Kf(e,t,n);return}fu.add(e);let r=e._isActiveViewer?.()===!0;e._isActiveViewer=()=>r,e._setActiveViewer=e=>{r=e},uu(e.termWrap),hu(e),Uo().then(n=>{fu.delete(e),e.term||e.abortController.signal.aborted||O.get(t)!==e||(Kf(e,t,n),e._setActiveViewer?.(r))},()=>{fu.delete(e),hu(e)})}function Kf(e,t,n){Vf(e.termWrap,e,n),Wf(e,t)}function qf(e){e?._syncGridOnEngagementEdge?.()}function Jf(e,t){if(!e)return;Gf(e,t),au(e,t),Xo(e);let n=e.term;n&&(n.refresh(0,n.rows-1),qf(e))}function Yf(e,t,n){e&&(n&&Gf(e,t),e._setActiveViewer?.(n))}var Xf={isVisible:document.visibilityState===`visible`,isFrozen:!1,isProbing:!1,isReplacing:!1},Zf=document.visibilityState===`visible`?null:Date.now(),Qf=null,$f=null;function ep(){Qf!==null&&window.clearTimeout(Qf),Qf=null}function tp(e){ep();let t=Date.now()+e;Qf=window.setTimeout(()=>{Qf=null,ip({kind:`heartbeat-due`,lateByMs:Date.now()-t})},e)}function np(){$f!==null&&window.clearTimeout($f),$f=null}function rp(e){switch(e.kind){case`probe-control`:_(e.deadlineMs,e.isAnnounced).then(e=>{ip({kind:e?`pong`:`pong-missed`})});return;case`replace-control`:o();return;case`close-sockets`:np(),v(),Nu();return;case`reconnect-shown-terminals`:ju();return;case`hold-input`:Hf();return;case`release-input`:Uf();return;case`schedule-heartbeat`:tp(e.inMs);return;case`cancel-heartbeat`:ep();return}}function ip(t){let n=e(Xf,t);Xf=n.state;for(let e of n.actions)rp(e)}function ap(){if(document.visibilityState!==`visible`){Zf=Date.now(),ip({kind:`hidden`});return}let e=Zf===null?0:Date.now()-Zf;Zf=null,Lo(`shown`,e),ip({kind:`shown`,hiddenForMs:e})}function op(e){np(),Fo(`control-${e}`),e===`connecting`?$f=window.setTimeout(()=>{$f=null,ip({kind:`handshake-overdue`})},t):(e===`opened`&&yo(),ip({kind:e===`opened`?`control-opened`:`control-closed`}))}function sp(){Lo(`resumed`,Zf===null?0:Date.now()-Zf),ip({kind:`resumed`})}function cp(){let e=Reflect.get(navigator,`connection`);e instanceof EventTarget&&e.addEventListener(`change`,()=>{Io(`link`),ip({kind:`network-changed`})})}function lp(){m(op),document.addEventListener(`visibilitychange`,ap),document.addEventListener(`freeze`,()=>ip({kind:`frozen`})),document.addEventListener(`resume`,sp),window.addEventListener(`pagehide`,e=>{e.persisted&&ip({kind:`frozen`})}),window.addEventListener(`pageshow`,e=>{e.persisted&&sp()}),window.addEventListener(`online`,()=>{Io(`online`),ip({kind:`network-changed`})}),window.addEventListener(`offline`,()=>Io(`offline`)),cp()}var up=!1,dp=!1,fp=!1,pp=null,mp=null;function hp(){return mp??=j(()=>import(`./nyan-cat-Y4DKSNpt.js`).then(e=>e.r).then(e=>(pp=e,e),e=>(mp=null,y(`flying-animals`,`nyan cat failed to load: ${l(e)}`),null)),__vite__mapDeps([2,1,3,4,5,6,7,8])),mp}function gp(e){!fp||e.currentFlightBlockReason(!0)?e.stopNyanCat():e.startNyanCat()}function _p(){dp=!0,vp(ri())}function vp(e){let t=document.documentElement;up||(up=!0,ds(()=>vp(ri())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>vp(ri()))),fp=e,e?(t.dataset.flyingAnimals=`true`,pp?gp(pp):dp&&hp().then(e=>{e&&gp(e)})):(delete t.dataset.flyingAnimals,pp?.stopNyanCat())}var yp=45e3,bp=`The server did not answer within ${yp/1e3} s.`,xp=`Select the issue to load its description.`,Sp=null,Cp=null,wp=new Map,Tp=null,Ep=new Map,Dp=new Map,Op=null,kp=new Map,Ap=new Map,jp=new Map,Mp=new Map,Np=new Set;function N(e){for(let t of Np)t(e)}function Pp(e){return`${e.key}:${e.updatedAt}`}function Fp(e){let t=Ep.get(e);t&&(Ep.delete(e),kp.set(t.issueKey,{text:bp,tone:`error`}),N(`detail`))}function Ip(e){let t=Ep.get(e);return t?(clearTimeout(t.timeoutHandle),Ep.delete(e),t):null}function Lp(){return{latestStatus:Cp,issueByKey:wp,selectedKey:Sp}}function Rp(e){Np.add(e)}function zp(e){Sp=e,Op&&Op.issue.key!==e&&(Op=null)}function Bp(){if(Sp)return wp.get(Sp)??(Op?.issue.key===Sp?Op.issue:void 0)}function Vp(e){return Op?.issue.key===e.key&&Op.isClosed}function Hp(e){return[...Dp.values()].some(t=>t.issue.key===e.key)}function Up(e,t){if(Hp(e))return;let n=d(`set-issue-state`);Tp?.({type:`set-issue-state`,requestId:n,repo:e.repo,issueNumber:e.number,state:t})?(Dp.set(n,{issue:e,state:t,timeoutHandle:setTimeout(()=>{Dp.delete(n),kp.set(e.key,{text:bp,tone:`error`}),N(`detail`)},yp)}),kp.set(e.key,{text:t===`closed`?`Closing issue.`:`Reopening issue.`,tone:`busy`}),N(`detail`)):(kp.set(e.key,{text:x,tone:`error`}),N(`detail`))}function Wp(e){let t=Dp.get(e.requestId);if(!t)return;clearTimeout(t.timeoutHandle),Dp.delete(e.requestId);let{issue:n,state:r}=t;e.ok?(Op={issue:n,isClosed:r===`closed`},kp.set(n.key,{text:r===`closed`?`Closed as completed.`:`Reopened.`,tone:`ok`}),N(`detail`)):(kp.set(n.key,{text:e.error||`Could not ${r===`closed`?`close`:`reopen`} the issue.`,tone:`error`}),N(`detail`))}function Gp(e){return[...Ep.values()].some(t=>t.issueKey===e.key)}function Kp(e){return kp.get(e.key)}function qp(e){let t=Pp(e),n=jp.get(t);return n===``?`No description.`:n??Mp.get(t)??`Loading description.`}function Jp(e){let t=Pp(e);if(jp.has(t)||[...Ap.values()].some(e=>e.cacheKey===t))return;let n=d(`issue-detail`);Mp.delete(t),Tp?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?Ap.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{Ap.delete(n),Mp.set(t,`${bp} ${xp}`),N(`detail`)},yp)}):Mp.set(t,`${x} ${xp}`)}function Yp(e){let t=e.projectId;if(!t||Gp(e))return;let n=d(`open-issue-session`);Tp?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(Ep.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>Fp(n),yp)}),kp.set(e.key,{text:`Opening session.`,tone:`busy`}),N(`detail`)):(kp.set(e.key,{text:x,tone:`error`}),N(`detail`))}function Xp(e){Tp?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function Zp(e){Tp=e}function Qp(){N(`session-state`)}function $p(e){if(!e){for(let e of Ep.values())clearTimeout(e.timeoutHandle),kp.set(e.issueKey,{text:x,tone:`error`});Ep.clear();for(let e of Dp.values())clearTimeout(e.timeoutHandle),kp.set(e.issue.key,{text:x,tone:`error`});Dp.clear();for(let e of Ap.values())clearTimeout(e.timeoutHandle),Mp.set(e.cacheKey,`${x} ${xp}`);Ap.clear(),N(`status`)}}function em(e){let t=Cp?.issues.find(e=>e.key===Sp);Cp=e,wp=new Map(e.issues.map(e=>[e.key,e])),Op&&!Op.isClosed&&wp.has(Op.issue.key)&&(Op=null);let n=e.issues.find(e=>e.key===Sp);n&&n.updatedAt!==t?.updatedAt&&Jp(n),N(`status`)}function tm(e){let t=Ap.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),Ap.delete(e.requestId),e.ok&&e.body!==null&&jp.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.`),N(`detail`))}function nm(e){if(typeof e.requestId!=`string`)return;let t=Ip(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`;kp.set(n,{text:`Session "${r}" ${a}.${i}`,tone:`ok`});let o=Cp?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),N(`status`);return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;kp.set(n,{text:r,tone:`error`}),N(`detail`)}var rm=new Map,im=new Set;function am(e){let t=ze.safeParse(e);if(!t.success)y(`reviews`,`dropped github-prs: ${r(t.error.issues)}`);else{rm=new Map(Object.entries(t.data.prs));for(let e of im)e()}}function om(e){return rm.get(e.toLowerCase())}function sm(e){im.add(e)}var cm=20,lm=[],um=null,dm=!1,fm=0,pm=null;function mm(){return pm??=j(()=>import(`./celebration-player-k9KDERaX.js`),__vite__mapDeps([9,10,6,3,4,5,7])).catch(e=>(pm=null,y(`merge-celebration`,`celebration player failed to load: ${l(e)}`),null)),pm}function hm(e){return dm?`playing`:e?`queued`:`empty`}function gm(){if(!um)return;let e=lm.length>0,t=hm(e);um.tray.dataset.state=t,um.count.textContent=e?String(lm.length):``,um.toggle.element.disabled=t!==`queued`,um.toggle.setState(t===`queued`?`attention`:`idle`)}function _m(){let e=lm.shift();if(dm=e!==void 0,gm(),!e)return;let t=fm;fm+=1,mm().then(n=>{n?(n.playCelebration(e,t),window.setTimeout(_m,n.CELEBRATION_DURATION_MS)):(lm.unshift(e),dm=!1,gm())})}function vm(e,t,n){um={tray:e,toggle:t,count:n},t.element.addEventListener(`click`,()=>{fm=0,_m()}),gm()}function ym(e){lm.push(e),lm.length>cm&&lm.shift(),gm()}var bm={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},xm=new Set([`FAILURE`,`ERROR`]);function Sm(e){return bm[e]}function Cm(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&&xm.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function wm(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 Tm(e){let t=Bt.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:wm(t)}}var Em=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],Dm=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],Om={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`},km={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`},Am={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`},jm={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 Nm(e){return Em[e.rows.reduce((e,{pr:t})=>Math.min(e,Em.indexOf(Om[t.stage])),Em.length-1)]}function Pm(e){let t=new Map(Em.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of Mm(e)){let e=t.get(Nm(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return Dm.flatMap(e=>t.get(e)??[])}function Fm(e,t){return Mm(e).find(e=>e.rows.some(e=>e.pr.key===t))?.rows??[]}function Im(e){return e.stackSize<2?null:`Stack ${e.depth+1}/${e.stackHeight}`}function Lm(e){return km[e]}function Rm(e){return Am[e]}function zm(e){return jm[e]}function Bm(e){return e?.isKeepMergeableEnabled!==!1}function Vm(e,t){if(!t||!e.keepMergeable||e.isKeepMergeableFixInFlight)return!1;let n=e.keepMergeableAttempt?.outcome;return n!==void 0&&n!==`pushed`&&n!==`stopped`}function Hm(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...Tm({...n,repo:r}),...e}]})}function Um(e){let t=new Map;for(let n of e)for(let e of n.links){let r=Oe(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 Wm(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 Gm=3;function Km(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,Gm).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 qm(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:Qt(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,isAuthorOrgMember:n.isAuthorOrgMember,liveHead:n.headRefOid,prStage:Tm(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n)}}var Jm=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`];function Ym(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 Xm(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function Zm(e){return e.status===`posted`&&Qm(e)}function Qm(e){if(!Xm(e)||kt(e))return!1;let t=rh(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 $m(e){return ih(e).length>0||Zm(e)}function eh(e){return $m(e)?`actionable`:Ym(e).band}function th(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[Ym(t).band].push(t);for(let e of Jm)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($m(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!ah(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[eh(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 Jm)t.ready.push(...n[e]);return t}function nh(e,t){return e.commit===t?e.isViewer||Tt.has(e.state):!1}function rh(e){return e.liveHead??e.reviewedHead}function ih(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function ah(e){return ih(e).length>0?!0:kt(e)?!1:Qm(e)?!0:!(e.githubReviews??[]).some(t=>nh(t,rh(e)))}function oh(e,t){return`${e}#${t}`}var sh=null,ch={},lh=[],uh=[],dh={},fh={},ph=[],mh={},hh={},gh={},_h=null,vh=new Set,yh=new Map,bh=!1,xh=new Set;function Sh(e){for(let t of xh)t(e)}function Ch(){return[...yh].flatMap(([e,t])=>{let n=O.get(e);return!n||t.length===0?[]:[{id:e,title:ar(n)||e,links:t}]})}function wh(){let e=Hm(sh?.prs??[],om),t=Wm(_h,e);_h=e,Oh(t),Sh({kind:`prs`})}function Th(){bh||(bh=!0,queueMicrotask(()=>{bh=!1,wh()}))}function Eh(e){xh.add(e)}function Dh(){return{prs:Hm(sh?.prs??[],om).map(e=>({...e,reviewItems:fh[e.key]??e.reviewItems})),status:sh,sessionsByPrKey:Um(Ch()),handledByPr:ch,prFlowWarnings:lh,prFlowApprovals:uh,sourceRunsByPr:dh,prFlowActions:ph,actionRunsByPr:mh,prActionsByPr:hh,prActionRunsByPr:gh}}function Oh(e){let t=e.filter(e=>!vh.has(e.key));if(t.length!==0){for(let e of t)vh.add(e.key);ym(Km(t))}}function kh(e){yh=e,Th()}function Ah(){Sh({kind:`session-state`})}function jh(e){let t=xt.safeParse(e);t.success?(sh=t.data,wh()):y(`reviews`,`dropped my-prs-status: ${r(t.error.issues)}`)}function Mh(e){let t=yt.safeParse(e);t.success?(ch=t.data.handledByPr,lh=t.data.warnings,uh=t.data.pendingApprovals,dh=t.data.sourceRunsByPr,fh=t.data.reviewItemsByPr,ph=t.data.actions,mh=t.data.actionRunsByPr,hh=t.data.prActionsByPr,gh=t.data.prActionRunsByPr,Sh({kind:`prs`})):y(`reviews`,`dropped pr-flows-status: ${r(t.error.issues)}`)}function Nh(e){Sh({kind:`merge-result`,message:e})}function Ph(e){Sh({kind:`connection`,isConnected:e})}sm(Th);var Fh=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}])),Ih={turn:`Your turn`,working:`Agent working`,queued:`Queued`,waiting:`Waiting on others`,done:`Done`,parked:`Parked`,aside:`Set aside`},Lh=[`turn`,`working`,`queued`,`waiting`,`done`,`parked`],Rh=new Set([`done`,`parked`]),zh=[`queued`,`working`,`turn`,`now`,`waiting`,`done`,`parked`],Bh={...Ih,turn:`Ready`,now:`Reviewing now`};function Vh(e){return zh.map(t=>e.find(e=>e.id===t)??{id:t,title:Bh[t],items:[]})}function Hh(e,t){let n=new Set(yg(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:Bh.now,items:e.items.filter(e=>i.has(e.key))},{id:`turn`,title:Bh.turn,items:e.items.filter(e=>!i.has(e.key))}]:[e]),pulledKeys:r}}function Uh({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 Wh(e,t){return t>0?`${e} / ${t}`:String(e)}var Gh={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`},Kh={settled:`review-settled`,inReview:`review-in-flight`,queued:`review-queued`,posted:`review-posted`,discarded:`review-discarded`},qh=Jm.indexOf(`waiting-on-author`);function Jh(e){return e.status===`ready`?Ym(e).band===`blocking-others`?`review-direct-ask`:`review-ready`:`review-follow-up`}function Yh(e,t){return t===`ready`?Jh(e):t===`attention`?`status`in e&&e.status===`error`?`review-failed`:`review-stale`:Kh[t]}function Xh(e,t,n){let r=e.state===`OPEN`;if(r&&Vm(e,n))return`mine-repair-failed`;if(r&&n&&e.keepMergeable&&e.isKeepMergeableFixInFlight)return`mine-repairing`;let i=Gh[e.stage];return Fh.get(i)?.group===`turn`&&e.stage!==`ready`&&t.has(Oe(e))?`mine-agent-fixing`:i}function Zh(e,t){return t===`ready`||t===`attention`?Jm.indexOf(eh(e)):t===`queued`?Jm.indexOf(Ym(e).band):0}function Qh(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function $h(e){let t=ih(e).flatMap(e=>Qh(e.lastReplyAt)??[]);return t.length>0?Math.max(...t):null}function eg(e,t){if(t===`inReview`)return Qh(e.startedAt)??1/0;if(t===`queued`)return Qh(e.prCreatedAt)??1/0;let n=e,r=t===`posted`?Qh(n.postedAt):null;return $h(n)??r??Qh(n.reviewedAt)??Qh(n.prCreatedAt)??1/0}function tg(e){return Qh(e.mergedAt??e.stageSinceMs??e.updatedAt)??1/0}var ng=864e5,rg=3*ng;function ig(e){return e.source===`team`?eg(e.review,e.kind):tg(e.pr)}function ag(e,t,n){if(e===`done`||e===`parked`||!Number.isFinite(t))return null;let r=n-t;return r>rg?`old`:r>=ng?`aging`:`fresh`}function og(e,t){return t>0&&e>t}function sg(e,t,n,r){let i=Fh.get(e);return i?[{item:r(i),row:i,priorityBandRank:t,waitStartMs:n}]:[]}function cg(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=>sg(Yh(t,e),Zh(t,e),eg(t,e),({action:n,kind:r})=>({source:`team`,key:`team:${t.key}`,prKey:Oe(t),kind:e,review:t,action:n,attention:r}))))}function lg(e,t,n){return Pm(e).flatMap(e=>e.rows).flatMap(e=>sg(Xh(e.pr,t,n),0,tg(e.pr),({action:t,kind:n})=>({source:`mine`,key:`mine:${e.pr.key}`,prKey:Oe(e.pr),pr:e.pr,stackRow:e,action:t,attention:n})))}function ug(e){return e.row.kind===`failed`?0:e.row.state===`review-direct-ask`?1:e.priorityBandRank>=qh?3:2}function dg(e,t){let n=e.waitStartMs-t.waitStartMs;return e.row.group===`turn`?ug(e)-ug(t)||n||e.item.key.localeCompare(t.item.key):e.row.rank-t.row.rank||e.priorityBandRank-t.priorityBandRank||n}function fg(e,t,n,r){let i=new Map(Lh.map(e=>[e,[]]));for(let a of[...cg(e),...lg(t,n,r)])i.get(a.row.group)?.push(a);return Lh.map(e=>({id:e,title:Ih[e],items:(i.get(e)??[]).toSorted(dg).map(e=>e.item)}))}var pg=[`turn`,`working`,`aside`],mg=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 hg(e){return e.status===`ready`&&e.verdict?`ready-${e.verdict}`:e.status}function gg(e){let t=Date.parse(e.item.createdAt);return Number.isNaN(t)?1/0:t}function _g(e){let t=e.flatMap(e=>{let t=mg.get(hg(e));return t?[{row:t,askedAtMs:gg(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 pg.map(e=>({id:e,title:Ih[e],items:t.filter(t=>t.row.group===e).map(e=>e.item)}))}function vg(e){return`${e.key}@${e.entry.status}:${e.entry.finishedAt??``}`}function yg(e){return e.find(e=>e.id===`turn`)?.items??[]}function bg(e,t){return t?e.flatMap(e=>e.items).find(e=>e.key===t)??null:null}function xg(e,t){return bg(e,t)?t:e.flatMap(e=>e.items)[0]?.key??null}function Sg(e){return e.source===`mine`?oh(e.pr.repo,e.pr.number):oh(e.review.repo,e.review.number)}function Cg(e,t){return yg(e).map(e=>({id:e.key,kind:e.attention??`waiting`,name:t(e)}))}function wg(e){return Cg(e,Sg)}function Tg(e,t){return wg(e).filter(e=>e.id!==t)}function Eg({capturedOrder:e,actedKey:t,groups:n}){let r=yg(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 Dg=new Set([`turn`,`now`]);function Og(e,t){let n=e.find(e=>Dg.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 kg(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 Ag(e){return yg(e).map(kg)}function jg({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:ft([...i]),unseen:ft([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:ft([...a]),unseen:ft([...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 Ng(e){return new Set(e.flatMap(e=>e.items).map(e=>(e.source===`mine`?e.pr.repo:e.review.repo).toLowerCase())).size>1}function Pg(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 Fg=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 Ig(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`:Fg.get(e.key)??null}function Lg(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 Rg(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 zg=null,Bg=null,Vg=new Set;function Hg(e){for(let t of Vg)t(e)}function Ug(){Bg=qm(zg,om),Hg({kind:`status`})}function Wg(e){Vg.add(e)}function Gg(){return Bg}function Kg(){return th(Bg)}function qg(e){let t=wt.safeParse(e);t.success?(zg=t.data,Ug()):y(`reviews`,`dropped team-review-status: ${r(t.error.issues)}`)}function Jg(e){Hg({kind:`action-result`,message:e})}function Yg(e){Hg({kind:`open-session-result`,message:e})}function Xg(e){Hg({kind:`connection`,isConnected:e})}sm(Ug);var Zg=[],Qg=null,$g=null,e_=null,t_=!1,n_=null,r_=mi(),i_=Di(),a_=new Set(i_.split(`|`).filter(Boolean)),o_=new Set,s_=new Set;function c_(e){for(let t of s_)t(e)}function l_(e){e!==r_&&(r_=e,si(e))}function u_(e){e!==i_&&(i_=e,a_=new Set(e.split(`|`).filter(Boolean)),$r(e))}function d_(){return Gg()!==null&&Dh().status!==null}function f_(){if(!d_())return;let e=jg({turnEntries:Ag(Zg),acknowledged:r_,unseen:i_,isLooking:$g?.isLooking()??!1});l_(e.acknowledged),u_(e.unseen),n_?.(e.isShown)}function p_(e){e_=e,c_({kind:`reveal`})}function m_(e){s_.add(e)}function h_(e){$g=e,f_()}function g_(){let{prs:e,sessionsByPrKey:t,status:n}=Dh();return Zg=fg(Kg(),e,new Set(t.keys()),Bm(n)),f_(),Zg}function __(){d_()&&(l_(ft(Ag(Zg))),f_())}function v_(e){n_=e,f_()}function y_(){return i_}function b_(e){return a_.has(e)}function x_(e){return a_.has(e)?(u_(ft([...a_].filter(t=>t!==e))),!0):!1}function S_(e){Qg=e}function C_(){return Qg}function w_(){let e=e_;return e_=null,e}function T_(e){if(e!==t_){t_=e;for(let e of o_)e()}}function E_(e){o_.add(e)}function D_(){return document.documentElement.dataset.layout===`phone`&&t_}function O_(){D_()&&c_({kind:`return-to-queue`})}function k_(){let e=Tg(Zg,$g?.selectedKey()??null)[0]?.id??null;return e?(p_(e),!0):!1}function A_(e){let t=Zg.flatMap(e=>e.items).find(t=>t.prKey===e.toLowerCase());return!t||!Qg?.openReviews()?!1:(p_(t.key),__(),!0)}Wg(e=>{e.kind===`status`&&g_()}),Eh(e=>{e.kind===`prs`&&g_()});function j_(){return{groups:Zg}}var M_={OPEN:0,MERGED:1,CLOSED:2};function N_(e){return e?M_[e.state]:M_.OPEN}function P_(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:gn(void 0)};let i=Rm(t.stage);return{key:n,text:r,detailText:`${r} ${t.title}`,stateText:Lm(t.stage),url:t.url,prTitle:t.title,look:{icon:zm(t.stage),tone:i},tier:gn(i)}}function F_(e,t){let n=e.map(e=>{let n=t(Oe(e));return{link:e,pr:n?Tm(n):void 0}});return n.sort((e,t)=>N_(e.pr)-N_(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>P_(e,t))}var I_=new Map;function L_(e){return document.querySelectorAll(`[data-pr-rows-for="${CSS.escape(e)}"]`)}function R_(e){return F_(I_.get(e)??[],om).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,onActivate:()=>{A_(e.key)||bd(e.url)}}))}function z_(e,t){let n=Ve(`session-pr-chip-unlink`);return n.append(Ee(ut)),n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),$t({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:()=>{ua(t,{type:`unlink-session-pr`,id:t,key:e.key})}})}),n}function B_(e,t){let n=_n({...e,text:e.key},{...e,className:`linked-pr-row-link`});e.prTitle&&n.append(T(`span`,`linked-pr-row-title`,e.prTitle)),e.stateText&&n.append(T(`span`,`linked-pr-row-stage`,e.stateText));let r=T(`li`,`linked-pr-row`);return r.append(n,z_(e,t)),r}function V_(e,t){e.dataset.prRowsFor=t;let n=R_(t);on(e,n,e=>B_(e,t),{visibleCount:n.length})}function H_(e){for(let t of e){let e=t.dataset.prRowsFor;e&&V_(t,e)}}function U_(e,t){let n=Yt.shape.links.safeParse(t??[]);I_.set(e,n.success?n.data:[]),H_(L_(e)),Sn(e),kh(I_)}function W_(e){I_.delete(e),kh(I_)}sm(()=>{H_(document.querySelectorAll(`[data-pr-rows-for]`)),In()});function P(e){return String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function G_(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function K_(e,t){return e||G_(t)>0}var q_={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},J_=null,Y_=!1,X_=!1,Z_=null,Q_=null,$_=null,ev=`—`;function tv(e){return e==null?ev:ht(e,`GB`)}function nv(e){return e==null?ev:he(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function rv(e){return e==null?ev:`${nv(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function iv(){let e=T(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=T(`div`,`health-summary`),n=Ve(`health-toggle`);n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=T(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,T(`span`,`health-toggle-label`,`Health`));let i=T(`div`,`health-stats`);t.append(n,i);let a=T(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{X_=!X_,e.dataset.expanded=String(X_),n.setAttribute(`aria-expanded`,String(X_)),a.hidden=!X_,X_&&(s({type:`request-health-snapshot`}),ov())}),e.append(t,a),Z_=e,Q_=i,$_=a,e}function av(){if(!Q_||!J_)return;let e=J_,t=G_(e.anomalies);Q_.innerHTML=`
3
3
  <span class="health-stat"><span class="health-stat-label">Heap</span> ${tv(e.process.heapUsed)}</span>
4
4
  <span class="health-stat"><span class="health-stat-label">Memory</span> ${tv(e.process.rss)}</span>
5
5
  <span class="health-stat"><span class="health-stat-label">Buffers</span> ${tv(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 sv(){if(!Z_)return;let e=K_(Y_,J_?.anomalies),t=Z_.hidden;Z_.hidden=!e,e&&t&&J_&&(av(),X_&&ov())}function cv(e){Y_=e,sv()}function lv(e){if(Z_)return Z_;let t=iv();return e.appendChild(t),sv(),t}function uv(e){J_=e,sv(),Z_&&!Z_.hidden&&(av(),X_&&ov())}var dv=null,fv=null,pv=!1,mv=null,hv=new Set;function gv(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function _v(){for(let e of hv)e()}function vv(){return{report:dv,hasReportSendFailed:pv}}function yv(e){hv.add(e)}function bv(e){fv=e}function xv(){if(!fv)return;mv=d(`hooks-report`);let e=fv({type:`request-hooks-report`,requestId:mv});e!==!pv&&(pv=!e,_v())}function Sv(e){gv(e,mv)&&(dv=e,pv=!1,_v())}function Cv(){xv()}var wv=new Map,Tv=new Map,Ev=new Map,Dv=null,Ov=`op://vault/item/field`,kv=`or paste the value`;function Av(e,t){return Object.fromEntries([...e].map(([e,n])=>[e,t(n)]).filter(([,e])=>e))}function jv(e,t,n){s(t?{type:`secret-decision`,id:e,isAllowed:t,referenceByName:Av(n.referenceByName,e=>e.value.trim()),valueByName:Av(n.valueByName,e=>e.value),newItemsVault:n.vault.value.trim()}:{type:`secret-decision`,id:e,isAllowed:t})}function Mv(){return Dv??`vault name`}function Nv(e,t,n){let r=T(`input`,`dialog-input ${e}`);return r.type=`text`,r.placeholder=t,r.spellcheck=!1,r.autocomplete=`off`,r.setAttribute(`aria-label`,n),r}function Pv(e,t){let n=T(`div`,`secret-request`);n.setAttribute(`role`,`group`),n.setAttribute(`aria-label`,`Secret request`);let r={referenceByName:new Map,valueByName:new Map,vault:Nv(`secret-request-vault`,Mv(),`Vault for pasted values`)};Ev.set(e,r.vault);let i=T(`div`,`secret-request-rows`);for(let e of t){let t=Nv(`secret-request-reference`,Ov,`Vault reference for ${e}`),n=Nv(`secret-request-value`,kv,`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=T(`div`,`secret-request-row`);a.append(T(`code`,`secret-request-name`,e),t,n),i.append(a)}let a=T(`label`,`secret-request-vault-row`);a.append(T(`span`,`secret-request-vault-label`,`Pasted values go into`),r.vault);let o=T(`div`,`secret-request-actions`);return o.append(C({variant:`secondary`,label:`Deny`,onClick:()=>jv(e,!1,r)}),C({variant:`primary`,label:`Allow`,onClick:()=>jv(e,!0,r)})),n.append(T(`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 Fv(e){Dv=e;for(let e of Ev.values())e.placeholder=Mv()}function Iv(e){let t=Tv.get(e),n=wv.get(e);return t!==void 0&&n!==void 0&&t.dataset.names===n.join(` `)}function Lv(e){let t=O.get(e);if(t&&Iv(e)&&Tv.get(e)?.parentElement===t.termWrap)return;Tv.get(e)?.remove(),Tv.delete(e),Ev.delete(e);let n=wv.get(e);if(!n||!t)return;let r=Pv(e,n);r.dataset.names=n.join(` `),Tv.set(e,r),t.termWrap.append(r)}function Rv(e,t){t.length===0?wv.delete(e):wv.set(e,[...t])}function zv(e){Fv(e.newItemsVault),Rv(e.id,e.names),Lv(e.id)}function Bv(e){Fv(e.newItemsVault);let t=[...wv.keys()];wv.clear();for(let[t,n]of Object.entries(e.requests))Rv(t,n);for(let e of new Set([...t,...wv.keys()]))Lv(e)}var Vv=new Map;function Hv(e){return Vv.get(e)??[]}function Uv(e){return Hv(e).length>0}function Wv(e){let t=k(e)?.btnDocs;t&&(t.hidden=!Uv(e))}var Gv=null,Kv=null;function qv(){return Kv??=j(()=>import(`./doc-editor-ui-qzAOMLgj.js`).then(e=>(Gv=e,e),e=>(Kv=null,y(`doc-editor`,`doc editor failed to load: ${l(e)}`),null)),__vite__mapDeps([11,12,13,4,3,14,15,16,17,18])),Kv}function Jv(e){qv().then(t=>t?.openDocEditor(e))}function Yv(e){qv().then(t=>t?.openDocEditorOn(e))}function Xv(e){Gv?.applyDocsToOpenEditor(e)}function Zv(e){Vv.set(e.id,e.docs),e.docs.length===0&&Vv.delete(e.id),Wv(e.id),Xv(e.id)}function Qv(e){let t=[...Vv.keys()];Vv.clear();for(let[t,n]of Object.entries(e.sessions))Vv.set(t,n);for(let e of new Set([...t,...Vv.keys()]))Wv(e),Xv(e)}var $v=10,ey={low:0,medium:1,high:2};function ty(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 ny(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 ry(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function iy(e,t){for(let n of e.hotspots)ry(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`});for(let n of e.blastRadius)n.transitiveDependentCount<$v||ry(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`})}function ay(e,t){return e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function oy(e){return e.conflictRisk===null?-1:ey[e.conflictRisk]}function sy(e,t){return t.severity-e.severity||oy(t)-oy(e)||e.heading.localeCompare(t.heading)||e.groupKey.localeCompare(t.groupKey)}function cy(e,t){return e===null||t===null?e??t:ey[t]>ey[e]?t:e}function ly(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?(e.lines.push(n),e.conflictRisk=cy(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(ay);return n.sort(sy)}function uy(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:ty(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of ny(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);iy(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:ly(r.values()),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function dy(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 fy(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 py(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=fy(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 my(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function hy(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 gy({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=vy(a);return{text:s(`ready to merge into ${e}`,`Ready to merge into ${e}`),namesMergeTarget:!0}}return i?t?{text:s(`not ready to merge`,`Not ready to merge`),namesMergeTarget:!1}:{text:s(`not committed yet`,`Not committed yet`),namesMergeTarget:!1}:{text:s(`session ended`,`Session ended`),namesMergeTarget:!1}}function _y({status:e,mergeReason:t,fetched:n,hasDiffError:r,hasChanges:i,hasCommits:a,canMerge:o,isWorkspace:s,live:c,effectiveBase:l,changedFileCount:u=0}){return e===`parked`&&t===`base-diverged`?{text:`Parked: base branch diverged`,namesMergeTarget:!1}:e===`parked`?{text:`Parked: merge conflict`,namesMergeTarget:!1}:e===`merging`?{text:`Merging`,namesMergeTarget:!1}:e===`merged`?{text:`Merged`,namesMergeTarget:!1}:r?{text:`Could not read changes`,namesMergeTarget:!1}:n?i?gy({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 vy(e){return e||`base`}function yy(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function by(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function xy({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 Sy({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function Cy(e){if(!e)return[];let t=new Map;for(let n of[...py(e.committed?.diff),...py(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 wy(e,t){return t===null?null:e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)??null}function Ty(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 Ey(e){return e!==E.DORMANT&&e!==E.DONE&&e!==E.FAILED}function Dy(e,t){return(Lt.includes(e)||e===E.RUNNING)&&t}function Oy(e){let{status:t,reason:n,isFetched:r,hasCommits:i,isWorkspace:a,state:o,effectiveBase:s}=e,c=hy(e.files),l=Ey(o),u=by(t,n,Dy(o,i)),d=Sy({fetched:r,changedFileCount:c.files,hasCommits:i}),f=_y({status:t,mergeReason:n,fetched:r,hasDiffError:e.hasDiffError,hasChanges:c.files>0||i,hasCommits:i,canMerge:!a&&u.isEnabled,isWorkspace:a,live:l,effectiveBase:s,changedFileCount:c.files}),p=!a&&u.isRendered&&(d||t===`parked`||t===`merging`),m=xy({status:t,hasCommits:i,live:l,state:o});return{sentence:t===`parked`?`${f.text}. ${yy(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 ky=5e3,Ay=new Map,jy=new Map,My=new Map,Ny=new Map,Py=new Map,Fy=new Map,Iy=new WeakMap,Ly=new WeakMap,Ry=new Set,zy=new Set,By=null,Vy=null,Hy=null,Uy=null,Wy=null;function Gy(e){return Ry.add(e),()=>Ry.delete(e)}function Ky(e){for(let t of Ry)t(e)}function qy(e){if(!e)return[];let t=Iy.get(e);if(t)return t;let n=Cy(e);return Iy.set(e,n),n}function Jy(e){if(!e)return null;let t=Ly.get(e);if(t)return t;let n=uy(e);return Ly.set(e,n),n}function Yy(e){return O.get(e)?.card.dataset.workspace!==void 0}function Xy(e){let t=O.get(e);if(!t)return null;let n=My.get(e)??null,r=qy(n),i=Ny.get(e)??null;return{...Oy({status:Ay.get(e)||`none`,reason:jy.get(e)??null,isFetched:My.has(e),hasCommits:n?.hasCommits===!0,hasDiffError:i!==null,isWorkspace:Yy(e),state:t.currentState,effectiveBase:t.effectiveBase,isMergeInFlight:Fy.has(e),files:r}),sessionId:e,sessionName:t.card.dataset.session||e,files:r,diffError:i,changeMapView:Jy(Py.get(e)),notice:By?.sessionId===e?By.text:null,isWorkspace:Yy(e)}}function Zy(e,t){By={sessionId:e,text:t},Vy&&clearTimeout(Vy),Vy=setTimeout(()=>{By=null,Ky(e)},ky),Ky(e)}function Qy(e){Py.has(e)||Py.set(e,null),s({type:`request-change-map`,id:e})}function $y(e){s({type:`request-session-diff`,id:e}),Qy(e)}function eb(e,t){let n=Ay.get(e);Ay.set(e,t),my(n,t)&&(My.delete(e),Ny.delete(e),Py.delete(e),e===ta()&&$y(e)),Ky(e)}function tb(e,t,n=null){let r=t||`none`;jy.set(e,n);let i=Fy.get(e);i!==void 0&&i!==r&&Fy.delete(e),eb(e,r)}function nb(e,t,n=null){jy.set(e,n),Fy.delete(e),eb(e,t||`none`)}function rb(e,t){let n=D(e);n&&(My.set(n,t),Ny.delete(n),Ky(n))}function ib(e,t){let n=D(e);n&&(Ny.set(n,t),Ky(n))}function ab(e,t){let n=D(e);if(!n)return;let r=tt.safeParse(t);r.success&&r.data.sessionId===n&&(Py.set(n,r.data),Ky(n))}function ob(e){let t=D(e);t&&t===ta()&&$y(t)}function sb(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function cb(e){let t=D(e);if(!t||t!==ta())return;let n=!My.has(t)||Ny.has(t),r=!Py.has(t)||sb(Py.get(t));n&&$y(t),r&&!n&&Qy(t),Ky(t)}function lb(e){let t=D(e);t&&Fy.delete(t)&&Ky(t)}function ub(e){let t=D(e);Ay.delete(t),jy.delete(t),My.delete(t),Ny.delete(t),Py.delete(t),Fy.delete(t),t===ta()?Ki(null):Ky(t)}function db(e,t){Fy.has(e)||(s(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(Fy.set(e,Ay.get(e)||`none`),Ky(e)):Zy(e,`Not connected. The merge was not sent.`))}function fb(e){let t=Xy(e);return t?Fy.has(e)?(Zy(e,`Merge is already on its way for "${t.sessionName}".`),!1):t.isMergeEnabled?O.get(e)?.currentState===E.RUNNING?($t({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:()=>db(e,!0)}),!0):(db(e,!1),!0):(Zy(e,t.mergeRefusal??`Nothing to merge in "${t.sessionName}" right now.`),!1):!1}function pb(e){let t=Xy(e);t?.isDiscardShown&&$t({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 mb(){return[...zy].some(e=>!e.hasAttribute(`data-slot-held`))}function hb(){let e=mb()&&document.visibilityState===`visible`?ta():null;e!==Hy&&(Uy&&clearInterval(Uy),Uy=null,Hy=e,s({type:`watch-session-changes`,id:e}),e&&(Uy=setInterval(()=>s({type:`watch-session-changes`,id:e}),Ze)))}function gb(e){Wy??=_b(),Wy.observe(e)}function _b(){return document.addEventListener(`visibilitychange`,hb),Gi(e=>{e&&$y(e),hb()}),new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&zy.add(t.target),t.isIntersecting||zy.delete(t.target);hb()})}var vb=!1,yb=new Set;function bb(e){vb=!!e,jb();for(let e of yb)e(vb)}function xb(e){return yb.add(e),()=>yb.delete(e)}function Sb(){return vb}function Cb(){let e=T(`div`,`debug-close`);return e.append(C({variant:`icon`,size:`small`,label:`Close debug overlay`,icon:Ee(ut)})),e}function wb(e){return e?pt(new Date(e)):`-`}function Tb(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function Eb(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Tb(e.quietMs)})`:``}function Db(e){let t=`<span class="debug-dim">${wb(e.ts)}</span>`;if(e.kind===`signal`){let n=P([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${P(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=Eb(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${P(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=P(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${P(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${P(e.category||`?`)}: <span class="debug-dim">${P(e.from||`?`)} → ${P(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${P(e.kind||`decision`)}</span>`}function Ob(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">${P(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">${P(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${wb(e.timestamp)}</span> ${P(e.from)} → ${P(e.to)} <span class="debug-label">${P(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?`${P(a.signal)} (${P(a.source||`?`)}${a.confidence?`/${P(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">${P(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 ${Tb(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">${P(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">${Db(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(Cb())}function kb(e,t){if(e.debugOpen){Ab(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(Cb()),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`)&&Ab(e)}),s({type:`debug-state`,id:t})}function Ab(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function jb(){for(let[,e]of O)e.btnDebug.classList.toggle(`visible`,vb),e.btnTrace.classList.toggle(`visible`,vb),vb||e.debugOpen&&Ab(e)}function Mb(e){let t=typeof e.id==`string`?O.get(e.id):void 0;t?.debugOpen&&Ob(t,e.payload)}function Nb(e){k(e)?.debugOpen&&s({type:`debug-state`,id:e})}function Pb(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:typeof t==`string`&&vt.has(t)}}function Fb(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 Ib(e,t){return{body:t.join(`
74
- `),tag:`glimmervoid-alert-${e.id}`,renotify:e.isStart}}var Lb=4e3;function Rb(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function zb(e,t,n,r=Lb){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 Bb=`#plan/`;function Vb(e){return`${Bb}${encodeURIComponent(e)}`}function Hb(e){if(!e.startsWith(Bb))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var Ub=null;function Wb(){return Ub??=j(()=>import(`./alert-sound-At4lBeip.js`),__vite__mapDeps([10,6])).catch(e=>(Ub=null,y(`alert-sound`,`alert sound failed to load: ${l(e)}`),null)),Ub}function Gb(){let e=ui();Wb().then(t=>t?.playAlertSound(e))}function Kb(){return typeof Notification>`u`?null:Notification}function qb(){return Kb()!==null}function Jb(){let e=Kb();return e?e.permission:`unavailable`}async function Yb(){let e=Kb();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function Xb(){return!qb()&&!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.`:qb()?Jb()===`denied`&&Wr()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function Zb(){if(!qb()||!Wr())return`off`;let e=Jb();return e===`granted`?`on`:e==="default"?`ask`:`off`}function Qb(){return Wr()&&Jb()==="default"}function $b(e=()=>{}){let t=T(`div`,`notification-permission`),n=()=>{let r=Xb();if(t.replaceChildren(),t.hidden=!r&&!Qb(),r){t.append(T(`p`,`notification-permission-hint text-meta text-text-muted`,r));return}let i=C({variant:`secondary`,label:`Enable desktop notifications`});i.addEventListener(`click`,()=>{i.disabled=!0,Yb().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var ex=`Notifications`,tx=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,nx=new Map,rx=!1;function ix(){rx||(rx=!0,Tr({source:ex,message:tx,hidesInStreamerMode:!1}))}function ax(e,t){let n=nx.get(e)??new Set;n.add(t),nx.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function ox(e){let t=nx.get(e);if(t){nx.delete(e);for(let e of t)e.close()}}function sx(e){return!qb()||!Wr()||document.documentElement.hasAttribute(`data-streamer`)?!1:e||!document.hasFocus()}function cx(){return sx(!1)&&Jb()===`granted`}var lx=null;function ux(e,t){let n=Kb();if(!n||(lx=Fb(lx,t,e.message),wr(ex),!zb(window.localStorage,Rb(`group-${t.id}`,`${e.session}-${e.category}`),Date.now())))return;let r=t.sessionIds.length===1?O.get(e.session):void 0,i=t.sessionIds.length>1?`${t.sessionIds.length} sessions`:r?ar(r):`Glimmervoid`;try{let r=new n(i,Ib(t,lx.lines));r.onclick=()=>{window.focus(),e.kind===`plan`&&(window.location.hash=Vb(e.session)),r.close()};for(let e of t.sessionIds)O.has(e)&&ax(e,r)}catch{}}var dx=null;function fx(e){return!e||e.id!==dx&&(dx=e.id,!0)}function px(e){O.get(e.session)?._isActiveViewer?.()===!0?s({type:`alert-seen`,id:e.session}):fx(e.group)&&xi()&&Gb()}function mx(e,t){t?ux(e,t):vx(e)}function hx(){let e=Reflect.get(navigator,`userAgentData`);return typeof e!=`object`||!e?!1:Reflect.get(e,`platform`)===`macOS`}function gx(e){!document.hasFocus()&&cx()&&vx(e)}function _x(e){if(vt.has(e.category??``)){gx(e);return}if(document.hasFocus()){px(e);return}let t=e.group;cx()&&(mx(e,t),!hx())||(sx(!1)&&Jb()===`denied`&&ix(),t?.isStart!==!1&&fx(t)&&xi()&&Gb())}function vx({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=Kb();if(!a||!sx(!!i)||(a.permission===`denied`&&ix(),a.permission!==`granted`)||(wr(ex),!zb(window.localStorage,Rb(e,t),Date.now())))return;let o=typeof e==`string`?e:``,s=O.get(o),c=s?ar(s):``;try{let i=new a(c||`Glimmervoid`,Pb(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=Vb(o)),i.close()},s&&ax(o,i)}catch{}}var yx=null;function bx(){return yx??=j(()=>import(`./resume-dialog-DRD_GKrw.js`),__vite__mapDeps([19,13,4,3,12,14,20,21,15])).catch(e=>(yx=null,y(`resume-dialog`,`restart dialog failed to load: ${l(e)}`),null)),yx}var xx=null,Sx=null;function Cx(){return Sx??=j(()=>import(`./plan-face-VwtdBhdq.js`).then(e=>(xx=e,e),()=>(Sx=null,null)),__vite__mapDeps([22,13,4,3,23,15,24,16,25])),Sx}function wx(e){let t=T(`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,Cx().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 Tx=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function Ex(e){return e===`approve`||e===`approve-accept-edits`}function Dx(e){return(e.state===`decided`||e.state===`closed`)&&Ex(e.lastDecision)}function Ox(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&Dx(n)}function kx(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function Ax(e){let t=kx(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 jx(e,t){return kx(e,t)?.openRevision?.revision??null}function Mx(e,t,n){if(n===null)return null;let r=kx(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function Nx(e,t){let n=t-e;return Number.isFinite(n)?pe(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function Px(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 Fx(e,t,n){let r=Px(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return Tx.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function Ix(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 Lx(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function Rx(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+st}function zx(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 ${Ye} characters, so nothing was sent`:Lx(e)>1e4?`the feedback composes more than the ${qe} characters the hook reply carries, so nothing was sent`:Rx(e)>We?`the decision is larger than one control frame carries, so nothing was sent`:null}function Bx(e){return e?`, ${e}`:``}function Vx(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=Ix(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 Hx(e,t,n){let r=Vx(e,t,n);return r?`${r}${Bx(e.problem)}`:e.problem??``}function Ux(e){let t=kx(e.state,e.selectedAgentId),n=Ax(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:Hx(e,t,n),actions:Fx(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:Px(e,t,n)}]}}function Wx(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 Gx({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 Kx({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var qx=e=>Gt.includes(e),Jx=e=>Vt.includes(e);function Yx(e){let t=e.currentState;e.btnRestart.classList.toggle(`visible`,qx(t)||Jx(t)||t===E.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,Sb()),e.btnPlan.hidden=Kx(e)===`hidden`}function Xx(e){let t=k(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(D(e)),Yx(t),au(t,D(e)),!0)}function Zx(e,t){let n=k(e);n&&(n.hasPlan=t===!0,Yx(n))}function Qx(e){let t=k(e.id);t&&(t.planReviewState=Wx(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),Yx(t))}function $x(e){let t=k(e.id);t&&t.planFace.update({draft:e})}function eS(e){let t=k(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),Yx(t))}function tS(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=k(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function nS(e){for(let[,t]of O)t.planFace.update({isConnected:e})}var rS=160,iS=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 aS(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=rS?t:`${t.slice(0,157)}...`}function oS(e,t){let n=iS[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?aS(r):``}var sS=5e3;function cS(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function lS(e,t){if(!e.toolUseId)return cS(e.text)??`context`;let n=t.get(e.toolUseId);return n?oS(n.name,n.input)||n.name:`expansion`}function uS(e){return e.kind!==`expansion`||e.toolUseId?!1:cS(e.text)!==null}function dS(e){return e.kind===`prompt`||e.kind===`session`||uS(e)}function fS(e){return new TextEncoder().encode(e).byteLength}var pS={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`};function mS(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:aS(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:aS(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:aS(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:aS(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:aS(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:lS(e,t)};if(e.kind===`tool_call`){let t=oS(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:`${fS(e.content)} bytes`}}function hS(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function gS(e,t){let n=mS(e,t),r=hS(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:pS[e.kind],text:`${r}${i}`,tone:o,badges:a}}function _S(e,t){return{record:e,...gS(e,t)}}function vS(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function yS(e,t){let n=vS(e);return!n||t.has(n)?null:n}function bS(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function xS(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function SS(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=vS(i.record);a&&t.has(a)&&(n.rows[r]=_S(i.record,e.toolCallByUseId))}}function CS(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function wS(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function TS(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=fS(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function ES(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=yS(i,e.toolCallByUseId);t&&bS(e.unresolvedToolUseCounts,t);let a=_S(i,e.toolCallByUseId);if(dS(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:wS()},TS(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:wS()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),TS(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 DS(e,t){let n=CS();ES(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)||bS(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],SS(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function OS(e){return e.rows.length+ +!!e.head}function kS(e){let t=0;for(let n of e.turns)t+=OS(n);return t}function AS(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=vS(n.record);t&&xS(e.unresolvedToolUseCounts,t)}}function jS(e,t){AS(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);AS(e,i);for(let e of i)TS(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function NS(e,t=sS){let n=kS(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=OS(t),jS(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 PS(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 FS(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 IS(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 LS(e,t=sS){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function RS(e,t=sS){return!LS(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function zS(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 BS=1e4,VS=null,HS=null,US=[],WS=null,GS=null,F=null,KS=null,qS=!1,JS=null,YS=()=>!1,XS=new Set;function ZS(e){for(let t of XS)t(e)}function QS(){KS&&=(clearTimeout(KS.timeoutHandle),null)}function $S(){KS=null,JS=`The trace did not load within ${Math.round(BS/1e3)} s.`,ZS({kind:`rebuild`})}function eC(e){QS(),qS=!1,JS=null,WS=e,F=e?{sessionId:e,grouping:CS(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,ZS({kind:`selection-reset`})}function tC(e){let t=FS(US,GS,WS,e);return GS&&t===GS&&(GS=null),t!==WS&&(eC(t),!0)}function nC(e){if(!VS)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};VS(t)?KS={request:e,timeoutHandle:setTimeout($S,BS)}:(JS=x,ZS({kind:`header`}))}function rC(e=!1){if(!VS)return;let t=IS({selectedSessionId:WS,isPanelVisible:e||YS(),hasPendingRequest:!!KS,hasLoadedOnce:F?.hasLoadedOnce??!1,nextOffset:F?.nextOffset??0});t&&nC(t)}function iC(){qS&&!KS&&(qS=!1,rC())}function aC(){if(!F)return;let e=NS(F.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!F.hasDroppedEarliestRows;t&&(F.hasDroppedEarliestRows=!0),ZS({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function oC(e){F&&(ZS({kind:`records-appended`,appends:ES(F.grouping,e)}),aC())}function sC(e){F&&(ZS({kind:`records-prepended`,prepend:DS(F.grouping,e)}),aC())}function cC(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 lC(){return{selectedSessionId:WS,hasPendingRequest:!!KS,hasLoadedOnce:F?.hasLoadedOnce??!1,hasDroppedEarliestRows:F?.hasDroppedEarliestRows??!1,firstOffset:F?.firstOffset??0,residentRowCount:F?kS(F.grouping):0}}function uC(){return{sessionOptions:US,selectedSessionId:WS,selectedTrace:F,pendingSessionId:KS?.request.id??null,traceFailureText:JS}}function dC(e){XS.add(e)}function fC(e){YS=e}function pC(){if(!VS)return;let e=RS(lC());e&&nC(e)}function mC(e){US.some(t=>t.id===e)&&e!==WS&&(GS=null,eC(e),rC(),ZS({kind:`rebuild`}))}function hC(){let e=tC(!0);return rC(!0),e}function gC(e){VS=e}function _C(e){HS=e}function vC(e){GS=e,HS?.()}function yC(e){US=PS(e);let t=tC(YS());t&&rC(),ZS({kind:`sessions`,hasSelectionChanged:t})}function bC(e){let t=cC(e);if(!t)return;let n=zS({pendingRequest:KS?.request??null,resident:F?{sessionId:F.sessionId,firstOffset:F.firstOffset,nextOffset:F.nextOffset,hasLoadedOnce:F.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?iC():(QS(),JS&&(JS=null,ZS({kind:`header`})),n===`stale`?iC():n===`reset`?(eC(t.id),F&&(F.filePath=t.path),rC(),ZS({kind:`rebuild`}),iC()):F&&(F.filePath=t.path,n===`prepend`?(F.firstOffset=t.start,sC(t.records),iC()):(n===`seed`&&(F.hasLoadedOnce=!0,F.firstOffset=t.start),F.nextOffset=t.next,oC(t.records),iC())))}function xC(e){let t=e?.id;typeof t==`string`&&t===WS&&YS()&&(KS?qS=!0:rC())}function SC(e){let t=e?.id;if(typeof t!=`string`||KS?.request.id!==t)return!1;QS(),qS=!1;let n=e?.message;return JS=typeof n==`string`&&n?n:`The trace could not be read.`,ZS({kind:`rebuild`}),!0}function CC(e){QS(),qS=!1,JS=e?null:x,e?(ZS({kind:`header`}),rC()):ZS({kind:`rebuild`})}function wC(e,t,n=!1){let r=T(`label`,`dialog-checkbox-label`),i=T(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,T(`span`,null,e)),r}function TC(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function EC(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:TC(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 DC(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:a}=tn({title:`Workspace repositories`}),o=T(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),s=T(`fieldset`,`dialog-workspace-list`);s.setAttribute(`aria-label`,`Workspace repositories`),s.append(T(`div`,`dialog-hint`,`Loading repositories...`));let l=T(`div`,`dialog-hint`);l.setAttribute(`role`,`status`);let u=T(`div`,`dialog-error`),d=C({variant:`primary`,label:`Save`,disabled:!0});i.append(d),n.append(o,s,l,u,i),a.addEventListener(`click`,r),requestAnimationFrame(()=>a.focus()),EC(e).then(e=>{if(t.isConnected){s.textContent=``;for(let t of e)s.append(wC(t.name,t.path,t.isMember));d.disabled=!1}}).catch(e=>{t.isConnected&&(s.textContent=``,u.textContent=`Could not load repositories: ${Wn(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: ${Wn(e)}`)}).finally(()=>{l.textContent=``,d.disabled=!1}))})}function OC(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function kC(e,t){pn(e.taskTitleEl,()=>un(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),ln(e,t)}),e.nameEl.addEventListener(`click`,()=>{fn(e.nameEl)||Ki(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`,()=>{OC(e),ln(e,t,{returnsFocusToTerminal:!e.renameTargetEl?.isConnected})}),e.btnRestart.addEventListener(`click`,()=>{OC(e),bx().then(n=>n?.openRestartDialog(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0}))}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{OC(e),DC(t)}),e.btnTrace.addEventListener(`click`,()=>{OC(e),vC(t)}),e.btnDocs.addEventListener(`click`,()=>{OC(e),Jv(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=Kx(e);n!==`hidden`&&(n===`face`?Xx(t):location.hash=Vb(t))}),e.btnRemove.addEventListener(`click`,()=>{OC(e),ea(t)});function n(){for(let[,t]of O)t!==e&&OC(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`)}e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation(),e.sessionMenu.classList.contains(`open`)?OC(e):n()}),da({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:()=>OC(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&&OC(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),OC(e),kb(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&Ab(e)},{signal:e.abortController.signal})}var AC=1500,jC=new WeakMap;function MC(e){clearTimeout(jC.get(e)),jC.delete(e)}function NC(e,t){let n=setTimeout(()=>{jC.delete(e),s({type:`dismiss`,id:t,expectedState:E.COMPLETE})},AC);jC.set(e,n)}function PC(e,t,n){let r=document.activeElement;return Wi({previousState:t,nextState:n,isPhoneLayout:us(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}var FC=e=>e==null?``:String(e);function IC(e,t,n){let r=k(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&hn(e,r.taskTitle)}}function LC(e){return typeof e==`string`&&O.has(e)}function RC(){return O.size}function zC(e){let t=e||{};t.linkPreviews!=null&&Yd(t.linkPreviews),t.cursorBlink!=null&&Rf(t.cursorBlink),t.debugMode!=null&&(bb(t.debugMode),cv(t.debugMode));for(let[,e]of O)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function BC(){Vu(O.values(),Uu())}function VC(e){return{state:e.currentState,unseenOutcome:e.unseenOutcome,ownerId:e.ownerId}}function HC(){let e=ur(hr.counts),t=e>0?`(${e}) Glimmervoid`:`Glimmervoid`;document.title!==t&&(document.title=t)}function UC(e,t,n,r={}){if(!fr)return;let i=D(e),a=FC(n)||E.DORMANT,o=Bn(i,FC(t),a,r),c=a===E.DORMANT;fr.appendChild(o.card);let l;function u(){l.face=`terminal`,l.card.dataset.face=`terminal`,l.termWrap.hidden=!1,l.planFace.hide(),Yx(l),Jf(l,i)}let d=new AbortController,f=wx({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=>Tn(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:FC(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=()=>Jf(l,i),l._showTerminalFace=u,l._showPreferredFace=u,l._setBorrowed=e=>{l.isBorrowed=e,o.card.toggleAttribute(`data-borrowed`,e),Yx(l)},o.card.append(f.el);let p=O.get(i);return p&&Kn(hr,VC(p)),O.set(i,l),dr(hr,VC(l)),Mr(i,l),kC(l,i),Yx(l),l.btnDocs.hidden=!Uv(i),Lv(i),a===E.RUNNING&&jr(l,!0),c||Gf(l,i),HC(),l}function WC(e,t){let n=k(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function GC(e,t){let n=k(e);if(!n)return;n.agent=typeof t==`string`?t:null;let r=n.card.querySelector(`.session-agent-mark`);r&&Gn(r,n.agent),Yx(n)}function KC(e,t){let n=k(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function qC(e,t,n=!1){let r=k(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=Jt(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function JC(e,t){let n=k(e);n&&(n.pendingPromptKind=typeof t==`string`?t:null)}function YC(e,t){let n=k(e);n&&(Kn(hr,VC(n)),n.unseenOutcome=t??null,dr(hr,VC(n)))}function XC(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function ZC(e,t,n=null){let r=k(e),i=FC(t)||`none`;r&&XC(r.card,i),tb(D(e),i,FC(n)||null)}function QC(e,t,n=null){let r=k(e),i=FC(t)||`none`;r&&XC(r.card,i),nb(D(e),i,FC(n)||null)}function $C(e,t){let n=k(e);if(!n)return;let r=FC(t);n.card.dataset.session=r,n.nameEl.textContent=r}function ew(e){let t=k(e);t&&(Ab(t),Kn(hr,VC(t)),O.delete(D(e)),Mr(D(e),void 0),xx?.dropPlanBodyCache(D(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),Pu(t,D(e)),Jo(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),HC())}function tw(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 nw(e,t){e.term&&(t===E.DONE||t===E.FAILED)&&(e.term.clear(),e.term.reset())}function rw(e){let t=O.get(e);t&&document.visibilityState===`visible`&&(us()||document.hasFocus())&&(jn(e),or({state:t.currentState,unseenOutcome:t.unseenOutcome})&&s({type:`dismiss`,id:e,expectedState:t.currentState}))}function iw(e,t,n){let r=k(e);if(!r)return;let i=FC(t),a=r.currentState;Kn(hr,VC(r)),r.currentState=i,dr(hr,VC(r)),Mr(D(e),r),i!==E.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(MC(r),r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),jr(r,i===E.RUNNING)),a===E.DORMANT&&i!==E.DORMANT&&Gf(r,D(e)),Yn({state:i})===`resting`&&ox(D(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,Jt(i,r.awaitingBackgroundTasks)),Yx(r),PC(r,a,i)&&NC(r,D(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)&&tw(r,s,i),i===E.INITIALIZING&&nw(r,a),HC()}var aw=ja({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function ow(e){let t=T(`ul`,`session-setup-list`);return t.append(...e.map(e=>T(`li`,null,e))),t}function sw(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=Ht(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[T(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=T(`div`,`session-setup-plugin`);return t.append(T(`h3`,null,e.name)),e.skills.length>0&&t.append(T(`p`,`session-setup-label`,`Skills`),ow(e.skills)),e.agents.length>0&&t.append(T(`p`,`session-setup-label`,`Agents`),ow(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[ow(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=T(`p`,`session-setup-hook`);return t.append(T(`span`,null,e.event),T(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>T(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[ow(t.skills)]:[]),n(`Agents`,t.agents.length>0?[ow(t.agents)]:[])}function cw(e){let t=T(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=T(`div`,`session-setup-sections`);aw.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function lw(e){let t=aw.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;sw(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function uw(e){return pe(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function dw(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${uw(Date.now()-e)} ago`}var fw=e=>`polled ${dw(e)}`;function pw(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=fw){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=Nr(a)}}}var mw=80,hw=Object.freeze([{value:`day`,label:`Today`,days:1},{value:`week`,label:`Last 7 days`,days:7},{value:`month`,label:`Last 30 days`,days:30}]),gw=`week`;function _w(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function vw(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function yw(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${_w(String(Math.abs(t)))}`}function bw(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}$${_w(r)}.${i}`}function xw(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}${vw((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${vw((n/1e6).toFixed(2))}M`:`${t}${vw((n/1e9).toFixed(2))}B`}function Sw(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=mw?`warn`:`ok`}var Cw=90;function ww(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&S(e.budgetUsd,null)!==null):[]}function Tw(e){let t=S(e?.pct,null);return t===null?0:t}function Ew(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=S(n.pct,null),i=S(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}function Dw(e){return e?.vendor===`codex`||e?.vendor===`kimi`?e.vendor:`claude`}function Ow(e,t=null){let n=[],r=Sw(Ew(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 ww(e)){let e=Tw(t);if(e<Cw)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return ft(n)}function kw(e,t=``){let n=e?.source;if(n===`fetched`){let e=$e(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=$e(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 Aw(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 jw(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=jw(e.dirs);if(n!==null&&t.push(`${yw(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${yw(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${yw(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${yw(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 Nw(e){return $e(e?.error,``)}function Pw(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}var Fw=`Estimated list prices, not a bill.`,Iw=`Enable in Settings.`,Lw=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Rw=/^(\d{4})-(\d{2})-(\d{2})$/,zw=new Set([`day`,`model`,`label`]),Bw=new Set([`model`,`label`]);function Vw(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${vw(e.toFixed(1))}%`}var Hw=`tokens`,Uw=Object.freeze([{value:`tokens`,label:`Tokens`},{value:`cost`,label:`Cost`}]);function Ww(e){return e===`cost`?`cost`:Hw}function Gw(e,t){return t===`cost`?bw(e):xw(e)}function Kw(e,t){if(t===`tokens`)return`tokens`;let n=Number(e?.costUSD);return Number.isFinite(n)&&n>0?`costUSD`:`tokens`}function qw(e){return e===`costUSD`?`share of cost`:`share of tokens`}function Jw(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function Yw(e){let t=Rw.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=Lw[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function Xw(e){let t=Zw(e);return t.length===0?``:t.length===1?Yw(t[0]):`${Yw(t[0])} to ${Yw(t[t.length-1])}`}function Zw(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>Rw.test(e)).sort()}function Qw(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:$w(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function $w(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=eT(e,n);return Rw.test(r)?r:eT(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function eT(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function tT(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:he(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function nT(e,t){let n=dD(Ne(t),-1),[,r,i]=e.yesterday.day.split(`-`).map(Number),a=e.yesterday.day===n?`yesterday`:`${Lw[r-1]} ${i}`,o=e.yesterday.sessionCount===1?`session`:`sessions`;return`${a}: ${e.yesterday.sessionCount} ${o}, ${tT(e.yesterday.activeMs/6e4)}`}function rT(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=Lw[n.getMonth()];return r?`${r} ${n.getDate()} ${_e(n)}`:`-`}var iT=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`}),aT=`Sessions spawned by Glimmervoid; terminal sessions count as other`,oT=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function sT(e){let t=$e(e,``);return t?iT[t]||t:iT.other}function cT(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function lT(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function uT(e){return cT(e).some(e=>lT(e.lane))}var dT=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function fT(e,t,n){let r=Ew(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function pT(e,t,n,r){if(!Array.isArray(t))return null;let i=t.filter(e=>e&&typeof e.lane==`string`),a=i.reduce((e,t)=>e+S(t.costUSD,0),0),o=i.reduce((e,t)=>e+S(t.tokens,0),0),s=i.filter(e=>lT(e.lane)).map(e=>({lane:String(e.lane),label:sT(e.lane),tokens:S(e.tokens,0),costUSD:S(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?Jw(c,a):Jw(l,o),d=fT(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:dT[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function mT(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:iE.map(e=>pT(e.key,r[e.key],t,n)).filter(e=>e!==null)}function hT(e){return e.planPct===null?``:`about ${Vw(e.planPct)} of plan`}function gT(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?bw(e.costUSD):xw(e.tokens)}`).join(`, `)}var _T=`team-review`;function vT(e){if(!Array.isArray(e?.byLane))return``;let t=cT(e).find(e=>e.lane===_T),n=S(t?.costUSD,0);if(n<=0)return``;let r=Jw(n,e?.totals?.costUSD),i=r===null?``:`, ${Vw(r)} of this period`;return`PR reviews cost ${bw(n)}${i}.`}function yT(e){let t=S(e,null);return t===null||t<=0?``:`${yw(t)} ${t===1?`session`:`sessions`}`}function bT(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function xT(e){let t=bT(e);if(!t)return``;let n=S(t.savedUSD,0);if(n<=0)return``;let r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e).length,i=r===0?``:`, at least, since ${r} ${r===1?`model has`:`models have`} no price`;return`Prompt caching saved ${bw(n)}${i}, across ${xw(S(t.cacheReadTokens,0))} cache read tokens.`}function ST(e){return e===`monthly`?`this month`:`today`}function CT(e){return`${bw(S(e?.spentUsd,0))} of ${bw(S(e?.budgetUsd,0))}`}function wT(e){return`${ST(e?.scope)} spend against budget`}var TT=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function ET(e){let t=Rw.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function DT(e){let t=ET(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Ne(t)}function OT(e){let t=Rw.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function kT(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 AT(e,t){e.tokens+=S(t?.tokens,0),e.costUSD+=S(t?.costUSD,0),e.input+=S(t?.input,0),e.output+=S(t?.output,0),e.cacheCreate+=S(t?.cacheCreate,0),e.cacheRead+=S(t?.cacheRead,0),e.days+=1,e.sources.add(t?.source===`history`?`history`:`live`);let n=Array.isArray(t?.vendors)?t.vendors:[];for(let t of n)e.vendorSet.add(t);let r=t?.models||[];for(let t of r){t?.vendor&&e.vendorSet.add(t.vendor);let n=hE(t),r=e.modelByName.get(n)||{key:n,model:t?.model??n,vendor:t?.vendor,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0};r.tokens+=S(t?.tokens,0),r.costUSD+=S(t?.costUSD,0),r.input+=S(t?.input,0),r.output+=S(t?.output,0),r.cacheCreate+=S(t?.cacheCreate,0),r.cacheRead+=S(t?.cacheRead,0),e.modelByName.set(n,r)}}function jT(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)||kT(r);AT(i,e),n.set(r,i)}return Array.from(n.values()).map(jT)}function NT(e){return MT(e,DT)}function PT(e){return MT(e,OT)}function FT(e,t){return t===`week`?NT(e):t===`month`?PT(e):Array.isArray(e)?[...e]:[]}var IT=/^(\d{4})-(\d{2})$/;function LT(e,t){if(t===`month`){let t=IT.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=Lw[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=Yw(e);return t===`-`?t:`week of ${t}`}return Yw(e)}function RT(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var zT=16,BT=Object.freeze([.05,.25,.5,.75]),VT=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function HT(e,t){let n=S(e,0),r=S(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<BT.length;e+=1)i>=BT[e]&&(a=e+1);return a}function UT(e,{weeks:t=zT,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>Rw.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`&&Rw.test(n)?n:Ne(o),c=ET(DT(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Ne(l),d=[],f=0,p=null;for(let e of r){let t=String(e.day);(p===null||t<p)&&(p=t),t<u||t>s||(f=Math.max(f,S(e.tokens,0)))}for(let e=0;e<t;e+=1)for(let t=0;t<7;t+=1){let n=new Date(l.getFullYear(),l.getMonth(),l.getDate()+e*7+t,12),r=Ne(n),a=i.get(r)||null,o=r>s,c=p!==null&&r<p;d.push({day:r,week:e,weekday:t,tokens:S(a?.tokens,0),costUSD:S(a?.costUSD,0),source:a?.source===`history`?`history`:a?`live`:null,noData:o||c||!a&&p===null,tone:HT(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function WT(e){let t=Yw(e?.day);if(e?.noData)return`${t}: no data`;let n=S(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${xw(n)} tokens, ${bw(S(e?.costUSD,0))}`}function GT(e){if(!e)return``;let t=S(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${YT(e.ratio)} the ${n} average: ${bw(e.todayUsd)} against ${bw(e.baselineUsd)}.`}function KT(e){return e?`This block is burning ${YT(e.ratio)} the usual rate: ${xw(e.current)} tokens per minute against ${xw(e.baseline)}.`:``}function qT(e){return[GT(e?.daily),KT(e?.burn)].filter(Boolean).join(` `)}function JT(e){return!!(e?.daily||e?.burn)}function YT(e){let t=S(e,null);return t===null?`-`:`${vw(t.toFixed(1))}x`}var XT=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`,kimi:`Kimi`});function ZT(e){let t=$e(e,``);return t?XT[t]||t:XT.claude}function QT(e,t){return eE(t)?ZT(e?.vendor):``}function $T(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>S(t[n]?.tokens,0)-S(t[e]?.tokens,0)).map(e=>({vendor:e,label:ZT(e),tokens:S(t[e]?.tokens,0),costUSD:S(t[e]?.costUSD,0)}))}function eE(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 tE=`Claude only`;function nE(e){return eE(e)?tE:``}var rE=36e5,iE=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]),aE=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`},{vendor:`kimi`,label:`Kimi Code`}]);function oE(e,t=Date.now()){let n=S(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function sE(e,t=Date.now()){let n=S(e,null);return n===null||n<=0||t-n>rE}function cE(e,t=Date.now()){if(!sE(e,t))return``;let n=oE(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function lE(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 uE(e){let t=$e(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function dE(e){return Nw(e)!==``}function fE(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 pE(e){return typeof e?.id==`string`&&e.id!==``}function mE(e){let t=$e(e?.label,``);return pE(e)&&t?t:fE(e?.project)||t||`unknown project`}function hE(e){let t=typeof e==`string`?e:e?.model;return $e(t,`unknown model`)}function gE(e){return String(e?.day??``)}function _E(e,t,n){if(!zw.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?gE(e):n(e)}function vE(e,t,n,r=mE){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=_E(e,t,r),o=_E(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 yE(e){return Bw.has(e)?`asc`:`desc`}function bE(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:yE(t)}}function xE(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var SE=Object.freeze({key:`lastTs`,dir:`desc`}),CE=Object.freeze({key:`tokens`,dir:`desc`}),wE=Object.freeze({key:`day`,dir:`desc`});function TE(e,t=SE){return vE(e,t.key,t.dir,mE)}function EE(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 DE(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${yw(t)} hidden`}function OE(e,t=CE){return vE(e,t.key,t.dir,hE)}function kE(e,t=wE){return vE(e,t.key,t.dir,gE)}function AE(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function jE(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,NE=24*ME,PE=Object.freeze({fiveHour:{lengthMs:5*ME,label:`5-hour`},sevenDay:{lengthMs:7*NE,label:`weekly`}}),FE=10,IE=80,LE=100,RE=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function zE(e,t){return e>=LE?`fail`:e>=IE||t!==null&&t>=IE?`warn`:`ok`}function BE(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 VE(e,t,n,r){let i=Ew(n,t);if(!i||i.pct===null||i.resetsAtMs!==null&&i.resetsAtMs<=r)return null;let a=PE[t],o=BE(a.lengthMs,i.resetsAtMs,r),s=o!==null&&o>=FE&&i.pct<LE?i.pct/(o/100):null;return{vendor:e,vendorLabel:aE.find(t=>t.vendor===e)?.label||e,key:t,windowLabel:a.label,usedPct:i.pct,elapsedPct:o,projectedPct:s,resetsAtMs:i.resetsAtMs,tone:zE(i.pct,s)}}function HE(e,t){return aE.flatMap(({vendor:n})=>iE.map(({key:r})=>VE(n,r,e[n],t)).filter(e=>e!==null))}function UE(e,t){let n=S(e,null);if(n===null||n<=0)return``;let r=new Date(n),i=_e(r);return Ne(n)===Ne(t)?i:n-t<7*NE&&r.getDay()!==new Date(t).getDay()?`${RE[r.getDay()]} ${i}`:`${Lw[r.getMonth()]} ${r.getDate()} ${i}`}function WE(e){return`${Math.round(e)}%`}function GE(e){return Math.max(e.usedPct,e.projectedPct??0)}function KE(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 qE(e,t){let n=KE(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 ${WE(100-r.usedPct)} of its ${r.windowLabel} window left.`}function JE(e,t){let n=UE(e,t);return!n||e===null?`until the window resets`:`until ${n}, in ${tT((e-t)/6e4)}`}function YE(e,t,n){let r=[`${e.vendorLabel} sessions stop answering ${JE(e.resetsAtMs,n)}. Their worktrees and conversations stay intact.`,qE(t,e.vendor)];return{tone:`fail`,headline:`${e.vendorLabel} ${e.windowLabel} limit reached.`,detail:r.filter(Boolean).join(` `)}}function XE(e,t){let n=UE(e.resetsAtMs,t),r=n?`, resets ${n}`:``;if(e.usedPct>=IE)return{tone:`warn`,headline:`${e.vendorLabel} ${e.windowLabel} limit is at ${WE(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 ${WE(e.projectedPct??e.usedPct)}.`}}function ZE(e){return{tone:`warn`,headline:`Over your ${ST(e.scope)===`today`?`daily`:`monthly`} budget.`,detail:`${CT(e)} spent ${ST(e.scope)}.`}}function QE(e,t,n,r){let i=e.find(e=>e.tone===`fail`);if(i)return YE(i,e,r);let a=e.filter(e=>e.tone===`warn`).sort((e,t)=>GE(t)-GE(e))[0];if(a)return XE(a,r);let o=t.find(e=>S(e.pct,0)>=100);if(o)return ZE(o);if(e.length===0)return{tone:`ok`,headline:n===null?`Nothing spent yet today.`:`${bw(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)=>GE(t)-GE(e))[0],c=UE(s.resetsAtMs,r);return{tone:`ok`,headline:`Every limit has room.`,detail:`Closest is ${s.vendorLabel} ${s.windowLabel} at ${WE(s.usedPct)}${c?`, resets ${c}`:``}.`}}function $E(e){return e.tone===`fail`?`limit reached`:e.projectedPct===null?e.elapsedPct===null?``:`too early to project`:`about ${WE(e.projectedPct)} at reset`}var eD=`report`;function tD(e){return hw.find(t=>t.value===e)?.label||``}function nD(e,t){return{key:Kw(e,t),dir:`desc`}}function rD(e,t){let n=OE(e?.models,nD(e?.totals,t))[0];if(!n)return null;let r=Kw(e?.totals,t);return{label:hE(n),sharePct:Jw(n[r],e?.totals?.[r])}}function iD(e,t){let n=TE(e?.sessions,nD(e?.totals,t)),r=n[0];return{count:n.length,topLabel:r?mE(r):``}}function aD(e){let t=cT(e).filter(e=>lT(e.lane));return t.length===0?null:t.reduce((e,t)=>e+S(t.costUSD,0),0)}function oD(e){let t=e.filter(e=>S(e.pct,0)>=100).length,n=e.length-t;return t===0?{value:`${n} of ${e.length}`,detail:e.length===1?`under its ceiling`:`all under their ceilings`}:{value:`${n} of ${e.length}`,detail:t===1?`1 over its ceiling`:`${t} over their ceilings`}}function sD(e){return Zw(e).length}function cD(e,t){let n=ET(e);return!n||t<=0?[]:Array.from({length:t},(e,r)=>{let i=new Date(n);return i.setDate(n.getDate()-(t-1-r)),Ne(i)})}function lD(e){return hw.find(t=>t.value===e)?.days??7}function uD(e){return e.reduce((e,t)=>t.resetsAtMs===null?e:e===null?t.resetsAtMs:Math.min(e,t.resetsAtMs),null)}function dD(e,t){let n=ET(e);return n?(n.setDate(n.getDate()+t),Ne(n)):``}function fD(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=String(e?.day??``);Rw.test(n)&&r.set(n,(r.get(n)??0)+S(e?.[t],0))}return r}function pD(e,t){let n=ET(e);return n?t<=7?RE[n.getDay()]:String(n.getDate()):e}function mD(e,t,n,r){let i=fD(e,r===`cost`?`costUSD`:`tokens`),a=cD(n,t).map(e=>({day:e,label:pD(e,t),value:i.get(e)??0,isToday:e===n})),o=a.reduce((e,t)=>e+t.value,0),s=cD(dD(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 hD(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 gD(e){return`${Gw(e.average,e.metric)} a day on average`}function _D(e){return eE(e)?$T(e).map(e=>`${e.label} ${bw(e.costUSD)}`).join(`, `):``}function vD(e){return eE(e)?$T(e).map(t=>({...t,sharePct:Jw(t.tokens,e?.tokens)})):[]}function yD(e){let t=e?.totals,n=[{label:`Processed tokens`,value:xw(S(t?.tokens,0))},{label:`Cached input`,value:xw(S(t?.cacheRead,0))},{label:`Uncached input`,value:xw(S(t?.input,0))},{label:`Output`,value:xw(S(t?.output,0))}],r=S(bT(e?.savings)?.savedUSD,0);return r>0&&n.push({label:`Cache savings`,value:bw(r)}),n}function bD(e){let t=(e?.yourDay?.insights??[]).map(e=>({text:e.text,tone:`ok`})),n=e?.anomaly;JT(n)&&t.push({text:qT(n),tone:`warn`});for(let n of[xT(e?.savings),vT(e)])n&&t.push({text:n,tone:`ok`});return t}function xD(e,t,n,r){let i=Kw(t,n),a=e.reduce((e,t)=>Math.max(e,S(t[i],0)),0);return e.map(e=>({row:e,label:r(e),tokens:S(e.tokens,0),costUSD:S(e.costUSD,0),sharePct:Jw(e[i],t?.[i]),barPct:Jw(e[i],a)??0}))}function SD(e,t){return xD(OE(e?.models,nD(e?.totals,t)),e?.totals,t,hE)}function CD(e,t){return xD(TE(e?.sessions,nD(e?.totals,t)),e?.totals,t,mE)}function wD(e){return[{label:`Input`,tokens:S(e.input,0)},{label:`Output`,tokens:S(e.output,0)},{label:`Cache write`,tokens:S(e.cacheCreate,0)},{label:`Cache read`,tokens:S(e.cacheRead,0)}]}var TD=2e4,ED=`glimmervoid-usage-metric`,DD=null,OD=null,kD={claude:null,codex:null,kimi:null},AD=null,jD=null,MD=null,ND=gw,PD=Ww(zr(ED,null)),FD=!1,ID=null,LD=null,RD=!0,zD=()=>!1,BD=new Set,VD=_t({getAck:Pi,setAck:gi,signature:()=>Ow(DD,kD.claude),isLooking:()=>zD()});function HD(e){for(let t of BD)t(e)}function UD(){AD?.(VD.refresh())}function WD(e){FD=e,HD(`refresh-status`),ID&&=(clearTimeout(ID),null),e&&(ID=setTimeout(()=>{ID=null,FD=!1,LD=`Usage did not answer within ${Math.round(TD/1e3)} s. Refresh to try again.`,HD(`refresh-status`)},TD))}function GD(e){let t=hw.find(t=>t.value===e);return t?t.days:null}function KD(){return{report:DD,sessions:OD,planLimitsByVendor:kD,rangeValue:ND,metric:PD}}function qD(){let e=!RD||!FD&&LD!==null;return RD?FD?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:LD??``,isPending:!1,hasFailure:e}:{text:DD?`${x} The figures below are from before the connection dropped.`:x,isPending:FD,hasFailure:e}}function JD(e){BD.add(e)}function YD(e){zD=e,UD()}function XD(){VD.acknowledge(),UD()}function ZD(e){AD=e,UD()}function QD(e){jD?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function $D(e){jD=e}function eO(e){ND=e}function tO(e){PD=e,Rr(ED,e)}function nO({force:e=!1}={}){if(!jD)return;MD=d(`usage`);let t={type:`request-usage-report`,requestId:MD};e&&(t.force=!0);let n=GD(ND);n!==null&&(t.days=n),LD=null,WD(!0),jD(t)||(LD=x,WD(!1))}function rO(e){RD=e,HD(`refresh-status`)}function iO(e){OD=e,HD(`sessions`)}function aO(e){let t=e;kD={...kD,[Dw(t)]:t},HD(`plan-limits`),UD()}function oO(e){Pw(e,MD)&&(LD=null,WD(!1),DD=e,HD(`report`),UD())}function sO(){let e=DD?.pricing||(OD?{source:OD.pricingSource}:null),t=Aw(e?.fetchedAt),n=[kw(e,t!==null&&t>0?dw(t):``)],r=Nw(DD);r&&n.push(r);let i=Mw(DD?.scan);return i&&n.push(i),n}var cO=[],lO=[],uO=[],dO=new Map;function fO(){for(let e of[...cO])e()}function pO(e){for(let t of lO)t(e)}function mO(e){return e.type===`whiteboard-result`}async function hO(e,t){try{let n=await c(e,t,{timeoutMs:Or});return mO(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:Dr(e,Or)}}}function gO(){return uO}function _O(e){return cO.push(e),()=>{let t=cO.indexOf(e);t>=0&&cO.splice(t,1)}}function vO(e){lO.push(e)}function yO(){let e=new Map;for(let t of uO)for(let n of t.connectedSessionIds){let r=e.get(n);r?r.push(t):e.set(n,[t])}dO=e}function bO(e){uO=[...e.boards].sort((e,t)=>t.updatedAt-e.updatedAt),yO(),fO()}function xO(e){uO=uO.filter(t=>t.id!==e.boardId),yO(),pO(e.boardId),fO()}async function SO(e){let t=await hO(`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 CO(e,t){let n=await hO(`whiteboard-op`,{boardId:e,ops:t});return n.ok?{ok:!0,patch:n.reply.patch??null}:n}async function wO(e){let t={"x-glimmervoid-upload-name":encodeURIComponent(e.name)};e.type&&(t[`content-type`]=e.type);let n=await fetch(Zt,{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=Xt.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 TO(e){let t=await hO(`whiteboard-delete`,{boardId:e});return t.ok?{ok:!0}:t}async function EO(e,t){let n=await hO(`whiteboard-connect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function DO(e,t){let n=await hO(`whiteboard-disconnect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function OO(e){let t=await hO(`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 kO=null;function AO(e){kO=e}function jO(e,t){kO?.(e,t)}function MO(e){return dO.get(e)??[]}var NO=null;function PO(e,t){NO={boardId:e,sessionId:t}}function FO(){let e=NO;return NO=null,e}var IO=()=>{};function LO(e){IO=e}function RO(e,t){PO(e,t),IO()}function zO(e,t){let n=e.queuedBySessionId[t]??0;return n===0?``:`${n} queued`}function BO(e,t,n){let r=zO(e,t),i=r?`wait`:`muted`;return{key:`board:${e.id}`,text:n,detailText:e.title,stateText:r,look:{icon:`board`,tone:i},tier:gn(i),className:`session-pr-chip session-board-chip`,ariaLabel:`Open board ${e.title}`,onActivate:()=>RO(e.id,t)}}function VO(e,t){let n=zO(e,t);return BO(e,t,n?`${e.title}, ${n}`:e.title)}function HO(e){return MO(e).map(t=>BO(t,e,t.title))}function UO(e,t,n){let r=VO(e,t),i=Ve(`session-pr-chip-unlink`);i.append(Ee(ut)),i.setAttribute(`aria-label`,`Disconnect board ${e.title}`),i.addEventListener(`click`,r=>{r.stopPropagation(),r.preventDefault(),$t({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:()=>{DO(e.id,t).then(e=>n(e.ok?null:e.error))}})});let a=T(`span`,`session-pr-chip-item`);return a.append(_n(r,r),i),a}function WO(e){let{dialog:t,close:n,actions:r,btnCancel:i}=tn({title:`Connect board`}),a=T(`div`,`session-pr-chips dialog-linked-prs`),o=T(`p`,`dialog-message`,`A connected session is told what others changed on the board with its next whiteboard get or prompt.`),s=T(`select`,`dialog-input`);s.setAttribute(`aria-label`,`Board to connect`);let c=Cr(`action-status`),l=C({variant:`primary`,label:`Connect`});r.append(l),t.append(a,o,s,c.element,r);function u(e){e&&c.show(`error`,e)}function d(){let t=MO(e);on(a,t.map(t=>VO(t,e)),n=>{let r=t.find(e=>`board:${e.id}`===n.key);return r?UO(r,e,u):_n(n,n)});let n=gO().filter(t=>!t.connectedSessionIds.includes(e));s.replaceChildren(...n.map(e=>{let t=T(`option`,null,e.title);return t.value=e.id,t})),n.length===0&&s.append(T(`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,EO(t,e).then(e=>{e.ok?n():(c.show(`error`,e.error),d())}))}),i.addEventListener(`click`,n);let f=_O(()=>{t.isConnected?d():f()});d()}_O(In);function GO(){return A.snapshot().borrowedCardId}var KO=null;function qO(e,t,n,{className:r,onRelease:i}={}){if(!e?.card||!n)return;let a=GO();a&&a!==t&&JO();let o=e.card;o._cardHostClass&&o._cardHostClass!==r&&o.classList.remove(o._cardHostClass),o._cardHostClass=r||``,r&&o.classList.add(r),Kt(o,n),KO=i??null,A.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function JO(){let e=GO(),t=KO;if(KO=null,t?.(),A.dispatch(`borrowCard`,null),!e)return null;let n=O.get(e);n?._showTerminalFace?.(),n?._setBorrowed?.(!1),n?._setActiveViewer?.(!1);let r=n?.card;return r&&(r._cardHostClass&&r.classList.remove(r._cardHostClass),delete r._cardHostClass,Nt(r,fr)),e}var YO=null,XO=null,ZO={},QO=null,$O=null,ek=null,tk=new Map,nk=new Map;function rk(){return XO??=j(()=>import(`./phone-shell-6J_LT8oK.js`).then(e=>{e.mountPhoneShell(ZO),ek&&e.orderPhonePanels(ek);for(let[t,n]of tk)e.setPhoneScreenAvailable(t,n);for(let[t,n]of nk)e.setPhoneScreenAttention(t,n);return YO=e,e},e=>(XO=null,y(`phone-shell`,`phone shell failed to load: ${l(e)}`),null)),__vite__mapDeps([26,3,4,13,21,27,14,15,24,28,12,5,6,7,20,29,30,31,23,32,33])),XO}function ik(e){ZO=e}async function ak(e){let t={options:e};QO=t;let n=await rk();if(QO!==t)return!1;if(!n)return QO=null,$O=null,!1;QO=null,n.activatePhoneShell(t.options);let r=$O;return $O=null,r?.(n),!0}function ok(){QO=null,$O=null,YO?.deactivatePhoneShell()}function sk(){return QO!==null||(YO?.isPhoneShellActive()??!1)}function ck(){return QO?QO.options?.sessionId??null:YO?.getPhoneSessionId()??null}function lk(e){ek=e,YO?.orderPhonePanels(e)}function uk(e,t){tk.set(e,t),YO?.setPhoneScreenAvailable(e,t)}function dk(e,t){nk.set(e,t),YO?.setPhoneScreenAttention(e,t)}function fk(){YO?.refreshPhoneBoard()}function pk(){YO?.syncPhoneHistory()}function mk(e){return QO?($O=t=>{e(t)},!0):YO?e(YO):!1}function hk(e){return mk(t=>t.showPhonePlan(e))}function gk(e){return mk(t=>t.showPhoneSession(e))}function _k(e){return mk(t=>t.showPhoneScreen(e))}function vk(){let e=ck();e&&k(e)?._isActiveViewer?.()===!0&&rw(e)}function yk(){qf(k(GO())),vk()}function bk(){window.addEventListener(`focus`,yk),window.addEventListener(`blur`,yk),document.addEventListener(`visibilitychange`,yk),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Zo()}),window.addEventListener(`pageshow`,e=>{e.persisted&&Zo()})}function xk(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function Sk(e,t,n){return t>0?{minPx:e.minPx,maxPx:Math.max(e.minPx,Math.min(e.maxPx,t-n))}:e}function Ck(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function wk({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:Sk(i,n.getBoundingClientRect().width,l),f=null,p=t=>{let i=d();e.setAttribute(`aria-valuemax`,String(i.maxPx));let a=xk(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=Ck(e.key,a);if(n===null)return;e.preventDefault();let r=p((f??t.getBoundingClientRect().width)+u*n);r!==null&&s(r)})}var Tk={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.`}},Ek=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:Ut[e],meaning:t}),Dk=Object.freeze([Ek(E.DORMANT,`Not started yet.`),Ek(E.STARTING,`Setting up the worktree and booting the agent.`),Ek(E.RUNNING,`The agent is mid-turn.`),Ek(E.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),Ek(E.WAITING,`Waiting on a permission prompt or your answer.`),Ek(E.COMPLETE,`Finished a turn you have not looked at yet.`),Ek(E.IDLE,`Ready for the next prompt.`),Ek(E.DONE,`The agent process ended.`),Ek(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 Ok(e,t){let n=T(`section`,`status-legend`),r=T(`dl`,`status-legend-rows`);return r.append(...t),n.append(T(`h2`,`status-legend-title`,e),r),n}function kk(e,t){let n=T(`div`,`status-legend-row`);return n.append(e,T(`dd`,`status-legend-meaning`,t)),n}function Ak(){return Ok(`Status colors`,Dk.map(e=>{let t=T(`dt`,`status-legend-badge`),n=T(`span`,`status-legend-glyph`),r=T(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=kk(t,e.meaning);return Nn(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function jk(){return Ok(`Pull request icons`,Object.keys(Tk).map(e=>{let t=Tk[e],n=T(`dt`,`status-legend-badge`);return n.append(fa(e),T(`span`,`status-legend-name`,t.label)),kk(n,t.meaning)}))}var Mk=null,Nk=null,Pk=!1,Fk=null;function Ik(){return Nk??=j(()=>import(`./first-run-checklist-B-J9-hZq.js`).then(e=>(Mk=e,e),e=>(Nk=null,y(`first-run`,`first-run checklist failed to load: ${l(e)}`),null)),__vite__mapDeps([34,12,13,4,3,14,5,6,7,35,27,15,21,24,28,20,36])),Nk}function Lk(e,t){Fk={host:e,isShown:t},Mk?Mk.showFirstRunChecklist(e,t):t&&Pk&&Ik().then(e=>{e&&Fk&&e.showFirstRunChecklist(Fk.host,Fk.isShown)})}function Rk(){Mk?.refreshFirstRunChecklist()}function zk(){Pk=!0,Fk&&Lk(Fk.host,Fk.isShown)}var Bk=`removed`,Vk=new Set([E.COMPLETE,E.DONE,E.FAILED,Bk]);function Hk(e){return Vk.has(e)}function Uk(e,t){let n=e.filter(e=>Hk(t(e))).length;return{settled:n,total:e.length,isAllSettled:e.length>0&&n===e.length}}function Wk(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 sv(){if(!Z_)return;let e=K_(Y_,J_?.anomalies),t=Z_.hidden;Z_.hidden=!e,e&&t&&J_&&(av(),X_&&ov())}function cv(e){Y_=e,sv()}function lv(e){if(Z_)return Z_;let t=iv();return e.appendChild(t),sv(),t}function uv(e){J_=e,sv(),Z_&&!Z_.hidden&&(av(),X_&&ov())}var dv=null,fv=null,pv=!1,mv=null,hv=new Set;function gv(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function _v(){for(let e of hv)e()}function vv(){return{report:dv,hasReportSendFailed:pv}}function yv(e){hv.add(e)}function bv(e){fv=e}function xv(){if(!fv)return;mv=d(`hooks-report`);let e=fv({type:`request-hooks-report`,requestId:mv});e!==!pv&&(pv=!e,_v())}function Sv(e){gv(e,mv)&&(dv=e,pv=!1,_v())}function Cv(){xv()}var wv=new Map,Tv=new Map,Ev=new Map,Dv=null,Ov=`op://vault/item/field`,kv=`or paste the value`;function Av(e,t){return Object.fromEntries([...e].map(([e,n])=>[e,t(n)]).filter(([,e])=>e))}function jv(e,t,n){s(t?{type:`secret-decision`,id:e,isAllowed:t,referenceByName:Av(n.referenceByName,e=>e.value.trim()),valueByName:Av(n.valueByName,e=>e.value),newItemsVault:n.vault.value.trim()}:{type:`secret-decision`,id:e,isAllowed:t})}function Mv(){return Dv??`vault name`}function Nv(e,t,n){let r=T(`input`,`dialog-input ${e}`);return r.type=`text`,r.placeholder=t,r.spellcheck=!1,r.autocomplete=`off`,r.setAttribute(`aria-label`,n),r}function Pv(e,t){let n=T(`div`,`secret-request`);n.setAttribute(`role`,`group`),n.setAttribute(`aria-label`,`Secret request`);let r={referenceByName:new Map,valueByName:new Map,vault:Nv(`secret-request-vault`,Mv(),`Vault for pasted values`)};Ev.set(e,r.vault);let i=T(`div`,`secret-request-rows`);for(let e of t){let t=Nv(`secret-request-reference`,Ov,`Vault reference for ${e}`),n=Nv(`secret-request-value`,kv,`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=T(`div`,`secret-request-row`);a.append(T(`code`,`secret-request-name`,e),t,n),i.append(a)}let a=T(`label`,`secret-request-vault-row`);a.append(T(`span`,`secret-request-vault-label`,`Pasted values go into`),r.vault);let o=T(`div`,`secret-request-actions`);return o.append(C({variant:`secondary`,label:`Deny`,onClick:()=>jv(e,!1,r)}),C({variant:`primary`,label:`Allow`,onClick:()=>jv(e,!0,r)})),n.append(T(`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 Fv(e){Dv=e;for(let e of Ev.values())e.placeholder=Mv()}function Iv(e){let t=Tv.get(e),n=wv.get(e);return t!==void 0&&n!==void 0&&t.dataset.names===n.join(` `)}function Lv(e){let t=O.get(e);if(t&&Iv(e)&&Tv.get(e)?.parentElement===t.termWrap)return;Tv.get(e)?.remove(),Tv.delete(e),Ev.delete(e);let n=wv.get(e);if(!n||!t)return;let r=Pv(e,n);r.dataset.names=n.join(` `),Tv.set(e,r),t.termWrap.append(r)}function Rv(e,t){t.length===0?wv.delete(e):wv.set(e,[...t])}function zv(e){Fv(e.newItemsVault),Rv(e.id,e.names),Lv(e.id)}function Bv(e){Fv(e.newItemsVault);let t=[...wv.keys()];wv.clear();for(let[t,n]of Object.entries(e.requests))Rv(t,n);for(let e of new Set([...t,...wv.keys()]))Lv(e)}var Vv=new Map;function Hv(e){return Vv.get(e)??[]}function Uv(e){return Hv(e).length>0}function Wv(e){let t=k(e)?.btnDocs;t&&(t.hidden=!Uv(e))}var Gv=null,Kv=null;function qv(){return Kv??=j(()=>import(`./doc-editor-ui-DsshrSMT.js`).then(e=>(Gv=e,e),e=>(Kv=null,y(`doc-editor`,`doc editor failed to load: ${l(e)}`),null)),__vite__mapDeps([11,12,13,4,3,14,15,16,17,18])),Kv}function Jv(e){qv().then(t=>t?.openDocEditor(e))}function Yv(e){qv().then(t=>t?.openDocEditorOn(e))}function Xv(e){Gv?.applyDocsToOpenEditor(e)}function Zv(e){Vv.set(e.id,e.docs),e.docs.length===0&&Vv.delete(e.id),Wv(e.id),Xv(e.id)}function Qv(e){let t=[...Vv.keys()];Vv.clear();for(let[t,n]of Object.entries(e.sessions))Vv.set(t,n);for(let e of new Set([...t,...Vv.keys()]))Wv(e),Xv(e)}var $v=10,ey={low:0,medium:1,high:2};function ty(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 ny(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 ry(e,t,n){let r=e.get(t)??[];r.push(n),e.set(t,r)}function iy(e,t){for(let n of e.hotspots)ry(t,`${e.sessionPathPrefix}${n.path}`,{text:`often fixed`});for(let n of e.blastRadius)n.transitiveDependentCount<$v||ry(t,`${e.sessionPathPrefix}${n.path}`,{text:`${n.transitiveDependentCount} depend on it`})}function ay(e,t){return e.openPath.localeCompare(t.openPath)||e.dedupeKey.localeCompare(t.dedupeKey)}function oy(e){return e.conflictRisk===null?-1:ey[e.conflictRisk]}function sy(e,t){return t.severity-e.severity||oy(t)-oy(e)||e.heading.localeCompare(t.heading)||e.groupKey.localeCompare(t.groupKey)}function cy(e,t){return e===null||t===null?e??t:ey[t]>ey[e]?t:e}function ly(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?(e.lines.push(n),e.conflictRisk=cy(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(ay);return n.sort(sy)}function uy(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:ty(r)});let r=new Map,i=new Map,a=e.error?[e.error]:[];for(let t of e.repos){for(let e of ny(t,n))r.has(e.dedupeKey)||r.set(e.dedupeKey,e);iy(t,i),t.error&&a.push(e.repos.length>1?`${t.name}: ${t.error}`:t.error)}return{worthALook:ly(r.values()),hintsByOpenPath:i,repos:e.repos.map(e=>({name:e.name,sessionPathPrefix:e.sessionPathPrefix})),errors:a}}function dy(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 fy(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 py(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=fy(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 my(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function hy(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 gy({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=vy(a);return{text:s(`ready to merge into ${e}`,`Ready to merge into ${e}`),namesMergeTarget:!0}}return i?t?{text:s(`not ready to merge`,`Not ready to merge`),namesMergeTarget:!1}:{text:s(`not committed yet`,`Not committed yet`),namesMergeTarget:!1}:{text:s(`session ended`,`Session ended`),namesMergeTarget:!1}}function _y({status:e,mergeReason:t,fetched:n,hasDiffError:r,hasChanges:i,hasCommits:a,canMerge:o,isWorkspace:s,live:c,effectiveBase:l,changedFileCount:u=0}){return e===`parked`&&t===`base-diverged`?{text:`Parked: base branch diverged`,namesMergeTarget:!1}:e===`parked`?{text:`Parked: merge conflict`,namesMergeTarget:!1}:e===`merging`?{text:`Merging`,namesMergeTarget:!1}:e===`merged`?{text:`Merged`,namesMergeTarget:!1}:r?{text:`Could not read changes`,namesMergeTarget:!1}:n?i?gy({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 vy(e){return e||`base`}function yy(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function by(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function xy({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 Sy({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function Cy(e){if(!e)return[];let t=new Map;for(let n of[...py(e.committed?.diff),...py(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 wy(e,t){return t===null?null:e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)??null}function Ty(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 Ey(e){return e!==E.DORMANT&&e!==E.DONE&&e!==E.FAILED}function Dy(e,t){return(Lt.includes(e)||e===E.RUNNING)&&t}function Oy(e){let{status:t,reason:n,isFetched:r,hasCommits:i,isWorkspace:a,state:o,effectiveBase:s}=e,c=hy(e.files),l=Ey(o),u=by(t,n,Dy(o,i)),d=Sy({fetched:r,changedFileCount:c.files,hasCommits:i}),f=_y({status:t,mergeReason:n,fetched:r,hasDiffError:e.hasDiffError,hasChanges:c.files>0||i,hasCommits:i,canMerge:!a&&u.isEnabled,isWorkspace:a,live:l,effectiveBase:s,changedFileCount:c.files}),p=!a&&u.isRendered&&(d||t===`parked`||t===`merging`),m=xy({status:t,hasCommits:i,live:l,state:o});return{sentence:t===`parked`?`${f.text}. ${yy(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 ky=5e3,Ay=new Map,jy=new Map,My=new Map,Ny=new Map,Py=new Map,Fy=new Map,Iy=new WeakMap,Ly=new WeakMap,Ry=new Set,zy=new Set,By=null,Vy=null,Hy=null,Uy=null,Wy=null;function Gy(e){return Ry.add(e),()=>Ry.delete(e)}function Ky(e){for(let t of Ry)t(e)}function qy(e){if(!e)return[];let t=Iy.get(e);if(t)return t;let n=Cy(e);return Iy.set(e,n),n}function Jy(e){if(!e)return null;let t=Ly.get(e);if(t)return t;let n=uy(e);return Ly.set(e,n),n}function Yy(e){return O.get(e)?.card.dataset.workspace!==void 0}function Xy(e){let t=O.get(e);if(!t)return null;let n=My.get(e)??null,r=qy(n),i=Ny.get(e)??null;return{...Oy({status:Ay.get(e)||`none`,reason:jy.get(e)??null,isFetched:My.has(e),hasCommits:n?.hasCommits===!0,hasDiffError:i!==null,isWorkspace:Yy(e),state:t.currentState,effectiveBase:t.effectiveBase,isMergeInFlight:Fy.has(e),files:r}),sessionId:e,sessionName:t.card.dataset.session||e,files:r,diffError:i,changeMapView:Jy(Py.get(e)),notice:By?.sessionId===e?By.text:null,isWorkspace:Yy(e)}}function Zy(e,t){By={sessionId:e,text:t},Vy&&clearTimeout(Vy),Vy=setTimeout(()=>{By=null,Ky(e)},ky),Ky(e)}function Qy(e){Py.has(e)||Py.set(e,null),s({type:`request-change-map`,id:e})}function $y(e){s({type:`request-session-diff`,id:e}),Qy(e)}function eb(e,t){let n=Ay.get(e);Ay.set(e,t),my(n,t)&&(My.delete(e),Ny.delete(e),Py.delete(e),e===ta()&&$y(e)),Ky(e)}function tb(e,t,n=null){let r=t||`none`;jy.set(e,n);let i=Fy.get(e);i!==void 0&&i!==r&&Fy.delete(e),eb(e,r)}function nb(e,t,n=null){jy.set(e,n),Fy.delete(e),eb(e,t||`none`)}function rb(e,t){let n=D(e);n&&(My.set(n,t),Ny.delete(n),Ky(n))}function ib(e,t){let n=D(e);n&&(Ny.set(n,t),Ky(n))}function ab(e,t){let n=D(e);if(!n)return;let r=tt.safeParse(t);r.success&&r.data.sessionId===n&&(Py.set(n,r.data),Ky(n))}function ob(e){let t=D(e);t&&t===ta()&&$y(t)}function sb(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function cb(e){let t=D(e);if(!t||t!==ta())return;let n=!My.has(t)||Ny.has(t),r=!Py.has(t)||sb(Py.get(t));n&&$y(t),r&&!n&&Qy(t),Ky(t)}function lb(e){let t=D(e);t&&Fy.delete(t)&&Ky(t)}function ub(e){let t=D(e);Ay.delete(t),jy.delete(t),My.delete(t),Ny.delete(t),Py.delete(t),Fy.delete(t),t===ta()?Ki(null):Ky(t)}function db(e,t){Fy.has(e)||(s(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(Fy.set(e,Ay.get(e)||`none`),Ky(e)):Zy(e,`Not connected. The merge was not sent.`))}function fb(e){let t=Xy(e);return t?Fy.has(e)?(Zy(e,`Merge is already on its way for "${t.sessionName}".`),!1):t.isMergeEnabled?O.get(e)?.currentState===E.RUNNING?($t({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:()=>db(e,!0)}),!0):(db(e,!1),!0):(Zy(e,t.mergeRefusal??`Nothing to merge in "${t.sessionName}" right now.`),!1):!1}function pb(e){let t=Xy(e);t?.isDiscardShown&&$t({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 mb(){return[...zy].some(e=>!e.hasAttribute(`data-slot-held`))}function hb(){let e=mb()&&document.visibilityState===`visible`?ta():null;e!==Hy&&(Uy&&clearInterval(Uy),Uy=null,Hy=e,s({type:`watch-session-changes`,id:e}),e&&(Uy=setInterval(()=>s({type:`watch-session-changes`,id:e}),Xe)))}function gb(e){Wy??=_b(),Wy.observe(e)}function _b(){return document.addEventListener(`visibilitychange`,hb),Gi(e=>{e&&$y(e),hb()}),new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&zy.add(t.target),t.isIntersecting||zy.delete(t.target);hb()})}var vb=!1,yb=new Set;function bb(e){vb=!!e,jb();for(let e of yb)e(vb)}function xb(e){return yb.add(e),()=>yb.delete(e)}function Sb(){return vb}function Cb(){let e=T(`div`,`debug-close`);return e.append(C({variant:`icon`,size:`small`,label:`Close debug overlay`,icon:Ee(ut)})),e}function wb(e){return e?pt(new Date(e)):`-`}function Tb(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function Eb(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Tb(e.quietMs)})`:``}function Db(e){let t=`<span class="debug-dim">${wb(e.ts)}</span>`;if(e.kind===`signal`){let n=P([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${P(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=Eb(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${P(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=P(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${P(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${P(e.category||`?`)}: <span class="debug-dim">${P(e.from||`?`)} → ${P(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${P(e.kind||`decision`)}</span>`}function Ob(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">${P(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">${P(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${wb(e.timestamp)}</span> ${P(e.from)} → ${P(e.to)} <span class="debug-label">${P(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?`${P(a.signal)} (${P(a.source||`?`)}${a.confidence?`/${P(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">${P(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 ${Tb(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">${P(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">${Db(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(Cb())}function kb(e,t){if(e.debugOpen){Ab(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(Cb()),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`)&&Ab(e)}),s({type:`debug-state`,id:t})}function Ab(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function jb(){for(let[,e]of O)e.btnDebug.classList.toggle(`visible`,vb),e.btnTrace.classList.toggle(`visible`,vb),vb||e.debugOpen&&Ab(e)}function Mb(e){let t=typeof e.id==`string`?O.get(e.id):void 0;t?.debugOpen&&Ob(t,e.payload)}function Nb(e){k(e)?.debugOpen&&s({type:`debug-state`,id:e})}function Pb(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:typeof t==`string`&&vt.has(t)}}function Fb(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 Ib(e,t){return{body:t.join(`
74
+ `),tag:`glimmervoid-alert-${e.id}`,renotify:e.isStart}}var Lb=4e3;function Rb(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function zb(e,t,n,r=Lb){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 Bb=`#plan/`;function Vb(e){return`${Bb}${encodeURIComponent(e)}`}function Hb(e){if(!e.startsWith(Bb))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var Ub=null;function Wb(){return Ub??=j(()=>import(`./alert-sound-At4lBeip.js`),__vite__mapDeps([10,6])).catch(e=>(Ub=null,y(`alert-sound`,`alert sound failed to load: ${l(e)}`),null)),Ub}function Gb(){let e=ui();Wb().then(t=>t?.playAlertSound(e))}function Kb(){return typeof Notification>`u`?null:Notification}function qb(){return Kb()!==null}function Jb(){let e=Kb();return e?e.permission:`unavailable`}async function Yb(){let e=Kb();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function Xb(){return!qb()&&!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.`:qb()?Jb()===`denied`&&Wr()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function Zb(){if(!qb()||!Wr())return`off`;let e=Jb();return e===`granted`?`on`:e==="default"?`ask`:`off`}function Qb(){return Wr()&&Jb()==="default"}function $b(e=()=>{}){let t=T(`div`,`notification-permission`),n=()=>{let r=Xb();if(t.replaceChildren(),t.hidden=!r&&!Qb(),r){t.append(T(`p`,`notification-permission-hint text-meta text-text-muted`,r));return}let i=C({variant:`secondary`,label:`Enable desktop notifications`});i.addEventListener(`click`,()=>{i.disabled=!0,Yb().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var ex=`Notifications`,tx=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,nx=new Map,rx=!1;function ix(){rx||(rx=!0,Tr({source:ex,message:tx,hidesInStreamerMode:!1}))}function ax(e,t){let n=nx.get(e)??new Set;n.add(t),nx.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function ox(e){let t=nx.get(e);if(t){nx.delete(e);for(let e of t)e.close()}}function sx(e){return!qb()||!Wr()||document.documentElement.hasAttribute(`data-streamer`)?!1:e||!document.hasFocus()}function cx(){return sx(!1)&&Jb()===`granted`}var lx=null;function ux(e,t){let n=Kb();if(!n||(lx=Fb(lx,t,e.message),wr(ex),!zb(window.localStorage,Rb(`group-${t.id}`,`${e.session}-${e.category}`),Date.now())))return;let r=t.sessionIds.length===1?O.get(e.session):void 0,i=t.sessionIds.length>1?`${t.sessionIds.length} sessions`:r?ar(r):`Glimmervoid`;try{let r=new n(i,Ib(t,lx.lines));r.onclick=()=>{window.focus(),e.kind===`plan`&&(window.location.hash=Vb(e.session)),r.close()};for(let e of t.sessionIds)O.has(e)&&ax(e,r)}catch{}}var dx=null;function fx(e){return!e||e.id!==dx&&(dx=e.id,!0)}function px(e){O.get(e.session)?._isActiveViewer?.()===!0?s({type:`alert-seen`,id:e.session}):fx(e.group)&&xi()&&Gb()}function mx(e,t){t?ux(e,t):vx(e)}function hx(){let e=Reflect.get(navigator,`userAgentData`);return typeof e!=`object`||!e?!1:Reflect.get(e,`platform`)===`macOS`}function gx(e){!document.hasFocus()&&cx()&&vx(e)}function _x(e){if(vt.has(e.category??``)){gx(e);return}if(document.hasFocus()){px(e);return}let t=e.group;cx()&&(mx(e,t),!hx())||(sx(!1)&&Jb()===`denied`&&ix(),t?.isStart!==!1&&fx(t)&&xi()&&Gb())}function vx({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=Kb();if(!a||!sx(!!i)||(a.permission===`denied`&&ix(),a.permission!==`granted`)||(wr(ex),!zb(window.localStorage,Rb(e,t),Date.now())))return;let o=typeof e==`string`?e:``,s=O.get(o),c=s?ar(s):``;try{let i=new a(c||`Glimmervoid`,Pb(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=Vb(o)),i.close()},s&&ax(o,i)}catch{}}var yx=null;function bx(){return yx??=j(()=>import(`./resume-dialog-Ct0dtFpq.js`),__vite__mapDeps([19,13,4,3,12,14,20,21,15])).catch(e=>(yx=null,y(`resume-dialog`,`restart dialog failed to load: ${l(e)}`),null)),yx}var xx=null,Sx=null;function Cx(){return Sx??=j(()=>import(`./plan-face-p_Q4xZ-H.js`).then(e=>(xx=e,e),()=>(Sx=null,null)),__vite__mapDeps([22,13,4,3,23,15,24,16,25])),Sx}function wx(e){let t=T(`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,Cx().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 Tx=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function Ex(e){return e===`approve`||e===`approve-accept-edits`}function Dx(e){return(e.state===`decided`||e.state===`closed`)&&Ex(e.lastDecision)}function Ox(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&Dx(n)}function kx(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function Ax(e){let t=kx(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 jx(e,t){return kx(e,t)?.openRevision?.revision??null}function Mx(e,t,n){if(n===null)return null;let r=kx(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function Nx(e,t){let n=t-e;return Number.isFinite(n)?pe(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function Px(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 Fx(e,t,n){let r=Px(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return Tx.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function Ix(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 Lx(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function Rx(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+st}function zx(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 ${et} characters, so nothing was sent`:Lx(e)>1e4?`the feedback composes more than the ${Je} characters the hook reply carries, so nothing was sent`:Rx(e)>We?`the decision is larger than one control frame carries, so nothing was sent`:null}function Bx(e){return e?`, ${e}`:``}function Vx(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=Ix(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 Hx(e,t,n){let r=Vx(e,t,n);return r?`${r}${Bx(e.problem)}`:e.problem??``}function Ux(e){let t=kx(e.state,e.selectedAgentId),n=Ax(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:Hx(e,t,n),actions:Fx(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:Px(e,t,n)}]}}function Wx(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 Gx({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 Kx({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var qx=e=>Gt.includes(e),Jx=e=>Vt.includes(e);function Yx(e){let t=e.currentState;e.btnRestart.classList.toggle(`visible`,qx(t)||Jx(t)||t===E.DORMANT),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,Sb()),e.btnPlan.hidden=Kx(e)===`hidden`}function Xx(e){let t=k(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(D(e)),Yx(t),au(t,D(e)),!0)}function Zx(e,t){let n=k(e);n&&(n.hasPlan=t===!0,Yx(n))}function Qx(e){let t=k(e.id);t&&(t.planReviewState=Wx(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),Yx(t))}function $x(e){let t=k(e.id);t&&t.planFace.update({draft:e})}function eS(e){let t=k(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),Yx(t))}function tS(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=k(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function nS(e){for(let[,t]of O)t.planFace.update({isConnected:e})}var rS=160,iS=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 aS(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=rS?t:`${t.slice(0,157)}...`}function oS(e,t){let n=iS[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?aS(r):``}var sS=5e3;function cS(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function lS(e,t){if(!e.toolUseId)return cS(e.text)??`context`;let n=t.get(e.toolUseId);return n?oS(n.name,n.input)||n.name:`expansion`}function uS(e){return e.kind!==`expansion`||e.toolUseId?!1:cS(e.text)!==null}function dS(e){return e.kind===`prompt`||e.kind===`session`||uS(e)}function fS(e){return new TextEncoder().encode(e).byteLength}var pS={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`};function mS(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:aS(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:aS(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:aS(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:aS(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:aS(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:lS(e,t)};if(e.kind===`tool_call`){let t=oS(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:`${fS(e.content)} bytes`}}function hS(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function gS(e,t){let n=mS(e,t),r=hS(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:pS[e.kind],text:`${r}${i}`,tone:o,badges:a}}function _S(e,t){return{record:e,...gS(e,t)}}function vS(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function yS(e,t){let n=vS(e);return!n||t.has(n)?null:n}function bS(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function xS(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function SS(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=vS(i.record);a&&t.has(a)&&(n.rows[r]=_S(i.record,e.toolCallByUseId))}}function CS(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function wS(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function TS(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=fS(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function ES(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=yS(i,e.toolCallByUseId);t&&bS(e.unresolvedToolUseCounts,t);let a=_S(i,e.toolCallByUseId);if(dS(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:wS()},TS(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:wS()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),TS(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 DS(e,t){let n=CS();ES(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)||bS(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],SS(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function OS(e){return e.rows.length+ +!!e.head}function kS(e){let t=0;for(let n of e.turns)t+=OS(n);return t}function AS(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=vS(n.record);t&&xS(e.unresolvedToolUseCounts,t)}}function jS(e,t){AS(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);AS(e,i);for(let e of i)TS(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function NS(e,t=sS){let n=kS(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=OS(t),jS(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 PS(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 FS(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 IS(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 LS(e,t=sS){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function RS(e,t=sS){return!LS(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function zS(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 BS=1e4,VS=null,HS=null,US=[],WS=null,GS=null,F=null,KS=null,qS=!1,JS=null,YS=()=>!1,XS=new Set;function ZS(e){for(let t of XS)t(e)}function QS(){KS&&=(clearTimeout(KS.timeoutHandle),null)}function $S(){KS=null,JS=`The trace did not load within ${Math.round(BS/1e3)} s.`,ZS({kind:`rebuild`})}function eC(e){QS(),qS=!1,JS=null,WS=e,F=e?{sessionId:e,grouping:CS(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,ZS({kind:`selection-reset`})}function tC(e){let t=FS(US,GS,WS,e);return GS&&t===GS&&(GS=null),t!==WS&&(eC(t),!0)}function nC(e){if(!VS)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};VS(t)?KS={request:e,timeoutHandle:setTimeout($S,BS)}:(JS=x,ZS({kind:`header`}))}function rC(e=!1){if(!VS)return;let t=IS({selectedSessionId:WS,isPanelVisible:e||YS(),hasPendingRequest:!!KS,hasLoadedOnce:F?.hasLoadedOnce??!1,nextOffset:F?.nextOffset??0});t&&nC(t)}function iC(){qS&&!KS&&(qS=!1,rC())}function aC(){if(!F)return;let e=NS(F.grouping),t=e.droppedTurnCount>0||e.droppedRowCount>0,n=t&&!F.hasDroppedEarliestRows;t&&(F.hasDroppedEarliestRows=!0),ZS({kind:`trimmed`,trim:{droppedTurnCount:e.droppedTurnCount,droppedRowCount:e.droppedRowCount,hasJustDroppedEarliestRows:n}})}function oC(e){F&&(ZS({kind:`records-appended`,appends:ES(F.grouping,e)}),aC())}function sC(e){F&&(ZS({kind:`records-prepended`,prepend:DS(F.grouping,e)}),aC())}function cC(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 lC(){return{selectedSessionId:WS,hasPendingRequest:!!KS,hasLoadedOnce:F?.hasLoadedOnce??!1,hasDroppedEarliestRows:F?.hasDroppedEarliestRows??!1,firstOffset:F?.firstOffset??0,residentRowCount:F?kS(F.grouping):0}}function uC(){return{sessionOptions:US,selectedSessionId:WS,selectedTrace:F,pendingSessionId:KS?.request.id??null,traceFailureText:JS}}function dC(e){XS.add(e)}function fC(e){YS=e}function pC(){if(!VS)return;let e=RS(lC());e&&nC(e)}function mC(e){US.some(t=>t.id===e)&&e!==WS&&(GS=null,eC(e),rC(),ZS({kind:`rebuild`}))}function hC(){let e=tC(!0);return rC(!0),e}function gC(e){VS=e}function _C(e){HS=e}function vC(e){GS=e,HS?.()}function yC(e){US=PS(e);let t=tC(YS());t&&rC(),ZS({kind:`sessions`,hasSelectionChanged:t})}function bC(e){let t=cC(e);if(!t)return;let n=zS({pendingRequest:KS?.request??null,resident:F?{sessionId:F.sessionId,firstOffset:F.firstOffset,nextOffset:F.nextOffset,hasLoadedOnce:F.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?iC():(QS(),JS&&(JS=null,ZS({kind:`header`})),n===`stale`?iC():n===`reset`?(eC(t.id),F&&(F.filePath=t.path),rC(),ZS({kind:`rebuild`}),iC()):F&&(F.filePath=t.path,n===`prepend`?(F.firstOffset=t.start,sC(t.records),iC()):(n===`seed`&&(F.hasLoadedOnce=!0,F.firstOffset=t.start),F.nextOffset=t.next,oC(t.records),iC())))}function xC(e){let t=e?.id;typeof t==`string`&&t===WS&&YS()&&(KS?qS=!0:rC())}function SC(e){let t=e?.id;if(typeof t!=`string`||KS?.request.id!==t)return!1;QS(),qS=!1;let n=e?.message;return JS=typeof n==`string`&&n?n:`The trace could not be read.`,ZS({kind:`rebuild`}),!0}function CC(e){QS(),qS=!1,JS=e?null:x,e?(ZS({kind:`header`}),rC()):ZS({kind:`rebuild`})}function wC(e,t,n=!1){let r=T(`label`,`dialog-checkbox-label`),i=T(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,T(`span`,null,e)),r}function TC(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function EC(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:TC(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 DC(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:a}=tn({title:`Workspace repositories`}),o=T(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),s=T(`fieldset`,`dialog-workspace-list`);s.setAttribute(`aria-label`,`Workspace repositories`),s.append(T(`div`,`dialog-hint`,`Loading repositories...`));let l=T(`div`,`dialog-hint`);l.setAttribute(`role`,`status`);let u=T(`div`,`dialog-error`),d=C({variant:`primary`,label:`Save`,disabled:!0});i.append(d),n.append(o,s,l,u,i),a.addEventListener(`click`,r),requestAnimationFrame(()=>a.focus()),EC(e).then(e=>{if(t.isConnected){s.textContent=``;for(let t of e)s.append(wC(t.name,t.path,t.isMember));d.disabled=!1}}).catch(e=>{t.isConnected&&(s.textContent=``,u.textContent=`Could not load repositories: ${Wn(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: ${Wn(e)}`)}).finally(()=>{l.textContent=``,d.disabled=!1}))})}function OC(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function kC(e,t){pn(e.taskTitleEl,()=>un(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),ln(e,t)}),e.nameEl.addEventListener(`click`,()=>{fn(e.nameEl)||Ki(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`,()=>{OC(e),ln(e,t,{returnsFocusToTerminal:!e.renameTargetEl?.isConnected})}),e.btnRestart.addEventListener(`click`,()=>{OC(e),bx().then(n=>n?.openRestartDialog(t,{readState:()=>e.currentState,canListEarlier:e.card.dataset.ephemeral===void 0}))}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{OC(e),DC(t)}),e.btnTrace.addEventListener(`click`,()=>{OC(e),vC(t)}),e.btnDocs.addEventListener(`click`,()=>{OC(e),Jv(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=Kx(e);n!==`hidden`&&(n===`face`?Xx(t):location.hash=Vb(t))}),e.btnRemove.addEventListener(`click`,()=>{OC(e),ea(t)});function n(){for(let[,t]of O)t!==e&&OC(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`)}e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation(),e.sessionMenu.classList.contains(`open`)?OC(e):n()}),da({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:()=>OC(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&&OC(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),OC(e),kb(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&Ab(e)},{signal:e.abortController.signal})}var AC=1500,jC=new WeakMap;function MC(e){clearTimeout(jC.get(e)),jC.delete(e)}function NC(e,t){let n=setTimeout(()=>{jC.delete(e),s({type:`dismiss`,id:t,expectedState:E.COMPLETE})},AC);jC.set(e,n)}function PC(e,t,n){let r=document.activeElement;return Wi({previousState:t,nextState:n,isPhoneLayout:us(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}var FC=e=>e==null?``:String(e);function IC(e,t,n){let r=k(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&hn(e,r.taskTitle)}}function LC(e){return typeof e==`string`&&O.has(e)}function RC(){return O.size}function zC(e){let t=e||{};t.linkPreviews!=null&&Yd(t.linkPreviews),t.cursorBlink!=null&&Rf(t.cursorBlink),t.debugMode!=null&&(bb(t.debugMode),cv(t.debugMode));for(let[,e]of O)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function BC(){Vu(O.values(),Uu())}function VC(e){return{state:e.currentState,unseenOutcome:e.unseenOutcome,ownerId:e.ownerId}}function HC(){let e=ur(hr.counts),t=e>0?`(${e}) Glimmervoid`:`Glimmervoid`;document.title!==t&&(document.title=t)}function UC(e,t,n,r={}){if(!fr)return;let i=D(e),a=FC(n)||E.DORMANT,o=Bn(i,FC(t),a,r),c=a===E.DORMANT;fr.appendChild(o.card);let l;function u(){l.face=`terminal`,l.card.dataset.face=`terminal`,l.termWrap.hidden=!1,l.planFace.hide(),Yx(l),Jf(l,i)}let d=new AbortController,f=wx({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=>Tn(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:FC(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=()=>Jf(l,i),l._showTerminalFace=u,l._showPreferredFace=u,l._setBorrowed=e=>{l.isBorrowed=e,o.card.toggleAttribute(`data-borrowed`,e),Yx(l)},o.card.append(f.el);let p=O.get(i);return p&&Kn(hr,VC(p)),O.set(i,l),dr(hr,VC(l)),Mr(i,l),kC(l,i),Yx(l),l.btnDocs.hidden=!Uv(i),Lv(i),a===E.RUNNING&&jr(l,!0),c||Gf(l,i),HC(),l}function WC(e,t){let n=k(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function GC(e,t){let n=k(e);if(!n)return;n.agent=typeof t==`string`?t:null;let r=n.card.querySelector(`.session-agent-mark`);r&&Gn(r,n.agent),Yx(n)}function KC(e,t){let n=k(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function qC(e,t,n=!1){let r=k(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=Jt(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function JC(e,t){let n=k(e);n&&(n.pendingPromptKind=typeof t==`string`?t:null)}function YC(e,t){let n=k(e);n&&(Kn(hr,VC(n)),n.unseenOutcome=t??null,dr(hr,VC(n)))}function XC(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function ZC(e,t,n=null){let r=k(e),i=FC(t)||`none`;r&&XC(r.card,i),tb(D(e),i,FC(n)||null)}function QC(e,t,n=null){let r=k(e),i=FC(t)||`none`;r&&XC(r.card,i),nb(D(e),i,FC(n)||null)}function $C(e,t){let n=k(e);if(!n)return;let r=FC(t);n.card.dataset.session=r,n.nameEl.textContent=r}function ew(e){let t=k(e);t&&(Ab(t),Kn(hr,VC(t)),O.delete(D(e)),Mr(D(e),void 0),xx?.dropPlanBodyCache(D(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),Pu(t,D(e)),Jo(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),HC())}function tw(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 nw(e,t){e.term&&(t===E.DONE||t===E.FAILED)&&(e.term.clear(),e.term.reset())}function rw(e){let t=O.get(e);t&&document.visibilityState===`visible`&&(us()||document.hasFocus())&&(jn(e),or({state:t.currentState,unseenOutcome:t.unseenOutcome})&&s({type:`dismiss`,id:e,expectedState:t.currentState}))}function iw(e,t,n){let r=k(e);if(!r)return;let i=FC(t),a=r.currentState;Kn(hr,VC(r)),r.currentState=i,dr(hr,VC(r)),Mr(D(e),r),i!==E.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(MC(r),r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),jr(r,i===E.RUNNING)),a===E.DORMANT&&i!==E.DORMANT&&Gf(r,D(e)),Yn({state:i})===`resting`&&ox(D(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,Jt(i,r.awaitingBackgroundTasks)),Yx(r),PC(r,a,i)&&NC(r,D(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)&&tw(r,s,i),i===E.INITIALIZING&&nw(r,a),HC()}var aw=ja({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function ow(e){let t=T(`ul`,`session-setup-list`);return t.append(...e.map(e=>T(`li`,null,e))),t}function sw(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=Ht(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[T(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=T(`div`,`session-setup-plugin`);return t.append(T(`h3`,null,e.name)),e.skills.length>0&&t.append(T(`p`,`session-setup-label`,`Skills`),ow(e.skills)),e.agents.length>0&&t.append(T(`p`,`session-setup-label`,`Agents`),ow(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[ow(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=T(`p`,`session-setup-hook`);return t.append(T(`span`,null,e.event),T(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>T(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[ow(t.skills)]:[]),n(`Agents`,t.agents.length>0?[ow(t.agents)]:[])}function cw(e){let t=T(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=T(`div`,`session-setup-sections`);aw.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function lw(e){let t=aw.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;sw(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function uw(e){return pe(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function dw(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${uw(Date.now()-e)} ago`}var fw=e=>`polled ${dw(e)}`;function pw(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=fw){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=Nr(a)}}}var mw=80,hw=Object.freeze([{value:`day`,label:`Today`,days:1},{value:`week`,label:`Last 7 days`,days:7},{value:`month`,label:`Last 30 days`,days:30}]),gw=`week`;function _w(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function vw(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function yw(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${_w(String(Math.abs(t)))}`}function bw(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}$${_w(r)}.${i}`}function xw(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}${vw((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${vw((n/1e6).toFixed(2))}M`:`${t}${vw((n/1e9).toFixed(2))}B`}function Sw(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=mw?`warn`:`ok`}var Cw=90;function ww(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&S(e.budgetUsd,null)!==null):[]}function Tw(e){let t=S(e?.pct,null);return t===null?0:t}function Ew(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=S(n.pct,null),i=S(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}function Dw(e){return e?.vendor===`codex`||e?.vendor===`kimi`?e.vendor:`claude`}function Ow(e,t=null){let n=[],r=Sw(Ew(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 ww(e)){let e=Tw(t);if(e<Cw)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return ft(n)}function kw(e,t=``){let n=e?.source;if(n===`fetched`){let e=Qe(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=Qe(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 Aw(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 jw(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=jw(e.dirs);if(n!==null&&t.push(`${yw(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${yw(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${yw(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${yw(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 Nw(e){return Qe(e?.error,``)}function Pw(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}var Fw=`Estimated list prices, not a bill.`,Iw=`Enable in Settings.`,Lw=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Rw=/^(\d{4})-(\d{2})-(\d{2})$/,zw=new Set([`day`,`model`,`label`]),Bw=new Set([`model`,`label`]);function Vw(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${vw(e.toFixed(1))}%`}var Hw=`tokens`,Uw=Object.freeze([{value:`tokens`,label:`Tokens`},{value:`cost`,label:`Cost`}]);function Ww(e){return e===`cost`?`cost`:Hw}function Gw(e,t){return t===`cost`?bw(e):xw(e)}function Kw(e,t){if(t===`tokens`)return`tokens`;let n=Number(e?.costUSD);return Number.isFinite(n)&&n>0?`costUSD`:`tokens`}function qw(e){return e===`costUSD`?`share of cost`:`share of tokens`}function Jw(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function Yw(e){let t=Rw.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=Lw[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function Xw(e){let t=Zw(e);return t.length===0?``:t.length===1?Yw(t[0]):`${Yw(t[0])} to ${Yw(t[t.length-1])}`}function Zw(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>Rw.test(e)).sort()}function Qw(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:$w(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function $w(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=eT(e,n);return Rw.test(r)?r:eT(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function eT(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function tT(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:he(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function nT(e,t){let n=dD(Ne(t),-1),[,r,i]=e.yesterday.day.split(`-`).map(Number),a=e.yesterday.day===n?`yesterday`:`${Lw[r-1]} ${i}`,o=e.yesterday.sessionCount===1?`session`:`sessions`;return`${a}: ${e.yesterday.sessionCount} ${o}, ${tT(e.yesterday.activeMs/6e4)}`}function rT(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=Lw[n.getMonth()];return r?`${r} ${n.getDate()} ${_e(n)}`:`-`}var iT=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`}),aT=`Sessions spawned by Glimmervoid; terminal sessions count as other`,oT=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function sT(e){let t=Qe(e,``);return t?iT[t]||t:iT.other}function cT(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function lT(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function uT(e){return cT(e).some(e=>lT(e.lane))}var dT=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function fT(e,t,n){let r=Ew(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function pT(e,t,n,r){if(!Array.isArray(t))return null;let i=t.filter(e=>e&&typeof e.lane==`string`),a=i.reduce((e,t)=>e+S(t.costUSD,0),0),o=i.reduce((e,t)=>e+S(t.tokens,0),0),s=i.filter(e=>lT(e.lane)).map(e=>({lane:String(e.lane),label:sT(e.lane),tokens:S(e.tokens,0),costUSD:S(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?Jw(c,a):Jw(l,o),d=fT(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:dT[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function mT(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:iE.map(e=>pT(e.key,r[e.key],t,n)).filter(e=>e!==null)}function hT(e){return e.planPct===null?``:`about ${Vw(e.planPct)} of plan`}function gT(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?bw(e.costUSD):xw(e.tokens)}`).join(`, `)}var _T=`team-review`;function vT(e){if(!Array.isArray(e?.byLane))return``;let t=cT(e).find(e=>e.lane===_T),n=S(t?.costUSD,0);if(n<=0)return``;let r=Jw(n,e?.totals?.costUSD),i=r===null?``:`, ${Vw(r)} of this period`;return`PR reviews cost ${bw(n)}${i}.`}function yT(e){let t=S(e,null);return t===null||t<=0?``:`${yw(t)} ${t===1?`session`:`sessions`}`}function bT(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function xT(e){let t=bT(e);if(!t)return``;let n=S(t.savedUSD,0);if(n<=0)return``;let r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e).length,i=r===0?``:`, at least, since ${r} ${r===1?`model has`:`models have`} no price`;return`Prompt caching saved ${bw(n)}${i}, across ${xw(S(t.cacheReadTokens,0))} cache read tokens.`}function ST(e){return e===`monthly`?`this month`:`today`}function CT(e){return`${bw(S(e?.spentUsd,0))} of ${bw(S(e?.budgetUsd,0))}`}function wT(e){return`${ST(e?.scope)} spend against budget`}var TT=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function ET(e){let t=Rw.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function DT(e){let t=ET(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Ne(t)}function OT(e){let t=Rw.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function kT(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 AT(e,t){e.tokens+=S(t?.tokens,0),e.costUSD+=S(t?.costUSD,0),e.input+=S(t?.input,0),e.output+=S(t?.output,0),e.cacheCreate+=S(t?.cacheCreate,0),e.cacheRead+=S(t?.cacheRead,0),e.days+=1,e.sources.add(t?.source===`history`?`history`:`live`);let n=Array.isArray(t?.vendors)?t.vendors:[];for(let t of n)e.vendorSet.add(t);let r=t?.models||[];for(let t of r){t?.vendor&&e.vendorSet.add(t.vendor);let n=hE(t),r=e.modelByName.get(n)||{key:n,model:t?.model??n,vendor:t?.vendor,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0};r.tokens+=S(t?.tokens,0),r.costUSD+=S(t?.costUSD,0),r.input+=S(t?.input,0),r.output+=S(t?.output,0),r.cacheCreate+=S(t?.cacheCreate,0),r.cacheRead+=S(t?.cacheRead,0),e.modelByName.set(n,r)}}function jT(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)||kT(r);AT(i,e),n.set(r,i)}return Array.from(n.values()).map(jT)}function NT(e){return MT(e,DT)}function PT(e){return MT(e,OT)}function FT(e,t){return t===`week`?NT(e):t===`month`?PT(e):Array.isArray(e)?[...e]:[]}var IT=/^(\d{4})-(\d{2})$/;function LT(e,t){if(t===`month`){let t=IT.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=Lw[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=Yw(e);return t===`-`?t:`week of ${t}`}return Yw(e)}function RT(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var zT=16,BT=Object.freeze([.05,.25,.5,.75]),VT=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function HT(e,t){let n=S(e,0),r=S(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<BT.length;e+=1)i>=BT[e]&&(a=e+1);return a}function UT(e,{weeks:t=zT,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>Rw.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`&&Rw.test(n)?n:Ne(o),c=ET(DT(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Ne(l),d=[],f=0,p=null;for(let e of r){let t=String(e.day);(p===null||t<p)&&(p=t),t<u||t>s||(f=Math.max(f,S(e.tokens,0)))}for(let e=0;e<t;e+=1)for(let t=0;t<7;t+=1){let n=new Date(l.getFullYear(),l.getMonth(),l.getDate()+e*7+t,12),r=Ne(n),a=i.get(r)||null,o=r>s,c=p!==null&&r<p;d.push({day:r,week:e,weekday:t,tokens:S(a?.tokens,0),costUSD:S(a?.costUSD,0),source:a?.source===`history`?`history`:a?`live`:null,noData:o||c||!a&&p===null,tone:HT(a?.tokens,f)})}return{cells:d,max:f,weeks:t}}function WT(e){let t=Yw(e?.day);if(e?.noData)return`${t}: no data`;let n=S(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${xw(n)} tokens, ${bw(S(e?.costUSD,0))}`}function GT(e){if(!e)return``;let t=S(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${YT(e.ratio)} the ${n} average: ${bw(e.todayUsd)} against ${bw(e.baselineUsd)}.`}function KT(e){return e?`This block is burning ${YT(e.ratio)} the usual rate: ${xw(e.current)} tokens per minute against ${xw(e.baseline)}.`:``}function qT(e){return[GT(e?.daily),KT(e?.burn)].filter(Boolean).join(` `)}function JT(e){return!!(e?.daily||e?.burn)}function YT(e){let t=S(e,null);return t===null?`-`:`${vw(t.toFixed(1))}x`}var XT=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`,kimi:`Kimi`});function ZT(e){let t=Qe(e,``);return t?XT[t]||t:XT.claude}function QT(e,t){return eE(t)?ZT(e?.vendor):``}function $T(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>S(t[n]?.tokens,0)-S(t[e]?.tokens,0)).map(e=>({vendor:e,label:ZT(e),tokens:S(t[e]?.tokens,0),costUSD:S(t[e]?.costUSD,0)}))}function eE(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 tE=`Claude only`;function nE(e){return eE(e)?tE:``}var rE=36e5,iE=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]),aE=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`},{vendor:`kimi`,label:`Kimi Code`}]);function oE(e,t=Date.now()){let n=S(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function sE(e,t=Date.now()){let n=S(e,null);return n===null||n<=0||t-n>rE}function cE(e,t=Date.now()){if(!sE(e,t))return``;let n=oE(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function lE(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 uE(e){let t=Qe(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function dE(e){return Nw(e)!==``}function fE(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 pE(e){return typeof e?.id==`string`&&e.id!==``}function mE(e){let t=Qe(e?.label,``);return pE(e)&&t?t:fE(e?.project)||t||`unknown project`}function hE(e){let t=typeof e==`string`?e:e?.model;return Qe(t,`unknown model`)}function gE(e){return String(e?.day??``)}function _E(e,t,n){if(!zw.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?gE(e):n(e)}function vE(e,t,n,r=mE){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=_E(e,t,r),o=_E(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 yE(e){return Bw.has(e)?`asc`:`desc`}function bE(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:yE(t)}}function xE(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var SE=Object.freeze({key:`lastTs`,dir:`desc`}),CE=Object.freeze({key:`tokens`,dir:`desc`}),wE=Object.freeze({key:`day`,dir:`desc`});function TE(e,t=SE){return vE(e,t.key,t.dir,mE)}function EE(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 DE(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${yw(t)} hidden`}function OE(e,t=CE){return vE(e,t.key,t.dir,hE)}function kE(e,t=wE){return vE(e,t.key,t.dir,gE)}function AE(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function jE(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,NE=24*ME,PE=Object.freeze({fiveHour:{lengthMs:5*ME,label:`5-hour`},sevenDay:{lengthMs:7*NE,label:`weekly`}}),FE=10,IE=80,LE=100,RE=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function zE(e,t){return e>=LE?`fail`:e>=IE||t!==null&&t>=IE?`warn`:`ok`}function BE(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 VE(e,t,n,r){let i=Ew(n,t);if(!i||i.pct===null||i.resetsAtMs!==null&&i.resetsAtMs<=r)return null;let a=PE[t],o=BE(a.lengthMs,i.resetsAtMs,r),s=o!==null&&o>=FE&&i.pct<LE?i.pct/(o/100):null;return{vendor:e,vendorLabel:aE.find(t=>t.vendor===e)?.label||e,key:t,windowLabel:a.label,usedPct:i.pct,elapsedPct:o,projectedPct:s,resetsAtMs:i.resetsAtMs,tone:zE(i.pct,s)}}function HE(e,t){return aE.flatMap(({vendor:n})=>iE.map(({key:r})=>VE(n,r,e[n],t)).filter(e=>e!==null))}function UE(e,t){let n=S(e,null);if(n===null||n<=0)return``;let r=new Date(n),i=_e(r);return Ne(n)===Ne(t)?i:n-t<7*NE&&r.getDay()!==new Date(t).getDay()?`${RE[r.getDay()]} ${i}`:`${Lw[r.getMonth()]} ${r.getDate()} ${i}`}function WE(e){return`${Math.round(e)}%`}function GE(e){return Math.max(e.usedPct,e.projectedPct??0)}function KE(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 qE(e,t){let n=KE(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 ${WE(100-r.usedPct)} of its ${r.windowLabel} window left.`}function JE(e,t){let n=UE(e,t);return!n||e===null?`until the window resets`:`until ${n}, in ${tT((e-t)/6e4)}`}function YE(e,t,n){let r=[`${e.vendorLabel} sessions stop answering ${JE(e.resetsAtMs,n)}. Their worktrees and conversations stay intact.`,qE(t,e.vendor)];return{tone:`fail`,headline:`${e.vendorLabel} ${e.windowLabel} limit reached.`,detail:r.filter(Boolean).join(` `)}}function XE(e,t){let n=UE(e.resetsAtMs,t),r=n?`, resets ${n}`:``;if(e.usedPct>=IE)return{tone:`warn`,headline:`${e.vendorLabel} ${e.windowLabel} limit is at ${WE(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 ${WE(e.projectedPct??e.usedPct)}.`}}function ZE(e){return{tone:`warn`,headline:`Over your ${ST(e.scope)===`today`?`daily`:`monthly`} budget.`,detail:`${CT(e)} spent ${ST(e.scope)}.`}}function QE(e,t,n,r){let i=e.find(e=>e.tone===`fail`);if(i)return YE(i,e,r);let a=e.filter(e=>e.tone===`warn`).sort((e,t)=>GE(t)-GE(e))[0];if(a)return XE(a,r);let o=t.find(e=>S(e.pct,0)>=100);if(o)return ZE(o);if(e.length===0)return{tone:`ok`,headline:n===null?`Nothing spent yet today.`:`${bw(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)=>GE(t)-GE(e))[0],c=UE(s.resetsAtMs,r);return{tone:`ok`,headline:`Every limit has room.`,detail:`Closest is ${s.vendorLabel} ${s.windowLabel} at ${WE(s.usedPct)}${c?`, resets ${c}`:``}.`}}function $E(e){return e.tone===`fail`?`limit reached`:e.projectedPct===null?e.elapsedPct===null?``:`too early to project`:`about ${WE(e.projectedPct)} at reset`}var eD=`report`;function tD(e){return hw.find(t=>t.value===e)?.label||``}function nD(e,t){return{key:Kw(e,t),dir:`desc`}}function rD(e,t){let n=OE(e?.models,nD(e?.totals,t))[0];if(!n)return null;let r=Kw(e?.totals,t);return{label:hE(n),sharePct:Jw(n[r],e?.totals?.[r])}}function iD(e,t){let n=TE(e?.sessions,nD(e?.totals,t)),r=n[0];return{count:n.length,topLabel:r?mE(r):``}}function aD(e){let t=cT(e).filter(e=>lT(e.lane));return t.length===0?null:t.reduce((e,t)=>e+S(t.costUSD,0),0)}function oD(e){let t=e.filter(e=>S(e.pct,0)>=100).length,n=e.length-t;return t===0?{value:`${n} of ${e.length}`,detail:e.length===1?`under its ceiling`:`all under their ceilings`}:{value:`${n} of ${e.length}`,detail:t===1?`1 over its ceiling`:`${t} over their ceilings`}}function sD(e){return Zw(e).length}function cD(e,t){let n=ET(e);return!n||t<=0?[]:Array.from({length:t},(e,r)=>{let i=new Date(n);return i.setDate(n.getDate()-(t-1-r)),Ne(i)})}function lD(e){return hw.find(t=>t.value===e)?.days??7}function uD(e){return e.reduce((e,t)=>t.resetsAtMs===null?e:e===null?t.resetsAtMs:Math.min(e,t.resetsAtMs),null)}function dD(e,t){let n=ET(e);return n?(n.setDate(n.getDate()+t),Ne(n)):``}function fD(e,t){let n=Array.isArray(e)?e:[],r=new Map;for(let e of n){let n=String(e?.day??``);Rw.test(n)&&r.set(n,(r.get(n)??0)+S(e?.[t],0))}return r}function pD(e,t){let n=ET(e);return n?t<=7?RE[n.getDay()]:String(n.getDate()):e}function mD(e,t,n,r){let i=fD(e,r===`cost`?`costUSD`:`tokens`),a=cD(n,t).map(e=>({day:e,label:pD(e,t),value:i.get(e)??0,isToday:e===n})),o=a.reduce((e,t)=>e+t.value,0),s=cD(dD(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 hD(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 gD(e){return`${Gw(e.average,e.metric)} a day on average`}function _D(e){return eE(e)?$T(e).map(e=>`${e.label} ${bw(e.costUSD)}`).join(`, `):``}function vD(e){return eE(e)?$T(e).map(t=>({...t,sharePct:Jw(t.tokens,e?.tokens)})):[]}function yD(e){let t=e?.totals,n=[{label:`Processed tokens`,value:xw(S(t?.tokens,0))},{label:`Cached input`,value:xw(S(t?.cacheRead,0))},{label:`Uncached input`,value:xw(S(t?.input,0))},{label:`Output`,value:xw(S(t?.output,0))}],r=S(bT(e?.savings)?.savedUSD,0);return r>0&&n.push({label:`Cache savings`,value:bw(r)}),n}function bD(e){let t=(e?.yourDay?.insights??[]).map(e=>({text:e.text,tone:`ok`})),n=e?.anomaly;JT(n)&&t.push({text:qT(n),tone:`warn`});for(let n of[xT(e?.savings),vT(e)])n&&t.push({text:n,tone:`ok`});return t}function xD(e,t,n,r){let i=Kw(t,n),a=e.reduce((e,t)=>Math.max(e,S(t[i],0)),0);return e.map(e=>({row:e,label:r(e),tokens:S(e.tokens,0),costUSD:S(e.costUSD,0),sharePct:Jw(e[i],t?.[i]),barPct:Jw(e[i],a)??0}))}function SD(e,t){return xD(OE(e?.models,nD(e?.totals,t)),e?.totals,t,hE)}function CD(e,t){return xD(TE(e?.sessions,nD(e?.totals,t)),e?.totals,t,mE)}function wD(e){return[{label:`Input`,tokens:S(e.input,0)},{label:`Output`,tokens:S(e.output,0)},{label:`Cache write`,tokens:S(e.cacheCreate,0)},{label:`Cache read`,tokens:S(e.cacheRead,0)}]}var TD=2e4,ED=`glimmervoid-usage-metric`,DD=null,OD=null,kD={claude:null,codex:null,kimi:null},AD=null,jD=null,MD=null,ND=gw,PD=Ww(zr(ED,null)),FD=!1,ID=null,LD=null,RD=!0,zD=()=>!1,BD=new Set,VD=_t({getAck:Pi,setAck:gi,signature:()=>Ow(DD,kD.claude),isLooking:()=>zD()});function HD(e){for(let t of BD)t(e)}function UD(){AD?.(VD.refresh())}function WD(e){FD=e,HD(`refresh-status`),ID&&=(clearTimeout(ID),null),e&&(ID=setTimeout(()=>{ID=null,FD=!1,LD=`Usage did not answer within ${Math.round(TD/1e3)} s. Refresh to try again.`,HD(`refresh-status`)},TD))}function GD(e){let t=hw.find(t=>t.value===e);return t?t.days:null}function KD(){return{report:DD,sessions:OD,planLimitsByVendor:kD,rangeValue:ND,metric:PD}}function qD(){let e=!RD||!FD&&LD!==null;return RD?FD?{text:`Refreshing`,isPending:!0,hasFailure:e}:{text:LD??``,isPending:!1,hasFailure:e}:{text:DD?`${x} The figures below are from before the connection dropped.`:x,isPending:FD,hasFailure:e}}function JD(e){BD.add(e)}function YD(e){zD=e,UD()}function XD(){VD.acknowledge(),UD()}function ZD(e){AD=e,UD()}function QD(e){jD?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function $D(e){jD=e}function eO(e){ND=e}function tO(e){PD=e,Rr(ED,e)}function nO({force:e=!1}={}){if(!jD)return;MD=d(`usage`);let t={type:`request-usage-report`,requestId:MD};e&&(t.force=!0);let n=GD(ND);n!==null&&(t.days=n),LD=null,WD(!0),jD(t)||(LD=x,WD(!1))}function rO(e){RD=e,HD(`refresh-status`)}function iO(e){OD=e,HD(`sessions`)}function aO(e){let t=e;kD={...kD,[Dw(t)]:t},HD(`plan-limits`),UD()}function oO(e){Pw(e,MD)&&(LD=null,WD(!1),DD=e,HD(`report`),UD())}function sO(){let e=DD?.pricing||(OD?{source:OD.pricingSource}:null),t=Aw(e?.fetchedAt),n=[kw(e,t!==null&&t>0?dw(t):``)],r=Nw(DD);r&&n.push(r);let i=Mw(DD?.scan);return i&&n.push(i),n}var cO=[],lO=[],uO=[],dO=new Map;function fO(){for(let e of[...cO])e()}function pO(e){for(let t of lO)t(e)}function mO(e){return e.type===`whiteboard-result`}async function hO(e,t){try{let n=await c(e,t,{timeoutMs:Or});return mO(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:Dr(e,Or)}}}function gO(){return uO}function _O(e){return cO.push(e),()=>{let t=cO.indexOf(e);t>=0&&cO.splice(t,1)}}function vO(e){lO.push(e)}function yO(){let e=new Map;for(let t of uO)for(let n of t.connectedSessionIds){let r=e.get(n);r?r.push(t):e.set(n,[t])}dO=e}function bO(e){uO=[...e.boards].sort((e,t)=>t.updatedAt-e.updatedAt),yO(),fO()}function xO(e){uO=uO.filter(t=>t.id!==e.boardId),yO(),pO(e.boardId),fO()}async function SO(e){let t=await hO(`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 CO(e,t){let n=await hO(`whiteboard-op`,{boardId:e,ops:t});return n.ok?{ok:!0,patch:n.reply.patch??null}:n}async function wO(e){let t={"x-glimmervoid-upload-name":encodeURIComponent(e.name)};e.type&&(t[`content-type`]=e.type);let n=await fetch(Zt,{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=Xt.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 TO(e){let t=await hO(`whiteboard-delete`,{boardId:e});return t.ok?{ok:!0}:t}async function EO(e,t){let n=await hO(`whiteboard-connect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function DO(e,t){let n=await hO(`whiteboard-disconnect`,{boardId:e,sessionId:t});return n.ok?{ok:!0}:n}async function OO(e){let t=await hO(`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 kO=null;function AO(e){kO=e}function jO(e,t){kO?.(e,t)}function MO(e){return dO.get(e)??[]}var NO=null;function PO(e,t){NO={boardId:e,sessionId:t}}function FO(){let e=NO;return NO=null,e}var IO=()=>{};function LO(e){IO=e}function RO(e,t){PO(e,t),IO()}function zO(e,t){let n=e.queuedBySessionId[t]??0;return n===0?``:`${n} queued`}function BO(e,t,n){let r=zO(e,t),i=r?`wait`:`muted`;return{key:`board:${e.id}`,text:n,detailText:e.title,stateText:r,look:{icon:`board`,tone:i},tier:gn(i),className:`session-pr-chip session-board-chip`,ariaLabel:`Open board ${e.title}`,onActivate:()=>RO(e.id,t)}}function VO(e,t){let n=zO(e,t);return BO(e,t,n?`${e.title}, ${n}`:e.title)}function HO(e){return MO(e).map(t=>BO(t,e,t.title))}function UO(e,t,n){let r=VO(e,t),i=Ve(`session-pr-chip-unlink`);i.append(Ee(ut)),i.setAttribute(`aria-label`,`Disconnect board ${e.title}`),i.addEventListener(`click`,r=>{r.stopPropagation(),r.preventDefault(),$t({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:()=>{DO(e.id,t).then(e=>n(e.ok?null:e.error))}})});let a=T(`span`,`session-pr-chip-item`);return a.append(_n(r,r),i),a}function WO(e){let{dialog:t,close:n,actions:r,btnCancel:i}=tn({title:`Connect board`}),a=T(`div`,`session-pr-chips dialog-linked-prs`),o=T(`p`,`dialog-message`,`A connected session is told what others changed on the board with its next whiteboard get or prompt.`),s=T(`select`,`dialog-input`);s.setAttribute(`aria-label`,`Board to connect`);let c=Cr(`action-status`),l=C({variant:`primary`,label:`Connect`});r.append(l),t.append(a,o,s,c.element,r);function u(e){e&&c.show(`error`,e)}function d(){let t=MO(e);on(a,t.map(t=>VO(t,e)),n=>{let r=t.find(e=>`board:${e.id}`===n.key);return r?UO(r,e,u):_n(n,n)});let n=gO().filter(t=>!t.connectedSessionIds.includes(e));s.replaceChildren(...n.map(e=>{let t=T(`option`,null,e.title);return t.value=e.id,t})),n.length===0&&s.append(T(`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,EO(t,e).then(e=>{e.ok?n():(c.show(`error`,e.error),d())}))}),i.addEventListener(`click`,n);let f=_O(()=>{t.isConnected?d():f()});d()}_O(In);function GO(){return A.snapshot().borrowedCardId}var KO=null;function qO(e,t,n,{className:r,onRelease:i}={}){if(!e?.card||!n)return;let a=GO();a&&a!==t&&JO();let o=e.card;o._cardHostClass&&o._cardHostClass!==r&&o.classList.remove(o._cardHostClass),o._cardHostClass=r||``,r&&o.classList.add(r),Kt(o,n),KO=i??null,A.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function JO(){let e=GO(),t=KO;if(KO=null,t?.(),A.dispatch(`borrowCard`,null),!e)return null;let n=O.get(e);n?._showTerminalFace?.(),n?._setBorrowed?.(!1),n?._setActiveViewer?.(!1);let r=n?.card;return r&&(r._cardHostClass&&r.classList.remove(r._cardHostClass),delete r._cardHostClass,Nt(r,fr)),e}var YO=null,XO=null,ZO={},QO=null,$O=null,ek=null,tk=new Map,nk=new Map;function rk(){return XO??=j(()=>import(`./phone-shell-BfUzchP7.js`).then(e=>{e.mountPhoneShell(ZO),ek&&e.orderPhonePanels(ek);for(let[t,n]of tk)e.setPhoneScreenAvailable(t,n);for(let[t,n]of nk)e.setPhoneScreenAttention(t,n);return YO=e,e},e=>(XO=null,y(`phone-shell`,`phone shell failed to load: ${l(e)}`),null)),__vite__mapDeps([26,3,4,13,21,27,14,15,24,28,12,5,6,7,20,29,30,31,23,32,33])),XO}function ik(e){ZO=e}async function ak(e){let t={options:e};QO=t;let n=await rk();if(QO!==t)return!1;if(!n)return QO=null,$O=null,!1;QO=null,n.activatePhoneShell(t.options);let r=$O;return $O=null,r?.(n),!0}function ok(){QO=null,$O=null,YO?.deactivatePhoneShell()}function sk(){return QO!==null||(YO?.isPhoneShellActive()??!1)}function ck(){return QO?QO.options?.sessionId??null:YO?.getPhoneSessionId()??null}function lk(e){ek=e,YO?.orderPhonePanels(e)}function uk(e,t){tk.set(e,t),YO?.setPhoneScreenAvailable(e,t)}function dk(e,t){nk.set(e,t),YO?.setPhoneScreenAttention(e,t)}function fk(){YO?.refreshPhoneBoard()}function pk(){YO?.syncPhoneHistory()}function mk(e){return QO?($O=t=>{e(t)},!0):YO?e(YO):!1}function hk(e){return mk(t=>t.showPhonePlan(e))}function gk(e){return mk(t=>t.showPhoneSession(e))}function _k(e){return mk(t=>t.showPhoneScreen(e))}function vk(){let e=ck();e&&k(e)?._isActiveViewer?.()===!0&&rw(e)}function yk(){qf(k(GO())),vk()}function bk(){window.addEventListener(`focus`,yk),window.addEventListener(`blur`,yk),document.addEventListener(`visibilitychange`,yk),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Zo()}),window.addEventListener(`pageshow`,e=>{e.persisted&&Zo()})}function xk(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function Sk(e,t,n){return t>0?{minPx:e.minPx,maxPx:Math.max(e.minPx,Math.min(e.maxPx,t-n))}:e}function Ck(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function wk({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:Sk(i,n.getBoundingClientRect().width,l),f=null,p=t=>{let i=d();e.setAttribute(`aria-valuemax`,String(i.maxPx));let a=xk(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=Ck(e.key,a);if(n===null)return;e.preventDefault();let r=p((f??t.getBoundingClientRect().width)+u*n);r!==null&&s(r)})}var Tk={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.`}},Ek=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:Ut[e],meaning:t}),Dk=Object.freeze([Ek(E.DORMANT,`Not started yet.`),Ek(E.STARTING,`Setting up the worktree and booting the agent.`),Ek(E.RUNNING,`The agent is mid-turn.`),Ek(E.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),Ek(E.WAITING,`Waiting on a permission prompt or your answer.`),Ek(E.COMPLETE,`Finished a turn you have not looked at yet.`),Ek(E.IDLE,`Ready for the next prompt.`),Ek(E.DONE,`The agent process ended.`),Ek(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 Ok(e,t){let n=T(`section`,`status-legend`),r=T(`dl`,`status-legend-rows`);return r.append(...t),n.append(T(`h2`,`status-legend-title`,e),r),n}function kk(e,t){let n=T(`div`,`status-legend-row`);return n.append(e,T(`dd`,`status-legend-meaning`,t)),n}function Ak(){return Ok(`Status colors`,Dk.map(e=>{let t=T(`dt`,`status-legend-badge`),n=T(`span`,`status-legend-glyph`),r=T(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=kk(t,e.meaning);return Nn(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function jk(){return Ok(`Pull request icons`,Object.keys(Tk).map(e=>{let t=Tk[e],n=T(`dt`,`status-legend-badge`);return n.append(fa(e),T(`span`,`status-legend-name`,t.label)),kk(n,t.meaning)}))}var Mk=null,Nk=null,Pk=!1,Fk=null;function Ik(){return Nk??=j(()=>import(`./first-run-checklist-BlWuVccS.js`).then(e=>(Mk=e,e),e=>(Nk=null,y(`first-run`,`first-run checklist failed to load: ${l(e)}`),null)),__vite__mapDeps([34,12,13,4,3,14,5,6,7,35,27,15,21,24,28,20,36])),Nk}function Lk(e,t){Fk={host:e,isShown:t},Mk?Mk.showFirstRunChecklist(e,t):t&&Pk&&Ik().then(e=>{e&&Fk&&e.showFirstRunChecklist(Fk.host,Fk.isShown)})}function Rk(){Mk?.refreshFirstRunChecklist()}function zk(){Pk=!0,Fk&&Lk(Fk.host,Fk.isShown)}var Bk=`removed`,Vk=new Set([E.COMPLETE,E.DONE,E.FAILED,Bk]);function Hk(e){return Vk.has(e)}function Uk(e,t){let n=e.filter(e=>Hk(t(e))).length;return{settled:n,total:e.length,isAllSettled:e.length>0&&n===e.length}}function Wk(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
- `):e.judge?.notes[t]??null}function Gk(e){return e.series?.id??e.id}function Kk(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 qk=[],Jk=null,Yk=new Set;function Xk(e){Yk.add(e)}function Zk(){return qk}function Qk(e){qk=e.races;for(let e of Yk)e()}function $k(){return Jk}function eA(e){Jk=e.history;for(let e of Yk)e()}function tA(e){let t=nA(e.id);if(!t)return null;let n=Uk(Object.values(t.sessionIdByContestant),e=>O.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 nA(e){return qk.find(t=>Object.values(t.sessionIdByContestant).includes(e))??null}var rA=()=>{};function iA(e){rA=e.openTerminal}function aA(e){rA(e)}function oA({onAdd:e}){let t=T(`div`,`session-group-header`),n=T(`span`,`session-group-label`),r=T(`span`,`session-group-count`),i=T(`span`,`session-group-rule`);i.setAttribute(`aria-hidden`,`true`);let a=C({variant:`icon`,size:`small`,label:`Add session to this project`,icon:Ee(He),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 sA(e,t,{isHostShown:n=!1}={}){let{header:r,label:i,count:a,addButton:o}=e;qi(r,`path`,t.projectPath??``),qi(r,`label`,t.label),Bi(i,n&&t.hostName?`${t.hostName} / ${t.label}`:t.label),Bi(a,String(t.rows.length)),na(a,t.rows.length===0),na(o,t.projectPath===null)}var cA={waitingCount:0,finishedCount:0,failedCount:0},lA={failed:Dt[E.FAILED],waiting:Dt[E.WAITING],finished:Dt[E.COMPLETE]},uA={failed:`failed`,waiting:`needs you`,finished:`finished`},dA=[`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`],fA=2500,pA=`cubic-bezier(0.16, 1, 0.3, 1)`,mA=`cubic-bezier(0.5, 0, 0.2, 1)`,hA=260,gA=200,_A=200,vA=300,yA=28,bA=360,xA=420,SA=200,CA=3,wA=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),TA=new WeakMap;function EA(e){let t=TA.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function DA(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function OA(){return wA?.matches??!1}function kA(e){return e.map(e=>({easing:pA,...e}))}function AA(e,t){let n=T(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${mr.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${mr.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${mr.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${mr.overflowSlot}px`);let r=T(`span`,`attention-banner-chips`),i=T(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=T(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=T(`span`,`attention-banner-status`);o.append(r,T(`span`,`attention-banner-count`),a);let s=Ve(`attention-banner-jump-row`);return s.append(o),t&&(t.classList.add(`attention-banner-jump`),s.append(t)),n.addEventListener(`click`,()=>e.onJump()),n.append(s),TA.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),jA(n,cA,[]),n}function jA(e,t,n){let r=EA(e);r.tiles=n,Bi(zt(e,`.attention-banner-count`),gr(t));let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&JA(e,r),MA(e)}function MA(e){let t=EA(e),n=zt(e,`.attention-banner-chips`),r=zt(n,`.attention-tile-overflow`),i=DA(e),a=t.tiles.slice(0,ir(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():IA(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??PA(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),FA(s,i,a===0),(s.parentElement!==n||NA(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;na(r,p===0),Bi(r,`+${p}`),Hi(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)&&BA(e,null),i){for(let e of d)LA(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?zA(r,a):a!==0&&RA(r,a,n)})}}function NA(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function PA(e,t){let n=T(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=T(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>BA(e,t)),n.addEventListener(`pointerleave`,()=>BA(e,null)),n}function FA(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}, ${uA[n]}`:`${r}, ${uA[n]}, passed on: ${a}`;Hi(e,`aria-label`,o),kr(zt(e,`.attention-tile-icon`),lA[n])}function IA(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=OA()?[{opacity:1},{opacity:0}]:kA([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:_A,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function LA(e){let t=OA()?[{opacity:0},{opacity:1}]:kA([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:gA})}function RA(e,t,n){OA()||e.animate(kA([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:vA,delay:n*yA,fill:`backwards`})}function zA(e,t){OA()?e.animate([{opacity:.35},{opacity:1}],{duration:bA,easing:pA}):e.animate(kA([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:bA})}function BA(e,t){let n=EA(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 VA(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function HA(e,t,n){let r=EA(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!DA(e)){n();return}BA(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=VA(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(UA(o,s),WA(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function UA(e,t){return!t||OA()?[{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 WA(e){return!e||OA()?{duration:SA,fill:`forwards`}:{duration:xA,easing:mA,fill:`forwards`}}function GA(e){let t=EA(e);e.hasAttribute(`data-empty`)&&qA(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!DA(e))return;let n={duration:hA};if(t.pressAnimations.push(e.animate(kA([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!OA()){t.pressAnimations.push(e.animate(kA([{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(kA([{transform:`none`},{transform:`translateY(${CA}px)`,offset:.3},{transform:`none`}]),n),r.animate(kA([{transform:`none`},{transform:`translateY(-${CA}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function KA(e){let t=dA.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??dA[0]}function qA(e,t){let n=KA(t.lastAllClearLine);t.lastAllClearLine=n,zt(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>JA(e,t),fA)}function JA(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var YA=new WeakMap;function XA(e){let t=YA.get(e);if(!t)throw Error(`attention ledger was not built by buildAttentionLedger`);return t}function ZA(e){return e.flatMap(e=>Vn(e.id).map(t=>({sessionId:e.id,seq:t.seq,ts:t.ts,text:`${e.name??``}: ${yr(t)}`}))).sort((e,t)=>t.ts-e.ts).map(({sessionId:e,seq:t,text:n})=>({sessionId:e,seq:t,text:n}))}function QA(e){let t=T(`div`,`attention-ledger`);t.hidden=!0;let n=C({variant:`quiet`,size:`small`,label:`Answers`,onClick:()=>ej(t)});n.classList.add(`attention-ledger-answers`),n.setAttribute(`aria-expanded`,`false`);let r=T(`ol`,`attention-ledger-list`);return r.hidden=!0,t.append(T(`span`,`attention-ledger-count`),n,r),YA.set(t,{onOpenSession:e,rows:[],openEntries:null}),t}function $A(e,t){let n=XA(e);n.rows=t;let r=(n.openEntries??ZA(t)).length;Bi(zt(e,`.attention-ledger-count`),sr(r)),na(e,r===0)}function ej(e){let t=XA(e);if(t.openEntries){tj(e);return}let n=ZA(t.rows);t.openEntries=n,zt(e,`.attention-ledger-answers`).setAttribute(`aria-expanded`,`true`);let r=zt(e,`.attention-ledger-list`);r.replaceChildren(...n.map(n=>{let r=Ve(`attention-ledger-item`,n.text);return r.addEventListener(`click`,()=>{tj(e),t.onOpenSession(n.sessionId)}),nj(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)Pn(e,t)}function tj(e){let t=XA(e);t.openEntries=null,zt(e,`.attention-ledger-answers`).setAttribute(`aria-expanded`,`false`);let n=zt(e,`.attention-ledger-list`);n.hidden=!0,n.replaceChildren(),$A(e,t.rows)}function nj(e){let t=T(`li`);return t.append(e),t}var rj=[],ij=new Set;function aj(e){let t=at.safeParse(e);if(t.success){rj=t.data;for(let e of ij)e()}}function oj(e){return rj.find(t=>t.agent===e)??null}function sj(e){return ij.add(e),()=>{ij.delete(e)}}var cj=2e3,lj={},uj=null,dj=null,fj=Qe,pj=null,mj=!1,hj=null,gj=[],_j=null,vj=()=>null,yj=()=>{},bj=!1,xj=new Set,Sj=new Set;function Cj(e){for(let t of Sj)t(e)}function wj(e){Sj.add(e)}function Tj(){return lj}function Ej(e){return lj={...lj,...e},lj}function Dj(){return{status:uj,journal:dj,request:fj,lastAutoCheckAt:pj,isCheckInFlight:mj,checkSendFailure:hj}}function Oj(e){let t=ke(fj,e);t!==fj&&(fj=t,Cj({kind:`update`,frame:`request`}))}function kj(){Oj(s({type:`update-apply`})?`request-sent`:`request-unsent`)}function Aj(){pj=Date.now();let e=s({type:`update-check`});mj=e,hj=e?null:x,Cj({kind:`update`,frame:`request`})}function jj(e){yj=e}function Mj(){yj()}function Nj(e){gj=[...e]}function Pj(){return gj}function Fj(e=null,t=null,n=null){let r=_j!==null&&(_j.sectionId!==null||_j.isLink);e===null&&n===null&&r||(_j={sectionId:e,settingId:t,hashAtRequest:n??location.hash,isLink:n!==null},Cj({kind:`activate`}))}function Ij(){let e=_j;return _j=null,e}function Lj(e){vj=e}function Rj(){for(let e of xj)e()}function zj(e){xj.add(e)}function Bj(){return us()&&vj()===`section`}function Vj(){Bj()&&Cj({kind:`return-to-list`})}function Hj(e){e&&(lj=e,aj(lj.agentLogins),Cj({kind:`broadcast`}))}function Uj(){bj||(bj=!0,window.setTimeout(()=>{c(`get-settings`,{}).then(e=>{e.settings&&Hj(e.settings)}).catch(()=>{bj=!1})},cj))}function Wj(){Cj({kind:`status`})}function Gj(e){Wj()}function Kj(e){uj=e,mj=!1,hj=null,fj=ke(fj,`status-frame`),Cj({kind:`update`,frame:`status`})}function qj(e){dj=e,fj=ke(fj,`progress-frame`),Cj({kind:`update`,frame:`progress`})}function Jj(e){if(e.scope!==`update`)return!1;let t=Pe(e.message),n=fj.requested;return fj=ke(fj,`error-frame`,t),mj=!1,n||(hj=t),Cj({kind:`update`,frame:`error`}),!0}var Yj=[`terminal`,`board`],Xj=.05,Zj=`application/x-glimmervoid-board-pane`,Qj=`input, textarea, select, button, [contenteditable="true"]`;function $j(){let e=fi(),t=new Set([`terminal`]),n=!1,r=[],i=T(`div`,`pane-layout`),a=T(`div`,`pane-trail`),o=T(`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=T(`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=T(`section`,`pane-group`);t.dataset.pane=e;let n=T(`div`,`pane-strip pane-header`),r=T(`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(Qj)?e.preventDefault():(e.dataTransfer?.setData(Zj,`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 Fi(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(ii(e,i))})}function m(t){t!==e&&(e=t,qr(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 Yj)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=Gr(e,v(t)),_())});let y=t=>{o.hasPointerCapture(t.pointerId)&&(o.releasePointerCapture(t.pointerId),delete o.dataset.dragging,qr(e))};return o.addEventListener(`pointerup`,y),o.addEventListener(`pointercancel`,y),o.addEventListener(`keydown`,t=>{let n={ArrowLeft:-.05,ArrowUp:-.05,ArrowRight:Xj,ArrowDown:Xj}[t.key];n!==void 0&&(t.preventDefault(),m(Gr(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 eM=[],tM=new Set,nM=new WeakSet,rM=null,iM=null;function aM(e){eM.some(t=>t.id===e.id)||(eM.push(e),sM(e.id,null))}function oM(){return eM}function sM(e,t){for(let n of tM)n(e,t)}function cM(e){return tM.add(e),()=>tM.delete(e)}function lM(e){e!==rM&&(pM(),rM=e)}function uM(e){rM===e&&(pM(),rM=null)}function dM(e,t){return iM?.page.id===e&&iM.sessionId===t}function fM(e,t,n=null){let r=eM.find(t=>t.id===e);if(!r||!rM||rM.sessionId()!==t||!r.isAvailableFor(t)||dM(e,t)&&n===null)return;pM();let i=rM,a=i.elementFor(r);gM(a),iM={page:r,sessionId:t},r.mount(a,t,{placement:i.placement,target:n}),i.didShow(r),sM(r.id,t)}function pM(){if(!iM)return;let{page:e,sessionId:t}=iM;iM=null,e.unmount(),rM?.didHide(e),sM(e.id,t)}function mM(){return iM?.page.canStepBack()??!1}function hM(){return iM?iM.page.canStepBack()?(iM.page.stepBack(),!0):(pM(),!0):!1}function gM(e){nM.has(e)||(nM.add(e),e.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Rt(e)||hM()&&e.preventDefault()}))}function _M({style:e}){let t=T(`div`,`session-page-bar session-page-bar-${e}`),n=new Map,r=null;function i(n){let i=e===`header`,a=Ee(n.iconPath),o=`${i?`open`:`show`}-${n.id}`,s=C({variant:`icon`,size:i?`small`:void 0,label:n.label,icon:a,action:o});s.addEventListener(`click`,()=>{r&&fM(n.id,r)});let c=T(`span`,`session-page-dot`);c.setAttribute(`aria-hidden`,`true`);let l=T(`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 eM)a(e)}return cM((e,t)=>{if(t!==null&&t!==r)return;let n=eM.find(t=>t.id===e);n&&a(n)}),o(),{element:t,showSession(e){r=e,o()}}}var vM=5,yM={high:`High`,medium:`Medium`,low:`Low`};function bM(e,t){let n=Ve(`review-look-line`,e.path);return n.append(T(`span`,`review-look-detail`,e.detail)),n.addEventListener(`click`,()=>t(e.openPath)),n}function xM(e,t){let n=T(`div`,`review-look-group`);n.dataset.kind=e.kind;let r=T(`p`,`review-look-text`,e.heading);if(e.conflictRisk){let t=T(`span`,`review-look-risk`,`Conflict risk: ${yM[e.conflictRisk]}`);t.dataset.risk=e.conflictRisk,r.append(` `,t)}n.append(r);for(let r of e.lines)n.append(bM(r,t));return n}function SM(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=T(`section`,`review-look`);if(i.append(T(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=T(`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,vM);if(a.length>0){let e=T(`div`,`review-look-list`);for(let t of a)e.append(xM(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=T(`div`,`review-look-more`),c=C({variant:`quiet`,size:`small`,label:`Show all`,action:`show-all-worth-a-look`,onClick:n});return s.append(T(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function CM(e){return(e??[]).map(e=>T(`span`,`review-file-hint`,e.text))}var wM=`changes`,TM={add:`+`,del:`-`,meta:`\\`},I=null,EM=null,L=null,R=null,DM=null,OM=!1;function kM(){let e=T(`section`,`review-reader`);e.setAttribute(`aria-label`,`Changes`),e.tabIndex=-1,e.hidden=!0;let t=T(`div`,`review-reader-bar`),n=T(`p`,`review-reader-status`);n.setAttribute(`role`,`status`);let r=T(`p`,`review-reader-notice`);r.setAttribute(`role`,`status`);let i=T(`div`,`review-reader-actions`),a=C({variant:`primary`,label:`Merge`,action:`merge-session`,onClick:()=>{L&&fb(L)}}),o=C({variant:`danger`,label:`Discard`,action:`discard-session`,onClick:()=>{L&&pb(L)}}),s=C({variant:`secondary`,label:`Close`,action:`close-reader`,onClick:pM});i.append(a,o,s),t.append(n,r,i);let c=T(`div`,`review-reader-body`),l=T(`div`,`review-reader-files`),u=T(`div`,`review-reader-diff`);return c.append(l,u),e.append(t,c),e.addEventListener(`keydown`,jM),Gy(e=>{e===L&&FM()}),Gi(()=>{R=null,OM=!1,FM(),MM()}),gb(e),{root:e,status:n,notice:r,mergeButton:a,discardButton:o,closeButton:s,fileColumn:l,diff:u}}function AM(){return I??=kM(),I}function jM(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Rt(e))return;let t=e.key===`j`?1:e.key===`k`?-1:0;if(t===0||!L)return;e.preventDefault();let n=Ty(Xy(L)?.files??[],R,t);n&&NM(n)}function MM(){L&&sM(wM,L)}function NM(e){R=e,FM(),I?.fileColumn.querySelector(`.review-reader-file[aria-current="true"]`)?.scrollIntoView({block:`nearest`}),MM()}function PM(e){let t=wy(e,DM);t&&(R=t.path,DM=null),wy(e,R)||(R=EM===`overlay`?e[0]?.path??null:null)}function FM(){if(!I||EM===null)return;L=ta();let e=L?Xy(L):null;if(I.closeButton.hidden=EM!==`overlay`,!e){IM(I);return}let t=R!==null;PM(e.files),I.status.textContent=e.sentence;let n=e.notice??(e.isMergeShown&&!e.isMergeEnabled?e.mergeRefusal:null);I.notice.textContent=n??``,I.notice.hidden=n===null,I.mergeButton.hidden=!e.isMergeShown,I.mergeButton.disabled=!e.isMergeEnabled,I.discardButton.hidden=!e.isDiscardShown,I.root.dataset.level=EM===`screen`&&R!==null?`diff`:`list`,LM(I.fileColumn,e),VM(I.diff,wy(e.files,R)),t!==(R!==null)&&MM()}function IM(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 LM(e,t){let n=e.scrollTop;if(e.replaceChildren(),t.diffError){e.append(T(`p`,`review-diff-error`,t.diffError));return}if(t.isEmpty){e.append(T(`p`,`review-empty-title`,t.sentence));return}t.totals.files>0&&e.append(RM(t.totals));let r=T(`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?dy(i,e.path):null;n&&n!==a&&r.append(T(`div`,`review-repo-label`,n)),a=n,r.append(zM(e,t))}e.append(r);let o=t.changeMapView?SM(t.changeMapView,{isShowingAll:OM,onShowAll:HM,onOpenFile:UM}):null;o&&e.append(o),e.scrollTop=n}function RM(e){let t=T(`p`,`review-reader-totals`);return t.append(T(`span`,`review-stat-files`,`${e.files} file${e.files===1?``:`s`}`),T(`span`,`review-add`,`+${e.added}`),T(`span`,`review-del`,`-${e.removed}`)),t}function zM(e,t){let n=Ve(`review-reader-file`);n.dataset.path=e.path,n.setAttribute(`role`,`listitem`),n.setAttribute(`aria-current`,String(e.path===R));let r=T(`span`,`review-file-name`);r.append(T(`span`,`review-file-path`,e.path));let i=CM(t.changeMapView?.hintsByOpenPath.get(e.path));if(i.length>0){let e=T(`span`,`review-file-hints`);e.append(...i),r.append(e)}return n.append(r,BM(e)),n.addEventListener(`click`,()=>NM(e.path)),n}function BM(e){let t=T(`span`,`review-file-counts`);return e.binary?(t.append(T(`span`,`review-bin`,`bin`)),t):(t.append(T(`span`,`review-add`,`+${e.added}`),T(`span`,`review-del`,`-${e.removed}`)),t)}function VM(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=T(`div`,`review-reader-diff-head`);if(r.append(T(`span`,`review-file-path`,t.path),BM(t)),e.append(r),t.binary){e.append(T(`div`,`review-file-binary`,`Binary file not shown`));return}let i=T(`div`,`review-file-body`);for(let e of t.hunks){i.append(T(`div`,`review-hunk-head`,e.header));for(let t of e.lines){let e=T(`div`,`review-line review-line-${t.type}`);e.append(T(`span`,`review-line-gutter`,TM[t.type]??` `),T(`span`,`review-line-text`,t.text)),i.append(e)}}e.append(i),e.scrollTop=n}function HM(){OM=!0,FM()}function UM(e){let t=wy(L?Xy(L)?.files??[]:[],e);t&&NM(t.path)}function WM(e,t){let{root:n}=AM();n.parentElement!==e&&e.append(n),EM=t,n.dataset.placement=t,n.hidden=!1}function GM(){I&&(I.root.hidden=!0,I.root.remove(),EM=null)}function KM(){R!==null&&(R=null,FM(),MM())}function qM(e,t){t===`header`&&(gb(e),new MutationObserver(hb).observe(e,{attributes:!0,attributeFilter:[`data-slot-held`]}))}Gy(e=>sM(wM,e));var JM={id:wM,label:`Changes`,iconPath:et,isAvailableFor:e=>Xy(e)!==null,hasUnreadFor:()=>!1,mount(e,t,{placement:n,target:r}){WM(e,n),DM=r,FM(),n===`overlay`&&AM().root.focus({preventScroll:!0})},unmount:GM,canStepBack:()=>EM===`screen`&&R!==null,stepBack:KM,attachButton:qM};function YM(){aM(JM)}var XM=`This machine`,ZM=null,QM=new Map;function $M(){let e=T(`div`,`rail-host-header`),t=T(`span`,`rail-host-label`),n=T(`span`,`rail-host-state`);return e.append(t,n),{header:e,label:t,stateText:n}}function eN(e,t,n,r){Bi(e.label,t),qi(e.header,`state`,n),Bi(e.stateText,r),na(e.stateText,r===``)}function tN(e,t,n){t.parentElement===e&&(n?t.nextElementSibling===n:e.lastElementChild===t)||e.insertBefore(t,n)}function nN(e){for(let[t,n]of[...QM])e.has(t)||(n.header.remove(),QM.delete(t))}function rN(e,{firstGroupHeaderOf:t,trailingNode:n}){let r=oc();if(nN(new Set(r.map(e=>e.id))),r.length===0){ZM?.header.remove();return}let i=n;for(let n of r.toReversed()){let r=QM.get(n.id)??$M();QM.set(n.id,r),eN(r,n.name,n.state,sc(n)),tN(e,r.header,t(n.id)??i),i=r.header}ZM??=$M(),eN(ZM,XM,`local`,``),tN(e,ZM.header,t(null)??i)}var iN=new Set([`terminal`]),aN=new Set([`terminal`,`board`]),oN=new Set([`board`]),sN=e=>e.ui.path,cN=e=>mc(e.id),lN=`application/x-glimmervoid-board-row`,uN=`application/x-glimmervoid-session-row`,dN=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),fN=null,pN=null,mN=null,hN=null,gN=null,z=null,_N=null,vN=null,yN=null,bN=null,xN=null,B=null,SN=Ii(),CN=null,wN=`terminal`,TN=null,EN=new Map,DN=new Map,ON=null,kN=null,AN=null,V=!1,jN=!1,MN=null,NN=new Map,H=new Map,PN=new Map,FN=new Map,U=null,IN=``,LN=[],RN=null,zN=new Map,BN=new Map,VN=new Set;function HN(){return ni(WN(gP()),VN)}function UN(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 WN(e){return _i(e,sN,tA,cN)}function GN(e,t){let n=e.find(e=>e.hostId===t);return n?FN.get(n.key)?.header??null:null}function KN(e){let t=FN.get(e.key),n=PN.get(e.key);return t&&n||(t=oA({onAdd:Qi}),n=T(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),FN.set(e.key,t),PN.set(e.key,n)),sA(t,e),Hi(n,`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function qN(){return V}function W(){return A.snapshot().focusedSessionId}function JN(){return V&&B!==null}function YN({rail:e,center:t,resizer:n}){if(fN=e,hN=t,!fN||!hN)return;let r=fN,i=hN;pP(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,zi(Ju)),pN=AA({onJump:QP,rowFor:e=>H.get(e)},ed());let a=T(`details`,`rail-section rail-status-key`);a.append(T(`summary`,`rail-section-summary`,`Status key`),Ak()),VP(a,Zr(),hi),mN=QA(mF),r.append(pN,mN,a),ON=T(`div`,`focus-empty`),ON.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,kN=ON.querySelector(`.focus-empty-title`),AN=ON.querySelector(`.focus-empty-desc`),z=$j(),gN=z.bodyOf(`terminal`),z.bodyOf(`board`).tabIndex=-1,z.onBoardDrag(rP),TN=T(`div`,`rail-unsplit-slot`,`Drop here to unsplit`),YM(),_N=_M({style:`header`}),z.trailSlot.append(_N.element),i.append(ON,z.element),i.addEventListener(`focusin`,tP),Xk(()=>{V&&G()}),_O(()=>{if(!V)return;let e=B!==null;G(),e&&B===null&&TF()}),r.addEventListener(`keydown`,mP),r.addEventListener(`dragover`,aP),r.addEventListener(`drop`,oP)}function XN(){let e=gO(),t=Li(SN,e);QN(CN?di(t,e,CN,ZN):t),CN=yi(e)}_O(XN);function ZN(e){return O.has(e)}function QN(e){e!==SN&&(SN=e,pi(e))}function $N(){return ci(SN,gO(),ZN)}function eP(e){return e?$N()[e]??null:null}function tP(e){let t=e.target instanceof Element?e.target.closest(`.pane-group`)?.dataset.pane:void 0;if(t!==`terminal`&&t!==`board`||t===wN)return;wN=t;let n=W(),r=n?H.get(n):void 0;n&&r&&LP(r,n,IP())}function nP(){return z?.element.hasAttribute(`data-dragging`)===!0}function rP(){if(!TN)return;let e=W(),t=e&&eP(e)?H.get(e)?._row:void 0;!nP()||!t?(TN.removeAttribute(`data-over`),TN.remove()):t.nextElementSibling!==TN&&t.after(TN)}function iP(){return nP()&&TN?.isConnected===!0}function aP(e){iP()&&(e.preventDefault(),TN?.toggleAttribute(`data-over`,!0))}function oP(e){let t=W();iP()&&t&&(e.preventDefault(),wN=`terminal`,QN(Ti(SN,t)),G(),eF(O.get(t),t))}function sP(e){if(!V||!e||B)return null;let t=$N();if(Object.hasOwn(t,e))return{sessionId:e,boardIdToOpen:null};let n=Ni(t,MO(e));return n?{sessionId:e,boardIdToOpen:n.id}:null}Ku(()=>sP(W())!==null);function cP(){let e=sP(W());return e?e.boardIdToOpen?(QN(Ri(SN,e.sessionId,e.boardIdToOpen)),G(),!0):(wN=`terminal`,QN(Ti(SN,e.sessionId)),G(),eF(O.get(e.sessionId),e.sessionId),!0):!1}function lP(e,t){let n=gO().find(e=>e.id===t);n&&O.has(e)&&(n.connectedSessionIds.includes(e)||EO(t,e).then(uP),QN(Ri(SN,e,t)),W()===e?G():mF(e))}function uP(e){e.ok||y(`focus`,`connecting a dropped board failed: ${e.error}`)}var dP={minPx:280,maxPx:480},fP=16;function pP(e){e&&fN&&wk({resizer:e,column:fN,widthHost:fN,widthProperty:`--rail-width`,bounds:dP,keyStepPx:fP,getStoredWidth:vi,setStoredWidth:ji})}function mP(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(),ea(n);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=hP(),n=t.find(t=>t===e.target)??(U?H.get(U):null),r=n?t.indexOf(n):-1,i=_r(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&&UN(a.dataset.id),a.focus())}function hP(){return fN?[...fN.querySelectorAll(`button.session-row[data-id], button.session-row[data-board-id]`)].filter(e=>!e.closest(`details:not([open])`)):[]}function gP(){return rr(aa(bP),_P())}function _P(){return er(Tj())}function vP(e){let t=_P();t.includes(e)&&Ej({sessionOrder:t.filter(t=>t!==e)})}function yP(e,t){let n=_P(),r=e=>{Ej({sessionOrder:e}),t()};r(e),c(`update-settings`,{settings:{sessionOrder:e}}).then(e=>{e.type===`settings-error`&&r(n)}).catch(()=>r(n))}wj(e=>{e.kind===`broadcast`&&G()});function bP(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function xP(e){let{row:t,refs:n}=Mn();t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,t=>MP(e,SP(t.target))),t.addEventListener(`pointerenter`,()=>{pN&&BA(pN,e)}),t.addEventListener(`pointerleave`,()=>{pN&&BA(pN,null)});let{item:r,removeButton:i}=An(t,()=>ea(e),()=>Vi(e));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,wP(r,e),jP(t,r,e),Object.assign(t,{_refs:n,_row:r})}function SP(e){return(e instanceof Element?e.closest(`[data-member]`)?.dataset.member:void 0)===`board`?`board`:`terminal`}function CP(e){return e.dataTransfer?.types.includes(lN)===!0}function wP(e,t){e.addEventListener(`dragover`,t=>{CP(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(lN);r&&(n.preventDefault(),lP(t,r))})}function TP(e){return RN!==null&&e.dataTransfer?.types.includes(uN)===!0}function EP(e){let t=RN?zN.get(RN):void 0,n=zN.get(e);return!t||!n?!1:cr(t,n,e=>BN.get(e.id)??``,new Set(zN.keys()))}function DP(e,t){let n=e.getBoundingClientRect();return t.clientY<n.top+n.height/2?`before`:`after`}function OP(){return LN.flatMap(e=>zN.get(e)??[])}function kP(){for(let e of fN?.querySelectorAll(`.session-row-item[data-drop-target]`)??[])delete e.dataset.dropTarget}function AP(e,t){let n=H.get(lr(OP(),e,t))?._row;n?.dataset.dropTarget!==t&&(kP(),n&&(n.dataset.dropTarget=t))}function jP(e,t,n){e.draggable=!0,e.addEventListener(`dragstart`,e=>{RN=n,e.dataTransfer?.setData(uN,n),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`)}),e.addEventListener(`dragend`,()=>{RN=null,kP()}),t.addEventListener(`dragover`,e=>{TP(e)&&EP(n)&&(e.preventDefault(),AP(n,DP(t,e)))}),t.addEventListener(`dragleave`,e=>{e.relatedTarget instanceof Node&&fN?.contains(e.relatedTarget)||kP()}),t.addEventListener(`drop`,e=>{kP(),TP(e)&&EP(n)&&RN&&(e.preventDefault(),yP(Jn(OP(),_P(),RN,n,DP(t,e)),G),RN=null)})}function MP(e,t=`terminal`){let n=ia(e);if(!n)return;wN=t===`board`&&eP(e)?`board`:`terminal`,mF(e);let r=H.get(e);r&&LP(r,e,IP()),wN===`board`?NP(e):eF(n,e)}function NP(e){requestAnimationFrame(()=>requestAnimationFrame(()=>{V&&W()===e&&z?.bodyOf(`board`).focus({preventScroll:!0})}))}function PP(e){let t=ia(e);t&&FP(t,e)}function FP(e,t){mF(t),eF(e,t)}function IP(){return new Map(gO().map(e=>[e.id,e.title]))}function LP(e,t,n){let r=eP(t),i=r?n.get(r)??null:null,a=r&&i!==null?{id:r,title:i}:null;bn(e,a,t===W()&&a!==null?wN:null)}function RP(e,{id:t,ui:n,state:r,name:i},a){let o=NN.get(t)||`none`;e.classList.toggle(`focused`,t===W()),Dn(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a});let s=t===U;Hi(e,`aria-selected`,String(s)),Hi(e,`tabindex`,s?`0`:`-1`)}function zP(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||``:Ir(r._refs?.glyph))}Ar(zP),Lr((e,t)=>{if(!V)return;let n=H.get(e);n&&Bi(n._refs.elapsed,Fr(t))});var BP=new Map;function G(e){if(!V)return;let t=fN;if(!t)return;let n=gP(),r=WN(n);zN=new Map(n.map(e=>[e.id,e])),BN=new Map(r.groups.flatMap(e=>e.rows.map(t=>[t.id,e.key])));let i=gO();B&&!i.some(e=>e.id===B)&&(B=null);let a=new Map(r.groups.filter(e=>e.hostId===null).flatMap(e=>e.rows.map(t=>[t.id,e.key]))),o=Oi(i,$N(),a),s=Hr(r,o.keys()),c=new Map(i.map(e=>[e.id,e.title])),l=new Set,u=new Set,d=vr(n,W()),f=new Map(d.map(({id:e},t)=>[e,t+1])),p=(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;u.add(t);let r=H.get(t),i=!r;r||(r=xP(t),H.set(t,r));let a=f.get(t)??null;(!e||i||e.has(t)||BP.get(t)!==a)&&RP(r,n,a),LP(r,t,c),BP.set(t,a)}a||Yi(n,[...t.flatMap(({id:e})=>H.get(e)?._row??[]),...r]),n._lastOrderKey=i},m=new Set(s.order),h=s.groups.map(e=>e.key).join(`
77
- `),g=h===IN;IN=h;for(let e of s.groups){let{header:n,list:r}=KN(e);g||t.append(n,r);let i=e.hostId===null?o.get(e.key):void 0;p(e.rows,r,i?KP(e.key,i,l):[])}qP(l,m),rN(t,{firstGroupHeaderOf:e=>GN(s.groups,e),trailingNode:null});for(let[e,t]of[...FN])m.has(e)||(t.header.remove(),PN.get(e)?.remove(),FN.delete(e),PN.delete(e));for(let[e,t]of H)u.has(e)||(t._row.remove(),H.delete(e),BP.delete(e),e===U&&(U=null));for(let e of[...NN.keys()])O.has(e)||NN.delete(e);let _=LN;LN=ni(r,VN);let v=W();if(v&&!ra(v)){pM(),A.dispatch(`focusSession`,null),U=null;let e=YP(_,v);if(e){let t=!document.activeElement||document.activeElement===document.body;mF(e),t&&eF(O.get(e),e);return}}hF();let y=W();if(y){let e=O.get(y);e&&e.card.parentElement!==gN&&nF(e,y)}_N?.showSession(B?null:y),sF(),rP(),ZP(n,d)}function VP(e,t,n){e.open=t,e.addEventListener(`toggle`,()=>n(e.open))}function HP(e){let{row:t,refs:n}=Mn();t.dataset.boardId=e,t.draggable=!0,t.addEventListener(`click`,()=>JP(e)),t.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(lN,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`link`)});let r=T(`div`,`session-row-item`);return r.dataset.boardNode=e,r.append(t),Object.assign(t,{_refs:n,_row:r})}function UP(e){let t=T(`details`,`focus-board-archive`);t.dataset.boardNode=`archive:${e}`;let n=T(`div`,`focus-board-archive-list`);return t.append(T(`summary`,`focus-board-archive-summary`,`Archived`),n),{details:t,list:n}}function WP(e){let t=e.connectedSessionIds.map(e=>O.get(e)).find(e=>e!==void 0);return t?bP(t):null}function GP(e,t){let n=EN.get(e.id);return n||(n=HP(e.id),EN.set(e.id,n)),Fn(n,n._refs,e.title,WP(e)),n.classList.toggle(`focused`,e.id===B),t.add(e.id),n._row}function KP(e,t,n){let r=t.active.map(e=>GP(e,n));if(t.archived.length===0)return r;let i=DN.get(e)??UP(e);return DN.set(e,i),Yi(i.list,t.archived.map(e=>GP(e,n))),[...r,i.details]}function qP(e,t){for(let[t,n]of EN)e.has(t)||(n._row.remove(),EN.delete(t));for(let[e,n]of DN)t.has(e)&&n.list.childElementCount>0||(n.details.remove(),DN.delete(e))}function JP(e){V&&(pF(),B=e,UN(null),G())}function YP(e,t){let n=e.filter(e=>e===t||ra(e));if(n.length<2)return LN.find(e=>ra(e))??null;let r=n.indexOf(t)===n.length-1;return _r(n,t,r?-1:1)}function XP(){return vr(gP(),W())}function ZP(e,t){pN&&(jA(pN,pr(e),t),mN&&$A(mN,e))}function QP(){if(!V)return;pN&&GA(pN);let e=XP()[0]?.id;e&&$P(e)}function $P(e){V&&(ia(e),H.get(e)?.scrollIntoView({block:`nearest`}),pN&&HA(pN,e,()=>tF(e)),mF(e),eF(O.get(e),e))}function eF(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{V&&W()===t&&e.term?.focus()}))}function tF(e){if(dN?.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=O.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function nF(e,t){if(!gN)return;let n=e.card.querySelector(`:scope > .session-card-header`);qO(e,t,gN,{className:`focus-centered`,onRelease:()=>{n?.classList.remove(`pane-header`),z?.setHeaderHost(`terminal`,null)}}),n?.classList.add(`pane-header`),n&&rF(n),Yf(e,t,!0)}function rF(e){let t=e.querySelector(`:scope > .session-name`);z?.setHeaderHost(`terminal`,{parent:e,before:t})}function iF(){return vN??=j(()=>import(`./boards-view-DIh7lkLS.js`).then(e=>(yN=e,e.onBoardPicked(lF),e)),__vite__mapDeps([37,3,4,17,13,12,14,31,23,15,21,29,16,38])),vN}function aF(e){vN=null,y(`focus`,`the board pane failed to load: ${l(e)}`)}function oF(e){z&&xN!==e&&(xN=e,z.showPanes(e))}function sF(){if(B){oF(oN),cF(null,B);return}let e=W(),t=eP(e);!e||!t?(oF(iN),bN=null):(oF(aN),cF(e,t))}function cF(e,t){let n=`${e??``}\n${t}`,r=bN!==n;bN=n,iF().then(n=>uF(n,e,r?t:null),aF)}function lF(e){if(!V)return;if(B){B=e,bN=`\n${e}`,G();return}let t=W();t&&(QN(Ri(SN,t,e)),bN=`${t}\n${e}`,G())}function uF(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 dF(){V&&bN!==null&&yN?.reopenSelectedBoard()}function fF(){let e=FO();V&&e?.sessionId&&O.has(e.sessionId)&&lP(e.sessionId,e.boardId)}function pF(){pM();let e=W();e&&(GO()===e&&JO(),A.dispatch(`focusSession`,null))}function mF(e){V&&O.has(e)&&(rw(e),sa(e),e!==W()&&(pF(),B=null,A.dispatch(`focusSession`,e),U=e,G()))}function hF(){if(!ON||!kN||!AN)return;let e=W(),t=!!B||!!(e&&O.has(e)),n=O.size>0;na(ON,t),z&&na(z.element,!t),Lk(ON,!n),na(kN,!n),na(AN,!n),!t&&n&&(Bi(kN,`No session selected`),Bi(AN,`Select a session from the rail on the left to focus it here.`))}function gF(e,t){NN.set(D(e),typeof t==`string`&&t?t:`none`),V&&G()}var _F={placement:`overlay`,sessionId:()=>V&&hN&&!B?W():null,elementFor:()=>{if(!hN)throw Error(`Focus view is not mounted`);return hN},didShow:()=>{},didHide:()=>{let e=W();e&&eF(O.get(e),e)}};function vF(e=null){let t=W();t&&fM(`changes`,t,e)}function yF(e){V&&O.has(e)&&mF(e)}function bF(e){return!V||!O.has(e)?!1:(mF(e),Xx(e))}function xF(e){if(!V)return;let t=HN()[e-1];t&&ra(t)&&MP(t)}function SF(e){if(!V)return;let t=HN().filter(e=>e===U||ra(e)),n=_r(t,U,e);n!=null&&ra(n)&&(PP(n),H.get(n)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=W();V&&e&&rw(e)});function CF(){fN&&(V=!0,lM(_F),pF(),U=null,G(),jN&&MN?$P(MN):jN&&XP().length>0?QP():(jN&&pN&&GA(pN),TF()))}function wF(e,t=null){jN=!0,MN=t;try{e()}finally{jN=!1,MN=null}}function TF(){if(!V||W()||B)return;let e=Zi();e&&mF(e)}function EF(){V&&=(pF(),uM(_F),U=null,!1)}var DF=200;function OF(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function kF(e){return/^#settings(?:[/?]|$)/.test(e)}function AF(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function jF(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,DF).join(``).trim()}}function MF(e,t,n){let r=T(`a`,`settings-link`,n);return r.href=OF(e,t),r}var NF={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},PF=[{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`}],FF=null,IF=null,LF=null,RF=()=>!1,zF=new Set,BF=new Set,VF=_t({getAck:wi,setAck:Br,signature:()=>ct({posthog:FF}),isLooking:()=>RF()});function HF(e){for(let t of BF)t(e)}function UF(){IF?.(VF.refresh())}function WF(){return{latest:FF,archivedLocally:zF,traceOpener:LF}}function GF(e){BF.add(e)}function KF(e){RF=e,UF()}function qF(e){zF.add(e)}function JF(){VF.acknowledge(),UF()}function YF(e){IF=e,UF()}function XF(e){LF=e}function ZF(e){FF=e,dt(FF,zF),HF({kind:`status`}),UF()}function QF(e){let t=Re(FF,e.projectId,e.issueId)?.inFlight===!0;it(FF,e)&&HF({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function $F(e){let t=xe(FF,e);HF({kind:`investigation-finished`,frame:e,isPatched:t}),t&&UF()}var eI=null,tI=[],nI=()=>!1,rI=null,iI=ki(),aI=bi(),oI=new Set(aI.split(`|`).filter(Boolean)),sI=new Set;function cI(e){for(let t of sI)t(e)}function lI(){return yg(tI).map(vg)}function uI(e){e!==iI&&(iI=e,Qr(e))}function dI(e){e!==aI&&(aI=e,oI=new Set(e.split(`|`).filter(Boolean)),Kr(e))}function fI(){if(!eI)return;let e=jg({turnEntries:lI(),acknowledged:iI,unseen:aI,isLooking:nI()});uI(e.acknowledged),dI(e.unseen),rI?.(e.isShown)}function pI(e){sI.add(e)}function mI(){return eI}function hI(){return tI}function gI(e){nI=e,fI()}function _I(e){rI=e,fI()}function vI(){eI&&(uI(ft(lI())),fI())}function yI(){return aI}function bI(e){return oI.has(e)}function xI(e){return oI.has(e)?(dI(ft([...oI].filter(t=>t!==e))),!0):!1}function SI(e){let t=Le.safeParse(e);t.success?(eI=t.data,tI=_g(t.data.entries),fI(),cI({kind:`status`})):y(`community`,`dropped community-status: ${r(t.error.issues)}`)}function CI(e){cI({kind:`connection`,isConnected:e})}function wI({source:e,className:t,title:n,allowsScripts:r}){let i=T(`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 TI=`panel-action`,EI=524288,DI=[`key`,`prKey`,`repo`,`number`,`action`,`actionId`,`itemKey`,`fingerprint`],OI=900;function kI(e){let t=ue.options.find(t=>t.shape.type.value===e);return new Set(Object.keys(t?.shape??{}).filter(e=>e!==`type`&&e!==`requestId`))}function AI(e){return e.map(e=>`${e.path.map(String).join(`.`)||`request`}: ${e.message}`).join(`; `)}function jI(e,t){let n=ve.safeParse(t);if(!n.success)return{ok:!1,error:`not sent: ${AI(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=ue.safeParse({...n.data,requestId:TI});if(!r.success)return{ok:!1,error:`${n.data.type} not sent: ${AI(r.error.issues)}`};let i=kI(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 ${EI} byte limit`}:{ok:!0,type:r.data.type,payload:a}}function MI(e,t,n){return`${e} sent ${t} ${DI.flatMap(e=>{let t=n[e];return typeof t==`string`||typeof t==`number`?[`${e}=${t}`]:[]}).join(` `)}`.trim().slice(0,OI)}var NI=`[^/\\\\\\s"'\`<>:]+`,PI=RegExp(`(?<![\\w./\\\\-])(?:/home/${NI}|/Users/${NI}|[A-Za-z]:[\\\\/]Users[\\\\/]${NI}|/root(?![\\w.-]))`,`g`);function FI(e){return e.replace(PI,`~`)}function II(e){return FI(ul(e))}var LI=1e3,RI=12e4,zI=new Map,BI=null;function VI(e){return hl()?II(e):e}var HI={sessions:()=>({sessions:[...O].map(([e,t])=>({id:e,name:VI(ar(t)),agent:t.agent??null,state:t.currentState,stateSinceMs:t.stateSince,taskTitle:t.taskTitle===null?null:VI(t.taskTitle)}))}),focus:()=>({sessionId:A.snapshot().focusedSessionId,view:A.snapshot().activeView,isStreamerMode:hl()}),theme:()=>_o(),usage:()=>({planLimits:Object.entries(KD().planLimitsByVendor).flatMap(([e,t])=>t===null||e!==`claude`&&e!==`codex`&&e!==`kimi`?[]:[{vendor:e,fiveHour:Ew(t,`fiveHour`),sevenDay:Ew(t,`sevenDay`)}])}),attention:()=>{let e=pr([...O.values()].map(e=>({state:e.currentState,unseenOutcome:e.unseenOutcome??null})));return{waiting:e.waitingCount,finished:e.finishedCount,failed:e.failedCount}},reviews:()=>j_()};function UI(e,t){e.frame.contentWindow?.postMessage(t,`*`)}function WI(e,t){let n=t.get(e);if(n)return n;let r=HI[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}=WI(t,n);e.lastSentJsonByTopic.get(t)!==i&&(e.lastSentJsonByTopic.set(t,i),UI(e,Te.parse({v:1,kind:`topic`,topic:t,data:r})))}function KI(){let e=!1,t=new Map;for(let n of zI.values()){for(let e of n.subscribedTopics)GI(n,e,t);e||=n.subscribedTopics.size>0}e||BI===null||(clearInterval(BI),BI=null)}var qI=new Map;async function JI(e,t){let n=await c(e,t).catch(e=>Wn(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 YI(e,t){UI(e,{v:1,kind:`store`,data:qI.get(e.packName)??{},error:t})}async function XI(e){let t=await JI(`pack-data-get`,{pack:e.packName});t.ok&&qI.set(e.packName,t.data),YI(e,t.ok?null:t.error)}async function ZI(e,t,n){let r=Ae(e.packName,Ce(qI.get(e.packName)??{},t,n));if(r!==null){YI(e,r);return}let i=await JI(`pack-data-set`,{pack:e.packName,key:t,value:n});if(!i.ok)YI(e,i.error);else{qI.set(e.packName,i.data);for(let t of zI.values())t.packName===e.packName&&YI(t,null)}}function QI(e,t){e.subscribedTopics=new Set(t.filter(t=>e.grantedTopics.has(t))),e.lastSentJsonByTopic.clear(),UI(e,{v:1,kind:`hello`,granted:[...e.subscribedTopics]}),XI(e);for(let t of e.subscribedTopics)GI(e,t);BI??=setInterval(KI,LI)}function $I(e,t,n,r,i=!1){UI(e,{v:1,kind:`action-result`,id:t,ok:r===null,timedOut:i,result:n,error:r})}function eL(e,t){return t.ok===!1?typeof t.error==`string`&&t.error!==``?t.error:`${e} was refused`:null}async function tL(e,t,n){let r=jI(e.acts,n);if(!r.ok){$I(e,t,null,r.error);return}s({type:`client-log`,scope:`packs`,text:MI(e.viewId,r.type,r.payload)});let i=await c(r.type,r.payload,{timeoutMs:RI}).catch(e=>Wn(e));if(i===`Request timed out`){$I(e,t,null,`${r.type} got no answer within ${RI/1e3} s; it may still run, so check before sending it again`,!0);return}if(typeof i==`string`){$I(e,t,null,`${r.type} failed: ${i}`);return}let a={...i};$I(e,t,a,eL(r.type,a))}function nL(e){let t=[...zI.values()].find(t=>t.frame.contentWindow!==null&&t.frame.contentWindow===e.source);if(!t)return;let n=De.safeParse(e.data);if(n.success){tL(t,n.data.id,n.data.request);return}let r=be.safeParse(e.data);r.success&&(r.data.kind===`store-set`?ZI(t,r.data.key,r.data.value):r.data.kind===`subscribe`&&QI(t,r.data.topics))}function rL(e,t,n){zI.size===0&&window.addEventListener(`message`,nL),zI.set(e,{viewId:e,frame:t,packName:n.pack,acts:n.acts,grantedTopics:new Set(n.reads),subscribedTopics:new Set,lastSentJsonByTopic:new Map})}var iL=null,aL=new Set;function oL(){return iL}function sL(e){return aL.add(e),()=>aL.delete(e)}function cL(e){let t=we.safeParse(e);if(!t.success)y(`settings`,`dropped packs-status: ${r(t.error.issues)}`);else{iL=t.data,uo(t.data.themes)&&yo();for(let e of aL)e()}}var lL=`about:blank`,uL={pack:``,reads:[],acts:[]},dL=new Map,fL=new Map;function pL(e){let t=T(`img`,`pack-tab-icon`);return t.src=e,t.alt=``,t.decoding=`async`,t.referrerPolicy=`no-referrer`,t}function mL(e){return fL.set(e.viewId,e),{mount(t){let n=fL.get(e.viewId);t.replaceChildren(hL(e.viewId,n?.entryUrl??lL,e.label,n??uL))}}}function hL(e,t,n,r){let i=wI({source:{kind:`url`,url:t},className:`pack-panel-frame`,title:n,allowsScripts:!0});return dL.set(e,i),rL(e,i,r),i}function gL(e,t,n,r){let i=dL.get(e);i&&i.getAttribute(`src`)!==t&&i.replaceWith(hL(e,t,n,r))}function _L(e){fL.set(e.viewId,e),gL(e.viewId,e.entryUrl,e.label,e)}function vL(e){fL.delete(e),gL(e,lL,dL.get(e)?.title??``,uL)}function yL(e){let t=()=>e(oL()?.panels??[]);sL(t),t()}var bL=`glimmervoid:preload-error-reload-at`,xL=3e4,SL=1e3,CL=$n();function wL(e,t){let n=CL.mountedModuleOf(e.view);n?t(n):CL.show(e).then(t).catch(t=>{throw y(`view`,`${e.view} failed to show: ${l(t)}`),t})}function TL(e){return CL.mountedModuleOf(e)}function EL(e){CL.mountEagerViews(e)}function DL(e){let t=()=>{CL.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,SL)}function OL(e){let t=Date.now();nr(e.getItem(bL),t,xL)&&(e.setItem(bL,String(t)),location.reload())}function kL(e){window.addEventListener(`vite:preloadError`,()=>OL(e()))}function AL(e,t){fetch(e,{method:`HEAD`,cache:`no-store`}).then(e=>{e.status===404&&OL(t())}).catch(()=>{})}function jL(e,t,n){let r=w(document,`#app-main`,`main`),i=Ve(`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)??T(`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=T(`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}=br(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 ML(e){return e.iconUrl?pL(e.iconUrl):Ee(Ue)}function NL(e){return jL({view:e.viewId,label:e.label,iconPath:``,panelClass:`pack-panel-view`,hasPanelChrome:!1,module:mL(e)},ML(e),()=>{})}function PL(e,t){e.tab.replaceChildren(ML(t),t.label)}function FL(e){S_({openTerminal:e.openTerminal,openReviews:e.openReviews}),iA({openTerminal:e.openTerminal}),jj(e.onRestart),AO(e.openReviewFile);let t=[{view:`focus`,label:`Focus`,iconPath:rt,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,refreshOn:[`connected`],module:{mount:()=>YN({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:CF,deactivate:EF,refresh:dF}},{view:`prs`,label:`Reviews`,iconPath:je,panelClass:`pr-view`,gate:{fromSettings:NF.teamReview},load:()=>j(()=>import(`./review-queue-panel-DAk2WHrm.js`).then(e=>e.view),__vite__mapDeps([39,40,14,13,4,3,12,33,41,15,42,30,27,21,24,28,5,6,7,20,31,23,32,29,43,36,44])),refreshOn:[`shown`],attention:{subscribe:v_,acknowledge:__},onConnectionChange:e=>{Ph(e),Xg(e)}},{view:`issues`,label:`Issues`,iconPath:Be,panelClass:`issues-view`,gate:{fromSettings:NF.issues},load:()=>j(()=>import(`./issues-panel-I6N9hEcg.js`).then(e=>e.view),__vite__mapDeps([45,13,4,3,12,14,33,42,30,27,15,21,24,28,5,6,7,20,31,23,32,29,43,16,46])),refreshOn:[`shown`],onConnectionChange:$p},{view:`usage`,label:`Usage`,iconPath:me,panelClass:`usage-view`,gate:{fromSettings:NF.usage},load:()=>j(()=>import(`./usage-panel-CuIScVal.js`).then(e=>e.view),__vite__mapDeps([47,3,4,13,48,49])),attention:{subscribe:ZD,acknowledge:XD},onConnectionChange:rO,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,iconPath:mt,panelClass:`radar-view`,gate:{fromSettings:NF.posthog},load:()=>j(()=>import(`./radar-panel-U8kArKZ3.js`).then(e=>e.view),__vite__mapDeps([50,13,4,3,48,51,12,14,35,27,15,21,24,28,5,6,7,20,32,29,52])),attention:{subscribe:YF,acknowledge:JF}},{view:`community`,label:`Community`,iconPath:Ge,panelClass:`community-view`,gate:{fromSettings:NF.community},load:()=>j(()=>import(`./community-panel-oPNEjWVB.js`).then(e=>e.view),__vite__mapDeps([53,13,4,3,40,14,12,33,41,43,5,6,7,21,15,36,54])),refreshOn:[`shown`],attention:{subscribe:_I,acknowledge:vI},onConnectionChange:CI},{view:`boards`,label:`Boards`,iconPath:Ue,isPhoneNavScreen:!0,isPhoneOnly:!0,panelClass:`boards-screen`,hasPanelChrome:!1,load:()=>j(()=>import(`./boards-view-DIh7lkLS.js`).then(e=>e.view),__vite__mapDeps([37,3,4,17,13,12,14,31,23,15,21,29,16,38])),refreshOn:[`shown`,`connected`]},{view:`hooks`,label:`Hooks`,iconPath:Ke,panelClass:`hooks-view`,load:()=>j(()=>import(`./hooks-panel-leiYaWxz.js`).then(e=>e.view),__vite__mapDeps([55,14,13,4,3,12,15,56])),refreshOn:[`shown`,`connected`,`hooks-updated`]},{view:`trace`,label:`Trace`,iconPath:Me,panelClass:`trace-view`,gate:{subscribe:xb},load:()=>j(()=>import(`./trace-panel-CHusMzMn.js`).then(e=>e.view),__vite__mapDeps([57,3,4,13,12,14,5,6,7,58])),refreshOn:[`shown`],onAvailabilityChange:e=>XF(e?vC:null),onConnectionChange:CC},{view:`benchmarks`,label:`Arena`,iconPath:ot,panelClass:`bench-view`,load:()=>j(()=>import(`./arena-panel-azL51Ses.js`).then(e=>e.view),__vite__mapDeps([59,13,4,3,14,21,29,15,28,60])),onConnectionChange:Da},{view:`settings`,label:`Settings`,iconPath:fe,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>j(()=>import(`./settings-panel-CMQPJBaI.js`).then(e=>e.view),__vite__mapDeps([61,3,4,5,6,7,2,1,8,62,13,10,51,12,14,35,27,15,21,24,28,20,32,29,42,30,31,23,33,44,63]))}].map(t=>jL(t,Ee(t.iconPath),e.setPhoneAttention));return w(document,`#header-tabs`,`div`).replaceChildren(...t.map(e=>e.tab)),t}function IL(e){return e===`remote`?`remote`:`local`}function LL(e,t){return IL(t)===`local`||e!==`shutdown`}var RL=!1,zL=new Set;function BL({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){let o=RC(),c=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;$t({title:t,message:c,confirmLabel:n,danger:r||o>0,onConfirm:()=>s({type:e})})}function VL(){BL({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function HL(){BL({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})}function UL(e){RL=LL(`shutdown`,e);for(let e of zL)e.isConnected?e.hidden=!RL:zL.delete(e)}function WL(e){e.hidden=!RL,zL.add(e)}function GL(e){e&&Fj(e),_k(`settings`)||q(`settings`,{section:e})}function KL(e){_k(e)||q(e)}function qL(){_k(`boards`)||(q(`focus`),fF())}function JL(){kF(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}var K=FL({onRestart:VL,openTerminal:e=>{gk(e)||(q(`focus`),yF(e))},openPlan:e=>{q(`focus`),bF(e)},openReviewFile:(e,t)=>{LC(e)&&(gk(e)||(q(`focus`),yF(e),vF(t)))},openReviews:()=>QL(`prs`)?(_k(`prs`)||q(`prs`),!0):!1,setPhoneAttention:dk});function YL(){return K.map(e=>e.view)}var XL=YL();function ZL(e){return K.find(t=>t.view===e)}function QL(e){return K.some(t=>t.view===e&&!t.tab.hidden)}var $L=!0,eR=null;function tR(e){ZL(e)?.attention?.acknowledge()}var nR=null;function rR(e){nR=s({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function iR(){nR&&rR(nR)}function aR(e){let t=ZL(e);t&&(wL(t,e=>Zn(t,e,`shown`)),rR(e))}function oR(e){Qn(K,{isPhoneShellActive:sk(),activeView:xr(),phoneScreen:A.snapshot().phoneScreen},e,TL)}function q(e,{section:t,setting:n,persist:r=!0}={}){let i=ZL(e);if(!i||!QL(e))return;let a=xr();A.dispatch(`setActiveView`,e),$L=r,r&&(eR=null),document.body.dataset.activeView=e,r&&Xr(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&&TL(a)?.deactivate?.(),wL(i,r=>{xr()===e&&(r.activate?.(),Zn(i,r,`shown`),e===`settings`&&t&&Fj(t,n??null))}),rR(e),a===`settings`&&e!==`settings`&&JL(),tR(e)}function sR(e,t){let{view:n}=e;e.tab.hidden=!t,uk(n,t),e.onAvailabilityChange?.(t),sk()||(!t&&xr()===n&&q(`focus`),t&&eR===n&&q(n))}function cR(e){for(let{view:t,isAvailable:n}of qn(K,e))sR(t,n)}var lR;function uR(e){lR=e;let t=Xn(XL,e);K.every((e,n)=>e.view===t[n])||(K.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),w(document,`#header-tabs`,`div`).append(...K.map(e=>e.tab)),lk(t))}function dR(){return K.filter(e=>!e.tab.hidden)}function fR(e,t){let n=e[t];return q(n.view),n.tab}function pR(e,t){let n=dR(),r=n.findIndex(t=>t.view===e);return fR(n,pa(r,t,n.length))}function mR(e){K.some(e=>e.tab===document.activeElement)&&e.focus()}var hR=null;function gR(e){let t=YL();uR(e),c(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&uR(t)}).catch(()=>uR(t))}function _R(e){let t=hR;if(hR=null,!t||t===e)return;let n=YL();gR(tr(n,t,n.indexOf(e)))}function vR({view:e,tab:t}){t.addEventListener(`click`,()=>q(e)),t.addEventListener(`dragstart`,t=>{hR=e,t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),t.addEventListener(`dragover`,n=>{hR&&hR!==e&&(n.preventDefault(),t.dataset.dropTarget=`true`)}),t.addEventListener(`dragleave`,()=>delete t.dataset.dropTarget),t.addEventListener(`drop`,n=>{n.preventDefault(),delete t.dataset.dropTarget,_R(e)}),t.addEventListener(`dragend`,()=>{hR=null}),t.addEventListener(`keydown`,e=>{if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=dR(),n=t.findIndex(e=>e.view===xr()),r=ma(e.key,n,t.length,`horizontal`);r!==null&&(e.preventDefault(),fR(t,r).focus())})}var yR=`pack:`,bR=new Map;function xR(e){let t=NL(e);return K.push(t),XL.push(t.view),w(document,`#header-tabs`,`div`).append(t.tab),vR(t),t}function SR(e){let t=new Set(e.map(e=>e.viewId));for(let e of K)e.view.startsWith(yR)&&!t.has(e.view)&&(vL(e.view),sR(e,!1));for(let t of e){let e=ZL(t.viewId)??xR(t),n=bR.get(t.viewId);n&&(n.label!==t.label||n.iconUrl!==t.iconUrl)&&PL(e,t),bR.set(t.viewId,t),_L(t),sR(e,!0)}uR(lR)}function CR(){let e=Ai(),t=kF(location.hash),n=Hb(location.hash);if(t&&(Fj(null,null,location.hash),q(`settings`,{persist:!1})),n&&q(`focus`,{persist:!1}),t||n)return;let r=QL(e);r||(eR=e),q(r?e:`focus`,{persist:r})}function wR(){let e=xr();q(QL(e)?e:`focus`,{persist:$L})}function TR(){Nj(K),EL(K);for(let e of K)e.gate&&(sR(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>sR(e,t)));_C(()=>{QL(`trace`)&&(_k(`trace`)||q(`trace`))});for(let e of K)vR(e);CR(),yL(SR)}function ER(e){return kF(e)?(Fj(null,null,e),_k(`settings`)||q(`settings`,{persist:!1}),!0):!1}var DR=`No plan is stored for this session yet. It appears here once the agent writes one.`,OR=`Plan`;function kR(e){let t=Hb(e);return t?!LC(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),sk()?(hk(t)||Tr({source:OR,sessionId:t,message:DR}),!0):(q(`focus`,{persist:!1}),bF(t)||Tr({source:OR,sessionId:t,message:DR}),!0)):!1}function AR(e){return kR(e)?!0:ER(e)}function jR(e){e.newURL===location.href&&AR(location.hash)}function MR(){document.addEventListener(`click`,e=>{if(!sk()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&AR(t.hash)&&e.preventDefault()}),window.addEventListener(`hashchange`,jR)}var NR=null,PR=new Set;function FR(){NR?.setState(xi()?`idle`:`off`)}function IR(e){Ei(e),FR();for(let t of PR)t(e)}function LR(e){PR.add(e)}function RR(e){NR=e,FR(),e.element.addEventListener(`click`,()=>IR(!xi()))}var zR=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,BR=[`title`,`label`],VR=new WeakMap,HR=new WeakMap,UR=null;function WR(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(zR)!==null}function GR(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function KR(e,t){if(t&&e===t.masked)return t;let n=II(e);return n===e?null:{original:e,masked:n}}function qR(e){let t=GR(e)?null:KR(e.data,VR.get(e));t?(VR.set(e,t),e.data!==t.masked&&(e.data=t.masked)):VR.delete(e)}function JR(e,t){let n=e.getAttribute(t),r=HR.get(e),i=n===null?null:KR(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),HR.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function YR(e){for(let t of BR)JR(e,t)}function XR(e){return e instanceof Element&&e.matches(zR)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function ZR(e){YR(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,XR);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&qR(e),e instanceof Element&&YR(e)}function QR(e){WR(e)||(e instanceof Text&&qR(e),e instanceof Element&&ZR(e))}function $R(e){e instanceof Element&&!WR(e)&&YR(e)}function ez(e){let t=new Set,n=new Set;for(let r of e){if(r.type===`childList`)for(let e of r.addedNodes)t.add(e);r.type===`characterData`&&t.add(r.target),r.type===`attributes`&&n.add(r.target)}for(let e of t)e.isConnected&&QR(e);for(let e of n)e.isConnected&&$R(e)}function tz(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);nz(e);for(let e=t.nextNode();e;e=t.nextNode())nz(e)}function nz(e){if(e instanceof Text){let t=VR.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=HR.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function rz(){if(UR)return;let e=new MutationObserver(t=>{ez(t),e.takeRecords()});ZR(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:BR}),UR=e}function iz(){UR&&(UR.disconnect(),UR=null,tz(document.body),VR=new WeakMap,HR=new WeakMap)}function az(e){e?rz():iz()}function oz(){az(hl()),_l(az)}var sz=Xe({label:`Play queued merge celebrations`,icon:Ee(ge,`1.6`),action:`play-celebrations`,states:[`idle`,`attention`]}),cz=C({variant:`primary`,label:`Session`,icon:Ee(He),action:`add-session`,onClick:oa});cz.id=`btn-add-session-header`;var lz=Xe({label:`Keyboard shortcuts and version`,icon:Ee(Je,`1.6`),action:`open-shortcuts-help`,onClick:()=>GL(`browser-shortcuts`),states:[`idle`]}).element,uz=Xe({label:`Mute alerts`,icon:Ee(gt,`1.6`),action:`toggle-mute`,states:[`idle`,`off`]}),dz=uz.element,fz=C({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-header-status`});fz.id=`header-status-dismiss`;var pz=w(document,`#celebration-tray`,`div`);pz.prepend(sz.element),w(document,`.header-right`,`div`).append(cz,lz,dz),w(document,`#header-status`,`p`).append(fz);function mz(){RR(uz),oz(),Wt(document.querySelector(`.header`))}function hz(){vm(pz,sz,w(document,`#celebration-tray-count`,`span`))}function gz(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 _z(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 vz(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function yz(e,t){return t||vz(e)?!1:_z(e)}var bz=C({variant:`primary`,size:`small`,label:`Restart`,action:`restart-to-update`,hidden:!0}),xz=C({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-update-command`}),Sz=C({variant:`icon`,size:`small`,label:`Dismiss update notice`,icon:Ee(ut),action:`dismiss-update-banner`});w(document,`#update-banner-cmd`,`code`).before(bz),w(document,`#update-banner-copy-status`,`span`).before(xz),w(document,`#update-banner`,`div`).append(Sz);var Cz=C({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-leftovers-command`}),wz=C({variant:`icon`,size:`small`,label:`Dismiss old report notice`,icon:Ee(ut),action:`dismiss-leftovers-banner`});w(document,`#post-turn-leftovers-copy-status`,`span`).before(Cz),w(document,`#post-turn-leftovers-banner`,`div`).append(wz);var Tz,Ez=null;function Dz(e,t,n){e.onclick=()=>{let e=It(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var Oz=MF(Se,ye,`Update`).href;function kz(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function Az(e){let t=w(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=Fe(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=kz(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===Ez||!a&&Tz!==void 0&&s===Tz||!a&&s&&li()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);w(document,`#update-banner-text`,`span`).textContent=i,w(document,`#update-banner-cmd`,`code`).textContent=c;let l=w(document,`#update-banner-update`,`a`);l.href=Oz,l.hidden=n!==`link`,bz.hidden=n!==`restart`,bz.onclick=VL;let u=w(document,`#update-banner-cmd`,`code`);u.hidden=n!==`command`,xz.hidden=n!==`command`;let d=w(document,`#update-banner-copy-status`,`span`);d.hidden=n!==`command`,d.textContent=``;let f=w(document,`#update-banner-link`,`a`);f.hidden=!e.releaseUrl,f.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,Dz(xz,d,c),Sz.onclick=()=>{t.hidden=!0,a?Ez=i:(Tz=s,Yr(s))}}var jz=!1;function Mz({repositories:e,command:t}){let n=w(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(jz)return;let r=w(document,`#post-turn-leftovers-copy-status`,`span`);w(document,`#post-turn-leftovers-text`,`span`).textContent=gz(e.length),w(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,Dz(Cz,r,t),wz.onclick=()=>{jz=!0,n.hidden=!0}}var Nz=w(document,`#telemetry-banner`,`div`),Pz=C({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-telemetry-banner`});Nz.append(Pz);function Fz(){Ci(!0),Nz.hidden=!0}function Iz(e){Nz.hidden=!yz(e,Vr())}function Lz(){let e=w(document,`#telemetry-banner-settings`,`a`);e.href=MF(`privacy`,`telemetry-enabled`,`What's collected`).href,e.addEventListener(`click`,Fz),Pz.addEventListener(`click`,Fz)}function Rz(e){j(()=>import(`./feature-hint-DYaAH_FS.js`).then(t=>t.showFeatureHint(e,{isFeatureEnabled:e=>QL(Ie[e]),openView:KL,openSetting:(e,t)=>ER(OF(e,t))}),e=>y(`feature-hint`,`hint card failed to load: ${l(e)}`)),__vite__mapDeps([64,13,4,3,62,5,6,7,8,14,65]))}function zz(){j(()=>import(`./feature-hint-DYaAH_FS.js`).then(e=>e.showStarHint(),e=>y(`star-hint`,`star card failed to load: ${l(e)}`)),__vite__mapDeps([64,13,4,3,62,5,6,7,8,14,65]))}var Bz=2500;function Vz({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}function Hz(e){ho(e.isExperimentalBuild===!0&&Ur()),zC(e),Hj(e),cR(e),Iz(e),uR(e.viewTabOrder),gl(e.streamerMode===!0)}var Uz=Object.freeze({top:[0,1],right:[-1,0],bottom:[0,-1],left:[1,0]}),Wz=160,Gz=950,Kz=900,qz=980,Jz=450,Yz=720,Xz=260,Zz=`cubic-bezier(0.22, 1, 0.36, 1)`,Qz=`cubic-bezier(0.2, 0.8, 0.3, 1)`,$z=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),eB=e=>new Promise(t=>{setTimeout(t,e)});function tB(e){return e!==void 0&&Object.hasOwn(Uz,e)}function nB(e){return[...e.querySelectorAll(`[data-side]`)].flatMap(e=>{let t=e instanceof SVGElement?e.dataset.side:void 0;if(!(e instanceof SVGElement)||!tB(t))return[];let[n,r]=Uz[t];return[{bracket:e,dx:n,dy:r}]})}function rB(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:Kl}],{duration:Wz,easing:`ease-out`})}}function iB(e){e.animate([{transform:`rotate(0deg)`,easing:`cubic-bezier(0.5, 0, 0.15, 1)`},{transform:`rotate(360deg)`,offset:.86,easing:Qz},{transform:`rotate(354deg)`,offset:.93,easing:Qz},{transform:`rotate(360deg)`}],{duration:Gz})}function aB(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:Kz,easing:`cubic-bezier(0.2, 0.9, 0.3, 1)`})}}function oB(e,t){e.animate([{transform:`scale(0)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:qz,easing:Zz,fill:`forwards`}),t.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`})}function sB(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:Yz,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:Yz,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 cB({mark:e,dial:t,light:n,halo:r}){return $z?.matches||document.hidden?Promise.resolve():(iB(t),aB(nB(e)),n.animate([{transform:`scale(1)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:qz,easing:Zz}),r.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`}),eB(qz))}async function lB(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($z?.matches||document.hidden||!(t instanceof SVGElement)||!n||!r||!i)return;let a=nB(t);rB(a),e.dataset.unlock=`spin`,await eB(Wz),iB(n),aB(a),oB(r,i),await eB(qz),e.dataset.unlock=`lit`,await eB(Jz),e.dataset.unlock=`burst`,sB(a,r,i),await eB(Xz)}var uB=w(document,`#connection-status`,`span`),dB=w(uB,`.connection-label`,`span`),fB=w(document,`#loading-screen`,`div`),pB=w(document,`#loading-status`,`div`),mB=w(document,`#loading-detail`,`div`),hB=w(document,`#shutdown-screen`,`div`),gB=w(document,`#shutdown-status`,`div`),_B=!1,vB=null,yB=!1;function bB(){_B||vB===null||Vz({hasSnapshot:yB,connectingTerminalCount:mu(),msSinceConnected:performance.now()-vB})===`reveal`&&SB()}function xB(){yB=!0,bB()}function SB(){_B||(_B=!0,DL(K),_p(),zk(),lB(fB).then(CB,CB))}function CB(){fB.classList.add(`fade-out`);let e=()=>fB.remove();fB.addEventListener(`transitionend`,t=>{t.target===fB&&e()}),setTimeout(e,1e3)}function wB(e,t){uB.dataset.state=`shutdown`,dB.textContent=e,gB.textContent=t,hB.classList.add(`active`)}var TB=new Set([`disconnected`,`connecting`]);function EB(e,t,n){uB.dataset.state=e,uB.toggleAttribute(`data-reconnected`,n),dB.textContent=t}function DB(e,t){EB(e,t,e===`connected`&&TB.has(uB.dataset.state??``))}function OB(e,t){uB.dataset.state!==`shutdown`&&EB(e===`verified`?`connected`:e,t,!1)}var kB=1e4,AB=`Server`,jB=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,MB=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,NB=null,PB=!1;function FB(){pB.textContent=`Reconnecting to server...`,mB.textContent=MB,mB.hidden=!PB}function IB(){NB=null,PB=!0,_B?Tr({source:AB,message:jB,hidesInStreamerMode:!1}):FB()}function LB(){NB!==null||PB||(NB=window.setTimeout(IB,kB))}function RB(){NB!==null&&window.clearTimeout(NB),NB=null,PB=!1,mB.hidden=!0,wr(AB)}function zB(){RB(),AL(import.meta.url,()=>window.sessionStorage),iR(),hB.classList.contains(`active`)?location.reload():(Rk(),document.body.classList.add(`app-ready`),!_B&&vB===null&&(vB=performance.now(),pB.textContent=`Connecting to sessions...`,setTimeout(SB,Bz)),bB(),oR(`connected`),c(`get-settings`,{}).then(e=>{e.settings&&(Hz(e.settings),xr()===`settings`&&ER(location.hash))}).catch(()=>{}))}function BB(e,t){if(e===`connecting`||e===`verified`)OB(e,t);else{DB(e,t),nS(e===`connected`);for(let t of K)t.onConnectionChange?.(e===`connected`);e===`connected`?zB():e===`disconnected`&&hB.classList.contains(`active`)?gB.textContent=`Waiting for server...`:(LB(),_B||FB())}}function VB(){pu(bB),h(BB)}var HB=14,UB=Object.freeze({idle:ql,failed:`#ef4444`,waiting:`#f59e0b`});function WB({waitingCount:e,failedCount:t}){return e>0?`waiting`:t>0?`failed`:`idle`}function GB(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)">${Jl({frame:Kl,light:UB[e],strokeWidth:HB})}</g></svg>`}function KB(){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 qB=KB(),JB=`idle`;function YB(e){let t=WB(e);t!==JB&&(JB=t,qB.href=`data:image/svg+xml,${encodeURIComponent(GB(t))}`)}function XB(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 ZB(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 QB(){Qp(),Ah(),fk()}function $B(){G(),QB()}function eV(){Ui(e=>{G(e),QB()})}var tV=null;function nV(e){let t=XB(tV,e);tV=t.knownBuild,t.reload&&location.reload()}function rV(e){Er(e),ew(e),Ba(e),ub(e),W_(e),wn(e),Cn(e),dc(e)}function iV(e){for(let t of fc(e))rV(t)}function aV(e,t){let n=new Set(e.map(e=>e.id));for(let e of[...O.keys()])lc(e)===t&&(n.has(e)||rV(e))}function oV(e,t=null){if(t)for(let n of e)uc(n.id,t);aV(e,t),t||Gj(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)LC(t.id)&&cV(t),LC(t.id)||UC(t.id,t.name,t.state,ZB(t)),za(t.id,t.coherenceHooks),U_(t.id,t.linkedPrs),xn(t.id,t.failureReason),Hn(t.id,t.attentionNotes),IC(t.id,t.taskTitle,t.taskTitleIsCustom),GC(t.id,t.agent),QC(t.id,t.mergeStatus,t.mergeReason),WC(t.id,t.effectiveBase),qC(t.id,t.activeAgents,t.awaitingBackgroundTasks),JC(t.id,t.pendingPromptKind),YC(t.id,t.unseenOutcome),yn(t.id,t.auditLog,t.managerSeenSeq),Zx(t.id,t.hasPlan);HC(),YB(hr.counts),G(),TF(),QB(),uV(),kR(location.hash),vk(),xB()}function sV(e,t){let n=e.dataset.skipPerms!==void 0;return(e.dataset.path??``)!==t.path||n!==t.dangerouslySkipPermissions}function cV(e){let t=O.get(e.id)?.card;t&&sV(t,e)?lV(e.id,e.name,e.state,e,e.linkedPrs):(iw(e.id,e.state,e.stateSince),On(e.id,!!e.saneYolo),an(e.id,e.isQuestionManagerOn),t&&t.dataset.session!==e.name&&$C(e.id,e.name),KC(e.id,e.isWorktree))}function lV(e,t,n,r,i){let a=O.get(e),o=ta()===e;za(e,null),ew(e),ub(e),wn(e),Cn(e),U_(e,i),UC(e,t,n,ZB(r)),o&&Ki(e),dV(e,a)}function uV(){yC([...O].map(([e,t])=>({id:e,name:ar(t)||e})))}function dV(e,t){Zx(e,t?.hasPlan===!0),YC(e,t?.unseenOutcome)}var fV=new Set([E.DONE,E.FAILED]);function pV(e,t){return e!==void 0&&fV.has(e)&&!fV.has(t)&&t!==E.DORMANT}function mV(e){let t=O.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;ew(e.id),UC(e.id,e.session,E.DORMANT,ZB({skipPerms:i,saneYolo:a,isQuestionManagerOn:e.isQuestionManagerOn??vn(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})),GC(e.id,t?.agent),dV(e.id,t)}function hV(e,t){let n=O.get(String(e.id))?.currentState;t.to===E.DORMANT&&n!==E.DORMANT?(mV(e),cb(e.id)):(iw(e.id,t.to,e.timestamp),xn(e.id,e.failureReason),e.saneYolo!==void 0&&On(e.id,e.saneYolo),cb(e.id),pV(n,t.to)&&Au(e.id))}function gV(e){if(LC(e.id))e.transition&&hV(e,e.transition),e.activeAgents!==void 0&&qC(e.id,e.activeAgents,e.awaitingBackgroundTasks),e.unseenOutcome!==void 0&&YC(e.id,e.unseenOutcome),e.pendingPromptKind!==void 0&&JC(e.id,e.pendingPromptKind),e.managerSeenSeq!==void 0&&zn(e.id,e.managerSeenSeq),e.attentionNotes!==void 0&&Hn(e.id,e.attentionNotes),e.isQuestionManagerOn!==void 0&&an(e.id,e.isQuestionManagerOn),e.unseenOutcome!==void 0&&HC(),YB(hr.counts),ca(e.id),Nb(e.id);else{if(!e.transition)return;UC(e.id,e.session,e.transition.to,ZB({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),YB(hr.counts),Qp()}}function _V(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 vV=`Secrets agents may read from your vault, per project. Revoking one makes the next request ask again.`,yV=null,bV=null;function xV(e,t){let n=T(`article`,`settings-view-setting`),r=T(`div`,`settings-view-setting-text`),i=T(`div`,`settings-view-setting-heading`);i.append(T(`h2`,`settings-view-setting-title`,t.name)),r.append(i,T(`p`,`settings-view-setting-description`,t.isAllowed?`Reads ${t.reference??`no reference yet`}`:`Denied`));let a=T(`div`,`settings-view-setting-control`);return a.append(C({variant:`secondary`,label:`Revoke`,action:`secret-revoke`,onClick:()=>{s({type:`secret-revoke`,project:e,name:t.name})}})),n.append(r,a),n}function SV(e){return[T(`h2`,`settings-view-subsection-title`,e.project),...e.approvals.map(t=>xV(e.project,t))]}function CV(){let e=T(`p`,`settings-view-section-description`,vV);return yV?yV.length===0?[e,T(`p`,`settings-view-setting-description`,`No approvals yet. An agent that runs glimmervoid need asks on its session card first.`)]:[e,...yV.flatMap(SV)]:[e,T(`p`,`settings-view-setting-description`,`Waiting for the server to list approvals.`)]}function wV(){bV?.isConnected&&bV.replaceChildren(...CV())}function TV(e){yV=e.projects,wV()}function EV(e){bV=T(`div`,`settings-view-stack`),e.appendChild(bV),wV()}var DV={"session-trace-response":e=>bC(e),"session-trace-changed":e=>xC(e),"session-plan-changed":e=>{Qx(e),QB()},"session-plan-draft":e=>{$x(e)},"session-plan-response":e=>{eS(e)},"session-docs-changed":e=>Zv(e),"session-docs-snapshot":e=>Qv(e),"session-secret-request":e=>zv(e),"secret-requests-snapshot":e=>Bv(e),"secret-approvals":e=>TV(e),"session-manager-decision":e=>{Rn(e.id,e.decision),$B()},"session-coherence-hooks":e=>{za(e.id,e.coherenceHooks),$B()},"session-coherence":e=>{Va(e),$B()},"session-coherence-snapshot":e=>{Ha(e),$B()},"session-coherence-journal-response":e=>qa(e)},OV={"team-review-status":e=>qg(e),"github-prs":e=>am(e),"my-prs-status":jh,"pr-flows-status":Mh,"packs-status":cL,"my-pr-merge-result":e=>Nh(e),"team-review-action-result":e=>Jg(e),"open-team-review-session-result":e=>Yg(e),"issues-status":e=>em(e),"issue-detail-result":e=>tm(e),"open-issue-session-result":e=>nm(e),"set-issue-state-result":e=>Wp(e)},kV={"radar-status":e=>ZF(e),"radar-investigation-activity":e=>QF(e),"radar-investigation-finished":e=>$F(e),"community-status":e=>SI(e),"benchmark-status":e=>Oa(e),"benchmark-action-result":e=>ka(e),"race-status":e=>Qk(e),"race-history":e=>eA(e),"usage-sessions":e=>iO(e),"usage-report":e=>{oO(e),Wj()},"plan-limits":e=>aO(e),"usage-budget-alert":e=>vx({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0})},AV=3e3,jV=null,MV=null,NV=Cr(`settings-hosts-status`);function PV(e){let t=e.hostVersion?`, build ${e.hostVersion}`:``;return`${e.sshTarget} port ${e.dashboardPort}: ${sc(e)}${t}`}async function FV(e){let t=await Sr(`remove-host`,{id:e.id},NV,{busyText:`Removing ${e.name}.`});t?.type===`host-change-result`&&(t.ok?NV.show(`ok`,`Removed ${e.name}. Its sessions keep running there.`):NV.show(`error`,`Not removed: ${t.error??`the server refused the change.`}`))}function IV(e){$t({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:()=>{FV(e)}})}function LV(e){let t=T(`div`,`settings-host-row`);t.dataset.state=e.state;let n=T(`div`,`settings-readonly`);return n.append(T(`span`,`settings-host-name`,`${e.name} (${e.id})`),T(`span`,null,PV(e))),t.append(n,C({variant:`secondary`,label:`Remove`,action:`remove-host`,onClick:()=>IV(e)})),t}function RV(){if(!jV)return;let e=oc();e.length===0?jV.replaceChildren(T(`div`,`settings-readonly`,`No hosts linked yet. Add one below.`)):jV.replaceChildren(...e.map(LV))}function zV(e,t,n){let r=T(`label`,`settings-host-field`),i=T(`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(T(`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):AV};t.disabled=!0;let a=await Sr(`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 VV(){let e=T(`form`,`settings-host-form`),t=zV(`Id`,`id`,`devbox`),n=zV(`Name`,`name`,`Same as the id`),r=zV(`Ssh target`,`sshTarget`,`me@devbox or a ~/.ssh/config alias`),i=zV(`Dashboard port`,`dashboardPort`,String(AV)),a=Cr(`settings-hosts-status`),o=C({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=T(`div`,`settings-telegram-test`);s.append(o,a.element);let c=T(`div`,`settings-host-fields`);return c.append(t.field,n.field,r.field,i.field),e.append(c,s),e}function HV(){let e=T(`div`,`settings-view-status-block settings-hosts`);return jV=T(`div`,`settings-host-list`),RV(),MV??=VV(),e.append(jV,NV.element,MV),e}function UV(){jV?.isConnected&&RV()}var WV=new Map,GV=()=>{},KV={connect:()=>{},abandon:()=>{},reconnectNow:()=>{},send:()=>!1,request:()=>Promise.reject(Error(x))};function qV(e){return typeof e.id==`string`?e.id:typeof e.sessionId==`string`?e.sessionId:null}f(e=>{let t=qV(e),n=t?lc(t):null;return n?WV.get(n)??KV:null},()=>[...WV.values()]);function JV(e,t,n,r){return(WV.get(e)??KV).request(t,n,r)}function YV(e){GV=e}function XV(e){let t=g({pathPrefix:`/hosts/${encodeURIComponent(e)}`,isLocal:!1,onMessage:t=>{t.type===`session-added`&&uc(t.id,e),GV(e,t)}});return t.connect(),t}function ZV(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,XV(e));return n}var QV={snapshot:e=>{nV(e.serverBuild),oV(e.sessions)},"hooks-report":e=>Sv(e),"save-hook-result":()=>Cv(),"delete-hook-result":()=>Cv(),"update-status":e=>{Az(e),Kj(e)},"update-progress":e=>qj(e.journal),"post-turn-leftovers":e=>Mz(e),"feature-hint":e=>Rz(e.hint),"star-hint":()=>zz(),error:e=>{let t=Jj(e),n=SC(e),r=tS(e);t||n||r||(e.id?Tn(e.id,e.message):Tr({source:AB,message:e.message}))},"settings-updated":e=>{e.settings&&Hz(e.settings),Rk()},"agent-logins":e=>aj(e.logins),"health-snapshot":e=>{e.stats&&uv(e.stats)},"client-trust":e=>UL(e.trust),"shutting-down":()=>wB(`Shutting down...`,`Shutting down sessions...`),restarting:()=>wB(`Restarting...`,`Restarting server...`),"hosts-status":e=>{ac(e.hosts),UV();for(let t of ZV(e.hosts))iV(t);$B()}},$V={"session-status":e=>gV(e),"session-added":e=>{U_(e.id,e.linkedPrs),LC(e.id)||(UC(e.id,e.session,e.state,ZB(e)),GC(e.id,e.agent)),YB(hr.counts),$B(),uV()},"session-close-confirm":e=>{$i(e.id)},"session-removed":e=>{rV(e.id),vP(e.id),YB(hr.counts),$B(),uV()},"session-title":e=>{IC(e.id,e.taskTitle,e.isCustom),$B()},"session-prs":e=>U_(e.id,e.linkedPrs),"session-renamed":e=>{$C(e.id,e.newName),$B(),uV()},"session-modified":e=>{lV(e.id,e.session,e.state,e,e.linkedPrs),GC(e.id,e.agent),YB(hr.counts),$B(),uV()},"session-git":e=>KC(e.id,!!e.worktree),"session-merge-status":e=>{ZC(e.id,e.mergeStatus,e.reason),gF(e.id,e.mergeStatus),QB()},"debug-state-response":e=>Mb(e),"session-setup-response":e=>lw(e),notify:e=>{_x(e),Nb(e.session)},"session-error":e=>{lb(e.id),tS(e)||Tn(e.id,e.message)}},eH=Ot.flatMap(e=>[!1,!0].flatMap(t=>[!1,!0].map(n=>({tone:e,dashed:t,back:n})))),tH=16,nH=new WeakMap;function rH(e){return e?.kind===`box`?Mt(e)?.asset??null:null}function iH(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 aH(e){return Ot.indexOf(e.tone)*4+(e.dashed?2:0)+ +!!e.back}function oH(e,t,n){t.kind===`wire`?e.wireCountByStyleSlot[aH(t)]+=n:t.kind===`box`&&(e.boxCountByChangeSlot[Pt.indexOf(t.change)]+=n,t.at===null&&t.step===null&&(e.floatingBoxCount+=n))}function sH(e){return e.kind===`wire`?[e.from,e.to]:e.kind===`frame`?e.contains:[]}function cH(e,t,n){t.kind===`box`&&t.step!==null&&(n?e.stepBoxIds.add(t.id):e.stepBoxIds.delete(t.id))}function lH(e){return e.kind===`box`&&(e.refs.length>0||Ct(e).some(e=>e.ref!==null))}function uH(e,t){lH(t)?e.anchoredIds.add(t.id):e.anchoredIds.delete(t.id)}function dH(e,t,n){for(let r of new Set(sH(t))){let i=e.dependentIdsByBoxId.get(r);i?i instanceof Set?i.add(t.id):i.length<tH?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 fH(e,t){for(let n of new Set(sH(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 pH(e,t){return{...t,id:e.storedIdOf(t.id)??t.id}}function mH(e,t,n){e.elementCount+=1,t.kind===`stroke`&&(e.strokeCount+=1),iH(e,rH(t),1),oH(e,t,1),dH(e,t,n),cH(e,t,!0),uH(e,t)}function hH(e,t){--e.elementCount,t.kind===`stroke`&&--e.strokeCount,iH(e,rH(t),-1),oH(e,t,-1),fH(e,t),cH(e,t,!1),e.anchoredIds.delete(t.id)}function gH(){return{elementCount:0,strokeCount:0,assetRefCount:new Map,dependentIdsByBoxId:new Map,stepBoxIds:new Set,anchoredIds:new Set,wireCountByStyleSlot:eH.map(()=>0),boxCountByChangeSlot:Pt.map(()=>0),floatingBoxCount:0}}function _H(e){let t=nH.get(e);if(t)return t;let n=gH();for(let t of e.values())mH(n,t,e);return nH.set(e,n),n}function vH(e){return{elementCount:e.elementCount,strokeCount:e.strokeCount,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),wireCountByStyleSlot:[...e.wireCountByStyleSlot],boxCountByChangeSlot:[...e.boxCountByChangeSlot],floatingBoxCount:e.floatingBoxCount}}function yH(e){let t=e.copy(),n=nH.get(e);return n&&nH.set(t,vH(n)),t}function bH(e,t){let n=nH.get(e),r=e.get(t.id);if(e.put(t),!n)return;let i=pH(e,t);r?(iH(n,rH(r),-1),iH(n,rH(t),1),oH(n,r,-1),oH(n,i,1),fH(n,r),dH(n,i,e),cH(n,r,!1),cH(n,i,!0),uH(n,i)):mH(n,i,e)}function xH(e,t){SH(e,t.id),bH(e,t)}function SH(e,t){let n=e.get(t);if(!n)return;e.remove(t);let r=nH.get(e);r&&hH(r,n)}var CH=26,wH=97;function TH(e){return e.step!==null}function EH(e){return[..._H(e.elements).stepBoxIds].flatMap(t=>{let n=e.elements.get(t);return n?.kind===`box`&&TH(n)?[n]:[]})}function DH(e,t,n){return[..._H(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 OH(e,t){let n=new Map;for(let r of t){let i=DH(e,r,t).map(e=>e.from);i.length>0&&n.set(r,i)}return n}function kH(e){let t=String.fromCharCode(wH+e%CH),n=Math.floor(e/CH);return n===0?t:`${t}${n+1}`}function AH(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 jH(e){let t=EH(e),n=OH(e,new Set(t.map(e=>e.id))),r=AH(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}${kH(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 MH(e){let t=NH(e.length);return e.forEach((e,n)=>{PH(t,n,e.x,e.y,e.x+e.width,e.y+e.height)}),t}function NH(e){return{count:e,lefts:new Float64Array(e),tops:new Float64Array(e),rights:new Float64Array(e),bottoms:new Float64Array(e)}}function PH(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 FH(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 IH(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 FH(n)}function LH(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 RH(e){let t=1;for(;t<e;)t*=2;return t}function zH(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 BH(e,t){let n=RH(t.length),r=new Int32Array(e.count),i=new Int32Array(e.count);for(let n=0;n<e.count;n+=1)r[n]=LH(t,e.tops[n]??0),i[n]=LH(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){zH(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=LH(t,e);for(let e=s+n;e>=1;e>>=1)zH(o[e]??[],a,i);let c=LH(t,r);c>s&&f(1,0,n-1,s+1,c,i)}}}function VH(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 HH(e){let t=IH(e);return e.map(e=>({rects:e,index:BH(e,t),closingOrder:VH(e.rights),nextClosing:0}))}function UH(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 WH(e,t){let[n]=HH([e]);if(n)for(let r of VH(e.lefts))UH(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 GH(e,t,n){let[r,i]=HH([e,t]);if(!r||!i)return;let a=VH(e.lefts),o=VH(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;UH(r,f),UH(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 KH(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 qH(e,t,n,r){let i=new Int32Array(e.length);for(let e=0;e<i.length;e+=1)i[e]=e;return KH(Int32Array.from(e),n,KH(Int32Array.from(t),r,i))}function JH(e,t,n,r){return Array.from(qH(e,t,n,r),n=>[e[n]??0,t[n]??0])}function YH(e){let t=[],n=[];return WH(MH(e),(e,r)=>{t.push(Math.min(e,r)),n.push(Math.max(e,r))}),JH(t,n,e.length,e.length)}var XH=10,ZH=4,QH=14,$H=2,eU=160;function tU(e,t){return t?e.y:e.x}function nU(e,t){return t?e.x:e.y}function rU(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||tU(a,t)!==tU(o,t)||nU(a,t)===nU(o,t))continue;let s=i===0||i+2===e.length;n.push({wire:r,index:i,line:tU(a,t),low:Math.min(nU(a,t),nU(o,t)),high:Math.max(nU(a,t),nU(o,t)),isFixed:s})}}),n.sort((e,t)=>e.line-t.line||e.low-t.low)}function iU(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 aU(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=iU(s,t);c.length>1&&n.push({line:i.line,low:i.low,high:o,bundles:c})}return n}function oU(e,t,n,r){let i=e[t.index],a=e[t.index+1];if(!i||!a)return 0;let o=nU(i,r)<nU(a,r)===n?e[t.index-1]:e[t.index+2];return o?Math.sign(tU(o,r)-t.line):0}function sU(e,t,n,r){let i=n[e.wire]??[],a=n[t.wire]??[],o=oU(i,e,!0,r),s=oU(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=oU(i,e,!1,r),l=oU(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 cU(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 lU(e,t,n,r,i,a){if(a<n||r<i)return-1;if(i<=n&&r<=a)return e.maxima[t]??-1;cU(e,t);let o=n+r>>1;return Math.max(lU(e,t*2,n,o,i,a),lU(e,t*2+1,o+1,r,i,a))}function uU(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}cU(e,t);let s=n+r>>1;uU(e,t*2,n,s,i,a,o),uU(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 dU(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 fU(e){let t=FH(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=dU(t,a.low),o=dU(t,a.high);a.offset=lU(r,1,0,n-1,e,o)+1,uU(r,1,0,n-1,e,o,a.offset),i=Math.max(i,a.offset+1)}return i}function pU(e){let t=new Set(e.flatMap(e=>e.isPinned?[e.offset]:[]));if(t.size>1)return;let[n]=t;return n??null}function mU(e,t,n,r){let i=t*XH+ZH+QH,a=r?{x:e.low,y:e.line-eU,width:e.high-e.low,height:320}:{x:e.line-eU,y:e.low,width:320,height:e.high-e.low},o=e.line-eU,s=e.line+eU,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+ZH>o&&(o=u+ZH,c=!0),a>=e.line&&a-ZH<s&&(s=a-ZH,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 hU(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(XH,i,a);return o<$H?null:{firstTrack:e-n*o,spacing:o}}let i=Math.min(XH,(r.high-r.low)/(t-1));if(i<$H)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 gU(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 _U(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 vU(e,t,n,r){let i=aU(rU(t,r),e),a=i.map(e=>(e.bundles.sort((e,n)=>{let[i]=e.members,[a]=n.members;return i&&a?sU(i,a,t,r):0}),fU(e.bundles)));i.forEach((i,o)=>{let s=a[o]??1;if(s<2)return;let c=pU(i.bundles),l=mU(i,s,n,r),u=hU(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=>_U(n,d(n),e,t)))for(let e of i.bundles)gU(e,d(e),t,r)})}function yU(e,t){let n=e.map(e=>e.points.map(e=>({x:e.x,y:e.y})));return vU(e,n,t,!0),vU(e,n,t,!1),n}var bU=1<<20,xU=1<<21,SU=64,CU=256;function wU(e,t=SU){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 EU(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 DU(e,t){return Math.floor(t/e.cellSize)}function OU(e,t){return(e+bU)*xU+(t+bU)}function kU(e,t,n,r,i){return(DU(e,r)-DU(e,t)+1)*(DU(e,i)-DU(e,n)+1)}function AU(e,t,n,r,i){return!(kU(e,t,n,r,i)<=CU)}function jU(e,t,n,r,i,a){let o=DU(e,t),s=DU(e,r),c=DU(e,n),l=DU(e,i);for(let e=o;e<=s;e+=1)for(let t=c;t<=l;t+=1)a(OU(e,t))}function MU(e,t){t>=e.isStored.length||e.isStored[t]===0||(e.isStored[t]=0,e.oversizedSlots.delete(t)||jU(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 NU(e,t,n){MU(e,t),EU(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,AU(e,n.x,n.y,n.x+n.width,n.y+n.height)?e.oversizedSlots.add(t):jU(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 PU(e){return e.currentStamp+=1,e.currentStamp<4294967295||(e.visitStamp.fill(0),e.currentStamp=1),e.currentStamp}function FU(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 IU(e,t,n){for(let r=0;r<e.isStored.length;r+=1)if(e.isStored[r]===1&&FU(e,r,t)&&n(r)===!0)return}function LU(e,t,n){let r=t.x+t.width,i=t.y+t.height;if(AU(e,t.x,t.y,r,i)){IU(e,t,n);return}let a=PU(e);for(let r of e.oversizedSlots)if(e.visitStamp[r]=a,FU(e,r,t)&&n(r)===!0)return;let o=DU(e,t.x),s=DU(e,r),c=DU(e,t.y),l=DU(e,i);for(let r=o;r<=s;r+=1)for(let i=c;i<=l;i+=1){let o=e.slotsByCell.get(OU(r,i));if(o){for(let r of o)if(e.visitStamp[r]!==a&&(e.visitStamp[r]=a,FU(e,r,t)&&n(r)===!0))return}}}function RU(e,t,n=()=>!0){let r=!1;return LU(e,t,e=>n(e)?(r=!0,!0):!1),r}function zU(e,t){let n=wU(t,e.length);for(let[t,r]of e.entries())NU(n,t,r);return n}var BU=1,VU=42,HU=42,UU=4,J=0,Y=1,WU=2,GU=3,KU=1024,qU=32,JU=-2,YU=1,XU=2,ZU=-1;function QU(){return{values:new Float64Array(64),length:0}}function $U(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 eW(e){return e.values.subarray(0,e.length)}function tW(){return{lines:QU(),starts:QU(),ends:QU()}}function nW(e,t,n,r){r<n||($U(e.lines,t),$U(e.starts,n),$U(e.ends,r))}function X(){return{alongs:QU(),acrosses:QU()}}function rW(e,t,n){return $U(e.alongs,t),$U(e.acrosses,n),e.alongs.length-1}function iW(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+UU;return{left:Math.round(n-VU),top:Math.max(Math.round(r-VU),o),right:Math.round(i+VU),bottom:Math.round(a+VU)}}function aW(e){let t=NH(e.length);return e.forEach((e,n)=>{PH(t,n,e.x-BU,e.y-BU,e.x+e.width+BU,e.y+e.height+BU)}),t}function oW(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===WU?{starts:e.tops,lows:e.lefts,highs:e.rights}:{starts:e.bottoms.map(e=>-e),lows:e.lefts,highs:e.rights}}function sW(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 cW(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=kW(o,0,o.length,i[t]??0);e<o.length&&(o[e]??0)<=(a[t]??0)&&s.push(t)}let c=NH(s.length);return s.forEach((t,n)=>{PH(c,n,e.lefts[t]??0,e.tops[t]??0,e.rights[t]??0,e.bottoms[t]??0)}),c}function lW(e,t,n){let r=oW(e,t),i=t===Y||t===GU,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 uW(e,t,n){if(n.alongs.length*e.count<=xW)return lW(e,t,n);let r=n.alongs.length*bW<e.count?cW(e,t,eW(n.acrosses)):e,i=oW(r,t),a=t===Y||t===GU,o=eW(n.alongs).map(e=>a?-e:e),s=eW(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=FH(c),u=RH(l.length),d=new Float64Array(u*2).fill(1/0),f=new Float64Array(o.length).fill(1/0),p=sW(i.starts),m=0;for(let e of sW(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=LH(l,i.lows[e]??0)+1+u,a=LH(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=LH(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 dW(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 fW(e,t,n){if(t.length*e.count<=xW)return dW(e,t,n);let r=new Uint8Array(t.length),i=NH(t.length);for(let e=0;e<t.length;e+=1)PH(i,e,t[e]??0,n[e]??0,t[e]??0,n[e]??0);return GH(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 pW(e,t){let n={xs:QU(),ys:QU(),awayDirections:QU()};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,GU],[i,a,J,GU],[e,o,Y,WU],[i,o,J,WU]])$U(n.xs,t),$U(n.ys,r),$U(n.awayDirections,s*4+c)}return n}function mW(e,t){return{rays:t,hits:t.map((t,n)=>uW(e,n,t))}}function hW(e,t,n){return t===J?Math.min(e,n.right):t===Y?Math.max(e,n.left):t===WU?Math.min(e,n.bottom):Math.max(e,n.top)}function gW(e,t,n){if(!Number.isFinite(t))return null;let r=n===J||n===WU?t+BU-14:t-BU+14;return Math.abs(r-e)<=HU?null:Math.round((e+r)/2)}function _W(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&&nW(e,t,o,Math.min(n,r)),o=Math.max(o,i);nW(e,t,o,r)}function vW(e,t){let n=tW(),r=tW(),i=[X(),X(),X(),X()],a=t.map(e=>{let t=e.outwardDirection===J||e.outwardDirection===Y;return rW(i[e.outwardDirection]??X(),t?e.x:e.y,t?e.y:e.x)}),o=mW(e.blockers,i);return t.forEach((t,i)=>{let s=hW(o.hits[t.outwardDirection]?.[a[i]??0]??1/0,t.outwardDirection,e.frame);t.outwardDirection===J||t.outwardDirection===Y?(nW(n,t.y,Math.min(t.x,s),Math.max(t.x,s)),nW(r,t.x,t.y,t.y)):(nW(r,t.x,Math.min(t.y,s),Math.max(t.y,s)),nW(n,t.y,t.x,t.x))}),{horizontal:n,vertical:r}}var yW=12,bW=4,xW=4096;function SW(e,t){let n=pW([...e.hardRects,...e.softRects],t),r=n.xs.length;return{count:r,xs:eW(n.xs),ys:eW(n.ys),awayDirections:eW(n.awayDirections),rows:new Float64Array(r*yW).fill(NaN)}}function CW(e,t,n,r,i,a){let o=t*yW+n*3;e[o]=r,e[o+1]=i,e[o+2]=a}function wW(e,t,n,r){let i=Float64Array.from(t,t=>e.xs[t]??0),a=Float64Array.from(t,t=>e.ys[t]??0),o=fW(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]=rW(i,a?t:n,a?n:t)}}let l=mW(n,s),u=(e,t,n)=>hW(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*yW,(s+1)*yW),o[n]===1)continue;let m=i[n]??0,h=a[n]??0,g=e=>c[n*4+e]??-1;CW(e.rows,s,0,h,u(l,Y,g(Y)),u(l,J,g(J))),CW(e.rows,s,1,m,u(l,GU,g(GU)),u(l,WU,g(WU)));let _=e.awayDirections[s]??0,v=Math.floor(_/4),y=_%4,ee=gW(m,l.hits[v]?.[g(v)]??1/0,v);ee!==null&&f.push(s,rW(d[GU]??X(),h,ee),rW(d[WU]??X(),h,ee),ee);let te=gW(h,l.hits[y]?.[g(y)]??1/0,y);te!==null&&te>=r.top&&p.push(s,rW(d[Y]??X(),m,te),rW(d[J]??X(),m,te),te)}let m=mW(n,d);for(let t=0;t<f.length;t+=4)CW(e.rows,f[t]??0,2,f[t+3]??0,u(m,GU,f[t+1]??0),u(m,WU,f[t+2]??0));for(let t=0;t<p.length;t+=4)CW(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=tW(),i=tW(),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*yW+n*3,i=e.rows[r]??NaN,o=a[n];!Number.isNaN(i)&&o&&nW(o,i,e.rows[r+1]??0,e.rows[r+2]??0)}return _W(r,t.top,t.left,t.right,n),nW(r,t.bottom,t.left,t.right),nW(i,t.left,t.top,t.bottom),nW(i,t.right,t.top,t.bottom),{horizontal:r,vertical:i}}function EW(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 DW(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&&EW(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 OW(e){let t=eW(e.lines),n=eW(e.starts),r=eW(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 kW(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 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 jW(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 MW(e){for(let t=1;t<e.length;t+=1)e[t]=(e[t]??0)+(e[t-1]??0);return e}function NW(e){return FH(Float64Array.from(e.lines))}function PW(e,t){let n=RH(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]=kW(t,0,t.length,e.starts[o]??0),i[o]=AW(t,0,t.length,e.ends[o]??0)-1,jW(n,r[o]??0,i[o]??-1,e=>{a[e+1]=(a[e+1]??0)+1});MW(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)jW(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 FW(e,t,n,r){let i=kW(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?AW(e.lines,i,s,n):kW(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 IW(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=FH(o),c=RH(Math.max(s.length*2-1,1)),l=e=>[kW(s,0,s.length,n[e]??0)*2+1,kW(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);jW(c,t,n,e=>{u[e+1]=(u[e+1]??0)+1})}MW(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);jW(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 LW(e,t){let n=kW(e,0,e.length,t);return e[n]===t?n*2:n===0||n===e.length?-1:n*2-1}function RW(e,t,n,r){let i=LW(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=kW(e.alongLows,i,e.offsets[t+1]??0,r);if(a>i&&(e.reachMaxima[a-1]??0)>n)return!0}return!1}function zW(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=NW(e),o=RH(Math.max(a.length,1)),s=new Int32Array(o*2),c=new Int32Array(o*2).fill(-1),l=t=>kW(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=kW(a,0,a.length,t.starts[n]??0),s=AW(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 BW(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 VW(e){return{horizontalPieces:new Int32Array(e),verticalPieces:new Int32Array(e),neighbors:new Int32Array(e*4).fill(JU),softSteps:new Uint8Array(e*4)}}function HW(e,t){let n=e.xs.length*2,r=VW(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 UW(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 WW(e,t){let n=iW(e,t);if(!n)return null;let r=aW(e.hardRects),i=SW(e,n);return wW(i,Array.from({length:i.count},(e,t)=>t),r,n),GW(e,n,r,i)}function GW(e,t,n,r){let i=TW(r,t,n);return{input:e,frame:t,blockers:n,corners:r,horizontal:OW(i.horizontal),vertical:OW(i.vertical),softAlongX:IW(e.softRects,!0),softAlongY:IW(e.softRects,!1)}}function KW(e){return WW(e,[])}function qW(e,t){return e.left===t.left&&e.top===t.top&&e.right===t.right&&e.bottom===t.bottom}function JW(e,t){let n=iW(e.input,t),r=n&&!qW(n,e.frame)?WW(e.input,t):e;if(!r)return null;let{softAlongX:i,softAlongY:a}=r,o=vW(r,t),s=DW(r.horizontal,OW(o.horizontal)),c=DW(r.vertical,OW(o.vertical)),l=PW(c,NW(s)),u=PW(s,NW(c)),d=zW(s,c),f=VW(KU),p=new Int32Array(KU*2).fill(ZU),m=(e,t)=>{let n=p.length-1;for(let r=UW(e,t,n);;r=r+1&n){let n=p[r]??ZU;if(n===ZU||f.horizontalPieces[n]===e&&f.verticalPieces[n]===t)return r}},h=()=>{p=new Int32Array(p.length*2).fill(ZU);for(let e=0;e<b.nodeCount;e+=1)p[m(f.horizontalPieces[e]??0,f.verticalPieces[e]??0)]=e},g=(e,t)=>{let n=p[m(e,t)]??ZU;if(n!==ZU)return n;let r=b.nodeCount;return r===b.xs.length&&(f=HW(b,f)),(r+1)*2>p.length&&h(),b.xs[r]=c.lines[t]??0,b.ys[r]=s.lines[e]??0,f.horizontalPieces[r]=e,f.verticalPieces[r]=t,p[m(e,t)]=r,b.nodeCount+=1,r},_=(e,t)=>{let n=t===J||t===WU,r=b.xs[e]??0,i=b.ys[e]??0;if(t===J||t===Y){let t=f.horizontalPieces[e]??0,a=FW(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=FW(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]??JU;if(n!==JU)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===XU;let r=v(e,t),o=t===J||t===Y,s=o?b.ys:b.xs,c=o?b.xs:b.ys,l=c[e]??0,u=c[r]??0,d=r>=0&&RW(o?i:a,s[e]??0,Math.min(l,u),Math.max(l,u)),p=d?XU:YU;return f.softSteps[e*4+t]=p,r>=0&&(f.softSteps[r*4+(t^1)]=p),d},ee=(e,t)=>{let n=BW(s,t,e),r=BW(c,e,t);return n<0||r<0?-1:g(n,r)},te=e=>d[f.horizontalPieces[e]??0]??-1,ne=(s.count+c.count)*qU,b={nodeCount:0,xs:new Float64Array(KU),ys:new Float64Array(KU),neighborOf:v,isSoftStep:y,nodeAt:ee,componentOf:te,beginSearch:()=>{b.nodeCount<=ne||(p.fill(ZU),f.neighbors.fill(JU,0,b.nodeCount*4),f.softSteps.fill(0,0,b.nodeCount*4),b.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 b}var YW=30,XW=60,ZW=512,QW=3,$W=400,eG=6,tG=1,nG=1e6,rG=4096,iG=200,aG=240,oG=2,sG=3e3,cG=[960,3840],lG=512,uG=64,dG=14,fG=8,pG=6.6,mG=5,hG=10,gG=2,_G=[.5,.35,.65,.2,.8],vG=256,yG=0,bG=1,xG=[{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},SG={left:0,right:1,top:2,bottom:3},CG=[1,0,3,2],wG=1;function TG(e){return e===`left`||e===`right`}function EG(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function DG(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function OG(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 kG(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 AG(e){return e.from.y===e.to.y}function jG(e,t){let n=t.x+t.width,r=t.y+t.height;if(AG(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 MG(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 NG(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 PG(e){return e.slice(1).flatMap((t,n)=>{let r=e[n];return r?[{from:r,to:t}]:[]})}function FG(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function IG(e){return{count:e.length,messageAt:t=>e[t]??``}}function LG(e){let t=e.reduce((e,t)=>e+t.count,0),n=t<=bt.layoutWarnings?t:bt.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 RG(e,t){return t.x>=e.x+e.width||t.x+t.width<=e.x}function zG(e,t,n){if(e.id===t.id)return{exitSide:`right`,entrySide:`top`};if(n)return{exitSide:`bottom`,entrySide:`bottom`};let r=EG(e),i=EG(t);return RG(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 BG=[`right`,`left`,`bottom`,`top`];function VG(e,t){let n=e.outputPort??lK(e.from,t.exitSide,1)[0]??EG(e.from),r=lK(e.to,t.entrySide,1)[0]??EG(e.to);if(!mK(t.exitSide,t.entrySide))return{...e,...t,start:n,end:r};let i=hK(r,t.entrySide,e.to,n),a=i===r&&!e.outputPort?hK(n,t.exitSide,e.from,r):n;return{...e,...t,start:a,end:i}}function HG(e,t){return NG(t.map(t=>({x:e.xs[t>>2]??0,y:e.ys[t>>2]??0})))}function UG(e,t,n,r,i){return t.map(t=>({side:t,point:t===n?r:lK(e,t,1)[0]??EG(e),direction:i[t],bias:t===n?0:tG}))}function WG(e){return[e,...BG.filter(t=>t!==e)]}function GG(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]:WG(t.exitSide),o=n.toSide?[n.toSide]:WG(t.entrySide);if(a.length<2&&o.length<2)return null;let s=VG(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}]:UG(r,a,a[0]??t.exitSide,s.start,Z),entries:UG(i,o,o[0]??t.entrySide,s.end,SG)}}function KG(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:CG[e.direction]??0}))])}function qG(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 JG(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 YG(e){return e===Z.right||e===Z.left}function XG(e,t){return t.x>e.x?Z.right:t.x<e.x?Z.left:t.y>e.y?Z.bottom:Z.top}function ZG(e,t){if(YG(e.direction)===YG(t.direction))return null;let n=YG(e.direction)?{x:t.point.x,y:e.point.y}:{x:e.point.x,y:t.point.y};return $K(n,e.point)||$K(n,t.point)||XG(e.point,n)!==e.direction||XG(n,t.point)!==t.direction?null:[e.point,n,t.point]}function QG(e,t,n){return PG([...e]).every(e=>{let r=Gq(e.from,e.to),i=n.obstaclesIn?.(DG(r,wG));return i!==void 0&&!i.hardRects.some(e=>e!==t.from&&e!==t.to&&MG(DG(e,wG),r))})}function $G(e){return PG([...e]).reduce((e,t)=>e+dq(t),0)}function eK(e,t,n,r){let i=Gq(e.from,e.to),a=n.obstaclesIn?.(DG(i,wG));if(!a||a.hardRects.some(e=>e!==t.from&&e!==t.to&&MG(DG(e,wG),i))||a.softRects.some(e=>MG(e,i)))return!1;let o=GK(r,i);return!(AG(e)?o.verticals:o.horizontals).some(t=>gq(e,t))}function tK(e,t){return JG(e,t)?[e.point,t.point]:ZG(e,t)}function nK(e){return e.exits.flatMap(t=>e.entries.flatMap(e=>{let n=tK(t,e);return n?[{exit:t,entry:e,points:n,bends:n.length-2,cost:$G(n)+t.bias+e.bias}]:[]}))}function rK(e,t,n){let r=nK(e).filter(n=>QG(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&&!PG(c.points).every(r=>eK(r,e.plan,t,n))?null:{exit:c.exit,entry:c.entry,points:c.points}}function iK(e,t,n){let r=MK(),i=UK();for(let a of e){let e=rK(a,t,i);if(e){qG(a,e.exit,e.entry,e.points),WK(i,PG(e.points));continue}let o=TK(a.plan,n),s=SK(t,o),c=s?CK(KG([a]),t,o,s):null,l=c?qK(c,a.exits,a.entries,null,nG,r,GK(i,o)):null;if(FK(r),!c||!l)continue;let u=HG(c,l.states);qG(a,l.exit,l.entry,u),WK(i,PG(u))}}function aK(e,t,n,r){let i=e.flatMap(e=>{if(r.cleanIds.has(e.wire.id))return[];let n=GG(e,t.get(e)??{exitSide:e.exitSide,entrySide:e.entrySide});return n?[n]:[]});i.length>0&&iK(i,n,r)}function oK(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 sK(e,t,n){let r=t.boxesById.get(e.from),i=t.boxesById.get(e.to);if(!r||!i)return null;let a=zG(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??EG(r),end:EG(i),found:null};return n&&(s.exitSide=n.exitSide,s.entrySide=n.entrySide),{plan:s,facing:a}}function cK(e,t){let n=new Map,r=e.wires.flatMap(r=>{let i=sK(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=sK(r,e,t.routeById.get(r.id));return i?(n.set(i.plan,i.facing),[i.plan]):[]});aK(r,n,e,t),oK(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 lK(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(dG,(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+fG,Math.min(o,e.y+e.height-fG-(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)*dG/2;return r.map(e=>({x:Math.round(a+e*dG),y:i}))}function uK(e,t){let n=TG(t)?e.height:e.width;return Math.max(1,Math.floor((n-16)/dG)+1)}function dK(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:EG(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??EG(e.from),assign:t=>{e.end=t}}]);return kG(t?n.filter(e=>t.has(e.box.id)):n,e=>`${e.box.id}|${e.side}`)}function fK(e){return new Map([...e.entries()].map(([e,t])=>[e,[...kG(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 pK(e,t){for(let[n,r]of e){let e=r[0],i=t.get(n)??[];if(!e)continue;let a=lK(e.box,e.side,i.length);for(let e of r){let t=a[i.indexOf(e.groupKey)];t&&e.assign(t)}}}function mK(e,t){return e===`right`&&t===`left`||e===`left`&&t===`right`||e===`bottom`&&t===`top`||e===`top`&&t===`bottom`}function hK(e,t,n,r){return TG(t)?r.y>=n.y+fG&&r.y<=n.y+n.height-fG?{x:e.x,y:r.y}:e:r.x>=n.x+fG&&r.x<=n.x+n.width-fG?{x:r.x,y:e.y}:e}function gK(e,t){let n=(e,n)=>(t.get(`${e.id}|${n}`)?.length??0)===1,r=new Map([...kG(e,e=>e.exitKey)].map(([e,t])=>[e,t.length]));for(let t of e){if(t.from.id===t.to.id||!mK(t.exitSide,t.entrySide))continue;let e=t.busKey===null&&n(t.to,t.entrySide)?hK(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=hK(t.start,t.exitSide,t.from,t.end)):t.end=e}}function _K(e,t){return[...e.entries()].flatMap(([e,n])=>{let r=n[0],i=t.get(e)?.length??0;return!r||i<=uK(r.box,r.side)?[]:[`box ${r.box.id} has ${i} wires on its ${r.side} side, more than fit`]})}function vK(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 yK(e){let t=[...e.boxesById.values()],n=zU(t,lG),r=zU(e.softObstacles,lG);return i=>{let a=[],o=[];return LU(n,i,e=>{let n=t[e];n&&a.push(n)}),LU(r,i,t=>{let n=e.softObstacles[t];n&&o.push(n)}),{hardRects:a,softRects:o}}}function bK(e){return e.obstaclesIn?e:{...e,obstaclesIn:yK(e)}}function xK(e){let t=e.x-oG,n=e.y-oG,r=e.width+4,i=e.height+4;return[{x:t,y:n,width:r,height:oG},{x:t,y:e.y+e.height,width:r,height:oG},{x:t,y:n,width:oG,height:i},{x:e.x+e.width,y:n,width:oG,height:i}]}function SK(e,t){let n=e.obstaclesIn?.(t)??null;return n&&n.hardRects.length<=sG?n:null}function CK(e,t,n,r){let i=KW({hardRects:[...r.hardRects,...xK(n)],softRects:r.softRects,contentTop:t.contentTop});return i?JW(i,e):null}function wK(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=KW({hardRects:[...i,...xK(n)],softRects:[...r.softRects,...a],contentTop:t.contentTop});return o?JW(o,vK([e])):null}function TK(e,t,n=aG){let r=(t.routeById.get(e.wire.id)?.points??[]).map(e=>({x:e.x,y:e.y,width:0,height:0}));return DG(OG([e.from,e.to,...r])??e.from,n)}function EK(){return{states:new Int32Array(1024),priorities:new Float64Array(1024),tieBreaks:new Float64Array(1024),size:0,lastPoppedPriority:0}}function DK(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 OK(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 kK(e){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}return e.size+=1,e.size-1}function AK(e,t){let n=t;for(;n>0;){let t=n-1>>1;if(!DK(e,n,t))return;OK(e,t,n),n=t}}function jK(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;OK(e,0,e.size);let n=0;for(;;){let r=n*2+1,i=r+1,a=n;if(r<e.size&&DK(e,r,a)&&(a=r),i<e.size&&DK(e,i,a)&&(a=i),a===n)return t;OK(e,a,n),n=a}}function MK(){return{bestCost:new Float64Array(rG).fill(1/0),cameFrom:new Int32Array(rG).fill(-1),touchedStates:new Int32Array(rG),touchedCount:0,heap:EK()}}function NK(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 PK(e,t){if(e.touchedCount===e.touchedStates.length){let t=new Int32Array(e.touchedCount*2);t.set(e.touchedStates),e.touchedStates=t}e.touchedStates[e.touchedCount]=t,e.touchedCount+=1}function FK(e){for(let t=0;t<e.touchedCount;t+=1){let n=e.touchedStates[t]??0;e.bestCost[n]=1/0,e.cameFrom[n]=-1}e.touchedCount=0,e.heap.size=0}function IK(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:SG[t.entrySide],bias:0},s=qK(e,[a],[o],n,YW,r,i)?.states??null;return FK(r),s}function LK(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 RK(e){return e===yG||e===bG}function zK(e,t,n,r){if(e===CG[t.direction])return 2;let i=RK(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=xG[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 BK(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,RK(t.direction));return[{...t,node:n,component:e.componentOf(n),approachStart:r,approachEnd:i}]})}function VK(e,t){for(let n of e)if(n.node===t)return n;return null}var HK={horizontals:[],verticals:[]};function UK(){return{grid:wU(ZW),segments:[]}}function WK(e,t){for(let n of t)NU(e.grid,e.segments.length,Gq(n.from,n.to)),e.segments.push(n)}function GK(e,t){let n={horizontals:[],verticals:[]};return LU(e.grid,t,t=>{let r=e.segments[t];r&&(AG(r)?n.horizontals:n.verticals).push(r)}),n}function KK(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)hq(t.from.x,i,o)&&hq(a,t.from.y,t.to.y)&&(c+=1);return c}for(let t of e.horizontals)hq(t.from.y,a,s)&&hq(i,t.from.x,t.to.x)&&(c+=1);return c}function qK(e,t,n,r,i,a,o=HK){e.beginSearch();let s=BK(e,n),c=BK(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{heap:u}=a;NK(a,e.nodeCount*4);let d=(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)+zK(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,PK(a,t);let n=kK(u);u.states[n]=t,u.priorities[n]=e.bias+d(e.node,e.direction),u.tieBreaks[n]=-e.bias,AK(u,n)}for(;;){let t=jK(u);if(t<0)return null;let n=t>>2,s=t&3,f=VK(l,n);if(f&&s===f.direction){let e=JK(a.cameFrom,t),n=VK(c,(e[0]??0)>>2);return n?{states:e,exit:n,entry:f}:null}let p=a.bestCost[t]??1/0;if(u.lastPoppedPriority>p+d(n,s)+1e-6)continue;let m=VK(c,n);for(let c=0;c<4;c+=1){if(m&&c!==m.direction||c===CG[s])continue;let f=e.neighborOf(n,c);if(f<0)continue;let h=VK(l,f);if(h&&c!==h.direction)continue;NK(a,e.nodeCount*4);let g=Math.abs((e.xs[f]??0)-(e.xs[n]??0))+Math.abs((e.ys[f]??0)-(e.ys[n]??0)),_=r!==null&&LK(e,n,f,r),v=g+(c===s?0:i)+KK(o,e,n,f)*XW+(e.isSoftStep(n,c)?g*QW:0)+(_?$W:0),y=f*4+c,ee=p+Math.max(v,1)+(h?.bias??0);if(ee>=(a.bestCost[y]??1/0))continue;a.bestCost[y]=ee,a.cameFrom[y]=t,PK(a,y);let te=kK(u);u.states[te]=y,u.priorities[te]=ee+d(f,c),u.tieBreaks[te]=-ee,AK(u,te)}}}function JK(e,t){let n=[];for(let r=t;r!==-1;r=e[r]??-1)n.push(r);return n.reverse()}function YK(e,t){let n=xG[Z[t]]??{x:0,y:0};return{x:e.x+n.x*14,y:e.y+n.y*14}}function XK(e){let t=YK(e.start,e.exitSide),n=YK(e.end,e.entrySide);return NG([e.start,t,{x:n.x,y:t.y},n,e.end])}function ZK(e,t){if(!e.wire.back)return null;let n=OG([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 QK(e,t,n){let r=e&&n?HG(e,n):XK(t);return{plan:t,points:r,segments:PG(r),routedPoints:r,states:n}}function $K(e,t){return e.x===t.x&&e.y===t.y}function eq(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||!$K(n.start,e.start)||!$K(n.end,e.end)?null:{plan:e,points:n.points,segments:PG(n.points),routedPoints:n.points,states:n.isRouted?[]:null}}function tq(e,t,n,r,i,a=aG){let o=TK(e,n,a),s=SK(t,o);if(!s)return null;let c=CK(vK([e]),t,o,s),l=c?IK(c,e,ZK(e,t.loopFrames),r,GK(i,o)):null;return l?QK(c,e,l):null}function nq(e,t,n,r,i){let a=TK(e,n),o=t.obstaclesIn?.(a)??null,s=o?wK(e,t,a,o):null;return QK(s,e,s?IK(s,e,ZK(e,t.loopFrames),r,GK(i,a)):null)}function rq(e,t,n,r,i){let a=n.isPreview?[]:cG;for(let o of a){let a=tq(e,t,n,r,i,o);if(a)return a}return nq(e,t,n,r,i)}function iq(e){let{found:t}=e;return!t||t.exitSide!==e.exitSide||t.entrySide!==e.entrySide||!$K(t.start,e.start)||!$K(t.end,e.end)?null:{plan:e,points:t.points,segments:PG(t.points),routedPoints:t.points,states:[]}}function aq(e,t,n,r,i){let a=eq(e,n)??iq(e)??tq(e,t,n,r,i)??rq(e,t,n,r,i);return WK(i,a.segments),a}function oq(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)+fG,o=(TG(t)?e.y+e.height:e.x+e.width)-fG;return{low:Math.max(a,i-dG/2),high:Math.min(o,i+dG/2)}}function sq(e,t,n){let r=MK(),i=UK(),a=e.map(e=>aq(e,t,n,r,i));if(n.isPreview)return a;let o=yU(a.map(e=>({points:e.points,exitKey:e.plan.exitKey,busKey:e.plan.busKey,startSlack:oq(e.plan.from,e.plan.exitSide,e.plan.start,e.plan.outputPort!==null),endSlack:oq(e.plan.to,e.plan.entrySide,e.plan.end,!1)})),e=>t.obstaclesIn?.(e).hardRects??[]);return a.map((e,t)=>{let n=NG(o[t]??e.points);return{...e,points:n,segments:PG(n)}})}function cq(e){return Math.max(0,e.points.length-2)}function lq(e){return Math.ceil(e.length*pG)}function uq(e,t){return{x:e.x-t/2,y:e.y-hG,width:t,height:13}}function dq(e){return Math.abs(e.from.x-e.to.x)+Math.abs(e.from.y-e.to.y)}function fq(e,t){if(!AG(e))return[];let n=e.from.y;return[Math.min(e.from.x,e.to.x)+mG+t/2,Math.max(e.from.x,e.to.x)-mG-t/2].flatMap(e=>[{x:e,y:n-mG},{x:e,y:n+mG+hG}])}function pq(e,t){let n=[...e].sort((e,t)=>dq(t)-dq(e));return[...e.slice(0,1),...n].flatMap(e=>[..._G.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 AG(e)?[{x:r,y:i-mG},{x:r,y:i+mG+hG}]:[{x:r+mG+t/2,y:i+hG/2},{x:r-mG-t/2,y:i+hG/2}]}),...fq(e,t)])}function mq(e,t,n){let r=new Map,i=e.flatMap(e=>e.segments),a=zU(i.map(e=>Gq(e.from,e.to)),vG),o=[...t.boxesById.values(),...t.softObstacles],s=zU(o,vG),c=[],l=wU(vG);for(let u of e){let e=u.plan.wire.label;if(!e)continue;let d=lq(e),f=pq(u.segments,d),p=f.find(e=>{let n=uq(e,d);if(n.y<t.contentTop)return!1;let r=DG(n,gG);return RU(a,r,e=>{let t=i[e];return t!==void 0&&jG(t,r)})||RU(s,n,e=>{let t=o[e];return t!==void 0&&MG(n,t)})?!1:!RU(l,n,e=>{let t=c[e];return t!==void 0&&MG(n,t)})}),m=p??f[0]??EG(u.plan.from);p||n.push(`wire ${u.plan.wire.id} label "${e}" has no clear spot`);let h=uq(m,d);r.set(u.plan.wire.id,{at:{x:Math.round(m.x),y:Math.round(m.y)},bounds:h}),NU(l,c.length,h),c.push(h)}return r}function hq(e,t,n){return e>Math.min(t,n)+.5&&e<Math.max(t,n)-.5}function gq(e,t){if(AG(e)===AG(t))return!1;let n=AG(e)?e:t,r=n===e?t:e;return hq(r.from.x,n.from.x,n.to.x)&&hq(n.from.y,r.from.y,r.to.y)}function _q(e,t){if(AG(e)!==AG(t))return!1;let n=AG(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 vq(e,t){return e.plan.busKey!==null&&e.plan.busKey===t.plan.busKey||e.plan.exitKey===t.plan.exitKey}function yq(e){let t=e.flatMap(e=>e.segments),n=NH(t.length),r=new Int32Array(t.length),i=0;return e.forEach((e,t)=>{for(let a of e.segments)PH(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 bq(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&&!vq(c,l)&&(gq(u,d)?e.set(s,!0):_q(u,d)&&e.set(s,!1))}function xq(){return{firsts:[],seconds:[],isCrossings:[]}}function Sq(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 Cq(e,t){let n=[];return e.wireIndexByPiece.forEach((e,r)=>{t.isChangedByWire[e]&&n.push(r)}),n}function wq(e,t){let n=NH(t.length);return t.forEach((t,r)=>{PH(n,r,e.lefts[t]??0,e.tops[t]??0,e.rights[t]??0,e.bottoms[t]??0)}),n}function Tq(e,t,n,r){let i=xq();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 WH(t.rects,(n,i)=>bq(r,e,t,n,i)),Sq(xq(),r,e.length);let i=Cq(t,n);return GH(wq(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||bq(r,e,t,s,o)}),Sq(Tq(n.previous.wirePairs,n.wireIndexByPrevious,n.wireIndexByPrevious,(e,t)=>!n.isChangedByWire[e]&&!n.isChangedByWire[t]),r,e.length)}function Dq(e,t,n,r){let i=qH(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 Oq=new WeakMap;function kq(e){let t=Oq.get(e);if(t)return t;let n=[...e.boxesById.values()];return Oq.set(e,n),n}function Aq(e){return`box ${e.id}`}function jq(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&&jG(f,d)&&e.set(c,!0)}function Mq(e,t,n,r){let i=n.map(e=>DG(e,-2)),a=MH(i),o=new Map;if(!r)return GH(t.rects,a,(r,a)=>jq(o,e,t,n,i,r,a)),Sq(xq(),o,n.length);let s=Cq(t,r);GH(wq(t.rects,s),a,(r,a)=>jq(o,e,t,n,i,s[r]??0,a));let c=n.map(e=>r.changedSolidKeys.has(Aq(e))),l=n.flatMap((e,t)=>c[t]?[t]:[]);GH(t.rects,wq(a,l),(r,a)=>jq(o,e,t,n,i,r,l[a]??0));let u=new Map(n.map((e,t)=>[Aq(e),t])),d=r.previous.solidKeys.map(e=>u.get(e)??-1),f=xq();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))}),Sq(f,o,n.length)}function Nq(e){return JSON.stringify([e.points,e.plan.exitKey,e.plan.busKey,e.plan.from.id,e.plan.to.id])}function Pq(e,t,n,r){if(!r||!n||n.size>uG)return null;let i=e.map((e,n)=>r.wireSignatureById.get(e.plan.wire.id)!==t[n]);if(i.filter(Boolean).length>iG)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 Fq(e,t,n,r,i){let a=yq(e),o=kq(t),s=e.map(Nq),c=Pq(e,s,n,i),l=Mq(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(Aq),wirePairs:u,runsThroughPairs:l});let d=t=>e[t]?.plan.wire.id;return[Dq(l,e.length,o.length,(e,t)=>`wire ${d(e)} runs through ${o[t]?.kind} ${o[t]?.id}`),Dq(u,e.length,e.length,(e,t,n)=>`wire ${d(e)} ${n?`crosses`:`overlaps`} wire ${d(t)}`)]}function Iq(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=cq(e);return t>eG?[`wire ${e.plan.wire.id} bends ${t} times`]:[]})}function Lq(e,t){return AG(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 Rq(e,t){if(!t||t===e)return null;let n=e.points.find(e=>t.segments.some(t=>Lq(e,t)));return!n||n.x===e.plan.end.x&&n.y===e.plan.end.y?null:n}function zq(e,t,n,r,i){return pK(n,r),gK([...e.plans,...e.contextPlans],r),sq(e.plans,t,i)}function Bq(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 Vq(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 Hq(e,t,n){t.length>uG?GH(MH(e),MH(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 Uq(e,t){return e.storedWireKeyOf?.(t)??JSON.stringify(t)}function Wq(e,t,n){if(!t||!n)return{routeById:t?.routeById??new Map,cleanIds:new Set,isPreview:!1};let r=n.rects.map(e=>DG(e,14)),i=e.wires.flatMap(n=>{let r=t.routeById.get(n.id);return r&&r.wireKey===Uq(e,n)?[{wire:n,remembered:r}]:[]}),a=i.flatMap(({wire:e,remembered:t})=>PG(t.points).map(t=>({wireId:e.id,rect:Gq(t.from,t.to)}))),o=new Set;Hq(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 Gq(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 Kq(e,t,n){let r=new Map(n.map(t=>[t.plan.wire.id,{wireKey:Uq(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 qq(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:FG(i),start:i[0]??r.start,end:i[i.length-1]??r.end,label:r.wire.label,labelAt:t.get(r.wire.id)?.at??EG(r.from),isDashed:r.wire.dashed||r.wire.back,isBack:r.wire.back,tone:r.wire.tone,hasArrowhead:a===void 0||a===e,joinAt:Rq(e,a)}})}function Jq(e){let t=bK(e),n={routeById:new Map,cleanIds:new Set,isPreview:!0},r=cK(t,n),i=dK(r.plans),a=zq(r,t,i,fK(i),n);return qq(a,mq(a,t,[]))}function Yq(e,t){let n=bK(e),r=Bq(n),i=t&&t.contentTop===n.contentTop?Vq(t.rectByKey,r):null,a=Wq(n,t,i),o=cK(n,a),s=n.contextWires?new Set(o.plans.flatMap(e=>[e.from.id,e.to.id])):null,c=dK([...o.plans,...o.contextPlans],s),l=fK(c),u=zq(o,n,c,l,a),d=[],f=mq(u,n,d),p=qq(u,f),m=[...f.values()].map(e=>e.bounds),h=Kq(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:()=>[IG(Iq(u)),...Fq(u,n,i?.keys??null,h,t?.warningPairs??null),IG([..._K(c,l),...d])],extent:OG([...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 Xq(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,Zq=220,Qq=90,$q=30,eJ=18,tJ=12,nJ=20,rJ=18,iJ=28,aJ=12,oJ=2,sJ=20,cJ=26,lJ=18,uJ=22,dJ=40,fJ=18,pJ=8,mJ=320,hJ=256,gJ=160;function _J(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 vJ(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>aJ){let t=_J(e.text,r-i-oJ).map(e=>o(e,1,oJ,null));return[o(``,0,0,a),...t]}let s=e.style===`item`?oJ:a?a.length+1:0;return _J(e.text,r-i-s-+(e.style===`code`)).map((e,t)=>o(e,t,s,a))}function yJ(e,t=cJ){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,vJ(e,n,t)))}function bJ(e){return e.shape===`icon`?gJ:e.shape===`device`?qt[e.device].defaultBoxWidth:Zq}function xJ(e){return e.width??bJ(e)}function SJ(e,t){return Math.floor(e*(t-24)/196)}function CJ(e){let t=e.icon?2:0;if(e.shape===`icon`)return{lines:[],media:null,device:null,fit:`fit`,glyphRoom:56,titleIconChars:0,dialValues:{}};let n=St(e);return e.shape===`device`?{lines:[],media:e.media,device:e.device,fit:e.fit,glyphRoom:0,titleIconChars:t,dialValues:n}:{lines:e.lines,media:Mt(e),device:null,fit:`fit`,glyphRoom:0,titleIconChars:t,dialValues:n}}function wJ(e,t){let{screen:n,bezel:r,toolbarHeight:i,base:a}=qt[e],o=Ft(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 TJ(e,t){let n=t-24,r=Math.round(mJ*t/Zq),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 EJ(e,t){return e.device?wJ(e.device,t-24):e.media?TJ(e.media,t):null}function DJ(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,dialValues:e.dialValues,x:t.x+tJ+r.screen.x,y:t.y+n+r.screen.y,width:r.screen.width,height:r.screen.height}}function OJ(e,t,n,r){if(!e.device||!r)return null;let i=t.x+tJ,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 kJ=new WeakMap;function AJ(e){let t=kJ.get(e);if(t)return t;let n=MJ(e);return kJ.set(e,n),n}function jJ(e,t){let n=CJ(e),r=SJ(sJ,t);return{titleLines:_J(e.title,r-n.titleIconChars),wasLines:e.change===`relabeled`&&e.was?_J(e.was,r):[],bodyLines:yJ(n.lines,SJ(cJ,t))}}function MJ(e){let t=CJ(e),n=e.step?fJ:0,r=+!!e.step?.linkedBoardId,i=xJ(e),{titleLines:a,wasLines:o,bodyLines:s}=jJ(e,i),c=tJ+n+t.glyphRoom+(o.length+a.length)*nJ+(s.length+r)*rJ,l=EJ(t,i),u=l?l.height+pJ:0,d=c+tJ+u,f=e.shape===`decision`?e.outputs:[];return{headerHeight:d,outputs:f,content:t,artTop:c+pJ,art:l,height:Math.max(d+f.length*iJ,e.height??0)}}function NJ(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`stroke`:e.stroke.push(t);return}}function PJ(e){let t={box:[],frame:[],wire:[],stroke:[]};for(let n of e.elements.values())NJ(t,n);return{...e,elementsByKind:t,planStepById:new Map(jH(e).map(e=>[e.boxId,e]))}}function FJ(e,t){return e.elementsByKind[t]}function IJ(e,t){return t.step?{label:e.get(t.id)?.label??``,status:t.step.status,linkedBoardId:t.step.linkedBoardId}:null}function LJ(e,t,n){let r=AJ(t),i=xJ(t),a=r.outputs.length>0?(r.height-r.headerHeight)/r.outputs.length:iJ;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,tone:t.shape===`sticky`?t.tone:null,headerHeight:r.headerHeight,media:DJ(r.content,n,r.artTop,r.art),device:OJ(r.content,n,r.artTop,r.art),step:IJ(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*a+a/2}}))}}function RJ(e,t){let n=[...e.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0);return{x:e.size>0?n+Qq:Q,y:t}}function zJ(e){return e.shape===`panel`&&e.step===null&&e.at===null}function BJ(e,t,n){let r=FJ(e,`box`).filter(zJ).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id));if(r.length===0)return;let i=[...n.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0),a=n.size>0?Math.round(i+Qq):Q,o=t;for(let t of r){let r=LJ(e.planStepById,t,{x:a,y:o});n.set(t.id,r),o+=r.height+$q}}function VJ(e,t,n){let r=new Map;for(let t of FJ(e,`box`)){let i=n.get(t.id);i&&r.set(t.id,LJ(e.planStepById,t,i))}for(let t of FJ(e,`box`))t.at&&r.set(t.id,LJ(e.planStepById,t,t.at));BJ(e,t,r);for(let n of FJ(e,`box`))r.has(n.id)||r.set(n.id,LJ(e.planStepById,n,RJ(r,t)));return r}function HJ(e,t){if(e.collapsed)return UJ(e,t);let n=OG(e.contains.flatMap(e=>t.get(e)??[]));return n?{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,stackedBoxCount:null,x:n.x-lJ,y:n.y-lJ-26,width:n.width+36,height:n.height+36+26}:null}function UJ(e,t){let n=e.contains[0],r=n===void 0?void 0:t.get(n);return r?{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,stackedBoxCount:e.contains.length,x:r.x,y:r.y-26,width:r.width+12,height:r.height+26+12}:null}function WJ(e,t){let n=new Map;for(let t of FJ(e,`frame`)){let e=t.collapsed?t.contains[0]:void 0;if(e!==void 0)for(let r of t.contains.slice(1))n.set(r,e)}return n.size===0?{visibleBoxesById:t,topCardIdByHiddenId:n}:{visibleBoxesById:new Map([...t].filter(([e])=>!n.has(e))),topCardIdByHiddenId:n}}function GJ(e,t){let n=t(e.from),r=t(e.to);return n===r?null:n===e.from&&r===e.to?e:{...e,from:n,to:r,fromOutput:n===e.from?e.fromOutput:null}}function KJ(e,t){if(t.size===0)return e;let n=e=>t.get(e)??e;return e.flatMap(e=>GJ(e,n)??[])}function qJ(e,t){return FJ(e,`frame`).flatMap(e=>HJ(e,t)??[])}function JJ(e){return{x:e.x,y:e.y,width:e.width,height:26}}function YJ(e){return{x:0,y:0,width:Q,height:e}}function XJ(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 ZJ(e,t,n){return XJ(OG([...e.flatMap(e=>e.kind===`wire`?[]:[e]),...t?[t]:[],YJ(n)]))}function QJ(e,t){return`box ${e} overlaps box ${t}`}function $J(e,t){return`box ${e} covers the title of frame ${t}`}function eY(e,t,n){let r=[...e.values()],i=YH(r).flatMap(([e,t])=>{let n=r[e],i=r[t];return n&&i&&MG(n,i)?[QJ(n.id,i.id)]:[]}),a=new Map(FJ(n,`frame`).map(e=>[e.id,new Set(e.contains)])),o=zU(r,hJ),s=t.flatMap(e=>{let t=JJ(e),n=[];return LU(o,t,i=>{let o=r[i];o&&!a.get(e.id)?.has(o.id)&&MG(o,t)&&n.push(i)}),n.sort((e,t)=>e-t).map(t=>$J(r[t]?.id??``,e.id))});return[...i,...s]}function tY(e,t,n){let{visibleBoxesById:r,topCardIdByHiddenId:i}=WJ(e,VJ(e,t.boxesTop,t.stepBandPositions)),a=qJ(e,r);return{boxesById:r,frames:a,routing:Yq({wires:KJ(FJ(e,`wire`),i),boxesById:r,softObstacles:a.map(JJ),loopFrames:a.filter(e=>e.isLoop),contentTop:t.contentTop,storedWireKeyOf:t=>e.elements.bodyOf(t.id)},n),collectPlacementWarnings:()=>eY(r,a,e)}}function nY(e){return e.step!==null&&e.at===null}function rY(e){let t=new Map(EH(e).filter(nY).map(e=>[e.id,e])),n=new Map;if(t.size===0)return{positionById:n,bottom:Q,columns:[]};let r=new Map;for(let n of jH(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+=AJ(e).height,c=s,a=Math.max(a,s),s+=$q;t.length>0&&o.push({x:i,bottom:c,boxCount:t.length}),i+=Math.max(...t.map(xJ))+Qq}return{positionById:n,bottom:a+dJ,columns:o}}function iY(e){return e>Q?e-eJ:-1/0}function aY(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+$q,0)]});return n.length===0?0:Math.max(Q,...n)+dJ-Q}function oY(e,t){let n=e.points.map((e,n)=>n%2==1?e+t:e),r=1/0,i=1/0,a=-1/0,o=-1/0;for(let e=0;e+1<n.length;e+=2){let t=n[e]??0,s=n[e+1]??0;r=Math.min(r,t),i=Math.min(i,s),a=Math.max(a,t),o=Math.max(o,s)}let s=e.width/2;return{kind:`stroke`,id:e.id,points:n,strokeWidth:e.width,tone:e.tone,x:r-s,y:i-s,width:a-r+e.width,height:o-i+e.width}}function sY(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:jt(n)}}var cY={plain:null,fail:`failure path`,join:`joins`};function lY(e,t,n){return`${e}|${t}|${n}`}function uY(e,t,n){let r=[cY[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var dY={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function fY(e){return Pt.flatMap(t=>t===`none`||!e.has(t)?[]:[{label:dY[t],swatch:{kind:`change`,change:t}}])}function pY(e){return e?Et.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}})):[]}function mY(e){return hY(e.legend,FJ(e,`wire`),new Set(FJ(e,`box`).map(e=>e.change)),e.planStepById.size>0)}function hY(e,t,n,r){let i=new Map(e.map(e=>[lY(e.tone,e.dashed||e.back,e.back),e.label])),a=new Set,o=[...t].flatMap(e=>{let t=e.dashed||e.back,n=lY(e.tone,t,e.back),r=i.get(n)??uY(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(lY(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,...fY(n),...pY(r)]}function gY(e,t){return t?.kind===`box`?{...e,...jJ(t,e.width)}:{...e,titleLines:[],wasLines:[],bodyLines:[]}}function _Y(e,t){switch(e.kind){case`box`:return gY(e,t);default:return e}}function vY(e,t){return{...e,elements:e.elements.map(e=>_Y(e,t.elements.get(e.id)))}}function yY(e){return vY(bY(e,null).layout,e)}function bY(e,t){let{positionById:n,bottom:r,columns:i}=rY(e),a=r-Q,o=PJ(sY(e,a)),s=r,c=tY(o,{boxesTop:s,contentTop:iY(r),stepBandPositions:n},t?.route??null),l={route:c.routing.memory},u=[...c.frames,...c.routing.wires,...c.boxesById.values(),...FJ(o,`stroke`).map(e=>oY(e,a))],d=xY(o.caption,ZJ(u,c.routing.extent,s),mY(o),n.size>0?i:[],a),f=[...c.routing.collectWarnings(),IG(c.collectPlacementWarnings())];return{layout:{elements:u,...d,warnings:LG(f)},memory:l,warningLists:f}}function xY(e,t,n,r,i){let a=t.y+t.height,o=n.map((e,t)=>({...e,x:Q,y:a+t*uJ})),s=a+o.length*uJ+(o.length>0?12:0),c=e?{text:e,x:Q,y:s}:null,l=o.length*uJ+(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 SY(e){return JSON.stringify(e)}function CY(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 wY(e,t,n){let r=n,i=new Map,a=[],o=[];for(let e of t.elements)e.kind===`box`&&i.set(e.id,e),e.kind===`frame`&&a.push(JJ(e)),e.kind===`frame`&&e.isLoop&&o.push(e);let s=[...r].flatMap(e=>i.get(e)??[]),c=[...e.elements.values()].flatMap(e=>e.kind===`wire`&&(r.has(e.from)||r.has(e.to))?[e]:[]),l=iY(t.pinnedOffsetY+Q);return(e,t)=>{let n=s.map(n=>CY(n,e,t));for(let e of n)i.set(e.id,e);return[...n,...Jq({wires:c,boxesById:i,softObstacles:a,loopFrames:o,contentTop:l})]}}var TY=2048,EY=.3,DY=.12,OY=.5,kY=6,AY=256,jY=30,MY=12,NY=28;function PY(e){return e>=EY?`full`:e>=DY?`titles`:`blocks`}function FY(e){return`${e.lod}:${e.level}:${e.chunkX}:${e.chunkY}`}function IY(e){return TY*2**e.level}function LY(e){let t=IY(e);return{x:e.chunkX*t,y:e.chunkY*t,width:t,height:t}}function RY(e,t){let n=IY({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 zY(e){return(e.lastX-e.firstX+1)*(e.lastY-e.firstY+1)}function BY(e,t){if(t!==`blocks`)return 0;let n=Math.max(e.width,e.height),r=0;for(;TY*2**r*kY<n&&r<jY;)r+=1;return r}function VY(e,t){let n={x:e.x-e.width*OY,y:e.y-e.height*OY,width:e.width*2,height:e.height*2},r=BY(e,t);for(;zY(RY(n,r))>AY&&r<jY;)r+=1;let i=RY(n,r);if(zY(i)>AY)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 HY(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 UY(e){if(e.kind===`wire`){let t=[...Xq(e.path),e.start,e.end];if(e.label){let n=lq(e.label)/2+MY;t.push({x:e.labelAt.x-n,y:e.labelAt.y-24},{x:e.labelAt.x+n,y:e.labelAt.y+MY})}return HY(t,MY)}return e.kind===`frame`?{...WY(e),width:Math.max(e.width,NY+lq(e.title))}:WY(e)}function WY(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}var GY=100,KY=[],$=null,qY=null;function JY(){for(let e of KY)e()}function YY(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 XY(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){qY!==null&&clearTimeout(qY),qY=null,e.sentTileIds=new Set(VY(e.view,e.lod).map(FY)),iX(e,t=>t.key.lod===e.lod&&!YY(t.rect,e.view))&&JY(),s({type:`whiteboard-view`,boardId:e.boardId,view:e.view,lod:e.lod,knownVersion:e.version})}function QY(e){qY===null&&(qY=setTimeout(()=>{qY=null,$===e&&ZY(e)},GY))}function $Y(e,t){for(let n of e.tiles.values())n.elementIds.delete(t)}function eX(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 tX(e){return VY(e.view,e.lod).every(t=>e.tiles.has(FY(t))||e.sentTileIds.has(FY(t)))}function nX(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 rX(e,t,n){let r=PY(n),i=$?.boardId!==e,a=i||!$?nX(e,t,r):$,o=a.lod!==r;$=a,a.view=t,a.lod=r,i||o||a.version===null||!tX(a)?ZY(a):QY(a)}function iX(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?(eX(e),e.assembled=null,!0):!1}function aX(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(FY(t.key),{key:t.key,rect:LY(t.key),elementIds:n,raster:t.raster?XY(t.raster):null})}function oX(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)aX(t,n);iX(t,()=>!0),t.assembled=null,JY()}}function sX(e,t){$Y(e,t.element.id);let n=UY(t.element),r=!1;for(let i of e.tiles.values())i.key.lod!==`blocks`&&YY(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 cX(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)$Y(t,n),t.elementById.delete(n);for(let n of e.diff.changed)sX(t,n);for(let n of e.diff.rasters){let e=t.tiles.get(FY(n.key));e&&(e.raster=n.raster?XY(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,JY()}}}function lX(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=jt(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 uX(e){if(!$||$.version===null)return;let t=e.get($.boardId);t===void 0?fX($.boardId):t!==$.version&&($.version=null,ZY($))}function dX(){$&&($.version=null,ZY($))}function fX(e){$?.boardId===e&&(qY!==null&&clearTimeout(qY),qY=null,$=null,JY())}function pX(e){KY.push(e)}var mX={"whiteboards-snapshot":e=>{bO(e),uX(new Map(e.boards.map(e=>[e.id,e.version])))},"whiteboard-removed":e=>{fX(e.boardId),xO(e)},"whiteboard-tiles":e=>oX(e),"whiteboard-tile-diff":e=>cX(e)},hX=`Worktree`,gX=`Worktree warning`,_X=_V([QV,$V,{"session-worktree-blocked":e=>{Tr({source:hX,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=>{Tr({source:gX,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=>{wr(hX,e.id),WC(e.id,e.base)},"session-diff":e=>{rb(e.id,e)},"session-diff-error":e=>{ib(e.id,e.message)},"change-map":e=>ab(e.id,e.map),"session-changed":e=>ob(e.id)},DV,mX,OV,kV]),vX=new Set([...Object.keys($V),...Object.keys(DV)]);function yX(e){let t=_X[e.type];t&&t(e)}function bX(){i(e=>{yX(e),oR(e.type)}),YV((e,t)=>{if(t.type===`snapshot`){oV(t.sessions,e);return}let n=t.type===`error`&&typeof t.id==`string`;(vX.has(t.type)||n)&&(yX(t),oR(t.type))})}function xX(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 SX(){ik({panels:xX(K),onScreenShown:e=>{aR(e),e!==`settings`&&JL(),e===`settings`&&!kF(location.hash)&&Fj(),tR(e)},canGoBack:e=>e===`settings`&&Bj()||e===`prs`&&D_(),onBack:e=>{e===`settings`&&Vj(),e===`prs`&&O_()},headerControls:[w(document,`.header-title`,`h1`),w(document,`#status-indicator`,`div`),w(document,`#celebration-tray`,`div`),cz,lz,dz]}),zj(pk),E_(pk)}function CX(e){if(e===`phone`){let e=W();for(let e of K)TL(e.view)?.deactivate?.();let t=kF(location.hash);ak({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}).then(e=>{e&&t&&Fj(null,null,location.hash),!e&&us()&&!sk()&&wR()});return}let t=ck();ok(),wR(),t&&yF(t)}function wX(){SX(),us()&&CX(`phone`),ds(CX)}function TX(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function EX(e){yF(e),sa(e),requestAnimationFrame(()=>requestAnimationFrame(()=>O.get(e)?.term?.focus()))}function DX(){let e=TX()??ta();e?la(e):document.getElementById(`btn-add-session-header`)?.click()}function OX({action:e,step:t}){switch(e){case`merge`:{let e=ta();return!e||JN()?!1:(fb(e),!0)}case`close-session`:{let e=ta();return e?(ea(e),!0):!1}case`board-split`:return qN()&&cP();case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return DX(),!0;case`next-attention`:return us()?!1:qN()?(QP(),!0):(xr()===`prs`&&k_()||wF(()=>q(`focus`)),!0);case`rail-step`:return qN()?(SF(t),!0):!1;case`view-step`:return!us()&&(mR(pR(xr(),t)),!0);case`session-nth`:return qN()?(xF(t),!0):!1;case`streamer-mode`:return xl(),!0}}function kX(e){return e.code!==`KeyZ`||e.altKey||e.shiftKey?!1:Ju===`mac`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function AX(){Xi(EX),document.addEventListener(`keydown`,e=>{if(e.repeat||Rt(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1;if(!t&&kX(e)&&!en()&&Ji()){e.preventDefault(),e.stopImmediatePropagation();return}let n=oi(e,Ju,{isTerminalFocused:t},Zu());n&&(en()||OX(n)&&e.preventDefault())})}function jX(){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))}),kL(()=>window.sessionStorage)}fo(ti()),mo(()=>{j(()=>import(`./alert-sound-At4lBeip.js`).then(e=>e.playNyanJingle(),e=>y(`alert-sound`,`nyan jingle failed to load: ${l(e)}`)),__vite__mapDeps([10,6]))}),vp(ri()),ls(),Sd(document),VB(),eV(),$D(s),j(()=>import(`./your-day-tip-_pFQLziL.js`).then(e=>e.startYourDayTips({openUsage:()=>KL(`usage`)}),e=>y(`your-day-tip`,`your day tips failed to load: ${l(e)}`)),__vite__mapDeps([66,13,4,3,64,62,5,6,7,8,14,65,21])),bv(s),gC(s),Zp(s),Ta(s),kn(V_),Ln(Ua),Ln(R_,`links`),Ln(HO,`links`),sn(WO),LO(qL),cn({isReadable:Wa,open:Ka}),mn(cw),_l(()=>oR(`settings-updated`)),bX(),Lz(),mz(),MR(),hz(),TR(),wX(),AX(),bk(),jX(),lv(w(document,`#health-footer-mount`,`div`)),Wu(BC),LB(),lp(),p();var MX=Si();MX&&b().then(()=>wu(MX));export{dM as $,$u as $a,Ng as $i,hE as $n,dC as $r,SO as $t,wI as A,Kp as Aa,O_ as Ai,rT as An,OE as Ar,OA as At,KF as B,Bp as Ba,ag as Bi,aD as Bn,ww as Br,Bk as Bt,IR as C,zm as Ca,yv as Ci,TT as Cn,bD as Cr,pA as Ct,WL as D,Cm as Da,b_ as Di,Iw as Dn,Kw as Dr,kA as Dt,HL as E,Sm as Ea,d_ as Ei,Fw as En,iD as Er,DA as Et,bI as F,Lp as Fa,m_ as Fi,nE as Fn,vD as Fr,aA as Ft,jF as G,of as Ga,vg as Gi,sD as Gn,dw as Gr,Lk as Gt,NF as H,Rp as Ha,Mg as Hi,uT as Hn,bw as Hr,Gk as Ht,xI as I,Yp as Ia,w_ as Ii,AE as In,EE as Ir,tA as It,yP as J,id as Ja,kg as Ji,dE as Jn,wC as Jr,wk as Jt,OF as K,bd as Ka,og as Ki,RT as Kn,uw as Kr,jk as Kt,pI as L,Xp as La,Wg as Li,Xw as Ln,nT as Lr,$k as Lt,hI as M,Vp as Ma,y_ as Mi,CT as Mn,rD as Mr,HA as Mt,mI as N,Gp as Na,T_ as Ni,ST as Nn,uE as Nr,oA as Nt,oL as O,om as Oa,x_ as Oi,xE as On,qw as Or,jA as Ot,yI as P,qp as Pa,A_ as Pi,oD as Pn,_D as Pr,sA as Pt,_M as Q,ed as Qa,Wh as Qi,lE as Qn,fC as Qr,gO as Qt,qF as R,Jp as Ra,Gg as Ri,Gw as Rn,hw as Rr,Zk as Rt,cB as S,Im as Sa,xv as Si,oT as Sn,Qw as Sr,sj as St,VL as T,Rm as Ta,h_ as Ti,iE as Tn,DE as Tr,QA as Tt,PF as U,vp as Ua,xg as Ui,WT as Un,Nw as Ur,Kk as Ut,GF as V,Up as Va,Vh as Vi,mT as Vn,xw as Vr,Uk as Vt,MF as W,Yf as Wa,Pg as Wi,UT as Wn,pw as Wr,Wk as Wt,mM as X,Qu as Xa,ig as Xi,cT as Xn,pC as Xr,GO as Xt,YM as Y,Ju as Ya,bg as Yi,sT as Yn,hC as Yr,qO as Yt,pM as Z,td as Za,Ig as Zi,yT as Zn,mC as Zr,JO as Zt,SH as _,Qm as _a,zb as _i,wE as _n,vo as _o,cE as _r,Dj as _t,wY as a,yg as aa,Gx as ai,CO as an,hl as ao,hT as ar,hM as at,HV as b,Fm as ba,Yv as bi,aT as bn,Ca as bo,SD as br,oj as bt,zJ as c,Oh as ca,Ex as ci,QD as cn,mc as co,HE as cr,Rj as ct,aY as d,ih as da,Mx as di,tO as dn,Ss as do,cD as dr,Aj as dt,Hh as ea,lC as ei,TO as en,Zu as eo,QT as er,cM as et,Xq as f,Ym as fa,$b as fi,eO as fn,us as fo,hD as fr,Mj as ft,yH as g,Vm as ga,Rb as gi,sO as gn,fo as go,oE as gr,Tj as gt,xH as h,Xm as ha,qb as hi,KD as hn,ho,mD as hr,Pj as ht,lX as i,Uh as ia,Ux as ii,OO as in,Hl as io,gT as ir,lM as it,gI as j,Hp as ja,C_ as ji,wT as jn,yD as jr,GA as jt,sL as k,sm as ka,g_ as ki,jE as kn,kE as kr,$A as kt,yY as l,Dh as la,jx as li,nO as ln,oc as lo,Jw as lr,Uj as lt,zU as m,th as ma,Yb as mi,qD as mn,yo as mo,FT as mr,Lj as mt,dX as n,Rg as na,LS as ni,_O as nn,Ul as no,uD as nr,uM as nt,SY as o,Og as oa,Nx as oi,FO as on,_l as oo,$E as or,Hj as ot,LU as p,rh as pa,Zb as pi,JD as pn,ds as po,LT as pr,Vj as pt,AF as q,ld as qa,Eg as qi,pE as qn,rw as qr,Ak as qt,rX as r,eg as ra,Xx as ri,jO as rn,Wl as ro,bE as rr,oM as rt,nY as s,Qh as sa,Ox as si,wO as sn,vl as so,QE as sr,Ej as st,pX as t,Lg as ta,uC as ti,vO as tn,ql as to,wD as tr,fM as tt,CY as u,Eh as ua,zx as ui,YD as un,Ks as uo,gD as ur,kj as ut,bH as v,Bm as va,Xv as vi,eD as vn,wa as vo,lD as vr,wj as vt,LR as w,Lm as wa,P as wi,aE as wn,UE as wr,AA as wt,EV as x,oh as xa,vv as xi,Uw as xn,CD as xr,aj as xt,JV as y,Zm as ya,Hv as yi,VT as yn,Ea as yo,tD as yr,Ij as yt,WF as z,zp as za,Rh as zi,Vw as zn,Tw as zr,Xk as zt};
76
+ `):e.judge?.notes[t]??null}function Gk(e){return e.series?.id??e.id}function Kk(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 qk=[],Jk=null,Yk=new Set;function Xk(e){Yk.add(e)}function Zk(){return qk}function Qk(e){qk=e.races;for(let e of Yk)e()}function $k(){return Jk}function eA(e){Jk=e.history;for(let e of Yk)e()}function tA(e){let t=nA(e.id);if(!t)return null;let n=Uk(Object.values(t.sessionIdByContestant),e=>O.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 nA(e){return qk.find(t=>Object.values(t.sessionIdByContestant).includes(e))??null}var rA=()=>{};function iA(e){rA=e.openTerminal}function aA(e){rA(e)}function oA({onAdd:e}){let t=T(`div`,`session-group-header`),n=T(`span`,`session-group-label`),r=T(`span`,`session-group-count`),i=T(`span`,`session-group-rule`);i.setAttribute(`aria-hidden`,`true`);let a=C({variant:`icon`,size:`small`,label:`Add session to this project`,icon:Ee(He),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 sA(e,t,{isHostShown:n=!1}={}){let{header:r,label:i,count:a,addButton:o}=e;qi(r,`path`,t.projectPath??``),qi(r,`label`,t.label),Bi(i,n&&t.hostName?`${t.hostName} / ${t.label}`:t.label),Bi(a,String(t.rows.length)),na(a,t.rows.length===0),na(o,t.projectPath===null)}var cA={waitingCount:0,finishedCount:0,failedCount:0},lA={failed:Dt[E.FAILED],waiting:Dt[E.WAITING],finished:Dt[E.COMPLETE]},uA={failed:`failed`,waiting:`needs you`,finished:`finished`},dA=[`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`],fA=2500,pA=`cubic-bezier(0.16, 1, 0.3, 1)`,mA=`cubic-bezier(0.5, 0, 0.2, 1)`,hA=260,gA=200,_A=200,vA=300,yA=28,bA=360,xA=420,SA=200,CA=3,wA=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),TA=new WeakMap;function EA(e){let t=TA.get(e);if(!t)throw Error(`attention banner was not built by buildAttentionBanner`);return t}function DA(e){return!document.hidden&&typeof e.animate==`function`&&e.getClientRects().length>0}function OA(){return wA?.matches??!1}function kA(e){return e.map(e=>({easing:pA,...e}))}function AA(e,t){let n=T(`div`,`attention-banner`);n.setAttribute(`role`,`status`),n.style.setProperty(`--attention-head-tile-px`,`${mr.headTile}px`),n.style.setProperty(`--attention-tile-px`,`${mr.tile}px`),n.style.setProperty(`--attention-tile-gap-px`,`${mr.tileGap}px`),n.style.setProperty(`--attention-overflow-px`,`${mr.overflowSlot}px`);let r=T(`span`,`attention-banner-chips`),i=T(`span`,`attention-tile-overflow`);i.setAttribute(`aria-hidden`,`true`),i.hidden=!0,r.append(i);let a=T(`span`,`attention-banner-line`);a.setAttribute(`aria-hidden`,`true`);let o=T(`span`,`attention-banner-status`);o.append(r,T(`span`,`attention-banner-count`),a);let s=Ve(`attention-banner-jump-row`);return s.append(o),t&&(t.classList.add(`attention-banner-jump`),s.append(t)),n.addEventListener(`click`,()=>e.onJump()),n.append(s),TA.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),jA(n,cA,[]),n}function jA(e,t,n){let r=EA(e);r.tiles=n,Bi(zt(e,`.attention-banner-count`),gr(t));let i=n.length>0;e.toggleAttribute(`data-empty`,!i),e.toggleAttribute(`data-jumpable`,i),i&&JA(e,r),MA(e)}function MA(e){let t=EA(e),n=zt(e,`.attention-banner-chips`),r=zt(n,`.attention-tile-overflow`),i=DA(e),a=t.tiles.slice(0,ir(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():IA(n,l[r])});let u=t.headId,d=[],f=null;a.forEach((i,a)=>{let o=t.tileById.get(i.id),s=o??PA(e,i.id);o||(t.tileById.set(i.id,s),d.push(s)),FA(s,i,a===0),(s.parentElement!==n||NA(s)!==f)&&n.insertBefore(s,r),f=s});let p=t.tiles.length-a.length;na(r,p===0),Bi(r,`+${p}`),Hi(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)&&BA(e,null),i){for(let e of d)LA(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?zA(r,a):a!==0&&RA(r,a,n)})}}function NA(e){let t=e.previousElementSibling;for(;t?.hasAttribute(`data-leaving`);)t=t.previousElementSibling;return t}function PA(e,t){let n=T(`span`,`attention-tile`);n.setAttribute(`role`,`img`),n.dataset.id=t;let r=T(`span`,`attention-tile-icon`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n.addEventListener(`pointerenter`,()=>BA(e,t)),n.addEventListener(`pointerleave`,()=>BA(e,null)),n}function FA(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}, ${uA[n]}`:`${r}, ${uA[n]}, passed on: ${a}`;Hi(e,`aria-label`,o),kr(zt(e,`.attention-tile-icon`),lA[n])}function IA(e,t){e.toggleAttribute(`data-leaving`,!0),e.style.left=`${t.left}px`,e.style.top=`${t.top}px`;let n=OA()?[{opacity:1},{opacity:0}]:kA([{transform:`none`,opacity:1},{transform:`scale(0.6)`,opacity:0}]),r=e.animate(n,{duration:_A,fill:`forwards`});r.onfinish=()=>e.remove(),r.oncancel=()=>e.remove()}function LA(e){let t=OA()?[{opacity:0},{opacity:1}]:kA([{transform:`scale(0.6)`,opacity:0},{transform:`none`,opacity:1}]);e.animate(t,{duration:gA})}function RA(e,t,n){OA()||e.animate(kA([{transform:`translateX(${t}px)`},{transform:`none`}]),{duration:vA,delay:n*yA,fill:`backwards`})}function zA(e,t){OA()?e.animate([{opacity:.35},{opacity:1}],{duration:bA,easing:pA}):e.animate(kA([{transform:`translateX(${t}px) scale(0.8)`,filter:`brightness(1.8)`},{transform:`scale(1.1)`,offset:.6},{transform:`none`,filter:`none`}]),{duration:bA})}function BA(e,t){let n=EA(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 VA(e){return!e||e.getClientRects().length===0?null:e.getBoundingClientRect()}function HA(e,t,n){let r=EA(e);if(r.flyingIds.has(t))return;let i=r.tileById.get(t);if(!i||!DA(e)){n();return}BA(e,null),r.flyingIds.add(t);let a=r.hooks.rowFor(t),o=i.getBoundingClientRect(),s=VA(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(UA(o,s),WA(s)),u=()=>{c.remove(),r.flyingIds.delete(t),i.isConnected&&(i.style.visibility=``),n()};l.onfinish=u,l.oncancel=u}function UA(e,t){return!t||OA()?[{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 WA(e){return!e||OA()?{duration:SA,fill:`forwards`}:{duration:xA,easing:mA,fill:`forwards`}}function GA(e){let t=EA(e);e.hasAttribute(`data-empty`)&&qA(e,t);for(let e of t.pressAnimations)e.cancel();if(t.pressAnimations=[],!DA(e))return;let n={duration:hA};if(t.pressAnimations.push(e.animate(kA([{opacity:0},{opacity:.07,offset:.3},{opacity:0}]),{...n,pseudoElement:`::after`})),!OA()){t.pressAnimations.push(e.animate(kA([{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(kA([{transform:`none`},{transform:`translateY(${CA}px)`,offset:.3},{transform:`none`}]),n),r.animate(kA([{transform:`none`},{transform:`translateY(-${CA}px)`,offset:.3},{transform:`none`}]),{...n,pseudoElement:`::after`}))}}function KA(e){let t=dA.filter(t=>t!==e);return t[Math.floor(Math.random()*t.length)]??dA[0]}function qA(e,t){let n=KA(t.lastAllClearLine);t.lastAllClearLine=n,zt(e,`.attention-banner-line`).textContent=n,e.toggleAttribute(`data-all-clear-line`,!0),t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=window.setTimeout(()=>JA(e,t),fA)}function JA(e,t){t.allClearLineTimer!==null&&window.clearTimeout(t.allClearLineTimer),t.allClearLineTimer=null,e.toggleAttribute(`data-all-clear-line`,!1)}var YA=new WeakMap;function XA(e){let t=YA.get(e);if(!t)throw Error(`attention ledger was not built by buildAttentionLedger`);return t}function ZA(e){return e.flatMap(e=>Vn(e.id).map(t=>({sessionId:e.id,seq:t.seq,ts:t.ts,text:`${e.name??``}: ${yr(t)}`}))).sort((e,t)=>t.ts-e.ts).map(({sessionId:e,seq:t,text:n})=>({sessionId:e,seq:t,text:n}))}function QA(e){let t=T(`div`,`attention-ledger`);t.hidden=!0;let n=C({variant:`quiet`,size:`small`,label:`Answers`,onClick:()=>ej(t)});n.classList.add(`attention-ledger-answers`),n.setAttribute(`aria-expanded`,`false`);let r=T(`ol`,`attention-ledger-list`);return r.hidden=!0,t.append(T(`span`,`attention-ledger-count`),n,r),YA.set(t,{onOpenSession:e,rows:[],openEntries:null}),t}function $A(e,t){let n=XA(e);n.rows=t;let r=(n.openEntries??ZA(t)).length;Bi(zt(e,`.attention-ledger-count`),sr(r)),na(e,r===0)}function ej(e){let t=XA(e);if(t.openEntries){tj(e);return}let n=ZA(t.rows);t.openEntries=n,zt(e,`.attention-ledger-answers`).setAttribute(`aria-expanded`,`true`);let r=zt(e,`.attention-ledger-list`);r.replaceChildren(...n.map(n=>{let r=Ve(`attention-ledger-item`,n.text);return r.addEventListener(`click`,()=>{tj(e),t.onOpenSession(n.sessionId)}),nj(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)Pn(e,t)}function tj(e){let t=XA(e);t.openEntries=null,zt(e,`.attention-ledger-answers`).setAttribute(`aria-expanded`,`false`);let n=zt(e,`.attention-ledger-list`);n.hidden=!0,n.replaceChildren(),$A(e,t.rows)}function nj(e){let t=T(`li`);return t.append(e),t}var rj=[],ij=new Set;function aj(e){let t=at.safeParse(e);if(t.success){rj=t.data;for(let e of ij)e()}}function oj(e){return rj.find(t=>t.agent===e)??null}function sj(e){return ij.add(e),()=>{ij.delete(e)}}var cj=2e3,lj={},uj=null,dj=null,fj=Ze,pj=null,mj=!1,hj=null,gj=[],_j=null,vj=()=>null,yj=()=>{},bj=!1,xj=new Set,Sj=new Set;function Cj(e){for(let t of Sj)t(e)}function wj(e){Sj.add(e)}function Tj(){return lj}function Ej(e){return lj={...lj,...e},lj}function Dj(){return{status:uj,journal:dj,request:fj,lastAutoCheckAt:pj,isCheckInFlight:mj,checkSendFailure:hj}}function Oj(e){let t=ke(fj,e);t!==fj&&(fj=t,Cj({kind:`update`,frame:`request`}))}function kj(){Oj(s({type:`update-apply`})?`request-sent`:`request-unsent`)}function Aj(){pj=Date.now();let e=s({type:`update-check`});mj=e,hj=e?null:x,Cj({kind:`update`,frame:`request`})}function jj(e){yj=e}function Mj(){yj()}function Nj(e){gj=[...e]}function Pj(){return gj}function Fj(e=null,t=null,n=null){let r=_j!==null&&(_j.sectionId!==null||_j.isLink);e===null&&n===null&&r||(_j={sectionId:e,settingId:t,hashAtRequest:n??location.hash,isLink:n!==null},Cj({kind:`activate`}))}function Ij(){let e=_j;return _j=null,e}function Lj(e){vj=e}function Rj(){for(let e of xj)e()}function zj(e){xj.add(e)}function Bj(){return us()&&vj()===`section`}function Vj(){Bj()&&Cj({kind:`return-to-list`})}function Hj(e){e&&(lj=e,aj(lj.agentLogins),Cj({kind:`broadcast`}))}function Uj(){bj||(bj=!0,window.setTimeout(()=>{c(`get-settings`,{}).then(e=>{e.settings&&Hj(e.settings)}).catch(()=>{bj=!1})},cj))}function Wj(){Cj({kind:`status`})}function Gj(e){Wj()}function Kj(e){uj=e,mj=!1,hj=null,fj=ke(fj,`status-frame`),Cj({kind:`update`,frame:`status`})}function qj(e){dj=e,fj=ke(fj,`progress-frame`),Cj({kind:`update`,frame:`progress`})}function Jj(e){if(e.scope!==`update`)return!1;let t=Pe(e.message),n=fj.requested;return fj=ke(fj,`error-frame`,t),mj=!1,n||(hj=t),Cj({kind:`update`,frame:`error`}),!0}var Yj=[`terminal`,`board`],Xj=.05,Zj=`application/x-glimmervoid-board-pane`,Qj=`input, textarea, select, button, [contenteditable="true"]`;function $j(){let e=fi(),t=new Set([`terminal`]),n=!1,r=[],i=T(`div`,`pane-layout`),a=T(`div`,`pane-trail`),o=T(`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=T(`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=T(`section`,`pane-group`);t.dataset.pane=e;let n=T(`div`,`pane-strip pane-header`),r=T(`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(Qj)?e.preventDefault():(e.dataTransfer?.setData(Zj,`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 Fi(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(ii(e,i))})}function m(t){t!==e&&(e=t,qr(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 Yj)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=Gr(e,v(t)),_())});let y=t=>{o.hasPointerCapture(t.pointerId)&&(o.releasePointerCapture(t.pointerId),delete o.dataset.dragging,qr(e))};return o.addEventListener(`pointerup`,y),o.addEventListener(`pointercancel`,y),o.addEventListener(`keydown`,t=>{let n={ArrowLeft:-.05,ArrowUp:-.05,ArrowRight:Xj,ArrowDown:Xj}[t.key];n!==void 0&&(t.preventDefault(),m(Gr(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 eM=[],tM=new Set,nM=new WeakSet,rM=null,iM=null;function aM(e){eM.some(t=>t.id===e.id)||(eM.push(e),sM(e.id,null))}function oM(){return eM}function sM(e,t){for(let n of tM)n(e,t)}function cM(e){return tM.add(e),()=>tM.delete(e)}function lM(e){e!==rM&&(pM(),rM=e)}function uM(e){rM===e&&(pM(),rM=null)}function dM(e,t){return iM?.page.id===e&&iM.sessionId===t}function fM(e,t,n=null){let r=eM.find(t=>t.id===e);if(!r||!rM||rM.sessionId()!==t||!r.isAvailableFor(t)||dM(e,t)&&n===null)return;pM();let i=rM,a=i.elementFor(r);gM(a),iM={page:r,sessionId:t},r.mount(a,t,{placement:i.placement,target:n}),i.didShow(r),sM(r.id,t)}function pM(){if(!iM)return;let{page:e,sessionId:t}=iM;iM=null,e.unmount(),rM?.didHide(e),sM(e.id,t)}function mM(){return iM?.page.canStepBack()??!1}function hM(){return iM?iM.page.canStepBack()?(iM.page.stepBack(),!0):(pM(),!0):!1}function gM(e){nM.has(e)||(nM.add(e),e.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Rt(e)||hM()&&e.preventDefault()}))}function _M({style:e}){let t=T(`div`,`session-page-bar session-page-bar-${e}`),n=new Map,r=null;function i(n){let i=e===`header`,a=Ee(n.iconPath),o=`${i?`open`:`show`}-${n.id}`,s=C({variant:`icon`,size:i?`small`:void 0,label:n.label,icon:a,action:o});s.addEventListener(`click`,()=>{r&&fM(n.id,r)});let c=T(`span`,`session-page-dot`);c.setAttribute(`aria-hidden`,`true`);let l=T(`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 eM)a(e)}return cM((e,t)=>{if(t!==null&&t!==r)return;let n=eM.find(t=>t.id===e);n&&a(n)}),o(),{element:t,showSession(e){r=e,o()}}}var vM=5,yM={high:`High`,medium:`Medium`,low:`Low`};function bM(e,t){let n=Ve(`review-look-line`,e.path);return n.append(T(`span`,`review-look-detail`,e.detail)),n.addEventListener(`click`,()=>t(e.openPath)),n}function xM(e,t){let n=T(`div`,`review-look-group`);n.dataset.kind=e.kind;let r=T(`p`,`review-look-text`,e.heading);if(e.conflictRisk){let t=T(`span`,`review-look-risk`,`Conflict risk: ${yM[e.conflictRisk]}`);t.dataset.risk=e.conflictRisk,r.append(` `,t)}n.append(r);for(let r of e.lines)n.append(bM(r,t));return n}function SM(e,{isShowingAll:t,onShowAll:n,onOpenFile:r}){if(e.worthALook.length===0&&e.errors.length===0)return null;let i=T(`section`,`review-look`);if(i.append(T(`h3`,`review-group-label`,`Worth a look`)),e.errors.length>0){let t=T(`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,vM);if(a.length>0){let e=T(`div`,`review-look-list`);for(let t of a)e.append(xM(t,r));i.append(e)}let o=e.worthALook.length-a.length;if(o===0)return i;let s=T(`div`,`review-look-more`),c=C({variant:`quiet`,size:`small`,label:`Show all`,action:`show-all-worth-a-look`,onClick:n});return s.append(T(`span`,`review-look-more-count`,`+${o} more`),c),i.append(s),i}function CM(e){return(e??[]).map(e=>T(`span`,`review-file-hint`,e.text))}var wM=`changes`,TM={add:`+`,del:`-`,meta:`\\`},I=null,EM=null,L=null,R=null,DM=null,OM=!1;function kM(){let e=T(`section`,`review-reader`);e.setAttribute(`aria-label`,`Changes`),e.tabIndex=-1,e.hidden=!0;let t=T(`div`,`review-reader-bar`),n=T(`p`,`review-reader-status`);n.setAttribute(`role`,`status`);let r=T(`p`,`review-reader-notice`);r.setAttribute(`role`,`status`);let i=T(`div`,`review-reader-actions`),a=C({variant:`primary`,label:`Merge`,action:`merge-session`,onClick:()=>{L&&fb(L)}}),o=C({variant:`danger`,label:`Discard`,action:`discard-session`,onClick:()=>{L&&pb(L)}}),s=C({variant:`secondary`,label:`Close`,action:`close-reader`,onClick:pM});i.append(a,o,s),t.append(n,r,i);let c=T(`div`,`review-reader-body`),l=T(`div`,`review-reader-files`),u=T(`div`,`review-reader-diff`);return c.append(l,u),e.append(t,c),e.addEventListener(`keydown`,jM),Gy(e=>{e===L&&FM()}),Gi(()=>{R=null,OM=!1,FM(),MM()}),gb(e),{root:e,status:n,notice:r,mergeButton:a,discardButton:o,closeButton:s,fileColumn:l,diff:u}}function AM(){return I??=kM(),I}function jM(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||Rt(e))return;let t=e.key===`j`?1:e.key===`k`?-1:0;if(t===0||!L)return;e.preventDefault();let n=Ty(Xy(L)?.files??[],R,t);n&&NM(n)}function MM(){L&&sM(wM,L)}function NM(e){R=e,FM(),I?.fileColumn.querySelector(`.review-reader-file[aria-current="true"]`)?.scrollIntoView({block:`nearest`}),MM()}function PM(e){let t=wy(e,DM);t&&(R=t.path,DM=null),wy(e,R)||(R=EM===`overlay`?e[0]?.path??null:null)}function FM(){if(!I||EM===null)return;L=ta();let e=L?Xy(L):null;if(I.closeButton.hidden=EM!==`overlay`,!e){IM(I);return}let t=R!==null;PM(e.files),I.status.textContent=e.sentence;let n=e.notice??(e.isMergeShown&&!e.isMergeEnabled?e.mergeRefusal:null);I.notice.textContent=n??``,I.notice.hidden=n===null,I.mergeButton.hidden=!e.isMergeShown,I.mergeButton.disabled=!e.isMergeEnabled,I.discardButton.hidden=!e.isDiscardShown,I.root.dataset.level=EM===`screen`&&R!==null?`diff`:`list`,LM(I.fileColumn,e),VM(I.diff,wy(e.files,R)),t!==(R!==null)&&MM()}function IM(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 LM(e,t){let n=e.scrollTop;if(e.replaceChildren(),t.diffError){e.append(T(`p`,`review-diff-error`,t.diffError));return}if(t.isEmpty){e.append(T(`p`,`review-empty-title`,t.sentence));return}t.totals.files>0&&e.append(RM(t.totals));let r=T(`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?dy(i,e.path):null;n&&n!==a&&r.append(T(`div`,`review-repo-label`,n)),a=n,r.append(zM(e,t))}e.append(r);let o=t.changeMapView?SM(t.changeMapView,{isShowingAll:OM,onShowAll:HM,onOpenFile:UM}):null;o&&e.append(o),e.scrollTop=n}function RM(e){let t=T(`p`,`review-reader-totals`);return t.append(T(`span`,`review-stat-files`,`${e.files} file${e.files===1?``:`s`}`),T(`span`,`review-add`,`+${e.added}`),T(`span`,`review-del`,`-${e.removed}`)),t}function zM(e,t){let n=Ve(`review-reader-file`);n.dataset.path=e.path,n.setAttribute(`role`,`listitem`),n.setAttribute(`aria-current`,String(e.path===R));let r=T(`span`,`review-file-name`);r.append(T(`span`,`review-file-path`,e.path));let i=CM(t.changeMapView?.hintsByOpenPath.get(e.path));if(i.length>0){let e=T(`span`,`review-file-hints`);e.append(...i),r.append(e)}return n.append(r,BM(e)),n.addEventListener(`click`,()=>NM(e.path)),n}function BM(e){let t=T(`span`,`review-file-counts`);return e.binary?(t.append(T(`span`,`review-bin`,`bin`)),t):(t.append(T(`span`,`review-add`,`+${e.added}`),T(`span`,`review-del`,`-${e.removed}`)),t)}function VM(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=T(`div`,`review-reader-diff-head`);if(r.append(T(`span`,`review-file-path`,t.path),BM(t)),e.append(r),t.binary){e.append(T(`div`,`review-file-binary`,`Binary file not shown`));return}let i=T(`div`,`review-file-body`);for(let e of t.hunks){i.append(T(`div`,`review-hunk-head`,e.header));for(let t of e.lines){let e=T(`div`,`review-line review-line-${t.type}`);e.append(T(`span`,`review-line-gutter`,TM[t.type]??` `),T(`span`,`review-line-text`,t.text)),i.append(e)}}e.append(i),e.scrollTop=n}function HM(){OM=!0,FM()}function UM(e){let t=wy(L?Xy(L)?.files??[]:[],e);t&&NM(t.path)}function WM(e,t){let{root:n}=AM();n.parentElement!==e&&e.append(n),EM=t,n.dataset.placement=t,n.hidden=!1}function GM(){I&&(I.root.hidden=!0,I.root.remove(),EM=null)}function KM(){R!==null&&(R=null,FM(),MM())}function qM(e,t){t===`header`&&(gb(e),new MutationObserver(hb).observe(e,{attributes:!0,attributeFilter:[`data-slot-held`]}))}Gy(e=>sM(wM,e));var JM={id:wM,label:`Changes`,iconPath:$e,isAvailableFor:e=>Xy(e)!==null,hasUnreadFor:()=>!1,mount(e,t,{placement:n,target:r}){WM(e,n),DM=r,FM(),n===`overlay`&&AM().root.focus({preventScroll:!0})},unmount:GM,canStepBack:()=>EM===`screen`&&R!==null,stepBack:KM,attachButton:qM};function YM(){aM(JM)}var XM=`This machine`,ZM=null,QM=new Map;function $M(){let e=T(`div`,`rail-host-header`),t=T(`span`,`rail-host-label`),n=T(`span`,`rail-host-state`);return e.append(t,n),{header:e,label:t,stateText:n}}function eN(e,t,n,r){Bi(e.label,t),qi(e.header,`state`,n),Bi(e.stateText,r),na(e.stateText,r===``)}function tN(e,t,n){t.parentElement===e&&(n?t.nextElementSibling===n:e.lastElementChild===t)||e.insertBefore(t,n)}function nN(e){for(let[t,n]of[...QM])e.has(t)||(n.header.remove(),QM.delete(t))}function rN(e,{firstGroupHeaderOf:t,trailingNode:n}){let r=oc();if(nN(new Set(r.map(e=>e.id))),r.length===0){ZM?.header.remove();return}let i=n;for(let n of r.toReversed()){let r=QM.get(n.id)??$M();QM.set(n.id,r),eN(r,n.name,n.state,sc(n)),tN(e,r.header,t(n.id)??i),i=r.header}ZM??=$M(),eN(ZM,XM,`local`,``),tN(e,ZM.header,t(null)??i)}var iN=new Set([`terminal`]),aN=new Set([`terminal`,`board`]),oN=new Set([`board`]),sN=e=>e.ui.path,cN=e=>mc(e.id),lN=`application/x-glimmervoid-board-row`,uN=`application/x-glimmervoid-session-row`,dN=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),fN=null,pN=null,mN=null,hN=null,gN=null,z=null,_N=null,vN=null,yN=null,bN=null,xN=null,B=null,SN=Ii(),CN=null,wN=`terminal`,TN=null,EN=new Map,DN=new Map,ON=null,kN=null,AN=null,V=!1,jN=!1,MN=null,NN=new Map,H=new Map,PN=new Map,FN=new Map,U=null,IN=``,LN=[],RN=null,zN=new Map,BN=new Map,VN=new Set;function HN(){return ni(WN(gP()),VN)}function UN(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 WN(e){return _i(e,sN,tA,cN)}function GN(e,t){let n=e.find(e=>e.hostId===t);return n?FN.get(n.key)?.header??null:null}function KN(e){let t=FN.get(e.key),n=PN.get(e.key);return t&&n||(t=oA({onAdd:Qi}),n=T(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),FN.set(e.key,t),PN.set(e.key,n)),sA(t,e),Hi(n,`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function qN(){return V}function W(){return A.snapshot().focusedSessionId}function JN(){return V&&B!==null}function YN({rail:e,center:t,resizer:n}){if(fN=e,hN=t,!fN||!hN)return;let r=fN,i=hN;pP(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,zi(Ju)),pN=AA({onJump:QP,rowFor:e=>H.get(e)},ed());let a=T(`details`,`rail-section rail-status-key`);a.append(T(`summary`,`rail-section-summary`,`Status key`),Ak()),VP(a,Zr(),hi),mN=QA(mF),r.append(pN,mN,a),ON=T(`div`,`focus-empty`),ON.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,kN=ON.querySelector(`.focus-empty-title`),AN=ON.querySelector(`.focus-empty-desc`),z=$j(),gN=z.bodyOf(`terminal`),z.bodyOf(`board`).tabIndex=-1,z.onBoardDrag(rP),TN=T(`div`,`rail-unsplit-slot`,`Drop here to unsplit`),YM(),_N=_M({style:`header`}),z.trailSlot.append(_N.element),i.append(ON,z.element),i.addEventListener(`focusin`,tP),Xk(()=>{V&&G()}),_O(()=>{if(!V)return;let e=B!==null;G(),e&&B===null&&TF()}),r.addEventListener(`keydown`,mP),r.addEventListener(`dragover`,aP),r.addEventListener(`drop`,oP)}function XN(){let e=gO(),t=Li(SN,e);QN(CN?di(t,e,CN,ZN):t),CN=yi(e)}_O(XN);function ZN(e){return O.has(e)}function QN(e){e!==SN&&(SN=e,pi(e))}function $N(){return ci(SN,gO(),ZN)}function eP(e){return e?$N()[e]??null:null}function tP(e){let t=e.target instanceof Element?e.target.closest(`.pane-group`)?.dataset.pane:void 0;if(t!==`terminal`&&t!==`board`||t===wN)return;wN=t;let n=W(),r=n?H.get(n):void 0;n&&r&&LP(r,n,IP())}function nP(){return z?.element.hasAttribute(`data-dragging`)===!0}function rP(){if(!TN)return;let e=W(),t=e&&eP(e)?H.get(e)?._row:void 0;!nP()||!t?(TN.removeAttribute(`data-over`),TN.remove()):t.nextElementSibling!==TN&&t.after(TN)}function iP(){return nP()&&TN?.isConnected===!0}function aP(e){iP()&&(e.preventDefault(),TN?.toggleAttribute(`data-over`,!0))}function oP(e){let t=W();iP()&&t&&(e.preventDefault(),wN=`terminal`,QN(Ti(SN,t)),G(),eF(O.get(t),t))}function sP(e){if(!V||!e||B)return null;let t=$N();if(Object.hasOwn(t,e))return{sessionId:e,boardIdToOpen:null};let n=Ni(t,MO(e));return n?{sessionId:e,boardIdToOpen:n.id}:null}Ku(()=>sP(W())!==null);function cP(){let e=sP(W());return e?e.boardIdToOpen?(QN(Ri(SN,e.sessionId,e.boardIdToOpen)),G(),!0):(wN=`terminal`,QN(Ti(SN,e.sessionId)),G(),eF(O.get(e.sessionId),e.sessionId),!0):!1}function lP(e,t){let n=gO().find(e=>e.id===t);n&&O.has(e)&&(n.connectedSessionIds.includes(e)||EO(t,e).then(uP),QN(Ri(SN,e,t)),W()===e?G():mF(e))}function uP(e){e.ok||y(`focus`,`connecting a dropped board failed: ${e.error}`)}var dP={minPx:280,maxPx:480},fP=16;function pP(e){e&&fN&&wk({resizer:e,column:fN,widthHost:fN,widthProperty:`--rail-width`,bounds:dP,keyStepPx:fP,getStoredWidth:vi,setStoredWidth:ji})}function mP(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(),ea(n);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=hP(),n=t.find(t=>t===e.target)??(U?H.get(U):null),r=n?t.indexOf(n):-1,i=_r(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&&UN(a.dataset.id),a.focus())}function hP(){return fN?[...fN.querySelectorAll(`button.session-row[data-id], button.session-row[data-board-id]`)].filter(e=>!e.closest(`details:not([open])`)):[]}function gP(){return rr(aa(bP),_P())}function _P(){return er(Tj())}function vP(e){let t=_P();t.includes(e)&&Ej({sessionOrder:t.filter(t=>t!==e)})}function yP(e,t){let n=_P(),r=e=>{Ej({sessionOrder:e}),t()};r(e),c(`update-settings`,{settings:{sessionOrder:e}}).then(e=>{e.type===`settings-error`&&r(n)}).catch(()=>r(n))}wj(e=>{e.kind===`broadcast`&&G()});function bP(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function xP(e){let{row:t,refs:n}=Mn();t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,t=>MP(e,SP(t.target))),t.addEventListener(`pointerenter`,()=>{pN&&BA(pN,e)}),t.addEventListener(`pointerleave`,()=>{pN&&BA(pN,null)});let{item:r,removeButton:i}=An(t,()=>ea(e),()=>Vi(e));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,wP(r,e),jP(t,r,e),Object.assign(t,{_refs:n,_row:r})}function SP(e){return(e instanceof Element?e.closest(`[data-member]`)?.dataset.member:void 0)===`board`?`board`:`terminal`}function CP(e){return e.dataTransfer?.types.includes(lN)===!0}function wP(e,t){e.addEventListener(`dragover`,t=>{CP(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(lN);r&&(n.preventDefault(),lP(t,r))})}function TP(e){return RN!==null&&e.dataTransfer?.types.includes(uN)===!0}function EP(e){let t=RN?zN.get(RN):void 0,n=zN.get(e);return!t||!n?!1:cr(t,n,e=>BN.get(e.id)??``,new Set(zN.keys()))}function DP(e,t){let n=e.getBoundingClientRect();return t.clientY<n.top+n.height/2?`before`:`after`}function OP(){return LN.flatMap(e=>zN.get(e)??[])}function kP(){for(let e of fN?.querySelectorAll(`.session-row-item[data-drop-target]`)??[])delete e.dataset.dropTarget}function AP(e,t){let n=H.get(lr(OP(),e,t))?._row;n?.dataset.dropTarget!==t&&(kP(),n&&(n.dataset.dropTarget=t))}function jP(e,t,n){e.draggable=!0,e.addEventListener(`dragstart`,e=>{RN=n,e.dataTransfer?.setData(uN,n),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`)}),e.addEventListener(`dragend`,()=>{RN=null,kP()}),t.addEventListener(`dragover`,e=>{TP(e)&&EP(n)&&(e.preventDefault(),AP(n,DP(t,e)))}),t.addEventListener(`dragleave`,e=>{e.relatedTarget instanceof Node&&fN?.contains(e.relatedTarget)||kP()}),t.addEventListener(`drop`,e=>{kP(),TP(e)&&EP(n)&&RN&&(e.preventDefault(),yP(Jn(OP(),_P(),RN,n,DP(t,e)),G),RN=null)})}function MP(e,t=`terminal`){let n=ia(e);if(!n)return;wN=t===`board`&&eP(e)?`board`:`terminal`,mF(e);let r=H.get(e);r&&LP(r,e,IP()),wN===`board`?NP(e):eF(n,e)}function NP(e){requestAnimationFrame(()=>requestAnimationFrame(()=>{V&&W()===e&&z?.bodyOf(`board`).focus({preventScroll:!0})}))}function PP(e){let t=ia(e);t&&FP(t,e)}function FP(e,t){mF(t),eF(e,t)}function IP(){return new Map(gO().map(e=>[e.id,e.title]))}function LP(e,t,n){let r=eP(t),i=r?n.get(r)??null:null,a=r&&i!==null?{id:r,title:i}:null;bn(e,a,t===W()&&a!==null?wN:null)}function RP(e,{id:t,ui:n,state:r,name:i},a){let o=NN.get(t)||`none`;e.classList.toggle(`focused`,t===W()),Dn(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:o===`none`?``:o,attentionPosition:a});let s=t===U;Hi(e,`aria-selected`,String(s)),Hi(e,`tabindex`,s?`0`:`-1`)}function zP(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||``:Ir(r._refs?.glyph))}Ar(zP),Lr((e,t)=>{if(!V)return;let n=H.get(e);n&&Bi(n._refs.elapsed,Fr(t))});var BP=new Map;function G(e){if(!V)return;let t=fN;if(!t)return;let n=gP(),r=WN(n);zN=new Map(n.map(e=>[e.id,e])),BN=new Map(r.groups.flatMap(e=>e.rows.map(t=>[t.id,e.key])));let i=gO();B&&!i.some(e=>e.id===B)&&(B=null);let a=new Map(r.groups.filter(e=>e.hostId===null).flatMap(e=>e.rows.map(t=>[t.id,e.key]))),o=Oi(i,$N(),a),s=Hr(r,o.keys()),c=new Map(i.map(e=>[e.id,e.title])),l=new Set,u=new Set,d=vr(n,W()),f=new Map(d.map(({id:e},t)=>[e,t+1])),p=(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;u.add(t);let r=H.get(t),i=!r;r||(r=xP(t),H.set(t,r));let a=f.get(t)??null;(!e||i||e.has(t)||BP.get(t)!==a)&&RP(r,n,a),LP(r,t,c),BP.set(t,a)}a||Yi(n,[...t.flatMap(({id:e})=>H.get(e)?._row??[]),...r]),n._lastOrderKey=i},m=new Set(s.order),h=s.groups.map(e=>e.key).join(`
77
+ `),g=h===IN;IN=h;for(let e of s.groups){let{header:n,list:r}=KN(e);g||t.append(n,r);let i=e.hostId===null?o.get(e.key):void 0;p(e.rows,r,i?KP(e.key,i,l):[])}qP(l,m),rN(t,{firstGroupHeaderOf:e=>GN(s.groups,e),trailingNode:null});for(let[e,t]of[...FN])m.has(e)||(t.header.remove(),PN.get(e)?.remove(),FN.delete(e),PN.delete(e));for(let[e,t]of H)u.has(e)||(t._row.remove(),H.delete(e),BP.delete(e),e===U&&(U=null));for(let e of[...NN.keys()])O.has(e)||NN.delete(e);let _=LN;LN=ni(r,VN);let v=W();if(v&&!ra(v)){pM(),A.dispatch(`focusSession`,null),U=null;let e=YP(_,v);if(e){let t=!document.activeElement||document.activeElement===document.body;mF(e),t&&eF(O.get(e),e);return}}hF();let y=W();if(y){let e=O.get(y);e&&e.card.parentElement!==gN&&nF(e,y)}_N?.showSession(B?null:y),sF(),rP(),ZP(n,d)}function VP(e,t,n){e.open=t,e.addEventListener(`toggle`,()=>n(e.open))}function HP(e){let{row:t,refs:n}=Mn();t.dataset.boardId=e,t.draggable=!0,t.addEventListener(`click`,()=>JP(e)),t.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(lN,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`link`)});let r=T(`div`,`session-row-item`);return r.dataset.boardNode=e,r.append(t),Object.assign(t,{_refs:n,_row:r})}function UP(e){let t=T(`details`,`focus-board-archive`);t.dataset.boardNode=`archive:${e}`;let n=T(`div`,`focus-board-archive-list`);return t.append(T(`summary`,`focus-board-archive-summary`,`Archived`),n),{details:t,list:n}}function WP(e){let t=e.connectedSessionIds.map(e=>O.get(e)).find(e=>e!==void 0);return t?bP(t):null}function GP(e,t){let n=EN.get(e.id);return n||(n=HP(e.id),EN.set(e.id,n)),Fn(n,n._refs,e.title,WP(e)),n.classList.toggle(`focused`,e.id===B),t.add(e.id),n._row}function KP(e,t,n){let r=t.active.map(e=>GP(e,n));if(t.archived.length===0)return r;let i=DN.get(e)??UP(e);return DN.set(e,i),Yi(i.list,t.archived.map(e=>GP(e,n))),[...r,i.details]}function qP(e,t){for(let[t,n]of EN)e.has(t)||(n._row.remove(),EN.delete(t));for(let[e,n]of DN)t.has(e)&&n.list.childElementCount>0||(n.details.remove(),DN.delete(e))}function JP(e){V&&(pF(),B=e,UN(null),G())}function YP(e,t){let n=e.filter(e=>e===t||ra(e));if(n.length<2)return LN.find(e=>ra(e))??null;let r=n.indexOf(t)===n.length-1;return _r(n,t,r?-1:1)}function XP(){return vr(gP(),W())}function ZP(e,t){pN&&(jA(pN,pr(e),t),mN&&$A(mN,e))}function QP(){if(!V)return;pN&&GA(pN);let e=XP()[0]?.id;e&&$P(e)}function $P(e){V&&(ia(e),H.get(e)?.scrollIntoView({block:`nearest`}),pN&&HA(pN,e,()=>tF(e)),mF(e),eF(O.get(e),e))}function eF(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{V&&W()===t&&e.term?.focus()}))}function tF(e){if(dN?.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=O.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function nF(e,t){if(!gN)return;let n=e.card.querySelector(`:scope > .session-card-header`);qO(e,t,gN,{className:`focus-centered`,onRelease:()=>{n?.classList.remove(`pane-header`),z?.setHeaderHost(`terminal`,null)}}),n?.classList.add(`pane-header`),n&&rF(n),Yf(e,t,!0)}function rF(e){let t=e.querySelector(`:scope > .session-name`);z?.setHeaderHost(`terminal`,{parent:e,before:t})}function iF(){return vN??=j(()=>import(`./boards-view-C2KW_DGj.js`).then(e=>(yN=e,e.onBoardPicked(lF),e)),__vite__mapDeps([37,3,4,17,13,12,14,31,23,15,21,29,16,38])),vN}function aF(e){vN=null,y(`focus`,`the board pane failed to load: ${l(e)}`)}function oF(e){z&&xN!==e&&(xN=e,z.showPanes(e))}function sF(){if(B){oF(oN),cF(null,B);return}let e=W(),t=eP(e);!e||!t?(oF(iN),bN=null):(oF(aN),cF(e,t))}function cF(e,t){let n=`${e??``}\n${t}`,r=bN!==n;bN=n,iF().then(n=>uF(n,e,r?t:null),aF)}function lF(e){if(!V)return;if(B){B=e,bN=`\n${e}`,G();return}let t=W();t&&(QN(Ri(SN,t,e)),bN=`${t}\n${e}`,G())}function uF(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 dF(){V&&bN!==null&&yN?.reopenSelectedBoard()}function fF(){let e=FO();V&&e?.sessionId&&O.has(e.sessionId)&&lP(e.sessionId,e.boardId)}function pF(){pM();let e=W();e&&(GO()===e&&JO(),A.dispatch(`focusSession`,null))}function mF(e){V&&O.has(e)&&(rw(e),sa(e),e!==W()&&(pF(),B=null,A.dispatch(`focusSession`,e),U=e,G()))}function hF(){if(!ON||!kN||!AN)return;let e=W(),t=!!B||!!(e&&O.has(e)),n=O.size>0;na(ON,t),z&&na(z.element,!t),Lk(ON,!n),na(kN,!n),na(AN,!n),!t&&n&&(Bi(kN,`No session selected`),Bi(AN,`Select a session from the rail on the left to focus it here.`))}function gF(e,t){NN.set(D(e),typeof t==`string`&&t?t:`none`),V&&G()}var _F={placement:`overlay`,sessionId:()=>V&&hN&&!B?W():null,elementFor:()=>{if(!hN)throw Error(`Focus view is not mounted`);return hN},didShow:()=>{},didHide:()=>{let e=W();e&&eF(O.get(e),e)}};function vF(e=null){let t=W();t&&fM(`changes`,t,e)}function yF(e){V&&O.has(e)&&mF(e)}function bF(e){return!V||!O.has(e)?!1:(mF(e),Xx(e))}function xF(e){if(!V)return;let t=HN()[e-1];t&&ra(t)&&MP(t)}function SF(e){if(!V)return;let t=HN().filter(e=>e===U||ra(e)),n=_r(t,U,e);n!=null&&ra(n)&&(PP(n),H.get(n)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=W();V&&e&&rw(e)});function CF(){fN&&(V=!0,lM(_F),pF(),U=null,G(),jN&&MN?$P(MN):jN&&XP().length>0?QP():(jN&&pN&&GA(pN),TF()))}function wF(e,t=null){jN=!0,MN=t;try{e()}finally{jN=!1,MN=null}}function TF(){if(!V||W()||B)return;let e=Zi();e&&mF(e)}function EF(){V&&=(pF(),uM(_F),U=null,!1)}var DF=200;function OF(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function kF(e){return/^#settings(?:[/?]|$)/.test(e)}function AF(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function jF(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,DF).join(``).trim()}}function MF(e,t,n){let r=T(`a`,`settings-link`,n);return r.href=OF(e,t),r}var NF={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},PF=[{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`}],FF=null,IF=null,LF=null,RF=()=>!1,zF=new Set,BF=new Set,VF=_t({getAck:wi,setAck:Br,signature:()=>ct({posthog:FF}),isLooking:()=>RF()});function HF(e){for(let t of BF)t(e)}function UF(){IF?.(VF.refresh())}function WF(){return{latest:FF,archivedLocally:zF,traceOpener:LF}}function GF(e){BF.add(e)}function KF(e){RF=e,UF()}function qF(e){zF.add(e)}function JF(){VF.acknowledge(),UF()}function YF(e){IF=e,UF()}function XF(e){LF=e}function ZF(e){FF=e,dt(FF,zF),HF({kind:`status`}),UF()}function QF(e){let t=Re(FF,e.projectId,e.issueId)?.inFlight===!0;it(FF,e)&&HF({kind:`investigation-activity`,projectId:e.projectId,issueId:e.issueId,wasInFlight:t})}function $F(e){let t=xe(FF,e);HF({kind:`investigation-finished`,frame:e,isPatched:t}),t&&UF()}var eI=null,tI=[],nI=()=>!1,rI=null,iI=ki(),aI=bi(),oI=new Set(aI.split(`|`).filter(Boolean)),sI=new Set;function cI(e){for(let t of sI)t(e)}function lI(){return yg(tI).map(vg)}function uI(e){e!==iI&&(iI=e,Qr(e))}function dI(e){e!==aI&&(aI=e,oI=new Set(e.split(`|`).filter(Boolean)),Kr(e))}function fI(){if(!eI)return;let e=jg({turnEntries:lI(),acknowledged:iI,unseen:aI,isLooking:nI()});uI(e.acknowledged),dI(e.unseen),rI?.(e.isShown)}function pI(e){sI.add(e)}function mI(){return eI}function hI(){return tI}function gI(e){nI=e,fI()}function _I(e){rI=e,fI()}function vI(){eI&&(uI(ft(lI())),fI())}function yI(){return aI}function bI(e){return oI.has(e)}function xI(e){return oI.has(e)?(dI(ft([...oI].filter(t=>t!==e))),!0):!1}function SI(e){let t=Le.safeParse(e);t.success?(eI=t.data,tI=_g(t.data.entries),fI(),cI({kind:`status`})):y(`community`,`dropped community-status: ${r(t.error.issues)}`)}function CI(e){cI({kind:`connection`,isConnected:e})}function wI({source:e,className:t,title:n,allowsScripts:r}){let i=T(`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 TI=`panel-action`,EI=524288,DI=[`key`,`prKey`,`repo`,`number`,`action`,`actionId`,`itemKey`,`fingerprint`],OI=900;function kI(e){let t=ue.options.find(t=>t.shape.type.value===e);return new Set(Object.keys(t?.shape??{}).filter(e=>e!==`type`&&e!==`requestId`))}function AI(e){return e.map(e=>`${e.path.map(String).join(`.`)||`request`}: ${e.message}`).join(`; `)}function jI(e,t){let n=ve.safeParse(t);if(!n.success)return{ok:!1,error:`not sent: ${AI(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=ue.safeParse({...n.data,requestId:TI});if(!r.success)return{ok:!1,error:`${n.data.type} not sent: ${AI(r.error.issues)}`};let i=kI(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 ${EI} byte limit`}:{ok:!0,type:r.data.type,payload:a}}function MI(e,t,n){return`${e} sent ${t} ${DI.flatMap(e=>{let t=n[e];return typeof t==`string`||typeof t==`number`?[`${e}=${t}`]:[]}).join(` `)}`.trim().slice(0,OI)}var NI=`[^/\\\\\\s"'\`<>:]+`,PI=RegExp(`(?<![\\w./\\\\-])(?:/home/${NI}|/Users/${NI}|[A-Za-z]:[\\\\/]Users[\\\\/]${NI}|/root(?![\\w.-]))`,`g`);function FI(e){return e.replace(PI,`~`)}function II(e){return FI(ul(e))}var LI=1e3,RI=12e4,zI=new Map,BI=null;function VI(e){return hl()?II(e):e}var HI={sessions:()=>({sessions:[...O].map(([e,t])=>({id:e,name:VI(ar(t)),agent:t.agent??null,state:t.currentState,stateSinceMs:t.stateSince,taskTitle:t.taskTitle===null?null:VI(t.taskTitle)}))}),focus:()=>({sessionId:A.snapshot().focusedSessionId,view:A.snapshot().activeView,isStreamerMode:hl()}),theme:()=>_o(),usage:()=>({planLimits:Object.entries(KD().planLimitsByVendor).flatMap(([e,t])=>t===null||e!==`claude`&&e!==`codex`&&e!==`kimi`?[]:[{vendor:e,fiveHour:Ew(t,`fiveHour`),sevenDay:Ew(t,`sevenDay`)}])}),attention:()=>{let e=pr([...O.values()].map(e=>({state:e.currentState,unseenOutcome:e.unseenOutcome??null})));return{waiting:e.waitingCount,finished:e.finishedCount,failed:e.failedCount}},reviews:()=>j_()};function UI(e,t){e.frame.contentWindow?.postMessage(t,`*`)}function WI(e,t){let n=t.get(e);if(n)return n;let r=HI[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}=WI(t,n);e.lastSentJsonByTopic.get(t)!==i&&(e.lastSentJsonByTopic.set(t,i),UI(e,Te.parse({v:1,kind:`topic`,topic:t,data:r})))}function KI(){let e=!1,t=new Map;for(let n of zI.values()){for(let e of n.subscribedTopics)GI(n,e,t);e||=n.subscribedTopics.size>0}e||BI===null||(clearInterval(BI),BI=null)}var qI=new Map;async function JI(e,t){let n=await c(e,t).catch(e=>Wn(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 YI(e,t){UI(e,{v:1,kind:`store`,data:qI.get(e.packName)??{},error:t})}async function XI(e){let t=await JI(`pack-data-get`,{pack:e.packName});t.ok&&qI.set(e.packName,t.data),YI(e,t.ok?null:t.error)}async function ZI(e,t,n){let r=Ae(e.packName,Ce(qI.get(e.packName)??{},t,n));if(r!==null){YI(e,r);return}let i=await JI(`pack-data-set`,{pack:e.packName,key:t,value:n});if(!i.ok)YI(e,i.error);else{qI.set(e.packName,i.data);for(let t of zI.values())t.packName===e.packName&&YI(t,null)}}function QI(e,t){e.subscribedTopics=new Set(t.filter(t=>e.grantedTopics.has(t))),e.lastSentJsonByTopic.clear(),UI(e,{v:1,kind:`hello`,granted:[...e.subscribedTopics]}),XI(e);for(let t of e.subscribedTopics)GI(e,t);BI??=setInterval(KI,LI)}function $I(e,t,n,r,i=!1){UI(e,{v:1,kind:`action-result`,id:t,ok:r===null,timedOut:i,result:n,error:r})}function eL(e,t){return t.ok===!1?typeof t.error==`string`&&t.error!==``?t.error:`${e} was refused`:null}async function tL(e,t,n){let r=jI(e.acts,n);if(!r.ok){$I(e,t,null,r.error);return}s({type:`client-log`,scope:`packs`,text:MI(e.viewId,r.type,r.payload)});let i=await c(r.type,r.payload,{timeoutMs:RI}).catch(e=>Wn(e));if(i===`Request timed out`){$I(e,t,null,`${r.type} got no answer within ${RI/1e3} s; it may still run, so check before sending it again`,!0);return}if(typeof i==`string`){$I(e,t,null,`${r.type} failed: ${i}`);return}let a={...i};$I(e,t,a,eL(r.type,a))}function nL(e){let t=[...zI.values()].find(t=>t.frame.contentWindow!==null&&t.frame.contentWindow===e.source);if(!t)return;let n=De.safeParse(e.data);if(n.success){tL(t,n.data.id,n.data.request);return}let r=be.safeParse(e.data);r.success&&(r.data.kind===`store-set`?ZI(t,r.data.key,r.data.value):r.data.kind===`subscribe`&&QI(t,r.data.topics))}function rL(e,t,n){zI.size===0&&window.addEventListener(`message`,nL),zI.set(e,{viewId:e,frame:t,packName:n.pack,acts:n.acts,grantedTopics:new Set(n.reads),subscribedTopics:new Set,lastSentJsonByTopic:new Map})}var iL=null,aL=new Set;function oL(){return iL}function sL(e){return aL.add(e),()=>aL.delete(e)}function cL(e){let t=we.safeParse(e);if(!t.success)y(`settings`,`dropped packs-status: ${r(t.error.issues)}`);else{iL=t.data,uo(t.data.themes)&&yo();for(let e of aL)e()}}var lL=`about:blank`,uL={pack:``,reads:[],acts:[]},dL=new Map,fL=new Map;function pL(e){let t=T(`img`,`pack-tab-icon`);return t.src=e,t.alt=``,t.decoding=`async`,t.referrerPolicy=`no-referrer`,t}function mL(e){return fL.set(e.viewId,e),{mount(t){let n=fL.get(e.viewId);t.replaceChildren(hL(e.viewId,n?.entryUrl??lL,e.label,n??uL))}}}function hL(e,t,n,r){let i=wI({source:{kind:`url`,url:t},className:`pack-panel-frame`,title:n,allowsScripts:!0});return dL.set(e,i),rL(e,i,r),i}function gL(e,t,n,r){let i=dL.get(e);i&&i.getAttribute(`src`)!==t&&i.replaceWith(hL(e,t,n,r))}function _L(e){fL.set(e.viewId,e),gL(e.viewId,e.entryUrl,e.label,e)}function vL(e){fL.delete(e),gL(e,lL,dL.get(e)?.title??``,uL)}function yL(e){let t=()=>e(oL()?.panels??[]);sL(t),t()}var bL=`glimmervoid:preload-error-reload-at`,xL=3e4,SL=1e3,CL=$n();function wL(e,t){let n=CL.mountedModuleOf(e.view);n?t(n):CL.show(e).then(t).catch(t=>{throw y(`view`,`${e.view} failed to show: ${l(t)}`),t})}function TL(e){return CL.mountedModuleOf(e)}function EL(e){CL.mountEagerViews(e)}function DL(e){let t=()=>{CL.prefetch(e.filter(e=>!e.tab.hidden))};`requestIdleCallback`in window?window.requestIdleCallback(t):setTimeout(t,SL)}function OL(e){let t=Date.now();nr(e.getItem(bL),t,xL)&&(e.setItem(bL,String(t)),location.reload())}function kL(e){window.addEventListener(`vite:preloadError`,()=>OL(e()))}function AL(e,t){fetch(e,{method:`HEAD`,cache:`no-store`}).then(e=>{e.status===404&&OL(t())}).catch(()=>{})}function jL(e,t,n){let r=w(document,`#app-main`,`main`),i=Ve(`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)??T(`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=T(`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}=br(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 ML(e){return e.iconUrl?pL(e.iconUrl):Ee(Ue)}function NL(e){return jL({view:e.viewId,label:e.label,iconPath:``,panelClass:`pack-panel-view`,hasPanelChrome:!1,module:mL(e)},ML(e),()=>{})}function PL(e,t){e.tab.replaceChildren(ML(t),t.label)}function FL(e){S_({openTerminal:e.openTerminal,openReviews:e.openReviews}),iA({openTerminal:e.openTerminal}),jj(e.onRestart),AO(e.openReviewFile);let t=[{view:`focus`,label:`Focus`,iconPath:rt,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,refreshOn:[`connected`],module:{mount:()=>YN({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:CF,deactivate:EF,refresh:dF}},{view:`prs`,label:`Reviews`,iconPath:je,panelClass:`pr-view`,gate:{fromSettings:NF.teamReview},load:()=>j(()=>import(`./review-queue-panel-CyUV0h31.js`).then(e=>e.view),__vite__mapDeps([39,40,14,13,4,3,12,33,41,15,42,30,27,21,24,28,5,6,7,20,31,23,32,29,43,36,44])),refreshOn:[`shown`],attention:{subscribe:v_,acknowledge:__},onConnectionChange:e=>{Ph(e),Xg(e)}},{view:`issues`,label:`Issues`,iconPath:Be,panelClass:`issues-view`,gate:{fromSettings:NF.issues},load:()=>j(()=>import(`./issues-panel-Dgy6w2wP.js`).then(e=>e.view),__vite__mapDeps([45,13,4,3,12,14,33,42,30,27,15,21,24,28,5,6,7,20,31,23,32,29,43,16,46])),refreshOn:[`shown`],onConnectionChange:$p},{view:`usage`,label:`Usage`,iconPath:me,panelClass:`usage-view`,gate:{fromSettings:NF.usage},load:()=>j(()=>import(`./usage-panel-CrAJMOkk.js`).then(e=>e.view),__vite__mapDeps([47,3,4,13,48,49])),attention:{subscribe:ZD,acknowledge:XD},onConnectionChange:rO,refreshOn:[`shown`,`connected`,`usage-sessions`]},{view:`radar`,label:`Radar`,iconPath:mt,panelClass:`radar-view`,gate:{fromSettings:NF.posthog},load:()=>j(()=>import(`./radar-panel-CutSh8oR.js`).then(e=>e.view),__vite__mapDeps([50,13,4,3,48,51,12,14,35,27,15,21,24,28,5,6,7,20,32,29,52])),attention:{subscribe:YF,acknowledge:JF}},{view:`community`,label:`Community`,iconPath:Ge,panelClass:`community-view`,gate:{fromSettings:NF.community},load:()=>j(()=>import(`./community-panel-C0yACNBn.js`).then(e=>e.view),__vite__mapDeps([53,13,4,3,40,14,12,33,41,43,5,6,7,21,15,36,54])),refreshOn:[`shown`],attention:{subscribe:_I,acknowledge:vI},onConnectionChange:CI},{view:`boards`,label:`Boards`,iconPath:Ue,isPhoneNavScreen:!0,isPhoneOnly:!0,panelClass:`boards-screen`,hasPanelChrome:!1,load:()=>j(()=>import(`./boards-view-C2KW_DGj.js`).then(e=>e.view),__vite__mapDeps([37,3,4,17,13,12,14,31,23,15,21,29,16,38])),refreshOn:[`shown`,`connected`]},{view:`hooks`,label:`Hooks`,iconPath:Ke,panelClass:`hooks-view`,load:()=>j(()=>import(`./hooks-panel-BHe0NfgP.js`).then(e=>e.view),__vite__mapDeps([55,14,13,4,3,12,15,56])),refreshOn:[`shown`,`connected`,`hooks-updated`]},{view:`trace`,label:`Trace`,iconPath:Me,panelClass:`trace-view`,gate:{subscribe:xb},load:()=>j(()=>import(`./trace-panel-CxF4QOxU.js`).then(e=>e.view),__vite__mapDeps([57,3,4,13,12,14,5,6,7,58])),refreshOn:[`shown`],onAvailabilityChange:e=>XF(e?vC:null),onConnectionChange:CC},{view:`benchmarks`,label:`Arena`,iconPath:ot,panelClass:`bench-view`,load:()=>j(()=>import(`./arena-panel-ESQaDRzw.js`).then(e=>e.view),__vite__mapDeps([59,13,4,3,14,21,29,15,28,60])),onConnectionChange:Da},{view:`settings`,label:`Settings`,iconPath:fe,panelClass:`settings-view`,hasPanelChrome:!1,load:()=>j(()=>import(`./settings-panel-mMlTwl2_.js`).then(e=>e.view),__vite__mapDeps([61,3,4,5,6,7,2,1,8,62,13,10,51,12,14,35,27,15,21,24,28,20,32,29,42,30,31,23,33,44,63]))}].map(t=>jL(t,Ee(t.iconPath),e.setPhoneAttention));return w(document,`#header-tabs`,`div`).replaceChildren(...t.map(e=>e.tab)),t}function IL(e){return e===`remote`?`remote`:`local`}function LL(e,t){return IL(t)===`local`||e!==`shutdown`}var RL=!1,zL=new Set;function BL({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){let o=RC(),c=o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i;$t({title:t,message:c,confirmLabel:n,danger:r||o>0,onConfirm:()=>s({type:e})})}function VL(){BL({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function HL(){BL({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})}function UL(e){RL=LL(`shutdown`,e);for(let e of zL)e.isConnected?e.hidden=!RL:zL.delete(e)}function WL(e){e.hidden=!RL,zL.add(e)}function GL(e){e&&Fj(e),_k(`settings`)||q(`settings`,{section:e})}function KL(e){_k(e)||q(e)}function qL(){_k(`boards`)||(q(`focus`),fF())}function JL(){kF(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}var K=FL({onRestart:VL,openTerminal:e=>{gk(e)||(q(`focus`),yF(e))},openPlan:e=>{q(`focus`),bF(e)},openReviewFile:(e,t)=>{LC(e)&&(gk(e)||(q(`focus`),yF(e),vF(t)))},openReviews:()=>QL(`prs`)?(_k(`prs`)||q(`prs`),!0):!1,setPhoneAttention:dk});function YL(){return K.map(e=>e.view)}var XL=YL();function ZL(e){return K.find(t=>t.view===e)}function QL(e){return K.some(t=>t.view===e&&!t.tab.hidden)}var $L=!0,eR=null;function tR(e){ZL(e)?.attention?.acknowledge()}var nR=null;function rR(e){nR=s({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function iR(){nR&&rR(nR)}function aR(e){let t=ZL(e);t&&(wL(t,e=>Zn(t,e,`shown`)),rR(e))}function oR(e){Qn(K,{isPhoneShellActive:sk(),activeView:xr(),phoneScreen:A.snapshot().phoneScreen},e,TL)}function q(e,{section:t,setting:n,persist:r=!0}={}){let i=ZL(e);if(!i||!QL(e))return;let a=xr();A.dispatch(`setActiveView`,e),$L=r,r&&(eR=null),document.body.dataset.activeView=e,r&&Xr(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&&TL(a)?.deactivate?.(),wL(i,r=>{xr()===e&&(r.activate?.(),Zn(i,r,`shown`),e===`settings`&&t&&Fj(t,n??null))}),rR(e),a===`settings`&&e!==`settings`&&JL(),tR(e)}function sR(e,t){let{view:n}=e;e.tab.hidden=!t,uk(n,t),e.onAvailabilityChange?.(t),sk()||(!t&&xr()===n&&q(`focus`),t&&eR===n&&q(n))}function cR(e){for(let{view:t,isAvailable:n}of qn(K,e))sR(t,n)}var lR;function uR(e){lR=e;let t=Xn(XL,e);K.every((e,n)=>e.view===t[n])||(K.sort((e,n)=>t.indexOf(e.view)-t.indexOf(n.view)),w(document,`#header-tabs`,`div`).append(...K.map(e=>e.tab)),lk(t))}function dR(){return K.filter(e=>!e.tab.hidden)}function fR(e,t){let n=e[t];return q(n.view),n.tab}function pR(e,t){let n=dR(),r=n.findIndex(t=>t.view===e);return fR(n,pa(r,t,n.length))}function mR(e){K.some(e=>e.tab===document.activeElement)&&e.focus()}var hR=null;function gR(e){let t=YL();uR(e),c(`update-settings`,{settings:{viewTabOrder:e}}).then(e=>{e.type===`settings-error`&&uR(t)}).catch(()=>uR(t))}function _R(e){let t=hR;if(hR=null,!t||t===e)return;let n=YL();gR(tr(n,t,n.indexOf(e)))}function vR({view:e,tab:t}){t.addEventListener(`click`,()=>q(e)),t.addEventListener(`dragstart`,t=>{hR=e,t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),t.addEventListener(`dragover`,n=>{hR&&hR!==e&&(n.preventDefault(),t.dataset.dropTarget=`true`)}),t.addEventListener(`dragleave`,()=>delete t.dataset.dropTarget),t.addEventListener(`drop`,n=>{n.preventDefault(),delete t.dataset.dropTarget,_R(e)}),t.addEventListener(`dragend`,()=>{hR=null}),t.addEventListener(`keydown`,e=>{if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;let t=dR(),n=t.findIndex(e=>e.view===xr()),r=ma(e.key,n,t.length,`horizontal`);r!==null&&(e.preventDefault(),fR(t,r).focus())})}var yR=`pack:`,bR=new Map;function xR(e){let t=NL(e);return K.push(t),XL.push(t.view),w(document,`#header-tabs`,`div`).append(t.tab),vR(t),t}function SR(e){let t=new Set(e.map(e=>e.viewId));for(let e of K)e.view.startsWith(yR)&&!t.has(e.view)&&(vL(e.view),sR(e,!1));for(let t of e){let e=ZL(t.viewId)??xR(t),n=bR.get(t.viewId);n&&(n.label!==t.label||n.iconUrl!==t.iconUrl)&&PL(e,t),bR.set(t.viewId,t),_L(t),sR(e,!0)}uR(lR)}function CR(){let e=Ai(),t=kF(location.hash),n=Hb(location.hash);if(t&&(Fj(null,null,location.hash),q(`settings`,{persist:!1})),n&&q(`focus`,{persist:!1}),t||n)return;let r=QL(e);r||(eR=e),q(r?e:`focus`,{persist:r})}function wR(){let e=xr();q(QL(e)?e:`focus`,{persist:$L})}function TR(){Nj(K),EL(K);for(let e of K)e.gate&&(sR(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>sR(e,t)));_C(()=>{QL(`trace`)&&(_k(`trace`)||q(`trace`))});for(let e of K)vR(e);CR(),yL(SR)}function ER(e){return kF(e)?(Fj(null,null,e),_k(`settings`)||q(`settings`,{persist:!1}),!0):!1}var DR=`No plan is stored for this session yet. It appears here once the agent writes one.`,OR=`Plan`;function kR(e){let t=Hb(e);return t?!LC(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),sk()?(hk(t)||Tr({source:OR,sessionId:t,message:DR}),!0):(q(`focus`,{persist:!1}),bF(t)||Tr({source:OR,sessionId:t,message:DR}),!0)):!1}function AR(e){return kR(e)?!0:ER(e)}function jR(e){e.newURL===location.href&&AR(location.hash)}function MR(){document.addEventListener(`click`,e=>{if(!sk()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&AR(t.hash)&&e.preventDefault()}),window.addEventListener(`hashchange`,jR)}var NR=null,PR=new Set;function FR(){NR?.setState(xi()?`idle`:`off`)}function IR(e){Ei(e),FR();for(let t of PR)t(e)}function LR(e){PR.add(e)}function RR(e){NR=e,FR(),e.element.addEventListener(`click`,()=>IR(!xi()))}var zR=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,BR=[`title`,`label`],VR=new WeakMap,HR=new WeakMap,UR=null;function WR(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(zR)!==null}function GR(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function KR(e,t){if(t&&e===t.masked)return t;let n=II(e);return n===e?null:{original:e,masked:n}}function qR(e){let t=GR(e)?null:KR(e.data,VR.get(e));t?(VR.set(e,t),e.data!==t.masked&&(e.data=t.masked)):VR.delete(e)}function JR(e,t){let n=e.getAttribute(t),r=HR.get(e),i=n===null?null:KR(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),HR.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function YR(e){for(let t of BR)JR(e,t)}function XR(e){return e instanceof Element&&e.matches(zR)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function ZR(e){YR(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,XR);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&qR(e),e instanceof Element&&YR(e)}function QR(e){WR(e)||(e instanceof Text&&qR(e),e instanceof Element&&ZR(e))}function $R(e){e instanceof Element&&!WR(e)&&YR(e)}function ez(e){let t=new Set,n=new Set;for(let r of e){if(r.type===`childList`)for(let e of r.addedNodes)t.add(e);r.type===`characterData`&&t.add(r.target),r.type===`attributes`&&n.add(r.target)}for(let e of t)e.isConnected&&QR(e);for(let e of n)e.isConnected&&$R(e)}function tz(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);nz(e);for(let e=t.nextNode();e;e=t.nextNode())nz(e)}function nz(e){if(e instanceof Text){let t=VR.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=HR.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function rz(){if(UR)return;let e=new MutationObserver(t=>{ez(t),e.takeRecords()});ZR(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:BR}),UR=e}function iz(){UR&&(UR.disconnect(),UR=null,tz(document.body),VR=new WeakMap,HR=new WeakMap)}function az(e){e?rz():iz()}function oz(){az(hl()),_l(az)}var sz=Ye({label:`Play queued merge celebrations`,icon:Ee(ge,`1.6`),action:`play-celebrations`,states:[`idle`,`attention`]}),cz=C({variant:`primary`,label:`Session`,icon:Ee(He),action:`add-session`,onClick:oa});cz.id=`btn-add-session-header`;var lz=Ye({label:`Keyboard shortcuts and version`,icon:Ee(qe,`1.6`),action:`open-shortcuts-help`,onClick:()=>GL(`browser-shortcuts`),states:[`idle`]}).element,uz=Ye({label:`Mute alerts`,icon:Ee(gt,`1.6`),action:`toggle-mute`,states:[`idle`,`off`]}),dz=uz.element,fz=C({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-header-status`});fz.id=`header-status-dismiss`;var pz=w(document,`#celebration-tray`,`div`);pz.prepend(sz.element),w(document,`.header-right`,`div`).append(cz,lz,dz),w(document,`#header-status`,`p`).append(fz);function mz(){RR(uz),oz(),Wt(document.querySelector(`.header`))}function hz(){vm(pz,sz,w(document,`#celebration-tray-count`,`span`))}function gz(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 _z(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 vz(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function yz(e,t){return t||vz(e)?!1:_z(e)}var bz=C({variant:`primary`,size:`small`,label:`Restart`,action:`restart-to-update`,hidden:!0}),xz=C({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-update-command`}),Sz=C({variant:`icon`,size:`small`,label:`Dismiss update notice`,icon:Ee(ut),action:`dismiss-update-banner`});w(document,`#update-banner-cmd`,`code`).before(bz),w(document,`#update-banner-copy-status`,`span`).before(xz),w(document,`#update-banner`,`div`).append(Sz);var Cz=C({variant:`secondary`,size:`small`,label:`Copy`,action:`copy-leftovers-command`}),wz=C({variant:`icon`,size:`small`,label:`Dismiss old report notice`,icon:Ee(ut),action:`dismiss-leftovers-banner`});w(document,`#post-turn-leftovers-copy-status`,`span`).before(Cz),w(document,`#post-turn-leftovers-banner`,`div`).append(wz);var Tz,Ez=null;function Dz(e,t,n){e.onclick=()=>{let e=It(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var Oz=MF(Se,ye,`Update`).href;function kz(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function Az(e){let t=w(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=Fe(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=kz(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===Ez||!a&&Tz!==void 0&&s===Tz||!a&&s&&li()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);w(document,`#update-banner-text`,`span`).textContent=i,w(document,`#update-banner-cmd`,`code`).textContent=c;let l=w(document,`#update-banner-update`,`a`);l.href=Oz,l.hidden=n!==`link`,bz.hidden=n!==`restart`,bz.onclick=VL;let u=w(document,`#update-banner-cmd`,`code`);u.hidden=n!==`command`,xz.hidden=n!==`command`;let d=w(document,`#update-banner-copy-status`,`span`);d.hidden=n!==`command`,d.textContent=``;let f=w(document,`#update-banner-link`,`a`);f.hidden=!e.releaseUrl,f.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,Dz(xz,d,c),Sz.onclick=()=>{t.hidden=!0,a?Ez=i:(Tz=s,Yr(s))}}var jz=!1;function Mz({repositories:e,command:t}){let n=w(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(jz)return;let r=w(document,`#post-turn-leftovers-copy-status`,`span`);w(document,`#post-turn-leftovers-text`,`span`).textContent=gz(e.length),w(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,Dz(Cz,r,t),wz.onclick=()=>{jz=!0,n.hidden=!0}}var Nz=w(document,`#telemetry-banner`,`div`),Pz=C({variant:`secondary`,size:`small`,label:`Dismiss`,action:`dismiss-telemetry-banner`});Nz.append(Pz);function Fz(){Ci(!0),Nz.hidden=!0}function Iz(e){Nz.hidden=!yz(e,Vr())}function Lz(){let e=w(document,`#telemetry-banner-settings`,`a`);e.href=MF(`privacy`,`telemetry-enabled`,`What's collected`).href,e.addEventListener(`click`,Fz),Pz.addEventListener(`click`,Fz)}function Rz(e){j(()=>import(`./feature-hint-DeKRVPni.js`).then(t=>t.showFeatureHint(e,{isFeatureEnabled:e=>QL(Ie[e]),openView:KL,openSetting:(e,t)=>ER(OF(e,t))}),e=>y(`feature-hint`,`hint card failed to load: ${l(e)}`)),__vite__mapDeps([64,13,4,3,62,5,6,7,8,14,65]))}function zz(){j(()=>import(`./feature-hint-DeKRVPni.js`).then(e=>e.showStarHint(),e=>y(`star-hint`,`star card failed to load: ${l(e)}`)),__vite__mapDeps([64,13,4,3,62,5,6,7,8,14,65]))}var Bz=2500;function Vz({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}function Hz(e){ho(e.isExperimentalBuild===!0&&Ur()),zC(e),Hj(e),cR(e),Iz(e),uR(e.viewTabOrder),gl(e.streamerMode===!0)}var Uz=Object.freeze({top:[0,1],right:[-1,0],bottom:[0,-1],left:[1,0]}),Wz=160,Gz=950,Kz=900,qz=980,Jz=450,Yz=720,Xz=260,Zz=`cubic-bezier(0.22, 1, 0.36, 1)`,Qz=`cubic-bezier(0.2, 0.8, 0.3, 1)`,$z=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),eB=e=>new Promise(t=>{setTimeout(t,e)});function tB(e){return e!==void 0&&Object.hasOwn(Uz,e)}function nB(e){return[...e.querySelectorAll(`[data-side]`)].flatMap(e=>{let t=e instanceof SVGElement?e.dataset.side:void 0;if(!(e instanceof SVGElement)||!tB(t))return[];let[n,r]=Uz[t];return[{bracket:e,dx:n,dy:r}]})}function rB(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:Kl}],{duration:Wz,easing:`ease-out`})}}function iB(e){e.animate([{transform:`rotate(0deg)`,easing:`cubic-bezier(0.5, 0, 0.15, 1)`},{transform:`rotate(360deg)`,offset:.86,easing:Qz},{transform:`rotate(354deg)`,offset:.93,easing:Qz},{transform:`rotate(360deg)`}],{duration:Gz})}function aB(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:Kz,easing:`cubic-bezier(0.2, 0.9, 0.3, 1)`})}}function oB(e,t){e.animate([{transform:`scale(0)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:qz,easing:Zz,fill:`forwards`}),t.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`})}function sB(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:Yz,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:Yz,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 cB({mark:e,dial:t,light:n,halo:r}){return $z?.matches||document.hidden?Promise.resolve():(iB(t),aB(nB(e)),n.animate([{transform:`scale(1)`},{transform:`scale(1.35)`,offset:.4},{transform:`scale(1)`}],{duration:480,delay:qz,easing:Zz}),r.animate([{transform:`scale(1)`,opacity:.8},{transform:`scale(3.4)`,opacity:0}],{duration:700,delay:1e3,easing:`ease-out`}),eB(qz))}async function lB(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($z?.matches||document.hidden||!(t instanceof SVGElement)||!n||!r||!i)return;let a=nB(t);rB(a),e.dataset.unlock=`spin`,await eB(Wz),iB(n),aB(a),oB(r,i),await eB(qz),e.dataset.unlock=`lit`,await eB(Jz),e.dataset.unlock=`burst`,sB(a,r,i),await eB(Xz)}var uB=w(document,`#connection-status`,`span`),dB=w(uB,`.connection-label`,`span`),fB=w(document,`#loading-screen`,`div`),pB=w(document,`#loading-status`,`div`),mB=w(document,`#loading-detail`,`div`),hB=w(document,`#shutdown-screen`,`div`),gB=w(document,`#shutdown-status`,`div`),_B=!1,vB=null,yB=!1;function bB(){_B||vB===null||Vz({hasSnapshot:yB,connectingTerminalCount:mu(),msSinceConnected:performance.now()-vB})===`reveal`&&SB()}function xB(){yB=!0,bB()}function SB(){_B||(_B=!0,DL(K),_p(),zk(),lB(fB).then(CB,CB))}function CB(){fB.classList.add(`fade-out`);let e=()=>fB.remove();fB.addEventListener(`transitionend`,t=>{t.target===fB&&e()}),setTimeout(e,1e3)}function wB(e,t){uB.dataset.state=`shutdown`,dB.textContent=e,gB.textContent=t,hB.classList.add(`active`)}var TB=new Set([`disconnected`,`connecting`]);function EB(e,t,n){uB.dataset.state=e,uB.toggleAttribute(`data-reconnected`,n),dB.textContent=t}function DB(e,t){EB(e,t,e===`connected`&&TB.has(uB.dataset.state??``))}function OB(e,t){uB.dataset.state!==`shutdown`&&EB(e===`verified`?`connected`:e,t,!1)}var kB=1e4,AB=`Server`,jB=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,MB=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,NB=null,PB=!1;function FB(){pB.textContent=`Reconnecting to server...`,mB.textContent=MB,mB.hidden=!PB}function IB(){NB=null,PB=!0,_B?Tr({source:AB,message:jB,hidesInStreamerMode:!1}):FB()}function LB(){NB!==null||PB||(NB=window.setTimeout(IB,kB))}function RB(){NB!==null&&window.clearTimeout(NB),NB=null,PB=!1,mB.hidden=!0,wr(AB)}function zB(){RB(),AL(import.meta.url,()=>window.sessionStorage),iR(),hB.classList.contains(`active`)?location.reload():(Rk(),document.body.classList.add(`app-ready`),!_B&&vB===null&&(vB=performance.now(),pB.textContent=`Connecting to sessions...`,setTimeout(SB,Bz)),bB(),oR(`connected`),c(`get-settings`,{}).then(e=>{e.settings&&(Hz(e.settings),xr()===`settings`&&ER(location.hash))}).catch(()=>{}))}function BB(e,t){if(e===`connecting`||e===`verified`)OB(e,t);else{DB(e,t),nS(e===`connected`);for(let t of K)t.onConnectionChange?.(e===`connected`);e===`connected`?zB():e===`disconnected`&&hB.classList.contains(`active`)?gB.textContent=`Waiting for server...`:(LB(),_B||FB())}}function VB(){pu(bB),h(BB)}var HB=14,UB=Object.freeze({idle:ql,failed:`#ef4444`,waiting:`#f59e0b`});function WB({waitingCount:e,failedCount:t}){return e>0?`waiting`:t>0?`failed`:`idle`}function GB(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)">${Jl({frame:Kl,light:UB[e],strokeWidth:HB})}</g></svg>`}function KB(){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 qB=KB(),JB=`idle`;function YB(e){let t=WB(e);t!==JB&&(JB=t,qB.href=`data:image/svg+xml,${encodeURIComponent(GB(t))}`)}function XB(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 ZB(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 QB(){Qp(),Ah(),fk()}function $B(){G(),QB()}function eV(){Ui(e=>{G(e),QB()})}var tV=null;function nV(e){let t=XB(tV,e);tV=t.knownBuild,t.reload&&location.reload()}function rV(e){Er(e),ew(e),Ba(e),ub(e),W_(e),wn(e),Cn(e),dc(e)}function iV(e){for(let t of fc(e))rV(t)}function aV(e,t){let n=new Set(e.map(e=>e.id));for(let e of[...O.keys()])lc(e)===t&&(n.has(e)||rV(e))}function oV(e,t=null){if(t)for(let n of e)uc(n.id,t);aV(e,t),t||Gj(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)LC(t.id)&&cV(t),LC(t.id)||UC(t.id,t.name,t.state,ZB(t)),za(t.id,t.coherenceHooks),U_(t.id,t.linkedPrs),xn(t.id,t.failureReason),Hn(t.id,t.attentionNotes),IC(t.id,t.taskTitle,t.taskTitleIsCustom),GC(t.id,t.agent),QC(t.id,t.mergeStatus,t.mergeReason),WC(t.id,t.effectiveBase),qC(t.id,t.activeAgents,t.awaitingBackgroundTasks),JC(t.id,t.pendingPromptKind),YC(t.id,t.unseenOutcome),yn(t.id,t.auditLog,t.managerSeenSeq),Zx(t.id,t.hasPlan);HC(),YB(hr.counts),G(),TF(),QB(),uV(),kR(location.hash),vk(),xB()}function sV(e,t){let n=e.dataset.skipPerms!==void 0;return(e.dataset.path??``)!==t.path||n!==t.dangerouslySkipPermissions}function cV(e){let t=O.get(e.id)?.card;t&&sV(t,e)?lV(e.id,e.name,e.state,e,e.linkedPrs):(iw(e.id,e.state,e.stateSince),On(e.id,!!e.saneYolo),an(e.id,e.isQuestionManagerOn),t&&t.dataset.session!==e.name&&$C(e.id,e.name),KC(e.id,e.isWorktree))}function lV(e,t,n,r,i){let a=O.get(e),o=ta()===e;za(e,null),ew(e),ub(e),wn(e),Cn(e),U_(e,i),UC(e,t,n,ZB(r)),o&&Ki(e),dV(e,a)}function uV(){yC([...O].map(([e,t])=>({id:e,name:ar(t)||e})))}function dV(e,t){Zx(e,t?.hasPlan===!0),YC(e,t?.unseenOutcome)}var fV=new Set([E.DONE,E.FAILED]);function pV(e,t){return e!==void 0&&fV.has(e)&&!fV.has(t)&&t!==E.DORMANT}function mV(e){let t=O.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;ew(e.id),UC(e.id,e.session,E.DORMANT,ZB({skipPerms:i,saneYolo:a,isQuestionManagerOn:e.isQuestionManagerOn??vn(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})),GC(e.id,t?.agent),dV(e.id,t)}function hV(e,t){let n=O.get(String(e.id))?.currentState;t.to===E.DORMANT&&n!==E.DORMANT?(mV(e),cb(e.id)):(iw(e.id,t.to,e.timestamp),xn(e.id,e.failureReason),e.saneYolo!==void 0&&On(e.id,e.saneYolo),cb(e.id),pV(n,t.to)&&Au(e.id))}function gV(e){if(LC(e.id))e.transition&&hV(e,e.transition),e.activeAgents!==void 0&&qC(e.id,e.activeAgents,e.awaitingBackgroundTasks),e.unseenOutcome!==void 0&&YC(e.id,e.unseenOutcome),e.pendingPromptKind!==void 0&&JC(e.id,e.pendingPromptKind),e.managerSeenSeq!==void 0&&zn(e.id,e.managerSeenSeq),e.attentionNotes!==void 0&&Hn(e.id,e.attentionNotes),e.isQuestionManagerOn!==void 0&&an(e.id,e.isQuestionManagerOn),e.unseenOutcome!==void 0&&HC(),YB(hr.counts),ca(e.id),Nb(e.id);else{if(!e.transition)return;UC(e.id,e.session,e.transition.to,ZB({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),YB(hr.counts),Qp()}}function _V(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 vV=`Secrets agents may read from your vault, per project. Revoking one makes the next request ask again.`,yV=null,bV=null;function xV(e,t){let n=T(`article`,`settings-view-setting`),r=T(`div`,`settings-view-setting-text`),i=T(`div`,`settings-view-setting-heading`);i.append(T(`h2`,`settings-view-setting-title`,t.name)),r.append(i,T(`p`,`settings-view-setting-description`,t.isAllowed?`Reads ${t.reference??`no reference yet`}`:`Denied`));let a=T(`div`,`settings-view-setting-control`);return a.append(C({variant:`secondary`,label:`Revoke`,action:`secret-revoke`,onClick:()=>{s({type:`secret-revoke`,project:e,name:t.name})}})),n.append(r,a),n}function SV(e){return[T(`h2`,`settings-view-subsection-title`,e.project),...e.approvals.map(t=>xV(e.project,t))]}function CV(){let e=T(`p`,`settings-view-section-description`,vV);return yV?yV.length===0?[e,T(`p`,`settings-view-setting-description`,`No approvals yet. An agent that runs glimmervoid need asks on its session card first.`)]:[e,...yV.flatMap(SV)]:[e,T(`p`,`settings-view-setting-description`,`Waiting for the server to list approvals.`)]}function wV(){bV?.isConnected&&bV.replaceChildren(...CV())}function TV(e){yV=e.projects,wV()}function EV(e){bV=T(`div`,`settings-view-stack`),e.appendChild(bV),wV()}var DV={"session-trace-response":e=>bC(e),"session-trace-changed":e=>xC(e),"session-plan-changed":e=>{Qx(e),QB()},"session-plan-draft":e=>{$x(e)},"session-plan-response":e=>{eS(e)},"session-docs-changed":e=>Zv(e),"session-docs-snapshot":e=>Qv(e),"session-secret-request":e=>zv(e),"secret-requests-snapshot":e=>Bv(e),"secret-approvals":e=>TV(e),"session-manager-decision":e=>{Rn(e.id,e.decision),$B()},"session-coherence-hooks":e=>{za(e.id,e.coherenceHooks),$B()},"session-coherence":e=>{Va(e),$B()},"session-coherence-snapshot":e=>{Ha(e),$B()},"session-coherence-journal-response":e=>qa(e)},OV={"team-review-status":e=>qg(e),"github-prs":e=>am(e),"my-prs-status":jh,"pr-flows-status":Mh,"packs-status":cL,"my-pr-merge-result":e=>Nh(e),"team-review-action-result":e=>Jg(e),"open-team-review-session-result":e=>Yg(e),"issues-status":e=>em(e),"issue-detail-result":e=>tm(e),"open-issue-session-result":e=>nm(e),"set-issue-state-result":e=>Wp(e)},kV={"radar-status":e=>ZF(e),"radar-investigation-activity":e=>QF(e),"radar-investigation-finished":e=>$F(e),"community-status":e=>SI(e),"benchmark-status":e=>Oa(e),"benchmark-action-result":e=>ka(e),"race-status":e=>Qk(e),"race-history":e=>eA(e),"usage-sessions":e=>iO(e),"usage-report":e=>{oO(e),Wj()},"plan-limits":e=>aO(e),"usage-budget-alert":e=>vx({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0})},AV=3e3,jV=null,MV=null,NV=Cr(`settings-hosts-status`);function PV(e){let t=e.hostVersion?`, build ${e.hostVersion}`:``;return`${e.sshTarget} port ${e.dashboardPort}: ${sc(e)}${t}`}async function FV(e){let t=await Sr(`remove-host`,{id:e.id},NV,{busyText:`Removing ${e.name}.`});t?.type===`host-change-result`&&(t.ok?NV.show(`ok`,`Removed ${e.name}. Its sessions keep running there.`):NV.show(`error`,`Not removed: ${t.error??`the server refused the change.`}`))}function IV(e){$t({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:()=>{FV(e)}})}function LV(e){let t=T(`div`,`settings-host-row`);t.dataset.state=e.state;let n=T(`div`,`settings-readonly`);return n.append(T(`span`,`settings-host-name`,`${e.name} (${e.id})`),T(`span`,null,PV(e))),t.append(n,C({variant:`secondary`,label:`Remove`,action:`remove-host`,onClick:()=>IV(e)})),t}function RV(){if(!jV)return;let e=oc();e.length===0?jV.replaceChildren(T(`div`,`settings-readonly`,`No hosts linked yet. Add one below.`)):jV.replaceChildren(...e.map(LV))}function zV(e,t,n){let r=T(`label`,`settings-host-field`),i=T(`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(T(`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):AV};t.disabled=!0;let a=await Sr(`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 VV(){let e=T(`form`,`settings-host-form`),t=zV(`Id`,`id`,`devbox`),n=zV(`Name`,`name`,`Same as the id`),r=zV(`Ssh target`,`sshTarget`,`me@devbox or a ~/.ssh/config alias`),i=zV(`Dashboard port`,`dashboardPort`,String(AV)),a=Cr(`settings-hosts-status`),o=C({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=T(`div`,`settings-telegram-test`);s.append(o,a.element);let c=T(`div`,`settings-host-fields`);return c.append(t.field,n.field,r.field,i.field),e.append(c,s),e}function HV(){let e=T(`div`,`settings-view-status-block settings-hosts`);return jV=T(`div`,`settings-host-list`),RV(),MV??=VV(),e.append(jV,NV.element,MV),e}function UV(){jV?.isConnected&&RV()}var WV=new Map,GV=()=>{},KV={connect:()=>{},abandon:()=>{},reconnectNow:()=>{},send:()=>!1,request:()=>Promise.reject(Error(x))};function qV(e){return typeof e.id==`string`?e.id:typeof e.sessionId==`string`?e.sessionId:null}f(e=>{let t=qV(e),n=t?lc(t):null;return n?WV.get(n)??KV:null},()=>[...WV.values()]);function JV(e,t,n,r){return(WV.get(e)??KV).request(t,n,r)}function YV(e){GV=e}function XV(e){let t=g({pathPrefix:`/hosts/${encodeURIComponent(e)}`,isLocal:!1,onMessage:t=>{t.type===`session-added`&&uc(t.id,e),GV(e,t)}});return t.connect(),t}function ZV(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,XV(e));return n}var QV={snapshot:e=>{nV(e.serverBuild),oV(e.sessions)},"hooks-report":e=>Sv(e),"save-hook-result":()=>Cv(),"delete-hook-result":()=>Cv(),"update-status":e=>{Az(e),Kj(e)},"update-progress":e=>qj(e.journal),"post-turn-leftovers":e=>Mz(e),"feature-hint":e=>Rz(e.hint),"star-hint":()=>zz(),error:e=>{let t=Jj(e),n=SC(e),r=tS(e);t||n||r||(e.id?Tn(e.id,e.message):Tr({source:AB,message:e.message}))},"settings-updated":e=>{e.settings&&Hz(e.settings),Rk()},"agent-logins":e=>aj(e.logins),"health-snapshot":e=>{e.stats&&uv(e.stats)},"client-trust":e=>UL(e.trust),"shutting-down":()=>wB(`Shutting down...`,`Shutting down sessions...`),restarting:()=>wB(`Restarting...`,`Restarting server...`),"hosts-status":e=>{ac(e.hosts),UV();for(let t of ZV(e.hosts))iV(t);$B()}},$V={"session-status":e=>gV(e),"session-added":e=>{U_(e.id,e.linkedPrs),LC(e.id)||(UC(e.id,e.session,e.state,ZB(e)),GC(e.id,e.agent)),YB(hr.counts),$B(),uV()},"session-close-confirm":e=>{$i(e.id)},"session-removed":e=>{rV(e.id),vP(e.id),YB(hr.counts),$B(),uV()},"session-title":e=>{IC(e.id,e.taskTitle,e.isCustom),$B()},"session-prs":e=>U_(e.id,e.linkedPrs),"session-renamed":e=>{$C(e.id,e.newName),$B(),uV()},"session-modified":e=>{lV(e.id,e.session,e.state,e,e.linkedPrs),GC(e.id,e.agent),YB(hr.counts),$B(),uV()},"session-git":e=>KC(e.id,!!e.worktree),"session-merge-status":e=>{ZC(e.id,e.mergeStatus,e.reason),gF(e.id,e.mergeStatus),QB()},"debug-state-response":e=>Mb(e),"session-setup-response":e=>lw(e),notify:e=>{_x(e),Nb(e.session)},"session-error":e=>{lb(e.id),tS(e)||Tn(e.id,e.message)}},eH=Ot.flatMap(e=>[!1,!0].flatMap(t=>[!1,!0].map(n=>({tone:e,dashed:t,back:n})))),tH=16,nH=new WeakMap;function rH(e){return e?.kind===`box`?Mt(e)?.asset??null:null}function iH(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 aH(e){return Ot.indexOf(e.tone)*4+(e.dashed?2:0)+ +!!e.back}function oH(e,t,n){t.kind===`wire`?e.wireCountByStyleSlot[aH(t)]+=n:t.kind===`box`&&(e.boxCountByChangeSlot[Pt.indexOf(t.change)]+=n,t.at===null&&t.step===null&&(e.floatingBoxCount+=n))}function sH(e){return e.kind===`wire`?[e.from,e.to]:e.kind===`frame`?e.contains:[]}function cH(e,t,n){t.kind===`box`&&t.step!==null&&(n?e.stepBoxIds.add(t.id):e.stepBoxIds.delete(t.id))}function lH(e){return e.kind===`box`&&(e.refs.length>0||Ct(e).some(e=>e.ref!==null))}function uH(e,t){lH(t)?e.anchoredIds.add(t.id):e.anchoredIds.delete(t.id)}function dH(e,t,n){for(let r of new Set(sH(t))){let i=e.dependentIdsByBoxId.get(r);i?i instanceof Set?i.add(t.id):i.length<tH?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 fH(e,t){for(let n of new Set(sH(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 pH(e,t){return{...t,id:e.storedIdOf(t.id)??t.id}}function mH(e,t,n){e.elementCount+=1,t.kind===`stroke`&&(e.strokeCount+=1),iH(e,rH(t),1),oH(e,t,1),dH(e,t,n),cH(e,t,!0),uH(e,t)}function hH(e,t){--e.elementCount,t.kind===`stroke`&&--e.strokeCount,iH(e,rH(t),-1),oH(e,t,-1),fH(e,t),cH(e,t,!1),e.anchoredIds.delete(t.id)}function gH(){return{elementCount:0,strokeCount:0,assetRefCount:new Map,dependentIdsByBoxId:new Map,stepBoxIds:new Set,anchoredIds:new Set,wireCountByStyleSlot:eH.map(()=>0),boxCountByChangeSlot:Pt.map(()=>0),floatingBoxCount:0}}function _H(e){let t=nH.get(e);if(t)return t;let n=gH();for(let t of e.values())mH(n,t,e);return nH.set(e,n),n}function vH(e){return{elementCount:e.elementCount,strokeCount:e.strokeCount,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),wireCountByStyleSlot:[...e.wireCountByStyleSlot],boxCountByChangeSlot:[...e.boxCountByChangeSlot],floatingBoxCount:e.floatingBoxCount}}function yH(e){let t=e.copy(),n=nH.get(e);return n&&nH.set(t,vH(n)),t}function bH(e,t){let n=nH.get(e),r=e.get(t.id);if(e.put(t),!n)return;let i=pH(e,t);r?(iH(n,rH(r),-1),iH(n,rH(t),1),oH(n,r,-1),oH(n,i,1),fH(n,r),dH(n,i,e),cH(n,r,!1),cH(n,i,!0),uH(n,i)):mH(n,i,e)}function xH(e,t){SH(e,t.id),bH(e,t)}function SH(e,t){let n=e.get(t);if(!n)return;e.remove(t);let r=nH.get(e);r&&hH(r,n)}var CH=26,wH=97;function TH(e){return e.step!==null}function EH(e){return[..._H(e.elements).stepBoxIds].flatMap(t=>{let n=e.elements.get(t);return n?.kind===`box`&&TH(n)?[n]:[]})}function DH(e,t,n){return[..._H(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 OH(e,t){let n=new Map;for(let r of t){let i=DH(e,r,t).map(e=>e.from);i.length>0&&n.set(r,i)}return n}function kH(e){let t=String.fromCharCode(wH+e%CH),n=Math.floor(e/CH);return n===0?t:`${t}${n+1}`}function AH(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 jH(e){let t=EH(e),n=OH(e,new Set(t.map(e=>e.id))),r=AH(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}${kH(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 MH(e){let t=NH(e.length);return e.forEach((e,n)=>{PH(t,n,e.x,e.y,e.x+e.width,e.y+e.height)}),t}function NH(e){return{count:e,lefts:new Float64Array(e),tops:new Float64Array(e),rights:new Float64Array(e),bottoms:new Float64Array(e)}}function PH(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 FH(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 IH(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 FH(n)}function LH(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 RH(e){let t=1;for(;t<e;)t*=2;return t}function zH(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 BH(e,t){let n=RH(t.length),r=new Int32Array(e.count),i=new Int32Array(e.count);for(let n=0;n<e.count;n+=1)r[n]=LH(t,e.tops[n]??0),i[n]=LH(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){zH(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=LH(t,e);for(let e=s+n;e>=1;e>>=1)zH(o[e]??[],a,i);let c=LH(t,r);c>s&&f(1,0,n-1,s+1,c,i)}}}function VH(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 HH(e){let t=IH(e);return e.map(e=>({rects:e,index:BH(e,t),closingOrder:VH(e.rights),nextClosing:0}))}function UH(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 WH(e,t){let[n]=HH([e]);if(n)for(let r of VH(e.lefts))UH(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 GH(e,t,n){let[r,i]=HH([e,t]);if(!r||!i)return;let a=VH(e.lefts),o=VH(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;UH(r,f),UH(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 KH(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 qH(e,t,n,r){let i=new Int32Array(e.length);for(let e=0;e<i.length;e+=1)i[e]=e;return KH(Int32Array.from(e),n,KH(Int32Array.from(t),r,i))}function JH(e,t,n,r){return Array.from(qH(e,t,n,r),n=>[e[n]??0,t[n]??0])}function YH(e){let t=[],n=[];return WH(MH(e),(e,r)=>{t.push(Math.min(e,r)),n.push(Math.max(e,r))}),JH(t,n,e.length,e.length)}var XH=10,ZH=4,QH=14,$H=2,eU=160;function tU(e,t){return t?e.y:e.x}function nU(e,t){return t?e.x:e.y}function rU(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||tU(a,t)!==tU(o,t)||nU(a,t)===nU(o,t))continue;let s=i===0||i+2===e.length;n.push({wire:r,index:i,line:tU(a,t),low:Math.min(nU(a,t),nU(o,t)),high:Math.max(nU(a,t),nU(o,t)),isFixed:s})}}),n.sort((e,t)=>e.line-t.line||e.low-t.low)}function iU(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 aU(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=iU(s,t);c.length>1&&n.push({line:i.line,low:i.low,high:o,bundles:c})}return n}function oU(e,t,n,r){let i=e[t.index],a=e[t.index+1];if(!i||!a)return 0;let o=nU(i,r)<nU(a,r)===n?e[t.index-1]:e[t.index+2];return o?Math.sign(tU(o,r)-t.line):0}function sU(e,t,n,r){let i=n[e.wire]??[],a=n[t.wire]??[],o=oU(i,e,!0,r),s=oU(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=oU(i,e,!1,r),l=oU(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 cU(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 lU(e,t,n,r,i,a){if(a<n||r<i)return-1;if(i<=n&&r<=a)return e.maxima[t]??-1;cU(e,t);let o=n+r>>1;return Math.max(lU(e,t*2,n,o,i,a),lU(e,t*2+1,o+1,r,i,a))}function uU(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}cU(e,t);let s=n+r>>1;uU(e,t*2,n,s,i,a,o),uU(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 dU(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 fU(e){let t=FH(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=dU(t,a.low),o=dU(t,a.high);a.offset=lU(r,1,0,n-1,e,o)+1,uU(r,1,0,n-1,e,o,a.offset),i=Math.max(i,a.offset+1)}return i}function pU(e){let t=new Set(e.flatMap(e=>e.isPinned?[e.offset]:[]));if(t.size>1)return;let[n]=t;return n??null}function mU(e,t,n,r){let i=t*XH+ZH+QH,a=r?{x:e.low,y:e.line-eU,width:e.high-e.low,height:320}:{x:e.line-eU,y:e.low,width:320,height:e.high-e.low},o=e.line-eU,s=e.line+eU,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+ZH>o&&(o=u+ZH,c=!0),a>=e.line&&a-ZH<s&&(s=a-ZH,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 hU(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(XH,i,a);return o<$H?null:{firstTrack:e-n*o,spacing:o}}let i=Math.min(XH,(r.high-r.low)/(t-1));if(i<$H)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 gU(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 _U(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 vU(e,t,n,r){let i=aU(rU(t,r),e),a=i.map(e=>(e.bundles.sort((e,n)=>{let[i]=e.members,[a]=n.members;return i&&a?sU(i,a,t,r):0}),fU(e.bundles)));i.forEach((i,o)=>{let s=a[o]??1;if(s<2)return;let c=pU(i.bundles),l=mU(i,s,n,r),u=hU(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=>_U(n,d(n),e,t)))for(let e of i.bundles)gU(e,d(e),t,r)})}function yU(e,t){let n=e.map(e=>e.points.map(e=>({x:e.x,y:e.y})));return vU(e,n,t,!0),vU(e,n,t,!1),n}var bU=1<<20,xU=1<<21,SU=64,CU=256;function wU(e,t=SU){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 EU(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 DU(e,t){return Math.floor(t/e.cellSize)}function OU(e,t){return(e+bU)*xU+(t+bU)}function kU(e,t,n,r,i){return(DU(e,r)-DU(e,t)+1)*(DU(e,i)-DU(e,n)+1)}function AU(e,t,n,r,i){return!(kU(e,t,n,r,i)<=CU)}function jU(e,t,n,r,i,a){let o=DU(e,t),s=DU(e,r),c=DU(e,n),l=DU(e,i);for(let e=o;e<=s;e+=1)for(let t=c;t<=l;t+=1)a(OU(e,t))}function MU(e,t){t>=e.isStored.length||e.isStored[t]===0||(e.isStored[t]=0,e.oversizedSlots.delete(t)||jU(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 NU(e,t,n){MU(e,t),EU(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,AU(e,n.x,n.y,n.x+n.width,n.y+n.height)?e.oversizedSlots.add(t):jU(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 PU(e){return e.currentStamp+=1,e.currentStamp<4294967295||(e.visitStamp.fill(0),e.currentStamp=1),e.currentStamp}function FU(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 IU(e,t,n){for(let r=0;r<e.isStored.length;r+=1)if(e.isStored[r]===1&&FU(e,r,t)&&n(r)===!0)return}function LU(e,t,n){let r=t.x+t.width,i=t.y+t.height;if(AU(e,t.x,t.y,r,i)){IU(e,t,n);return}let a=PU(e);for(let r of e.oversizedSlots)if(e.visitStamp[r]=a,FU(e,r,t)&&n(r)===!0)return;let o=DU(e,t.x),s=DU(e,r),c=DU(e,t.y),l=DU(e,i);for(let r=o;r<=s;r+=1)for(let i=c;i<=l;i+=1){let o=e.slotsByCell.get(OU(r,i));if(o){for(let r of o)if(e.visitStamp[r]!==a&&(e.visitStamp[r]=a,FU(e,r,t)&&n(r)===!0))return}}}function RU(e,t,n=()=>!0){let r=!1;return LU(e,t,e=>n(e)?(r=!0,!0):!1),r}function zU(e,t){let n=wU(t,e.length);for(let[t,r]of e.entries())NU(n,t,r);return n}var BU=1,VU=42,HU=42,UU=4,J=0,Y=1,WU=2,GU=3,KU=1024,qU=32,JU=-2,YU=1,XU=2,ZU=-1;function QU(){return{values:new Float64Array(64),length:0}}function $U(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 eW(e){return e.values.subarray(0,e.length)}function tW(){return{lines:QU(),starts:QU(),ends:QU()}}function nW(e,t,n,r){r<n||($U(e.lines,t),$U(e.starts,n),$U(e.ends,r))}function X(){return{alongs:QU(),acrosses:QU()}}function rW(e,t,n){return $U(e.alongs,t),$U(e.acrosses,n),e.alongs.length-1}function iW(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+UU;return{left:Math.round(n-VU),top:Math.max(Math.round(r-VU),o),right:Math.round(i+VU),bottom:Math.round(a+VU)}}function aW(e){let t=NH(e.length);return e.forEach((e,n)=>{PH(t,n,e.x-BU,e.y-BU,e.x+e.width+BU,e.y+e.height+BU)}),t}function oW(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===WU?{starts:e.tops,lows:e.lefts,highs:e.rights}:{starts:e.bottoms.map(e=>-e),lows:e.lefts,highs:e.rights}}function sW(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 cW(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=kW(o,0,o.length,i[t]??0);e<o.length&&(o[e]??0)<=(a[t]??0)&&s.push(t)}let c=NH(s.length);return s.forEach((t,n)=>{PH(c,n,e.lefts[t]??0,e.tops[t]??0,e.rights[t]??0,e.bottoms[t]??0)}),c}function lW(e,t,n){let r=oW(e,t),i=t===Y||t===GU,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 uW(e,t,n){if(n.alongs.length*e.count<=xW)return lW(e,t,n);let r=n.alongs.length*bW<e.count?cW(e,t,eW(n.acrosses)):e,i=oW(r,t),a=t===Y||t===GU,o=eW(n.alongs).map(e=>a?-e:e),s=eW(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=FH(c),u=RH(l.length),d=new Float64Array(u*2).fill(1/0),f=new Float64Array(o.length).fill(1/0),p=sW(i.starts),m=0;for(let e of sW(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=LH(l,i.lows[e]??0)+1+u,a=LH(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=LH(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 dW(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 fW(e,t,n){if(t.length*e.count<=xW)return dW(e,t,n);let r=new Uint8Array(t.length),i=NH(t.length);for(let e=0;e<t.length;e+=1)PH(i,e,t[e]??0,n[e]??0,t[e]??0,n[e]??0);return GH(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 pW(e,t){let n={xs:QU(),ys:QU(),awayDirections:QU()};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,GU],[i,a,J,GU],[e,o,Y,WU],[i,o,J,WU]])$U(n.xs,t),$U(n.ys,r),$U(n.awayDirections,s*4+c)}return n}function mW(e,t){return{rays:t,hits:t.map((t,n)=>uW(e,n,t))}}function hW(e,t,n){return t===J?Math.min(e,n.right):t===Y?Math.max(e,n.left):t===WU?Math.min(e,n.bottom):Math.max(e,n.top)}function gW(e,t,n){if(!Number.isFinite(t))return null;let r=n===J||n===WU?t+BU-14:t-BU+14;return Math.abs(r-e)<=HU?null:Math.round((e+r)/2)}function _W(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&&nW(e,t,o,Math.min(n,r)),o=Math.max(o,i);nW(e,t,o,r)}function vW(e,t){let n=tW(),r=tW(),i=[X(),X(),X(),X()],a=t.map(e=>{let t=e.outwardDirection===J||e.outwardDirection===Y;return rW(i[e.outwardDirection]??X(),t?e.x:e.y,t?e.y:e.x)}),o=mW(e.blockers,i);return t.forEach((t,i)=>{let s=hW(o.hits[t.outwardDirection]?.[a[i]??0]??1/0,t.outwardDirection,e.frame);t.outwardDirection===J||t.outwardDirection===Y?(nW(n,t.y,Math.min(t.x,s),Math.max(t.x,s)),nW(r,t.x,t.y,t.y)):(nW(r,t.x,Math.min(t.y,s),Math.max(t.y,s)),nW(n,t.y,t.x,t.x))}),{horizontal:n,vertical:r}}var yW=12,bW=4,xW=4096;function SW(e,t){let n=pW([...e.hardRects,...e.softRects],t),r=n.xs.length;return{count:r,xs:eW(n.xs),ys:eW(n.ys),awayDirections:eW(n.awayDirections),rows:new Float64Array(r*yW).fill(NaN)}}function CW(e,t,n,r,i,a){let o=t*yW+n*3;e[o]=r,e[o+1]=i,e[o+2]=a}function wW(e,t,n,r){let i=Float64Array.from(t,t=>e.xs[t]??0),a=Float64Array.from(t,t=>e.ys[t]??0),o=fW(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]=rW(i,a?t:n,a?n:t)}}let l=mW(n,s),u=(e,t,n)=>hW(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*yW,(s+1)*yW),o[n]===1)continue;let m=i[n]??0,h=a[n]??0,g=e=>c[n*4+e]??-1;CW(e.rows,s,0,h,u(l,Y,g(Y)),u(l,J,g(J))),CW(e.rows,s,1,m,u(l,GU,g(GU)),u(l,WU,g(WU)));let _=e.awayDirections[s]??0,v=Math.floor(_/4),y=_%4,ee=gW(m,l.hits[v]?.[g(v)]??1/0,v);ee!==null&&f.push(s,rW(d[GU]??X(),h,ee),rW(d[WU]??X(),h,ee),ee);let te=gW(h,l.hits[y]?.[g(y)]??1/0,y);te!==null&&te>=r.top&&p.push(s,rW(d[Y]??X(),m,te),rW(d[J]??X(),m,te),te)}let m=mW(n,d);for(let t=0;t<f.length;t+=4)CW(e.rows,f[t]??0,2,f[t+3]??0,u(m,GU,f[t+1]??0),u(m,WU,f[t+2]??0));for(let t=0;t<p.length;t+=4)CW(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=tW(),i=tW(),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*yW+n*3,i=e.rows[r]??NaN,o=a[n];!Number.isNaN(i)&&o&&nW(o,i,e.rows[r+1]??0,e.rows[r+2]??0)}return _W(r,t.top,t.left,t.right,n),nW(r,t.bottom,t.left,t.right),nW(i,t.left,t.top,t.bottom),nW(i,t.right,t.top,t.bottom),{horizontal:r,vertical:i}}function EW(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 DW(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&&EW(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 OW(e){let t=eW(e.lines),n=eW(e.starts),r=eW(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 kW(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 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 jW(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 MW(e){for(let t=1;t<e.length;t+=1)e[t]=(e[t]??0)+(e[t-1]??0);return e}function NW(e){return FH(Float64Array.from(e.lines))}function PW(e,t){let n=RH(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]=kW(t,0,t.length,e.starts[o]??0),i[o]=AW(t,0,t.length,e.ends[o]??0)-1,jW(n,r[o]??0,i[o]??-1,e=>{a[e+1]=(a[e+1]??0)+1});MW(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)jW(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 FW(e,t,n,r){let i=kW(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?AW(e.lines,i,s,n):kW(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 IW(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=FH(o),c=RH(Math.max(s.length*2-1,1)),l=e=>[kW(s,0,s.length,n[e]??0)*2+1,kW(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);jW(c,t,n,e=>{u[e+1]=(u[e+1]??0)+1})}MW(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);jW(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 LW(e,t){let n=kW(e,0,e.length,t);return e[n]===t?n*2:n===0||n===e.length?-1:n*2-1}function RW(e,t,n,r){let i=LW(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=kW(e.alongLows,i,e.offsets[t+1]??0,r);if(a>i&&(e.reachMaxima[a-1]??0)>n)return!0}return!1}function zW(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=NW(e),o=RH(Math.max(a.length,1)),s=new Int32Array(o*2),c=new Int32Array(o*2).fill(-1),l=t=>kW(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=kW(a,0,a.length,t.starts[n]??0),s=AW(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 BW(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 VW(e){return{horizontalPieces:new Int32Array(e),verticalPieces:new Int32Array(e),neighbors:new Int32Array(e*4).fill(JU),softSteps:new Uint8Array(e*4)}}function HW(e,t){let n=e.xs.length*2,r=VW(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 UW(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 WW(e,t){let n=iW(e,t);if(!n)return null;let r=aW(e.hardRects),i=SW(e,n);return wW(i,Array.from({length:i.count},(e,t)=>t),r,n),GW(e,n,r,i)}function GW(e,t,n,r){let i=TW(r,t,n);return{input:e,frame:t,blockers:n,corners:r,horizontal:OW(i.horizontal),vertical:OW(i.vertical),softAlongX:IW(e.softRects,!0),softAlongY:IW(e.softRects,!1)}}function KW(e){return WW(e,[])}function qW(e,t){return e.left===t.left&&e.top===t.top&&e.right===t.right&&e.bottom===t.bottom}function JW(e,t){let n=iW(e.input,t),r=n&&!qW(n,e.frame)?WW(e.input,t):e;if(!r)return null;let{softAlongX:i,softAlongY:a}=r,o=vW(r,t),s=DW(r.horizontal,OW(o.horizontal)),c=DW(r.vertical,OW(o.vertical)),l=PW(c,NW(s)),u=PW(s,NW(c)),d=zW(s,c),f=VW(KU),p=new Int32Array(KU*2).fill(ZU),m=(e,t)=>{let n=p.length-1;for(let r=UW(e,t,n);;r=r+1&n){let n=p[r]??ZU;if(n===ZU||f.horizontalPieces[n]===e&&f.verticalPieces[n]===t)return r}},h=()=>{p=new Int32Array(p.length*2).fill(ZU);for(let e=0;e<b.nodeCount;e+=1)p[m(f.horizontalPieces[e]??0,f.verticalPieces[e]??0)]=e},g=(e,t)=>{let n=p[m(e,t)]??ZU;if(n!==ZU)return n;let r=b.nodeCount;return r===b.xs.length&&(f=HW(b,f)),(r+1)*2>p.length&&h(),b.xs[r]=c.lines[t]??0,b.ys[r]=s.lines[e]??0,f.horizontalPieces[r]=e,f.verticalPieces[r]=t,p[m(e,t)]=r,b.nodeCount+=1,r},_=(e,t)=>{let n=t===J||t===WU,r=b.xs[e]??0,i=b.ys[e]??0;if(t===J||t===Y){let t=f.horizontalPieces[e]??0,a=FW(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=FW(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]??JU;if(n!==JU)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===XU;let r=v(e,t),o=t===J||t===Y,s=o?b.ys:b.xs,c=o?b.xs:b.ys,l=c[e]??0,u=c[r]??0,d=r>=0&&RW(o?i:a,s[e]??0,Math.min(l,u),Math.max(l,u)),p=d?XU:YU;return f.softSteps[e*4+t]=p,r>=0&&(f.softSteps[r*4+(t^1)]=p),d},ee=(e,t)=>{let n=BW(s,t,e),r=BW(c,e,t);return n<0||r<0?-1:g(n,r)},te=e=>d[f.horizontalPieces[e]??0]??-1,ne=(s.count+c.count)*qU,b={nodeCount:0,xs:new Float64Array(KU),ys:new Float64Array(KU),neighborOf:v,isSoftStep:y,nodeAt:ee,componentOf:te,beginSearch:()=>{b.nodeCount<=ne||(p.fill(ZU),f.neighbors.fill(JU,0,b.nodeCount*4),f.softSteps.fill(0,0,b.nodeCount*4),b.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 b}var YW=30,XW=60,ZW=512,QW=3,$W=400,eG=6,tG=1,nG=1e6,rG=4096,iG=200,aG=240,oG=2,sG=3e3,cG=[960,3840],lG=512,uG=64,dG=14,fG=8,pG=6.6,mG=5,hG=10,gG=2,_G=[.5,.35,.65,.2,.8],vG=256,yG=0,bG=1,xG=[{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},SG={left:0,right:1,top:2,bottom:3},CG=[1,0,3,2],wG=1;function TG(e){return e===`left`||e===`right`}function EG(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function DG(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function OG(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 kG(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 AG(e){return e.from.y===e.to.y}function jG(e,t){let n=t.x+t.width,r=t.y+t.height;if(AG(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 MG(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 NG(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 PG(e){return e.slice(1).flatMap((t,n)=>{let r=e[n];return r?[{from:r,to:t}]:[]})}function FG(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function IG(e){return{count:e.length,messageAt:t=>e[t]??``}}function LG(e){let t=e.reduce((e,t)=>e+t.count,0),n=t<=bt.layoutWarnings?t:bt.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 RG(e,t){return t.x>=e.x+e.width||t.x+t.width<=e.x}function zG(e,t,n){if(e.id===t.id)return{exitSide:`right`,entrySide:`top`};if(n)return{exitSide:`bottom`,entrySide:`bottom`};let r=EG(e),i=EG(t);return RG(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 BG=[`right`,`left`,`bottom`,`top`];function VG(e,t){let n=e.outputPort??lK(e.from,t.exitSide,1)[0]??EG(e.from),r=lK(e.to,t.entrySide,1)[0]??EG(e.to);if(!mK(t.exitSide,t.entrySide))return{...e,...t,start:n,end:r};let i=hK(r,t.entrySide,e.to,n),a=i===r&&!e.outputPort?hK(n,t.exitSide,e.from,r):n;return{...e,...t,start:a,end:i}}function HG(e,t){return NG(t.map(t=>({x:e.xs[t>>2]??0,y:e.ys[t>>2]??0})))}function UG(e,t,n,r,i){return t.map(t=>({side:t,point:t===n?r:lK(e,t,1)[0]??EG(e),direction:i[t],bias:t===n?0:tG}))}function WG(e){return[e,...BG.filter(t=>t!==e)]}function GG(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]:WG(t.exitSide),o=n.toSide?[n.toSide]:WG(t.entrySide);if(a.length<2&&o.length<2)return null;let s=VG(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}]:UG(r,a,a[0]??t.exitSide,s.start,Z),entries:UG(i,o,o[0]??t.entrySide,s.end,SG)}}function KG(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:CG[e.direction]??0}))])}function qG(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 JG(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 YG(e){return e===Z.right||e===Z.left}function XG(e,t){return t.x>e.x?Z.right:t.x<e.x?Z.left:t.y>e.y?Z.bottom:Z.top}function ZG(e,t){if(YG(e.direction)===YG(t.direction))return null;let n=YG(e.direction)?{x:t.point.x,y:e.point.y}:{x:e.point.x,y:t.point.y};return $K(n,e.point)||$K(n,t.point)||XG(e.point,n)!==e.direction||XG(n,t.point)!==t.direction?null:[e.point,n,t.point]}function QG(e,t,n){return PG([...e]).every(e=>{let r=Gq(e.from,e.to),i=n.obstaclesIn?.(DG(r,wG));return i!==void 0&&!i.hardRects.some(e=>e!==t.from&&e!==t.to&&MG(DG(e,wG),r))})}function $G(e){return PG([...e]).reduce((e,t)=>e+dq(t),0)}function eK(e,t,n,r){let i=Gq(e.from,e.to),a=n.obstaclesIn?.(DG(i,wG));if(!a||a.hardRects.some(e=>e!==t.from&&e!==t.to&&MG(DG(e,wG),i))||a.softRects.some(e=>MG(e,i)))return!1;let o=GK(r,i);return!(AG(e)?o.verticals:o.horizontals).some(t=>gq(e,t))}function tK(e,t){return JG(e,t)?[e.point,t.point]:ZG(e,t)}function nK(e){return e.exits.flatMap(t=>e.entries.flatMap(e=>{let n=tK(t,e);return n?[{exit:t,entry:e,points:n,bends:n.length-2,cost:$G(n)+t.bias+e.bias}]:[]}))}function rK(e,t,n){let r=nK(e).filter(n=>QG(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&&!PG(c.points).every(r=>eK(r,e.plan,t,n))?null:{exit:c.exit,entry:c.entry,points:c.points}}function iK(e,t,n){let r=MK(),i=UK();for(let a of e){let e=rK(a,t,i);if(e){qG(a,e.exit,e.entry,e.points),WK(i,PG(e.points));continue}let o=TK(a.plan,n),s=SK(t,o),c=s?CK(KG([a]),t,o,s):null,l=c?qK(c,a.exits,a.entries,null,nG,r,GK(i,o)):null;if(FK(r),!c||!l)continue;let u=HG(c,l.states);qG(a,l.exit,l.entry,u),WK(i,PG(u))}}function aK(e,t,n,r){let i=e.flatMap(e=>{if(r.cleanIds.has(e.wire.id))return[];let n=GG(e,t.get(e)??{exitSide:e.exitSide,entrySide:e.entrySide});return n?[n]:[]});i.length>0&&iK(i,n,r)}function oK(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 sK(e,t,n){let r=t.boxesById.get(e.from),i=t.boxesById.get(e.to);if(!r||!i)return null;let a=zG(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??EG(r),end:EG(i),found:null};return n&&(s.exitSide=n.exitSide,s.entrySide=n.entrySide),{plan:s,facing:a}}function cK(e,t){let n=new Map,r=e.wires.flatMap(r=>{let i=sK(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=sK(r,e,t.routeById.get(r.id));return i?(n.set(i.plan,i.facing),[i.plan]):[]});aK(r,n,e,t),oK(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 lK(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(dG,(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+fG,Math.min(o,e.y+e.height-fG-(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)*dG/2;return r.map(e=>({x:Math.round(a+e*dG),y:i}))}function uK(e,t){let n=TG(t)?e.height:e.width;return Math.max(1,Math.floor((n-16)/dG)+1)}function dK(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:EG(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??EG(e.from),assign:t=>{e.end=t}}]);return kG(t?n.filter(e=>t.has(e.box.id)):n,e=>`${e.box.id}|${e.side}`)}function fK(e){return new Map([...e.entries()].map(([e,t])=>[e,[...kG(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 pK(e,t){for(let[n,r]of e){let e=r[0],i=t.get(n)??[];if(!e)continue;let a=lK(e.box,e.side,i.length);for(let e of r){let t=a[i.indexOf(e.groupKey)];t&&e.assign(t)}}}function mK(e,t){return e===`right`&&t===`left`||e===`left`&&t===`right`||e===`bottom`&&t===`top`||e===`top`&&t===`bottom`}function hK(e,t,n,r){return TG(t)?r.y>=n.y+fG&&r.y<=n.y+n.height-fG?{x:e.x,y:r.y}:e:r.x>=n.x+fG&&r.x<=n.x+n.width-fG?{x:r.x,y:e.y}:e}function gK(e,t){let n=(e,n)=>(t.get(`${e.id}|${n}`)?.length??0)===1,r=new Map([...kG(e,e=>e.exitKey)].map(([e,t])=>[e,t.length]));for(let t of e){if(t.from.id===t.to.id||!mK(t.exitSide,t.entrySide))continue;let e=t.busKey===null&&n(t.to,t.entrySide)?hK(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=hK(t.start,t.exitSide,t.from,t.end)):t.end=e}}function _K(e,t){return[...e.entries()].flatMap(([e,n])=>{let r=n[0],i=t.get(e)?.length??0;return!r||i<=uK(r.box,r.side)?[]:[`box ${r.box.id} has ${i} wires on its ${r.side} side, more than fit`]})}function vK(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 yK(e){let t=[...e.boxesById.values()],n=zU(t,lG),r=zU(e.softObstacles,lG);return i=>{let a=[],o=[];return LU(n,i,e=>{let n=t[e];n&&a.push(n)}),LU(r,i,t=>{let n=e.softObstacles[t];n&&o.push(n)}),{hardRects:a,softRects:o}}}function bK(e){return e.obstaclesIn?e:{...e,obstaclesIn:yK(e)}}function xK(e){let t=e.x-oG,n=e.y-oG,r=e.width+4,i=e.height+4;return[{x:t,y:n,width:r,height:oG},{x:t,y:e.y+e.height,width:r,height:oG},{x:t,y:n,width:oG,height:i},{x:e.x+e.width,y:n,width:oG,height:i}]}function SK(e,t){let n=e.obstaclesIn?.(t)??null;return n&&n.hardRects.length<=sG?n:null}function CK(e,t,n,r){let i=KW({hardRects:[...r.hardRects,...xK(n)],softRects:r.softRects,contentTop:t.contentTop});return i?JW(i,e):null}function wK(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=KW({hardRects:[...i,...xK(n)],softRects:[...r.softRects,...a],contentTop:t.contentTop});return o?JW(o,vK([e])):null}function TK(e,t,n=aG){let r=(t.routeById.get(e.wire.id)?.points??[]).map(e=>({x:e.x,y:e.y,width:0,height:0}));return DG(OG([e.from,e.to,...r])??e.from,n)}function EK(){return{states:new Int32Array(1024),priorities:new Float64Array(1024),tieBreaks:new Float64Array(1024),size:0,lastPoppedPriority:0}}function DK(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 OK(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 kK(e){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}return e.size+=1,e.size-1}function AK(e,t){let n=t;for(;n>0;){let t=n-1>>1;if(!DK(e,n,t))return;OK(e,t,n),n=t}}function jK(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;OK(e,0,e.size);let n=0;for(;;){let r=n*2+1,i=r+1,a=n;if(r<e.size&&DK(e,r,a)&&(a=r),i<e.size&&DK(e,i,a)&&(a=i),a===n)return t;OK(e,a,n),n=a}}function MK(){return{bestCost:new Float64Array(rG).fill(1/0),cameFrom:new Int32Array(rG).fill(-1),touchedStates:new Int32Array(rG),touchedCount:0,heap:EK()}}function NK(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 PK(e,t){if(e.touchedCount===e.touchedStates.length){let t=new Int32Array(e.touchedCount*2);t.set(e.touchedStates),e.touchedStates=t}e.touchedStates[e.touchedCount]=t,e.touchedCount+=1}function FK(e){for(let t=0;t<e.touchedCount;t+=1){let n=e.touchedStates[t]??0;e.bestCost[n]=1/0,e.cameFrom[n]=-1}e.touchedCount=0,e.heap.size=0}function IK(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:SG[t.entrySide],bias:0},s=qK(e,[a],[o],n,YW,r,i)?.states??null;return FK(r),s}function LK(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 RK(e){return e===yG||e===bG}function zK(e,t,n,r){if(e===CG[t.direction])return 2;let i=RK(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=xG[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 BK(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,RK(t.direction));return[{...t,node:n,component:e.componentOf(n),approachStart:r,approachEnd:i}]})}function VK(e,t){for(let n of e)if(n.node===t)return n;return null}var HK={horizontals:[],verticals:[]};function UK(){return{grid:wU(ZW),segments:[]}}function WK(e,t){for(let n of t)NU(e.grid,e.segments.length,Gq(n.from,n.to)),e.segments.push(n)}function GK(e,t){let n={horizontals:[],verticals:[]};return LU(e.grid,t,t=>{let r=e.segments[t];r&&(AG(r)?n.horizontals:n.verticals).push(r)}),n}function KK(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)hq(t.from.x,i,o)&&hq(a,t.from.y,t.to.y)&&(c+=1);return c}for(let t of e.horizontals)hq(t.from.y,a,s)&&hq(i,t.from.x,t.to.x)&&(c+=1);return c}function qK(e,t,n,r,i,a,o=HK){e.beginSearch();let s=BK(e,n),c=BK(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{heap:u}=a;NK(a,e.nodeCount*4);let d=(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)+zK(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,PK(a,t);let n=kK(u);u.states[n]=t,u.priorities[n]=e.bias+d(e.node,e.direction),u.tieBreaks[n]=-e.bias,AK(u,n)}for(;;){let t=jK(u);if(t<0)return null;let n=t>>2,s=t&3,f=VK(l,n);if(f&&s===f.direction){let e=JK(a.cameFrom,t),n=VK(c,(e[0]??0)>>2);return n?{states:e,exit:n,entry:f}:null}let p=a.bestCost[t]??1/0;if(u.lastPoppedPriority>p+d(n,s)+1e-6)continue;let m=VK(c,n);for(let c=0;c<4;c+=1){if(m&&c!==m.direction||c===CG[s])continue;let f=e.neighborOf(n,c);if(f<0)continue;let h=VK(l,f);if(h&&c!==h.direction)continue;NK(a,e.nodeCount*4);let g=Math.abs((e.xs[f]??0)-(e.xs[n]??0))+Math.abs((e.ys[f]??0)-(e.ys[n]??0)),_=r!==null&&LK(e,n,f,r),v=g+(c===s?0:i)+KK(o,e,n,f)*XW+(e.isSoftStep(n,c)?g*QW:0)+(_?$W:0),y=f*4+c,ee=p+Math.max(v,1)+(h?.bias??0);if(ee>=(a.bestCost[y]??1/0))continue;a.bestCost[y]=ee,a.cameFrom[y]=t,PK(a,y);let te=kK(u);u.states[te]=y,u.priorities[te]=ee+d(f,c),u.tieBreaks[te]=-ee,AK(u,te)}}}function JK(e,t){let n=[];for(let r=t;r!==-1;r=e[r]??-1)n.push(r);return n.reverse()}function YK(e,t){let n=xG[Z[t]]??{x:0,y:0};return{x:e.x+n.x*14,y:e.y+n.y*14}}function XK(e){let t=YK(e.start,e.exitSide),n=YK(e.end,e.entrySide);return NG([e.start,t,{x:n.x,y:t.y},n,e.end])}function ZK(e,t){if(!e.wire.back)return null;let n=OG([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 QK(e,t,n){let r=e&&n?HG(e,n):XK(t);return{plan:t,points:r,segments:PG(r),routedPoints:r,states:n}}function $K(e,t){return e.x===t.x&&e.y===t.y}function eq(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||!$K(n.start,e.start)||!$K(n.end,e.end)?null:{plan:e,points:n.points,segments:PG(n.points),routedPoints:n.points,states:n.isRouted?[]:null}}function tq(e,t,n,r,i,a=aG){let o=TK(e,n,a),s=SK(t,o);if(!s)return null;let c=CK(vK([e]),t,o,s),l=c?IK(c,e,ZK(e,t.loopFrames),r,GK(i,o)):null;return l?QK(c,e,l):null}function nq(e,t,n,r,i){let a=TK(e,n),o=t.obstaclesIn?.(a)??null,s=o?wK(e,t,a,o):null;return QK(s,e,s?IK(s,e,ZK(e,t.loopFrames),r,GK(i,a)):null)}function rq(e,t,n,r,i){let a=n.isPreview?[]:cG;for(let o of a){let a=tq(e,t,n,r,i,o);if(a)return a}return nq(e,t,n,r,i)}function iq(e){let{found:t}=e;return!t||t.exitSide!==e.exitSide||t.entrySide!==e.entrySide||!$K(t.start,e.start)||!$K(t.end,e.end)?null:{plan:e,points:t.points,segments:PG(t.points),routedPoints:t.points,states:[]}}function aq(e,t,n,r,i){let a=eq(e,n)??iq(e)??tq(e,t,n,r,i)??rq(e,t,n,r,i);return WK(i,a.segments),a}function oq(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)+fG,o=(TG(t)?e.y+e.height:e.x+e.width)-fG;return{low:Math.max(a,i-dG/2),high:Math.min(o,i+dG/2)}}function sq(e,t,n){let r=MK(),i=UK(),a=e.map(e=>aq(e,t,n,r,i));if(n.isPreview)return a;let o=yU(a.map(e=>({points:e.points,exitKey:e.plan.exitKey,busKey:e.plan.busKey,startSlack:oq(e.plan.from,e.plan.exitSide,e.plan.start,e.plan.outputPort!==null),endSlack:oq(e.plan.to,e.plan.entrySide,e.plan.end,!1)})),e=>t.obstaclesIn?.(e).hardRects??[]);return a.map((e,t)=>{let n=NG(o[t]??e.points);return{...e,points:n,segments:PG(n)}})}function cq(e){return Math.max(0,e.points.length-2)}function lq(e){return Math.ceil(e.length*pG)}function uq(e,t){return{x:e.x-t/2,y:e.y-hG,width:t,height:13}}function dq(e){return Math.abs(e.from.x-e.to.x)+Math.abs(e.from.y-e.to.y)}function fq(e,t){if(!AG(e))return[];let n=e.from.y;return[Math.min(e.from.x,e.to.x)+mG+t/2,Math.max(e.from.x,e.to.x)-mG-t/2].flatMap(e=>[{x:e,y:n-mG},{x:e,y:n+mG+hG}])}function pq(e,t){let n=[...e].sort((e,t)=>dq(t)-dq(e));return[...e.slice(0,1),...n].flatMap(e=>[..._G.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 AG(e)?[{x:r,y:i-mG},{x:r,y:i+mG+hG}]:[{x:r+mG+t/2,y:i+hG/2},{x:r-mG-t/2,y:i+hG/2}]}),...fq(e,t)])}function mq(e,t,n){let r=new Map,i=e.flatMap(e=>e.segments),a=zU(i.map(e=>Gq(e.from,e.to)),vG),o=[...t.boxesById.values(),...t.softObstacles],s=zU(o,vG),c=[],l=wU(vG);for(let u of e){let e=u.plan.wire.label;if(!e)continue;let d=lq(e),f=pq(u.segments,d),p=f.find(e=>{let n=uq(e,d);if(n.y<t.contentTop)return!1;let r=DG(n,gG);return RU(a,r,e=>{let t=i[e];return t!==void 0&&jG(t,r)})||RU(s,n,e=>{let t=o[e];return t!==void 0&&MG(n,t)})?!1:!RU(l,n,e=>{let t=c[e];return t!==void 0&&MG(n,t)})}),m=p??f[0]??EG(u.plan.from);p||n.push(`wire ${u.plan.wire.id} label "${e}" has no clear spot`);let h=uq(m,d);r.set(u.plan.wire.id,{at:{x:Math.round(m.x),y:Math.round(m.y)},bounds:h}),NU(l,c.length,h),c.push(h)}return r}function hq(e,t,n){return e>Math.min(t,n)+.5&&e<Math.max(t,n)-.5}function gq(e,t){if(AG(e)===AG(t))return!1;let n=AG(e)?e:t,r=n===e?t:e;return hq(r.from.x,n.from.x,n.to.x)&&hq(n.from.y,r.from.y,r.to.y)}function _q(e,t){if(AG(e)!==AG(t))return!1;let n=AG(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 vq(e,t){return e.plan.busKey!==null&&e.plan.busKey===t.plan.busKey||e.plan.exitKey===t.plan.exitKey}function yq(e){let t=e.flatMap(e=>e.segments),n=NH(t.length),r=new Int32Array(t.length),i=0;return e.forEach((e,t)=>{for(let a of e.segments)PH(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 bq(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&&!vq(c,l)&&(gq(u,d)?e.set(s,!0):_q(u,d)&&e.set(s,!1))}function xq(){return{firsts:[],seconds:[],isCrossings:[]}}function Sq(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 Cq(e,t){let n=[];return e.wireIndexByPiece.forEach((e,r)=>{t.isChangedByWire[e]&&n.push(r)}),n}function wq(e,t){let n=NH(t.length);return t.forEach((t,r)=>{PH(n,r,e.lefts[t]??0,e.tops[t]??0,e.rights[t]??0,e.bottoms[t]??0)}),n}function Tq(e,t,n,r){let i=xq();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 WH(t.rects,(n,i)=>bq(r,e,t,n,i)),Sq(xq(),r,e.length);let i=Cq(t,n);return GH(wq(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||bq(r,e,t,s,o)}),Sq(Tq(n.previous.wirePairs,n.wireIndexByPrevious,n.wireIndexByPrevious,(e,t)=>!n.isChangedByWire[e]&&!n.isChangedByWire[t]),r,e.length)}function Dq(e,t,n,r){let i=qH(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 Oq=new WeakMap;function kq(e){let t=Oq.get(e);if(t)return t;let n=[...e.boxesById.values()];return Oq.set(e,n),n}function Aq(e){return`box ${e.id}`}function jq(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&&jG(f,d)&&e.set(c,!0)}function Mq(e,t,n,r){let i=n.map(e=>DG(e,-2)),a=MH(i),o=new Map;if(!r)return GH(t.rects,a,(r,a)=>jq(o,e,t,n,i,r,a)),Sq(xq(),o,n.length);let s=Cq(t,r);GH(wq(t.rects,s),a,(r,a)=>jq(o,e,t,n,i,s[r]??0,a));let c=n.map(e=>r.changedSolidKeys.has(Aq(e))),l=n.flatMap((e,t)=>c[t]?[t]:[]);GH(t.rects,wq(a,l),(r,a)=>jq(o,e,t,n,i,r,l[a]??0));let u=new Map(n.map((e,t)=>[Aq(e),t])),d=r.previous.solidKeys.map(e=>u.get(e)??-1),f=xq();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))}),Sq(f,o,n.length)}function Nq(e){return JSON.stringify([e.points,e.plan.exitKey,e.plan.busKey,e.plan.from.id,e.plan.to.id])}function Pq(e,t,n,r){if(!r||!n||n.size>uG)return null;let i=e.map((e,n)=>r.wireSignatureById.get(e.plan.wire.id)!==t[n]);if(i.filter(Boolean).length>iG)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 Fq(e,t,n,r,i){let a=yq(e),o=kq(t),s=e.map(Nq),c=Pq(e,s,n,i),l=Mq(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(Aq),wirePairs:u,runsThroughPairs:l});let d=t=>e[t]?.plan.wire.id;return[Dq(l,e.length,o.length,(e,t)=>`wire ${d(e)} runs through ${o[t]?.kind} ${o[t]?.id}`),Dq(u,e.length,e.length,(e,t,n)=>`wire ${d(e)} ${n?`crosses`:`overlaps`} wire ${d(t)}`)]}function Iq(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=cq(e);return t>eG?[`wire ${e.plan.wire.id} bends ${t} times`]:[]})}function Lq(e,t){return AG(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 Rq(e,t){if(!t||t===e)return null;let n=e.points.find(e=>t.segments.some(t=>Lq(e,t)));return!n||n.x===e.plan.end.x&&n.y===e.plan.end.y?null:n}function zq(e,t,n,r,i){return pK(n,r),gK([...e.plans,...e.contextPlans],r),sq(e.plans,t,i)}function Bq(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 Vq(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 Hq(e,t,n){t.length>uG?GH(MH(e),MH(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 Uq(e,t){return e.storedWireKeyOf?.(t)??JSON.stringify(t)}function Wq(e,t,n){if(!t||!n)return{routeById:t?.routeById??new Map,cleanIds:new Set,isPreview:!1};let r=n.rects.map(e=>DG(e,14)),i=e.wires.flatMap(n=>{let r=t.routeById.get(n.id);return r&&r.wireKey===Uq(e,n)?[{wire:n,remembered:r}]:[]}),a=i.flatMap(({wire:e,remembered:t})=>PG(t.points).map(t=>({wireId:e.id,rect:Gq(t.from,t.to)}))),o=new Set;Hq(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 Gq(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 Kq(e,t,n){let r=new Map(n.map(t=>[t.plan.wire.id,{wireKey:Uq(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 qq(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:FG(i),start:i[0]??r.start,end:i[i.length-1]??r.end,label:r.wire.label,labelAt:t.get(r.wire.id)?.at??EG(r.from),isDashed:r.wire.dashed||r.wire.back,isBack:r.wire.back,tone:r.wire.tone,hasArrowhead:a===void 0||a===e,joinAt:Rq(e,a)}})}function Jq(e){let t=bK(e),n={routeById:new Map,cleanIds:new Set,isPreview:!0},r=cK(t,n),i=dK(r.plans),a=zq(r,t,i,fK(i),n);return qq(a,mq(a,t,[]))}function Yq(e,t){let n=bK(e),r=Bq(n),i=t&&t.contentTop===n.contentTop?Vq(t.rectByKey,r):null,a=Wq(n,t,i),o=cK(n,a),s=n.contextWires?new Set(o.plans.flatMap(e=>[e.from.id,e.to.id])):null,c=dK([...o.plans,...o.contextPlans],s),l=fK(c),u=zq(o,n,c,l,a),d=[],f=mq(u,n,d),p=qq(u,f),m=[...f.values()].map(e=>e.bounds),h=Kq(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:()=>[IG(Iq(u)),...Fq(u,n,i?.keys??null,h,t?.warningPairs??null),IG([..._K(c,l),...d])],extent:OG([...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 Xq(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,Zq=220,Qq=90,$q=30,eJ=18,tJ=12,nJ=20,rJ=18,iJ=28,aJ=12,oJ=2,sJ=20,cJ=26,lJ=18,uJ=22,dJ=40,fJ=18,pJ=8,mJ=320,hJ=256,gJ=160;function _J(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 vJ(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>aJ){let t=_J(e.text,r-i-oJ).map(e=>o(e,1,oJ,null));return[o(``,0,0,a),...t]}let s=e.style===`item`?oJ:a?a.length+1:0;return _J(e.text,r-i-s-+(e.style===`code`)).map((e,t)=>o(e,t,s,a))}function yJ(e,t=cJ){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,vJ(e,n,t)))}function bJ(e){return e.shape===`icon`?gJ:e.shape===`device`?qt[e.device].defaultBoxWidth:Zq}function xJ(e){return e.width??bJ(e)}function SJ(e,t){return Math.floor(e*(t-24)/196)}function CJ(e){let t=e.icon?2:0;if(e.shape===`icon`)return{lines:[],media:null,device:null,fit:`fit`,glyphRoom:56,titleIconChars:0,dialValues:{}};let n=St(e);return e.shape===`device`?{lines:[],media:e.media,device:e.device,fit:e.fit,glyphRoom:0,titleIconChars:t,dialValues:n}:{lines:e.lines,media:Mt(e),device:null,fit:`fit`,glyphRoom:0,titleIconChars:t,dialValues:n}}function wJ(e,t){let{screen:n,bezel:r,toolbarHeight:i,base:a}=qt[e],o=Ft(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 TJ(e,t){let n=t-24,r=Math.round(mJ*t/Zq),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 EJ(e,t){return e.device?wJ(e.device,t-24):e.media?TJ(e.media,t):null}function DJ(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,dialValues:e.dialValues,x:t.x+tJ+r.screen.x,y:t.y+n+r.screen.y,width:r.screen.width,height:r.screen.height}}function OJ(e,t,n,r){if(!e.device||!r)return null;let i=t.x+tJ,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 kJ=new WeakMap;function AJ(e){let t=kJ.get(e);if(t)return t;let n=MJ(e);return kJ.set(e,n),n}function jJ(e,t){let n=CJ(e),r=SJ(sJ,t);return{titleLines:_J(e.title,r-n.titleIconChars),wasLines:e.change===`relabeled`&&e.was?_J(e.was,r):[],bodyLines:yJ(n.lines,SJ(cJ,t))}}function MJ(e){let t=CJ(e),n=e.step?fJ:0,r=+!!e.step?.linkedBoardId,i=xJ(e),{titleLines:a,wasLines:o,bodyLines:s}=jJ(e,i),c=tJ+n+t.glyphRoom+(o.length+a.length)*nJ+(s.length+r)*rJ,l=EJ(t,i),u=l?l.height+pJ:0,d=c+tJ+u,f=e.shape===`decision`?e.outputs:[];return{headerHeight:d,outputs:f,content:t,artTop:c+pJ,art:l,height:Math.max(d+f.length*iJ,e.height??0)}}function NJ(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`stroke`:e.stroke.push(t);return}}function PJ(e){let t={box:[],frame:[],wire:[],stroke:[]};for(let n of e.elements.values())NJ(t,n);return{...e,elementsByKind:t,planStepById:new Map(jH(e).map(e=>[e.boxId,e]))}}function FJ(e,t){return e.elementsByKind[t]}function IJ(e,t){return t.step?{label:e.get(t.id)?.label??``,status:t.step.status,linkedBoardId:t.step.linkedBoardId}:null}function LJ(e,t,n){let r=AJ(t),i=xJ(t),a=r.outputs.length>0?(r.height-r.headerHeight)/r.outputs.length:iJ;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,tone:t.shape===`sticky`?t.tone:null,headerHeight:r.headerHeight,media:DJ(r.content,n,r.artTop,r.art),device:OJ(r.content,n,r.artTop,r.art),step:IJ(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*a+a/2}}))}}function RJ(e,t){let n=[...e.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0);return{x:e.size>0?n+Qq:Q,y:t}}function zJ(e){return e.shape===`panel`&&e.step===null&&e.at===null}function BJ(e,t,n){let r=FJ(e,`box`).filter(zJ).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id));if(r.length===0)return;let i=[...n.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0),a=n.size>0?Math.round(i+Qq):Q,o=t;for(let t of r){let r=LJ(e.planStepById,t,{x:a,y:o});n.set(t.id,r),o+=r.height+$q}}function VJ(e,t,n){let r=new Map;for(let t of FJ(e,`box`)){let i=n.get(t.id);i&&r.set(t.id,LJ(e.planStepById,t,i))}for(let t of FJ(e,`box`))t.at&&r.set(t.id,LJ(e.planStepById,t,t.at));BJ(e,t,r);for(let n of FJ(e,`box`))r.has(n.id)||r.set(n.id,LJ(e.planStepById,n,RJ(r,t)));return r}function HJ(e,t){if(e.collapsed)return UJ(e,t);let n=OG(e.contains.flatMap(e=>t.get(e)??[]));return n?{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,stackedBoxCount:null,x:n.x-lJ,y:n.y-lJ-26,width:n.width+36,height:n.height+36+26}:null}function UJ(e,t){let n=e.contains[0],r=n===void 0?void 0:t.get(n);return r?{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,stackedBoxCount:e.contains.length,x:r.x,y:r.y-26,width:r.width+12,height:r.height+26+12}:null}function WJ(e,t){let n=new Map;for(let t of FJ(e,`frame`)){let e=t.collapsed?t.contains[0]:void 0;if(e!==void 0)for(let r of t.contains.slice(1))n.set(r,e)}return n.size===0?{visibleBoxesById:t,topCardIdByHiddenId:n}:{visibleBoxesById:new Map([...t].filter(([e])=>!n.has(e))),topCardIdByHiddenId:n}}function GJ(e,t){let n=t(e.from),r=t(e.to);return n===r?null:n===e.from&&r===e.to?e:{...e,from:n,to:r,fromOutput:n===e.from?e.fromOutput:null}}function KJ(e,t){if(t.size===0)return e;let n=e=>t.get(e)??e;return e.flatMap(e=>GJ(e,n)??[])}function qJ(e,t){return FJ(e,`frame`).flatMap(e=>HJ(e,t)??[])}function JJ(e){return{x:e.x,y:e.y,width:e.width,height:26}}function YJ(e){return{x:0,y:0,width:Q,height:e}}function XJ(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 ZJ(e,t,n){return XJ(OG([...e.flatMap(e=>e.kind===`wire`?[]:[e]),...t?[t]:[],YJ(n)]))}function QJ(e,t){return`box ${e} overlaps box ${t}`}function $J(e,t){return`box ${e} covers the title of frame ${t}`}function eY(e,t,n){let r=[...e.values()],i=YH(r).flatMap(([e,t])=>{let n=r[e],i=r[t];return n&&i&&MG(n,i)?[QJ(n.id,i.id)]:[]}),a=new Map(FJ(n,`frame`).map(e=>[e.id,new Set(e.contains)])),o=zU(r,hJ),s=t.flatMap(e=>{let t=JJ(e),n=[];return LU(o,t,i=>{let o=r[i];o&&!a.get(e.id)?.has(o.id)&&MG(o,t)&&n.push(i)}),n.sort((e,t)=>e-t).map(t=>$J(r[t]?.id??``,e.id))});return[...i,...s]}function tY(e,t,n){let{visibleBoxesById:r,topCardIdByHiddenId:i}=WJ(e,VJ(e,t.boxesTop,t.stepBandPositions)),a=qJ(e,r);return{boxesById:r,frames:a,routing:Yq({wires:KJ(FJ(e,`wire`),i),boxesById:r,softObstacles:a.map(JJ),loopFrames:a.filter(e=>e.isLoop),contentTop:t.contentTop,storedWireKeyOf:t=>e.elements.bodyOf(t.id)},n),collectPlacementWarnings:()=>eY(r,a,e)}}function nY(e){return e.step!==null&&e.at===null}function rY(e){let t=new Map(EH(e).filter(nY).map(e=>[e.id,e])),n=new Map;if(t.size===0)return{positionById:n,bottom:Q,columns:[]};let r=new Map;for(let n of jH(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+=AJ(e).height,c=s,a=Math.max(a,s),s+=$q;t.length>0&&o.push({x:i,bottom:c,boxCount:t.length}),i+=Math.max(...t.map(xJ))+Qq}return{positionById:n,bottom:a+dJ,columns:o}}function iY(e){return e>Q?e-eJ:-1/0}function aY(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+$q,0)]});return n.length===0?0:Math.max(Q,...n)+dJ-Q}function oY(e,t){let n=e.points.map((e,n)=>n%2==1?e+t:e),r=1/0,i=1/0,a=-1/0,o=-1/0;for(let e=0;e+1<n.length;e+=2){let t=n[e]??0,s=n[e+1]??0;r=Math.min(r,t),i=Math.min(i,s),a=Math.max(a,t),o=Math.max(o,s)}let s=e.width/2;return{kind:`stroke`,id:e.id,points:n,strokeWidth:e.width,tone:e.tone,x:r-s,y:i-s,width:a-r+e.width,height:o-i+e.width}}function sY(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:jt(n)}}var cY={plain:null,fail:`failure path`,join:`joins`};function lY(e,t,n){return`${e}|${t}|${n}`}function uY(e,t,n){let r=[cY[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var dY={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function fY(e){return Pt.flatMap(t=>t===`none`||!e.has(t)?[]:[{label:dY[t],swatch:{kind:`change`,change:t}}])}function pY(e){return e?Et.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}})):[]}function mY(e){return hY(e.legend,FJ(e,`wire`),new Set(FJ(e,`box`).map(e=>e.change)),e.planStepById.size>0)}function hY(e,t,n,r){let i=new Map(e.map(e=>[lY(e.tone,e.dashed||e.back,e.back),e.label])),a=new Set,o=[...t].flatMap(e=>{let t=e.dashed||e.back,n=lY(e.tone,t,e.back),r=i.get(n)??uY(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(lY(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,...fY(n),...pY(r)]}function gY(e,t){return t?.kind===`box`?{...e,...jJ(t,e.width)}:{...e,titleLines:[],wasLines:[],bodyLines:[]}}function _Y(e,t){switch(e.kind){case`box`:return gY(e,t);default:return e}}function vY(e,t){return{...e,elements:e.elements.map(e=>_Y(e,t.elements.get(e.id)))}}function yY(e){return vY(bY(e,null).layout,e)}function bY(e,t){let{positionById:n,bottom:r,columns:i}=rY(e),a=r-Q,o=PJ(sY(e,a)),s=r,c=tY(o,{boxesTop:s,contentTop:iY(r),stepBandPositions:n},t?.route??null),l={route:c.routing.memory},u=[...c.frames,...c.routing.wires,...c.boxesById.values(),...FJ(o,`stroke`).map(e=>oY(e,a))],d=xY(o.caption,ZJ(u,c.routing.extent,s),mY(o),n.size>0?i:[],a),f=[...c.routing.collectWarnings(),IG(c.collectPlacementWarnings())];return{layout:{elements:u,...d,warnings:LG(f)},memory:l,warningLists:f}}function xY(e,t,n,r,i){let a=t.y+t.height,o=n.map((e,t)=>({...e,x:Q,y:a+t*uJ})),s=a+o.length*uJ+(o.length>0?12:0),c=e?{text:e,x:Q,y:s}:null,l=o.length*uJ+(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 SY(e){return JSON.stringify(e)}function CY(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 wY(e,t,n){let r=n,i=new Map,a=[],o=[];for(let e of t.elements)e.kind===`box`&&i.set(e.id,e),e.kind===`frame`&&a.push(JJ(e)),e.kind===`frame`&&e.isLoop&&o.push(e);let s=[...r].flatMap(e=>i.get(e)??[]),c=[...e.elements.values()].flatMap(e=>e.kind===`wire`&&(r.has(e.from)||r.has(e.to))?[e]:[]),l=iY(t.pinnedOffsetY+Q);return(e,t)=>{let n=s.map(n=>CY(n,e,t));for(let e of n)i.set(e.id,e);return[...n,...Jq({wires:c,boxesById:i,softObstacles:a,loopFrames:o,contentTop:l})]}}var TY=2048,EY=.3,DY=.12,OY=.5,kY=6,AY=256,jY=30,MY=12,NY=28;function PY(e){return e>=EY?`full`:e>=DY?`titles`:`blocks`}function FY(e){return`${e.lod}:${e.level}:${e.chunkX}:${e.chunkY}`}function IY(e){return TY*2**e.level}function LY(e){let t=IY(e);return{x:e.chunkX*t,y:e.chunkY*t,width:t,height:t}}function RY(e,t){let n=IY({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 zY(e){return(e.lastX-e.firstX+1)*(e.lastY-e.firstY+1)}function BY(e,t){if(t!==`blocks`)return 0;let n=Math.max(e.width,e.height),r=0;for(;TY*2**r*kY<n&&r<jY;)r+=1;return r}function VY(e,t){let n={x:e.x-e.width*OY,y:e.y-e.height*OY,width:e.width*2,height:e.height*2},r=BY(e,t);for(;zY(RY(n,r))>AY&&r<jY;)r+=1;let i=RY(n,r);if(zY(i)>AY)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 HY(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 UY(e){if(e.kind===`wire`){let t=[...Xq(e.path),e.start,e.end];if(e.label){let n=lq(e.label)/2+MY;t.push({x:e.labelAt.x-n,y:e.labelAt.y-24},{x:e.labelAt.x+n,y:e.labelAt.y+MY})}return HY(t,MY)}return e.kind===`frame`?{...WY(e),width:Math.max(e.width,NY+lq(e.title))}:WY(e)}function WY(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}var GY=100,KY=[],$=null,qY=null;function JY(){for(let e of KY)e()}function YY(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 XY(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){qY!==null&&clearTimeout(qY),qY=null,e.sentTileIds=new Set(VY(e.view,e.lod).map(FY)),iX(e,t=>t.key.lod===e.lod&&!YY(t.rect,e.view))&&JY(),s({type:`whiteboard-view`,boardId:e.boardId,view:e.view,lod:e.lod,knownVersion:e.version})}function QY(e){qY===null&&(qY=setTimeout(()=>{qY=null,$===e&&ZY(e)},GY))}function $Y(e,t){for(let n of e.tiles.values())n.elementIds.delete(t)}function eX(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 tX(e){return VY(e.view,e.lod).every(t=>e.tiles.has(FY(t))||e.sentTileIds.has(FY(t)))}function nX(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 rX(e,t,n){let r=PY(n),i=$?.boardId!==e,a=i||!$?nX(e,t,r):$,o=a.lod!==r;$=a,a.view=t,a.lod=r,i||o||a.version===null||!tX(a)?ZY(a):QY(a)}function iX(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?(eX(e),e.assembled=null,!0):!1}function aX(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(FY(t.key),{key:t.key,rect:LY(t.key),elementIds:n,raster:t.raster?XY(t.raster):null})}function oX(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)aX(t,n);iX(t,()=>!0),t.assembled=null,JY()}}function sX(e,t){$Y(e,t.element.id);let n=UY(t.element),r=!1;for(let i of e.tiles.values())i.key.lod!==`blocks`&&YY(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 cX(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)$Y(t,n),t.elementById.delete(n);for(let n of e.diff.changed)sX(t,n);for(let n of e.diff.rasters){let e=t.tiles.get(FY(n.key));e&&(e.raster=n.raster?XY(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,JY()}}}function lX(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=jt(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 uX(e){if(!$||$.version===null)return;let t=e.get($.boardId);t===void 0?fX($.boardId):t!==$.version&&($.version=null,ZY($))}function dX(){$&&($.version=null,ZY($))}function fX(e){$?.boardId===e&&(qY!==null&&clearTimeout(qY),qY=null,$=null,JY())}function pX(e){KY.push(e)}var mX={"whiteboards-snapshot":e=>{bO(e),uX(new Map(e.boards.map(e=>[e.id,e.version])))},"whiteboard-removed":e=>{fX(e.boardId),xO(e)},"whiteboard-tiles":e=>oX(e),"whiteboard-tile-diff":e=>cX(e)},hX=`Worktree`,gX=`Worktree warning`,_X=_V([QV,$V,{"session-worktree-blocked":e=>{Tr({source:hX,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=>{Tr({source:gX,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=>{wr(hX,e.id),WC(e.id,e.base)},"session-diff":e=>{rb(e.id,e)},"session-diff-error":e=>{ib(e.id,e.message)},"change-map":e=>ab(e.id,e.map),"session-changed":e=>ob(e.id)},DV,mX,OV,kV]),vX=new Set([...Object.keys($V),...Object.keys(DV)]);function yX(e){let t=_X[e.type];t&&t(e)}function bX(){i(e=>{yX(e),oR(e.type)}),YV((e,t)=>{if(t.type===`snapshot`){oV(t.sessions,e);return}let n=t.type===`error`&&typeof t.id==`string`;(vX.has(t.type)||n)&&(yX(t),oR(t.type))})}function xX(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 SX(){ik({panels:xX(K),onScreenShown:e=>{aR(e),e!==`settings`&&JL(),e===`settings`&&!kF(location.hash)&&Fj(),tR(e)},canGoBack:e=>e===`settings`&&Bj()||e===`prs`&&D_(),onBack:e=>{e===`settings`&&Vj(),e===`prs`&&O_()},headerControls:[w(document,`.header-title`,`h1`),w(document,`#status-indicator`,`div`),w(document,`#celebration-tray`,`div`),cz,lz,dz]}),zj(pk),E_(pk)}function CX(e){if(e===`phone`){let e=W();for(let e of K)TL(e.view)?.deactivate?.();let t=kF(location.hash);ak({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}).then(e=>{e&&t&&Fj(null,null,location.hash),!e&&us()&&!sk()&&wR()});return}let t=ck();ok(),wR(),t&&yF(t)}function wX(){SX(),us()&&CX(`phone`),ds(CX)}function TX(){return(document.activeElement?.closest(`.session-card`))?.dataset.id??null}function EX(e){yF(e),sa(e),requestAnimationFrame(()=>requestAnimationFrame(()=>O.get(e)?.term?.focus()))}function DX(){let e=TX()??ta();e?la(e):document.getElementById(`btn-add-session-header`)?.click()}function OX({action:e,step:t}){switch(e){case`merge`:{let e=ta();return!e||JN()?!1:(fb(e),!0)}case`close-session`:{let e=ta();return e?(ea(e),!0):!1}case`board-split`:return qN()&&cP();case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`quick-session`:return DX(),!0;case`next-attention`:return us()?!1:qN()?(QP(),!0):(xr()===`prs`&&k_()||wF(()=>q(`focus`)),!0);case`rail-step`:return qN()?(SF(t),!0):!1;case`view-step`:return!us()&&(mR(pR(xr(),t)),!0);case`session-nth`:return qN()?(xF(t),!0):!1;case`streamer-mode`:return xl(),!0}}function kX(e){return e.code!==`KeyZ`||e.altKey||e.shiftKey?!1:Ju===`mac`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function AX(){Xi(EX),document.addEventListener(`keydown`,e=>{if(e.repeat||Rt(e))return;let t=document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1;if(!t&&kX(e)&&!en()&&Ji()){e.preventDefault(),e.stopImmediatePropagation();return}let n=oi(e,Ju,{isTerminalFocused:t},Zu());n&&(en()||OX(n)&&e.preventDefault())})}function jX(){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))}),kL(()=>window.sessionStorage)}fo(ti()),mo(()=>{j(()=>import(`./alert-sound-At4lBeip.js`).then(e=>e.playNyanJingle(),e=>y(`alert-sound`,`nyan jingle failed to load: ${l(e)}`)),__vite__mapDeps([10,6]))}),vp(ri()),ls(),Sd(document),VB(),eV(),$D(s),j(()=>import(`./your-day-tip-Cjr_jrYW.js`).then(e=>e.startYourDayTips({openUsage:()=>KL(`usage`)}),e=>y(`your-day-tip`,`your day tips failed to load: ${l(e)}`)),__vite__mapDeps([66,13,4,3,64,62,5,6,7,8,14,65,21])),bv(s),gC(s),Zp(s),Ta(s),kn(V_),Ln(Ua),Ln(R_,`links`),Ln(HO,`links`),sn(WO),LO(qL),cn({isReadable:Wa,open:Ka}),mn(cw),_l(()=>oR(`settings-updated`)),bX(),Lz(),mz(),MR(),hz(),TR(),wX(),AX(),bk(),jX(),lv(w(document,`#health-footer-mount`,`div`)),Wu(BC),LB(),lp(),p();var MX=Si();MX&&b().then(()=>wu(MX));export{dM as $,$u as $a,Ng as $i,hE as $n,dC as $r,SO as $t,wI as A,Kp as Aa,O_ as Ai,rT as An,OE as Ar,OA as At,KF as B,Bp as Ba,ag as Bi,aD as Bn,ww as Br,Bk as Bt,IR as C,zm as Ca,yv as Ci,TT as Cn,bD as Cr,pA as Ct,WL as D,Cm as Da,b_ as Di,Iw as Dn,Kw as Dr,kA as Dt,HL as E,Sm as Ea,d_ as Ei,Fw as En,iD as Er,DA as Et,bI as F,Lp as Fa,m_ as Fi,nE as Fn,vD as Fr,aA as Ft,jF as G,of as Ga,vg as Gi,sD as Gn,dw as Gr,Lk as Gt,NF as H,Rp as Ha,Mg as Hi,uT as Hn,bw as Hr,Gk as Ht,xI as I,Yp as Ia,w_ as Ii,AE as In,EE as Ir,tA as It,yP as J,id as Ja,kg as Ji,dE as Jn,wC as Jr,wk as Jt,OF as K,bd as Ka,og as Ki,RT as Kn,uw as Kr,jk as Kt,pI as L,Xp as La,Wg as Li,Xw as Ln,nT as Lr,$k as Lt,hI as M,Vp as Ma,y_ as Mi,CT as Mn,rD as Mr,HA as Mt,mI as N,Gp as Na,T_ as Ni,ST as Nn,uE as Nr,oA as Nt,oL as O,om as Oa,x_ as Oi,xE as On,qw as Or,jA as Ot,yI as P,qp as Pa,A_ as Pi,oD as Pn,_D as Pr,sA as Pt,_M as Q,ed as Qa,Wh as Qi,lE as Qn,fC as Qr,gO as Qt,qF as R,Jp as Ra,Gg as Ri,Gw as Rn,hw as Rr,Zk as Rt,cB as S,Im as Sa,xv as Si,oT as Sn,Qw as Sr,sj as St,VL as T,Rm as Ta,h_ as Ti,iE as Tn,DE as Tr,QA as Tt,PF as U,vp as Ua,xg as Ui,WT as Un,Nw as Ur,Kk as Ut,GF as V,Up as Va,Vh as Vi,mT as Vn,xw as Vr,Uk as Vt,MF as W,Yf as Wa,Pg as Wi,UT as Wn,pw as Wr,Wk as Wt,mM as X,Qu as Xa,ig as Xi,cT as Xn,pC as Xr,GO as Xt,YM as Y,Ju as Ya,bg as Yi,sT as Yn,hC as Yr,qO as Yt,pM as Z,td as Za,Ig as Zi,yT as Zn,mC as Zr,JO as Zt,SH as _,Qm as _a,zb as _i,wE as _n,vo as _o,cE as _r,Dj as _t,wY as a,yg as aa,Gx as ai,CO as an,hl as ao,hT as ar,hM as at,HV as b,Fm as ba,Yv as bi,aT as bn,Ca as bo,SD as br,oj as bt,zJ as c,Oh as ca,Ex as ci,QD as cn,mc as co,HE as cr,Rj as ct,aY as d,ih as da,Mx as di,tO as dn,Ss as do,cD as dr,Aj as dt,Hh as ea,lC as ei,TO as en,Zu as eo,QT as er,cM as et,Xq as f,Ym as fa,$b as fi,eO as fn,us as fo,hD as fr,Mj as ft,yH as g,Vm as ga,Rb as gi,sO as gn,fo as go,oE as gr,Tj as gt,xH as h,Xm as ha,qb as hi,KD as hn,ho,mD as hr,Pj as ht,lX as i,Uh as ia,Ux as ii,OO as in,Hl as io,gT as ir,lM as it,gI as j,Hp as ja,C_ as ji,wT as jn,yD as jr,GA as jt,sL as k,sm as ka,g_ as ki,jE as kn,kE as kr,$A as kt,yY as l,Dh as la,jx as li,nO as ln,oc as lo,Jw as lr,Uj as lt,zU as m,th as ma,Yb as mi,qD as mn,yo as mo,FT as mr,Lj as mt,dX as n,Rg as na,LS as ni,_O as nn,Ul as no,uD as nr,uM as nt,SY as o,Og as oa,Nx as oi,FO as on,_l as oo,$E as or,Hj as ot,LU as p,rh as pa,Zb as pi,JD as pn,ds as po,LT as pr,Vj as pt,AF as q,ld as qa,Eg as qi,pE as qn,rw as qr,Ak as qt,rX as r,eg as ra,Xx as ri,jO as rn,Wl as ro,bE as rr,oM as rt,nY as s,Qh as sa,Ox as si,wO as sn,vl as so,QE as sr,Ej as st,pX as t,Lg as ta,uC as ti,vO as tn,ql as to,wD as tr,fM as tt,CY as u,Eh as ua,zx as ui,YD as un,Ks as uo,gD as ur,kj as ut,bH as v,Bm as va,Xv as vi,eD as vn,wa as vo,lD as vr,wj as vt,LR as w,Lm as wa,P as wi,aE as wn,UE as wr,AA as wt,EV as x,oh as xa,vv as xi,Uw as xn,CD as xr,aj as xt,JV as y,Zm as ya,Hv as yi,VT as yn,Ea as yo,tD as yr,Ij as yt,WF as z,zp as za,Rh as zi,Vw as zn,Tw as zr,Xk as zt};