@jingyi0605/codingns 0.5.1 → 0.5.5

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 (93) hide show
  1. package/dist/public/assets/{AdaptiveButlerPage-SffCV4Vb.js → AdaptiveButlerPage-CUyNL98E.js} +1 -1
  2. package/dist/public/assets/App-BFP7LCSC.js +30 -0
  3. package/dist/public/assets/{BootstrapPage--zExdgfM.js → BootstrapPage-G74dX2Us.js} +1 -1
  4. package/dist/public/assets/ConversationPage-Bz0_tvvM.js +2 -0
  5. package/dist/public/assets/{DesktopDetachPreviewPage-DvI9CIKi.js → DesktopDetachPreviewPage-IV7oEdOX.js} +1 -1
  6. package/dist/public/assets/DesktopWindowPage-BBmHyRg5.js +2 -0
  7. package/dist/public/assets/FileContextPanel--FVTxDrq.js +1 -0
  8. package/dist/public/assets/GitSidebar-DAiSi9oc.js +6 -0
  9. package/dist/public/assets/{MobileCreateSessionSheet-CXSKMnYn.js → MobileCreateSessionSheet-DqVwz_Hp.js} +1 -1
  10. package/dist/public/assets/MobileSheet-D1lMrcvD.js +1 -0
  11. package/dist/public/assets/{MobileTopHeaderFrame-BWorAJ1C.js → MobileTopHeaderFrame-COTc7cRr.js} +1 -1
  12. package/dist/public/assets/{MobileWorkspaceSwitcherHeader-DOr4pTUq.js → MobileWorkspaceSwitcherHeader-DJPV9ym2.js} +1 -1
  13. package/dist/public/assets/RelayConnectEntryPage-dSwU8VzK.js +1 -0
  14. package/dist/public/assets/{ServerSettingsModal-BYB0GvTl.js → ServerSettingsModal-B34ms3ze.js} +1 -1
  15. package/dist/public/assets/{SessionIndexPage-CR3IARXX.js → SessionIndexPage-D3tG1gmM.js} +1 -1
  16. package/dist/public/assets/SettingsPage-B3-6-5GL.js +1 -0
  17. package/dist/public/assets/{TerminalManagerPanel-PQ-EM64j.js → TerminalManagerPanel-DhuTEdzV.js} +1 -1
  18. package/dist/public/assets/{TerminalPage-CvnHXBhw.js → TerminalPage-DpsvQQVR.js} +19 -19
  19. package/dist/public/assets/{TerminalRuntimeFallbackModal-D7Aq186N.js → TerminalRuntimeFallbackModal-CNzOt5v5.js} +1 -1
  20. package/dist/public/assets/{ToolFilesPage-Qzkc6K2I.js → ToolFilesPage-BX9QDi9Y.js} +1 -1
  21. package/dist/public/assets/{ToolGitPage-BdNDN-cV.js → ToolGitPage-4VtFox3p.js} +1 -1
  22. package/dist/public/assets/{ToolProcessesPage-EXJ9DHWI.js → ToolProcessesPage-DZJC6Qnt.js} +1 -1
  23. package/dist/public/assets/{ToolsHomePage-CjF3CWzR.js → ToolsHomePage-D7JbrAWv.js} +1 -1
  24. package/dist/public/assets/{WorkbenchLandingPage-DZPk4SmX.js → WorkbenchLandingPage-C0yqnzqh.js} +1 -1
  25. package/dist/public/assets/WorkbenchLayout-Brlj8K3i.js +3 -0
  26. package/dist/public/assets/{WorkbenchModal-B09hC9b5.js → WorkbenchModal-CbDxaCOR.js} +1 -1
  27. package/dist/public/assets/{WorkbenchShellRoute-DsW4mBTX.css → WorkbenchShellRoute-BMcnFadA.css} +1 -1
  28. package/dist/public/assets/WorkbenchShellRoute-puGpdDFY.js +1 -0
  29. package/dist/public/assets/{WorkspaceDebugDetailPage-Bcq8s-Ma.js → WorkspaceDebugDetailPage-fTGweC9N.js} +1 -1
  30. package/dist/public/assets/{WorkspaceDetailPage-DNAa8pKr.js → WorkspaceDetailPage-BtaIzSDB.js} +1 -1
  31. package/dist/public/assets/{WorkspaceHomePage-BoiLuACV.js → WorkspaceHomePage-CUmmYDrM.js} +1 -1
  32. package/dist/public/assets/{client-runtime-manager-CRQ-F5d2.js → client-runtime-manager-RHFa_iWo.js} +1 -1
  33. package/dist/public/assets/{default-session-permission-mode-D0wZ9Jek.js → default-session-permission-mode-Cu5SreTG.js} +1 -1
  34. package/dist/public/assets/file-tree-icon-BMKuc5pw.js +31 -0
  35. package/dist/public/assets/index-Cq3ue0za.css +1 -0
  36. package/dist/public/assets/index-DEbFT-Aq.js +42 -0
  37. package/dist/public/assets/{preferences-service-gOt2ZjKZ.js → preferences-service-gv_9vGKz.js} +1 -1
  38. package/dist/public/assets/session-runtime-machine-Bfnxkk9B.js +17 -0
  39. package/dist/public/assets/{terminal-runtime-meta-BMT-rSEe.js → terminal-runtime-meta-B9xJGY__.js} +1 -1
  40. package/dist/public/assets/{useRegisteredDebugTemplates-zMcEOGca.js → useRegisteredDebugTemplates-CDfl54Wt.js} +1 -1
  41. package/dist/public/index.html +2 -2
  42. package/dist/server/config/env.d.ts +1 -0
  43. package/dist/server/config/env.js +36 -0
  44. package/dist/server/config/env.js.map +1 -1
  45. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.d.ts +16 -1
  46. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.js.map +1 -1
  47. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.d.ts +2 -1
  48. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js +18 -0
  49. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js.map +1 -1
  50. package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.d.ts +13 -0
  51. package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.js +2 -0
  52. package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.js.map +1 -0
  53. package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.d.ts +6 -0
  54. package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js +110 -10
  55. package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js.map +1 -1
  56. package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.d.ts +16 -4
  57. package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js +216 -101
  58. package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js.map +1 -1
  59. package/dist/server/modules/relay-tunnel/relay-tunnel-service.d.ts +4 -1
  60. package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +256 -34
  61. package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
  62. package/dist/server/modules/sessions/session-activity-inspector.js +6 -8
  63. package/dist/server/modules/sessions/session-activity-inspector.js.map +1 -1
  64. package/dist/server/modules/sessions/session-history-service.d.ts +1 -0
  65. package/dist/server/modules/sessions/session-history-service.js +62 -7
  66. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  67. package/dist/server/modules/workbench/workbench-service.d.ts +32 -2
  68. package/dist/server/modules/workbench/workbench-service.js +36 -2
  69. package/dist/server/modules/workbench/workbench-service.js.map +1 -1
  70. package/dist/server/server/create-server.js +10 -5
  71. package/dist/server/server/create-server.js.map +1 -1
  72. package/dist/server/ws/workbench-ws-hub.js +166 -16
  73. package/dist/server/ws/workbench-ws-hub.js.map +1 -1
  74. package/dist/server/ws/ws-server.js +141 -8
  75. package/dist/server/ws/ws-server.js.map +1 -1
  76. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +33 -6
  77. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
  78. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +78 -36
  79. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
  80. package/package.json +1 -1
  81. package/dist/public/assets/App-WOLwMld_.js +0 -30
  82. package/dist/public/assets/ConversationPage-D9pzRmOg.js +0 -2
  83. package/dist/public/assets/DesktopWindowPage-D8FpOSLE.js +0 -2
  84. package/dist/public/assets/FileContextPanel-C8T7oqRN.js +0 -1
  85. package/dist/public/assets/GitSidebar-Bze7DNnc.js +0 -6
  86. package/dist/public/assets/MobileSheet-Gzc14EpR.js +0 -1
  87. package/dist/public/assets/SettingsPage-B_BQtnwE.js +0 -1
  88. package/dist/public/assets/WorkbenchLayout-rwQib5In.js +0 -3
  89. package/dist/public/assets/WorkbenchShellRoute-Cerk5uK7.js +0 -1
  90. package/dist/public/assets/file-tree-icon-Dp_xhVfD.js +0 -31
  91. package/dist/public/assets/index-C2G8Gmf1.js +0 -42
  92. package/dist/public/assets/index-CpPTUeA3.css +0 -1
  93. package/dist/public/assets/session-runtime-machine-Dq3pW-UF.js +0 -17
@@ -1,4 +1,4 @@
1
- var kl=Object.defineProperty;var El=(e,t,i)=>t in e?kl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var tt=(e,t,i)=>El(e,typeof t!="symbol"?t+"":t,i);import{l as Pn,C as Tl,b as y,t as b,j as p}from"./index-C2G8Gmf1.js";import{e as Rl,M as sa}from"./MobileSheet-Gzc14EpR.js";import{a1 as Bl,U as Ml,u as Dl,w as Ll,r as Pl,a2 as Al}from"./WorkbenchLayout-rwQib5In.js";import{d as Il,u as Nl,c as Ol,e as Fl}from"./App-WOLwMld_.js";import{M as Hl}from"./MobileWorkspaceSwitcherHeader-DOr4pTUq.js";import{b as ra,c as zl,d as An,e as ar,g as In,f as Wl,h as $l,i as jl,j as Ul}from"./terminal-runtime-meta-BMT-rSEe.js";import{T as Kl,i as ql}from"./TerminalRuntimeFallbackModal-D7Aq186N.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";import"./WorkbenchModal-B09hC9b5.js";import"./MobileTopHeaderFrame-BWorAJ1C.js";/**
1
+ var Pl=Object.defineProperty;var Al=(e,t,i)=>t in e?Pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var it=(e,t,i)=>Al(e,typeof t!="symbol"?t+"":t,i);import{m as On,D as Il,b as y,t as w,E as Nl,j as p}from"./index-DEbFT-Aq.js";import{e as Ol,M as la}from"./MobileSheet-D1lMrcvD.js";import{a1 as Fl,U as Hl,u as zl,a2 as Wl,w as $l,r as jl,a3 as Ul}from"./WorkbenchLayout-Brlj8K3i.js";import{e as Kl,u as ql,c as Vl,f as Yl}from"./App-BFP7LCSC.js";import{M as Xl}from"./MobileWorkspaceSwitcherHeader-DJPV9ym2.js";import{b as ha,c as Gl,d as Fn,e as ur,g as Hn,f as Zl,h as Jl,i as Ql,j as eh}from"./terminal-runtime-meta-B9xJGY__.js";import{T as th,i as ih}from"./TerminalRuntimeFallbackModal-CNzOt5v5.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";import"./WorkbenchModal-CbDxaCOR.js";import"./MobileTopHeaderFrame-COTc7cRr.js";/**
2
2
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
3
3
  * @license MIT
4
4
  *
@@ -9,7 +9,7 @@ var kl=Object.defineProperty;var El=(e,t,i)=>t in e?kl(e,t,{enumerable:!0,config
9
9
  * Fabrice Bellard's javascript vt100 for jslinux:
10
10
  * http://bellard.org/jslinux/
11
11
  * Copyright (c) 2011 Fabrice Bellard
12
- */var Vl=2,Yl=1,Xl=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=s-a,u=r-h-t;return{cols:Math.max(Vl,Math.floor(u/e.css.cell.width)),rows:Math.max(Yl,Math.floor(l/e.css.cell.height))}}};/**
12
+ */var sh=2,rh=1,nh=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=s-a,u=r-h-t;return{cols:Math.max(sh,Math.floor(u/e.css.cell.width)),rows:Math.max(rh,Math.floor(l/e.css.cell.height))}}};/**
13
13
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
14
14
  * @license MIT
15
15
  *
@@ -20,8 +20,8 @@ var kl=Object.defineProperty;var El=(e,t,i)=>t in e?kl(e,t,{enumerable:!0,config
20
20
  * Fabrice Bellard's javascript vt100 for jslinux:
21
21
  * http://bellard.org/jslinux/
22
22
  * Copyright (c) 2011 Fabrice Bellard
23
- */var Pe=0,Ae=0,Ie=0,ye=0,Ye;(e=>{function t(r,n,o,a){return a!==void 0?`#${Kt(r)}${Kt(n)}${Kt(o)}${Kt(a)}`:`#${Kt(r)}${Kt(n)}${Kt(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(Ye||(Ye={}));var Gl;(e=>{function t(h,l){if(ye=(l.rgba&255)/255,ye===1)return{css:l.css,rgba:l.rgba};let u=l.rgba>>24&255,d=l.rgba>>16&255,_=l.rgba>>8&255,m=h.rgba>>24&255,f=h.rgba>>16&255,g=h.rgba>>8&255;Pe=m+Math.round((u-m)*ye),Ae=f+Math.round((d-f)*ye),Ie=g+Math.round((_-g)*ye);let k=Ye.toCss(Pe,Ae,Ie),L=Ye.toRgba(Pe,Ae,Ie);return{css:k,rgba:L}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,u){let d=hs.ensureContrastRatio(h.rgba,l.rgba,u);if(d)return Ye.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[Pe,Ae,Ie]=hs.toChannels(l),{css:Ye.toCss(Pe,Ae,Ie),rgba:l}}e.opaque=r;function n(h,l){return ye=Math.round(l*255),[Pe,Ae,Ie]=hs.toChannels(h.rgba),{css:Ye.toCss(Pe,Ae,Ie,ye),rgba:Ye.toRgba(Pe,Ae,Ie,ye)}}e.opacity=n;function o(h,l){return ye=h.rgba&255,n(h,ye*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(Gl||(Gl={}));var We;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Pe=parseInt(r.slice(1,2).repeat(2),16),Ae=parseInt(r.slice(2,3).repeat(2),16),Ie=parseInt(r.slice(3,4).repeat(2),16),Ye.toColor(Pe,Ae,Ie);case 5:return Pe=parseInt(r.slice(1,2).repeat(2),16),Ae=parseInt(r.slice(2,3).repeat(2),16),Ie=parseInt(r.slice(3,4).repeat(2),16),ye=parseInt(r.slice(4,5).repeat(2),16),Ye.toColor(Pe,Ae,Ie,ye);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Pe=parseInt(n[1]),Ae=parseInt(n[2]),Ie=parseInt(n[3]),ye=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Ye.toColor(Pe,Ae,Ie,ye);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Pe,Ae,Ie,ye]=t.getImageData(0,0,1,1).data,ye!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ye.toRgba(Pe,Ae,Ie,ye),css:r}}e.toColor=s})(We||(We={}));var Ze;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+u*.7152+d*.0722}e.relativeLuminance2=i})(Ze||(Ze={}));var hs;(e=>{function t(o,a){if(ye=(a&255)/255,ye===1)return a;let h=a>>24&255,l=a>>16&255,u=a>>8&255,d=o>>24&255,_=o>>16&255,m=o>>8&255;return Pe=d+Math.round((h-d)*ye),Ae=_+Math.round((l-_)*ye),Ie=m+Math.round((u-m)*ye),Ye.toRgba(Pe,Ae,Ie)}e.blend=t;function i(o,a,h){let l=Ze.relativeLuminance(o>>8),u=Ze.relativeLuminance(a>>8);if(Et(l,u)<h){if(u<l){let m=s(o,a,h),f=Et(l,Ze.relativeLuminance(m>>8));if(f<h){let g=r(o,a,h),k=Et(l,Ze.relativeLuminance(g>>8));return f>k?m:g}return m}let d=r(o,a,h),_=Et(l,Ze.relativeLuminance(d>>8));if(_<h){let m=s(o,a,h),f=Et(l,Ze.relativeLuminance(m>>8));return _>f?d:m}return d}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,_=a>>24&255,m=a>>16&255,f=a>>8&255,g=Et(Ze.relativeLuminance2(_,m,f),Ze.relativeLuminance2(l,u,d));for(;g<h&&(_>0||m>0||f>0);)_-=Math.max(0,Math.ceil(_*.1)),m-=Math.max(0,Math.ceil(m*.1)),f-=Math.max(0,Math.ceil(f*.1)),g=Et(Ze.relativeLuminance2(_,m,f),Ze.relativeLuminance2(l,u,d));return(_<<24|m<<16|f<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,_=a>>24&255,m=a>>16&255,f=a>>8&255,g=Et(Ze.relativeLuminance2(_,m,f),Ze.relativeLuminance2(l,u,d));for(;g<h&&(_<255||m<255||f<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),g=Et(Ze.relativeLuminance2(_,m,f),Ze.relativeLuminance2(l,u,d));return(_<<24|m<<16|f<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(hs||(hs={}));function Kt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Et(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Zl=Object.freeze((()=>{let e=[We.toColor("#2e3436"),We.toColor("#cc0000"),We.toColor("#4e9a06"),We.toColor("#c4a000"),We.toColor("#3465a4"),We.toColor("#75507b"),We.toColor("#06989a"),We.toColor("#d3d7cf"),We.toColor("#555753"),We.toColor("#ef2929"),We.toColor("#8ae234"),We.toColor("#fce94f"),We.toColor("#729fcf"),We.toColor("#ad7fa8"),We.toColor("#34e2e2"),We.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:Ye.toCss(s,r,n),rgba:Ye.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Ye.toCss(s,s,s),rgba:Ye.toRgba(s,s,s)})}return e})());function Nn(e,t,i){return Math.max(t,Math.min(e,i))}function Jl(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var na=class{constructor(t){this._buffer=t}serialize(t,i){let s=this._buffer.getNullCell(),r=this._buffer.getNullCell(),n=s,o=t.start.y,a=t.end.y,h=t.start.x,l=t.end.x;this._beforeSerialize(a-o,o,a);for(let u=o;u<=a;u++){let d=this._buffer.getLine(u);if(d){let _=u===t.start.y?h:0,m=u===t.end.y?l:d.length;for(let f=_;f<m;f++){let g=d.getCell(f,n===s?r:s);if(!g){console.warn(`Can't get cell at row=${u}, col=${f}`);continue}this._nextCell(g,n,u,f),n=g}}this._rowEnd(u,u===a)}return this._afterSerialize(),this._serializeString(i)}_nextCell(t,i,s,r){}_rowEnd(t,i){}_beforeSerialize(t,i,s){}_afterSerialize(){}_serializeString(t){return""}};function oa(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function Rt(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function aa(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}var Ql=class extends na{constructor(e,t){super(e),this._terminal=t,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,t,i){this._allRows=new Array(e),this._lastContentCursorRow=t,this._lastCursorRow=t,this._firstRow=t}_rowEnd(e,t){var s;this._nullCellCount>0&&!Rt(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let i="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let r=this._buffer.getLine(e),n=this._buffer.getLine(e+1);if(!n.isWrapped)i=`\r
24
- `,this._lastCursorRow=e+1,this._lastCursorCol=0;else{i="";let o=r.getCell(r.length-1,this._thisRowLastChar),a=r.getCell(r.length-2,this._thisRowLastSecondChar),h=n.getCell(0,this._nextRowFirstChar),l=h.getWidth()>1,u=!1;(h.getChars()&&l?this._nullCellCount<=1:this._nullCellCount<=0)&&((o.getChars()||o.getWidth()===0)&&Rt(o,h)&&(u=!0),l&&(a.getChars()||a.getWidth()===0)&&Rt(o,h)&&Rt(a,h)&&(u=!0)),u||(i="-".repeat(this._nullCellCount+1),i+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(i+="\x1B[A",i+=`\x1B[${r.length-this._nullCellCount}C`,i+=`\x1B[${this._nullCellCount}X`,i+=`\x1B[${r.length-this._nullCellCount}D`,i+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=i,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let i=[],s=!oa(e,t),r=!Rt(e,t),n=!aa(e,t);if(s||r||n)if(e.isAttributeDefault())t.isAttributeDefault()||i.push(0);else{if(s){let o=e.getFgColor();e.isFgRGB()?i.push(38,2,o>>>16&255,o>>>8&255,o&255):e.isFgPalette()?o>=16?i.push(38,5,o):i.push(o&8?90+(o&7):30+(o&7)):i.push(39)}if(r){let o=e.getBgColor();e.isBgRGB()?i.push(48,2,o>>>16&255,o>>>8&255,o&255):e.isBgPalette()?o>=16?i.push(48,5,o):i.push(o&8?100+(o&7):40+(o&7)):i.push(49)}n&&(e.isInverse()!==t.isInverse()&&i.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&i.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&i.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&i.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&i.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&i.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&i.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&i.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&i.push(e.isStrikethrough()?9:29))}return i}_nextCell(e,t,i,s){if(e.getWidth()===0)return;let r=e.getChars()==="",n=this._diffStyle(e,this._cursorStyle);if(r?!Rt(this._cursorStyle,e):n.length>0){this._nullCellCount>0&&(Rt(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=i,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${n.join(";")}m`;let o=this._buffer.getLine(i);o!==void 0&&(o.getCell(s,this._cursorStyle),this._cursorStyleRow=i,this._cursorStyleCol=s)}r?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Rt(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=i,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let i="";for(let n=0;n<t;n++)i+=this._allRows[n],n+1<t&&(i+=this._allRowSeparators[n]);if(!e){let n=this._buffer.baseY+this._buffer.cursorY,o=this._buffer.cursorX,a=n!==this._lastCursorRow||o!==this._lastCursorCol,h=l=>{l>0?i+=`\x1B[${l}C`:l<0&&(i+=`\x1B[${-l}D`)};a&&((l=>{l>0?i+=`\x1B[${l}B`:l<0&&(i+=`\x1B[${-l}A`)})(n-this._lastCursorRow),h(o-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,r=this._diffStyle(s,this._cursorStyle);return r.length>0&&(i+=`\x1B[${r.join(";")}m`),i}},eh=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,i,s){let r=i.length,n=s===void 0?r:Nn(s+t.rows,0,r);return this._serializeBufferByRange(t,i,{start:r-n,end:r-1},!1)}_serializeBufferByRange(t,i,s,r){return new Ql(i,t).serialize({start:{x:0,y:typeof s.start=="number"?s.start:s.start.line},end:{x:t.cols,y:typeof s.end=="number"?s.end:s.end.line}},r)}_serializeBufferAsHTML(t,i){var h;let s=t.buffer.active,r=new th(s,t,i),n=i.onlySelection??!1,o=i.range;if(o)return r.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:t.cols,y:(o.endLine,o.endLine)}});if(!n){let l=s.length,u=i.scrollback,d=u===void 0?l:Nn(u+t.rows,0,l);return r.serialize({start:{x:0,y:l-d},end:{x:t.cols,y:l-1}})}let a=(h=this._terminal)==null?void 0:h.getSelectionPosition();return a!==void 0?r.serialize({start:{x:a.start.x,y:a.start.y},end:{x:a.end.x,y:a.end.y}}):""}_serializeModes(t){let i="",s=t.modes;if(s.applicationCursorKeysMode&&(i+="\x1B[?1h"),s.applicationKeypadMode&&(i+="\x1B[?66h"),s.bracketedPasteMode&&(i+="\x1B[?2004h"),s.insertMode&&(i+="\x1B[4h"),s.originMode&&(i+="\x1B[?6h"),s.reverseWraparoundMode&&(i+="\x1B[?45h"),s.sendFocusMode&&(i+="\x1B[?1004h"),s.wraparoundMode===!1&&(i+="\x1B[?7l"),s.mouseTrackingMode!=="none")switch(s.mouseTrackingMode){case"x10":i+="\x1B[?9h";break;case"vt200":i+="\x1B[?1000h";break;case"drag":i+="\x1B[?1002h";break;case"any":i+="\x1B[?1003h";break}return i}serialize(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let i=t!=null&&t.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,t.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,t==null?void 0:t.scrollback);if(!(t!=null&&t.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let s=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);i+=`\x1B[?1049h\x1B[H${s}`}return t!=null&&t.excludeModes||(i+=this._serializeModes(this._terminal)),i}serializeAsHTML(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t||{})}dispose(){}},th=class extends na{constructor(t,i,s){super(t),this._terminal=i,this._options=s,this._currentRow="",this._htmlContent="",i._core._themeService?this._ansiColors=i._core._themeService.colors.ansi:this._ansiColors=Zl}_padStart(t,i,s){return i=i>>0,s=s??" ",t.length>i?t:(i-=t.length,i>s.length&&(s+=s.repeat(i/s.length)),s.slice(0,i)+t)}_beforeSerialize(t,i,s){var a,h;this._htmlContent+="<html><body><!--StartFragment--><pre>";let r="#000000",n="#ffffff";(this._options.includeGlobalBackground??!1)&&(r=((a=this._terminal.options.theme)==null?void 0:a.foreground)??"#ffffff",n=((h=this._terminal.options.theme)==null?void 0:h.background)??"#000000");let o=[];o.push("color: "+r+";"),o.push("background-color: "+n+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+o.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(t,i){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(t,i){let s=i?t.getFgColor():t.getBgColor();if(i?t.isFgRGB():t.isBgRGB())return"#"+[s>>16&255,s>>8&255,s&255].map(r=>this._padStart(r.toString(16),2,"0")).join("");if(i?t.isFgPalette():t.isBgPalette())return this._ansiColors[s].css}_diffStyle(t,i){let s=[],r=!oa(t,i),n=!Rt(t,i),o=!aa(t,i);if(r||n||o){let a=this._getHexColor(t,!0);a&&s.push("color: "+a+";");let h=this._getHexColor(t,!1);return h&&s.push("background-color: "+h+";"),t.isInverse()&&s.push("color: #000000; background-color: #BFBFBF;"),t.isBold()&&s.push("font-weight: bold;"),t.isUnderline()&&t.isOverline()?s.push("text-decoration: overline underline;"):t.isUnderline()?s.push("text-decoration: underline;"):t.isOverline()&&s.push("text-decoration: overline;"),t.isBlink()&&s.push("text-decoration: blink;"),t.isInvisible()&&s.push("visibility: hidden;"),t.isItalic()&&s.push("font-style: italic;"),t.isDim()&&s.push("opacity: 0.5;"),t.isStrikethrough()&&s.push("text-decoration: line-through;"),s}}_nextCell(t,i,s,r){if(t.getWidth()===0)return;let n=t.getChars()==="",o=this._diffStyle(t,i);o&&(this._currentRow+=o.length===0?"</span><span>":"</span><span style='"+o.join(" ")+"'>"),n?this._currentRow+=" ":this._currentRow+=Jl(t.getChars())}_serializeString(){return this._htmlContent}};/**
23
+ */var Ae=0,Ie=0,Ne=0,be=0,Ye;(e=>{function t(r,n,o,a){return a!==void 0?`#${Jt(r)}${Jt(n)}${Jt(o)}${Jt(a)}`:`#${Jt(r)}${Jt(n)}${Jt(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(Ye||(Ye={}));var oh;(e=>{function t(h,l){if(be=(l.rgba&255)/255,be===1)return{css:l.css,rgba:l.rgba};let u=l.rgba>>24&255,d=l.rgba>>16&255,_=l.rgba>>8&255,m=h.rgba>>24&255,f=h.rgba>>16&255,v=h.rgba>>8&255;Ae=m+Math.round((u-m)*be),Ie=f+Math.round((d-f)*be),Ne=v+Math.round((_-v)*be);let k=Ye.toCss(Ae,Ie,Ne),D=Ye.toRgba(Ae,Ie,Ne);return{css:k,rgba:D}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,u){let d=_s.ensureContrastRatio(h.rgba,l.rgba,u);if(d)return Ye.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[Ae,Ie,Ne]=_s.toChannels(l),{css:Ye.toCss(Ae,Ie,Ne),rgba:l}}e.opaque=r;function n(h,l){return be=Math.round(l*255),[Ae,Ie,Ne]=_s.toChannels(h.rgba),{css:Ye.toCss(Ae,Ie,Ne,be),rgba:Ye.toRgba(Ae,Ie,Ne,be)}}e.opacity=n;function o(h,l){return be=h.rgba&255,n(h,be*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(oh||(oh={}));var je;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ae=parseInt(r.slice(1,2).repeat(2),16),Ie=parseInt(r.slice(2,3).repeat(2),16),Ne=parseInt(r.slice(3,4).repeat(2),16),Ye.toColor(Ae,Ie,Ne);case 5:return Ae=parseInt(r.slice(1,2).repeat(2),16),Ie=parseInt(r.slice(2,3).repeat(2),16),Ne=parseInt(r.slice(3,4).repeat(2),16),be=parseInt(r.slice(4,5).repeat(2),16),Ye.toColor(Ae,Ie,Ne,be);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Ae=parseInt(n[1]),Ie=parseInt(n[2]),Ne=parseInt(n[3]),be=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Ye.toColor(Ae,Ie,Ne,be);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ae,Ie,Ne,be]=t.getImageData(0,0,1,1).data,be!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ye.toRgba(Ae,Ie,Ne,be),css:r}}e.toColor=s})(je||(je={}));var Ze;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+u*.7152+d*.0722}e.relativeLuminance2=i})(Ze||(Ze={}));var _s;(e=>{function t(o,a){if(be=(a&255)/255,be===1)return a;let h=a>>24&255,l=a>>16&255,u=a>>8&255,d=o>>24&255,_=o>>16&255,m=o>>8&255;return Ae=d+Math.round((h-d)*be),Ie=_+Math.round((l-_)*be),Ne=m+Math.round((u-m)*be),Ye.toRgba(Ae,Ie,Ne)}e.blend=t;function i(o,a,h){let l=Ze.relativeLuminance(o>>8),u=Ze.relativeLuminance(a>>8);if(Pt(l,u)<h){if(u<l){let m=s(o,a,h),f=Pt(l,Ze.relativeLuminance(m>>8));if(f<h){let v=r(o,a,h),k=Pt(l,Ze.relativeLuminance(v>>8));return f>k?m:v}return m}let d=r(o,a,h),_=Pt(l,Ze.relativeLuminance(d>>8));if(_<h){let m=s(o,a,h),f=Pt(l,Ze.relativeLuminance(m>>8));return _>f?d:m}return d}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,_=a>>24&255,m=a>>16&255,f=a>>8&255,v=Pt(Ze.relativeLuminance2(_,m,f),Ze.relativeLuminance2(l,u,d));for(;v<h&&(_>0||m>0||f>0);)_-=Math.max(0,Math.ceil(_*.1)),m-=Math.max(0,Math.ceil(m*.1)),f-=Math.max(0,Math.ceil(f*.1)),v=Pt(Ze.relativeLuminance2(_,m,f),Ze.relativeLuminance2(l,u,d));return(_<<24|m<<16|f<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,_=a>>24&255,m=a>>16&255,f=a>>8&255,v=Pt(Ze.relativeLuminance2(_,m,f),Ze.relativeLuminance2(l,u,d));for(;v<h&&(_<255||m<255||f<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),v=Pt(Ze.relativeLuminance2(_,m,f),Ze.relativeLuminance2(l,u,d));return(_<<24|m<<16|f<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(_s||(_s={}));function Jt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Pt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var ah=Object.freeze((()=>{let e=[je.toColor("#2e3436"),je.toColor("#cc0000"),je.toColor("#4e9a06"),je.toColor("#c4a000"),je.toColor("#3465a4"),je.toColor("#75507b"),je.toColor("#06989a"),je.toColor("#d3d7cf"),je.toColor("#555753"),je.toColor("#ef2929"),je.toColor("#8ae234"),je.toColor("#fce94f"),je.toColor("#729fcf"),je.toColor("#ad7fa8"),je.toColor("#34e2e2"),je.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:Ye.toCss(s,r,n),rgba:Ye.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Ye.toCss(s,s,s),rgba:Ye.toRgba(s,s,s)})}return e})());function zn(e,t,i){return Math.max(t,Math.min(e,i))}function lh(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var ca=class{constructor(t){this._buffer=t}serialize(t,i){let s=this._buffer.getNullCell(),r=this._buffer.getNullCell(),n=s,o=t.start.y,a=t.end.y,h=t.start.x,l=t.end.x;this._beforeSerialize(a-o,o,a);for(let u=o;u<=a;u++){let d=this._buffer.getLine(u);if(d){let _=u===t.start.y?h:0,m=u===t.end.y?l:d.length;for(let f=_;f<m;f++){let v=d.getCell(f,n===s?r:s);if(!v){console.warn(`Can't get cell at row=${u}, col=${f}`);continue}this._nextCell(v,n,u,f),n=v}}this._rowEnd(u,u===a)}return this._afterSerialize(),this._serializeString(i)}_nextCell(t,i,s,r){}_rowEnd(t,i){}_beforeSerialize(t,i,s){}_afterSerialize(){}_serializeString(t){return""}};function ua(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function It(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function da(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}var hh=class extends ca{constructor(e,t){super(e),this._terminal=t,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,t,i){this._allRows=new Array(e),this._lastContentCursorRow=t,this._lastCursorRow=t,this._firstRow=t}_rowEnd(e,t){var s;this._nullCellCount>0&&!It(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let i="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let r=this._buffer.getLine(e),n=this._buffer.getLine(e+1);if(!n.isWrapped)i=`\r
24
+ `,this._lastCursorRow=e+1,this._lastCursorCol=0;else{i="";let o=r.getCell(r.length-1,this._thisRowLastChar),a=r.getCell(r.length-2,this._thisRowLastSecondChar),h=n.getCell(0,this._nextRowFirstChar),l=h.getWidth()>1,u=!1;(h.getChars()&&l?this._nullCellCount<=1:this._nullCellCount<=0)&&((o.getChars()||o.getWidth()===0)&&It(o,h)&&(u=!0),l&&(a.getChars()||a.getWidth()===0)&&It(o,h)&&It(a,h)&&(u=!0)),u||(i="-".repeat(this._nullCellCount+1),i+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(i+="\x1B[A",i+=`\x1B[${r.length-this._nullCellCount}C`,i+=`\x1B[${this._nullCellCount}X`,i+=`\x1B[${r.length-this._nullCellCount}D`,i+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=i,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let i=[],s=!ua(e,t),r=!It(e,t),n=!da(e,t);if(s||r||n)if(e.isAttributeDefault())t.isAttributeDefault()||i.push(0);else{if(s){let o=e.getFgColor();e.isFgRGB()?i.push(38,2,o>>>16&255,o>>>8&255,o&255):e.isFgPalette()?o>=16?i.push(38,5,o):i.push(o&8?90+(o&7):30+(o&7)):i.push(39)}if(r){let o=e.getBgColor();e.isBgRGB()?i.push(48,2,o>>>16&255,o>>>8&255,o&255):e.isBgPalette()?o>=16?i.push(48,5,o):i.push(o&8?100+(o&7):40+(o&7)):i.push(49)}n&&(e.isInverse()!==t.isInverse()&&i.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&i.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&i.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&i.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&i.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&i.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&i.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&i.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&i.push(e.isStrikethrough()?9:29))}return i}_nextCell(e,t,i,s){if(e.getWidth()===0)return;let r=e.getChars()==="",n=this._diffStyle(e,this._cursorStyle);if(r?!It(this._cursorStyle,e):n.length>0){this._nullCellCount>0&&(It(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=i,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${n.join(";")}m`;let o=this._buffer.getLine(i);o!==void 0&&(o.getCell(s,this._cursorStyle),this._cursorStyleRow=i,this._cursorStyleCol=s)}r?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(It(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=i,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let i="";for(let n=0;n<t;n++)i+=this._allRows[n],n+1<t&&(i+=this._allRowSeparators[n]);if(!e){let n=this._buffer.baseY+this._buffer.cursorY,o=this._buffer.cursorX,a=n!==this._lastCursorRow||o!==this._lastCursorCol,h=l=>{l>0?i+=`\x1B[${l}C`:l<0&&(i+=`\x1B[${-l}D`)};a&&((l=>{l>0?i+=`\x1B[${l}B`:l<0&&(i+=`\x1B[${-l}A`)})(n-this._lastCursorRow),h(o-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,r=this._diffStyle(s,this._cursorStyle);return r.length>0&&(i+=`\x1B[${r.join(";")}m`),i}},ch=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,i,s){let r=i.length,n=s===void 0?r:zn(s+t.rows,0,r);return this._serializeBufferByRange(t,i,{start:r-n,end:r-1},!1)}_serializeBufferByRange(t,i,s,r){return new hh(i,t).serialize({start:{x:0,y:typeof s.start=="number"?s.start:s.start.line},end:{x:t.cols,y:typeof s.end=="number"?s.end:s.end.line}},r)}_serializeBufferAsHTML(t,i){var h;let s=t.buffer.active,r=new uh(s,t,i),n=i.onlySelection??!1,o=i.range;if(o)return r.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:t.cols,y:(o.endLine,o.endLine)}});if(!n){let l=s.length,u=i.scrollback,d=u===void 0?l:zn(u+t.rows,0,l);return r.serialize({start:{x:0,y:l-d},end:{x:t.cols,y:l-1}})}let a=(h=this._terminal)==null?void 0:h.getSelectionPosition();return a!==void 0?r.serialize({start:{x:a.start.x,y:a.start.y},end:{x:a.end.x,y:a.end.y}}):""}_serializeModes(t){let i="",s=t.modes;if(s.applicationCursorKeysMode&&(i+="\x1B[?1h"),s.applicationKeypadMode&&(i+="\x1B[?66h"),s.bracketedPasteMode&&(i+="\x1B[?2004h"),s.insertMode&&(i+="\x1B[4h"),s.originMode&&(i+="\x1B[?6h"),s.reverseWraparoundMode&&(i+="\x1B[?45h"),s.sendFocusMode&&(i+="\x1B[?1004h"),s.wraparoundMode===!1&&(i+="\x1B[?7l"),s.mouseTrackingMode!=="none")switch(s.mouseTrackingMode){case"x10":i+="\x1B[?9h";break;case"vt200":i+="\x1B[?1000h";break;case"drag":i+="\x1B[?1002h";break;case"any":i+="\x1B[?1003h";break}return i}serialize(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let i=t!=null&&t.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,t.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,t==null?void 0:t.scrollback);if(!(t!=null&&t.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let s=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);i+=`\x1B[?1049h\x1B[H${s}`}return t!=null&&t.excludeModes||(i+=this._serializeModes(this._terminal)),i}serializeAsHTML(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t||{})}dispose(){}},uh=class extends ca{constructor(t,i,s){super(t),this._terminal=i,this._options=s,this._currentRow="",this._htmlContent="",i._core._themeService?this._ansiColors=i._core._themeService.colors.ansi:this._ansiColors=ah}_padStart(t,i,s){return i=i>>0,s=s??" ",t.length>i?t:(i-=t.length,i>s.length&&(s+=s.repeat(i/s.length)),s.slice(0,i)+t)}_beforeSerialize(t,i,s){var a,h;this._htmlContent+="<html><body><!--StartFragment--><pre>";let r="#000000",n="#ffffff";(this._options.includeGlobalBackground??!1)&&(r=((a=this._terminal.options.theme)==null?void 0:a.foreground)??"#ffffff",n=((h=this._terminal.options.theme)==null?void 0:h.background)??"#000000");let o=[];o.push("color: "+r+";"),o.push("background-color: "+n+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+o.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(t,i){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(t,i){let s=i?t.getFgColor():t.getBgColor();if(i?t.isFgRGB():t.isBgRGB())return"#"+[s>>16&255,s>>8&255,s&255].map(r=>this._padStart(r.toString(16),2,"0")).join("");if(i?t.isFgPalette():t.isBgPalette())return this._ansiColors[s].css}_diffStyle(t,i){let s=[],r=!ua(t,i),n=!It(t,i),o=!da(t,i);if(r||n||o){let a=this._getHexColor(t,!0);a&&s.push("color: "+a+";");let h=this._getHexColor(t,!1);return h&&s.push("background-color: "+h+";"),t.isInverse()&&s.push("color: #000000; background-color: #BFBFBF;"),t.isBold()&&s.push("font-weight: bold;"),t.isUnderline()&&t.isOverline()?s.push("text-decoration: overline underline;"):t.isUnderline()?s.push("text-decoration: underline;"):t.isOverline()&&s.push("text-decoration: overline;"),t.isBlink()&&s.push("text-decoration: blink;"),t.isInvisible()&&s.push("visibility: hidden;"),t.isItalic()&&s.push("font-style: italic;"),t.isDim()&&s.push("opacity: 0.5;"),t.isStrikethrough()&&s.push("text-decoration: line-through;"),s}}_nextCell(t,i,s,r){if(t.getWidth()===0)return;let n=t.getChars()==="",o=this._diffStyle(t,i);o&&(this._currentRow+=o.length===0?"</span><span>":"</span><span style='"+o.join(" ")+"'>"),n?this._currentRow+=" ":this._currentRow+=lh(t.getChars())}_serializeString(){return this._htmlContent}};/**
25
25
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
26
26
  * @license MIT
27
27
  *
@@ -32,24 +32,24 @@ var kl=Object.defineProperty;var El=(e,t,i)=>t in e?kl(e,t,{enumerable:!0,config
32
32
  * Fabrice Bellard's javascript vt100 for jslinux:
33
33
  * http://bellard.org/jslinux/
34
34
  * Copyright (c) 2011 Fabrice Bellard
35
- */var la=Object.defineProperty,ih=Object.getOwnPropertyDescriptor,sh=(e,t)=>{for(var i in t)la(e,i,{get:t[i],enumerable:!0})},Ce=(e,t,i,s)=>{for(var r=s>1?void 0:s?ih(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&la(t,i,r),r},F=(e,t)=>(i,s)=>t(i,s,e),On="Terminal input",lr={get:()=>On,set:e=>On=e},Fn="Too much output to announce, navigate to rows manually to read",hr={get:()=>Fn,set:e=>Fn=e};function rh(e){return e.replace(/\r?\n/g,"\r")}function nh(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function oh(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function ah(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");ha(r,t,i,s)}}function ha(e,t,i,s){e=rh(e),e=nh(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function ca(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Hn(e,t,i,s,r){ca(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Ht(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Cs(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var lh=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},hh=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let _=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let f=0,g;for(;(g=this.interim[++f]&63)&&f<4;)m<<=6,m|=g;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,L=k-f;for(;l<L;){if(l>=i)return 0;if(g=e[l++],(g&192)!==128){l--,_=!0;break}else this.interim[f++]=g,m<<=6,m|=g&63}_||(k===2?m<128?l--:t[s++]=m:k===3?m<2048||m>=55296&&m<=57343||m===65279||(t[s++]=m):m<65536||m>1114111||(t[s++]=m)),this.interim.fill(0)}let u=i-4,d=l;for(;d<i;){for(;d<u&&!((r=e[d])&128)&&!((n=e[d+1])&128)&&!((o=e[d+2])&128)&&!((a=e[d+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((r&224)===192){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}t[s++]=h}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},ua="",zt=" ",$i=class da{constructor(){this.fg=0,this.bg=0,this.extended=new ps}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new da;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ps=class fa{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new fa(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ut=class _a extends $i{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ps,this.combinedData=""}static fromCharData(t){let i=new _a;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ht(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},zn="di$target",cr="di$dependencies",js=new Map;function ch(e){return e[cr]||[]}function He(e){if(js.has(e))return js.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");uh(t,i,r)};return t._id=e,js.set(e,t),t}function uh(e,t,i){t[zn]===t?t[cr].push({id:e,index:i}):(t[cr]=[{id:e,index:i}],t[zn]=t)}var Qe=He("BufferService"),ma=He("CoreMouseService"),ei=He("CoreService"),dh=He("CharsetService"),Vr=He("InstantiationService"),pa=He("LogService"),et=He("OptionsService"),ga=He("OscLinkService"),fh=He("UnicodeService"),ji=He("DecorationService"),ur=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var u;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new ut,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let d=0;d<o;d++)if(!(h===-1&&!i.hasContent(d))){if(i.loadCell(d,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=d,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&d===o-1){let _=(u=this._oscLinkService.getLinkData(a))==null?void 0:u.uri;if(_){let m={start:{x:h+1,y:e},end:{x:d+(!l&&d===o-1?1:0),y:e}},f=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let g=new URL(_);["http:","https:"].includes(g.protocol)||(f=!0)}catch{f=!0}f||s.push({text:_,range:m,activate:(g,k)=>r?r.activate(g,k,m):_h(g,k),hover:(g,k)=>{var L;return(L=r==null?void 0:r.hover)==null?void 0:L.call(r,g,k,m)},leave:(g,k)=>{var L;return(L=r==null?void 0:r.leave)==null?void 0:L.call(r,g,k,m)}})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};ur=Ce([F(0,Qe),F(1,et),F(2,ga)],ur);function _h(e,t){if(confirm(`Do you want to navigate to ${t}?
35
+ */var fa=Object.defineProperty,dh=Object.getOwnPropertyDescriptor,fh=(e,t)=>{for(var i in t)fa(e,i,{get:t[i],enumerable:!0})},ye=(e,t,i,s)=>{for(var r=s>1?void 0:s?dh(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&fa(t,i,r),r},z=(e,t)=>(i,s)=>t(i,s,e),Wn="Terminal input",dr={get:()=>Wn,set:e=>Wn=e},$n="Too much output to announce, navigate to rows manually to read",fr={get:()=>$n,set:e=>$n=e};function _h(e){return e.replace(/\r?\n/g,"\r")}function mh(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function ph(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function gh(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");_a(r,t,i,s)}}function _a(e,t,i,s){e=_h(e),e=mh(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function ma(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function jn(e,t,i,s,r){ma(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Vt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Rs(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var vh=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},Sh=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let _=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let f=0,v;for(;(v=this.interim[++f]&63)&&f<4;)m<<=6,m|=v;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,D=k-f;for(;l<D;){if(l>=i)return 0;if(v=e[l++],(v&192)!==128){l--,_=!0;break}else this.interim[f++]=v,m<<=6,m|=v&63}_||(k===2?m<128?l--:t[s++]=m:k===3?m<2048||m>=55296&&m<=57343||m===65279||(t[s++]=m):m<65536||m>1114111||(t[s++]=m)),this.interim.fill(0)}let u=i-4,d=l;for(;d<i;){for(;d<u&&!((r=e[d])&128)&&!((n=e[d+1])&128)&&!((o=e[d+2])&128)&&!((a=e[d+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((r&224)===192){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}t[s++]=h}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},pa="",Yt=" ",qi=class ga{constructor(){this.fg=0,this.bg=0,this.extended=new ws}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new ga;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ws=class va{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new va(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mt=class Sa extends qi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ws,this.combinedData=""}static fromCharData(t){let i=new Sa;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Vt(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Un="di$target",_r="di$dependencies",Vs=new Map;function bh(e){return e[_r]||[]}function ze(e){if(Vs.has(e))return Vs.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");wh(t,i,r)};return t._id=e,Vs.set(e,t),t}function wh(e,t,i){t[Un]===t?t[_r].push({id:e,index:i}):(t[_r]=[{id:e,index:i}],t[Un]=t)}var Qe=ze("BufferService"),ba=ze("CoreMouseService"),ai=ze("CoreService"),yh=ze("CharsetService"),Zr=ze("InstantiationService"),wa=ze("LogService"),et=ze("OptionsService"),ya=ze("OscLinkService"),Ch=ze("UnicodeService"),Vi=ze("DecorationService"),mr=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var u;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new mt,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let d=0;d<o;d++)if(!(h===-1&&!i.hasContent(d))){if(i.loadCell(d,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=d,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&d===o-1){let _=(u=this._oscLinkService.getLinkData(a))==null?void 0:u.uri;if(_){let m={start:{x:h+1,y:e},end:{x:d+(!l&&d===o-1?1:0),y:e}},f=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let v=new URL(_);["http:","https:"].includes(v.protocol)||(f=!0)}catch{f=!0}f||s.push({text:_,range:m,activate:(v,k)=>r?r.activate(v,k,m):xh(v,k),hover:(v,k)=>{var D;return(D=r==null?void 0:r.hover)==null?void 0:D.call(r,v,k,m)},leave:(v,k)=>{var D;return(D=r==null?void 0:r.leave)==null?void 0:D.call(r,v,k,m)}})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};mr=ye([z(0,Qe),z(1,et),z(2,ya)],mr);function xh(e,t){if(confirm(`Do you want to navigate to ${t}?
36
36
 
37
- WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var xs=He("CharSizeService"),Mt=He("CoreBrowserService"),Yr=He("MouseService"),Dt=He("RenderService"),mh=He("SelectionService"),va=He("CharacterJoinerService"),_i=He("ThemeService"),Sa=He("LinkProviderService"),ph=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Wn.isErrorNoTelemetry(e)?new Wn(e.message+`
37
+ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Ms=ze("CharSizeService"),Ot=ze("CoreBrowserService"),Jr=ze("MouseService"),Ft=ze("RenderService"),kh=ze("SelectionService"),Ca=ze("CharacterJoinerService"),Si=ze("ThemeService"),xa=ze("LinkProviderService"),Eh=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Kn.isErrorNoTelemetry(e)?new Kn(e.message+`
38
38
 
39
39
  `+e.stack):new Error(e.message+`
40
40
 
41
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},gh=new ph;function cs(e){vh(e)||gh.onUnexpectedError(e)}var dr="Canceled";function vh(e){return e instanceof Sh?!0:e instanceof Error&&e.name===dr&&e.message===dr}var Sh=class extends Error{constructor(){super(dr),this.name=this.message}};function bh(e){return new Error(`Illegal argument: ${e}`)}var Wn=class fr extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof fr)return t;let i=new fr;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},_r=class ba extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,ba.prototype)}};function rt(e,t=0){return e[e.length-(1+t)]}var yh;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(yh||(yh={}));function wh(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var ya;(e=>{function t(N){return N&&typeof N=="object"&&typeof N[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(N){yield N}e.single=r;function n(N){return t(N)?N:r(N)}e.wrap=n;function o(N){return N||i}e.from=o;function*a(N){for(let R=N.length-1;R>=0;R--)yield N[R]}e.reverse=a;function h(N){return!N||N[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(N){return N[Symbol.iterator]().next().value}e.first=l;function u(N,R){let z=0;for(let X of N)if(R(X,z++))return!0;return!1}e.some=u;function d(N,R){for(let z of N)if(R(z))return z}e.find=d;function*_(N,R){for(let z of N)R(z)&&(yield z)}e.filter=_;function*m(N,R){let z=0;for(let X of N)yield R(X,z++)}e.map=m;function*f(N,R){let z=0;for(let X of N)yield*R(X,z++)}e.flatMap=f;function*g(...N){for(let R of N)yield*R}e.concat=g;function k(N,R,z){let X=z;for(let G of N)X=R(X,G);return X}e.reduce=k;function*L(N,R,z=N.length){for(R<0&&(R+=N.length),z<0?z+=N.length:z>N.length&&(z=N.length);R<z;R++)yield N[R]}e.slice=L;function U(N,R=Number.POSITIVE_INFINITY){let z=[];if(R===0)return[z,N];let X=N[Symbol.iterator]();for(let G=0;G<R;G++){let se=X.next();if(se.done)return[z,e.empty()];z.push(se.value)}return[z,{[Symbol.iterator](){return X}}]}e.consume=U;async function $(N){let R=[];for await(let z of N)R.push(z);return Promise.resolve(R)}e.asyncToArray=$})(ya||(ya={}));function Jt(e){if(ya.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Ch(...e){return me(()=>Jt(e))}function me(e){return{dispose:wh(()=>{e()})}}var wa=class Ca{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Jt(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Ca.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};wa.DISABLE_DISPOSED_WARNING=!1;var Wt=wa,ie=class{constructor(){this._store=new Wt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ie.None=Object.freeze({dispose(){}});var fi=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Bt=typeof window=="object"?window:globalThis,mr=class pr{constructor(t){this.element=t,this.next=pr.Undefined,this.prev=pr.Undefined}};mr.Undefined=new mr(void 0);var ve=mr,$n=class{constructor(){this._first=ve.Undefined,this._last=ve.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ve.Undefined}clear(){let e=this._first;for(;e!==ve.Undefined;){let t=e.next;e.prev=ve.Undefined,e.next=ve.Undefined,e=t}this._first=ve.Undefined,this._last=ve.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new ve(e);if(this._first===ve.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==ve.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ve.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ve.Undefined&&e.next!==ve.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ve.Undefined&&e.next===ve.Undefined?(this._first=ve.Undefined,this._last=ve.Undefined):e.next===ve.Undefined?(this._last=this._last.prev,this._last.next=ve.Undefined):e.prev===ve.Undefined&&(this._first=this._first.next,this._first.prev=ve.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ve.Undefined;)yield e.element,e=e.next}},xh=globalThis.performance&&typeof globalThis.performance.now=="function",kh=class xa{static create(t){return new xa(t)}constructor(t){this._now=xh&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},je;(e=>{e.None=()=>ie.None;function t(C,S){return d(C,()=>{},0,void 0,!0,void 0,S)}e.defer=t;function i(C){return(S,B=null,T)=>{let P=!1,E;return E=C(A=>{if(!P)return E?E.dispose():P=!0,S.call(B,A)},null,T),P&&E.dispose(),E}}e.once=i;function s(C,S,B){return l((T,P=null,E)=>C(A=>T.call(P,S(A)),null,E),B)}e.map=s;function r(C,S,B){return l((T,P=null,E)=>C(A=>{S(A),T.call(P,A)},null,E),B)}e.forEach=r;function n(C,S,B){return l((T,P=null,E)=>C(A=>S(A)&&T.call(P,A),null,E),B)}e.filter=n;function o(C){return C}e.signal=o;function a(...C){return(S,B=null,T)=>{let P=Ch(...C.map(E=>E(A=>S.call(B,A))));return u(P,T)}}e.any=a;function h(C,S,B,T){let P=B;return s(C,E=>(P=S(P,E),P),T)}e.reduce=h;function l(C,S){let B,T={onWillAddFirstListener(){B=C(P.fire,P)},onDidRemoveLastListener(){B==null||B.dispose()}},P=new D(T);return S==null||S.add(P),P.event}function u(C,S){return S instanceof Array?S.push(C):S&&S.add(C),C}function d(C,S,B=100,T=!1,P=!1,E,A){let J,ae,oe,ke=0,be,O={leakWarningThreshold:E,onWillAddFirstListener(){J=C(Z=>{ke++,ae=S(ae,Z),T&&!oe&&(I.fire(ae),ae=void 0),be=()=>{let q=ae;ae=void 0,oe=void 0,(!T||ke>1)&&I.fire(q),ke=0},typeof B=="number"?(clearTimeout(oe),oe=setTimeout(be,B)):oe===void 0&&(oe=0,queueMicrotask(be))})},onWillRemoveListener(){P&&ke>0&&(be==null||be())},onDidRemoveLastListener(){be=void 0,J.dispose()}},I=new D(O);return A==null||A.add(I),I.event}e.debounce=d;function _(C,S=0,B){return e.debounce(C,(T,P)=>T?(T.push(P),T):[P],S,void 0,!0,void 0,B)}e.accumulate=_;function m(C,S=(T,P)=>T===P,B){let T=!0,P;return n(C,E=>{let A=T||!S(E,P);return T=!1,P=E,A},B)}e.latch=m;function f(C,S,B){return[e.filter(C,S,B),e.filter(C,T=>!S(T),B)]}e.split=f;function g(C,S=!1,B=[],T){let P=B.slice(),E=C(ae=>{P?P.push(ae):J.fire(ae)});T&&T.add(E);let A=()=>{P==null||P.forEach(ae=>J.fire(ae)),P=null},J=new D({onWillAddFirstListener(){E||(E=C(ae=>J.fire(ae)),T&&T.add(E))},onDidAddFirstListener(){P&&(S?setTimeout(A):A())},onDidRemoveLastListener(){E&&E.dispose(),E=null}});return T&&T.add(J),J.event}e.buffer=g;function k(C,S){return(B,T,P)=>{let E=S(new U);return C(function(A){let J=E.evaluate(A);J!==L&&B.call(T,J)},void 0,P)}}e.chain=k;let L=Symbol("HaltChainable");class U{constructor(){this.steps=[]}map(S){return this.steps.push(S),this}forEach(S){return this.steps.push(B=>(S(B),B)),this}filter(S){return this.steps.push(B=>S(B)?B:L),this}reduce(S,B){let T=B;return this.steps.push(P=>(T=S(T,P),T)),this}latch(S=(B,T)=>B===T){let B=!0,T;return this.steps.push(P=>{let E=B||!S(P,T);return B=!1,T=P,E?P:L}),this}evaluate(S){for(let B of this.steps)if(S=B(S),S===L)break;return S}}function $(C,S,B=T=>T){let T=(...J)=>A.fire(B(...J)),P=()=>C.on(S,T),E=()=>C.removeListener(S,T),A=new D({onWillAddFirstListener:P,onDidRemoveLastListener:E});return A.event}e.fromNodeEventEmitter=$;function N(C,S,B=T=>T){let T=(...J)=>A.fire(B(...J)),P=()=>C.addEventListener(S,T),E=()=>C.removeEventListener(S,T),A=new D({onWillAddFirstListener:P,onDidRemoveLastListener:E});return A.event}e.fromDOMEventEmitter=N;function R(C){return new Promise(S=>i(C)(S))}e.toPromise=R;function z(C){let S=new D;return C.then(B=>{S.fire(B)},()=>{S.fire(void 0)}).finally(()=>{S.dispose()}),S.event}e.fromPromise=z;function X(C,S){return C(B=>S.fire(B))}e.forward=X;function G(C,S,B){return S(B),C(T=>S(T))}e.runAndSubscribe=G;class se{constructor(S,B){this._observable=S,this._counter=0,this._hasChanged=!1;let T={onWillAddFirstListener:()=>{S.addObserver(this)},onDidRemoveLastListener:()=>{S.removeObserver(this)}};this.emitter=new D(T),B&&B.add(this.emitter)}beginUpdate(S){this._counter++}handlePossibleChange(S){}handleChange(S,B){this._hasChanged=!0}endUpdate(S){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ne(C,S){return new se(C,S).emitter.event}e.fromObservable=ne;function Q(C){return(S,B,T)=>{let P=0,E=!1,A={beginUpdate(){P++},endUpdate(){P--,P===0&&(C.reportChanges(),E&&(E=!1,S.call(B)))},handlePossibleChange(){},handleChange(){E=!0}};C.addObserver(A),C.reportChanges();let J={dispose(){C.removeObserver(A)}};return T instanceof Wt?T.add(J):Array.isArray(T)&&T.push(J),J}}e.fromObservableLight=Q})(je||(je={}));var gr=class vr{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${vr._idPool++}`,vr.all.add(this)}start(t){this._stopWatch=new kh,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};gr.all=new Set,gr._idPool=0;var Eh=gr,Th=-1,ka=class Ea{constructor(t,i,s=(Ea._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let h=new Mh(a,n);this._errorHandler(h)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};ka._idPool=1;var Rh=ka,Bh=class Ta{constructor(t){this.value=t}static create(){let t=new Error;return new Ta(t.stack??"")}print(){console.warn(this.value.split(`
41
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Th=new Eh;function ms(e){Rh(e)||Th.onUnexpectedError(e)}var pr="Canceled";function Rh(e){return e instanceof Mh?!0:e instanceof Error&&e.name===pr&&e.message===pr}var Mh=class extends Error{constructor(){super(pr),this.name=this.message}};function Bh(e){return new Error(`Illegal argument: ${e}`)}var Kn=class gr extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof gr)return t;let i=new gr;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},vr=class ka extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,ka.prototype)}};function ot(e,t=0){return e[e.length-(1+t)]}var Dh;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Dh||(Dh={}));function Lh(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Ea;(e=>{function t(N){return N&&typeof N=="object"&&typeof N[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(N){yield N}e.single=r;function n(N){return t(N)?N:r(N)}e.wrap=n;function o(N){return N||i}e.from=o;function*a(N){for(let A=N.length-1;A>=0;A--)yield N[A]}e.reverse=a;function h(N){return!N||N[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(N){return N[Symbol.iterator]().next().value}e.first=l;function u(N,A){let O=0;for(let Q of N)if(A(Q,O++))return!0;return!1}e.some=u;function d(N,A){for(let O of N)if(A(O))return O}e.find=d;function*_(N,A){for(let O of N)A(O)&&(yield O)}e.filter=_;function*m(N,A){let O=0;for(let Q of N)yield A(Q,O++)}e.map=m;function*f(N,A){let O=0;for(let Q of N)yield*A(Q,O++)}e.flatMap=f;function*v(...N){for(let A of N)yield*A}e.concat=v;function k(N,A,O){let Q=O;for(let Y of N)Q=A(Q,Y);return Q}e.reduce=k;function*D(N,A,O=N.length){for(A<0&&(A+=N.length),O<0?O+=N.length:O>N.length&&(O=N.length);A<O;A++)yield N[A]}e.slice=D;function W(N,A=Number.POSITIVE_INFINITY){let O=[];if(A===0)return[O,N];let Q=N[Symbol.iterator]();for(let Y=0;Y<A;Y++){let te=Q.next();if(te.done)return[O,e.empty()];O.push(te.value)}return[O,{[Symbol.iterator](){return Q}}]}e.consume=W;async function U(N){let A=[];for await(let O of N)A.push(O);return Promise.resolve(A)}e.asyncToArray=U})(Ea||(Ea={}));function ni(e){if(Ea.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Ph(...e){return pe(()=>ni(e))}function pe(e){return{dispose:Lh(()=>{e()})}}var Ta=class Ra{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ni(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Ra.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Ta.DISABLE_DISPOSED_WARNING=!1;var Xt=Ta,se=class{constructor(){this._store=new Xt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};se.None=Object.freeze({dispose(){}});var vi=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Nt=typeof window=="object"?window:globalThis,Sr=class br{constructor(t){this.element=t,this.next=br.Undefined,this.prev=br.Undefined}};Sr.Undefined=new Sr(void 0);var ge=Sr,qn=class{constructor(){this._first=ge.Undefined,this._last=ge.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ge.Undefined}clear(){let e=this._first;for(;e!==ge.Undefined;){let t=e.next;e.prev=ge.Undefined,e.next=ge.Undefined,e=t}this._first=ge.Undefined,this._last=ge.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new ge(e);if(this._first===ge.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==ge.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ge.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ge.Undefined&&e.next!==ge.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ge.Undefined&&e.next===ge.Undefined?(this._first=ge.Undefined,this._last=ge.Undefined):e.next===ge.Undefined?(this._last=this._last.prev,this._last.next=ge.Undefined):e.prev===ge.Undefined&&(this._first=this._first.next,this._first.prev=ge.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ge.Undefined;)yield e.element,e=e.next}},Ah=globalThis.performance&&typeof globalThis.performance.now=="function",Ih=class Ma{static create(t){return new Ma(t)}constructor(t){this._now=Ah&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ke;(e=>{e.None=()=>se.None;function t(b,S){return d(b,()=>{},0,void 0,!0,void 0,S)}e.defer=t;function i(b){return(S,R=null,E)=>{let I=!1,T;return T=b(P=>{if(!I)return T?T.dispose():I=!0,S.call(R,P)},null,E),I&&T.dispose(),T}}e.once=i;function s(b,S,R){return l((E,I=null,T)=>b(P=>E.call(I,S(P)),null,T),R)}e.map=s;function r(b,S,R){return l((E,I=null,T)=>b(P=>{S(P),E.call(I,P)},null,T),R)}e.forEach=r;function n(b,S,R){return l((E,I=null,T)=>b(P=>S(P)&&E.call(I,P),null,T),R)}e.filter=n;function o(b){return b}e.signal=o;function a(...b){return(S,R=null,E)=>{let I=Ph(...b.map(T=>T(P=>S.call(R,P))));return u(I,E)}}e.any=a;function h(b,S,R,E){let I=R;return s(b,T=>(I=S(I,T),I),E)}e.reduce=h;function l(b,S){let R,E={onWillAddFirstListener(){R=b(I.fire,I)},onDidRemoveLastListener(){R==null||R.dispose()}},I=new B(E);return S==null||S.add(I),I.event}function u(b,S){return S instanceof Array?S.push(b):S&&S.add(b),b}function d(b,S,R=100,E=!1,I=!1,T,P){let ee,ae,ne,ce=0,_e,me={leakWarningThreshold:T,onWillAddFirstListener(){ee=b(L=>{ce++,ae=S(ae,L),E&&!ne&&(F.fire(ae),ae=void 0),_e=()=>{let J=ae;ae=void 0,ne=void 0,(!E||ce>1)&&F.fire(J),ce=0},typeof R=="number"?(clearTimeout(ne),ne=setTimeout(_e,R)):ne===void 0&&(ne=0,queueMicrotask(_e))})},onWillRemoveListener(){I&&ce>0&&(_e==null||_e())},onDidRemoveLastListener(){_e=void 0,ee.dispose()}},F=new B(me);return P==null||P.add(F),F.event}e.debounce=d;function _(b,S=0,R){return e.debounce(b,(E,I)=>E?(E.push(I),E):[I],S,void 0,!0,void 0,R)}e.accumulate=_;function m(b,S=(E,I)=>E===I,R){let E=!0,I;return n(b,T=>{let P=E||!S(T,I);return E=!1,I=T,P},R)}e.latch=m;function f(b,S,R){return[e.filter(b,S,R),e.filter(b,E=>!S(E),R)]}e.split=f;function v(b,S=!1,R=[],E){let I=R.slice(),T=b(ae=>{I?I.push(ae):ee.fire(ae)});E&&E.add(T);let P=()=>{I==null||I.forEach(ae=>ee.fire(ae)),I=null},ee=new B({onWillAddFirstListener(){T||(T=b(ae=>ee.fire(ae)),E&&E.add(T))},onDidAddFirstListener(){I&&(S?setTimeout(P):P())},onDidRemoveLastListener(){T&&T.dispose(),T=null}});return E&&E.add(ee),ee.event}e.buffer=v;function k(b,S){return(R,E,I)=>{let T=S(new W);return b(function(P){let ee=T.evaluate(P);ee!==D&&R.call(E,ee)},void 0,I)}}e.chain=k;let D=Symbol("HaltChainable");class W{constructor(){this.steps=[]}map(S){return this.steps.push(S),this}forEach(S){return this.steps.push(R=>(S(R),R)),this}filter(S){return this.steps.push(R=>S(R)?R:D),this}reduce(S,R){let E=R;return this.steps.push(I=>(E=S(E,I),E)),this}latch(S=(R,E)=>R===E){let R=!0,E;return this.steps.push(I=>{let T=R||!S(I,E);return R=!1,E=I,T?I:D}),this}evaluate(S){for(let R of this.steps)if(S=R(S),S===D)break;return S}}function U(b,S,R=E=>E){let E=(...ee)=>P.fire(R(...ee)),I=()=>b.on(S,E),T=()=>b.removeListener(S,E),P=new B({onWillAddFirstListener:I,onDidRemoveLastListener:T});return P.event}e.fromNodeEventEmitter=U;function N(b,S,R=E=>E){let E=(...ee)=>P.fire(R(...ee)),I=()=>b.addEventListener(S,E),T=()=>b.removeEventListener(S,E),P=new B({onWillAddFirstListener:I,onDidRemoveLastListener:T});return P.event}e.fromDOMEventEmitter=N;function A(b){return new Promise(S=>i(b)(S))}e.toPromise=A;function O(b){let S=new B;return b.then(R=>{S.fire(R)},()=>{S.fire(void 0)}).finally(()=>{S.dispose()}),S.event}e.fromPromise=O;function Q(b,S){return b(R=>S.fire(R))}e.forward=Q;function Y(b,S,R){return S(R),b(E=>S(E))}e.runAndSubscribe=Y;class te{constructor(S,R){this._observable=S,this._counter=0,this._hasChanged=!1;let E={onWillAddFirstListener:()=>{S.addObserver(this)},onDidRemoveLastListener:()=>{S.removeObserver(this)}};this.emitter=new B(E),R&&R.add(this.emitter)}beginUpdate(S){this._counter++}handlePossibleChange(S){}handleChange(S,R){this._hasChanged=!0}endUpdate(S){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ue(b,S){return new te(b,S).emitter.event}e.fromObservable=ue;function Z(b){return(S,R,E)=>{let I=0,T=!1,P={beginUpdate(){I++},endUpdate(){I--,I===0&&(b.reportChanges(),T&&(T=!1,S.call(R)))},handlePossibleChange(){},handleChange(){T=!0}};b.addObserver(P),b.reportChanges();let ee={dispose(){b.removeObserver(P)}};return E instanceof Xt?E.add(ee):Array.isArray(E)&&E.push(ee),ee}}e.fromObservableLight=Z})(Ke||(Ke={}));var wr=class yr{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${yr._idPool++}`,yr.all.add(this)}start(t){this._stopWatch=new Ih,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};wr.all=new Set,wr._idPool=0;var Nh=wr,Oh=-1,Ba=class Da{constructor(t,i,s=(Da._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let h=new zh(a,n);this._errorHandler(h)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};Ba._idPool=1;var Fh=Ba,Hh=class La{constructor(t){this.value=t}static create(){let t=new Error;return new La(t.stack??"")}print(){console.warn(this.value.split(`
42
42
  `).slice(2).join(`
43
- `))}},Mh=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Dh=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Lh=0,Us=class{constructor(e){this.value=e,this.id=Lh++}},Ph=2,Ah,D=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Rh((e==null?void 0:e.onListenerError)??cs,((i=this._options)==null?void 0:i.leakWarningThreshold)??Th):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Eh(this._options._profName):void 0,this._deliveryQueue=(r=this._options)==null?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var o,a,h,l,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],m=new Dh(`${d}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((o=this._options)==null?void 0:o.onListenerError)||cs)(m),ie.None}if(this._disposed)return ie.None;t&&(e=e.bind(t));let s=new Us(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Bh.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Us?(this._deliveryQueue??(this._deliveryQueue=new Ih),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||h.call(a,this),this._listeners=s,(u=(l=this._options)==null?void 0:l.onDidAddFirstListener)==null||u.call(l,this)),this._size++;let n=me(()=>{r==null||r(),this._removeListener(s)});return i instanceof Wt?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var r,n,o,a;if((n=(r=this._options)==null?void 0:r.onWillRemoveListener)==null||n.call(r,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(a=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||a.call(o,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*Ph<=t.length){let h=0;for(let l=0;l<t.length;l++)t[l]?t[h++]=t[l]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=h}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||cs;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Us)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(r=this._perfMon)==null||r.stop()}hasListeners(){return this._size>0}},Ih=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Sr=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new D,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new D,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Sr.INSTANCE=new Sr;var Xr=Sr;function Nh(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Xr.INSTANCE.onDidChangeZoomLevel;function Oh(e){return Xr.INSTANCE.getZoomFactor(e)}Xr.INSTANCE.onDidChangeFullscreen;var mi=typeof navigator=="object"?navigator.userAgent:"",br=mi.indexOf("Firefox")>=0,Fh=mi.indexOf("AppleWebKit")>=0,Gr=mi.indexOf("Chrome")>=0,Hh=!Gr&&mi.indexOf("Safari")>=0;mi.indexOf("Electron/")>=0;mi.indexOf("Android")>=0;var Ks=!1;if(typeof Bt.matchMedia=="function"){let e=Bt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Bt.matchMedia("(display-mode: fullscreen)");Ks=e.matches,Nh(Bt,e,({matches:i})=>{Ks&&t.matches||(Ks=i)})}var di="en",yr=!1,wr=!1,us=!1,Ra=!1,Xi,ds=di,jn=di,zh,ft,Gt=globalThis,$e,ea;typeof Gt.vscode<"u"&&typeof Gt.vscode.process<"u"?$e=Gt.vscode.process:typeof process<"u"&&typeof((ea=process==null?void 0:process.versions)==null?void 0:ea.node)=="string"&&($e=process);var ta,Wh=typeof((ta=$e==null?void 0:$e.versions)==null?void 0:ta.electron)=="string",$h=Wh&&($e==null?void 0:$e.type)==="renderer",ia;if(typeof $e=="object"){yr=$e.platform==="win32",wr=$e.platform==="darwin",us=$e.platform==="linux",us&&$e.env.SNAP&&$e.env.SNAP_REVISION,$e.env.CI||$e.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Xi=di,ds=di;let e=$e.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Xi=t.userLocale,jn=t.osLocale,ds=t.resolvedLanguage||di,zh=(ia=t.languagePack)==null?void 0:ia.translationsConfigFile}catch{}Ra=!0}else typeof navigator=="object"&&!$h?(ft=navigator.userAgent,yr=ft.indexOf("Windows")>=0,wr=ft.indexOf("Macintosh")>=0,(ft.indexOf("Macintosh")>=0||ft.indexOf("iPad")>=0||ft.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,us=ft.indexOf("Linux")>=0,(ft==null?void 0:ft.indexOf("Mobi"))>=0,ds=globalThis._VSCODE_NLS_LANGUAGE||di,Xi=navigator.language.toLowerCase(),jn=Xi):console.error("Unable to resolve platform.");var Ba=yr,yt=wr,jh=us,Un=Ra,wt=ft,Nt=ds,Uh;(e=>{function t(){return Nt}e.value=t;function i(){return Nt.length===2?Nt==="en":Nt.length>=3?Nt[0]==="e"&&Nt[1]==="n"&&Nt[2]==="-":!1}e.isDefaultVariant=i;function s(){return Nt==="en"}e.isDefault=s})(Uh||(Uh={}));var Kh=typeof Gt.postMessage=="function"&&!Gt.importScripts;(()=>{if(Kh){let e=[];Gt.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Gt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var qh=!!(wt&&wt.indexOf("Chrome")>=0);wt&&wt.indexOf("Firefox")>=0;!qh&&wt&&wt.indexOf("Safari")>=0;wt&&wt.indexOf("Edg/")>=0;wt&&wt.indexOf("Android")>=0;var ci=typeof navigator=="object"?navigator:{};Un||document.queryCommandSupported&&document.queryCommandSupported("copy")||ci&&ci.clipboard&&ci.clipboard.writeText,Un||ci&&ci.clipboard&&ci.clipboard.readText;var Zr=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},qs=new Zr,Kn=new Zr,qn=new Zr,Vh=new Array(230),Ma;(e=>{function t(a){return qs.keyCodeToStr(a)}e.toString=t;function i(a){return qs.strToKeyCode(a)}e.fromString=i;function s(a){return Kn.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return qn.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return Kn.strToKeyCode(a)||qn.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return qs.keyCodeToStr(a)}e.toElectronAccelerator=o})(Ma||(Ma={}));var Yh=class Da{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof Da&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Xh([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Xh=class{constructor(e){if(e.length===0)throw bh("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Gh(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Ma.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(br)switch(t){case 59:return 85;case 60:if(jh)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(yt)return 57;break}else if(Fh&&(yt&&t===93||!yt&&t===92))return 57;return Vh[t]||0}var Zh=yt?256:2048,Jh=512,Qh=1024,ec=yt?2048:256,Vn=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=Gh(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=Zh),this.altKey&&(t|=Jh),this.shiftKey&&(t|=Qh),this.metaKey&&(t|=ec),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Yh(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Yn=new WeakMap;function tc(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var ic=class{static getSameOriginWindowChain(e){let t=Yn.get(e);if(!t){t=[],Yn.set(e,t);let i=e,s;do s=tc(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},Gi=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=ic.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Xn=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Gr){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*a):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?br&&!yt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Hh&&Ba?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*a):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?br&&!yt?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},La=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),sc;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof rc?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:je.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:La})})(sc||(sc={}));var rc=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?La:(this._emitter||(this._emitter=new D),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Jr=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new _r("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new _r("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},nc=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new _r("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=me(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},oc;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(oc||(oc={}));var Gn=class ht{static fromArray(t){return new ht(i=>{i.emitMany(t)})}static fromPromise(t){return new ht(async i=>{i.emitMany(await t)})}static fromPromises(t){return new ht(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new ht(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new D,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await je.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new ht(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return ht.map(this,t)}static filter(t,i){return new ht(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return ht.filter(this,t)}static coalesce(t){return ht.filter(t,i=>!!i)}coalesce(){return ht.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return ht.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Gn.EMPTY=Gn.fromArray([]);var{getWindow:bt,getWindowId:ac,onDidRegisterWindow:lc}=(function(){let e=new Map,t={window:Bt,disposables:new Wt};e.set(Bt.vscodeWindowId,t);let i=new D,s=new D,r=new D;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return ie.None;let a=new Wt,h={window:o,disposables:a.add(new Wt)};return e.set(o.vscodeWindowId,h),a.add(me(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(Y(o,Le.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:Bt},getDocument(o){return bt(o).document}}})(),hc=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Y(e,t,i,s){return new hc(e,t,i,s)}var Zn=function(e,t,i,s){return Y(e,t,i,s)},Qr,cc=class extends nc{constructor(e){super(),this.defaultTarget=e&&bt(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Jn=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){cs(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(Jn.sort),o.shift().execute();s.set(n,!1)};Qr=(n,o,a=0)=>{let h=ac(n),l=new Jn(o,a),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(l),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function uc(e){let t=e.getBoundingClientRect(),i=bt(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Le={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},dc=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=it(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=it(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=it(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=it(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=it(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=it(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=it(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=it(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=it(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=it(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=it(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=it(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=it(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=it(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function it(e){return typeof e=="number"?`${e}px`:e}function Ii(e){return new dc(e)}var Pa=class{constructor(){this._hooks=new Wt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(me(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=bt(e)}this._hooks.add(Y(n,Le.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Y(n,Le.POINTER_UP,o=>this.stopMonitoring(!0)))}};function fc(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var vt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(vt||(vt={}));var Mi=class Ve extends ie{constructor(){super(),this.dispatched=!1,this.targets=new $n,this.ignoreTargets=new $n,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(je.runAndSubscribe(lc,({window:t,disposables:i})=>{i.add(Y(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Y(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Y(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Bt,disposables:this._store}))}static addTarget(t){if(!Ve.isTouchDevice())return ie.None;Ve.INSTANCE||(Ve.INSTANCE=new Ve);let i=Ve.INSTANCE.targets.push(t);return me(i)}static ignoreTarget(t){if(!Ve.isTouchDevice())return ie.None;Ve.INSTANCE||(Ve.INSTANCE=new Ve);let i=Ve.INSTANCE.ignoreTargets.push(t);return me(i)}static isTouchDevice(){return"ontouchstart"in Bt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(vt.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let h=this.activeTouches[a.identifier],l=Date.now()-h.initialTimeStamp;if(l<Ve.HOLD_DELAY&&Math.abs(h.initialPageX-rt(h.rollingPageX))<30&&Math.abs(h.initialPageY-rt(h.rollingPageY))<30){let u=this.newGestureEvent(vt.Tap,h.initialTarget);u.pageX=rt(h.rollingPageX),u.pageY=rt(h.rollingPageY),this.dispatchEvent(u)}else if(l>=Ve.HOLD_DELAY&&Math.abs(h.initialPageX-rt(h.rollingPageX))<30&&Math.abs(h.initialPageY-rt(h.rollingPageY))<30){let u=this.newGestureEvent(vt.Contextmenu,h.initialTarget);u.pageX=rt(h.rollingPageX),u.pageY=rt(h.rollingPageY),this.dispatchEvent(u)}else if(r===1){let u=rt(h.rollingPageX),d=rt(h.rollingPageY),_=rt(h.rollingTimestamps)-h.rollingTimestamps[0],m=u-h.rollingPageX[0],f=d-h.rollingPageY[0],g=[...this.targets].filter(k=>h.initialTarget instanceof Node&&k.contains(h.initialTarget));this.inertia(t,g,s,Math.abs(m)/_,m>0?1:-1,u,Math.abs(f)/_,f>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(vt.End,h.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===vt.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Ve.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===vt.Change||t.type===vt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,h,l){this.handle=Qr(t,()=>{let u=Date.now(),d=u-s,_=0,m=0,f=!0;r+=Ve.SCROLL_FRICTION*d,a+=Ve.SCROLL_FRICTION*d,r>0&&(f=!1,_=n*r*d),a>0&&(f=!1,m=h*a*d);let g=this.newGestureEvent(vt.Change);g.translationX=_,g.translationY=m,i.forEach(k=>k.dispatchEvent(g)),f||this.inertia(t,i,u,r,n,o+_,a,h,l+m)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=this.newGestureEvent(vt.Change,o.initialTarget);a.translationX=n.pageX-rt(o.rollingPageX),a.translationY=n.pageY-rt(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Mi.SCROLL_FRICTION=-.005,Mi.HOLD_DELAY=700,Mi.CLEAR_TAP_COUNT_TIME=400,Ce([fc],Mi,"isTouchDevice",1);var _c=Mi,en=class extends ie{onclick(e,t){this._register(Y(e,Le.CLICK,i=>t(new Gi(bt(e),i))))}onmousedown(e,t){this._register(Y(e,Le.MOUSE_DOWN,i=>t(new Gi(bt(e),i))))}onmouseover(e,t){this._register(Y(e,Le.MOUSE_OVER,i=>t(new Gi(bt(e),i))))}onmouseleave(e,t){this._register(Y(e,Le.MOUSE_LEAVE,i=>t(new Gi(bt(e),i))))}onkeydown(e,t){this._register(Y(e,Le.KEY_DOWN,i=>t(new Vn(i))))}onkeyup(e,t){this._register(Y(e,Le.KEY_UP,i=>t(new Vn(i))))}oninput(e,t){this._register(Y(e,Le.INPUT,t))}onblur(e,t){this._register(Y(e,Le.BLUR,t))}onfocus(e,t){this._register(Y(e,Le.FOCUS,t))}onchange(e,t){this._register(Y(e,Le.CHANGE,t))}ignoreGesture(e){return _c.ignoreTarget(e)}},Qn=11,mc=class extends en{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Qn+"px",this.domNode.style.height=Qn+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Pa),this._register(Zn(this.bgDomNode,Le.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Zn(this.domNode,Le.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new cc),this._pointerdownScheduleRepeatTimer=this._register(new Jr)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,bt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},pc=class Cr{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Cr(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Cr(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:h}}},gc=class extends ie{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new D),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new pc(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new to(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=to.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},eo=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Vs(e,t){let i=t-e;return function(s){return e+i*bc(s)}}function vc(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var to=class xr{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),vc(Vs(t,r),Vs(n,i),.33)}return Vs(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new eo(s,r,!1)}return new eo(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return xr.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new xr(t,i,r,s)}};function Sc(e){return Math.pow(e,3)}function bc(e){return 1-Sc(1-e)}var yc=class extends ie{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Jr)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},wc=140,Aa=class extends en{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new yc(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Pa),this._shouldRender=!0,this.domNode=Ii(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Y(this.domNode.domNode,Le.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new mc(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Ii(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Y(this.slider.domNode,Le.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=uc(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(Ba&&o>wc){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ia=class kr{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new kr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(s*a/r))),u=(a-l)/(r-s),d=n*u;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:u,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=kr._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Cc=class extends Aa{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ia(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},xc=class extends Aa{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ia(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},kc=500,io=50,Ec=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Er=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Gr){let i=bt(t.browserEvent),s=Oh(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new Ec(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),u=Math.max(r,o),d=Math.max(n,a);u%h===0&&d%l===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Er.INSTANCE=new Er;var Tc=Er,Rc=class extends en{constructor(e,t,i){super(),this._onScroll=this._register(new D),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new D),this.onWillScroll=this._onWillScroll.event,this._options=Mc(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new xc(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Cc(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Ii(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ii(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ii(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Jr),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Jt(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,yt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Xn(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Jt(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Xn(i))};this._mouseWheelToDispose.push(Y(this._listenOnDomNode,Le.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=Tc.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!yt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let u=io*n,d=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(l,d)}if(o){let u=io*o,d=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(l,d)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),kc)}},Bc=class extends Rc{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Mc(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,yt&&(t.className+=" mac"),t}var Tr=class extends ie{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new D),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new gc({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>Qr(s.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Bc(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(je.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(me(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(me(()=>this._styleElement.remove())),this._register(je.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
44
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(l=>this._handleScroll(l)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Tr=Ce([F(2,Qe),F(3,Mt),F(4,ma),F(5,_i),F(6,et),F(7,Dt)],Tr);var Rr=class extends ie{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(n=>this._removeDecoration(n))),this._register(me(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Rr=Ce([F(1,Qe),F(2,Mt),F(3,ji),F(4,Dt)],Rr);var Dc=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},pt={full:0,left:0,center:0,right:0},Ot={full:0,left:0,center:0,right:0},Ci={full:0,left:0,center:0,right:0},gs=class extends ie{constructor(e,t,i,s,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new Dc,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(l=this._viewportElement.parentElement)==null||l.insertBefore(this._canvas,this._viewportElement),this._register(me(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Ot.full=this._canvas.width,Ot.left=e,Ot.center=t,Ot.right=e,this._refreshDrawHeightConstants(),Ci.full=1,Ci.left=1,Ci.center=1+Ot.left,Ci.right=1+Ot.left+Ot.center}_refreshDrawHeightConstants(){pt.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);pt.left=t,pt.center=t,pt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pt.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ci[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-pt[e.position||"full"]/2),Ot[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+pt[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};gs=Ce([F(2,Qe),F(3,ji),F(4,Dt),F(5,et),F(6,_i),F(7,Mt)],gs);var x;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
45
- `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(x||(x={}));var fs;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(fs||(fs={}));var Na;(e=>e.ST=`${x.ESC}\\`)(Na||(Na={}));var Br=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${x.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Br=Ce([F(2,Qe),F(3,et),F(4,ei),F(5,Dt)],Br);var Ne=0,Oe=0,Fe=0,we=0,so={css:"#00000000",rgba:0},Te;(e=>{function t(r,n,o,a){return a!==void 0?`#${qt(r)}${qt(n)}${qt(o)}${qt(a)}`:`#${qt(r)}${qt(n)}${qt(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(Te||(Te={}));var _e;(e=>{function t(h,l){if(we=(l.rgba&255)/255,we===1)return{css:l.css,rgba:l.rgba};let u=l.rgba>>24&255,d=l.rgba>>16&255,_=l.rgba>>8&255,m=h.rgba>>24&255,f=h.rgba>>16&255,g=h.rgba>>8&255;Ne=m+Math.round((u-m)*we),Oe=f+Math.round((d-f)*we),Fe=g+Math.round((_-g)*we);let k=Te.toCss(Ne,Oe,Fe),L=Te.toRgba(Ne,Oe,Fe);return{css:k,rgba:L}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,u){let d=_s.ensureContrastRatio(h.rgba,l.rgba,u);if(d)return Te.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[Ne,Oe,Fe]=_s.toChannels(l),{css:Te.toCss(Ne,Oe,Fe),rgba:l}}e.opaque=r;function n(h,l){return we=Math.round(l*255),[Ne,Oe,Fe]=_s.toChannels(h.rgba),{css:Te.toCss(Ne,Oe,Fe,we),rgba:Te.toRgba(Ne,Oe,Fe,we)}}e.opacity=n;function o(h,l){return we=h.rgba&255,n(h,we*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(_e||(_e={}));var Se;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ne=parseInt(r.slice(1,2).repeat(2),16),Oe=parseInt(r.slice(2,3).repeat(2),16),Fe=parseInt(r.slice(3,4).repeat(2),16),Te.toColor(Ne,Oe,Fe);case 5:return Ne=parseInt(r.slice(1,2).repeat(2),16),Oe=parseInt(r.slice(2,3).repeat(2),16),Fe=parseInt(r.slice(3,4).repeat(2),16),we=parseInt(r.slice(4,5).repeat(2),16),Te.toColor(Ne,Oe,Fe,we);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Ne=parseInt(n[1]),Oe=parseInt(n[2]),Fe=parseInt(n[3]),we=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Te.toColor(Ne,Oe,Fe,we);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ne,Oe,Fe,we]=t.getImageData(0,0,1,1).data,we!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Te.toRgba(Ne,Oe,Fe,we),css:r}}e.toColor=s})(Se||(Se={}));var Je;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+u*.7152+d*.0722}e.relativeLuminance2=i})(Je||(Je={}));var _s;(e=>{function t(o,a){if(we=(a&255)/255,we===1)return a;let h=a>>24&255,l=a>>16&255,u=a>>8&255,d=o>>24&255,_=o>>16&255,m=o>>8&255;return Ne=d+Math.round((h-d)*we),Oe=_+Math.round((l-_)*we),Fe=m+Math.round((u-m)*we),Te.toRgba(Ne,Oe,Fe)}e.blend=t;function i(o,a,h){let l=Je.relativeLuminance(o>>8),u=Je.relativeLuminance(a>>8);if(Tt(l,u)<h){if(u<l){let m=s(o,a,h),f=Tt(l,Je.relativeLuminance(m>>8));if(f<h){let g=r(o,a,h),k=Tt(l,Je.relativeLuminance(g>>8));return f>k?m:g}return m}let d=r(o,a,h),_=Tt(l,Je.relativeLuminance(d>>8));if(_<h){let m=s(o,a,h),f=Tt(l,Je.relativeLuminance(m>>8));return _>f?d:m}return d}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,_=a>>24&255,m=a>>16&255,f=a>>8&255,g=Tt(Je.relativeLuminance2(_,m,f),Je.relativeLuminance2(l,u,d));for(;g<h&&(_>0||m>0||f>0);)_-=Math.max(0,Math.ceil(_*.1)),m-=Math.max(0,Math.ceil(m*.1)),f-=Math.max(0,Math.ceil(f*.1)),g=Tt(Je.relativeLuminance2(_,m,f),Je.relativeLuminance2(l,u,d));return(_<<24|m<<16|f<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,_=a>>24&255,m=a>>16&255,f=a>>8&255,g=Tt(Je.relativeLuminance2(_,m,f),Je.relativeLuminance2(l,u,d));for(;g<h&&(_<255||m<255||f<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),g=Tt(Je.relativeLuminance2(_,m,f),Je.relativeLuminance2(l,u,d));return(_<<24|m<<16|f<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(_s||(_s={}));function qt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Tt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Lc=class extends $i{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},vs=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ut}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),r=0,n=0,o=0,a=t.getFg(0),h=t.getBg(0);for(let l=0;l<t.getTrimmedLength();l++)if(t.loadCell(l,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==h){if(l-r>1){let u=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<u.length;d++)i.push(u[d])}r=l,o=n,a=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||zt.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<l.length;u++)i.push(l[u])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let h=this._characterJoiners[a].handler(n);for(let l=0;l<h.length;l++)vs._mergeRanges(o,h[l])}catch(h){console.error(h)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let h=t.getWidth(a),l=t.getString(a).length||zt.length;if(h!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=l}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};vs=Ce([F(0,Qe)],vs);function Pc(e){return 57508<=e&&e<=57558}function Ac(e){return 9472<=e&&e<=9631}function Ic(e){return Pc(e)||Ac(e)}function Nc(){return{css:{canvas:Zi(),cell:Zi()},device:{canvas:Zi(),cell:Zi(),char:{width:0,height:0,left:0,top:0}}}}function Zi(){return{width:0,height:0}}var Mr=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new ut,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,h,l,u){let d=[],_=this._characterJoinerService.getJoinedCharacters(t),m=this._themeService.colors,f=e.getNoBgTrimmedLength();i&&f<n+1&&(f=n+1);let g,k=0,L="",U=0,$=0,N=0,R=0,z=!1,X=0,G=!1,se=0,ne=0,Q=[],C=l!==-1&&u!==-1;for(let S=0;S<f;S++){e.loadCell(S,this._workCell);let B=this._workCell.getWidth();if(B===0)continue;let T=!1,P=S>=ne,E=S,A=this._workCell;if(_.length>0&&S===_[0][0]&&P){let ee=_.shift(),Xe=this._isCellInSelection(ee[0],t);for(U=ee[0]+1;U<ee[1];U++)P&&(P=Xe===this._isCellInSelection(U,t));P&&(P=!i||n<ee[0]||n>=ee[1]),P?(T=!0,A=new Lc(this._workCell,e.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),E=ee[1]-1,B=A.getWidth()):ne=ee[1]}let J=this._isCellInSelection(S,t),ae=i&&S===n,oe=C&&S>=l&&S<=u,ke=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,ee=>{ke=!0});let be=A.getChars()||zt;if(be===" "&&(A.isUnderline()||A.isOverline())&&(be=" "),se=B*a-h.get(be,A.isBold(),A.isItalic()),!g)g=this._document.createElement("span");else if(k&&(J&&G||!J&&!G&&A.bg===$)&&(J&&G&&m.selectionForeground||A.fg===N)&&A.extended.ext===R&&oe===z&&se===X&&!ae&&!T&&!ke&&P){A.isInvisible()?L+=zt:L+=be,k++;continue}else k&&(g.textContent=L),g=this._document.createElement("span"),k=0,L="";if($=A.bg,N=A.fg,R=A.extended.ext,z=oe,X=se,G=J,T&&n>=S&&n<=E&&(n=S),!this._coreService.isCursorHidden&&ae&&this._coreService.isCursorInitialized){if(Q.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&Q.push("xterm-cursor-blink"),Q.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":Q.push("xterm-cursor-outline");break;case"block":Q.push("xterm-cursor-block");break;case"bar":Q.push("xterm-cursor-bar");break;case"underline":Q.push("xterm-cursor-underline");break}}if(A.isBold()&&Q.push("xterm-bold"),A.isItalic()&&Q.push("xterm-italic"),A.isDim()&&Q.push("xterm-dim"),A.isInvisible()?L=zt:L=A.getChars()||zt,A.isUnderline()&&(Q.push(`xterm-underline-${A.extended.underlineStyle}`),L===" "&&(L=" "),!A.isUnderlineColorDefault()))if(A.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${$i.toColorRGB(A.getUnderlineColor()).join(",")})`;else{let ee=A.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&A.isBold()&&ee<8&&(ee+=8),g.style.textDecorationColor=m.ansi[ee].css}A.isOverline()&&(Q.push("xterm-overline"),L===" "&&(L=" ")),A.isStrikethrough()&&Q.push("xterm-strikethrough"),oe&&(g.style.textDecoration="underline");let O=A.getFgColor(),I=A.getFgColorMode(),Z=A.getBgColor(),q=A.getBgColorMode(),le=!!A.isInverse();if(le){let ee=O;O=Z,Z=ee;let Xe=I;I=q,q=Xe}let De,j,V=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,ee=>{ee.options.layer!=="top"&&V||(ee.backgroundColorRGB&&(q=50331648,Z=ee.backgroundColorRGB.rgba>>8&16777215,De=ee.backgroundColorRGB),ee.foregroundColorRGB&&(I=50331648,O=ee.foregroundColorRGB.rgba>>8&16777215,j=ee.foregroundColorRGB),V=ee.options.layer==="top")}),!V&&J&&(De=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,Z=De.rgba>>8&16777215,q=50331648,V=!0,m.selectionForeground&&(I=50331648,O=m.selectionForeground.rgba>>8&16777215,j=m.selectionForeground)),V&&Q.push("xterm-decoration-top");let pe;switch(q){case 16777216:case 33554432:pe=m.ansi[Z],Q.push(`xterm-bg-${Z}`);break;case 50331648:pe=Te.toColor(Z>>16,Z>>8&255,Z&255),this._addStyle(g,`background-color:#${ro((Z>>>0).toString(16),"0",6)}`);break;case 0:default:le?(pe=m.foreground,Q.push("xterm-bg-257")):pe=m.background}switch(De||A.isDim()&&(De=_e.multiplyOpacity(pe,.5)),I){case 16777216:case 33554432:A.isBold()&&O<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(O+=8),this._applyMinimumContrast(g,pe,m.ansi[O],A,De,void 0)||Q.push(`xterm-fg-${O}`);break;case 50331648:let ee=Te.toColor(O>>16&255,O>>8&255,O&255);this._applyMinimumContrast(g,pe,ee,A,De,j)||this._addStyle(g,`color:#${ro(O.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(g,pe,m.foreground,A,De,j)||le&&Q.push("xterm-fg-257")}Q.length&&(g.className=Q.join(" "),Q.length=0),!ae&&!T&&!ke&&P?k++:g.textContent=L,se!==this.defaultSpacing&&(g.style.letterSpacing=`${se}px`),d.push(g),S=E}return g&&k&&(g.textContent=L),d}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ic(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=_e.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Mr=Ce([F(1,va),F(2,et),F(3,Mt),F(4,ei),F(5,ji),F(6,_i)],Mr);function ro(e,t,i){for(;e.length<i;)e=t+e;return e}var Oc=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Fc=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function Hc(){return new Fc}var Ys="xterm-dom-renderer-owner-",lt="xterm-rows",Ji="xterm-fg-",no="xterm-bg-",xi="xterm-focus",Qi="xterm-selection",zc=1,Dr=class extends ie{constructor(e,t,i,s,r,n,o,a,h,l,u,d,_,m){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=_,this._themeService=m,this._terminalClass=zc++,this._rowElements=[],this._selectionRenderModel=Hc(),this.onRequestRedraw=this._register(new D).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(lt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Qi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Nc(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(f=>this._injectCss(f))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(Mr,document),this._element.classList.add(Ys+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(f=>this._handleLinkHover(f))),this._register(this._linkifier2.onHideLinkUnderline(f=>this._handleLinkLeave(f))),this._register(me(()=>{this._element.classList.remove(Ys+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Oc(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${lt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${lt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${lt} .xterm-dim { color: ${_e.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${lt}.${xi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${lt}.${xi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${lt}.${xi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Qi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Qi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Qi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Ji}${n} { color: ${o.css}; }${this._terminalSelector} .${Ji}${n}.xterm-dim { color: ${_e.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${no}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ji}257 { color: ${_e.opaque(e.background).css}; }${this._terminalSelector} .${Ji}257.xterm-dim { color: ${_e.multiplyOpacity(_e.opaque(e.background),.5).css}; }${this._terminalSelector} .${no}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(xi),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(xi),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let u=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,u)),n!==o){let d=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+i.ydisp,u=this._rowElements[h],d=i.lines.get(l);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,l,l===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ys}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=i;m<=s;++m){let f=m+a.ydisp,g=this._rowElements[m],k=a.lines.get(f);if(!g||!k)break;g.replaceChildren(...this._rowFactory.createRow(k,f,f===h,d,_,l,u,this.dimensions.css.cell.width,this._widthCache,n?m===i?e:0:-1,n?(m===s?t:r)-1:-1))}}};Dr=Ce([F(7,Vr),F(8,xs),F(9,et),F(10,Qe),F(11,ei),F(12,Mt),F(13,_i)],Dr);var Lr=class extends ie{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new D),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new $c(this._optionsService))}catch{this._measureStrategy=this._register(new Wc(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Lr=Ce([F(2,et)],Lr);var Oa=class extends ie{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},Wc=class extends Oa{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},$c=class extends Oa{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},jc=class extends ie{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Uc(this._window)),this._onDprChange=this._register(new D),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new D),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(je.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Y(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Y(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Uc=class extends ie{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new fi),this._onDprChange=this._register(new D),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(me(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Y(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Kc=class extends ie{constructor(){super(),this.linkProviders=[],this._register(me(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function tn(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function qc(e,t,i,s,r,n,o,a,h){if(!n)return;let l=tn(e,t,i);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),s+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var Pr=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return qc(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=tn(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Pr=Ce([F(0,Dt),F(1,xs)],Pr);var Vc=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Fa={};sh(Fa,{getSafariVersion:()=>Xc,isChromeOS:()=>$a,isFirefox:()=>Ha,isIpad:()=>Gc,isIphone:()=>Zc,isLegacyEdge:()=>Yc,isLinux:()=>sn,isMac:()=>Ss,isNode:()=>ks,isSafari:()=>za,isWindows:()=>Wa});var ks=typeof process<"u"&&"title"in process,Ui=ks?"node":navigator.userAgent,Ki=ks?"node":navigator.platform,Ha=Ui.includes("Firefox"),Yc=Ui.includes("Edge"),za=/^((?!chrome|android).)*safari/i.test(Ui);function Xc(){if(!za)return 0;let e=Ui.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Ss=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ki),Gc=Ki==="iPad",Zc=Ki==="iPhone",Wa=["Windows","Win16","Win32","WinCE"].includes(Ki),sn=Ki.indexOf("Linux")>=0,$a=/\bCrOS\b/.test(Ui),ja=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},Jc=class extends ja{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Qc=class extends ja{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},bs=!ks&&"requestIdleCallback"in window?Qc:Jc,eu=class{constructor(){this._queue=new bs}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Ar=class extends ie{constructor(e,t,i,s,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new fi),this._pausedResizeTask=new eu,this._observerDisposable=this._register(new fi),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new D),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new D),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new D),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new D),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Vc((l,u)=>this._renderRows(l,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new tu(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(me(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var l;return(l=this._renderer.value)==null?void 0:l.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=me(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Ar=Ce([F(2,et),F(3,xs),F(4,ei),F(5,ji),F(6,Qe),F(7,Mt),F(8,_i)],Ar);var tu=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function iu(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return nu(r,n,e,t,i,s)+Es(n,t,i,s)+ou(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",Fi(Math.abs(r-e),Oi(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),h=ru(n>t?e:r,i)+(a-1)*i.cols+1+su(n>t?r:e);return Fi(h,Oi(o,s))}function su(e,t){return e-1}function ru(e,t){return t.cols-e}function nu(e,t,i,s,r,n){return Es(t,s,r,n).length===0?"":Fi(Ka(e,t,e,t-Qt(t,r),!1,r).length,Oi("D",n))}function Es(e,t,i,s){let r=e-Qt(e,i),n=t-Qt(t,i),o=Math.abs(r-n)-au(e,t,i);return Fi(o,Oi(Ua(e,t),s))}function ou(e,t,i,s,r,n){let o;Es(t,s,r,n).length>0?o=s-Qt(s,r):o=t;let a=s,h=lu(e,t,i,s,r,n);return Fi(Ka(e,o,i,a,h==="C",r).length,Oi(h,n))}function au(e,t,i){var o;let s=0,r=e-Qt(e,i),n=t-Qt(t,i);for(let a=0;a<Math.abs(r-n);a++){let h=Ua(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+h*a))!=null&&o.isWrapped&&s++}return s}function Qt(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function lu(e,t,i,s,r,n){let o;return Es(i,s,r,n).length>0?o=s-Qt(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function Ua(e,t){return e>t?"A":"B"}function Ka(e,t,i,s,r,n){let o=e,a=t,h="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function Oi(e,t){let i=t?"O":"[";return x.ESC+i+e}function Fi(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var hu=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function oo(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Xs=50,cu=15,uu=50,du=500,fu=" ",_u=new RegExp(fu,"g"),Ir=class extends ie{constructor(e,t,i,s,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ut,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new D),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new D),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new D),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new D),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new hu(this._bufferService),this._activeSelectionMode=0,this._register(me(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=i.translateBufferLineToString(o,!0,r,n);s.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),a=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?s[s.length-1]+=a:s.push(a)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(_u," ")).join(Wa?`\r
43
+ `))}},zh=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Wh=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},$h=0,Ys=class{constructor(e){this.value=e,this.id=$h++}},jh=2,Uh,B=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Fh((e==null?void 0:e.onListenerError)??ms,((i=this._options)==null?void 0:i.leakWarningThreshold)??Oh):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Nh(this._options._profName):void 0,this._deliveryQueue=(r=this._options)==null?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var o,a,h,l,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],m=new Wh(`${d}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((o=this._options)==null?void 0:o.onListenerError)||ms)(m),se.None}if(this._disposed)return se.None;t&&(e=e.bind(t));let s=new Ys(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Hh.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Ys?(this._deliveryQueue??(this._deliveryQueue=new Kh),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||h.call(a,this),this._listeners=s,(u=(l=this._options)==null?void 0:l.onDidAddFirstListener)==null||u.call(l,this)),this._size++;let n=pe(()=>{r==null||r(),this._removeListener(s)});return i instanceof Xt?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var r,n,o,a;if((n=(r=this._options)==null?void 0:r.onWillRemoveListener)==null||n.call(r,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(a=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||a.call(o,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*jh<=t.length){let h=0;for(let l=0;l<t.length;l++)t[l]?t[h++]=t[l]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=h}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||ms;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Ys)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(r=this._perfMon)==null||r.stop()}hasListeners(){return this._size>0}},Kh=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Cr=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new B,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new B,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Cr.INSTANCE=new Cr;var Qr=Cr;function qh(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Qr.INSTANCE.onDidChangeZoomLevel;function Vh(e){return Qr.INSTANCE.getZoomFactor(e)}Qr.INSTANCE.onDidChangeFullscreen;var bi=typeof navigator=="object"?navigator.userAgent:"",xr=bi.indexOf("Firefox")>=0,Yh=bi.indexOf("AppleWebKit")>=0,en=bi.indexOf("Chrome")>=0,Xh=!en&&bi.indexOf("Safari")>=0;bi.indexOf("Electron/")>=0;bi.indexOf("Android")>=0;var Xs=!1;if(typeof Nt.matchMedia=="function"){let e=Nt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Nt.matchMedia("(display-mode: fullscreen)");Xs=e.matches,qh(Nt,e,({matches:i})=>{Xs&&t.matches||(Xs=i)})}var gi="en",kr=!1,Er=!1,ps=!1,Pa=!1,es,gs=gi,Vn=gi,Gh,vt,si=globalThis,Ue,na;typeof si.vscode<"u"&&typeof si.vscode.process<"u"?Ue=si.vscode.process:typeof process<"u"&&typeof((na=process==null?void 0:process.versions)==null?void 0:na.node)=="string"&&(Ue=process);var oa,Zh=typeof((oa=Ue==null?void 0:Ue.versions)==null?void 0:oa.electron)=="string",Jh=Zh&&(Ue==null?void 0:Ue.type)==="renderer",aa;if(typeof Ue=="object"){kr=Ue.platform==="win32",Er=Ue.platform==="darwin",ps=Ue.platform==="linux",ps&&Ue.env.SNAP&&Ue.env.SNAP_REVISION,Ue.env.CI||Ue.env.BUILD_ARTIFACTSTAGINGDIRECTORY,es=gi,gs=gi;let e=Ue.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);es=t.userLocale,Vn=t.osLocale,gs=t.resolvedLanguage||gi,Gh=(aa=t.languagePack)==null?void 0:aa.translationsConfigFile}catch{}Pa=!0}else typeof navigator=="object"&&!Jh?(vt=navigator.userAgent,kr=vt.indexOf("Windows")>=0,Er=vt.indexOf("Macintosh")>=0,(vt.indexOf("Macintosh")>=0||vt.indexOf("iPad")>=0||vt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ps=vt.indexOf("Linux")>=0,(vt==null?void 0:vt.indexOf("Mobi"))>=0,gs=globalThis._VSCODE_NLS_LANGUAGE||gi,es=navigator.language.toLowerCase(),Vn=es):console.error("Unable to resolve platform.");var Aa=kr,Tt=Er,Qh=ps,Yn=Pa,Rt=vt,Ut=gs,ec;(e=>{function t(){return Ut}e.value=t;function i(){return Ut.length===2?Ut==="en":Ut.length>=3?Ut[0]==="e"&&Ut[1]==="n"&&Ut[2]==="-":!1}e.isDefaultVariant=i;function s(){return Ut==="en"}e.isDefault=s})(ec||(ec={}));var tc=typeof si.postMessage=="function"&&!si.importScripts;(()=>{if(tc){let e=[];si.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),si.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var ic=!!(Rt&&Rt.indexOf("Chrome")>=0);Rt&&Rt.indexOf("Firefox")>=0;!ic&&Rt&&Rt.indexOf("Safari")>=0;Rt&&Rt.indexOf("Edg/")>=0;Rt&&Rt.indexOf("Android")>=0;var mi=typeof navigator=="object"?navigator:{};Yn||document.queryCommandSupported&&document.queryCommandSupported("copy")||mi&&mi.clipboard&&mi.clipboard.writeText,Yn||mi&&mi.clipboard&&mi.clipboard.readText;var tn=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Gs=new tn,Xn=new tn,Gn=new tn,sc=new Array(230),Ia;(e=>{function t(a){return Gs.keyCodeToStr(a)}e.toString=t;function i(a){return Gs.strToKeyCode(a)}e.fromString=i;function s(a){return Xn.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return Gn.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return Xn.strToKeyCode(a)||Gn.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Gs.keyCodeToStr(a)}e.toElectronAccelerator=o})(Ia||(Ia={}));var rc=class Na{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof Na&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new nc([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},nc=class{constructor(e){if(e.length===0)throw Bh("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function oc(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Ia.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(xr)switch(t){case 59:return 85;case 60:if(Qh)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Tt)return 57;break}else if(Yh&&(Tt&&t===93||!Tt&&t===92))return 57;return sc[t]||0}var ac=Tt?256:2048,lc=512,hc=1024,cc=Tt?2048:256,Zn=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=oc(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=ac),this.altKey&&(t|=lc),this.shiftKey&&(t|=hc),this.metaKey&&(t|=cc),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new rc(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Jn=new WeakMap;function uc(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var dc=class{static getSameOriginWindowChain(e){let t=Jn.get(e);if(!t){t=[],Jn.set(e,t);let i=e,s;do s=uc(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},ts=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=dc.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Qn=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(en){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*a):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?xr&&!Tt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Xh&&Aa?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*a):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?xr&&!Tt?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Oa=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),fc;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof _c?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ke.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Oa})})(fc||(fc={}));var _c=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Oa:(this._emitter||(this._emitter=new B),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},sn=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new vr("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new vr("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},mc=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new vr("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=pe(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},pc;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(pc||(pc={}));var eo=class ft{static fromArray(t){return new ft(i=>{i.emitMany(t)})}static fromPromise(t){return new ft(async i=>{i.emitMany(await t)})}static fromPromises(t){return new ft(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new ft(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new B,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ke.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new ft(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return ft.map(this,t)}static filter(t,i){return new ft(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return ft.filter(this,t)}static coalesce(t){return ft.filter(t,i=>!!i)}coalesce(){return ft.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return ft.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};eo.EMPTY=eo.fromArray([]);var{getWindow:Et,getWindowId:gc,onDidRegisterWindow:vc}=(function(){let e=new Map,t={window:Nt,disposables:new Xt};e.set(Nt.vscodeWindowId,t);let i=new B,s=new B,r=new B;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return se.None;let a=new Xt,h={window:o,disposables:a.add(new Xt)};return e.set(o.vscodeWindowId,h),a.add(pe(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(X(o,Pe.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:Nt},getDocument(o){return Et(o).document}}})(),Sc=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function X(e,t,i,s){return new Sc(e,t,i,s)}var to=function(e,t,i,s){return X(e,t,i,s)},rn,bc=class extends mc{constructor(e){super(),this.defaultTarget=e&&Et(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},io=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){ms(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(io.sort),o.shift().execute();s.set(n,!1)};rn=(n,o,a=0)=>{let h=gc(n),l=new io(o,a),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(l),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function wc(e){let t=e.getBoundingClientRect(),i=Et(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Pe={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},yc=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=st(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=st(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=st(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=st(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=st(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=st(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=st(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=st(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=st(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=st(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=st(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=st(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=st(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=st(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function st(e){return typeof e=="number"?`${e}px`:e}function Hi(e){return new yc(e)}var Fa=class{constructor(){this._hooks=new Xt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(pe(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=Et(e)}this._hooks.add(X(n,Pe.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(X(n,Pe.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Cc(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var xt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(xt||(xt={}));var Ai=class Ve extends se{constructor(){super(),this.dispatched=!1,this.targets=new qn,this.ignoreTargets=new qn,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ke.runAndSubscribe(vc,({window:t,disposables:i})=>{i.add(X(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(X(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(X(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Nt,disposables:this._store}))}static addTarget(t){if(!Ve.isTouchDevice())return se.None;Ve.INSTANCE||(Ve.INSTANCE=new Ve);let i=Ve.INSTANCE.targets.push(t);return pe(i)}static ignoreTarget(t){if(!Ve.isTouchDevice())return se.None;Ve.INSTANCE||(Ve.INSTANCE=new Ve);let i=Ve.INSTANCE.ignoreTargets.push(t);return pe(i)}static isTouchDevice(){return"ontouchstart"in Nt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(xt.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let h=this.activeTouches[a.identifier],l=Date.now()-h.initialTimeStamp;if(l<Ve.HOLD_DELAY&&Math.abs(h.initialPageX-ot(h.rollingPageX))<30&&Math.abs(h.initialPageY-ot(h.rollingPageY))<30){let u=this.newGestureEvent(xt.Tap,h.initialTarget);u.pageX=ot(h.rollingPageX),u.pageY=ot(h.rollingPageY),this.dispatchEvent(u)}else if(l>=Ve.HOLD_DELAY&&Math.abs(h.initialPageX-ot(h.rollingPageX))<30&&Math.abs(h.initialPageY-ot(h.rollingPageY))<30){let u=this.newGestureEvent(xt.Contextmenu,h.initialTarget);u.pageX=ot(h.rollingPageX),u.pageY=ot(h.rollingPageY),this.dispatchEvent(u)}else if(r===1){let u=ot(h.rollingPageX),d=ot(h.rollingPageY),_=ot(h.rollingTimestamps)-h.rollingTimestamps[0],m=u-h.rollingPageX[0],f=d-h.rollingPageY[0],v=[...this.targets].filter(k=>h.initialTarget instanceof Node&&k.contains(h.initialTarget));this.inertia(t,v,s,Math.abs(m)/_,m>0?1:-1,u,Math.abs(f)/_,f>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(xt.End,h.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===xt.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Ve.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===xt.Change||t.type===xt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,h,l){this.handle=rn(t,()=>{let u=Date.now(),d=u-s,_=0,m=0,f=!0;r+=Ve.SCROLL_FRICTION*d,a+=Ve.SCROLL_FRICTION*d,r>0&&(f=!1,_=n*r*d),a>0&&(f=!1,m=h*a*d);let v=this.newGestureEvent(xt.Change);v.translationX=_,v.translationY=m,i.forEach(k=>k.dispatchEvent(v)),f||this.inertia(t,i,u,r,n,o+_,a,h,l+m)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=this.newGestureEvent(xt.Change,o.initialTarget);a.translationX=n.pageX-ot(o.rollingPageX),a.translationY=n.pageY-ot(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ai.SCROLL_FRICTION=-.005,Ai.HOLD_DELAY=700,Ai.CLEAR_TAP_COUNT_TIME=400,ye([Cc],Ai,"isTouchDevice",1);var xc=Ai,nn=class extends se{onclick(e,t){this._register(X(e,Pe.CLICK,i=>t(new ts(Et(e),i))))}onmousedown(e,t){this._register(X(e,Pe.MOUSE_DOWN,i=>t(new ts(Et(e),i))))}onmouseover(e,t){this._register(X(e,Pe.MOUSE_OVER,i=>t(new ts(Et(e),i))))}onmouseleave(e,t){this._register(X(e,Pe.MOUSE_LEAVE,i=>t(new ts(Et(e),i))))}onkeydown(e,t){this._register(X(e,Pe.KEY_DOWN,i=>t(new Zn(i))))}onkeyup(e,t){this._register(X(e,Pe.KEY_UP,i=>t(new Zn(i))))}oninput(e,t){this._register(X(e,Pe.INPUT,t))}onblur(e,t){this._register(X(e,Pe.BLUR,t))}onfocus(e,t){this._register(X(e,Pe.FOCUS,t))}onchange(e,t){this._register(X(e,Pe.CHANGE,t))}ignoreGesture(e){return xc.ignoreTarget(e)}},so=11,kc=class extends nn{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=so+"px",this.domNode.style.height=so+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Fa),this._register(to(this.bgDomNode,Pe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(to(this.domNode,Pe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new bc),this._pointerdownScheduleRepeatTimer=this._register(new sn)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Et(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Ec=class Tr{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Tr(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Tr(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:h}}},Tc=class extends se{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new B),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Ec(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new no(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=no.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},ro=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Zs(e,t){let i=t-e;return function(s){return e+i*Bc(s)}}function Rc(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var no=class Rr{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),Rc(Zs(t,r),Zs(n,i),.33)}return Zs(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new ro(s,r,!1)}return new ro(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Rr.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new Rr(t,i,r,s)}};function Mc(e){return Math.pow(e,3)}function Bc(e){return 1-Mc(1-e)}var Dc=class extends se{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new sn)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Lc=140,Ha=class extends nn{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Dc(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Fa),this._shouldRender=!0,this.domNode=Hi(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(X(this.domNode.domNode,Pe.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new kc(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Hi(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(X(this.slider.domNode,Pe.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=wc(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(Aa&&o>Lc){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},za=class Mr{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Mr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(s*a/r))),u=(a-l)/(r-s),d=n*u;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:u,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=Mr._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Pc=class extends Ha{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new za(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Ac=class extends Ha{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new za(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},Ic=500,oo=50,Nc=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Br=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(en){let i=Et(t.browserEvent),s=Vh(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new Nc(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),u=Math.max(r,o),d=Math.max(n,a);u%h===0&&d%l===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Br.INSTANCE=new Br;var Oc=Br,Fc=class extends nn{constructor(e,t,i){super(),this._onScroll=this._register(new B),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new B),this.onWillScroll=this._onWillScroll.event,this._options=zc(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Ac(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Pc(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Hi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Hi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Hi(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new sn),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ni(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Tt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Qn(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ni(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Qn(i))};this._mouseWheelToDispose.push(X(this._listenOnDomNode,Pe.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=Oc.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!Tt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let u=oo*n,d=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(l,d)}if(o){let u=oo*o,d=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(l,d)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Ic)}},Hc=class extends Fc{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function zc(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Tt&&(t.className+=" mac"),t}var Dr=class extends se{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new B),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Tc({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>rn(s.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Hc(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ke.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(pe(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(pe(()=>this._styleElement.remove())),this._register(Ke.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
44
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(l=>this._handleScroll(l)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Dr=ye([z(2,Qe),z(3,Ot),z(4,ba),z(5,Si),z(6,et),z(7,Ft)],Dr);var Lr=class extends se{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(n=>this._removeDecoration(n))),this._register(pe(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Lr=ye([z(1,Qe),z(2,Ot),z(3,Vi),z(4,Ft)],Lr);var Wc=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},yt={full:0,left:0,center:0,right:0},Kt={full:0,left:0,center:0,right:0},Ti={full:0,left:0,center:0,right:0},ys=class extends se{constructor(e,t,i,s,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new Wc,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(l=this._viewportElement.parentElement)==null||l.insertBefore(this._canvas,this._viewportElement),this._register(pe(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Kt.full=this._canvas.width,Kt.left=e,Kt.center=t,Kt.right=e,this._refreshDrawHeightConstants(),Ti.full=1,Ti.left=1,Ti.center=1+Kt.left,Ti.right=1+Kt.left+Kt.center}_refreshDrawHeightConstants(){yt.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);yt.left=t,yt.center=t,yt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yt.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ti[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-yt[e.position||"full"]/2),Kt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+yt[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ys=ye([z(2,Qe),z(3,Vi),z(4,Ft),z(5,et),z(6,Si),z(7,Ot)],ys);var x;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
45
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(x||(x={}));var vs;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(vs||(vs={}));var Wa;(e=>e.ST=`${x.ESC}\\`)(Wa||(Wa={}));var Pr=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${x.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Pr=ye([z(2,Qe),z(3,et),z(4,ai),z(5,Ft)],Pr);var Oe=0,Fe=0,He=0,we=0,ao={css:"#00000000",rgba:0},Re;(e=>{function t(r,n,o,a){return a!==void 0?`#${Qt(r)}${Qt(n)}${Qt(o)}${Qt(a)}`:`#${Qt(r)}${Qt(n)}${Qt(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(Re||(Re={}));var fe;(e=>{function t(h,l){if(we=(l.rgba&255)/255,we===1)return{css:l.css,rgba:l.rgba};let u=l.rgba>>24&255,d=l.rgba>>16&255,_=l.rgba>>8&255,m=h.rgba>>24&255,f=h.rgba>>16&255,v=h.rgba>>8&255;Oe=m+Math.round((u-m)*we),Fe=f+Math.round((d-f)*we),He=v+Math.round((_-v)*we);let k=Re.toCss(Oe,Fe,He),D=Re.toRgba(Oe,Fe,He);return{css:k,rgba:D}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,u){let d=Ss.ensureContrastRatio(h.rgba,l.rgba,u);if(d)return Re.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[Oe,Fe,He]=Ss.toChannels(l),{css:Re.toCss(Oe,Fe,He),rgba:l}}e.opaque=r;function n(h,l){return we=Math.round(l*255),[Oe,Fe,He]=Ss.toChannels(h.rgba),{css:Re.toCss(Oe,Fe,He,we),rgba:Re.toRgba(Oe,Fe,He,we)}}e.opacity=n;function o(h,l){return we=h.rgba&255,n(h,we*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(fe||(fe={}));var ve;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Oe=parseInt(r.slice(1,2).repeat(2),16),Fe=parseInt(r.slice(2,3).repeat(2),16),He=parseInt(r.slice(3,4).repeat(2),16),Re.toColor(Oe,Fe,He);case 5:return Oe=parseInt(r.slice(1,2).repeat(2),16),Fe=parseInt(r.slice(2,3).repeat(2),16),He=parseInt(r.slice(3,4).repeat(2),16),we=parseInt(r.slice(4,5).repeat(2),16),Re.toColor(Oe,Fe,He,we);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Oe=parseInt(n[1]),Fe=parseInt(n[2]),He=parseInt(n[3]),we=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Re.toColor(Oe,Fe,He,we);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Oe,Fe,He,we]=t.getImageData(0,0,1,1).data,we!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Re.toRgba(Oe,Fe,He,we),css:r}}e.toColor=s})(ve||(ve={}));var Je;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+u*.7152+d*.0722}e.relativeLuminance2=i})(Je||(Je={}));var Ss;(e=>{function t(o,a){if(we=(a&255)/255,we===1)return a;let h=a>>24&255,l=a>>16&255,u=a>>8&255,d=o>>24&255,_=o>>16&255,m=o>>8&255;return Oe=d+Math.round((h-d)*we),Fe=_+Math.round((l-_)*we),He=m+Math.round((u-m)*we),Re.toRgba(Oe,Fe,He)}e.blend=t;function i(o,a,h){let l=Je.relativeLuminance(o>>8),u=Je.relativeLuminance(a>>8);if(At(l,u)<h){if(u<l){let m=s(o,a,h),f=At(l,Je.relativeLuminance(m>>8));if(f<h){let v=r(o,a,h),k=At(l,Je.relativeLuminance(v>>8));return f>k?m:v}return m}let d=r(o,a,h),_=At(l,Je.relativeLuminance(d>>8));if(_<h){let m=s(o,a,h),f=At(l,Je.relativeLuminance(m>>8));return _>f?d:m}return d}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,_=a>>24&255,m=a>>16&255,f=a>>8&255,v=At(Je.relativeLuminance2(_,m,f),Je.relativeLuminance2(l,u,d));for(;v<h&&(_>0||m>0||f>0);)_-=Math.max(0,Math.ceil(_*.1)),m-=Math.max(0,Math.ceil(m*.1)),f-=Math.max(0,Math.ceil(f*.1)),v=At(Je.relativeLuminance2(_,m,f),Je.relativeLuminance2(l,u,d));return(_<<24|m<<16|f<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,_=a>>24&255,m=a>>16&255,f=a>>8&255,v=At(Je.relativeLuminance2(_,m,f),Je.relativeLuminance2(l,u,d));for(;v<h&&(_<255||m<255||f<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),v=At(Je.relativeLuminance2(_,m,f),Je.relativeLuminance2(l,u,d));return(_<<24|m<<16|f<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(Ss||(Ss={}));function Qt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function At(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var $c=class extends qi{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Cs=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new mt}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),r=0,n=0,o=0,a=t.getFg(0),h=t.getBg(0);for(let l=0;l<t.getTrimmedLength();l++)if(t.loadCell(l,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==h){if(l-r>1){let u=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<u.length;d++)i.push(u[d])}r=l,o=n,a=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||Yt.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<l.length;u++)i.push(l[u])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let h=this._characterJoiners[a].handler(n);for(let l=0;l<h.length;l++)Cs._mergeRanges(o,h[l])}catch(h){console.error(h)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let h=t.getWidth(a),l=t.getString(a).length||Yt.length;if(h!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=l}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Cs=ye([z(0,Qe)],Cs);function jc(e){return 57508<=e&&e<=57558}function Uc(e){return 9472<=e&&e<=9631}function Kc(e){return jc(e)||Uc(e)}function qc(){return{css:{canvas:is(),cell:is()},device:{canvas:is(),cell:is(),char:{width:0,height:0,left:0,top:0}}}}function is(){return{width:0,height:0}}var Ar=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new mt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,h,l,u){let d=[],_=this._characterJoinerService.getJoinedCharacters(t),m=this._themeService.colors,f=e.getNoBgTrimmedLength();i&&f<n+1&&(f=n+1);let v,k=0,D="",W=0,U=0,N=0,A=0,O=!1,Q=0,Y=!1,te=0,ue=0,Z=[],b=l!==-1&&u!==-1;for(let S=0;S<f;S++){e.loadCell(S,this._workCell);let R=this._workCell.getWidth();if(R===0)continue;let E=!1,I=S>=ue,T=S,P=this._workCell;if(_.length>0&&S===_[0][0]&&I){let G=_.shift(),Xe=this._isCellInSelection(G[0],t);for(W=G[0]+1;W<G[1];W++)I&&(I=Xe===this._isCellInSelection(W,t));I&&(I=!i||n<G[0]||n>=G[1]),I?(E=!0,P=new $c(this._workCell,e.translateToString(!0,G[0],G[1]),G[1]-G[0]),T=G[1]-1,R=P.getWidth()):ue=G[1]}let ee=this._isCellInSelection(S,t),ae=i&&S===n,ne=b&&S>=l&&S<=u,ce=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,G=>{ce=!0});let _e=P.getChars()||Yt;if(_e===" "&&(P.isUnderline()||P.isOverline())&&(_e=" "),te=R*a-h.get(_e,P.isBold(),P.isItalic()),!v)v=this._document.createElement("span");else if(k&&(ee&&Y||!ee&&!Y&&P.bg===U)&&(ee&&Y&&m.selectionForeground||P.fg===N)&&P.extended.ext===A&&ne===O&&te===Q&&!ae&&!E&&!ce&&I){P.isInvisible()?D+=Yt:D+=_e,k++;continue}else k&&(v.textContent=D),v=this._document.createElement("span"),k=0,D="";if(U=P.bg,N=P.fg,A=P.extended.ext,O=ne,Q=te,Y=ee,E&&n>=S&&n<=T&&(n=S),!this._coreService.isCursorHidden&&ae&&this._coreService.isCursorInitialized){if(Z.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&Z.push("xterm-cursor-blink"),Z.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":Z.push("xterm-cursor-outline");break;case"block":Z.push("xterm-cursor-block");break;case"bar":Z.push("xterm-cursor-bar");break;case"underline":Z.push("xterm-cursor-underline");break}}if(P.isBold()&&Z.push("xterm-bold"),P.isItalic()&&Z.push("xterm-italic"),P.isDim()&&Z.push("xterm-dim"),P.isInvisible()?D=Yt:D=P.getChars()||Yt,P.isUnderline()&&(Z.push(`xterm-underline-${P.extended.underlineStyle}`),D===" "&&(D=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())v.style.textDecorationColor=`rgb(${qi.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let G=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&G<8&&(G+=8),v.style.textDecorationColor=m.ansi[G].css}P.isOverline()&&(Z.push("xterm-overline"),D===" "&&(D=" ")),P.isStrikethrough()&&Z.push("xterm-strikethrough"),ne&&(v.style.textDecoration="underline");let me=P.getFgColor(),F=P.getFgColorMode(),L=P.getBgColor(),J=P.getBgColorMode(),V=!!P.isInverse();if(V){let G=me;me=L,L=G;let Xe=F;F=J,J=Xe}let Ce,Le,$=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,G=>{G.options.layer!=="top"&&$||(G.backgroundColorRGB&&(J=50331648,L=G.backgroundColorRGB.rgba>>8&16777215,Ce=G.backgroundColorRGB),G.foregroundColorRGB&&(F=50331648,me=G.foregroundColorRGB.rgba>>8&16777215,Le=G.foregroundColorRGB),$=G.options.layer==="top")}),!$&&ee&&(Ce=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,L=Ce.rgba>>8&16777215,J=50331648,$=!0,m.selectionForeground&&(F=50331648,me=m.selectionForeground.rgba>>8&16777215,Le=m.selectionForeground)),$&&Z.push("xterm-decoration-top");let j;switch(J){case 16777216:case 33554432:j=m.ansi[L],Z.push(`xterm-bg-${L}`);break;case 50331648:j=Re.toColor(L>>16,L>>8&255,L&255),this._addStyle(v,`background-color:#${lo((L>>>0).toString(16),"0",6)}`);break;case 0:default:V?(j=m.foreground,Z.push("xterm-bg-257")):j=m.background}switch(Ce||P.isDim()&&(Ce=fe.multiplyOpacity(j,.5)),F){case 16777216:case 33554432:P.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(v,j,m.ansi[me],P,Ce,void 0)||Z.push(`xterm-fg-${me}`);break;case 50331648:let G=Re.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(v,j,G,P,Ce,Le)||this._addStyle(v,`color:#${lo(me.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(v,j,m.foreground,P,Ce,Le)||V&&Z.push("xterm-fg-257")}Z.length&&(v.className=Z.join(" "),Z.length=0),!ae&&!E&&!ce&&I?k++:v.textContent=D,te!==this.defaultSpacing&&(v.style.letterSpacing=`${te}px`),d.push(v),S=T}return v&&k&&(v.textContent=D),d}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Kc(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=fe.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Ar=ye([z(1,Ca),z(2,et),z(3,Ot),z(4,ai),z(5,Vi),z(6,Si)],Ar);function lo(e,t,i){for(;e.length<i;)e=t+e;return e}var Vc=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Yc=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function Xc(){return new Yc}var Js="xterm-dom-renderer-owner-",dt="xterm-rows",ss="xterm-fg-",ho="xterm-bg-",Ri="xterm-focus",rs="xterm-selection",Gc=1,Ir=class extends se{constructor(e,t,i,s,r,n,o,a,h,l,u,d,_,m){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=_,this._themeService=m,this._terminalClass=Gc++,this._rowElements=[],this._selectionRenderModel=Xc(),this.onRequestRedraw=this._register(new B).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(dt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(rs),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=qc(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(f=>this._injectCss(f))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(Ar,document),this._element.classList.add(Js+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(f=>this._handleLinkHover(f))),this._register(this._linkifier2.onHideLinkUnderline(f=>this._handleLinkLeave(f))),this._register(pe(()=>{this._element.classList.remove(Js+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Vc(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${dt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${dt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${dt} .xterm-dim { color: ${fe.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${dt}.${Ri} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${dt}.${Ri} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${dt}.${Ri} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${dt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${dt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${dt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${dt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${dt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${rs} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${rs} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${rs} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${ss}${n} { color: ${o.css}; }${this._terminalSelector} .${ss}${n}.xterm-dim { color: ${fe.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${ho}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${ss}257 { color: ${fe.opaque(e.background).css}; }${this._terminalSelector} .${ss}257.xterm-dim { color: ${fe.multiplyOpacity(fe.opaque(e.background),.5).css}; }${this._terminalSelector} .${ho}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ri),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ri),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let u=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,u)),n!==o){let d=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+i.ydisp,u=this._rowElements[h],d=i.lines.get(l);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,l,l===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Js}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=i;m<=s;++m){let f=m+a.ydisp,v=this._rowElements[m],k=a.lines.get(f);if(!v||!k)break;v.replaceChildren(...this._rowFactory.createRow(k,f,f===h,d,_,l,u,this.dimensions.css.cell.width,this._widthCache,n?m===i?e:0:-1,n?(m===s?t:r)-1:-1))}}};Ir=ye([z(7,Zr),z(8,Ms),z(9,et),z(10,Qe),z(11,ai),z(12,Ot),z(13,Si)],Ir);var Nr=class extends se{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new B),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Jc(this._optionsService))}catch{this._measureStrategy=this._register(new Zc(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Nr=ye([z(2,et)],Nr);var $a=class extends se{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},Zc=class extends $a{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Jc=class extends $a{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Qc=class extends se{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new eu(this._window)),this._onDprChange=this._register(new B),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new B),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ke.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(X(this._textarea,"focus",()=>this._isFocused=!0)),this._register(X(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},eu=class extends se{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new vi),this._onDprChange=this._register(new B),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(pe(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=X(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},tu=class extends se{constructor(){super(),this.linkProviders=[],this._register(pe(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function on(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function iu(e,t,i,s,r,n,o,a,h){if(!n)return;let l=on(e,t,i);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),s+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var Or=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return iu(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=on(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Or=ye([z(0,Ft),z(1,Ms)],Or);var su=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},ja={};fh(ja,{getSafariVersion:()=>nu,isChromeOS:()=>Va,isFirefox:()=>Ua,isIpad:()=>ou,isIphone:()=>au,isLegacyEdge:()=>ru,isLinux:()=>an,isMac:()=>xs,isNode:()=>Bs,isSafari:()=>Ka,isWindows:()=>qa});var Bs=typeof process<"u"&&"title"in process,Yi=Bs?"node":navigator.userAgent,Xi=Bs?"node":navigator.platform,Ua=Yi.includes("Firefox"),ru=Yi.includes("Edge"),Ka=/^((?!chrome|android).)*safari/i.test(Yi);function nu(){if(!Ka)return 0;let e=Yi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var xs=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Xi),ou=Xi==="iPad",au=Xi==="iPhone",qa=["Windows","Win16","Win32","WinCE"].includes(Xi),an=Xi.indexOf("Linux")>=0,Va=/\bCrOS\b/.test(Yi),Ya=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},lu=class extends Ya{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},hu=class extends Ya{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ks=!Bs&&"requestIdleCallback"in window?hu:lu,cu=class{constructor(){this._queue=new ks}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Fr=class extends se{constructor(e,t,i,s,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new vi),this._pausedResizeTask=new cu,this._observerDisposable=this._register(new vi),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new B),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new B),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new B),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new B),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new su((l,u)=>this._renderRows(l,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new uu(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(pe(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var l;return(l=this._renderer.value)==null?void 0:l.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=pe(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Fr=ye([z(2,et),z(3,Ms),z(4,ai),z(5,Vi),z(6,Qe),z(7,Ot),z(8,Si)],Fr);var uu=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function du(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return mu(r,n,e,t,i,s)+Ds(n,t,i,s)+pu(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",$i(Math.abs(r-e),Wi(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),h=_u(n>t?e:r,i)+(a-1)*i.cols+1+fu(n>t?r:e);return $i(h,Wi(o,s))}function fu(e,t){return e-1}function _u(e,t){return t.cols-e}function mu(e,t,i,s,r,n){return Ds(t,s,r,n).length===0?"":$i(Ga(e,t,e,t-oi(t,r),!1,r).length,Wi("D",n))}function Ds(e,t,i,s){let r=e-oi(e,i),n=t-oi(t,i),o=Math.abs(r-n)-gu(e,t,i);return $i(o,Wi(Xa(e,t),s))}function pu(e,t,i,s,r,n){let o;Ds(t,s,r,n).length>0?o=s-oi(s,r):o=t;let a=s,h=vu(e,t,i,s,r,n);return $i(Ga(e,o,i,a,h==="C",r).length,Wi(h,n))}function gu(e,t,i){var o;let s=0,r=e-oi(e,i),n=t-oi(t,i);for(let a=0;a<Math.abs(r-n);a++){let h=Xa(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+h*a))!=null&&o.isWrapped&&s++}return s}function oi(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function vu(e,t,i,s,r,n){let o;return Ds(i,s,r,n).length>0?o=s-oi(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function Xa(e,t){return e>t?"A":"B"}function Ga(e,t,i,s,r,n){let o=e,a=t,h="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function Wi(e,t){let i=t?"O":"[";return x.ESC+i+e}function $i(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var Su=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function co(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Qs=50,bu=15,wu=50,yu=500,Cu=" ",xu=new RegExp(Cu,"g"),Hr=class extends se{constructor(e,t,i,s,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new mt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new B),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new B),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new B),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new B),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new Su(this._bufferService),this._activeSelectionMode=0,this._register(pe(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=i.translateBufferLineToString(o,!0,r,n);s.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),a=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?s[s.length-1]+=a:s.push(a)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(xu," ")).join(qa?`\r
46
46
  `:`
47
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),sn&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=oo(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=tn(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-Xs),Xs),t/=Xs,t/Math.abs(t)+Math.round(t*(cu-1)))}shouldForceSelection(e){return Ss?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),uu)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Ss&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<du&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=iu(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,u=0,d=0,_=0,m=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let k=e[0],L=e[0];n.getWidth(k)===0&&(u++,k--),n.getWidth(L)===2&&(d++,L++);let U=n.getString(L).length;for(U>1&&(m+=U-1,h+=U-1);k>0&&a>0&&!this._isCharWordSeparator(n.loadCell(k-1,this._workCell));){n.loadCell(k-1,this._workCell);let $=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,k--):$>1&&(_+=$-1,a-=$-1),a--,k--}for(;L<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(L+1,this._workCell));){n.loadCell(L+1,this._workCell);let $=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,L++):$>1&&(m+=$-1,h+=$-1),h++,L++}}h++;let f=a+l-u+_,g=Math.min(this._bufferService.cols,h-a+u+d-_-m);if(!(!t&&o.slice(a,h).trim()==="")){if(i&&f===0&&n.getCodePoint(0)!==32){let k=r.lines.get(e[1]-1);if(k&&n.isWrapped&&k.getCodePoint(this._bufferService.cols-1)!==32){let L=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(L){let U=this._bufferService.cols-L.start;f-=U,g+=U}}}if(s&&f+g===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let k=r.lines.get(e[1]+1);if(k!=null&&k.isWrapped&&k.getCodePoint(0)!==32){let L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(g+=L.length)}}return{start:f,length:g}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=oo(i,this._bufferService.cols)}};Ir=Ce([F(3,Qe),F(4,ei),F(5,Yr),F(6,et),F(7,Dt),F(8,Mt)],Ir);var ao=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},lo=class{constructor(){this._color=new ao,this._css=new ao}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Re=Object.freeze((()=>{let e=[Se.toColor("#2e3436"),Se.toColor("#cc0000"),Se.toColor("#4e9a06"),Se.toColor("#c4a000"),Se.toColor("#3465a4"),Se.toColor("#75507b"),Se.toColor("#06989a"),Se.toColor("#d3d7cf"),Se.toColor("#555753"),Se.toColor("#ef2929"),Se.toColor("#8ae234"),Se.toColor("#fce94f"),Se.toColor("#729fcf"),Se.toColor("#ad7fa8"),Se.toColor("#34e2e2"),Se.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:Te.toCss(s,r,n),rgba:Te.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Te.toCss(s,s,s),rgba:Te.toRgba(s,s,s)})}return e})()),Vt=Se.toColor("#ffffff"),Di=Se.toColor("#000000"),ho=Se.toColor("#ffffff"),co=Di,ki={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},mu=Vt,Nr=class extends ie{constructor(e){super(),this._optionsService=e,this._contrastCache=new lo,this._halfContrastCache=new lo,this._onChangeColors=this._register(new D),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Vt,background:Di,cursor:ho,cursorAccent:co,selectionForeground:void 0,selectionBackgroundTransparent:ki,selectionBackgroundOpaque:_e.blend(Di,ki),selectionInactiveBackgroundTransparent:ki,selectionInactiveBackgroundOpaque:_e.blend(Di,ki),scrollbarSliderBackground:_e.opacity(Vt,.2),scrollbarSliderHoverBackground:_e.opacity(Vt,.4),scrollbarSliderActiveBackground:_e.opacity(Vt,.5),overviewRulerBorder:Vt,ansi:Re.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=ue(e.foreground,Vt),t.background=ue(e.background,Di),t.cursor=_e.blend(t.background,ue(e.cursor,ho)),t.cursorAccent=_e.blend(t.background,ue(e.cursorAccent,co)),t.selectionBackgroundTransparent=ue(e.selectionBackground,ki),t.selectionBackgroundOpaque=_e.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ue(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=_e.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ue(e.selectionForeground,so):void 0,t.selectionForeground===so&&(t.selectionForeground=void 0),_e.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=_e.opacity(t.selectionBackgroundTransparent,.3)),_e.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=_e.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ue(e.scrollbarSliderBackground,_e.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ue(e.scrollbarSliderHoverBackground,_e.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ue(e.scrollbarSliderActiveBackground,_e.opacity(t.foreground,.5)),t.overviewRulerBorder=ue(e.overviewRulerBorder,mu),t.ansi=Re.slice(),t.ansi[0]=ue(e.black,Re[0]),t.ansi[1]=ue(e.red,Re[1]),t.ansi[2]=ue(e.green,Re[2]),t.ansi[3]=ue(e.yellow,Re[3]),t.ansi[4]=ue(e.blue,Re[4]),t.ansi[5]=ue(e.magenta,Re[5]),t.ansi[6]=ue(e.cyan,Re[6]),t.ansi[7]=ue(e.white,Re[7]),t.ansi[8]=ue(e.brightBlack,Re[8]),t.ansi[9]=ue(e.brightRed,Re[9]),t.ansi[10]=ue(e.brightGreen,Re[10]),t.ansi[11]=ue(e.brightYellow,Re[11]),t.ansi[12]=ue(e.brightBlue,Re[12]),t.ansi[13]=ue(e.brightMagenta,Re[13]),t.ansi[14]=ue(e.brightCyan,Re[14]),t.ansi[15]=ue(e.brightWhite,Re[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=ue(e.extendedAnsi[s],Re[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Nr=Ce([F(0,et)],Nr);function ue(e,t){if(e!==void 0)try{return Se.toColor(e)}catch{}return t}var pu=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},gu=class{constructor(){this._services=new pu,this._services.set(Vr,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=ch(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},vu={trace:0,debug:1,info:2,warn:3,error:4,off:5},Su="xterm.js: ",Or=class extends ie{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=vu[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":Su)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Or=Ce([F(0,et)],Or);var uo=class extends ie{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new D),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new D),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new D),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},te=3,Ee=Object.freeze(new $i),es=0,Gs=2,Li=class qa{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*te);let r=i||ut.fromCharData([0,ua,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*te+0],s=i&2097151;return[this._data[t*te+1],i&2097152?this._combined[t]:s?Ht(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*te+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*te+0]=t|2097152|i[2]<<22):this._data[t*te+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*te+0]>>22}hasWidth(t){return this._data[t*te+0]&12582912}getFg(t){return this._data[t*te+1]}getBg(t){return this._data[t*te+2]}hasContent(t){return this._data[t*te+0]&4194303}getCodePoint(t){let i=this._data[t*te+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*te+0]&2097152}getString(t){let i=this._data[t*te+0];return i&2097152?this._combined[t]:i&2097151?Ht(i&2097151):""}isProtected(t){return this._data[t*te+2]&536870912}loadCell(t,i){return es=t*te,i.content=this._data[es+0],i.fg=this._data[es+1],i.bg=this._data[es+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*te+0]=i.content,this._data[t*te+1]=i.fg,this._data[t*te+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*te+0]=i|s<<22,this._data[t*te+1]=r.fg,this._data[t*te+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*te+0];r&2097152?this._combined[t]+=Ht(i):r&2097151?(this._combined[t]=Ht(r&2097151)+Ht(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*te+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new ut;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new ut;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Gs<this._data.buffer.byteLength;let s=t*te;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*Gs<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Gs<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new qa(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*te+0]&4194303)return t+(this._data[t*te+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*te+0]&4194303||this._data[t*te+2]&50331648)return t+(this._data[t*te+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l<te;l++)this._data[(s+h)*te+l]=o[(i+h)*te+l];o[(i+h)*te+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let l=0;l<te;l++)this._data[(s+h)*te+l]=o[(i+h)*te+l];o[(i+h)*te+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let a=Object.keys(t._combined);for(let h=0;h<a.length;h++){let l=parseInt(a[h],10);l>=i&&(this._combined[l-i+s]=t._combined[l])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*te+0],a=o&2097151,h=o&2097152?this._combined[i]:a?Ht(a):zt;if(n+=h,r)for(let l=0;l<h.length;++l)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function bu(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let h=a,l=e.get(++h);if(!l.isWrapped)continue;let u=[e.get(a)];for(;h<e.length&&l.isWrapped;)u.push(l),l=e.get(++h);if(!n&&s>=a&&s<h){a+=u.length-1;continue}let d=0,_=Hi(u,d,t),m=1,f=0;for(;m<u.length;){let k=Hi(u,m,t),L=k-f,U=i-_,$=Math.min(L,U);u[d].copyCellsFrom(u[m],f,_,$,!1),_+=$,_===i&&(d++,_=0),f+=$,f===k&&(m++,f=0),_===0&&d!==0&&u[d-1].getWidth(i-1)===2&&(u[d].copyCellsFrom(u[d-1],i-1,_++,1,!1),u[d-1].setCell(i-1,r))}u[d].replaceCells(_,i,r);let g=0;for(let k=u.length-1;k>0&&(k>d||u[k].getTrimmedLength()===0);k--)g++;g>0&&(o.push(a+u.length-g),o.push(g)),a+=u.length-1}return o}function yu(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function wu(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Cu(e,t,i){let s=[],r=e.map((h,l)=>Hi(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let h=Hi(e,o,t);n>h&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let u=l?i-1:i;s.push(u),a+=u}return s}function Hi(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var Va=class Ya{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ya._nextId++,this._onDispose=this.register(new D),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Jt(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Va._nextId=1;var xu=Va,Me={},Yt=Me.B;Me[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Me.A={"#":"£"};Me.B=void 0;Me[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Me.C=Me[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Me.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Me.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Me.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Me.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Me.E=Me[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Me.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Me.H=Me[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Me["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var fo=4294967295,_o=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ee.clone(),this.savedCharset=Yt,this.markers=[],this._nullCell=ut.fromCharData([0,ua,1,0]),this._whitespaceCell=ut.fromCharData([0,zt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new bs,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new uo(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new ps),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new ps),this._whitespaceCell}getBlankLine(e,t){return new Li(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>fo?fo:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ee);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new uo(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Ee),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Li(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Li(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=bu(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ee),i);if(s.length>0){let r=yu(this.lines,s);wu(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Ee),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Li(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Ee),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!i){let $=this.ybase+this.y;if($>=o&&$<o+h.length)continue}let l=h[h.length-1].getTrimmedLength(),u=Cu(h,this._cols,e),d=u.length-h.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+d):_=Math.max(0,this.lines.length-this.lines.maxLength+d);let m=[];for(let $=0;$<d;$++){let N=this.getBlankLine(Ee,!0);m.push(N)}m.length>0&&(r.push({start:o+h.length+n,newLines:m}),n+=m.length),h.push(...m);let f=u.length-1,g=u[f];g===0&&(f--,g=u[f]);let k=h.length-d-1,L=l;for(;k>=0;){let $=Math.min(L,g);if(h[f]===void 0)break;if(h[f].copyCellsFrom(h[k],L-$,g-$,$,!0),g-=$,g===0&&(f--,g=u[f]),L-=$,L===0){k--;let N=Math.max(k,0);L=Hi(h,N,this._cols)}}for(let $=0;$<h.length;$++)u[$]<e&&h[$].setCell(u[$],s);let U=d-_;for(;U-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(r.length>0){let o=[],a=[];for(let g=0;g<this.lines.length;g++)a.push(this.lines.get(g));let h=this.lines.length,l=h-1,u=0,d=r[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let _=0;for(let g=Math.min(this.lines.maxLength-1,h+n-1);g>=0;g--)if(d&&d.start>l+_){for(let k=d.newLines.length-1;k>=0;k--)this.lines.set(g--,d.newLines[k]);g++,o.push({index:l+1,amount:d.newLines.length}),_+=d.newLines.length,d=r[++u]}else this.lines.set(g,a[l--]);let m=0;for(let g=o.length-1;g>=0;g--)o[g].index+=m,this.lines.onInsertEmitter.fire(o[g]),m+=o[g].amount;let f=Math.max(0,h+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new xu(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},ku=class extends ie{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new D),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new _o(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new _o(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Xa=2,Ga=1,Fr=class extends ie{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new D),this.onResize=this._onResize.event,this._onScroll=this._register(new D),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Xa),this.rows=Math.max(e.rawOptions.rows||0,Ga),this.buffers=this._register(new ku(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Fr=Ce([F(0,et)],Fr);var ui={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Ss,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Eu=["normal","bold","100","200","300","400","500","600","700","800","900"],Tu=class extends ie{constructor(e){super(),this._onOptionChange=this._register(new D),this.onOptionChange=this._onOptionChange.event;let t={...ui};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(me(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in ui))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in ui))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=ui[e]),!Ru(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ui[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Eu.includes(t)?t:ui[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function Ru(e){return e==="block"||e==="underline"||e==="bar"}function Pi(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Pi(e[s],t-1);return i}var mo=Object.freeze({insertMode:!1}),po=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Hr=class extends ie{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new D),this.onData=this._onData.event,this._onUserInput=this._register(new D),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new D),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new D),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Pi(mo),this.decPrivateModes=Pi(po)}reset(){this.modes=Pi(mo),this.decPrivateModes=Pi(po)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Hr=Ce([F(0,Qe),F(1,pa),F(2,et)],Hr);var go={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Zs(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Js=String.fromCharCode,vo={DEFAULT:e=>{let t=[Zs(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Js(t[0])}${Js(t[1])}${Js(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Zs(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Zs(e,!0)};${e.x};${e.y}${t}`}},zr=class extends ie{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new D),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(go))this.addProtocol(s,go[s]);for(let s of Object.keys(vo))this.addEncoding(s,vo[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};zr=Ce([F(0,Qe),F(1,ei),F(2,et)],zr);var Qs=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Bu=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Be;function Mu(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var Du=class{constructor(){if(this.version="6",!Be){Be=new Uint8Array(65536),Be.fill(1),Be[0]=0,Be.fill(0,1,32),Be.fill(0,127,160),Be.fill(2,4352,4448),Be[9001]=2,Be[9002]=2,Be.fill(2,11904,42192),Be[12351]=1,Be.fill(2,44032,55204),Be.fill(2,63744,64256),Be.fill(2,65040,65050),Be.fill(2,65072,65136),Be.fill(2,65280,65377),Be.fill(2,65504,65511);for(let e=0;e<Qs.length;++e)Be.fill(0,Qs[e][0],Qs[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Be[e]:Mu(e,Bu)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=Xt.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return Xt.createPropertyValue(0,i,s)}},Xt=class ms{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new D,this.onChange=this._onChange.event;let t=new Du;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=ms.extractWidth(a);ms.extractShouldJoin(a)&&(h-=ms.extractWidth(s)),i+=h,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Lu=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function So(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var Ei=2147483647,Pu=256,Za=class Wr{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>Pu)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Wr;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new Wr(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Ei?Ei:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Ei?Ei:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,Ei):t}},Ti=[],Au=class{constructor(){this._state=0,this._active=Ti,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ti}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Ti,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ti,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",Cs(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Ti,this._id=-1,this._state=0}}},nt=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Cs(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Ri=[],Iu=class{constructor(){this._handlers=Object.create(null),this._active=Ri,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ri}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Ri,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ri,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",Cs(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Ri,this._ident=0}},Ai=new Za;Ai.addParam(0);var bo=class{constructor(e){this._handler=e,this._data="",this._params=Ai,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ai,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Cs(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=Ai,this._data="",this._hitLimit=!1,i));return this._params=Ai,this._data="",this._hitLimit=!1,t}},Nu=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},ct=160,Ou=(function(){let e=new Nu(4095),t=Array.apply(null,Array(256)).map((a,h)=>h),i=(a,h)=>t.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ct,0,2,0),e.add(ct,8,5,8),e.add(ct,6,0,6),e.add(ct,11,0,11),e.add(ct,13,13,13),e})(),Fu=class extends ie{constructor(e=Ou){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Za,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(me(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Au),this._dcsParser=this._register(new Iu),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a<t;++a){switch(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:ct)],r>>4){case 2:for(let _=a+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<ct){this._printHandler(e,a,_),a=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<ct){this._printHandler(e,a,_),a=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<ct){this._printHandler(e,a,_),a=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<ct){this._printHandler(e,a,_),a=_-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],l=h?h.length-1:-1;for(;l>=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let u=this._escHandlers[this._collect<<8|s],d=u?u.length-1:-1;for(;d>=0&&(o=u[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,u,d,r,a),o;d<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let _=a+1;;++_)if(_>=t||(s=e[_])===24||s===26||s===27||s>127&&s<ct){this._dcsParser.put(e,a,_),a=_-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=a+1;;_++)if(_>=t||(s=e[_])<32||s>127&&s<ct){this._oscParser.put(e,a,_),a=_-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},Hu=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,zu=/^[\da-f]+$/;function yo(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Hu.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),zu.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function er(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function Wu(e,t=16){let[i,s,r]=e;return`rgb:${er(i,t)}/${er(s,t)}/${er(r,t)}`}var $u={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ft=131072,wo=10;function Co(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var xo=5e3,ko=0,ju=class extends ie{constructor(e,t,i,s,r,n,o,a,h=new Fu){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new lh,this._utf8Decoder=new hh,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ee.clone(),this._eraseAttrDataInternal=Ee.clone(),this._onRequestBell=this._register(new D),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new D),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new D),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new D),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new D),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new D),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new D),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new D),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new D),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new D),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new D),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new D),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new D),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new $r(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:u.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:u,data:d})}),this._parser.setDcsHandlerFallback((l,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:u,payload:d})}),this._parser.setPrintHandler((l,u,d)=>this.print(l,u,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(x.BEL,()=>this.bell()),this._parser.setExecuteHandler(x.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(x.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(x.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(x.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(x.BS,()=>this.backspace()),this._parser.setExecuteHandler(x.HT,()=>this.tab()),this._parser.setExecuteHandler(x.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(x.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(fs.IND,()=>this.index()),this._parser.setExecuteHandler(fs.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(fs.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new nt(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new nt(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new nt(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new nt(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new nt(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new nt(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new nt(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new nt(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new nt(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new nt(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new nt(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new nt(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in Me)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new bo((l,u)=>this.requestStatusString(l,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),xo))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${xo} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ft&&(n=this._parseStack.position+Ft)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ft&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ft))),o||this._dirtyRowTracker.clearRange(),e.length>Ft)for(let l=n;l<e.length;l+=Ft){let u=l+Ft<e.length?l+Ft:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(l,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,u),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,r,d,l),this._logSlowResolvingAsync(i),i}else if(!o){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,l))return this._preserveStack(s,r,l,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let _=this._parser.precedingJoinState;for(let m=t;m<i;++m){if(s=e[m],s<127&&n){let L=n[String.fromCharCode(s)];L&&(s=L.charCodeAt(0))}let f=this._unicodeService.charProperties(s,_);r=Xt.extractWidth(f);let g=Xt.extractShouldJoin(f),k=g?Xt.extractWidth(_):0;if(_=f,o&&this._onA11yChar.fire(Ht(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-k>a){if(h){let L=d,U=this._activeBuffer.x-k;for(this._activeBuffer.x=k,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),k>0&&d instanceof Li&&d.copyCellsFrom(L,U,0,k,!1);U<a;)L.setCellFromCodepoint(U++,0,1,u)}else if(this._activeBuffer.x=a-1,r===2)continue}if(g&&this._activeBuffer.x){let L=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-L,s,r);for(let U=r-k;--U>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-k,this._activeBuffer.getNullCell(u)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,s,r,u),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=_,this._activeBuffer.x<a&&i-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Co(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new bo(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new nt(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ee));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=Xt.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let l=0;l<n.length;){let u=n.codePointAt(l)||0;o[a++]=u,l+=u>65535?2:1}let h=a;for(let l=1;l<i;++l)o.copyWithin(h,0,a),h+=a;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(x.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(x.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(x.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(x.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(x.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Yt),this._charsetService.setgCharset(1,Yt),this._charsetService.setgCharset(2,Yt),this._charsetService.setgCharset(3,Yt);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:u}=a,d=this._optionsService.rawOptions,_=(g,k)=>(o.triggerDataEvent(`${x.ESC}[${t?"":"?"}${g};${k}$y`),!0),m=g=>g?1:2,f=e.params[0];return t?f===2?_(f,4):f===4?_(f,m(o.modes.insertMode)):f===12?_(f,3):f===20?_(f,m(d.convertEol)):_(f,0):f===1?_(f,m(s.applicationCursorKeys)):f===3?_(f,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):f===6?_(f,m(s.origin)):f===7?_(f,m(s.wraparound)):f===8?_(f,3):f===9?_(f,m(r==="X10")):f===12?_(f,m(d.cursorBlink)):f===25?_(f,m(!o.isCursorHidden)):f===45?_(f,m(s.reverseWraparound)):f===66?_(f,m(s.applicationKeypad)):f===67?_(f,4):f===1e3?_(f,m(r==="VT200")):f===1002?_(f,m(r==="DRAG")):f===1003?_(f,m(r==="ANY")):f===1004?_(f,m(s.sendFocus)):f===1005?_(f,4):f===1006?_(f,m(n==="SGR")):f===1015?_(f,4):f===1016?_(f,m(n==="SGR_PIXELS")):f===1048?_(f,1):f===47||f===1047||f===1049?_(f,m(l===u)):f===2004?_(f,m(s.bracketedPasteMode)):f===2026?_(f,m(s.synchronizedOutput)):_(f,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=$i.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ee.fg,e.bg=Ee.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Ee.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Ee.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Ee.fg&16777215,s.bg&=-67108864,s.bg|=Ee.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${x.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${x.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${x.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ee.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Co(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${x.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>wo&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>wo&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Eo(n))if(r==="?")t.push({type:0,index:n});else{let o=yo(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=yo(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Eo(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Yt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset($u[e[0]],Me[e[1]]||Yt),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ee.clone(),this._eraseAttrDataInternal=Ee.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new ut;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${x.ESC}${o}${x.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},$r=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(ko=e,e=t,t=ko),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};$r=Ce([F(0,Qe)],$r);function Eo(e){return 0<=e&&e<256}var Uu=5e7,To=12,Ku=50,qu=class extends ie{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new D),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Uu)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=To?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=To)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Ku&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},jr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};jr=Ce([F(0,Qe)],jr);var Ro=!1,Vu=class extends ie{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new fi),this._onBinary=this._register(new D),this.onBinary=this._onBinary.event,this._onData=this._register(new D),this.onData=this._onData.event,this._onLineFeed=this._register(new D),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new D),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new D),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new D),this._instantiationService=new gu,this.optionsService=this._register(new Tu(e)),this._instantiationService.setService(et,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Fr)),this._instantiationService.setService(Qe,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Or)),this._instantiationService.setService(pa,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Hr)),this._instantiationService.setService(ei,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(zr)),this._instantiationService.setService(ma,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Xt)),this._instantiationService.setService(fh,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Lu),this._instantiationService.setService(dh,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(jr),this._instantiationService.setService(ga,this._oscLinkService),this._inputHandler=this._register(new ju(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(je.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(je.forward(this._bufferService.onResize,this._onResize)),this._register(je.forward(this.coreService.onData,this._onData)),this._register(je.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new qu((t,i)=>this._inputHandler.parse(t,i))),this._register(je.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new D),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Ro&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ro=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Xa),t=Math.max(t,Ga),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(So.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(So(this._bufferService),!1))),this._windowsWrappingHeuristics.value=me(()=>{for(let t of e)t.dispose()})}}},Yu={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function Xu(e,t,i,s){var o;let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=x.ESC+"OA":r.key=x.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=x.ESC+"OD":r.key=x.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=x.ESC+"OC":r.key=x.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=x.ESC+"OB":r.key=x.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":x.DEL,e.altKey&&(r.key=x.ESC+r.key);break;case 9:if(e.shiftKey){r.key=x.ESC+"[Z";break}r.key=x.HT,r.cancel=!0;break;case 13:r.key=e.altKey?x.ESC+x.CR:x.CR,r.cancel=!0;break;case 27:r.key=x.ESC,e.altKey&&(r.key=x.ESC+x.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"D":t?r.key=x.ESC+"OD":r.key=x.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"C":t?r.key=x.ESC+"OC":r.key=x.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"A":t?r.key=x.ESC+"OA":r.key=x.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"B":t?r.key=x.ESC+"OB":r.key=x.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=x.ESC+"[2~");break;case 46:n?r.key=x.ESC+"[3;"+(n+1)+"~":r.key=x.ESC+"[3~";break;case 36:n?r.key=x.ESC+"[1;"+(n+1)+"H":t?r.key=x.ESC+"OH":r.key=x.ESC+"[H";break;case 35:n?r.key=x.ESC+"[1;"+(n+1)+"F":t?r.key=x.ESC+"OF":r.key=x.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=x.ESC+"[5;"+(n+1)+"~":r.key=x.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=x.ESC+"[6;"+(n+1)+"~":r.key=x.ESC+"[6~";break;case 112:n?r.key=x.ESC+"[1;"+(n+1)+"P":r.key=x.ESC+"OP";break;case 113:n?r.key=x.ESC+"[1;"+(n+1)+"Q":r.key=x.ESC+"OQ";break;case 114:n?r.key=x.ESC+"[1;"+(n+1)+"R":r.key=x.ESC+"OR";break;case 115:n?r.key=x.ESC+"[1;"+(n+1)+"S":r.key=x.ESC+"OS";break;case 116:n?r.key=x.ESC+"[15;"+(n+1)+"~":r.key=x.ESC+"[15~";break;case 117:n?r.key=x.ESC+"[17;"+(n+1)+"~":r.key=x.ESC+"[17~";break;case 118:n?r.key=x.ESC+"[18;"+(n+1)+"~":r.key=x.ESC+"[18~";break;case 119:n?r.key=x.ESC+"[19;"+(n+1)+"~":r.key=x.ESC+"[19~";break;case 120:n?r.key=x.ESC+"[20;"+(n+1)+"~":r.key=x.ESC+"[20~";break;case 121:n?r.key=x.ESC+"[21;"+(n+1)+"~":r.key=x.ESC+"[21~";break;case 122:n?r.key=x.ESC+"[23;"+(n+1)+"~":r.key=x.ESC+"[23~";break;case 123:n?r.key=x.ESC+"[24;"+(n+1)+"~":r.key=x.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=x.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=x.DEL:e.keyCode===219?r.key=x.ESC:e.keyCode===220?r.key=x.FS:e.keyCode===221&&(r.key=x.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=Yu[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=x.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=x.ESC+l}else if(e.keyCode===32)r.key=x.ESC+(e.ctrlKey?x.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=x.ESC+h,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=x.US),e.key==="@"&&(r.key=x.NUL));break}return r}var xe=0,Gu=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new bs,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new bs,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(xe=this._search(t),xe===-1)||this._getKey(this._array[xe])!==t)return!1;do if(this._array[xe]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(xe),!0;while(++xe<this._array.length&&this._getKey(this._array[xe])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xe=this._search(e),!(xe<0||xe>=this._array.length)&&this._getKey(this._array[xe])===e))do yield this._array[xe];while(++xe<this._array.length&&this._getKey(this._array[xe])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xe=this._search(e),!(xe<0||xe>=this._array.length)&&this._getKey(this._array[xe])===e))do t(this._array[xe]);while(++xe<this._array.length&&this._getKey(this._array[xe])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},tr=0,Bo=0,Zu=class extends ie{constructor(){super(),this._decorations=new Gu(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new D),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new D),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(me(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Ju(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{tr=r.options.x??0,Bo=tr+(r.options.width??1),e>=tr&&e<Bo&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},Ju=class extends Wt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new D),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new D),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Se.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Se.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Qu=1e3,ed=class{constructor(e,t=Qu){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Mo=20,ys=class extends ie{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new ed(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
48
- `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Y(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(me(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Mo+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
49
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Mo+1&&(this._liveRegion.textContent+=hr.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var a;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let u=h instanceof Text?h.parentNode:h,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(u);if(!_)return console.warn("columns is null. Race condition?"),null;let m=l<_.length?_[l]:_.slice(-1)[0]+1;return m>=this._terminal.cols&&(++d,m=0),{row:d,column:m}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var r,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};ys=Ce([F(1,Vr),F(2,Mt),F(3,Dt)],ys);var Ur=class extends ie{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new D),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new D),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(me(()=>{var n;Jt(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Y(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Y(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Y(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Y(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var l,u;if(this._isMouseOut)return;let h=a==null?void 0:a.map(d=>({link:d}));(l=this._activeProviderReplies)==null||l.set(n,h),i=this._checkLinkProviderResult(n,e,i),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<e?0:o.link.range.start.x,h=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(a=>this._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&td(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Jt(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Ur=Ce([F(1,Yr),F(2,Dt),F(3,Qe),F(4,Sa)],Ur);function td(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var id=class extends Vu{constructor(e={}){super(e),this._linkifier=this._register(new fi),this.browser=Fa,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new fi),this._onCursorMove=this._register(new D),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new D),this.onKey=this._onKey.event,this._onRender=this._register(new D),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new D),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new D),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new D),this.onBell=this._onBell.event,this._onFocus=this._register(new D),this._onBlur=this._register(new D),this._onA11yCharEmitter=this._register(new D),this._onA11yTabEmitter=this._register(new D),this._onWillOpen=this._register(new D),this._setup(),this._decorationService=this._instantiationService.createInstance(Zu),this._instantiationService.setService(ji,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Kc),this._instantiationService.setService(Sa,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ur)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(je.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(je.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(je.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(je.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(me(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=_e.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${x.ESC}]${s};${Wu(r)}${Na.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=Te.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=Te.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ys,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Y(this.element,"copy",t=>{this.hasSelection()&&oh(t,this._selectionService)}));let e=t=>ah(t,this.textarea,this.coreService,this.optionsService);this._register(Y(this.textarea,"paste",e)),this._register(Y(this.element,"paste",e)),Ha?this._register(Y(this.element,"mousedown",t=>{t.button===2&&Hn(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Y(this.element,"contextmenu",t=>{Hn(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),sn&&this._register(Y(this.element,"auxclick",t=>{t.button===1&&ca(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Y(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Y(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Y(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Y(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Y(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Y(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Y(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Y(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",lr.get()),$a||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(jc,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Mt,this._coreBrowserService),this._register(Y(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(Y(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Lr,this._document,this._helperContainer),this._instantiationService.setService(xs,this._charSizeService),this._themeService=this._instantiationService.createInstance(Nr),this._instantiationService.setService(_i,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(vs),this._instantiationService.setService(va,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Ar,this.rows,this.screenElement)),this._instantiationService.setService(Dt,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Br,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Pr),this._instantiationService.setService(Yr,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Ur,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Tr,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ir,this.element,this.screenElement,s)),this._instantiationService.setService(mh,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(je.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(Rr,this.screenElement)),this._register(Y(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(ys,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gs,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gs,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Dr,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var l,u,d,_,m;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let f=n.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(n,(_=(d=(u=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:_.height,(m=e._coreBrowserService)==null?void 0:m.dpr)===0)return!1;h=f<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Y(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(Y(t,"wheel",n=>{var o,a,h,l,u;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(n,!0);let d=x.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ha(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=Xu(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===x.ETX||i.key===x.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(sd(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ee));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(x.ESC+"[I"):this.coreService.triggerDataEvent(x.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${x.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${x.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function sd(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var rd=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},nd=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new ut)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Do=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new nd(t)}getNullCell(){return new ut}},od=class extends ie{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new D),this.onBufferChange=this._onBufferChange.event,this._normal=new Do(this._core.buffers.normal,"normal"),this._alternate=new Do(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},ad=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},ld=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},hd=["cols","rows"],gt=0,cd=class extends ie{constructor(e){super(),this._core=this._register(new id(e)),this._addonManager=this._register(new rd),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(hd.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new ad(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new ld(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new od(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
50
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return lr.get()},set promptLabel(e){lr.set(e)},get tooMuchOutput(){return hr.get()},set tooMuchOutput(e){hr.set(e)}}}_verifyIntegers(...e){for(gt of e)if(gt===1/0||isNaN(gt)||gt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(gt of e)if(gt&&(gt===1/0||isNaN(gt)||gt%1!==0||gt<0))throw new Error("This API only accepts positive integers")}};const Ja="codingns.user-app.terminal-page",ud=3,dd=20,fd=5,_d=400,md=200,pd=2e5,gd=12e4,vd=.7,Sd=2,ir={selectedWorkspaceId:null,activeTerminalIdByWorkspace:{},pinnedTerminalIdsByWorkspace:{},cursorByTerminalId:{},viewStateByTerminalId:{},zoomScale:null};function bd(){var t,i;const e=gi();return{selectedWorkspaceId:((t=e.selectedWorkspaceId)==null?void 0:t.value)??null,activeTerminalIdByWorkspace:is(e.activeTerminalIdByWorkspace),pinnedTerminalIdsByWorkspace:is(e.pinnedTerminalIdsByWorkspace),cursorByTerminalId:is(e.cursorByTerminalId),viewStateByTerminalId:is(e.viewStateByTerminalId),zoomScale:((i=e.zoomScale)==null?void 0:i.value)??null}}function yd(e){pi((t,i)=>({...t,selectedWorkspaceId:{value:e,updatedAt:i}}))}function wd(e){var t;return((t=gi().activeTerminalIdByWorkspace[e])==null?void 0:t.value)??null}function Cd(e,t){pi((i,s)=>{const r={...i,activeTerminalIdByWorkspace:{...i.activeTerminalIdByWorkspace}};return t?r.activeTerminalIdByWorkspace[e]={value:t,updatedAt:s}:delete r.activeTerminalIdByWorkspace[e],r})}function xd(e){var t;return((t=gi().pinnedTerminalIdsByWorkspace[e])==null?void 0:t.value)??[]}function Lo(e,t){pi((i,s)=>{const r={...i,pinnedTerminalIdsByWorkspace:{...i.pinnedTerminalIdsByWorkspace}},n=el(t);return n.length===0?(delete r.pinnedTerminalIdsByWorkspace[e],r):(r.pinnedTerminalIdsByWorkspace[e]={value:n,updatedAt:s},r)})}function kd(){var e;return((e=gi().zoomScale)==null?void 0:e.value)??null}function Ed(e){pi((t,i)=>({...t,zoomScale:{value:tl(e),updatedAt:i}}))}function Td(e,t){pi((i,s)=>{const r={...i,cursorByTerminalId:{...i.cursorByTerminalId}};return t?(r.cursorByTerminalId[e]=Qa(i.cursorByTerminalId[e],{value:t,updatedAt:s}),r):(delete r.cursorByTerminalId[e],r)})}function Kr(e){var r,n;const t=gi(),i=((r=t.viewStateByTerminalId[e])==null?void 0:r.value)??null,s=((n=t.cursorByTerminalId[e])==null?void 0:n.value)??null;return i?i.cursor&&s&&zi(s,i.cursor)?{resumeCursor:s,viewState:null}:{resumeCursor:i.cursor??s,viewState:i}:{resumeCursor:s,viewState:null}}function Rd(e,t){pi((i,s)=>{const r={...i,cursorByTerminalId:{...i.cursorByTerminalId},viewStateByTerminalId:{...i.viewStateByTerminalId}};return t?(r.viewStateByTerminalId[e]=Id(i.viewStateByTerminalId[e],{value:t,updatedAt:s}),t.cursor&&(r.cursorByTerminalId[e]=Qa(i.cursorByTerminalId[e],{value:t.cursor,updatedAt:s})),r):(delete r.viewStateByTerminalId[e],r)})}function pi(e){if(typeof window>"u")return;const t=gi(),i=Date.now(),s=e(t,i);window.localStorage.setItem(Ja,JSON.stringify({schemaVersion:ud,state:s}))}function gi(){if(typeof window>"u")return ir;try{const e=window.localStorage.getItem(Ja);if(!e)return ir;const t=JSON.parse(e),i=t&&typeof t=="object"&&"state"in t&&t.state&&typeof t.state=="object"?t.state:t;return{selectedWorkspaceId:Md(i.selectedWorkspaceId),activeTerminalIdByWorkspace:ts(i.activeTerminalIdByWorkspace,Po),pinnedTerminalIdsByWorkspace:ts(i.pinnedTerminalIdsByWorkspace,Ld),cursorByTerminalId:ts(i.cursorByTerminalId,Po),viewStateByTerminalId:ts(i.viewStateByTerminalId,Pd),zoomScale:Bd(i.zoomScale)}}catch{return ir}}function Bd(e){return e===null?null:rn(e,Ad)??null}function Md(e){return e===null?null:rn(e,Dd)??null}function ts(e,t){if(!e||typeof e!="object")return{};const i={};for(const[s,r]of Object.entries(e)){const n=rn(r,t);s&&n&&(i[s]=n)}return i}function rn(e,t){const i=t(e);if(i!==null)return{value:i,updatedAt:0};if(!e||typeof e!="object")return null;const s=e,r=t(s.value);return r===null?null:{value:r,updatedAt:Number.isFinite(s.updatedAt)?Number(s.updatedAt):0}}function Po(e){return typeof e=="string"&&e?e:null}function Dd(e){return e===null?null:typeof e=="string"?e:null}function Ld(e){return Array.isArray(e)?el(e.filter(i=>typeof i=="string")):null}function Pd(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.content!="string"||t.content.length===0||t.content.length>gd||t.cursor!==null&&t.cursor!==void 0&&typeof t.cursor!="string"||!Number.isInteger(t.cols)||!Number.isInteger(t.rows)||!Number.isInteger(t.viewportY)||t.historyBeforeSeq!==null&&t.historyBeforeSeq!==void 0&&!Number.isInteger(t.historyBeforeSeq)||t.historyHasOlder!==void 0&&typeof t.historyHasOlder!="boolean")return null;const i=t.cols,s=t.rows,r=t.viewportY;return i<dd||i>_d||s<fd||s>md||r<0||r>pd?null:{content:t.content,cursor:typeof t.cursor=="string"?t.cursor:null,cols:i,rows:s,viewportY:r,historyBeforeSeq:typeof t.historyBeforeSeq=="number"?t.historyBeforeSeq:null,historyHasOlder:typeof t.historyHasOlder=="boolean"?t.historyHasOlder:!0}}function Ad(e){return typeof e!="number"||!Number.isFinite(e)?null:tl(e)}function is(e){const t={};for(const[i,s]of Object.entries(e))t[i]=s.value;return t}function Qa(e,t){return!e||zi(t.value,e.value)?t:zi(e.value,t.value)?e:t.updatedAt>=e.updatedAt?t:e}function Id(e,t){if(!e)return t;const i=e.value.cursor,s=t.value.cursor;return s&&i&&zi(s,i)?t:s&&i&&zi(i,s)?e:t.value.content.length!==e.value.content.length?t.value.content.length>e.value.content.length?t:e:t.updatedAt>=e.updatedAt?t:e}function zi(e,t){const i=Number(e),s=Number(t);return!Number.isInteger(i)||!Number.isInteger(s)?!1:i>s}function el(e){return Array.from(new Set(e.map(t=>t.trim()).filter(Boolean)))}function tl(e){return Math.min(Sd,Math.max(vd,e))}function Nd({terminals:e,preferredTerminalId:t,currentActiveTerminalId:i,persistedTerminalId:s}){const r=sr(e,t),n=sr(e,i),o=sr(e,s),a=e.find(h=>h.status==="running")??null;return rr(r)??rr(n)??rr(o)??a??r??n??o??e[0]??null}function sr(e,t){return t?e.find(i=>i.id===t)??null:null}function rr(e){return!e||e.status!=="running"?null:e}const Od="codingns.terminal.debug",Fd=Hd();let Ao=0;function Zt(){return Fd}function Hd(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search).get("terminalDebug");if(e)return Io(e);try{const t=window.localStorage.getItem(Od);return t?Io(t):!1}catch{return!1}}function St(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function zd(e){return Ao+=1,`${e}-${Date.now().toString(36)}-${Ao.toString(36)}`}function Ni(e,t={}){Zt()&&console.info(`[terminal-debug][client] ${e}`,t)}function Io(e){const t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}const Wd=8,$d=1e4;class jd{constructor(t){tt(this,"socket",null);tt(this,"disposed",!1);tt(this,"authRecoveryInFlight",!1);tt(this,"manuallyDisconnected",!1);tt(this,"lastCursor");tt(this,"isSubscribed",!1);tt(this,"pendingInput","");tt(this,"inputFlushTimer",null);tt(this,"pendingInputQueuedAtMs",null);tt(this,"pendingResize",null);tt(this,"lastSentResizeKey",null);tt(this,"inputDebugTraces",new Map);tt(this,"connectionManager");this.options=t,this.lastCursor=t.lastCursor,this.connectionManager=new Bl({onReconnect:i=>{this.connect(i)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}updateCursor(t){this.lastCursor=t}sendInput(t){t&&(this.pendingInputQueuedAtMs===null&&(this.pendingInputQueuedAtMs=St()),this.pendingInput+=t,this.logDebug("input.queued",{charCount:t.length,pendingCharCount:this.pendingInput.length,preview:ss(t)}),this.canSendRealtimePayload()&&(this.pruneStaleInputDebugTraces(),this.scheduleInputFlush()))}sendCurrentDimensions(t,i){!Number.isInteger(t)||!Number.isInteger(i)||t<1||i<1||this.resize(t,i)}sendTerminalInput(t){const i=this.pendingInputQueuedAtMs??St(),s=St(),n=Zt()?zd(this.options.terminalId):void 0;n&&this.inputDebugTraces.set(n,{traceId:n,queuedAtMs:i,sentAtMs:s,ackedAtMs:null,charCount:t.length,preview:ss(t)}),this.logDebug("input.sent",{traceId:n??null,charCount:t.length,queuedForMs:s-i,preview:ss(t)}),this.sendMessage({type:"terminal.input",terminalId:this.options.terminalId,content:t,...n?{clientTraceId:n,clientSentAtMs:s}:{}}),this.pendingInputQueuedAtMs=null}resize(t,i){this.pendingResize={cols:t,rows:i},this.isSubscribed&&this.flushPendingResize()}disconnect(){this.manuallyDisconnected=!0,this.isSubscribed=!1,this.inputDebugTraces.clear();const t=this.socket;this.socket=null,t==null||t.close(),this.options.onConnectionChange("closed")}reconnectNow(){this.manuallyDisconnected=!1,this.connectionManager.reconnectNow()}close(){var t;this.disposed=!0,this.manuallyDisconnected=!0,this.connectionManager.close(),this.clearInputFlushTimer(),this.inputDebugTraces.clear(),(t=this.socket)==null||t.close(),this.socket=null,this.isSubscribed=!1}connect(t){var n;if(this.disposed||this.manuallyDisconnected)return;t&&this.socket&&(this.socket.close(),this.socket=null);const i=(n=Pn.getState().session)==null?void 0:n.accessToken;if(!i){this.options.onUnauthorized();return}const s=`${Tl("/ws")}?access_token=${encodeURIComponent(i)}`,r=new WebSocket(s);this.socket=r,r.addEventListener("open",()=>{this.isSubscribed=!1,r.send(JSON.stringify({type:"terminal.subscribe",terminalId:this.options.terminalId,lastCursor:this.lastCursor}))}),r.addEventListener("message",o=>{const a=JSON.parse(o.data);if(a.type==="system.connected"){this.connectionManager.markConnected();return}if(a.type==="terminal.subscribed"){this.isSubscribed=!0,this.options.onSubscribed(),this.flushPendingResize(),this.flushPendingInput(!0);return}if(a.type==="terminal.error"){if(a.error_code==="UNAUTHORIZED"){this.handleUnauthorized();return}this.options.onError(a);return}if(a.type!=="terminal.resize.accepted"){if(a.type==="terminal.input.accepted"){if(this.pruneStaleInputDebugTraces(),a.clientTraceId){const h=this.inputDebugTraces.get(a.clientTraceId);h&&(h.ackedAtMs=St(),this.logDebug("input.acknowledged",{traceId:h.traceId,charCount:h.charCount,sendToAckMs:h.ackedAtMs-h.sentAtMs,preview:h.preview}))}return}if(a.type==="terminal.backfill"){this.lastCursor=a.latestCursor??this.lastCursor,this.options.onBackfill(a);return}if(a.type==="terminal.output"){this.lastCursor=a.chunk.cursor,this.pruneStaleInputDebugTraces(),this.handleDebugOutput(a.chunk.content,a.chunk.cursor),this.options.onOutput(a);return}if(a.type==="terminal.status"){this.options.onStatus(a);return}a.type}}),r.addEventListener("close",()=>{this.disposed||this.socket!==r||(this.isSubscribed=!1,this.connectionManager.markDisconnected())}),r.addEventListener("error",()=>{this.disposed||this.socket!==r||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,this.isSubscribed=!1,t==null||t.close(),Pn.refresh().then(i=>{if(this.authRecoveryInFlight=!1,!(this.disposed||this.manuallyDisconnected)){if(i.status==="refreshed"){this.connectionManager.reconnectNow();return}if(i.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendMessage(t){!this.socket||this.socket.readyState!==WebSocket.OPEN||this.socket.send(JSON.stringify(t))}canSendRealtimePayload(){return!!(this.socket&&this.socket.readyState===WebSocket.OPEN&&this.isSubscribed)}flushPendingInput(t=!1){if(!this.pendingInput||!this.canSendRealtimePayload())return;t||this.clearInputFlushTimer();const i=this.pendingInput;this.pendingInput="",this.sendTerminalInput(i)}scheduleInputFlush(){this.inputFlushTimer===null&&(this.inputFlushTimer=window.setTimeout(()=>{this.inputFlushTimer=null,this.flushPendingInput(!0)},Wd))}clearInputFlushTimer(){this.inputFlushTimer!==null&&(window.clearTimeout(this.inputFlushTimer),this.inputFlushTimer=null)}flushPendingResize(){if(!this.pendingResize||!this.canSendRealtimePayload())return;const t=this.pendingResize,i=`${t.cols}x${t.rows}`;if(this.lastSentResizeKey===i){this.pendingResize=null;return}this.sendMessage({type:"terminal.resize",terminalId:this.options.terminalId,cols:t.cols,rows:t.rows}),this.lastSentResizeKey=i,this.pendingResize=null}handleDebugOutput(t,i){if(!Zt())return;const s=this.inputDebugTraces.values().next().value;if(!s)return;const r=St();this.inputDebugTraces.delete(s.traceId),this.logDebug("output.received_after_input",{traceId:s.traceId,cursor:i,charCount:t.length,sendToOutputMs:r-s.sentAtMs,ackToOutputMs:s.ackedAtMs===null?null:r-s.ackedAtMs,preview:ss(t)})}logDebug(t,i){Ni(`terminal.${t}`,{terminalId:this.options.terminalId,...i})}pruneStaleInputDebugTraces(){if(!Zt()||this.inputDebugTraces.size===0)return;const t=St();for(const[i,s]of this.inputDebugTraces.entries()){const r=t-s.sentAtMs;r<$d||(this.inputDebugTraces.delete(i),this.logDebug("input.trace_expired",{traceId:i,ageMs:r,charCount:s.charCount,preview:s.preview}))}}}function ss(e){return e.replace(/\r/g,"\\r").replace(/\n/g,"\\n").slice(0,60)}const Ud=250,Kd=/\u001b\[\?(?:\d+;)*\d+c|\u001b\[>(?:\d+;)*\d+c/g;function qd(e,t=window){let i=!1,s="",r=null,n=null,o=!1;const a=()=>{r!==null&&(t.clearTimeout(r),r=null)},h=()=>{n!==null&&(t.clearTimeout(n),n=null)},l=()=>{if(!i||r!==null||n!==null||s.length===0)return;const u=o?Vd(s):s;s="",o=!1,u&&e(u)};return{enqueue(u){if(u){if(i&&r===null&&n===null){e(u);return}s+=u}},suspend(){a(),h(),i=!1},resume(u=0){if(a(),h(),u<=0){i=!0,l();return}i=!1,o=!0,r=t.setTimeout(()=>{r=null,i=!0,n=t.setTimeout(()=>{n=null,l()},Ud)},u)},dispose(){a(),h(),i=!1,s="",o=!1}}}function Vd(e){return e.replace(Kd,"")}const Yd=120,Xd=120,Gd=30,Zd=14,Jd=160,Qd=12e4,ef=20,tf=5,sf=320,rf=120,nf=.8,of=1.6,No=.1,af=700,Oo=10,lf=300,hf=250,Fo=196,cf=6,nr=8,nn=72,on=48,uf=60*1e3,df=20,ff=6,_f=14,mf=2,Ho=.06,zo=.9,pf=.97,gf=3600,vf=3,Sf=.05,Wo=28,rs={primary:null,secondary:null},ns={primary:"closed",secondary:"closed"};function __({externalWindowMode:e=!1,externalWindowWorkspaceId:t=null,workbenchShellOverrides:i}={}){var Ln;const s=Il(),r=Ml(s),n=Rl(),o=Nl(),{workspaceId:a}=Ol(),h=Dl(),{navigationGroups:l,currentWorkspaceId:u,selectWorkspace:d,subscribeTerminalManagerSnapshot:_,requestTerminalManagerRefresh:m,addTerminalManagerSnapshotListener:f}={navigationGroups:(i==null?void 0:i.navigationGroups)??h.navigationGroups,currentWorkspaceId:(i==null?void 0:i.currentWorkspaceId)??h.currentWorkspaceId,selectWorkspace:(i==null?void 0:i.selectWorkspace)??h.selectWorkspace,subscribeTerminalManagerSnapshot:(i==null?void 0:i.subscribeTerminalManagerSnapshot)??h.subscribeTerminalManagerSnapshot,requestTerminalManagerRefresh:(i==null?void 0:i.requestTerminalManagerRefresh)??h.requestTerminalManagerRefresh,addTerminalManagerSnapshotListener:(i==null?void 0:i.addTerminalManagerSnapshotListener)??h.addTerminalManagerSnapshotListener},g=y.useRef(null),k=y.useRef(null),L=y.useRef(null),U=y.useRef(null),$=y.useRef({}),N=y.useRef(null),R=y.useRef(null),z=y.useRef(null),X=y.useRef(null),G=y.useRef(""),se=y.useRef([]),ne=y.useRef(0),Q=y.useRef({primary:null,secondary:null}),C=y.useRef(rs),S=y.useRef("primary"),B=y.useRef("single"),T=y.useMemo(()=>l.map(c=>c.workspace),[l]),P=(a==null?void 0:a.trim())||(t==null?void 0:t.trim())||null,[E,A]=y.useState(""),[J,ae]=y.useState(""),[oe,ke]=y.useState([]),[be,O]=y.useState(""),[I,Z]=y.useState(""),[q,le]=y.useState(!1),[De,j]=y.useState(!1),[V,pe]=y.useState(!1),[ee,Xe]=y.useState(!1),[ge,H]=y.useState([]),[W,Ue]=y.useState(!1),[Ke,ze]=y.useState(null),[he,fe]=y.useState(null),[qe,$t]=y.useState(!1),[vi,Rs]=y.useState(null),[hn,cn]=y.useState(!1),[ti,al]=y.useState("single"),[Ct,ll]=y.useState("primary"),[jt,un]=y.useState(rs),[qi,Lt]=y.useState(ns),[dn,Vi]=y.useState([]),[fn,ii]=y.useState([]),[Si,hl]=y.useState({}),[Ut,cl]=y.useState(()=>kd()??1),si=y.useMemo(()=>T.find(c=>c.id===u)??null,[u,T]),ri=y.useMemo(()=>T.find(c=>c.id===E)??si??null,[E,si,T]),_t=y.useMemo(()=>{var c;return(ri==null?void 0:ri.id)??(si==null?void 0:si.id)??P??E??((c=T[0])==null?void 0:c.id)??""},[ri,P,E,si,T]),ul=y.useMemo(()=>ri??T[0]??{id:"__terminal-mobile-workspace-placeholder__",name:b("terminal.mobileWorkspaceSwitcherPlaceholder"),path:b("home.emptyWorkspaces")},[ri,T]),{dismissToast:Bs,showToast:dt}=Fl(),Ge=y.useCallback((c,v="info")=>{},[]),_n=y.useCallback((c,v)=>{Q.current[c]=v},[]),mn=y.useCallback(()=>{o("/login",{replace:!0})},[o]),Ms=y.useCallback((c,v)=>{const w=L.current,M=v??$.current[c];if(!w||!M||!M.isConnected)return null;const K=w.getBoundingClientRect(),de=M.getBoundingClientRect(),re=Math.max(nr,K.width-Fo-nr),st=rl(de.right-K.left-Fo,nr,re),at=Math.max(0,de.bottom-K.top+cf);return{terminalId:c,top:at,left:st}},[]),pn=y.useCallback(c=>{const v=Ms(c);if(!v){fe(null);return}fe(w=>!w||w.terminalId!==c||w.top===v.top&&w.left===v.left?w:v)},[Ms]),bi=y.useMemo(()=>new Set(dn),[dn]),Ds=y.useMemo(()=>new Set(fn),[fn]),gn=y.useMemo(()=>Mf(ge,bi),[bi,ge]),vn=y.useMemo(()=>ra(s.ui.osFamily),[s.ui.osFamily]),ce=!s.isDesktop&&s.isMobile,dl=s.isDesktop&&s.bridge.supported&&!e&&!!_t,Pt=ce?"single":ti,ni=ce?"primary":Ct,xt=y.useMemo(()=>ce?{primary:jt[Ct]??jt.primary,secondary:null}:jt,[Ct,ce,jt]),Ls=y.useMemo(()=>ce?{primary:qi[Ct]??qi.primary,secondary:"closed"}:qi,[Ct,ce,qi]),kt=xt[ni],ot=y.useMemo(()=>ge.find(c=>c.id===kt)??null,[kt,ge]),Ps=y.useMemo(()=>he?ge.find(c=>c.id===he.terminalId)??null:null,[he,ge]),fl=Pt==="single"?["primary"]:["primary","secondary"],mt=y.useMemo(()=>Nf(oe,s.ui.osFamily),[s.ui.osFamily,oe]),_l=y.useMemo(()=>mt.find(c=>c.value===I)??mt[0]??null,[I,mt]),ml={"--terminal-mobile-list-width":ce&&q?"60vw":"0px"};y.useEffect(()=>{se.current=ge},[ge]),wf(k,N,ce,E||_t),y.useEffect(()=>{O(c=>os(oe,c)??"")},[oe]),y.useEffect(()=>{Z(c=>{var v,w;return mt.length?c&&mt.some(M=>M.value===c&&M.available)?c:((v=mt.find(M=>M.available))==null?void 0:v.value)??((w=mt[0])==null?void 0:w.value)??"":""})},[mt]);function At(c){const v=c(C.current);C.current=v,un(v)}function oi(c){S.current=c,ll(c)}function As(c){B.current=c,al(c)}const ai=y.useCallback((c,v,w={})=>{var de;if(G.current!==c)return;se.current=v,H(v),ii(re=>{const st=new Set(v.map(at=>at.id));return re.filter(at=>st.has(at))}),Vi(re=>{const st=new Set(v.map(hi=>hi.id)),at=re.filter(hi=>st.has(hi));return at.length!==re.length&&Lo(c,at),at});const M=wd(c),K=((de=Nd({terminals:v,preferredTerminalId:w.preferredTerminalId,currentActiveTerminalId:C.current[S.current]??C.current.primary,persistedTerminalId:M}))==null?void 0:de.id)??null;un(re=>{const st=ls({terminals:v,currentBindings:re,splitDirection:B.current,fallbackTerminalId:K,preferredPaneId:w.preferredPaneId??S.current});return C.current=st,st})},[]),It=y.useCallback(async(c,v={})=>{const w=ne.current+1;ne.current=w;try{const M=await zl(c);if(w!==ne.current||G.current!==c)return;ai(c,M.items,v)}catch(M){if(w!==ne.current||G.current!==c)return;const K=M instanceof Error?M.message:b("terminal.workspaceLoadFailed");Ge(K,"error")}},[ai,Ge]),Sn=y.useCallback(()=>E?It(E):Promise.resolve(),[It,E]);y.useEffect(()=>{G.current=E},[E]),y.useEffect(()=>{C.current=jt},[jt]),y.useEffect(()=>{S.current=Ct},[Ct]),y.useEffect(()=>{B.current=ti},[ti]),y.useEffect(()=>{if(!ce)return;const c=C.current[S.current]??C.current.primary,v=B.current!=="single",w=S.current!=="primary",M=C.current.secondary!==null||C.current.primary!==c;!v&&!w&&!M||(At(()=>({primary:c,secondary:null})),As("single"),oi("primary"),Lt(K=>K.secondary==="closed"?K:{...K,secondary:"closed"}))},[ce]),y.useEffect(()=>{var K,de;const c=bd().selectedWorkspaceId,v=P&&(T.length===0||T.some(re=>re.id===P))?P:null,w=u&&T.some(re=>re.id===u)?u:null,M=v??w??P??null??((K=T.find(re=>re.id===c))==null?void 0:K.id)??((de=T[0])==null?void 0:de.id)??"";A(re=>v||(re&&T.some(st=>st.id===re)?re:M))},[P,u,T]),y.useEffect(()=>{yd(E||null)},[E]),y.useEffect(()=>{if(!E){Vi([]);return}Vi(xd(E))},[E]),y.useEffect(()=>{if(kt||ge.length===0)return;const c=ol(ge);c&&wi(c,"primary")},[kt,ge]),y.useEffect(()=>{Ed(Ut)},[Ut]),y.useEffect(()=>{fe(null)},[Ct,jt,E]),y.useEffect(()=>{ce&&le(!1)},[kt,ce,E]),y.useEffect(()=>{he&&!ge.some(c=>c.id===he.terminalId)&&fe(null)},[he,ge]),y.useEffect(()=>{if(E)return f(c=>{c.workspaceId===E&&(Ll(Qo(E),{revision:c.revision??null,terminals:c.terminals,templates:c.templates,templateStatuses:c.templateStatuses,shellOptions:c.shellOptions}),ke(c.shellOptions??[]),ai(c.workspaceId,c.terminals))})},[f,ai,E]),y.useEffect(()=>{if(!he)return;const c=U.current,v=()=>{pn(he.terminalId)},w=window.requestAnimationFrame(v);return window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),c==null||c.addEventListener("scroll",v,{passive:!0}),()=>{window.cancelAnimationFrame(w),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),c==null||c.removeEventListener("scroll",v)}},[he,pn]),y.useEffect(()=>{if(!he&&!qe)return;function c(w){var re,st,at,hi;const M=w.target,K=(((re=g.current)==null?void 0:re.contains(M))??!1)||!!he&&(((st=$.current[he.terminalId])==null?void 0:st.contains(M))??!1),de=(((at=R.current)==null?void 0:at.contains(M))??!1)||(((hi=z.current)==null?void 0:hi.contains(M))??!1);he&&!K&&fe(null),qe&&!de&&$t(!1)}function v(w){w.key==="Escape"&&(fe(null),$t(!1))}return window.addEventListener("mousedown",c),window.addEventListener("keydown",v),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",v)}},[he,qe]),y.useEffect(()=>{if(!E){ke([]),O(""),le(!1),j(!1),se.current=[],H([]),At(()=>rs),oi("primary"),Lt(ns),ze(null);return}oi("primary"),Lt(ns),ze(null);const c=Pl(Qo(E),uf);if(c?(ke(Df(c.shellOptions)),ai(E,c.terminals)):(ke([]),se.current=[],H([]),At(()=>rs),oi("primary"),Lt(ns),ze(null)),_(E,{knownRevision:(c==null?void 0:c.revision)??null}),c){const v=window.setTimeout(()=>{m(E,{knownRevision:c.revision??null})},1500);return()=>{window.clearTimeout(v)}}m(E,{knownRevision:null}),e&&(It(E),oe.length===0&&An().then(v=>{ke(v.items??[])}).catch(()=>{}))},[ai,e,m,It,E,oe.length,_]),y.useEffect(()=>{E&&Cd(E,kt??null)},[kt,E]);const bn=y.useCallback((c,v)=>{Lt(w=>({...w,[c]:v}))},[]),yn=y.useCallback(c=>{c.status!=="running"&&ii(v=>v.filter(w=>w!==c.id)),H(v=>{const w=v.map(M=>M.id===c.id?{...M,status:c.status,statusDetail:c.statusDetail,processId:c.processId??M.processId??null}:M);return se.current=w,w})},[]);function yi(c,v){hl(w=>{if(v===null){if(!(c in w))return w;const M={...w};return delete M[c],M}return w[c]===v?w:{...w,[c]:v}})}function Is(c,v){dt({id:or(c),title:v==="closing"?b("terminal.closing"):b("terminal.deleting"),description:v==="closing"?b("terminal.closePendingDescription"):b("terminal.deletePendingDescription"),tone:"info",durationMs:null})}async function wn(c,v,w){for(let M=0;M<Oo;M+=1){if(G.current!==c)return"workspace_changed";await It(c);const K=se.current.find(re=>re.id===v)??null;if(w==="deleting"?K===null:K===null||K.status!=="running")return"settled";M<Oo-1&&await Vf()}return"timeout"}function Cn(c){oi(c)}function Ns(c){wi(c,S.current)}function wi(c,v){const w=ce?"primary":v,M=ce?"single":B.current;At(K=>{const de=M==="single"?{primary:c,secondary:null}:{...K,[w]:c};if(M!=="single"){const re=w==="primary"?"secondary":"primary";de[re]===c&&(de[re]=qr(ge,c))}return ls({terminals:ge,currentBindings:de,splitDirection:M,fallbackTerminalId:c,preferredPaneId:w})}),ii(K=>K.filter(de=>de!==c)),fe(null)}async function Os(c,v={}){try{return await jl(c)}catch(w){if(v.allowFallbackPrompt!==!1&&c.runtimeType!=="embedded-pty"&&ql(w))return Rs(c),null;throw w}}async function Yi(){if(oe.length>0||ee)return oe;Xe(!0);try{const v=(await An()).items??[];return ke(v),v}catch{return oe}finally{Xe(!1)}}async function xn(){!ce||!_t||W||(await Yi(),j(!0))}async function Fs(c,v,w={}){var M;Ue(!0),ze(v);try{const K=await Os(c);if(!K){li(v);return}Hs(K,v),li(v),(M=w.onCreated)==null||M.call(w),await It(c.workspaceId,{preferredTerminalId:K.id,preferredPaneId:v}),Ge(b("terminal.created"),"success")}catch(K){li(v),Ge(K instanceof Error?K.message:b("terminal.createFailed"),"error")}finally{Ue(!1)}}function li(c){ze(v=>v===c?null:v)}function Hs(c,v){const w=ce?"primary":v,M=ce?"single":B.current,K=Gf(se.current,c);se.current=K,H(K),At(de=>ls({terminals:K,currentBindings:{...de,[w]:c.id,...M==="single"?{primary:c.id,secondary:null}:{}},splitDirection:M,fallbackTerminalId:c.id,preferredPaneId:w})),Lt(de=>({...de,[w]:c.status==="running"?"reconnecting":"closed"})),ii(de=>de.filter(re=>re!==c.id))}async function pl(){const c=_t;if(!c||W)return;const v=ce?"primary":S.current,w=await Yi(),M=os(w.length>0?w:oe,be);await Fs({workspaceId:c,shell:M??void 0,runtimeType:J||void 0},v)}async function gl(){if(!_t||W)return;const v=await Yi(),w=v.length>0?v:oe,M=os(w,be);if(Lf(w,ce,s.ui.osFamily)){O(M??""),pe(!0);return}await pl()}async function vl(){const c=_t;if(!c||W)return;const v=oe.length>0?oe:await Yi(),w=os(v.length>0?v:oe,be);await Fs({workspaceId:c,shell:w??void 0,runtimeType:as(J,s.ui.osFamily)},S.current,{onCreated:()=>{pe(!1)}})}async function Sl(){const c=_t;if(!c||W)return;const v=_l;!v||!v.available||await Fs({workspaceId:c,shell:v.value,runtimeType:as(J,s.ui.osFamily)},"primary",{onCreated:()=>{j(!1),le(!1)}})}async function kn(c,v){return yi(v,"deleting"),Is(v,"deleting"),await Ul(v),wn(c,v,"deleting")}async function zs(c){if(!E||Si[c])return;const v=E,w=or(c);fe(null),yi(c,"closing"),Is(c,"closing"),(async()=>{try{await Wl(c);const M=await wn(v,c,"closing");if(M==="workspace_changed"){Bs(w);return}if(M==="timeout"){dt({id:w,title:b("terminal.closed"),description:b("terminal.closeSyncDelayed"),tone:"warning"});return}if(!se.current.some(de=>de.id===c)){dt({id:w,title:b("terminal.deleted"),tone:"success"});return}const K=await kn(v,c);if(K==="workspace_changed"){Bs(w);return}if(K==="timeout"){dt({id:w,title:b("terminal.deleted"),description:b("terminal.deleteSyncDelayed"),tone:"warning"});return}dt({id:w,title:b("terminal.deleted"),tone:"success"})}catch(M){dt({id:w,title:M instanceof Error?M.message:b("terminal.closeFailed"),tone:"error"})}finally{yi(c,null)}})()}async function En(c){if(!E||Si[c])return;const v=E,w=or(c);fe(null),yi(c,"deleting"),Is(c,"deleting"),(async()=>{try{const M=await kn(v,c);if(M==="workspace_changed"){Bs(w);return}if(M==="timeout"){dt({id:w,title:b("terminal.deleted"),description:b("terminal.deleteSyncDelayed"),tone:"warning"});return}dt({id:w,title:b("terminal.deleted"),tone:"success"})}catch(M){dt({id:w,title:M instanceof Error?M.message:b("terminal.deleteFailed"),tone:"error"})}finally{yi(c,null)}})()}async function Tn(c){if(!E)return;const v=ce?"primary":S.current;try{const w=await Os({workspaceId:E,cwd:c.cwd,shell:c.shell,runtimeType:c.runtimeType});if(!w)return;Hs(w,v),fe(null),await It(E,{preferredTerminalId:w.id,preferredPaneId:v}),Ge(b("terminal.duplicateSuccess"),"success")}catch(w){Ge(w instanceof Error?w.message:b("terminal.duplicateFailed"),"error")}}async function bl(){const c=vi;if(!c)return;const v=ce?"primary":S.current;cn(!0),ze(v);try{const w=await Os({...c,runtimeType:"embedded-pty"},{allowFallbackPrompt:!1});if(!w){li(v);return}Hs(w,v),ae("embedded-pty"),Rs(null),pe(!1),j(!1),li(v),await It(c.workspaceId,{preferredTerminalId:w.id,preferredPaneId:v}),Ge(b("terminal.created"),"success")}catch(w){li(v),Ge(w instanceof Error?w.message:b("terminal.createFailed"),"error")}finally{cn(!1)}}function Rn(c){E&&(Vi(v=>{const w=v.includes(c)?v.filter(M=>M!==c):[c,...v];return Lo(E,w),w}),fe(null))}function Bn(c){var w;const v=Wi(c,xt,Pt,ni);v&&((w=Q.current[v])==null||w.disconnect(),At(M=>({...M,[v]:null})),Lt(M=>({...M,[v]:"closed"})),ii(M=>M.includes(c)?M:[...M,c]),fe(null),Ge(b("terminal.disconnected"),"warning"))}function Mn(c){var w;const v=Wi(c,xt,Pt,ni);v&&(ii(M=>M.filter(K=>K!==c)),Lt(M=>({...M,[v]:"reconnecting"})),(w=Q.current[v])==null||w.reconnect(),fe(null),Ge(b("terminal.reconnectRequested")))}function Ws(c){cl(an(c))}function $s(c){if(!ce){if(c==="single"){At(v=>({primary:S.current==="secondary"?v.secondary??v.primary:v.primary,secondary:null})),As("single"),oi("primary");return}As(c),At(v=>ls({terminals:ge,currentBindings:v,splitDirection:c,fallbackTerminalId:v[S.current]??v.primary,preferredPaneId:S.current}))}}async function yl(){if(ot)try{const c=zf({terminalId:ot.id,splitDirection:Pt,paneBindings:xt,paneApiById:Q.current});if(!c.trim()){Ge(b("terminal.logEmpty"),"warning");return}const v=new Date().toISOString().replace(/[:.]/g,"-"),M=`${Xf(ot.name||"terminal")}-${v}.log`;Yf(M,c),Ge(b("terminal.saveLogSuccess"),"success")}catch(c){Ge(c instanceof Error?c.message:b("terminal.saveLogFailed"),"error")}}function Dn(c){if(ce){if(c==="right"){n.trigger("gesture"),le(!0);return}n.trigger("gesture"),le(!1)}}function wl(c){if(!ce||q)return;const v=c.touches[0];v&&(X.current={x:v.clientX,y:v.clientY})}function Cl(c){if(!ce||q){X.current=null;return}const v=X.current,w=c.changedTouches[0];if(X.current=null,!v||!w)return;const M=w.clientX-v.x,K=w.clientY-v.y;Math.abs(M)<nn||Math.abs(K)>on||Math.abs(M)<=Math.abs(K)||M<0||Dn("right")}const xl=y.useCallback(async c=>{const v=await Al(s,{workspaceId:c,focusOwner:"terminal-page"});v.ok||dt({title:v.detail??b("terminal.openExternalFailed"),tone:"error"})},[s,dt]);return p.jsxs("main",{className:"terminal-layout mobile-page-fixed-root",children:[p.jsx(Kl,{open:vi!==null,busy:hn,onClose:()=>{hn||Rs(null)},onConfirmFallback:()=>{bl()}}),p.jsx("section",{ref:k,className:"terminal-shell","data-mobile":ce,"data-mobile-list-open":ce?q:void 0,style:ce?ml:void 0,children:ce?p.jsxs(p.Fragment,{children:[p.jsx(Hl,{containerRef:N,currentWorkspace:ul,workspaces:T,onSelectWorkspace:c=>{d(c),A(c)},trailing:p.jsx("button",{type:"button",className:"secondary-button mobile-tools-more-button","aria-label":b("terminal.mobileDrawerAction"),title:b("terminal.mobileDrawerAction"),"aria-expanded":q,onClick:()=>{le(c=>!c)},children:p.jsx(il,{})})}),p.jsx(bf,{open:q,terminals:gn,pinnedTerminalIds:bi,activeTerminalId:(ot==null?void 0:ot.id)??null,creatingTerminal:W,paneBindings:xt,splitDirection:Pt,activePaneId:ni,paneConnectionStates:Ls,terminalMutations:Si,manuallyDisconnectedTerminalIdSet:Ds,onClose:()=>{le(!1)},onCreateTerminal:()=>{le(!1),xn()},onSelectTerminal:c=>{wi(c,"primary"),le(!1)},onBindToActivePane:c=>{Ns(c),le(!1)},onBindToPane:wi,onDuplicate:Tn,onDisconnect:Bn,onReconnect:Mn,onCloseTerminal:zs,onDeleteTerminal:En,onTogglePin:Rn}),p.jsxs("div",{className:"terminal-stage-surface terminal-stage-surface-mobile",children:[p.jsx("div",{className:"terminal-mobile-edge-swipe-zone","aria-hidden":"true",onTouchStart:wl,onTouchEnd:Cl,onTouchCancel:()=>{X.current=null}}),p.jsx("div",{className:"terminal-stage-grid","data-layout":"single","data-mobile":"true",children:p.jsx(Uo,{paneId:"primary",paneLabel:b("terminal.panePrimary"),terminal:ot,pendingCreation:!ot&&Ke==="primary",zoomScale:Ut,active:!0,isMobileLayout:!0,onActivate:Cn,onSwipeGesture:Dn,onConnectionChange:bn,onTerminalStatus:yn,onRequireReload:Sn,onUnauthorized:mn,registerApi:_n,notifyTerminal:Ge,canCreateTerminal:!!_t,onRequestCreateTerminal:()=>{xn()},onRequestOpenTerminalDrawer:()=>{le(!0)}},`mobile-${(ot==null?void 0:ot.id)??"empty"}`)})]}),p.jsx(jo,{open:De,loading:ee,creating:W,shellChoices:mt,osFamily:s.ui.osFamily,selectedShell:I,runtimeType:as(J,s.ui.osFamily),title:b("terminal.mobileCreateSheetTitle"),shellLabel:b("terminal.mobileCreateShellLabel"),shellDescription:b("terminal.mobileCreateShellDescription"),runtimeLabel:b("terminal.mobileCreateRuntimeLabel"),runtimeDescription:b("terminal.mobileCreateRuntimeDescription"),confirmLabel:b("terminal.mobileCreateConfirm"),onClose:()=>{W||j(!1)},onSelectShell:Z,onSelectRuntime:c=>{ae(c)},onConfirm:()=>{Sl()}})]}):p.jsxs(p.Fragment,{children:[p.jsx("header",{className:"terminal-tabbar","data-window-drag-handle":"terminal-tabbar","data-tauri-drag-region":r,children:p.jsxs("div",{ref:L,className:"terminal-tabbar-main","data-tauri-drag-region":r,children:[p.jsxs("div",{ref:U,className:"terminal-tabbar-scroll",role:"tablist","aria-label":b("terminal.title"),"data-window-drag":"ignore",children:[gn.map(c=>{const v=c.id===kt,w=bi.has(c.id),M=(he==null?void 0:he.terminalId)===c.id,K=Si[c.id]??null,de=K?"creating":ln({terminal:c,paneBindings:xt,paneConnectionStates:Ls,manuallyDisconnectedTerminalIdSet:Ds});return p.jsxs("div",{className:"terminal-tab-shell","data-active":v,"data-assigned":qf(c.id,xt,Pt),children:[p.jsx("button",{className:"terminal-tab","data-active":v,type:"button",role:"tab","aria-selected":v,"aria-busy":K!==null,onClick:()=>{v||n.trigger("selection"),Ns(c.id)},onAuxClick:re=>{re.button!==1||K!==null||(re.preventDefault(),zs(c.id))},children:p.jsx("span",{className:"terminal-tab-name",children:p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"terminal-tab-status-dot","data-status":de,"aria-hidden":"true"}),w?p.jsx("span",{className:"terminal-tab-pin-indicator",children:"•"}):null,p.jsx("span",{className:"terminal-tab-name-text",children:c.name}),p.jsx("span",{className:"terminal-tab-runtime",title:In(c.runtimeType,s.ui.osFamily),children:ar(c.runtimeType,s.ui.osFamily)}),K?p.jsxs("span",{className:"terminal-tab-operation","data-operation":K,children:[p.jsx("span",{className:"terminal-tab-operation-spinner","aria-hidden":"true"}),K==="closing"?b("terminal.closePendingBadge"):b("terminal.deletePendingBadge")]}):null]})})}),p.jsx("button",{ref:re=>{$.current[c.id]=re},className:"terminal-tab-inline-action",type:"button","data-open":M,disabled:K!==null,"aria-haspopup":"menu","aria-label":b("terminal.moreActions"),"aria-expanded":M,onClick:re=>{if(re.stopPropagation(),M){fe(null);return}fe(Ms(c.id,re.currentTarget)??{terminalId:c.id,top:0,left:0})},children:"⋯"})]},c.id)}),Ke?p.jsx("div",{className:"terminal-tab-shell",role:"presentation","data-active":kt===null&&Ct===Ke,"data-assigned":"false","data-pending":"true",children:p.jsx("div",{className:"terminal-tab","aria-hidden":"true",children:p.jsxs("span",{className:"terminal-tab-name",children:[p.jsx("span",{className:"terminal-tab-status-dot","data-status":"creating","aria-hidden":"true"}),p.jsx("span",{className:"terminal-tab-name-text",children:b("terminal.creating")}),p.jsx("span",{className:"terminal-tab-runtime",title:In(J||void 0,s.ui.osFamily),children:ar(J||void 0,s.ui.osFamily)})]})})}):null,p.jsx("button",{className:"terminal-tab-control",type:"button","aria-label":b("terminal.createButton"),title:b("terminal.createButton"),disabled:!E||W,onClick:()=>{gl()},children:p.jsx("span",{className:"terminal-toolbar-icon","aria-hidden":"true",children:p.jsx("svg",{viewBox:"0 0 16 16",focusable:"false",children:p.jsx("path",{d:"M8 3.25a.75.75 0 0 1 .75.75v3.25H12a.75.75 0 0 1 0 1.5H8.75V12a.75.75 0 0 1-1.5 0V8.75H4A.75.75 0 0 1 4 7.25h3.25V4A.75.75 0 0 1 8 3.25Z"})})})})]}),p.jsx("div",{className:"terminal-tabbar-inline-actions",children:p.jsxs("div",{className:"terminal-toolbar-anchor","data-window-drag":"ignore",children:[p.jsx("div",{ref:R,className:"terminal-toolbar-inline","data-open":qe,"aria-hidden":!qe,"data-window-drag":"ignore",children:p.jsxs("div",{className:"terminal-toolbar-cluster",children:[dl?p.jsx("button",{type:"button",className:"terminal-toolbar-menu-action",onClick:()=>{_t&&($t(!1),xl(_t))},children:b("terminal.openExternalAction")}):null,p.jsxs("div",{className:"terminal-toolbar-section",children:[p.jsx("span",{className:"terminal-toolbar-label",children:b("terminal.runtimeField")}),p.jsx("select",{className:"terminal-runtime-select",value:J,"aria-label":b("terminal.runtimeField"),title:(Ln=vn.find(c=>c.value===J))==null?void 0:Ln.description,onChange:c=>{ae(c.target.value)},children:vn.map(c=>p.jsx("option",{value:c.value,children:c.label},c.value||"auto"))})]}),p.jsxs("div",{className:"terminal-toolbar-section",children:[p.jsx("span",{className:"terminal-toolbar-label",children:b("terminal.zoomLabel")}),p.jsxs("div",{className:"terminal-zoom-group","aria-label":b("terminal.zoomLabel"),children:[p.jsx("button",{type:"button",className:"terminal-zoom-button","aria-label":b("terminal.zoomOutAction"),onClick:()=>{Ws(Ut-No)},children:"-"}),p.jsx("button",{type:"button",className:"terminal-zoom-value","aria-label":b("terminal.zoomResetAction"),onClick:()=>{Ws(1)},children:Hf(Ut)}),p.jsx("button",{type:"button",className:"terminal-zoom-button","aria-label":b("terminal.zoomInAction"),onClick:()=>{Ws(Ut+No)},children:"+"})]})]}),p.jsxs("div",{className:"terminal-toolbar-section",children:[p.jsx("span",{className:"terminal-toolbar-label",children:b("terminal.layoutLabel")}),p.jsxs("div",{className:"terminal-layout-switcher",children:[p.jsx("button",{type:"button",className:"terminal-layout-button","data-active":ti==="single","aria-label":b("terminal.layoutSingleAction"),onClick:()=>{$s("single")},children:"1"}),p.jsx("button",{type:"button",className:"terminal-layout-button","data-active":ti==="vertical","aria-label":b("terminal.layoutVerticalAction"),onClick:()=>{$s("vertical")},children:"||"}),p.jsx("button",{type:"button",className:"terminal-layout-button","data-active":ti==="horizontal","aria-label":b("terminal.layoutHorizontalAction"),onClick:()=>{$s("horizontal")},children:"="})]})]}),p.jsx("button",{type:"button",className:"terminal-toolbar-save",disabled:!ot,onClick:()=>{yl()},children:b("terminal.saveLogAction")})]})}),p.jsx("button",{ref:z,type:"button",className:"terminal-toolbar-toggle terminal-toolbar-toggle-tool","data-open":qe,"aria-label":b("terminal.toolbarToggleAction"),"aria-expanded":qe,onClick:()=>{fe(null),$t(c=>!c)},children:p.jsx("span",{className:"terminal-toolbar-icon terminal-toolbar-icon-tool","aria-hidden":"true",children:p.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",focusable:"false",children:[p.jsx("path",{d:"M13.1 3.3a3.1 3.1 0 0 0-2.4 3.77L4.95 12.82a1.5 1.5 0 1 0 2.12 2.12l5.74-5.74a3.1 3.1 0 0 0 3.77-2.4l-1.76.5a1.06 1.06 0 0 1-1.04-.28l-1.3-1.3a1.06 1.06 0 0 1-.28-1.04l.9-1.38Z",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round"}),p.jsx("path",{d:"m5.85 11.92 2.22 2.22",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round"})]})})})]})}),he&&Ps?p.jsx(Cf,{ref:g,actionMenu:he,terminal:Ps,paneBindings:xt,splitDirection:Pt,activePaneId:ni,paneConnectionStates:Ls,pinnedTerminalIdSet:bi,manuallyDisconnectedTerminalIdSet:Ds,pendingMutation:Si[Ps.id]??null,onBindToActivePane:Ns,onBindToPane:wi,onDuplicate:Tn,onDisconnect:Bn,onReconnect:Mn,onClose:zs,onDelete:En,onTogglePin:Rn,onCloseMenu:()=>{fe(null)}}):null]})}),p.jsx("div",{className:"terminal-stage-surface",children:p.jsx("div",{className:"terminal-stage-grid","data-layout":Pt,"data-mobile":"false",children:fl.map(c=>{const v=xt[c],w=ge.find(M=>M.id===v)??null;return p.jsx(Uo,{paneId:c,paneLabel:c==="primary"?b("terminal.panePrimary"):b("terminal.paneSecondary"),terminal:w,pendingCreation:!w&&Ke===c,zoomScale:Ut,active:ni===c,onActivate:Cn,onConnectionChange:bn,onTerminalStatus:yn,onRequireReload:Sn,onUnauthorized:mn,registerApi:_n,notifyTerminal:Ge},`${c}-${(w==null?void 0:w.id)??"empty"}`)})})})]})}),p.jsx(jo,{open:V,loading:ee,creating:W,shellChoices:mt,osFamily:s.ui.osFamily,selectedShell:be,runtimeType:as(J,s.ui.osFamily),title:b("terminal.createDialogTitle"),shellLabel:b("terminal.mobileCreateShellLabel"),shellDescription:b("terminal.createDialogShellDescription"),runtimeLabel:b("terminal.mobileCreateRuntimeLabel"),runtimeDescription:b("terminal.createDialogRuntimeDescription"),confirmLabel:b("terminal.createDialogConfirm"),onClose:()=>{W||pe(!1)},onSelectShell:O,onSelectRuntime:c=>{ae(c)},onConfirm:()=>{vl()}})]})}function bf({open:e,terminals:t,pinnedTerminalIds:i,activeTerminalId:s,creatingTerminal:r,paneBindings:n,splitDirection:o,activePaneId:a,paneConnectionStates:h,terminalMutations:l,manuallyDisconnectedTerminalIdSet:u,onClose:d,onCreateTerminal:_,onSelectTerminal:m,onBindToActivePane:f,onBindToPane:g,onDuplicate:k,onDisconnect:L,onReconnect:U,onCloseTerminal:$,onDeleteTerminal:N,onTogglePin:R}){const z=y.useRef(null),[X,G]=y.useState(null),se=t.filter(C=>i.has(C.id)),ne=t.filter(C=>!i.has(C.id)),Q=t.find(C=>C.id===X)??null;return y.useEffect(()=>{e||G(null)},[e]),e?p.jsxs(p.Fragment,{children:[p.jsxs("section",{className:"terminal-mobile-list-rail surface-card","aria-label":b("terminal.mobileDrawerTitle"),onTouchStart:C=>{const S=C.touches[0];S&&(z.current={x:S.clientX,y:S.clientY})},onTouchEnd:C=>{const S=z.current,B=C.changedTouches[0];if(z.current=null,!S||!B)return;const T=B.clientX-S.x,P=B.clientY-S.y;Math.abs(T)<nn||Math.abs(P)>on||Math.abs(T)<=Math.abs(P)||T>=0||d()},onTouchCancel:()=>{z.current=null},children:[p.jsxs("div",{className:"terminal-mobile-list-heading",children:[p.jsx("strong",{children:b("terminal.mobileDrawerTitle")}),p.jsx("p",{children:b("terminal.mobileDrawerDescription")})]}),p.jsxs("div",{className:"terminal-mobile-list-body",children:[se.length>0?p.jsxs("section",{className:"terminal-mobile-list-group terminal-mobile-list-group-pinned",children:[p.jsxs("div",{className:"terminal-mobile-list-group-heading",children:[p.jsx("span",{children:b("terminal.mobilePinnedSectionTitle")}),p.jsx("span",{className:"workbench-section-counter",children:se.length})]}),p.jsx("div",{className:"terminal-mobile-session-list",children:se.map(C=>p.jsx($o,{terminal:C,active:C.id===s,pendingMutation:l[C.id]??null,onOpen:m,onOpenMenu:S=>{G(B=>B===S?null:S)}},C.id))})]}):null,p.jsxs("section",{className:"terminal-mobile-list-group terminal-mobile-list-group-workspace",children:[p.jsxs("div",{className:"terminal-mobile-list-group-heading",children:[p.jsx("span",{children:b("terminal.workspaceField")}),p.jsx("span",{className:"workbench-section-counter",children:ne.length})]}),ne.length>0?p.jsx("div",{className:"terminal-mobile-session-list",children:ne.map(C=>p.jsx($o,{terminal:C,active:C.id===s,pendingMutation:l[C.id]??null,onOpen:m,onOpenMenu:S=>{G(B=>B===S?null:S)}},C.id))}):p.jsx("div",{className:"workbench-session-empty",children:b("terminal.mobileDrawerEmptyDescription")})]})]}),p.jsx("div",{className:"terminal-mobile-list-footer",children:p.jsxs("button",{type:"button",className:"workbench-import-toggle terminal-mobile-list-create",disabled:r,onClick:_,children:[p.jsx("span",{className:"workbench-import-toggle-symbol",children:"+"}),p.jsx("span",{className:"workbench-import-toggle-label",children:b("terminal.createButton")})]})})]}),p.jsx(yf,{terminal:Q,pendingMutation:Q?l[Q.id]??null:null,paneBindings:n,splitDirection:o,activePaneId:a,paneConnectionStates:h,pinnedTerminalIdSet:i,manuallyDisconnectedTerminalIdSet:u,onClose:()=>{G(null)},onBindToActivePane:C=>{G(null),f(C)},onBindToPane:(C,S)=>{G(null),g(C,S)},onDuplicate:async C=>{G(null),await k(C)},onDisconnect:C=>{G(null),L(C)},onReconnect:C=>{G(null),U(C)},onCloseTerminal:async C=>{G(null),await $(C)},onDeleteTerminal:async C=>{G(null),await N(C)},onTogglePin:C=>{G(null),R(C)}})]}):null}function $o({terminal:e,active:t,pendingMutation:i,onOpen:s,onOpenMenu:r}){return p.jsxs("article",{className:"terminal-mobile-session-card","data-active":t,children:[p.jsxs("button",{type:"button",className:"terminal-mobile-session-primary","data-active":t?"true":"false",onClick:()=>{s(e.id)},children:[p.jsxs("div",{className:"terminal-mobile-session-title-row",children:[p.jsx("span",{className:Ff(e.status)}),p.jsx("span",{className:"terminal-mobile-session-title",title:e.name,children:e.name}),p.jsx("span",{className:"terminal-mobile-session-runtime-badge",children:ar(e.runtimeType)})]}),p.jsx("div",{className:"terminal-mobile-session-path",title:e.cwd,children:e.cwd}),i?p.jsxs("div",{className:"terminal-mobile-session-operation",children:[p.jsx("span",{className:"terminal-tab-operation-spinner","aria-hidden":"true"}),p.jsx("span",{children:i==="closing"?b("terminal.closePendingBadge"):b("terminal.deletePendingBadge")})]}):null]}),p.jsx("button",{type:"button",className:"terminal-mobile-session-action","aria-label":b("terminal.moreActions"),title:b("terminal.moreActions"),onClick:n=>{n.stopPropagation(),r(e.id)},children:p.jsx(il,{})})]})}function yf({terminal:e,pendingMutation:t,paneBindings:i,splitDirection:s,activePaneId:r,paneConnectionStates:n,pinnedTerminalIdSet:o,manuallyDisconnectedTerminalIdSet:a,onClose:h,onBindToActivePane:l,onBindToPane:u,onDuplicate:d,onDisconnect:_,onReconnect:m,onCloseTerminal:f,onDeleteTerminal:g,onTogglePin:k}){if(!e||typeof document>"u")return null;const L=o.has(e.id),U=Wi(e.id,i,s,r),$=U?n[U]:"closed",N=ln({terminal:e,paneBindings:i,paneConnectionStates:n,manuallyDisconnectedTerminalIdSet:a}),R=t===null&&e.status==="running"&&N!=="disconnected",z=t===null&&!R,X=t===null&&U!==null&&e.status==="running";return p.jsxs(sa,{open:!0,title:b("terminal.moreActions"),description:e.name,kind:"action",height:"auto",className:"terminal-mobile-action-sheet",cardClassName:"terminal-mobile-action-sheet-card",bodyClassName:"terminal-mobile-action-list",onClose:h,children:[s!=="single"?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.primary===e.id,onClick:()=>{u(e.id,"primary")},children:b("terminal.bindToPrimaryPaneAction")}),p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.secondary===e.id,onClick:()=>{u(e.id,"secondary")},children:b("terminal.bindToSecondaryPaneAction")})]}):p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.primary===e.id,onClick:()=>{l(e.id)},children:b("terminal.bindToPaneAction")}),p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{d(e)},children:b("terminal.duplicateAction")}),X?$==="connected"?p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{_(e.id)},children:b("terminal.disconnectAction")}):p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{m(e.id)},children:b("terminal.reconnectAction")}):null,R?p.jsx("button",{type:"button",className:"terminal-mobile-action-item",onClick:()=>{f(e.id)},children:b("terminal.closeButton")}):null,z?p.jsx("button",{type:"button",className:"terminal-mobile-action-item danger",onClick:()=>{g(e.id)},children:b("terminal.deleteAction")}):null,p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{k(e.id)},children:L?b("terminal.unpinAction"):b("terminal.pinAction")})]})}function wf(e,t,i,s){y.useEffect(()=>{const r=e.current,n=t.current;if(!i||!r){r&&r.style.removeProperty("--terminal-mobile-header-height");return}if(!n){r.style.removeProperty("--terminal-mobile-header-height");return}const o=r,a=n;function h(){!e.current||!a.isConnected||o.style.setProperty("--terminal-mobile-header-height",`${a.offsetHeight}px`)}h();const l=typeof ResizeObserver<"u"?new ResizeObserver(h):null;return l==null||l.observe(a),window.addEventListener("resize",h),()=>{l==null||l.disconnect(),window.removeEventListener("resize",h),r.style.removeProperty("--terminal-mobile-header-height")}},[i,t,s,e])}function jo({open:e,loading:t,creating:i,shellChoices:s,osFamily:r,selectedShell:n,runtimeType:o,title:a,shellLabel:h,shellDescription:l,runtimeLabel:u,runtimeDescription:d,confirmLabel:_,onClose:m,onSelectShell:f,onSelectRuntime:g,onConfirm:k}){if(!e||typeof document>"u")return null;const L=s.find(R=>R.value===n)??s[0]??null,U=ra(r).find(R=>R.value==="tmux")??null,$=[{value:"tmux",title:(U==null?void 0:U.label)??b("terminal.mobileRuntimePersistentTitle"),description:(U==null?void 0:U.description)??b("terminal.mobileRuntimePersistentDescription")},{value:"embedded-pty",title:b("terminal.mobileRuntimeSessionTitle"),description:b("terminal.mobileRuntimeSessionDescription")}],N=i||t||!L||!L.available;return p.jsxs(sa,{open:!0,title:a,kind:"form",height:"three-quarter",className:"terminal-mobile-create-sheet",cardClassName:"terminal-mobile-create-sheet-card",bodyClassName:"terminal-mobile-create-sheet-body",dismissible:!i,onClose:m,children:[p.jsxs("section",{className:"terminal-mobile-create-section",children:[p.jsxs("div",{className:"terminal-mobile-create-section-copy",children:[p.jsx("strong",{children:h}),p.jsx("p",{children:l})]}),t&&s.length===0?p.jsxs("div",{className:"terminal-mobile-create-loading",children:[p.jsx("span",{className:"terminal-pending-indicator","aria-hidden":"true"}),p.jsx("span",{children:b("terminal.mobileCreateLoadingShells")})]}):p.jsx("div",{className:"terminal-mobile-choice-grid",role:"list",children:s.map(R=>{const z=R.value===n;return p.jsxs("button",{type:"button",className:"terminal-mobile-choice-card","data-selected":z?"true":"false",disabled:!R.available||i,onClick:()=>{f(R.value)},children:[p.jsxs("span",{className:"terminal-mobile-choice-copy",children:[p.jsx("strong",{children:R.label}),p.jsx("span",{children:R.description})]}),!R.available&&R.unavailableReason?p.jsx("span",{className:"terminal-mobile-choice-badge terminal-mobile-choice-badge-muted",children:R.unavailableReason}):z?p.jsx("span",{className:"terminal-mobile-choice-badge",children:b("settings.enabled")}):null]},R.id)})})]}),p.jsxs("section",{className:"terminal-mobile-create-section",children:[p.jsxs("div",{className:"terminal-mobile-create-section-copy",children:[p.jsx("strong",{children:u}),p.jsx("p",{children:d})]}),p.jsx("div",{className:"terminal-mobile-choice-grid",role:"list",children:$.map(R=>{const z=R.value===o;return p.jsxs("button",{type:"button",className:"terminal-mobile-choice-card","data-selected":z?"true":"false",disabled:i,onClick:()=>{g(R.value)},children:[p.jsxs("span",{className:"terminal-mobile-choice-copy",children:[p.jsx("strong",{children:R.title}),p.jsx("span",{children:R.description})]}),z?p.jsx("span",{className:"terminal-mobile-choice-badge",children:b("settings.enabled")}):null]},R.value)})})]}),p.jsx("button",{type:"button",className:"terminal-mobile-primary-action terminal-mobile-create-confirm",disabled:N,onClick:k,children:i?b("terminal.creating"):_})]})}function il(){return p.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[p.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),p.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),p.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}const Cf=y.forwardRef(function({actionMenu:t,terminal:i,pendingMutation:s,paneBindings:r,splitDirection:n,activePaneId:o,paneConnectionStates:a,pinnedTerminalIdSet:h,manuallyDisconnectedTerminalIdSet:l,onBindToActivePane:u,onBindToPane:d,onDuplicate:_,onDisconnect:m,onReconnect:f,onClose:g,onDelete:k,onTogglePin:L,onCloseMenu:U},$){const N=h.has(i.id),R=Wi(i.id,r,n,o),z=R?a[R]:"closed",X=ln({terminal:i,paneBindings:r,paneConnectionStates:a,manuallyDisconnectedTerminalIdSet:l}),G=s===null&&i.status==="running"&&X!=="disconnected",se=s===null&&!G,ne=s===null&&R!==null&&i.status==="running",Q=n!=="single";return p.jsxs("div",{ref:$,className:"terminal-tab-menu",role:"menu",style:{top:`${t.top}px`,left:`${t.left}px`},onClick:C=>{C.stopPropagation()},children:[Q?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.primary===i.id,onClick:()=>{d(i.id,"primary")},children:b("terminal.bindToPrimaryPaneAction")}),p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.secondary===i.id,onClick:()=>{d(i.id,"secondary")},children:b("terminal.bindToSecondaryPaneAction")})]}):p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.primary===i.id,onClick:()=>{u(i.id)},children:b("terminal.bindToPaneAction")}),p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{U(),_(i)},children:b("terminal.duplicateAction")}),ne?p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"terminal-tab-menu-divider",role:"separator"}),z==="connected"?p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{m(i.id)},children:b("terminal.disconnectAction")}):p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{f(i.id)},children:b("terminal.reconnectAction")})]}):null,p.jsx("div",{className:"terminal-tab-menu-divider",role:"separator"}),G?p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",onClick:()=>{U(),g(i.id)},children:b("terminal.closeButton")}):null,se?p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",onClick:()=>{k(i.id)},children:b("terminal.deleteAction")}):null,p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{L(i.id)},children:N?b("terminal.unpinAction"):b("terminal.pinAction")})]})});function Uo({paneId:e,paneLabel:t,terminal:i,pendingCreation:s,zoomScale:r,active:n,isMobileLayout:o=!1,canCreateTerminal:a=!0,onActivate:h,onSwipeGesture:l,onConnectionChange:u,onTerminalStatus:d,onRequireReload:_,onUnauthorized:m,registerApi:f,notifyTerminal:g,onRequestCreateTerminal:k,onRequestOpenTerminalDrawer:L}){const U=y.useRef(null),$=y.useRef(null),N=y.useRef(null),R=y.useRef(null),z=y.useRef(null),X=y.useRef(null),G=y.useRef(null),se=y.useRef(!0),ne=y.useRef(!1),Q=y.useRef(null),C=y.useRef((i==null?void 0:i.status)??null),S=y.useRef(!1),B=y.useRef([]),T=y.useRef(n),P=!o,E=y.useCallback(O=>{var I;O&&((I=N.current)==null||I.sendInput(O))},[]),A=y.useCallback(O=>{const I=Number(O);!Number.isInteger(I)||I<=0||(X.current=X.current===null?I:Math.min(X.current,I),G.current=X.current)},[]),J=y.useCallback(async O=>{const I=R.current;if(!I)return;if(!O.content){se.current=O.hasMore,G.current=O.nextBeforeSeq;return}const Z=nl(I.readPlainText()),q=O.replaceContent?Math.max(0,O.lineCount-Z):O.anchorLine;await I.prependHistory(O.content,q,{replaceContent:O.replaceContent===!0}),X.current=O.nextBeforeSeq??X.current,G.current=O.nextBeforeSeq,se.current=O.hasMore,I.schedulePersist()},[]),ae=y.useCallback(()=>{const O=R.current;return O?O.terminal.buffer.active.baseY===0:!1},[]),oe=y.useCallback(async()=>{if(!(i!=null&&i.id)||ne.current||!se.current)return;const O=G.current;if(O!==null){ne.current=!0;try{let I=O,Z=ff;for(;I!==null&&Z>0;){const q=await $l(i.id,{beforeSeq:I,limit:df});if(await J(q),Z-=1,!q.hasMore||!ae())break;I=q.nextBeforeSeq}}catch(I){g(I instanceof Error?I.message:b("conversation.historyLoadFailed"),"error")}finally{ne.current=!1}}},[J,g,ae,i==null?void 0:i.id]);y.useEffect(()=>{C.current=(i==null?void 0:i.status)??null},[i==null?void 0:i.status]),y.useEffect(()=>{T.current=n},[n]),y.useEffect(()=>{var O;n&&((O=R.current)==null||O.focus())},[n,i==null?void 0:i.id]),y.useEffect(()=>{var O,I;(O=R.current)==null||O.setFontSize(Zo(r)),(I=R.current)==null||I.reflow()},[r]),y.useEffect(()=>{if(typeof document>"u")return;const O=()=>{var Z;(Z=R.current)==null||Z.applyTheme()};O();const I=new MutationObserver(Z=>{Z.some(q=>q.attributeName==="data-theme")&&O()});return I.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{I.disconnect()}},[i==null?void 0:i.id]),y.useEffect(()=>{var Z;if((Z=R.current)==null||Z.dispose(),R.current=null,f(e,null),!(i!=null&&i.id)||!U.current)return;const O=Kr(i.id).viewState,I=xf({container:U.current,restoredViewState:O,fontSize:Zo(r),enableTouchMomentum:o,getCursor:()=>z.current,getHistoryPaging:()=>({beforeSeq:G.current,hasOlder:se.current}),canResize:()=>C.current==="running",onInput:E,onResize:({cols:q,rows:le})=>{var De;(De=N.current)==null||De.resize(q,le)},onViewportTop:()=>{oe()},onCursorChange:q=>{Td(i.id,q)},onViewStateChange:q=>{Rd(i.id,q)}});return R.current=I,f(e,{focus:()=>{I.focus()},readPlainText:()=>I.readPlainText(),disconnect:()=>{var q;(q=N.current)==null||q.disconnect()},reconnect:()=>{var q;(q=N.current)==null||q.reconnectNow()}}),()=>{I.persistNow(),I.dispose(),R.current===I&&(R.current=null),f(e,null)}},[E,oe,e,f,i==null?void 0:i.id,r]),y.useEffect(()=>{var le,De;if((le=N.current)==null||le.close(),N.current=null,Q.current=null,(De=R.current)==null||De.suspendInputForwarding(),u(e,"closed"),!(i!=null&&i.id)){z.current=null,X.current=null,G.current=null,se.current=!0,ne.current=!1,S.current=!1,B.current=[];return}const O=Kr(i.id),I=O.viewState,Z=O.resumeCursor;z.current=Z,X.current=(I==null?void 0:I.historyBeforeSeq)??null,G.current=(I==null?void 0:I.historyBeforeSeq)??null,se.current=(I==null?void 0:I.historyHasOlder)===!1&&i.runtimeType==="tmux"?!0:(I==null?void 0:I.historyHasOlder)??!0,ne.current=!1,S.current=!1,B.current=[];const q=new jd({terminalId:i.id,lastCursor:Z,onConnectionChange:j=>{var V;j!=="connected"&&((V=R.current)==null||V.suspendInputForwarding()),u(e,j)},onSubscribed:()=>{var V;const j=R.current;j&&(j.suspendInputForwarding(),j.reflow(),q.sendCurrentDimensions(j.terminal.cols,j.terminal.rows),j.resumeInputForwarding(i.runtimeType==="tmux"?Yd:0)),T.current&&((V=R.current)==null||V.focus())},onBackfill:j=>{var ge,H;const V=R.current,pe=Ts(j.chunks),ee=V==null?void 0:V.shouldAutoRevealLatest();V&&(j.cursorReset?(Vo(V.terminal,pe),X.current=null):V.restoredFromSnapshot?qo(V.terminal,pe):(Vo(V.terminal,pe),X.current=null),ee&&V.revealLatest()),S.current=!0,pe.length>0&&A((ge=pe[0])==null?void 0:ge.cursor);const Xe=j.latestCursor??z.current;if(z.current=Xe,V==null||V.scheduleCursorPersist(Xe),V&&B.current.length>0){const W=Ef(B.current,j.latestCursor);if(B.current=[],W.length>0){qo(V.terminal,W);const Ue=((H=W.at(-1))==null?void 0:H.cursor)??Xe;z.current=Ue,V.scheduleCursorPersist(Ue)}}if(Q.current==="idle_closed"){g(b("terminal.recoveryIdleClosed"),"warning");return}if(Z){g(j.truncated?b("terminal.recoveryTruncated"):b("terminal.recoveryComplete"),j.truncated?"warning":"success");return}I!=null&&I.content||g(b("terminal.connectedHint"))},onOutput:j=>{const V=R.current,pe=!S.current,ee=V==null?void 0:V.shouldAutoRevealLatest();if(pe){B.current=[...B.current,j.chunk],z.current=j.chunk.cursor,V==null||V.scheduleCursorPersist(j.chunk.cursor);return}if(V&&Zt()){const Xe=St();V.terminal.write(j.chunk.content,()=>{Ni("terminal.output.rendered",{terminalId:i.id,cursor:j.chunk.cursor,charCount:j.chunk.content.length,renderMs:St()-Xe})})}else V==null||V.terminal.write(j.chunk.content);ee&&(V==null||V.revealLatest()),z.current=j.chunk.cursor,A(j.chunk.cursor),V==null||V.scheduleCursorPersist(j.chunk.cursor)},onStatus:j=>{if(d({id:j.terminal.id,status:j.terminal.status,statusDetail:j.terminal.statusDetail,processId:j.terminal.processId??null}),j.terminal.id===i.id){if(C.current=j.terminal.status,j.terminal.status!=="running"&&u(e,"closed"),j.terminal.status==="closed"&&j.terminal.statusDetail==="TERMINAL_IDLE_TIMEOUT"){Q.current="idle_closed",g(b("terminal.recoveryIdleClosed"),"warning");return}j.terminal.status==="error"&&j.terminal.statusDetail&&g(j.terminal.statusDetail,"error")}},onError:j=>{if(j.terminalId===i.id){if(j.error_code==="TERMINAL_NOT_RUNNING"){_();return}j.error_code!=="INVALID_TERMINAL_SIZE"&&g(j.detail,"error")}},onUnauthorized:m});return N.current=q,q.start(),()=>{q.close(),S.current=!1,B.current=[],u(e,"closed")}},[oe,g,u,_,d,m,e,i==null?void 0:i.id,i==null?void 0:i.runtimeType,A]);const ke=y.useCallback(O=>{var Z;if(!P||!n||!(i!=null&&i.id)||Pf(O))return;const I=Af(O.nativeEvent);I&&(O.preventDefault(),O.stopPropagation(),E(I),(Z=R.current)==null||Z.focus())},[n,E,i==null?void 0:i.id,P]),be=y.useCallback(O=>{var Z;if(!P||!n||!(i!=null&&i.id)||sl(O.target))return;const I=O.clipboardData.getData("text");I&&(O.preventDefault(),E(I),(Z=R.current)==null||Z.focus())},[n,E,i==null?void 0:i.id,P]);return p.jsx("article",{className:"terminal-pane-card","data-active":n,"data-empty":!i,tabIndex:i?0:-1,onMouseDown:O=>{h(e),O.currentTarget.focus({preventScroll:!0})},onClick:()=>{var O;(O=R.current)==null||O.focus()},onKeyDown:ke,onPaste:be,onTouchStart:O=>{if(!o)return;const I=O.touches[0];I&&($.current={x:I.clientX,y:I.clientY})},onTouchEnd:O=>{if(!o||!l){$.current=null;return}const I=$.current,Z=O.changedTouches[0];if($.current=null,!I||!Z)return;const q=Z.clientX-I.x,le=Z.clientY-I.y;Math.abs(q)<nn||Math.abs(le)>on||Math.abs(q)<=Math.abs(le)||l(q<0?"left":"right")},onTouchCancel:()=>{$.current=null},children:i?p.jsx("div",{className:"terminal-canvas",children:p.jsx("div",{ref:U,className:"terminal-xterm"})}):s?p.jsxs("div",{className:"terminal-empty-state terminal-empty-state-inline terminal-pending-state",children:[p.jsx("span",{className:"terminal-pane-label",children:t}),p.jsx("span",{className:"terminal-pending-indicator","aria-hidden":"true"}),p.jsx("h1",{children:b("terminal.creating")}),p.jsx("p",{children:b("terminal.creationPendingDescription")})]}):p.jsxs("div",{className:o?"terminal-empty-state terminal-empty-state-inline terminal-mobile-empty-state":"terminal-empty-state terminal-empty-state-inline",children:[p.jsx("span",{className:"terminal-pane-label",children:t}),p.jsx("h1",{children:o?b("terminal.mobileEmptyTitle"):b("terminal.stageEmptyTitle")}),p.jsx("p",{children:o?b("terminal.mobileEmptyDescription"):b("terminal.splitEmptySubtitle")}),o?p.jsxs("div",{className:"terminal-mobile-empty-actions",children:[p.jsx("button",{type:"button",className:"terminal-mobile-primary-action",disabled:!a,onClick:()=>{k==null||k()},children:b("terminal.createButton")}),p.jsx("button",{type:"button",className:"terminal-mobile-secondary-action",onClick:()=>{L==null||L()},children:b("terminal.mobileDrawerAction")})]}):null]})})}function xf(e){var ee,Xe,ge;const t=Go(),i=new cd({cols:((ee=e.restoredViewState)==null?void 0:ee.cols)??Xd,rows:((Xe=e.restoredViewState)==null?void 0:Xe.rows)??Gd,cursorBlink:!0,scrollback:2e3,allowTransparency:!1,fontFamily:'"Cascadia Mono", "Cascadia Code", "Consolas", monospace',fontSize:e.fontSize,theme:t}),s=new Xl,r=new eh,n=qd(H=>{e.onInput(H)});let o=null,a=null,h=null,l=!1,u=!1,d=!1,_=i.cols,m=i.rows,f=null,g=0,k=0,L=0,U=null,$=0,N=!1;const R=()=>{i.focus()};i.loadAddon(s),i.loadAddon(r),i.onData(H=>{n.enqueue(H)});const z=typeof i.onScroll=="function"?i.onScroll(H=>{var W;H===0&&((W=e.onViewportTop)==null||W.call(e)),q()}):null;i.onResize(({cols:H,rows:W})=>{_=H,m=W,e.canResize()&&e.onResize({cols:H,rows:W}),q()}),e.container.replaceChildren(),i.open(e.container),Xo(e.container,t);const X=e.container.querySelector(".xterm"),G=e.container.querySelector(".xterm-viewport"),se=G instanceof HTMLElement?G:X instanceof HTMLElement?X:e.container,ne=X instanceof HTMLElement?X:e.container;ne.addEventListener("mousedown",R,{passive:!0}),ne.addEventListener("pointerdown",R,{passive:!0}),se.style.touchAction="pan-y",se.style.overscrollBehavior="contain","webkitOverflowScrolling"in se.style&&(se.style.webkitOverflowScrolling="touch");const Q=H=>{var Ke;if(u||H.deltaY===0)return!1;const W=i.buffer.active.viewportY===0;return i.buffer.active.baseY>0?!0:(H.deltaY<0&&W&&((Ke=e.onViewportTop)==null||Ke.call(e)),!1)},C=()=>i.buffer.active.baseY>0||i.buffer.active.viewportY>0,S=()=>{U!==null&&(window.cancelAnimationFrame(U),U=null),$=0},B=H=>{var ze;if(u||H===0)return!1;const W=i.buffer.active.viewportY===0,Ue=i.buffer.active.viewportY;if(C()){i.scrollLines(H);const he=i.buffer.active.viewportY!==Ue;return q(),he}return H<0&&W&&((ze=e.onViewportTop)==null||ze.call(e)),!1},T=()=>{if(!e.enableTouchMomentum){k=0;return}if(S(),!N||!C()||Math.abs(k)<Ho){k=0;return}let H=performance.now(),W=0,Ue=0;const Ke=ze=>{if(u){S();return}const he=Math.max(1,ze-H);H=ze,W+=he,$+=k*he;const fe=Ko($);if(fe!==0){if(Ue=0,$-=fe,!B(fe)){k=0,S();return}}else Ue+=1;if(k*=Math.pow(pf,he/16),Ue>=vf||W>=gf||Math.abs(k)<Ho){k=0,S();return}U=window.requestAnimationFrame(Ke)};U=window.requestAnimationFrame(Ke)},P=H=>{const W=H.touches[0];if(S(),k=0,N=!1,L=performance.now(),!W){f=null;return}f={x:W.clientX,y:W.clientY}},E=H=>{if(!f)return;const W=H.touches[0];if(!W)return;const Ue=W.clientX-f.x,Ke=W.clientY-f.y;if(Math.abs(Ke)<=Math.abs(Ue)){f={x:W.clientX,y:W.clientY};return}H.preventDefault();const ze=performance.now(),he=Math.max(1,ze-L);L=ze;const fe=-Ke/_f;g+=fe;const qe=Ko(g);if(qe!==0){g-=qe;const $t=B(qe);if(e.enableTouchMomentum&&$t){const vi=rl(qe/he*mf,-zo,zo);k=k===0?vi:k*.35+vi*.65,N=!0}else $t||(k=0,N=!1)}f={x:W.clientX,y:W.clientY}},A=()=>{f=null,g=0,T()},J=()=>{f=null,g=0,k=0,N=!1,S()};typeof i.attachCustomWheelEventHandler=="function"&&i.attachCustomWheelEventHandler(Q),ne.addEventListener("touchstart",P,{passive:!0}),ne.addEventListener("touchmove",E,{passive:!1}),ne.addEventListener("touchend",A,{passive:!0}),ne.addEventListener("touchcancel",J,{passive:!0}),(ge=e.restoredViewState)!=null&&ge.content?i.write(e.restoredViewState.content,()=>{const H=e.restoredViewState;H&&H.viewportY>0&&i.scrollToLine(H.viewportY),be().then(()=>{le()})}):be().then(()=>{le()});const ae=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{window.requestAnimationFrame(()=>{le()})});ae==null||ae.observe(e.container),typeof document<"u"&&"fonts"in document&&document.fonts.ready.then(()=>{window.requestAnimationFrame(()=>{le()})});const oe=()=>{Ni("terminal.persist.pagehide",{cursor:e.getCursor()}),O()},ke=()=>{document.visibilityState==="hidden"&&(Ni("terminal.persist.visibility_hidden",{cursor:e.getCursor()}),O())};typeof window<"u"&&window.addEventListener("pagehide",oe),typeof document<"u"&&document.addEventListener("visibilitychange",ke);async function be(){for(let H=0;H<10;H+=1){if(Yo(e.container))return;await new Promise(W=>{window.requestAnimationFrame(()=>W())})}}function O(){if(u)return;const H=Zt()?St():0;o!==null&&(window.clearTimeout(o),o=null);const W=kf(i,r,e.getCursor(),e.getHistoryPaging());W?(a!==null&&(window.clearTimeout(a),a=null),l=!1):I(e.getCursor()),e.onViewStateChange(W),Zt()&&Ni("terminal.persist.completed",{cursor:e.getCursor(),hasViewState:!!W,contentLength:(W==null?void 0:W.content.length)??0,historyBeforeSeq:(W==null?void 0:W.historyBeforeSeq)??null,durationMs:St()-H})}function I(H){u||(a!==null&&(window.clearTimeout(a),a=null),H!==void 0&&(h=H,l=!0),l&&(e.onCursorChange(h),l=!1))}function Z(H){u||(h=H,l=!0,a!==null&&window.clearTimeout(a),a=window.setTimeout(()=>{I()},lf))}function q(){u||(o!==null&&window.clearTimeout(o),o=window.setTimeout(()=>{O()},hf))}function le(){if(u)return;const H=V();if(De(),!Yo(e.container))return;const W=s.proposeDimensions();!W||W.cols<ef||W.rows<tf||d&&W.cols===_&&W.rows===m||(s.fit(),d=!0,_=i.cols,m=i.rows,H&&j())}function De(){const H=Rf(e.container.clientHeight);e.container.style.setProperty("--terminal-bottom-gap",`${H}px`)}function j(){Bf(i)}function V(){return Tf(i)}function pe(){const H=Go();i.options.theme=H,Xo(e.container,H)}return{terminal:i,restoredFromSnapshot:!!e.restoredViewState,focus:()=>{i.focus()},reflow:()=>{le()},revealLatest:j,shouldAutoRevealLatest:V,prependHistory:async(H,W=nl(H),Ue={})=>{if(!H)return;const Ke=i.buffer.active.viewportY,ze=Jo(i),he=Ue.replaceContent?ws(H):jf(H,ze);await new Promise(fe=>{i.reset(),i.write(Uf(he),()=>{const qe=Math.max(0,Ke+Math.max(W,0));qe>0&&i.scrollToLine(qe),fe()})}),q()},readPlainText:()=>Jo(i),setFontSize:H=>{i.options.fontSize!==H&&(i.options.fontSize=H,le(),q())},applyTheme:pe,persistNow:O,scheduleCursorPersist:Z,schedulePersist:q,suspendInputForwarding:()=>{n.suspend()},resumeInputForwarding:(H=0)=>{n.resume(H)},dispose:()=>{u=!0,n.dispose(),o!==null&&window.clearTimeout(o),a!==null&&window.clearTimeout(a),ne.removeEventListener("mousedown",R),ne.removeEventListener("pointerdown",R),ne.removeEventListener("touchstart",P),ne.removeEventListener("touchmove",E),ne.removeEventListener("touchend",A),ne.removeEventListener("touchcancel",J),S(),z==null||z.dispose(),ae==null||ae.disconnect(),typeof window<"u"&&window.removeEventListener("pagehide",oe),typeof document<"u"&&document.removeEventListener("visibilitychange",ke),i.dispose(),e.container.replaceChildren()}}}function Ko(e){return e<0?Math.ceil(e):Math.floor(e)}function kf(e,t,i,s){const r=t.serialize({scrollback:Jd});return!r||r.length>Qd?null:{content:r,cursor:i,cols:e.cols,rows:e.rows,viewportY:e.buffer.active.viewportY,historyBeforeSeq:s.beforeSeq,historyHasOlder:s.hasOlder}}function qo(e,t){const i=Ts(t);i.length!==0&&e.write(i.map(s=>s.content).join(""))}function Vo(e,t){e.reset();const i=Ts(t);i.length!==0&&e.write(i.map(s=>s.content).join(""))}function Ts(e){if(e.length<2)return e;const t=e.map((i,s)=>({chunk:i,index:s,cursor:Number(i.cursor)}));return t.some(i=>!Number.isFinite(i.cursor))?e:[...t].sort((i,s)=>i.cursor===s.cursor?i.index-s.index:i.cursor-s.cursor).map(i=>i.chunk)}function Ef(e,t){const i=Ts(e);if(!t)return i;const s=Number(t);return Number.isFinite(s)?i.filter(r=>{const n=Number(r.cursor);return!Number.isFinite(n)||n>s}):i}function Tf(e,t=1){return e.buffer.active.baseY-e.buffer.active.viewportY<=t}function Rf(e){return!Number.isFinite(e)||e<=0?Wo:Math.max(Wo,Math.ceil(e*Sf))}function Bf(e){const t=e;if(typeof t.scrollToBottom=="function"){t.scrollToBottom();return}e.scrollToLine(e.buffer.active.baseY)}function Yo(e){return e.clientWidth>=sf&&e.clientHeight>=rf}function Xo(e,t){const i=t.background??"",s=t.foreground??"",r=t.cursor??s,n=t.cursorAccent??i,o=t.selectionBackground??"";e.style.background=i,e.style.setProperty("--terminal-theme-background",i),e.style.setProperty("--terminal-theme-foreground",s),e.style.setProperty("--terminal-theme-cursor",r),e.style.setProperty("--terminal-theme-cursor-accent",n),e.style.setProperty("--terminal-theme-selection",o)}function Go(){if(typeof window>"u")return{background:"#ffffff",foreground:"#1a1a1a",cursor:"#1a1a1a",cursorAccent:"#ffffff",selectionBackground:"rgba(0, 122, 255, 0.18)"};const e=window.getComputedStyle(document.documentElement),t=Bi(e,"--terminal-theme-background","#ffffff"),i=Bi(e,"--terminal-theme-foreground","#1a1a1a"),s=Bi(e,"--terminal-theme-cursor",i),r=Bi(e,"--terminal-theme-cursor-accent",t),n=Bi(e,"--terminal-theme-selection","rgba(0, 122, 255, 0.18)");return{background:t,foreground:i,cursor:s,cursorAccent:r,selectionBackground:n}}function Bi(e,t,i){return e.getPropertyValue(t).trim()||i}function Mf(e,t){return[...e].sort((i,s)=>{const r=t.has(i.id),n=t.has(s.id);return r!==n?r?-1:1:i.createdAt!==s.createdAt?i.createdAt.localeCompare(s.createdAt):i.name!==s.name?i.name.localeCompare(s.name,"zh-CN-u-kn-true"):i.id.localeCompare(s.id)})}function Df(e){return Array.isArray(e)?e.filter(t=>{if(!t||typeof t!="object")return!1;const i=t;return typeof i.id=="string"&&typeof i.label=="string"&&typeof i.shell=="string"&&typeof i.available=="boolean"}):[]}function os(e,t){var s;const i=t.trim();if(i){const r=e.find(n=>n.available&&n.shell===i);if(r)return r.shell}return((s=e.find(r=>r.available))==null?void 0:s.shell)??null}function as(e,t){return e||(t==="windows"?"embedded-pty":"tmux")}function Lf(e,t,i){return t||i!=="windows"?!1:e.filter(s=>s.available).length>1}function Pf(e){if(e.nativeEvent.isComposing||sl(e.target)||e.metaKey||e.altKey)return!0;const t=e.currentTarget;return t instanceof HTMLElement&&t.dataset.empty==="true"}function sl(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"?!0:e.isContentEditable}function Af(e){const t=e.key;if(!t||t==="Process"||t==="Dead"||t==="Unidentified")return null;if(e.ctrlKey)return If(t);if(t.length===1)return t;switch(t){case"Enter":return"\r";case"Backspace":return"";case"Tab":return" ";case"Escape":return"\x1B";case"ArrowUp":return"\x1B[A";case"ArrowDown":return"\x1B[B";case"ArrowRight":return"\x1B[C";case"ArrowLeft":return"\x1B[D";case"Home":return"\x1B[H";case"End":return"\x1B[F";case"Delete":return"\x1B[3~";case"Insert":return"\x1B[2~";case"PageUp":return"\x1B[5~";case"PageDown":return"\x1B[6~";default:return null}}function If(e){if(e.length===1){const t=e.toUpperCase();if(t>="A"&&t<="Z")return String.fromCharCode(t.charCodeAt(0)-64);switch(t){case"@":case" ":return"\0";case"[":return"\x1B";case"\\":return"";case"]":return"";case"^":return"";case"_":return"";default:return null}}switch(e){case"Enter":return`
51
- `;case"Backspace":return"\b";case"Tab":return" ";default:return null}}function Nf(e,t){return e.length>0?e.map(i=>({id:i.id,label:Of(i),value:i.shell,description:i.shell,available:i.available,unavailableReason:i.unavailableReason})):t==="windows"?[{id:"cmd",label:"CMD",value:"cmd",description:"经典命令行",available:!0,unavailableReason:null},{id:"powershell",label:"PowerShell",value:"powershell",description:"适合脚本与系统管理",available:!0,unavailableReason:null},{id:"git-bash",label:"Git Bash",value:"git-bash",description:"更接近 Unix 命令体验",available:!0,unavailableReason:null}]:[{id:t==="linux"?"bash":"zsh",label:t==="linux"?"bash":"zsh",value:t==="linux"?"bash":"zsh",description:t==="linux"?"常见 Linux Shell":"macOS 常见默认 Shell",available:!0,unavailableReason:null}]}function Of(e){if(e.id==="cmd")return"CMD";if(e.id==="powershell")return"PowerShell";if(e.id==="git-bash")return"Git Bash";if(e.id==="default"){const t=e.shell.split(/[\\/]/);return(t[t.length-1]??e.shell).replace(/\.exe$/i,"")||e.label}return e.label}function Ff(e){return e==="running"?"session-state-indicator is-running":e==="creating"?"session-state-indicator is-running-inferred":e==="error"?"session-state-indicator is-subagent-running":"session-state-indicator is-idle"}function an(e){return Math.min(of,Math.max(nf,e))}function rl(e,t,i){return Math.min(i,Math.max(t,e))}function Zo(e){return Math.round(Zd*an(e)*10)/10}function Hf(e){return`${Math.round(an(e)*100)}%`}function zf(e){var i;const t=Wi(e.terminalId,e.paneBindings,e.splitDirection,"primary");if(t){const s=((i=e.paneApiById[t])==null?void 0:i.readPlainText())??"";if(s.trim())return s}return Wf(e.terminalId)}function Wf(e){const t=Kr(e).viewState;return t?$f(t.content):""}function $f(e){return e.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g,"").replace(/\u001b\][^\u0007]*(?:\u0007|\u001b\\)/g,"").replace(/\u001bP[\s\S]*?\u001b\\/g,"").replace(/\r/g,"")}function Jo(e){const t=[];for(let i=0;i<e.buffer.active.length;i+=1){const s=e.buffer.active.getLine(i);s&&t.push(s.translateToString(!0))}return t.join(`
52
- `).trimEnd()}function jf(e,t){const i=ws(e),s=ws(t);return i?s?`${i}
53
- ${s}`:i:s}function ws(e){return e.replace(/\r/g,"").replace(/\n+$/g,"").trimEnd()}function Uf(e){return e.replace(/\r?\n/g,`\r
54
- `)}function nl(e){const t=ws(e);return t?t.split(`
55
- `).length:0}function ls(e){const t=new Set(e.terminals.map(r=>r.id));let i=e.currentBindings.primary&&t.has(e.currentBindings.primary)?e.currentBindings.primary:null,s=e.splitDirection!=="single"&&e.currentBindings.secondary&&t.has(e.currentBindings.secondary)?e.currentBindings.secondary:null;return e.fallbackTerminalId&&t.has(e.fallbackTerminalId)&&(e.preferredPaneId==="secondary"&&e.splitDirection!=="single"?(s=e.fallbackTerminalId,i=i??qr(e.terminals,s)??s):i=e.fallbackTerminalId),i=i??ol(e.terminals),e.splitDirection==="single"?{primary:i,secondary:null}:(s=s??qr(e.terminals,i),{primary:i,secondary:s})}function ln(e){if(e.terminal.status!=="running")return e.terminal.status;const t=Kf(e.terminal.id,e.paneBindings,e.paneConnectionStates);return t.includes("connected")?"running":t.includes("reconnecting")?"creating":t.length>0||e.manuallyDisconnectedTerminalIdSet.has(e.terminal.id)?"disconnected":"running"}function Kf(e,t,i){const s=[];return t.primary===e&&s.push(i.primary),t.secondary===e&&s.push(i.secondary),s}function ol(e){var t,i;return((t=e.find(s=>s.status==="running"))==null?void 0:t.id)??((i=e[0])==null?void 0:i.id)??null}function qr(e,t){var i;return((i=e.find(s=>s.id!==t))==null?void 0:i.id)??null}function qf(e,t,i){return t.primary===e?!0:i!=="single"&&t.secondary===e}function Wi(e,t,i,s){return t[s]===e?s:t.primary===e?"primary":i!=="single"&&t.secondary===e?"secondary":null}function or(e){return`terminal-mutation-${e}`}function Qo(e){return`terminal-manager.snapshot.${e}`}function Vf(){return new Promise(e=>{window.setTimeout(e,af)})}function Yf(e,t){if(typeof document>"u")throw new Error(b("terminal.saveLogFailed"));const i=new Blob([t],{type:"text/plain;charset=utf-8"}),s=window.URL.createObjectURL(i),r=document.createElement("a");r.href=s,r.download=e,document.body.append(r),r.click(),r.remove(),window.URL.revokeObjectURL(s)}function Xf(e){return e.trim().replace(/[\\/:*?"<>|]+/g,"-")||"terminal"}function Gf(e,t){const i=e.findIndex(r=>r.id===t.id);if(i===-1)return[...e,t];const s=[...e];return s[i]=t,s}export{__ as TerminalPage,Af as translateKeyboardEventToTerminalInput};
47
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),an&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=co(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=on(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-Qs),Qs),t/=Qs,t/Math.abs(t)+Math.round(t*(bu-1)))}shouldForceSelection(e){return xs?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),wu)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(xs&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<yu&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=du(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,u=0,d=0,_=0,m=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let k=e[0],D=e[0];n.getWidth(k)===0&&(u++,k--),n.getWidth(D)===2&&(d++,D++);let W=n.getString(D).length;for(W>1&&(m+=W-1,h+=W-1);k>0&&a>0&&!this._isCharWordSeparator(n.loadCell(k-1,this._workCell));){n.loadCell(k-1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,k--):U>1&&(_+=U-1,a-=U-1),a--,k--}for(;D<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(D+1,this._workCell));){n.loadCell(D+1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,D++):U>1&&(m+=U-1,h+=U-1),h++,D++}}h++;let f=a+l-u+_,v=Math.min(this._bufferService.cols,h-a+u+d-_-m);if(!(!t&&o.slice(a,h).trim()==="")){if(i&&f===0&&n.getCodePoint(0)!==32){let k=r.lines.get(e[1]-1);if(k&&n.isWrapped&&k.getCodePoint(this._bufferService.cols-1)!==32){let D=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(D){let W=this._bufferService.cols-D.start;f-=W,v+=W}}}if(s&&f+v===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let k=r.lines.get(e[1]+1);if(k!=null&&k.isWrapped&&k.getCodePoint(0)!==32){let D=this._getWordAt([0,e[1]+1],!1,!1,!0);D&&(v+=D.length)}}return{start:f,length:v}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=co(i,this._bufferService.cols)}};Hr=ye([z(3,Qe),z(4,ai),z(5,Jr),z(6,et),z(7,Ft),z(8,Ot)],Hr);var uo=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},fo=class{constructor(){this._color=new uo,this._css=new uo}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Me=Object.freeze((()=>{let e=[ve.toColor("#2e3436"),ve.toColor("#cc0000"),ve.toColor("#4e9a06"),ve.toColor("#c4a000"),ve.toColor("#3465a4"),ve.toColor("#75507b"),ve.toColor("#06989a"),ve.toColor("#d3d7cf"),ve.toColor("#555753"),ve.toColor("#ef2929"),ve.toColor("#8ae234"),ve.toColor("#fce94f"),ve.toColor("#729fcf"),ve.toColor("#ad7fa8"),ve.toColor("#34e2e2"),ve.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:Re.toCss(s,r,n),rgba:Re.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Re.toCss(s,s,s),rgba:Re.toRgba(s,s,s)})}return e})()),ei=ve.toColor("#ffffff"),Ii=ve.toColor("#000000"),_o=ve.toColor("#ffffff"),mo=Ii,Mi={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ku=ei,zr=class extends se{constructor(e){super(),this._optionsService=e,this._contrastCache=new fo,this._halfContrastCache=new fo,this._onChangeColors=this._register(new B),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ei,background:Ii,cursor:_o,cursorAccent:mo,selectionForeground:void 0,selectionBackgroundTransparent:Mi,selectionBackgroundOpaque:fe.blend(Ii,Mi),selectionInactiveBackgroundTransparent:Mi,selectionInactiveBackgroundOpaque:fe.blend(Ii,Mi),scrollbarSliderBackground:fe.opacity(ei,.2),scrollbarSliderHoverBackground:fe.opacity(ei,.4),scrollbarSliderActiveBackground:fe.opacity(ei,.5),overviewRulerBorder:ei,ansi:Me.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=le(e.foreground,ei),t.background=le(e.background,Ii),t.cursor=fe.blend(t.background,le(e.cursor,_o)),t.cursorAccent=fe.blend(t.background,le(e.cursorAccent,mo)),t.selectionBackgroundTransparent=le(e.selectionBackground,Mi),t.selectionBackgroundOpaque=fe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=le(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=fe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?le(e.selectionForeground,ao):void 0,t.selectionForeground===ao&&(t.selectionForeground=void 0),fe.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=fe.opacity(t.selectionBackgroundTransparent,.3)),fe.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=fe.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=le(e.scrollbarSliderBackground,fe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=le(e.scrollbarSliderHoverBackground,fe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=le(e.scrollbarSliderActiveBackground,fe.opacity(t.foreground,.5)),t.overviewRulerBorder=le(e.overviewRulerBorder,ku),t.ansi=Me.slice(),t.ansi[0]=le(e.black,Me[0]),t.ansi[1]=le(e.red,Me[1]),t.ansi[2]=le(e.green,Me[2]),t.ansi[3]=le(e.yellow,Me[3]),t.ansi[4]=le(e.blue,Me[4]),t.ansi[5]=le(e.magenta,Me[5]),t.ansi[6]=le(e.cyan,Me[6]),t.ansi[7]=le(e.white,Me[7]),t.ansi[8]=le(e.brightBlack,Me[8]),t.ansi[9]=le(e.brightRed,Me[9]),t.ansi[10]=le(e.brightGreen,Me[10]),t.ansi[11]=le(e.brightYellow,Me[11]),t.ansi[12]=le(e.brightBlue,Me[12]),t.ansi[13]=le(e.brightMagenta,Me[13]),t.ansi[14]=le(e.brightCyan,Me[14]),t.ansi[15]=le(e.brightWhite,Me[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=le(e.extendedAnsi[s],Me[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};zr=ye([z(0,et)],zr);function le(e,t){if(e!==void 0)try{return ve.toColor(e)}catch{}return t}var Eu=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Tu=class{constructor(){this._services=new Eu,this._services.set(Zr,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=bh(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},Ru={trace:0,debug:1,info:2,warn:3,error:4,off:5},Mu="xterm.js: ",Wr=class extends se{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Ru[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":Mu)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Wr=ye([z(0,et)],Wr);var po=class extends se{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new B),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new B),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new B),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ie=3,Te=Object.freeze(new qi),ns=0,er=2,Ni=class Za{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ie);let r=i||mt.fromCharData([0,pa,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*ie+0],s=i&2097151;return[this._data[t*ie+1],i&2097152?this._combined[t]:s?Vt(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*ie+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*ie+0]=t|2097152|i[2]<<22):this._data[t*ie+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*ie+0]>>22}hasWidth(t){return this._data[t*ie+0]&12582912}getFg(t){return this._data[t*ie+1]}getBg(t){return this._data[t*ie+2]}hasContent(t){return this._data[t*ie+0]&4194303}getCodePoint(t){let i=this._data[t*ie+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*ie+0]&2097152}getString(t){let i=this._data[t*ie+0];return i&2097152?this._combined[t]:i&2097151?Vt(i&2097151):""}isProtected(t){return this._data[t*ie+2]&536870912}loadCell(t,i){return ns=t*ie,i.content=this._data[ns+0],i.fg=this._data[ns+1],i.bg=this._data[ns+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*ie+0]=i.content,this._data[t*ie+1]=i.fg,this._data[t*ie+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*ie+0]=i|s<<22,this._data[t*ie+1]=r.fg,this._data[t*ie+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*ie+0];r&2097152?this._combined[t]+=Vt(i):r&2097151?(this._combined[t]=Vt(r&2097151)+Vt(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*ie+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new mt;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new mt;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*er<this._data.buffer.byteLength;let s=t*ie;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*er<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*er<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new Za(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ie+0]&4194303)return t+(this._data[t*ie+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ie+0]&4194303||this._data[t*ie+2]&50331648)return t+(this._data[t*ie+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l<ie;l++)this._data[(s+h)*ie+l]=o[(i+h)*ie+l];o[(i+h)*ie+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let l=0;l<ie;l++)this._data[(s+h)*ie+l]=o[(i+h)*ie+l];o[(i+h)*ie+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let a=Object.keys(t._combined);for(let h=0;h<a.length;h++){let l=parseInt(a[h],10);l>=i&&(this._combined[l-i+s]=t._combined[l])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*ie+0],a=o&2097151,h=o&2097152?this._combined[i]:a?Vt(a):Yt;if(n+=h,r)for(let l=0;l<h.length;++l)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function Bu(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let h=a,l=e.get(++h);if(!l.isWrapped)continue;let u=[e.get(a)];for(;h<e.length&&l.isWrapped;)u.push(l),l=e.get(++h);if(!n&&s>=a&&s<h){a+=u.length-1;continue}let d=0,_=ji(u,d,t),m=1,f=0;for(;m<u.length;){let k=ji(u,m,t),D=k-f,W=i-_,U=Math.min(D,W);u[d].copyCellsFrom(u[m],f,_,U,!1),_+=U,_===i&&(d++,_=0),f+=U,f===k&&(m++,f=0),_===0&&d!==0&&u[d-1].getWidth(i-1)===2&&(u[d].copyCellsFrom(u[d-1],i-1,_++,1,!1),u[d-1].setCell(i-1,r))}u[d].replaceCells(_,i,r);let v=0;for(let k=u.length-1;k>0&&(k>d||u[k].getTrimmedLength()===0);k--)v++;v>0&&(o.push(a+u.length-v),o.push(v)),a+=u.length-1}return o}function Du(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function Lu(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Pu(e,t,i){let s=[],r=e.map((h,l)=>ji(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let h=ji(e,o,t);n>h&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let u=l?i-1:i;s.push(u),a+=u}return s}function ji(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var Ja=class Qa{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Qa._nextId++,this._onDispose=this.register(new B),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ni(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Ja._nextId=1;var Au=Ja,De={},ti=De.B;De[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};De.A={"#":"£"};De.B=void 0;De[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};De.C=De[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};De.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};De.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};De.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};De.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};De.E=De[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};De.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};De.H=De[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};De["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var go=4294967295,vo=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Te.clone(),this.savedCharset=ti,this.markers=[],this._nullCell=mt.fromCharData([0,pa,1,0]),this._whitespaceCell=mt.fromCharData([0,Yt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ks,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new po(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new ws),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new ws),this._whitespaceCell}getBlankLine(e,t){return new Ni(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>go?go:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Te);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new po(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Te),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Ni(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Ni(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=Bu(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Te),i);if(s.length>0){let r=Du(this.lines,s);Lu(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Te),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Ni(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Te),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!i){let U=this.ybase+this.y;if(U>=o&&U<o+h.length)continue}let l=h[h.length-1].getTrimmedLength(),u=Pu(h,this._cols,e),d=u.length-h.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+d):_=Math.max(0,this.lines.length-this.lines.maxLength+d);let m=[];for(let U=0;U<d;U++){let N=this.getBlankLine(Te,!0);m.push(N)}m.length>0&&(r.push({start:o+h.length+n,newLines:m}),n+=m.length),h.push(...m);let f=u.length-1,v=u[f];v===0&&(f--,v=u[f]);let k=h.length-d-1,D=l;for(;k>=0;){let U=Math.min(D,v);if(h[f]===void 0)break;if(h[f].copyCellsFrom(h[k],D-U,v-U,U,!0),v-=U,v===0&&(f--,v=u[f]),D-=U,D===0){k--;let N=Math.max(k,0);D=ji(h,N,this._cols)}}for(let U=0;U<h.length;U++)u[U]<e&&h[U].setCell(u[U],s);let W=d-_;for(;W-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(r.length>0){let o=[],a=[];for(let v=0;v<this.lines.length;v++)a.push(this.lines.get(v));let h=this.lines.length,l=h-1,u=0,d=r[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let _=0;for(let v=Math.min(this.lines.maxLength-1,h+n-1);v>=0;v--)if(d&&d.start>l+_){for(let k=d.newLines.length-1;k>=0;k--)this.lines.set(v--,d.newLines[k]);v++,o.push({index:l+1,amount:d.newLines.length}),_+=d.newLines.length,d=r[++u]}else this.lines.set(v,a[l--]);let m=0;for(let v=o.length-1;v>=0;v--)o[v].index+=m,this.lines.onInsertEmitter.fire(o[v]),m+=o[v].amount;let f=Math.max(0,h+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new Au(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Iu=class extends se{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new B),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new vo(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new vo(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},el=2,tl=1,$r=class extends se{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new B),this.onResize=this._onResize.event,this._onScroll=this._register(new B),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,el),this.rows=Math.max(e.rawOptions.rows||0,tl),this.buffers=this._register(new Iu(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};$r=ye([z(0,et)],$r);var pi={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:xs,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Nu=["normal","bold","100","200","300","400","500","600","700","800","900"],Ou=class extends se{constructor(e){super(),this._onOptionChange=this._register(new B),this.onOptionChange=this._onOptionChange.event;let t={...pi};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(pe(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in pi))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in pi))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=pi[e]),!Fu(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=pi[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Nu.includes(t)?t:pi[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function Fu(e){return e==="block"||e==="underline"||e==="bar"}function Oi(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Oi(e[s],t-1);return i}var So=Object.freeze({insertMode:!1}),bo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),jr=class extends se{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new B),this.onData=this._onData.event,this._onUserInput=this._register(new B),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new B),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new B),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Oi(So),this.decPrivateModes=Oi(bo)}reset(){this.modes=Oi(So),this.decPrivateModes=Oi(bo)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};jr=ye([z(0,Qe),z(1,wa),z(2,et)],jr);var wo={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function tr(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var ir=String.fromCharCode,yo={DEFAULT:e=>{let t=[tr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${ir(t[0])}${ir(t[1])}${ir(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${tr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${tr(e,!0)};${e.x};${e.y}${t}`}},Ur=class extends se{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new B),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(wo))this.addProtocol(s,wo[s]);for(let s of Object.keys(yo))this.addEncoding(s,yo[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Ur=ye([z(0,Qe),z(1,ai),z(2,et)],Ur);var sr=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Hu=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Be;function zu(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var Wu=class{constructor(){if(this.version="6",!Be){Be=new Uint8Array(65536),Be.fill(1),Be[0]=0,Be.fill(0,1,32),Be.fill(0,127,160),Be.fill(2,4352,4448),Be[9001]=2,Be[9002]=2,Be.fill(2,11904,42192),Be[12351]=1,Be.fill(2,44032,55204),Be.fill(2,63744,64256),Be.fill(2,65040,65050),Be.fill(2,65072,65136),Be.fill(2,65280,65377),Be.fill(2,65504,65511);for(let e=0;e<sr.length;++e)Be.fill(0,sr[e][0],sr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Be[e]:zu(e,Hu)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=ii.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return ii.createPropertyValue(0,i,s)}},ii=class bs{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new B,this.onChange=this._onChange.event;let t=new Wu;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=bs.extractWidth(a);bs.extractShouldJoin(a)&&(h-=bs.extractWidth(s)),i+=h,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},$u=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Co(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var Bi=2147483647,ju=256,il=class Kr{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>ju)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Kr;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new Kr(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Bi?Bi:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Bi?Bi:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,Bi):t}},Di=[],Uu=class{constructor(){this._state=0,this._active=Di,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Di}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Di,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Di,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",Rs(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Di,this._id=-1,this._state=0}}},at=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Rs(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Li=[],Ku=class{constructor(){this._handlers=Object.create(null),this._active=Li,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Li}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Li,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Li,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",Rs(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Li,this._ident=0}},Fi=new il;Fi.addParam(0);var xo=class{constructor(e){this._handler=e,this._data="",this._params=Fi,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Fi,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Rs(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=Fi,this._data="",this._hitLimit=!1,i));return this._params=Fi,this._data="",this._hitLimit=!1,t}},qu=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},_t=160,Vu=(function(){let e=new qu(4095),t=Array.apply(null,Array(256)).map((a,h)=>h),i=(a,h)=>t.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(_t,0,2,0),e.add(_t,8,5,8),e.add(_t,6,0,6),e.add(_t,11,0,11),e.add(_t,13,13,13),e})(),Yu=class extends se{constructor(e=Vu){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new il,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(pe(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Uu),this._dcsParser=this._register(new Ku),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a<t;++a){switch(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:_t)],r>>4){case 2:for(let _=a+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<_t){this._printHandler(e,a,_),a=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<_t){this._printHandler(e,a,_),a=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<_t){this._printHandler(e,a,_),a=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<_t){this._printHandler(e,a,_),a=_-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],l=h?h.length-1:-1;for(;l>=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let u=this._escHandlers[this._collect<<8|s],d=u?u.length-1:-1;for(;d>=0&&(o=u[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,u,d,r,a),o;d<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let _=a+1;;++_)if(_>=t||(s=e[_])===24||s===26||s===27||s>127&&s<_t){this._dcsParser.put(e,a,_),a=_-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=a+1;;_++)if(_>=t||(s=e[_])<32||s>127&&s<_t){this._oscParser.put(e,a,_),a=_-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},Xu=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,Gu=/^[\da-f]+$/;function ko(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Xu.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Gu.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function rr(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function Zu(e,t=16){let[i,s,r]=e;return`rgb:${rr(i,t)}/${rr(s,t)}/${rr(r,t)}`}var Ju={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qt=131072,Eo=10;function To(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Ro=5e3,Mo=0,Qu=class extends se{constructor(e,t,i,s,r,n,o,a,h=new Yu){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new vh,this._utf8Decoder=new Sh,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Te.clone(),this._eraseAttrDataInternal=Te.clone(),this._onRequestBell=this._register(new B),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new B),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new B),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new B),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new B),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new B),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new B),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new B),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new B),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new B),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new B),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new B),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new B),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new qr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:u.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:u,data:d})}),this._parser.setDcsHandlerFallback((l,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:u,payload:d})}),this._parser.setPrintHandler((l,u,d)=>this.print(l,u,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(x.BEL,()=>this.bell()),this._parser.setExecuteHandler(x.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(x.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(x.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(x.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(x.BS,()=>this.backspace()),this._parser.setExecuteHandler(x.HT,()=>this.tab()),this._parser.setExecuteHandler(x.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(x.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(vs.IND,()=>this.index()),this._parser.setExecuteHandler(vs.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(vs.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new at(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new at(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new at(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new at(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new at(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new at(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new at(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new at(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new at(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new at(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new at(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new at(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in De)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new xo((l,u)=>this.requestStatusString(l,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Ro))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Ro} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>qt&&(n=this._parseStack.position+qt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<qt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,qt))),o||this._dirtyRowTracker.clearRange(),e.length>qt)for(let l=n;l<e.length;l+=qt){let u=l+qt<e.length?l+qt:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(l,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,u),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,r,d,l),this._logSlowResolvingAsync(i),i}else if(!o){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,l))return this._preserveStack(s,r,l,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let _=this._parser.precedingJoinState;for(let m=t;m<i;++m){if(s=e[m],s<127&&n){let D=n[String.fromCharCode(s)];D&&(s=D.charCodeAt(0))}let f=this._unicodeService.charProperties(s,_);r=ii.extractWidth(f);let v=ii.extractShouldJoin(f),k=v?ii.extractWidth(_):0;if(_=f,o&&this._onA11yChar.fire(Vt(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-k>a){if(h){let D=d,W=this._activeBuffer.x-k;for(this._activeBuffer.x=k,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),k>0&&d instanceof Ni&&d.copyCellsFrom(D,W,0,k,!1);W<a;)D.setCellFromCodepoint(W++,0,1,u)}else if(this._activeBuffer.x=a-1,r===2)continue}if(v&&this._activeBuffer.x){let D=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-D,s,r);for(let W=r-k;--W>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-k,this._activeBuffer.getNullCell(u)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,s,r,u),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=_,this._activeBuffer.x<a&&i-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>To(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new xo(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new at(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Te));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=ii.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let l=0;l<n.length;){let u=n.codePointAt(l)||0;o[a++]=u,l+=u>65535?2:1}let h=a;for(let l=1;l<i;++l)o.copyWithin(h,0,a),h+=a;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(x.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(x.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(x.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(x.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(x.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ti),this._charsetService.setgCharset(1,ti),this._charsetService.setgCharset(2,ti),this._charsetService.setgCharset(3,ti);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(v=>(v[v.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",v[v.SET=1]="SET",v[v.RESET=2]="RESET",v[v.PERMANENTLY_SET=3]="PERMANENTLY_SET",v[v.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:u}=a,d=this._optionsService.rawOptions,_=(v,k)=>(o.triggerDataEvent(`${x.ESC}[${t?"":"?"}${v};${k}$y`),!0),m=v=>v?1:2,f=e.params[0];return t?f===2?_(f,4):f===4?_(f,m(o.modes.insertMode)):f===12?_(f,3):f===20?_(f,m(d.convertEol)):_(f,0):f===1?_(f,m(s.applicationCursorKeys)):f===3?_(f,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):f===6?_(f,m(s.origin)):f===7?_(f,m(s.wraparound)):f===8?_(f,3):f===9?_(f,m(r==="X10")):f===12?_(f,m(d.cursorBlink)):f===25?_(f,m(!o.isCursorHidden)):f===45?_(f,m(s.reverseWraparound)):f===66?_(f,m(s.applicationKeypad)):f===67?_(f,4):f===1e3?_(f,m(r==="VT200")):f===1002?_(f,m(r==="DRAG")):f===1003?_(f,m(r==="ANY")):f===1004?_(f,m(s.sendFocus)):f===1005?_(f,4):f===1006?_(f,m(n==="SGR")):f===1015?_(f,4):f===1016?_(f,m(n==="SGR_PIXELS")):f===1048?_(f,1):f===47||f===1047||f===1049?_(f,m(l===u)):f===2004?_(f,m(s.bracketedPasteMode)):f===2026?_(f,m(s.synchronizedOutput)):_(f,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=qi.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Te.fg,e.bg=Te.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Te.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Te.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Te.fg&16777215,s.bg&=-67108864,s.bg|=Te.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${x.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${x.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${x.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Te.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!To(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${x.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Eo&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Eo&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Bo(n))if(r==="?")t.push({type:0,index:n});else{let o=ko(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=ko(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Bo(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,ti),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Ju[e[0]],De[e[1]]||ti),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Te.clone(),this._eraseAttrDataInternal=Te.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new mt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${x.ESC}${o}${x.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},qr=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Mo=e,e=t,t=Mo),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};qr=ye([z(0,Qe)],qr);function Bo(e){return 0<=e&&e<256}var ed=5e7,Do=12,td=50,id=class extends se{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new B),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>ed)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=Do?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Do)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>td&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Vr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Vr=ye([z(0,Qe)],Vr);var Lo=!1,sd=class extends se{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new vi),this._onBinary=this._register(new B),this.onBinary=this._onBinary.event,this._onData=this._register(new B),this.onData=this._onData.event,this._onLineFeed=this._register(new B),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new B),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new B),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new B),this._instantiationService=new Tu,this.optionsService=this._register(new Ou(e)),this._instantiationService.setService(et,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance($r)),this._instantiationService.setService(Qe,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Wr)),this._instantiationService.setService(wa,this._logService),this.coreService=this._register(this._instantiationService.createInstance(jr)),this._instantiationService.setService(ai,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ur)),this._instantiationService.setService(ba,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ii)),this._instantiationService.setService(Ch,this.unicodeService),this._charsetService=this._instantiationService.createInstance($u),this._instantiationService.setService(yh,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Vr),this._instantiationService.setService(ya,this._oscLinkService),this._inputHandler=this._register(new Qu(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ke.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ke.forward(this._bufferService.onResize,this._onResize)),this._register(Ke.forward(this.coreService.onData,this._onData)),this._register(Ke.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new id((t,i)=>this._inputHandler.parse(t,i))),this._register(Ke.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new B),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Lo&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Lo=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,el),t=Math.max(t,tl),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Co.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Co(this._bufferService),!1))),this._windowsWrappingHeuristics.value=pe(()=>{for(let t of e)t.dispose()})}}},rd={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function nd(e,t,i,s){var o;let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=x.ESC+"OA":r.key=x.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=x.ESC+"OD":r.key=x.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=x.ESC+"OC":r.key=x.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=x.ESC+"OB":r.key=x.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":x.DEL,e.altKey&&(r.key=x.ESC+r.key);break;case 9:if(e.shiftKey){r.key=x.ESC+"[Z";break}r.key=x.HT,r.cancel=!0;break;case 13:r.key=e.altKey?x.ESC+x.CR:x.CR,r.cancel=!0;break;case 27:r.key=x.ESC,e.altKey&&(r.key=x.ESC+x.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"D":t?r.key=x.ESC+"OD":r.key=x.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"C":t?r.key=x.ESC+"OC":r.key=x.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"A":t?r.key=x.ESC+"OA":r.key=x.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"B":t?r.key=x.ESC+"OB":r.key=x.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=x.ESC+"[2~");break;case 46:n?r.key=x.ESC+"[3;"+(n+1)+"~":r.key=x.ESC+"[3~";break;case 36:n?r.key=x.ESC+"[1;"+(n+1)+"H":t?r.key=x.ESC+"OH":r.key=x.ESC+"[H";break;case 35:n?r.key=x.ESC+"[1;"+(n+1)+"F":t?r.key=x.ESC+"OF":r.key=x.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=x.ESC+"[5;"+(n+1)+"~":r.key=x.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=x.ESC+"[6;"+(n+1)+"~":r.key=x.ESC+"[6~";break;case 112:n?r.key=x.ESC+"[1;"+(n+1)+"P":r.key=x.ESC+"OP";break;case 113:n?r.key=x.ESC+"[1;"+(n+1)+"Q":r.key=x.ESC+"OQ";break;case 114:n?r.key=x.ESC+"[1;"+(n+1)+"R":r.key=x.ESC+"OR";break;case 115:n?r.key=x.ESC+"[1;"+(n+1)+"S":r.key=x.ESC+"OS";break;case 116:n?r.key=x.ESC+"[15;"+(n+1)+"~":r.key=x.ESC+"[15~";break;case 117:n?r.key=x.ESC+"[17;"+(n+1)+"~":r.key=x.ESC+"[17~";break;case 118:n?r.key=x.ESC+"[18;"+(n+1)+"~":r.key=x.ESC+"[18~";break;case 119:n?r.key=x.ESC+"[19;"+(n+1)+"~":r.key=x.ESC+"[19~";break;case 120:n?r.key=x.ESC+"[20;"+(n+1)+"~":r.key=x.ESC+"[20~";break;case 121:n?r.key=x.ESC+"[21;"+(n+1)+"~":r.key=x.ESC+"[21~";break;case 122:n?r.key=x.ESC+"[23;"+(n+1)+"~":r.key=x.ESC+"[23~";break;case 123:n?r.key=x.ESC+"[24;"+(n+1)+"~":r.key=x.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=x.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=x.DEL:e.keyCode===219?r.key=x.ESC:e.keyCode===220?r.key=x.FS:e.keyCode===221&&(r.key=x.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=rd[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=x.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=x.ESC+l}else if(e.keyCode===32)r.key=x.ESC+(e.ctrlKey?x.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=x.ESC+h,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=x.US),e.key==="@"&&(r.key=x.NUL));break}return r}var xe=0,od=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ks,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ks,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(xe=this._search(t),xe===-1)||this._getKey(this._array[xe])!==t)return!1;do if(this._array[xe]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(xe),!0;while(++xe<this._array.length&&this._getKey(this._array[xe])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xe=this._search(e),!(xe<0||xe>=this._array.length)&&this._getKey(this._array[xe])===e))do yield this._array[xe];while(++xe<this._array.length&&this._getKey(this._array[xe])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xe=this._search(e),!(xe<0||xe>=this._array.length)&&this._getKey(this._array[xe])===e))do t(this._array[xe]);while(++xe<this._array.length&&this._getKey(this._array[xe])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},nr=0,Po=0,ad=class extends se{constructor(){super(),this._decorations=new od(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new B),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new B),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(pe(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new ld(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{nr=r.options.x??0,Po=nr+(r.options.width??1),e>=nr&&e<Po&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},ld=class extends Xt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new B),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new B),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ve.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ve.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},hd=1e3,cd=class{constructor(e,t=hd){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Ao=20,Es=class extends se{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new cd(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
48
+ `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(X(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(pe(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Ao+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
49
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Ao+1&&(this._liveRegion.textContent+=fr.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var a;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let u=h instanceof Text?h.parentNode:h,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(u);if(!_)return console.warn("columns is null. Race condition?"),null;let m=l<_.length?_[l]:_.slice(-1)[0]+1;return m>=this._terminal.cols&&(++d,m=0),{row:d,column:m}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var r,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Es=ye([z(1,Zr),z(2,Ot),z(3,Ft)],Es);var Yr=class extends se{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new B),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new B),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(pe(()=>{var n;ni(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(X(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(X(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(X(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(X(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var l,u;if(this._isMouseOut)return;let h=a==null?void 0:a.map(d=>({link:d}));(l=this._activeProviderReplies)==null||l.set(n,h),i=this._checkLinkProviderResult(n,e,i),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<e?0:o.link.range.start.x,h=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(a=>this._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&ud(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ni(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Yr=ye([z(1,Jr),z(2,Ft),z(3,Qe),z(4,xa)],Yr);function ud(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var dd=class extends sd{constructor(e={}){super(e),this._linkifier=this._register(new vi),this.browser=ja,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new vi),this._onCursorMove=this._register(new B),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new B),this.onKey=this._onKey.event,this._onRender=this._register(new B),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new B),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new B),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new B),this.onBell=this._onBell.event,this._onFocus=this._register(new B),this._onBlur=this._register(new B),this._onA11yCharEmitter=this._register(new B),this._onA11yTabEmitter=this._register(new B),this._onWillOpen=this._register(new B),this._setup(),this._decorationService=this._instantiationService.createInstance(ad),this._instantiationService.setService(Vi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(tu),this._instantiationService.setService(xa,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(mr)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Ke.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ke.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ke.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ke.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(pe(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=fe.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${x.ESC}]${s};${Zu(r)}${Wa.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=Re.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=Re.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Es,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(X(this.element,"copy",t=>{this.hasSelection()&&ph(t,this._selectionService)}));let e=t=>gh(t,this.textarea,this.coreService,this.optionsService);this._register(X(this.textarea,"paste",e)),this._register(X(this.element,"paste",e)),Ua?this._register(X(this.element,"mousedown",t=>{t.button===2&&jn(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(X(this.element,"contextmenu",t=>{jn(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),an&&this._register(X(this.element,"auxclick",t=>{t.button===1&&ma(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(X(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(X(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(X(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(X(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(X(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(X(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(X(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(X(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",dr.get()),Va||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Qc,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Ot,this._coreBrowserService),this._register(X(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(X(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Nr,this._document,this._helperContainer),this._instantiationService.setService(Ms,this._charSizeService),this._themeService=this._instantiationService.createInstance(zr),this._instantiationService.setService(Si,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Cs),this._instantiationService.setService(Ca,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Fr,this.rows,this.screenElement)),this._instantiationService.setService(Ft,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Pr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Or),this._instantiationService.setService(Jr,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Yr,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Dr,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Hr,this.element,this.screenElement,s)),this._instantiationService.setService(kh,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Ke.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(Lr,this.screenElement)),this._register(X(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Es,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ys,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ys,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ir,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var l,u,d,_,m;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let f=n.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(n,(_=(d=(u=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:_.height,(m=e._coreBrowserService)==null?void 0:m.dpr)===0)return!1;h=f<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(X(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(X(t,"wheel",n=>{var o,a,h,l,u;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(n,!0);let d=x.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){_a(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=nd(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===x.ETX||i.key===x.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(fd(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Te));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(x.ESC+"[I"):this.coreService.triggerDataEvent(x.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${x.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${x.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function fd(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var _d=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},md=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new mt)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Io=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new md(t)}getNullCell(){return new mt}},pd=class extends se{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new B),this.onBufferChange=this._onBufferChange.event,this._normal=new Io(this._core.buffers.normal,"normal"),this._alternate=new Io(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},gd=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},vd=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Sd=["cols","rows"],Ct=0,bd=class extends se{constructor(e){super(),this._core=this._register(new dd(e)),this._addonManager=this._register(new _d),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(Sd.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new gd(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new vd(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new pd(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
50
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return dr.get()},set promptLabel(e){dr.set(e)},get tooMuchOutput(){return fr.get()},set tooMuchOutput(e){fr.set(e)}}}_verifyIntegers(...e){for(Ct of e)if(Ct===1/0||isNaN(Ct)||Ct%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ct of e)if(Ct&&(Ct===1/0||isNaN(Ct)||Ct%1!==0||Ct<0))throw new Error("This API only accepts positive integers")}};const sl="codingns.user-app.terminal-page",wd=3,yd=20,Cd=5,xd=400,kd=200,Ed=2e5,Td=12e4,Rd=.7,Md=2,or={selectedWorkspaceId:null,activeTerminalIdByWorkspace:{},pinnedTerminalIdsByWorkspace:{},cursorByTerminalId:{},viewStateByTerminalId:{},zoomScale:null};function Bd(){var t,i;const e=yi();return{selectedWorkspaceId:((t=e.selectedWorkspaceId)==null?void 0:t.value)??null,activeTerminalIdByWorkspace:as(e.activeTerminalIdByWorkspace),pinnedTerminalIdsByWorkspace:as(e.pinnedTerminalIdsByWorkspace),cursorByTerminalId:as(e.cursorByTerminalId),viewStateByTerminalId:as(e.viewStateByTerminalId),zoomScale:((i=e.zoomScale)==null?void 0:i.value)??null}}function Dd(e){wi((t,i)=>({...t,selectedWorkspaceId:{value:e,updatedAt:i}}))}function Ld(e){var t;return((t=yi().activeTerminalIdByWorkspace[e])==null?void 0:t.value)??null}function Pd(e,t){wi((i,s)=>{const r={...i,activeTerminalIdByWorkspace:{...i.activeTerminalIdByWorkspace}};return t?r.activeTerminalIdByWorkspace[e]={value:t,updatedAt:s}:delete r.activeTerminalIdByWorkspace[e],r})}function Ad(e){var t;return((t=yi().pinnedTerminalIdsByWorkspace[e])==null?void 0:t.value)??[]}function No(e,t){wi((i,s)=>{const r={...i,pinnedTerminalIdsByWorkspace:{...i.pinnedTerminalIdsByWorkspace}},n=nl(t);return n.length===0?(delete r.pinnedTerminalIdsByWorkspace[e],r):(r.pinnedTerminalIdsByWorkspace[e]={value:n,updatedAt:s},r)})}function Id(){var e;return((e=yi().zoomScale)==null?void 0:e.value)??null}function Nd(e){wi((t,i)=>({...t,zoomScale:{value:ol(e),updatedAt:i}}))}function Od(e,t){wi((i,s)=>{const r={...i,cursorByTerminalId:{...i.cursorByTerminalId}};return t?(r.cursorByTerminalId[e]=rl(i.cursorByTerminalId[e],{value:t,updatedAt:s}),r):(delete r.cursorByTerminalId[e],r)})}function Xr(e){var r,n;const t=yi(),i=((r=t.viewStateByTerminalId[e])==null?void 0:r.value)??null,s=((n=t.cursorByTerminalId[e])==null?void 0:n.value)??null;return i?i.cursor&&s&&Ui(s,i.cursor)?{resumeCursor:s,viewState:null}:{resumeCursor:i.cursor??s,viewState:i}:{resumeCursor:s,viewState:null}}function Fd(e,t){wi((i,s)=>{const r={...i,cursorByTerminalId:{...i.cursorByTerminalId},viewStateByTerminalId:{...i.viewStateByTerminalId}};return t?(r.viewStateByTerminalId[e]=Kd(i.viewStateByTerminalId[e],{value:t,updatedAt:s}),t.cursor&&(r.cursorByTerminalId[e]=rl(i.cursorByTerminalId[e],{value:t.cursor,updatedAt:s})),r):(delete r.viewStateByTerminalId[e],r)})}function wi(e){if(typeof window>"u")return;const t=yi(),i=Date.now(),s=e(t,i);window.localStorage.setItem(sl,JSON.stringify({schemaVersion:wd,state:s}))}function yi(){if(typeof window>"u")return or;try{const e=window.localStorage.getItem(sl);if(!e)return or;const t=JSON.parse(e),i=t&&typeof t=="object"&&"state"in t&&t.state&&typeof t.state=="object"?t.state:t;return{selectedWorkspaceId:zd(i.selectedWorkspaceId),activeTerminalIdByWorkspace:os(i.activeTerminalIdByWorkspace,Oo),pinnedTerminalIdsByWorkspace:os(i.pinnedTerminalIdsByWorkspace,$d),cursorByTerminalId:os(i.cursorByTerminalId,Oo),viewStateByTerminalId:os(i.viewStateByTerminalId,jd),zoomScale:Hd(i.zoomScale)}}catch{return or}}function Hd(e){return e===null?null:ln(e,Ud)??null}function zd(e){return e===null?null:ln(e,Wd)??null}function os(e,t){if(!e||typeof e!="object")return{};const i={};for(const[s,r]of Object.entries(e)){const n=ln(r,t);s&&n&&(i[s]=n)}return i}function ln(e,t){const i=t(e);if(i!==null)return{value:i,updatedAt:0};if(!e||typeof e!="object")return null;const s=e,r=t(s.value);return r===null?null:{value:r,updatedAt:Number.isFinite(s.updatedAt)?Number(s.updatedAt):0}}function Oo(e){return typeof e=="string"&&e?e:null}function Wd(e){return e===null?null:typeof e=="string"?e:null}function $d(e){return Array.isArray(e)?nl(e.filter(i=>typeof i=="string")):null}function jd(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.content!="string"||t.content.length===0||t.content.length>Td||t.cursor!==null&&t.cursor!==void 0&&typeof t.cursor!="string"||!Number.isInteger(t.cols)||!Number.isInteger(t.rows)||!Number.isInteger(t.viewportY)||t.historyBeforeSeq!==null&&t.historyBeforeSeq!==void 0&&!Number.isInteger(t.historyBeforeSeq)||t.historyHasOlder!==void 0&&typeof t.historyHasOlder!="boolean")return null;const i=t.cols,s=t.rows,r=t.viewportY;return i<yd||i>xd||s<Cd||s>kd||r<0||r>Ed?null:{content:t.content,cursor:typeof t.cursor=="string"?t.cursor:null,cols:i,rows:s,viewportY:r,historyBeforeSeq:typeof t.historyBeforeSeq=="number"?t.historyBeforeSeq:null,historyHasOlder:typeof t.historyHasOlder=="boolean"?t.historyHasOlder:!0}}function Ud(e){return typeof e!="number"||!Number.isFinite(e)?null:ol(e)}function as(e){const t={};for(const[i,s]of Object.entries(e))t[i]=s.value;return t}function rl(e,t){return!e||Ui(t.value,e.value)?t:Ui(e.value,t.value)?e:t.updatedAt>=e.updatedAt?t:e}function Kd(e,t){if(!e)return t;const i=e.value.cursor,s=t.value.cursor;return s&&i&&Ui(s,i)?t:s&&i&&Ui(i,s)?e:t.value.content.length!==e.value.content.length?t.value.content.length>e.value.content.length?t:e:t.updatedAt>=e.updatedAt?t:e}function Ui(e,t){const i=Number(e),s=Number(t);return!Number.isInteger(i)||!Number.isInteger(s)?!1:i>s}function nl(e){return Array.from(new Set(e.map(t=>t.trim()).filter(Boolean)))}function ol(e){return Math.min(Md,Math.max(Rd,e))}function qd({terminals:e,preferredTerminalId:t,currentActiveTerminalId:i,persistedTerminalId:s}){const r=ar(e,t),n=ar(e,i),o=ar(e,s),a=e.find(h=>h.status==="running")??null;return lr(r)??lr(n)??lr(o)??a??r??n??o??e[0]??null}function ar(e,t){return t?e.find(i=>i.id===t)??null:null}function lr(e){return!e||e.status!=="running"?null:e}const Vd="codingns.terminal.debug",Yd=Xd();let Fo=0;function ri(){return Yd}function Xd(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search).get("terminalDebug");if(e)return Ho(e);try{const t=window.localStorage.getItem(Vd);return t?Ho(t):!1}catch{return!1}}function kt(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Gd(e){return Fo+=1,`${e}-${Date.now().toString(36)}-${Fo.toString(36)}`}function zi(e,t={}){ri()&&console.info(`[terminal-debug][client] ${e}`,t)}function Ho(e){const t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}const Zd=8,Jd=1e4;class Qd{constructor(t){it(this,"socket",null);it(this,"disposed",!1);it(this,"authRecoveryInFlight",!1);it(this,"manuallyDisconnected",!1);it(this,"lastCursor");it(this,"isSubscribed",!1);it(this,"pendingInput","");it(this,"inputFlushTimer",null);it(this,"pendingInputQueuedAtMs",null);it(this,"pendingResize",null);it(this,"lastSentResizeKey",null);it(this,"inputDebugTraces",new Map);it(this,"connectionManager");this.options=t,this.lastCursor=t.lastCursor,this.connectionManager=new Fl({onReconnect:i=>{this.connect(i)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}updateCursor(t){this.lastCursor=t}sendInput(t){t&&(this.pendingInputQueuedAtMs===null&&(this.pendingInputQueuedAtMs=kt()),this.pendingInput+=t,this.logDebug("input.queued",{charCount:t.length,pendingCharCount:this.pendingInput.length,preview:ls(t)}),this.canSendRealtimePayload()&&(this.pruneStaleInputDebugTraces(),this.scheduleInputFlush()))}sendCurrentDimensions(t,i){!Number.isInteger(t)||!Number.isInteger(i)||t<1||i<1||this.resize(t,i)}sendTerminalInput(t){const i=this.pendingInputQueuedAtMs??kt(),s=kt(),n=ri()?Gd(this.options.terminalId):void 0;n&&this.inputDebugTraces.set(n,{traceId:n,queuedAtMs:i,sentAtMs:s,ackedAtMs:null,charCount:t.length,preview:ls(t)}),this.logDebug("input.sent",{traceId:n??null,charCount:t.length,queuedForMs:s-i,preview:ls(t)}),this.sendMessage({type:"terminal.input",terminalId:this.options.terminalId,content:t,...n?{clientTraceId:n,clientSentAtMs:s}:{}}),this.pendingInputQueuedAtMs=null}resize(t,i){this.pendingResize={cols:t,rows:i},this.isSubscribed&&this.flushPendingResize()}disconnect(){this.manuallyDisconnected=!0,this.isSubscribed=!1,this.inputDebugTraces.clear();const t=this.socket;this.socket=null,t==null||t.close(),this.options.onConnectionChange("closed")}reconnectNow(){this.manuallyDisconnected=!1,this.connectionManager.reconnectNow()}close(){var t;this.disposed=!0,this.manuallyDisconnected=!0,this.connectionManager.close(),this.clearInputFlushTimer(),this.inputDebugTraces.clear(),(t=this.socket)==null||t.close(),this.socket=null,this.isSubscribed=!1}connect(t){var n;if(this.disposed||this.manuallyDisconnected)return;t&&this.socket&&(this.socket.close(),this.socket=null);const i=(n=On.getState().session)==null?void 0:n.accessToken;if(!i){this.options.onUnauthorized();return}const s=`${Il("/ws")}?access_token=${encodeURIComponent(i)}`,r=new WebSocket(s);this.socket=r,r.addEventListener("open",()=>{this.isSubscribed=!1,r.send(JSON.stringify({type:"terminal.subscribe",terminalId:this.options.terminalId,lastCursor:this.lastCursor}))}),r.addEventListener("message",o=>{const a=JSON.parse(o.data);if(a.type==="system.connected"){this.connectionManager.markConnected();return}if(a.type==="terminal.subscribed"){this.isSubscribed=!0,this.options.onSubscribed(),this.flushPendingResize(),this.flushPendingInput(!0);return}if(a.type==="terminal.error"){if(a.error_code==="UNAUTHORIZED"){this.handleUnauthorized();return}this.options.onError(a);return}if(a.type!=="terminal.resize.accepted"){if(a.type==="terminal.input.accepted"){if(this.pruneStaleInputDebugTraces(),a.clientTraceId){const h=this.inputDebugTraces.get(a.clientTraceId);h&&(h.ackedAtMs=kt(),this.logDebug("input.acknowledged",{traceId:h.traceId,charCount:h.charCount,sendToAckMs:h.ackedAtMs-h.sentAtMs,preview:h.preview}))}return}if(a.type==="terminal.backfill"){this.lastCursor=a.latestCursor??this.lastCursor,this.options.onBackfill(a);return}if(a.type==="terminal.output"){this.lastCursor=a.chunk.cursor,this.pruneStaleInputDebugTraces(),this.handleDebugOutput(a.chunk.content,a.chunk.cursor),this.options.onOutput(a);return}if(a.type==="terminal.status"){this.options.onStatus(a);return}a.type}}),r.addEventListener("close",()=>{this.disposed||this.socket!==r||(this.isSubscribed=!1,this.connectionManager.markDisconnected())}),r.addEventListener("error",()=>{this.disposed||this.socket!==r||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,this.isSubscribed=!1,t==null||t.close(),On.refresh().then(i=>{if(this.authRecoveryInFlight=!1,!(this.disposed||this.manuallyDisconnected)){if(i.status==="refreshed"){this.connectionManager.reconnectNow();return}if(i.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendMessage(t){!this.socket||this.socket.readyState!==WebSocket.OPEN||this.socket.send(JSON.stringify(t))}canSendRealtimePayload(){return!!(this.socket&&this.socket.readyState===WebSocket.OPEN&&this.isSubscribed)}flushPendingInput(t=!1){if(!this.pendingInput||!this.canSendRealtimePayload())return;t||this.clearInputFlushTimer();const i=this.pendingInput;this.pendingInput="",this.sendTerminalInput(i)}scheduleInputFlush(){this.inputFlushTimer===null&&(this.inputFlushTimer=window.setTimeout(()=>{this.inputFlushTimer=null,this.flushPendingInput(!0)},Zd))}clearInputFlushTimer(){this.inputFlushTimer!==null&&(window.clearTimeout(this.inputFlushTimer),this.inputFlushTimer=null)}flushPendingResize(){if(!this.pendingResize||!this.canSendRealtimePayload())return;const t=this.pendingResize,i=`${t.cols}x${t.rows}`;if(this.lastSentResizeKey===i){this.pendingResize=null;return}this.sendMessage({type:"terminal.resize",terminalId:this.options.terminalId,cols:t.cols,rows:t.rows}),this.lastSentResizeKey=i,this.pendingResize=null}handleDebugOutput(t,i){if(!ri())return;const s=this.inputDebugTraces.values().next().value;if(!s)return;const r=kt();this.inputDebugTraces.delete(s.traceId),this.logDebug("output.received_after_input",{traceId:s.traceId,cursor:i,charCount:t.length,sendToOutputMs:r-s.sentAtMs,ackToOutputMs:s.ackedAtMs===null?null:r-s.ackedAtMs,preview:ls(t)})}logDebug(t,i){zi(`terminal.${t}`,{terminalId:this.options.terminalId,...i})}pruneStaleInputDebugTraces(){if(!ri()||this.inputDebugTraces.size===0)return;const t=kt();for(const[i,s]of this.inputDebugTraces.entries()){const r=t-s.sentAtMs;r<Jd||(this.inputDebugTraces.delete(i),this.logDebug("input.trace_expired",{traceId:i,ageMs:r,charCount:s.charCount,preview:s.preview}))}}}function ls(e){return e.replace(/\r/g,"\\r").replace(/\n/g,"\\n").slice(0,60)}const ef=250,tf=/\u001b\[\?(?:\d+;)*\d+c|\u001b\[>(?:\d+;)*\d+c/g;function sf(e,t=window){let i=!1,s="",r=null,n=null,o=!1;const a=()=>{r!==null&&(t.clearTimeout(r),r=null)},h=()=>{n!==null&&(t.clearTimeout(n),n=null)},l=()=>{if(!i||r!==null||n!==null||s.length===0)return;const u=o?rf(s):s;s="",o=!1,u&&e(u)};return{enqueue(u){if(u){if(i&&r===null&&n===null){e(u);return}s+=u}},suspend(){a(),h(),i=!1},resume(u=0){if(a(),h(),u<=0){i=!0,l();return}i=!1,o=!0,r=t.setTimeout(()=>{r=null,i=!0,n=t.setTimeout(()=>{n=null,l()},ef)},u)},dispose(){a(),h(),i=!1,s="",o=!1}}}function rf(e){return e.replace(tf,"")}const nf=120,of=120,af=120,lf=30,hf=14,cf=160,uf=12e4,al=20,ll=5,df=320,ff=120,_f=.8,mf=1.6,zo=.1,pf=700,Wo=10,gf=300,vf=250,$o=196,Sf=6,hr=8,hn=72,cn=48,bf=60*1e3,wf=20,yf=6,Cf=14,xf=2,jo=.06,Uo=.9,kf=.97,Ef=3600,Tf=3,Rf=.05,Ko=28,hs={primary:null,secondary:null},cs={primary:"closed",secondary:"closed"};function x_({externalWindowMode:e=!1,externalWindowWorkspaceId:t=null,workbenchShellOverrides:i}={}){var Nn;const s=Kl(),r=Hl(s),n=Ol(),o=ql(),{workspaceId:a}=Vl(),h=zl(),{navigationGroups:l,currentWorkspaceId:u,selectWorkspace:d,subscribeTerminalManagerSnapshot:_,requestTerminalManagerRefresh:m,addTerminalManagerSnapshotListener:f}={navigationGroups:(i==null?void 0:i.navigationGroups)??h.navigationGroups,currentWorkspaceId:(i==null?void 0:i.currentWorkspaceId)??h.currentWorkspaceId,selectWorkspace:(i==null?void 0:i.selectWorkspace)??h.selectWorkspace,subscribeTerminalManagerSnapshot:(i==null?void 0:i.subscribeTerminalManagerSnapshot)??h.subscribeTerminalManagerSnapshot,requestTerminalManagerRefresh:(i==null?void 0:i.requestTerminalManagerRefresh)??h.requestTerminalManagerRefresh,addTerminalManagerSnapshotListener:(i==null?void 0:i.addTerminalManagerSnapshotListener)??h.addTerminalManagerSnapshotListener},v=y.useRef(null),k=y.useRef(null),D=y.useRef(null),W=y.useRef(null),U=y.useRef({}),N=y.useRef(null),A=y.useRef(null),O=y.useRef(null),Q=y.useRef(null),Y=y.useRef(""),te=y.useRef([]),ue=y.useRef(0),Z=y.useRef({primary:null,secondary:null}),b=y.useRef(hs),S=y.useRef("primary"),R=y.useRef("single"),E=y.useMemo(()=>l.map(c=>c.workspace),[l]),I=(a==null?void 0:a.trim())||(t==null?void 0:t.trim())||null,[T,P]=y.useState(""),[ee,ae]=y.useState(""),[ne,ce]=y.useState([]),[_e,me]=y.useState(""),[F,L]=y.useState(""),[J,V]=y.useState(!1),[Ce,Le]=y.useState(!1),[$,j]=y.useState(!1),[G,Xe]=y.useState(!1),[de,pt]=y.useState([]),[We,Ht]=y.useState(!1),[St,Mt]=y.useState(null),[Se,ke]=y.useState(null),[H,K]=y.useState(!1),[$e,Ee]=y.useState(null),[qe,lt]=y.useState(!1),[tt,bt]=y.useState("single"),[ht,Gi]=y.useState("primary"),[Gt,fn]=y.useState(hs),[Zi,zt]=y.useState(cs),[_n,Ji]=y.useState([]),[mn,li]=y.useState([]),[Ci,pl]=y.useState({}),[Zt,gl]=y.useState(()=>Id()??1),hi=y.useMemo(()=>E.find(c=>c.id===u)??null,[u,E]),Bt=y.useMemo(()=>E.find(c=>c.id===T)??hi??null,[T,hi,E]),rt=y.useMemo(()=>{var c;return(Bt==null?void 0:Bt.id)??(hi==null?void 0:hi.id)??I??T??((c=E[0])==null?void 0:c.id)??""},[Bt,I,T,hi,E]),vl=y.useMemo(()=>Bt??E[0]??{id:"__terminal-mobile-workspace-placeholder__",name:w("terminal.mobileWorkspaceSwitcherPlaceholder"),path:w("home.emptyWorkspaces")},[Bt,E]),{dismissToast:Ps,showToast:gt}=Yl(),Ge=y.useCallback((c,g="info")=>{},[]),pn=y.useCallback((c,g)=>{Z.current[c]=g},[]),gn=y.useCallback(()=>{o("/login",{replace:!0})},[o]),As=y.useCallback((c,g)=>{const C=D.current,M=g??U.current[c];if(!C||!M||!M.isConnected)return null;const q=C.getBoundingClientRect(),he=M.getBoundingClientRect(),re=Math.max(hr,q.width-$o-hr),nt=fl(he.right-q.left-$o,hr,re),ut=Math.max(0,he.bottom-q.top+Sf);return{terminalId:c,top:ut,left:nt}},[]),vn=y.useCallback(c=>{const g=As(c);if(!g){ke(null);return}ke(C=>!C||C.terminalId!==c||C.top===g.top&&C.left===g.left?C:g)},[As]),xi=y.useMemo(()=>new Set(_n),[_n]),Is=y.useMemo(()=>new Set(mn),[mn]),Sn=y.useMemo(()=>zf(de,xi),[xi,de]),bn=y.useMemo(()=>ha(s.ui.osFamily),[s.ui.osFamily]),oe=!s.isDesktop&&s.isMobile,Sl=s.isDesktop&&s.bridge.supported&&!e&&!!rt,wn=y.useMemo(()=>rt?Wl(rt):null,[rt]),bl=Nl(c=>wn?c.openWindowIds.includes(wn):!1),yn=e||!bl,Wt=oe?"single":tt,ci=oe?"primary":ht,Dt=y.useMemo(()=>oe?{primary:Gt[ht]??Gt.primary,secondary:null}:Gt,[ht,oe,Gt]),Ns=y.useMemo(()=>oe?{primary:Zi[ht]??Zi.primary,secondary:"closed"}:Zi,[ht,oe,Zi]),Lt=Dt[ci],ct=y.useMemo(()=>de.find(c=>c.id===Lt)??null,[Lt,de]),Os=y.useMemo(()=>Se?de.find(c=>c.id===Se.terminalId)??null:null,[Se,de]),wl=Wt==="single"?["primary"]:["primary","secondary"],wt=y.useMemo(()=>qf(ne,s.ui.osFamily),[s.ui.osFamily,ne]),yl=y.useMemo(()=>wt.find(c=>c.value===F)??wt[0]??null,[F,wt]),Cl={"--terminal-mobile-list-width":oe&&J?"60vw":"0px"};y.useEffect(()=>{te.current=de},[de]),Df(k,N,oe,T||rt),y.useEffect(()=>{me(c=>us(ne,c)??"")},[ne]),y.useEffect(()=>{L(c=>{var g,C;return wt.length?c&&wt.some(M=>M.value===c&&M.available)?c:((g=wt.find(M=>M.available))==null?void 0:g.value)??((C=wt[0])==null?void 0:C.value)??"":""})},[wt]);function $t(c){const g=c(b.current);b.current=g,fn(g)}function ui(c){S.current=c,Gi(c)}function Fs(c){R.current=c,bt(c)}const di=y.useCallback((c,g,C={})=>{var he;if(Y.current!==c)return;te.current=g,pt(g),li(re=>{const nt=new Set(g.map(ut=>ut.id));return re.filter(ut=>nt.has(ut))}),Ji(re=>{const nt=new Set(g.map(_i=>_i.id)),ut=re.filter(_i=>nt.has(_i));return ut.length!==re.length&&No(c,ut),ut});const M=Ld(c),q=((he=qd({terminals:g,preferredTerminalId:C.preferredTerminalId,currentActiveTerminalId:b.current[S.current]??b.current.primary,persistedTerminalId:M}))==null?void 0:he.id)??null;fn(re=>{const nt=fs({terminals:g,currentBindings:re,splitDirection:R.current,fallbackTerminalId:q,preferredPaneId:C.preferredPaneId??S.current});return b.current=nt,nt})},[]),jt=y.useCallback(async(c,g={})=>{const C=ue.current+1;ue.current=C;try{const M=await Gl(c);if(C!==ue.current||Y.current!==c)return;di(c,M.items,g)}catch(M){if(C!==ue.current||Y.current!==c)return;const q=M instanceof Error?M.message:w("terminal.workspaceLoadFailed");Ge(q,"error")}},[di,Ge]),Cn=y.useCallback(()=>T?jt(T):Promise.resolve(),[jt,T]);y.useEffect(()=>{Y.current=T},[T]),y.useEffect(()=>{b.current=Gt},[Gt]),y.useEffect(()=>{S.current=ht},[ht]),y.useEffect(()=>{R.current=tt},[tt]),y.useEffect(()=>{if(!oe)return;const c=b.current[S.current]??b.current.primary,g=R.current!=="single",C=S.current!=="primary",M=b.current.secondary!==null||b.current.primary!==c;!g&&!C&&!M||($t(()=>({primary:c,secondary:null})),Fs("single"),ui("primary"),zt(q=>q.secondary==="closed"?q:{...q,secondary:"closed"}))},[oe]),y.useEffect(()=>{var q,he;const c=Bd().selectedWorkspaceId,g=I&&(E.length===0||E.some(re=>re.id===I))?I:null,C=u&&E.some(re=>re.id===u)?u:null,M=g??C??I??null??((q=E.find(re=>re.id===c))==null?void 0:q.id)??((he=E[0])==null?void 0:he.id)??"";P(re=>g||(re&&E.some(nt=>nt.id===re)?re:M))},[I,u,E]),y.useEffect(()=>{Dd(T||null)},[T]),y.useEffect(()=>{if(!T){Ji([]);return}Ji(Ad(T))},[T]),y.useEffect(()=>{if(Lt||de.length===0)return;const c=ml(de);c&&Ei(c,"primary")},[Lt,de]),y.useEffect(()=>{Nd(Zt)},[Zt]),y.useEffect(()=>{ke(null)},[ht,Gt,T]),y.useEffect(()=>{oe&&V(!1)},[Lt,oe,T]),y.useEffect(()=>{Se&&!de.some(c=>c.id===Se.terminalId)&&ke(null)},[Se,de]),y.useEffect(()=>{if(T)return f(c=>{c.workspaceId===T&&($l(ra(T),{revision:c.revision??null,terminals:c.terminals,templates:c.templates,templateStatuses:c.templateStatuses,shellOptions:c.shellOptions}),ce(c.shellOptions??[]),di(c.workspaceId,c.terminals))})},[f,di,T]),y.useEffect(()=>{if(!Se)return;const c=W.current,g=()=>{vn(Se.terminalId)},C=window.requestAnimationFrame(g);return window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),c==null||c.addEventListener("scroll",g,{passive:!0}),()=>{window.cancelAnimationFrame(C),window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),c==null||c.removeEventListener("scroll",g)}},[Se,vn]),y.useEffect(()=>{if(!Se&&!H)return;function c(C){var re,nt,ut,_i;const M=C.target,q=(((re=v.current)==null?void 0:re.contains(M))??!1)||!!Se&&(((nt=U.current[Se.terminalId])==null?void 0:nt.contains(M))??!1),he=(((ut=A.current)==null?void 0:ut.contains(M))??!1)||(((_i=O.current)==null?void 0:_i.contains(M))??!1);Se&&!q&&ke(null),H&&!he&&K(!1)}function g(C){C.key==="Escape"&&(ke(null),K(!1))}return window.addEventListener("mousedown",c),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",g)}},[Se,H]),y.useEffect(()=>{if(!T){ce([]),me(""),V(!1),Le(!1),te.current=[],pt([]),$t(()=>hs),ui("primary"),zt(cs),Mt(null);return}ui("primary"),zt(cs),Mt(null);const c=jl(ra(T),bf);if(c?(ce(Wf(c.shellOptions)),di(T,c.terminals)):(ce([]),te.current=[],pt([]),$t(()=>hs),ui("primary"),zt(cs),Mt(null)),_(T,{knownRevision:(c==null?void 0:c.revision)??null}),c){const g=window.setTimeout(()=>{m(T,{knownRevision:c.revision??null})},1500);return()=>{window.clearTimeout(g)}}m(T,{knownRevision:null}),e&&(jt(T),ne.length===0&&Fn().then(g=>{ce(g.items??[])}).catch(()=>{}))},[di,e,m,jt,T,ne.length,_]),y.useEffect(()=>{T&&Pd(T,Lt??null)},[Lt,T]);const xn=y.useCallback((c,g)=>{zt(C=>({...C,[c]:g}))},[]),kn=y.useCallback(c=>{c.status!=="running"&&li(g=>g.filter(C=>C!==c.id)),pt(g=>{const C=g.map(M=>M.id===c.id?{...M,status:c.status,statusDetail:c.statusDetail,processId:c.processId??M.processId??null}:M);return te.current=C,C})},[]);function ki(c,g){pl(C=>{if(g===null){if(!(c in C))return C;const M={...C};return delete M[c],M}return C[c]===g?C:{...C,[c]:g}})}function Hs(c,g){gt({id:cr(c),title:g==="closing"?w("terminal.closing"):w("terminal.deleting"),description:g==="closing"?w("terminal.closePendingDescription"):w("terminal.deletePendingDescription"),tone:"info",durationMs:null})}async function En(c,g,C){for(let M=0;M<Wo;M+=1){if(Y.current!==c)return"workspace_changed";await jt(c);const q=te.current.find(re=>re.id===g)??null;if(C==="deleting"?q===null:q===null||q.status!=="running")return"settled";M<Wo-1&&await s_()}return"timeout"}function Tn(c){ui(c)}function zs(c){Ei(c,S.current)}function Ei(c,g){const C=oe?"primary":g,M=oe?"single":R.current;$t(q=>{const he=M==="single"?{primary:c,secondary:null}:{...q,[C]:c};if(M!=="single"){const re=C==="primary"?"secondary":"primary";he[re]===c&&(he[re]=Gr(de,c))}return fs({terminals:de,currentBindings:he,splitDirection:M,fallbackTerminalId:c,preferredPaneId:C})}),li(q=>q.filter(he=>he!==c)),ke(null)}async function Ws(c,g={}){try{return await Ql(c)}catch(C){if(g.allowFallbackPrompt!==!1&&c.runtimeType!=="embedded-pty"&&ih(C))return Ee(c),null;throw C}}async function Qi(){if(ne.length>0||G)return ne;Xe(!0);try{const g=(await Fn()).items??[];return ce(g),g}catch{return ne}finally{Xe(!1)}}async function Rn(){!oe||!rt||We||(await Qi(),Le(!0))}async function $s(c,g,C={}){var M;Ht(!0),Mt(g);try{const q=await Ws(c);if(!q){fi(g);return}js(q,g),fi(g),(M=C.onCreated)==null||M.call(C),await jt(c.workspaceId,{preferredTerminalId:q.id,preferredPaneId:g}),Ge(w("terminal.created"),"success")}catch(q){fi(g),Ge(q instanceof Error?q.message:w("terminal.createFailed"),"error")}finally{Ht(!1)}}function fi(c){Mt(g=>g===c?null:g)}function js(c,g){const C=oe?"primary":g,M=oe?"single":R.current,q=o_(te.current,c);te.current=q,pt(q),$t(he=>fs({terminals:q,currentBindings:{...he,[C]:c.id,...M==="single"?{primary:c.id,secondary:null}:{}},splitDirection:M,fallbackTerminalId:c.id,preferredPaneId:C})),zt(he=>({...he,[C]:c.status==="running"?"reconnecting":"closed"})),li(he=>he.filter(re=>re!==c.id))}async function xl(){const c=rt;if(!c||We)return;const g=oe?"primary":S.current,C=await Qi(),M=us(C.length>0?C:ne,_e);await $s({workspaceId:c,shell:M??void 0,runtimeType:ee||void 0},g)}async function kl(){if(!rt||We)return;const g=await Qi(),C=g.length>0?g:ne,M=us(C,_e);if($f(C,oe,s.ui.osFamily)){me(M??""),j(!0);return}await xl()}async function El(){const c=rt;if(!c||We)return;const g=ne.length>0?ne:await Qi(),C=us(g.length>0?g:ne,_e);await $s({workspaceId:c,shell:C??void 0,runtimeType:ds(ee,s.ui.osFamily)},S.current,{onCreated:()=>{j(!1)}})}async function Tl(){const c=rt;if(!c||We)return;const g=yl;!g||!g.available||await $s({workspaceId:c,shell:g.value,runtimeType:ds(ee,s.ui.osFamily)},"primary",{onCreated:()=>{Le(!1),V(!1)}})}async function Mn(c,g){return ki(g,"deleting"),Hs(g,"deleting"),await eh(g),En(c,g,"deleting")}async function Us(c){if(!T||Ci[c])return;const g=T,C=cr(c);ke(null),ki(c,"closing"),Hs(c,"closing"),(async()=>{try{await Zl(c);const M=await En(g,c,"closing");if(M==="workspace_changed"){Ps(C);return}if(M==="timeout"){gt({id:C,title:w("terminal.closed"),description:w("terminal.closeSyncDelayed"),tone:"warning"});return}if(!te.current.some(he=>he.id===c)){gt({id:C,title:w("terminal.deleted"),tone:"success"});return}const q=await Mn(g,c);if(q==="workspace_changed"){Ps(C);return}if(q==="timeout"){gt({id:C,title:w("terminal.deleted"),description:w("terminal.deleteSyncDelayed"),tone:"warning"});return}gt({id:C,title:w("terminal.deleted"),tone:"success"})}catch(M){gt({id:C,title:M instanceof Error?M.message:w("terminal.closeFailed"),tone:"error"})}finally{ki(c,null)}})()}async function Bn(c){if(!T||Ci[c])return;const g=T,C=cr(c);ke(null),ki(c,"deleting"),Hs(c,"deleting"),(async()=>{try{const M=await Mn(g,c);if(M==="workspace_changed"){Ps(C);return}if(M==="timeout"){gt({id:C,title:w("terminal.deleted"),description:w("terminal.deleteSyncDelayed"),tone:"warning"});return}gt({id:C,title:w("terminal.deleted"),tone:"success"})}catch(M){gt({id:C,title:M instanceof Error?M.message:w("terminal.deleteFailed"),tone:"error"})}finally{ki(c,null)}})()}async function Dn(c){if(!T)return;const g=oe?"primary":S.current;try{const C=await Ws({workspaceId:T,cwd:c.cwd,shell:c.shell,runtimeType:c.runtimeType});if(!C)return;js(C,g),ke(null),await jt(T,{preferredTerminalId:C.id,preferredPaneId:g}),Ge(w("terminal.duplicateSuccess"),"success")}catch(C){Ge(C instanceof Error?C.message:w("terminal.duplicateFailed"),"error")}}async function Rl(){const c=$e;if(!c)return;const g=oe?"primary":S.current;lt(!0),Mt(g);try{const C=await Ws({...c,runtimeType:"embedded-pty"},{allowFallbackPrompt:!1});if(!C){fi(g);return}js(C,g),ae("embedded-pty"),Ee(null),j(!1),Le(!1),fi(g),await jt(c.workspaceId,{preferredTerminalId:C.id,preferredPaneId:g}),Ge(w("terminal.created"),"success")}catch(C){fi(g),Ge(C instanceof Error?C.message:w("terminal.createFailed"),"error")}finally{lt(!1)}}function Ln(c){T&&(Ji(g=>{const C=g.includes(c)?g.filter(M=>M!==c):[c,...g];return No(T,C),C}),ke(null))}function Pn(c){var C;const g=Ki(c,Dt,Wt,ci);g&&((C=Z.current[g])==null||C.disconnect(),$t(M=>({...M,[g]:null})),zt(M=>({...M,[g]:"closed"})),li(M=>M.includes(c)?M:[...M,c]),ke(null),Ge(w("terminal.disconnected"),"warning"))}function An(c){var C;const g=Ki(c,Dt,Wt,ci);g&&(li(M=>M.filter(q=>q!==c)),zt(M=>({...M,[g]:"reconnecting"})),(C=Z.current[g])==null||C.reconnect(),ke(null),Ge(w("terminal.reconnectRequested")))}function Ks(c){gl(un(c))}function qs(c){if(!oe){if(c==="single"){$t(g=>({primary:S.current==="secondary"?g.secondary??g.primary:g.primary,secondary:null})),Fs("single"),ui("primary");return}Fs(c),$t(g=>fs({terminals:de,currentBindings:g,splitDirection:c,fallbackTerminalId:g[S.current]??g.primary,preferredPaneId:S.current}))}}async function Ml(){if(ct)try{const c=Gf({terminalId:ct.id,splitDirection:Wt,paneBindings:Dt,paneApiById:Z.current});if(!c.trim()){Ge(w("terminal.logEmpty"),"warning");return}const g=new Date().toISOString().replace(/[:.]/g,"-"),M=`${n_(ct.name||"terminal")}-${g}.log`;r_(M,c),Ge(w("terminal.saveLogSuccess"),"success")}catch(c){Ge(c instanceof Error?c.message:w("terminal.saveLogFailed"),"error")}}function In(c){if(oe){if(c==="right"){n.trigger("gesture"),V(!0);return}n.trigger("gesture"),V(!1)}}function Bl(c){if(!oe||J)return;const g=c.touches[0];g&&(Q.current={x:g.clientX,y:g.clientY})}function Dl(c){if(!oe||J){Q.current=null;return}const g=Q.current,C=c.changedTouches[0];if(Q.current=null,!g||!C)return;const M=C.clientX-g.x,q=C.clientY-g.y;Math.abs(M)<hn||Math.abs(q)>cn||Math.abs(M)<=Math.abs(q)||M<0||In("right")}const Ll=y.useCallback(async(c,g)=>{const C=await Ul(s,{workspaceId:c,workspaceName:g,focusOwner:"terminal-page"});C.ok||gt({title:C.detail??w("terminal.openExternalFailed"),tone:"error"})},[s,gt]);return p.jsxs("main",{className:"terminal-layout mobile-page-fixed-root",children:[p.jsx(th,{open:$e!==null,busy:qe,onClose:()=>{qe||Ee(null)},onConfirmFallback:()=>{Rl()}}),p.jsx("section",{ref:k,className:"terminal-shell","data-mobile":oe,"data-mobile-list-open":oe?J:void 0,style:oe?Cl:void 0,children:oe?p.jsxs(p.Fragment,{children:[p.jsx(Xl,{containerRef:N,currentWorkspace:vl,workspaces:E,onSelectWorkspace:c=>{d(c),P(c)},trailing:p.jsx("button",{type:"button",className:"secondary-button mobile-tools-more-button","aria-label":w("terminal.mobileDrawerAction"),title:w("terminal.mobileDrawerAction"),"aria-expanded":J,onClick:()=>{V(c=>!c)},children:p.jsx(hl,{})})}),p.jsx(Mf,{open:J,terminals:Sn,pinnedTerminalIds:xi,activeTerminalId:(ct==null?void 0:ct.id)??null,creatingTerminal:We,paneBindings:Dt,splitDirection:Wt,activePaneId:ci,paneConnectionStates:Ns,terminalMutations:Ci,manuallyDisconnectedTerminalIdSet:Is,onClose:()=>{V(!1)},onCreateTerminal:()=>{V(!1),Rn()},onSelectTerminal:c=>{Ei(c,"primary"),V(!1)},onBindToActivePane:c=>{zs(c),V(!1)},onBindToPane:Ei,onDuplicate:Dn,onDisconnect:Pn,onReconnect:An,onCloseTerminal:Us,onDeleteTerminal:Bn,onTogglePin:Ln}),p.jsxs("div",{className:"terminal-stage-surface terminal-stage-surface-mobile",children:[p.jsx("div",{className:"terminal-mobile-edge-swipe-zone","aria-hidden":"true",onTouchStart:Bl,onTouchEnd:Dl,onTouchCancel:()=>{Q.current=null}}),p.jsx("div",{className:"terminal-stage-grid","data-layout":"single","data-mobile":"true",children:p.jsx(Yo,{paneId:"primary",paneLabel:w("terminal.panePrimary"),terminal:ct,pendingCreation:!ct&&St==="primary",zoomScale:Zt,active:!0,ownsTerminalSize:yn,isMobileLayout:!0,onActivate:Tn,onSwipeGesture:In,onConnectionChange:xn,onTerminalStatus:kn,onRequireReload:Cn,onUnauthorized:gn,registerApi:pn,notifyTerminal:Ge,canCreateTerminal:!!rt,onRequestCreateTerminal:()=>{Rn()},onRequestOpenTerminalDrawer:()=>{V(!0)}},`mobile-${(ct==null?void 0:ct.id)??"empty"}`)})]}),p.jsx(Vo,{open:Ce,loading:G,creating:We,shellChoices:wt,osFamily:s.ui.osFamily,selectedShell:F,runtimeType:ds(ee,s.ui.osFamily),title:w("terminal.mobileCreateSheetTitle"),shellLabel:w("terminal.mobileCreateShellLabel"),shellDescription:w("terminal.mobileCreateShellDescription"),runtimeLabel:w("terminal.mobileCreateRuntimeLabel"),runtimeDescription:w("terminal.mobileCreateRuntimeDescription"),confirmLabel:w("terminal.mobileCreateConfirm"),onClose:()=>{We||Le(!1)},onSelectShell:L,onSelectRuntime:c=>{ae(c)},onConfirm:()=>{Tl()}})]}):p.jsxs(p.Fragment,{children:[p.jsx("header",{className:"terminal-tabbar","data-window-drag-handle":"terminal-tabbar","data-tauri-drag-region":r,children:p.jsxs("div",{ref:D,className:"terminal-tabbar-main","data-tauri-drag-region":r,children:[p.jsxs("div",{ref:W,className:"terminal-tabbar-scroll",role:"tablist","aria-label":w("terminal.title"),"data-window-drag":"ignore",children:[Sn.map(c=>{const g=c.id===Lt,C=xi.has(c.id),M=(Se==null?void 0:Se.terminalId)===c.id,q=Ci[c.id]??null,he=q?"creating":dn({terminal:c,paneBindings:Dt,paneConnectionStates:Ns,manuallyDisconnectedTerminalIdSet:Is});return p.jsxs("div",{className:"terminal-tab-shell","data-active":g,"data-assigned":i_(c.id,Dt,Wt),children:[p.jsx("button",{className:"terminal-tab","data-active":g,type:"button",role:"tab","aria-selected":g,"aria-busy":q!==null,onClick:()=>{g||n.trigger("selection"),zs(c.id)},onAuxClick:re=>{re.button!==1||q!==null||(re.preventDefault(),Us(c.id))},children:p.jsx("span",{className:"terminal-tab-name",children:p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"terminal-tab-status-dot","data-status":he,"aria-hidden":"true"}),C?p.jsx("span",{className:"terminal-tab-pin-indicator",children:"•"}):null,p.jsx("span",{className:"terminal-tab-name-text",children:c.name}),p.jsx("span",{className:"terminal-tab-runtime",title:Hn(c.runtimeType,s.ui.osFamily),children:ur(c.runtimeType,s.ui.osFamily)}),q?p.jsxs("span",{className:"terminal-tab-operation","data-operation":q,children:[p.jsx("span",{className:"terminal-tab-operation-spinner","aria-hidden":"true"}),q==="closing"?w("terminal.closePendingBadge"):w("terminal.deletePendingBadge")]}):null]})})}),p.jsx("button",{ref:re=>{U.current[c.id]=re},className:"terminal-tab-inline-action",type:"button","data-open":M,disabled:q!==null,"aria-haspopup":"menu","aria-label":w("terminal.moreActions"),"aria-expanded":M,onClick:re=>{if(re.stopPropagation(),M){ke(null);return}ke(As(c.id,re.currentTarget)??{terminalId:c.id,top:0,left:0})},children:"⋯"})]},c.id)}),St?p.jsx("div",{className:"terminal-tab-shell",role:"presentation","data-active":Lt===null&&ht===St,"data-assigned":"false","data-pending":"true",children:p.jsx("div",{className:"terminal-tab","aria-hidden":"true",children:p.jsxs("span",{className:"terminal-tab-name",children:[p.jsx("span",{className:"terminal-tab-status-dot","data-status":"creating","aria-hidden":"true"}),p.jsx("span",{className:"terminal-tab-name-text",children:w("terminal.creating")}),p.jsx("span",{className:"terminal-tab-runtime",title:Hn(ee||void 0,s.ui.osFamily),children:ur(ee||void 0,s.ui.osFamily)})]})})}):null,p.jsx("button",{className:"terminal-tab-control",type:"button","aria-label":w("terminal.createButton"),title:w("terminal.createButton"),disabled:!T||We,onClick:()=>{kl()},children:p.jsx("span",{className:"terminal-toolbar-icon","aria-hidden":"true",children:p.jsx("svg",{viewBox:"0 0 16 16",focusable:"false",children:p.jsx("path",{d:"M8 3.25a.75.75 0 0 1 .75.75v3.25H12a.75.75 0 0 1 0 1.5H8.75V12a.75.75 0 0 1-1.5 0V8.75H4A.75.75 0 0 1 4 7.25h3.25V4A.75.75 0 0 1 8 3.25Z"})})})})]}),p.jsx("div",{className:"terminal-tabbar-inline-actions",children:p.jsxs("div",{className:"terminal-toolbar-anchor","data-window-drag":"ignore",children:[p.jsx("div",{ref:A,className:"terminal-toolbar-inline","data-open":H,"aria-hidden":!H,"data-window-drag":"ignore",children:p.jsxs("div",{className:"terminal-toolbar-cluster",children:[Sl?p.jsx("button",{type:"button",className:"terminal-toolbar-menu-action",onClick:()=>{rt&&(K(!1),Ll(rt,(Bt==null?void 0:Bt.name)??null))},children:w("terminal.openExternalAction")}):null,p.jsxs("div",{className:"terminal-toolbar-section",children:[p.jsx("span",{className:"terminal-toolbar-label",children:w("terminal.runtimeField")}),p.jsx("select",{className:"terminal-runtime-select",value:ee,"aria-label":w("terminal.runtimeField"),title:(Nn=bn.find(c=>c.value===ee))==null?void 0:Nn.description,onChange:c=>{ae(c.target.value)},children:bn.map(c=>p.jsx("option",{value:c.value,children:c.label},c.value||"auto"))})]}),p.jsxs("div",{className:"terminal-toolbar-section",children:[p.jsx("span",{className:"terminal-toolbar-label",children:w("terminal.zoomLabel")}),p.jsxs("div",{className:"terminal-zoom-group","aria-label":w("terminal.zoomLabel"),children:[p.jsx("button",{type:"button",className:"terminal-zoom-button","aria-label":w("terminal.zoomOutAction"),onClick:()=>{Ks(Zt-zo)},children:"-"}),p.jsx("button",{type:"button",className:"terminal-zoom-value","aria-label":w("terminal.zoomResetAction"),onClick:()=>{Ks(1)},children:Xf(Zt)}),p.jsx("button",{type:"button",className:"terminal-zoom-button","aria-label":w("terminal.zoomInAction"),onClick:()=>{Ks(Zt+zo)},children:"+"})]})]}),p.jsxs("div",{className:"terminal-toolbar-section",children:[p.jsx("span",{className:"terminal-toolbar-label",children:w("terminal.layoutLabel")}),p.jsxs("div",{className:"terminal-layout-switcher",children:[p.jsx("button",{type:"button",className:"terminal-layout-button","data-active":tt==="single","aria-label":w("terminal.layoutSingleAction"),onClick:()=>{qs("single")},children:"1"}),p.jsx("button",{type:"button",className:"terminal-layout-button","data-active":tt==="vertical","aria-label":w("terminal.layoutVerticalAction"),onClick:()=>{qs("vertical")},children:"||"}),p.jsx("button",{type:"button",className:"terminal-layout-button","data-active":tt==="horizontal","aria-label":w("terminal.layoutHorizontalAction"),onClick:()=>{qs("horizontal")},children:"="})]})]}),p.jsx("button",{type:"button",className:"terminal-toolbar-save",disabled:!ct,onClick:()=>{Ml()},children:w("terminal.saveLogAction")})]})}),p.jsx("button",{ref:O,type:"button",className:"terminal-toolbar-toggle terminal-toolbar-toggle-tool","data-open":H,"aria-label":w("terminal.toolbarToggleAction"),"aria-expanded":H,onClick:()=>{ke(null),K(c=>!c)},children:p.jsx("span",{className:"terminal-toolbar-icon terminal-toolbar-icon-tool","aria-hidden":"true",children:p.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",focusable:"false",children:[p.jsx("path",{d:"M13.1 3.3a3.1 3.1 0 0 0-2.4 3.77L4.95 12.82a1.5 1.5 0 1 0 2.12 2.12l5.74-5.74a3.1 3.1 0 0 0 3.77-2.4l-1.76.5a1.06 1.06 0 0 1-1.04-.28l-1.3-1.3a1.06 1.06 0 0 1-.28-1.04l.9-1.38Z",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round"}),p.jsx("path",{d:"m5.85 11.92 2.22 2.22",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round"})]})})})]})}),Se&&Os?p.jsx(Lf,{ref:v,actionMenu:Se,terminal:Os,paneBindings:Dt,splitDirection:Wt,activePaneId:ci,paneConnectionStates:Ns,pinnedTerminalIdSet:xi,manuallyDisconnectedTerminalIdSet:Is,pendingMutation:Ci[Os.id]??null,onBindToActivePane:zs,onBindToPane:Ei,onDuplicate:Dn,onDisconnect:Pn,onReconnect:An,onClose:Us,onDelete:Bn,onTogglePin:Ln,onCloseMenu:()=>{ke(null)}}):null]})}),p.jsx("div",{className:"terminal-stage-surface",children:p.jsx("div",{className:"terminal-stage-grid","data-layout":Wt,"data-mobile":"false",children:wl.map(c=>{const g=Dt[c],C=de.find(M=>M.id===g)??null;return p.jsx(Yo,{paneId:c,paneLabel:c==="primary"?w("terminal.panePrimary"):w("terminal.paneSecondary"),terminal:C,pendingCreation:!C&&St===c,zoomScale:Zt,active:ci===c,ownsTerminalSize:yn,onActivate:Tn,onConnectionChange:xn,onTerminalStatus:kn,onRequireReload:Cn,onUnauthorized:gn,registerApi:pn,notifyTerminal:Ge},`${c}-${(C==null?void 0:C.id)??"empty"}`)})})})]})}),p.jsx(Vo,{open:$,loading:G,creating:We,shellChoices:wt,osFamily:s.ui.osFamily,selectedShell:_e,runtimeType:ds(ee,s.ui.osFamily),title:w("terminal.createDialogTitle"),shellLabel:w("terminal.mobileCreateShellLabel"),shellDescription:w("terminal.createDialogShellDescription"),runtimeLabel:w("terminal.mobileCreateRuntimeLabel"),runtimeDescription:w("terminal.createDialogRuntimeDescription"),confirmLabel:w("terminal.createDialogConfirm"),onClose:()=>{We||j(!1)},onSelectShell:me,onSelectRuntime:c=>{ae(c)},onConfirm:()=>{El()}})]})}function Mf({open:e,terminals:t,pinnedTerminalIds:i,activeTerminalId:s,creatingTerminal:r,paneBindings:n,splitDirection:o,activePaneId:a,paneConnectionStates:h,terminalMutations:l,manuallyDisconnectedTerminalIdSet:u,onClose:d,onCreateTerminal:_,onSelectTerminal:m,onBindToActivePane:f,onBindToPane:v,onDuplicate:k,onDisconnect:D,onReconnect:W,onCloseTerminal:U,onDeleteTerminal:N,onTogglePin:A}){const O=y.useRef(null),[Q,Y]=y.useState(null),te=t.filter(b=>i.has(b.id)),ue=t.filter(b=>!i.has(b.id)),Z=t.find(b=>b.id===Q)??null;return y.useEffect(()=>{e||Y(null)},[e]),e?p.jsxs(p.Fragment,{children:[p.jsxs("section",{className:"terminal-mobile-list-rail surface-card","aria-label":w("terminal.mobileDrawerTitle"),onTouchStart:b=>{const S=b.touches[0];S&&(O.current={x:S.clientX,y:S.clientY})},onTouchEnd:b=>{const S=O.current,R=b.changedTouches[0];if(O.current=null,!S||!R)return;const E=R.clientX-S.x,I=R.clientY-S.y;Math.abs(E)<hn||Math.abs(I)>cn||Math.abs(E)<=Math.abs(I)||E>=0||d()},onTouchCancel:()=>{O.current=null},children:[p.jsxs("div",{className:"terminal-mobile-list-heading",children:[p.jsx("strong",{children:w("terminal.mobileDrawerTitle")}),p.jsx("p",{children:w("terminal.mobileDrawerDescription")})]}),p.jsxs("div",{className:"terminal-mobile-list-body",children:[te.length>0?p.jsxs("section",{className:"terminal-mobile-list-group terminal-mobile-list-group-pinned",children:[p.jsxs("div",{className:"terminal-mobile-list-group-heading",children:[p.jsx("span",{children:w("terminal.mobilePinnedSectionTitle")}),p.jsx("span",{className:"workbench-section-counter",children:te.length})]}),p.jsx("div",{className:"terminal-mobile-session-list",children:te.map(b=>p.jsx(qo,{terminal:b,active:b.id===s,pendingMutation:l[b.id]??null,onOpen:m,onOpenMenu:S=>{Y(R=>R===S?null:S)}},b.id))})]}):null,p.jsxs("section",{className:"terminal-mobile-list-group terminal-mobile-list-group-workspace",children:[p.jsxs("div",{className:"terminal-mobile-list-group-heading",children:[p.jsx("span",{children:w("terminal.workspaceField")}),p.jsx("span",{className:"workbench-section-counter",children:ue.length})]}),ue.length>0?p.jsx("div",{className:"terminal-mobile-session-list",children:ue.map(b=>p.jsx(qo,{terminal:b,active:b.id===s,pendingMutation:l[b.id]??null,onOpen:m,onOpenMenu:S=>{Y(R=>R===S?null:S)}},b.id))}):p.jsx("div",{className:"workbench-session-empty",children:w("terminal.mobileDrawerEmptyDescription")})]})]}),p.jsx("div",{className:"terminal-mobile-list-footer",children:p.jsxs("button",{type:"button",className:"workbench-import-toggle terminal-mobile-list-create",disabled:r,onClick:_,children:[p.jsx("span",{className:"workbench-import-toggle-symbol",children:"+"}),p.jsx("span",{className:"workbench-import-toggle-label",children:w("terminal.createButton")})]})})]}),p.jsx(Bf,{terminal:Z,pendingMutation:Z?l[Z.id]??null:null,paneBindings:n,splitDirection:o,activePaneId:a,paneConnectionStates:h,pinnedTerminalIdSet:i,manuallyDisconnectedTerminalIdSet:u,onClose:()=>{Y(null)},onBindToActivePane:b=>{Y(null),f(b)},onBindToPane:(b,S)=>{Y(null),v(b,S)},onDuplicate:async b=>{Y(null),await k(b)},onDisconnect:b=>{Y(null),D(b)},onReconnect:b=>{Y(null),W(b)},onCloseTerminal:async b=>{Y(null),await U(b)},onDeleteTerminal:async b=>{Y(null),await N(b)},onTogglePin:b=>{Y(null),A(b)}})]}):null}function qo({terminal:e,active:t,pendingMutation:i,onOpen:s,onOpenMenu:r}){return p.jsxs("article",{className:"terminal-mobile-session-card","data-active":t,children:[p.jsxs("button",{type:"button",className:"terminal-mobile-session-primary","data-active":t?"true":"false",onClick:()=>{s(e.id)},children:[p.jsxs("div",{className:"terminal-mobile-session-title-row",children:[p.jsx("span",{className:Yf(e.status)}),p.jsx("span",{className:"terminal-mobile-session-title",title:e.name,children:e.name}),p.jsx("span",{className:"terminal-mobile-session-runtime-badge",children:ur(e.runtimeType)})]}),p.jsx("div",{className:"terminal-mobile-session-path",title:e.cwd,children:e.cwd}),i?p.jsxs("div",{className:"terminal-mobile-session-operation",children:[p.jsx("span",{className:"terminal-tab-operation-spinner","aria-hidden":"true"}),p.jsx("span",{children:i==="closing"?w("terminal.closePendingBadge"):w("terminal.deletePendingBadge")})]}):null]}),p.jsx("button",{type:"button",className:"terminal-mobile-session-action","aria-label":w("terminal.moreActions"),title:w("terminal.moreActions"),onClick:n=>{n.stopPropagation(),r(e.id)},children:p.jsx(hl,{})})]})}function Bf({terminal:e,pendingMutation:t,paneBindings:i,splitDirection:s,activePaneId:r,paneConnectionStates:n,pinnedTerminalIdSet:o,manuallyDisconnectedTerminalIdSet:a,onClose:h,onBindToActivePane:l,onBindToPane:u,onDuplicate:d,onDisconnect:_,onReconnect:m,onCloseTerminal:f,onDeleteTerminal:v,onTogglePin:k}){if(!e||typeof document>"u")return null;const D=o.has(e.id),W=Ki(e.id,i,s,r),U=W?n[W]:"closed",N=dn({terminal:e,paneBindings:i,paneConnectionStates:n,manuallyDisconnectedTerminalIdSet:a}),A=t===null&&e.status==="running"&&N!=="disconnected",O=t===null&&!A,Q=t===null&&W!==null&&e.status==="running";return p.jsxs(la,{open:!0,title:w("terminal.moreActions"),description:e.name,kind:"action",height:"auto",className:"terminal-mobile-action-sheet",cardClassName:"terminal-mobile-action-sheet-card",bodyClassName:"terminal-mobile-action-list",onClose:h,children:[s!=="single"?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.primary===e.id,onClick:()=>{u(e.id,"primary")},children:w("terminal.bindToPrimaryPaneAction")}),p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.secondary===e.id,onClick:()=>{u(e.id,"secondary")},children:w("terminal.bindToSecondaryPaneAction")})]}):p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.primary===e.id,onClick:()=>{l(e.id)},children:w("terminal.bindToPaneAction")}),p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{d(e)},children:w("terminal.duplicateAction")}),Q?U==="connected"?p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{_(e.id)},children:w("terminal.disconnectAction")}):p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{m(e.id)},children:w("terminal.reconnectAction")}):null,A?p.jsx("button",{type:"button",className:"terminal-mobile-action-item",onClick:()=>{f(e.id)},children:w("terminal.closeButton")}):null,O?p.jsx("button",{type:"button",className:"terminal-mobile-action-item danger",onClick:()=>{v(e.id)},children:w("terminal.deleteAction")}):null,p.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{k(e.id)},children:D?w("terminal.unpinAction"):w("terminal.pinAction")})]})}function Df(e,t,i,s){y.useEffect(()=>{const r=e.current,n=t.current;if(!i||!r){r&&r.style.removeProperty("--terminal-mobile-header-height");return}if(!n){r.style.removeProperty("--terminal-mobile-header-height");return}const o=r,a=n;function h(){!e.current||!a.isConnected||o.style.setProperty("--terminal-mobile-header-height",`${a.offsetHeight}px`)}h();const l=typeof ResizeObserver<"u"?new ResizeObserver(h):null;return l==null||l.observe(a),window.addEventListener("resize",h),()=>{l==null||l.disconnect(),window.removeEventListener("resize",h),r.style.removeProperty("--terminal-mobile-header-height")}},[i,t,s,e])}function Vo({open:e,loading:t,creating:i,shellChoices:s,osFamily:r,selectedShell:n,runtimeType:o,title:a,shellLabel:h,shellDescription:l,runtimeLabel:u,runtimeDescription:d,confirmLabel:_,onClose:m,onSelectShell:f,onSelectRuntime:v,onConfirm:k}){if(!e||typeof document>"u")return null;const D=s.find(A=>A.value===n)??s[0]??null,W=ha(r).find(A=>A.value==="tmux")??null,U=[{value:"tmux",title:(W==null?void 0:W.label)??w("terminal.mobileRuntimePersistentTitle"),description:(W==null?void 0:W.description)??w("terminal.mobileRuntimePersistentDescription")},{value:"embedded-pty",title:w("terminal.mobileRuntimeSessionTitle"),description:w("terminal.mobileRuntimeSessionDescription")}],N=i||t||!D||!D.available;return p.jsxs(la,{open:!0,title:a,kind:"form",height:"three-quarter",className:"terminal-mobile-create-sheet",cardClassName:"terminal-mobile-create-sheet-card",bodyClassName:"terminal-mobile-create-sheet-body",dismissible:!i,onClose:m,children:[p.jsxs("section",{className:"terminal-mobile-create-section",children:[p.jsxs("div",{className:"terminal-mobile-create-section-copy",children:[p.jsx("strong",{children:h}),p.jsx("p",{children:l})]}),t&&s.length===0?p.jsxs("div",{className:"terminal-mobile-create-loading",children:[p.jsx("span",{className:"terminal-pending-indicator","aria-hidden":"true"}),p.jsx("span",{children:w("terminal.mobileCreateLoadingShells")})]}):p.jsx("div",{className:"terminal-mobile-choice-grid",role:"list",children:s.map(A=>{const O=A.value===n;return p.jsxs("button",{type:"button",className:"terminal-mobile-choice-card","data-selected":O?"true":"false",disabled:!A.available||i,onClick:()=>{f(A.value)},children:[p.jsxs("span",{className:"terminal-mobile-choice-copy",children:[p.jsx("strong",{children:A.label}),p.jsx("span",{children:A.description})]}),!A.available&&A.unavailableReason?p.jsx("span",{className:"terminal-mobile-choice-badge terminal-mobile-choice-badge-muted",children:A.unavailableReason}):O?p.jsx("span",{className:"terminal-mobile-choice-badge",children:w("settings.enabled")}):null]},A.id)})})]}),p.jsxs("section",{className:"terminal-mobile-create-section",children:[p.jsxs("div",{className:"terminal-mobile-create-section-copy",children:[p.jsx("strong",{children:u}),p.jsx("p",{children:d})]}),p.jsx("div",{className:"terminal-mobile-choice-grid",role:"list",children:U.map(A=>{const O=A.value===o;return p.jsxs("button",{type:"button",className:"terminal-mobile-choice-card","data-selected":O?"true":"false",disabled:i,onClick:()=>{v(A.value)},children:[p.jsxs("span",{className:"terminal-mobile-choice-copy",children:[p.jsx("strong",{children:A.title}),p.jsx("span",{children:A.description})]}),O?p.jsx("span",{className:"terminal-mobile-choice-badge",children:w("settings.enabled")}):null]},A.value)})})]}),p.jsx("button",{type:"button",className:"terminal-mobile-primary-action terminal-mobile-create-confirm",disabled:N,onClick:k,children:i?w("terminal.creating"):_})]})}function hl(){return p.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[p.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),p.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),p.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}const Lf=y.forwardRef(function({actionMenu:t,terminal:i,pendingMutation:s,paneBindings:r,splitDirection:n,activePaneId:o,paneConnectionStates:a,pinnedTerminalIdSet:h,manuallyDisconnectedTerminalIdSet:l,onBindToActivePane:u,onBindToPane:d,onDuplicate:_,onDisconnect:m,onReconnect:f,onClose:v,onDelete:k,onTogglePin:D,onCloseMenu:W},U){const N=h.has(i.id),A=Ki(i.id,r,n,o),O=A?a[A]:"closed",Q=dn({terminal:i,paneBindings:r,paneConnectionStates:a,manuallyDisconnectedTerminalIdSet:l}),Y=s===null&&i.status==="running"&&Q!=="disconnected",te=s===null&&!Y,ue=s===null&&A!==null&&i.status==="running",Z=n!=="single";return p.jsxs("div",{ref:U,className:"terminal-tab-menu",role:"menu",style:{top:`${t.top}px`,left:`${t.left}px`},onClick:b=>{b.stopPropagation()},children:[Z?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.primary===i.id,onClick:()=>{d(i.id,"primary")},children:w("terminal.bindToPrimaryPaneAction")}),p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.secondary===i.id,onClick:()=>{d(i.id,"secondary")},children:w("terminal.bindToSecondaryPaneAction")})]}):p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.primary===i.id,onClick:()=>{u(i.id)},children:w("terminal.bindToPaneAction")}),p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{W(),_(i)},children:w("terminal.duplicateAction")}),ue?p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"terminal-tab-menu-divider",role:"separator"}),O==="connected"?p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{m(i.id)},children:w("terminal.disconnectAction")}):p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{f(i.id)},children:w("terminal.reconnectAction")})]}):null,p.jsx("div",{className:"terminal-tab-menu-divider",role:"separator"}),Y?p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",onClick:()=>{W(),v(i.id)},children:w("terminal.closeButton")}):null,te?p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",onClick:()=>{k(i.id)},children:w("terminal.deleteAction")}):null,p.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{D(i.id)},children:N?w("terminal.unpinAction"):w("terminal.pinAction")})]})});function Yo({paneId:e,paneLabel:t,terminal:i,pendingCreation:s,zoomScale:r,active:n,ownsTerminalSize:o,isMobileLayout:a=!1,canCreateTerminal:h=!0,onActivate:l,onSwipeGesture:u,onConnectionChange:d,onTerminalStatus:_,onRequireReload:m,onUnauthorized:f,registerApi:v,notifyTerminal:k,onRequestCreateTerminal:D,onRequestOpenTerminalDrawer:W}){const U=y.useRef(null),N=y.useRef(null),A=y.useRef(null),O=y.useRef(null),Q=y.useRef(null),Y=y.useRef(null),te=y.useRef(null),ue=y.useRef(!0),Z=y.useRef(!1),b=y.useRef(null),S=y.useRef((i==null?void 0:i.status)??null),R=y.useRef(!1),E=y.useRef([]),I=y.useRef(n),T=!a,P=y.useCallback(F=>{var L;F&&((L=A.current)==null||L.sendInput(F))},[]),ee=y.useCallback(F=>{const L=Number(F);!Number.isInteger(L)||L<=0||(Y.current=Y.current===null?L:Math.min(Y.current,L),te.current=Y.current)},[]),ae=y.useCallback(async F=>{const L=O.current;if(!L)return;if(!F.content){ue.current=F.hasMore,te.current=F.nextBeforeSeq;return}const J=_l(L.readPlainText()),V=F.replaceContent?Math.max(0,F.lineCount-J):F.anchorLine;await L.prependHistory(F.content,V,{replaceContent:F.replaceContent===!0}),Y.current=F.nextBeforeSeq??Y.current,te.current=F.nextBeforeSeq,ue.current=F.hasMore,L.schedulePersist()},[]),ne=y.useCallback(()=>{const F=O.current;return F?F.terminal.buffer.active.baseY===0:!1},[]),ce=y.useCallback(async()=>{if(!(i!=null&&i.id)||Z.current||!ue.current)return;const F=te.current;if(F!==null){Z.current=!0;try{let L=F,J=yf;for(;L!==null&&J>0;){const V=await Jl(i.id,{beforeSeq:L,limit:wf});if(await ae(V),J-=1,!V.hasMore||!ne())break;L=V.nextBeforeSeq}}catch(L){k(L instanceof Error?L.message:w("conversation.historyLoadFailed"),"error")}finally{Z.current=!1}}},[ae,k,ne,i==null?void 0:i.id]);y.useEffect(()=>{S.current=(i==null?void 0:i.status)??null},[i==null?void 0:i.status]),y.useEffect(()=>{I.current=n},[n]),y.useEffect(()=>{var F;n&&((F=O.current)==null||F.focus())},[n,i==null?void 0:i.id]),y.useEffect(()=>{var F,L;(F=O.current)==null||F.setFontSize(ia(r)),(L=O.current)==null||L.reflow()},[r]),y.useEffect(()=>{var L;const F=O.current;F&&(F.reflow(),o&&((L=A.current)==null||L.sendCurrentDimensions(F.terminal.cols,F.terminal.rows)))},[o,i==null?void 0:i.id]),y.useEffect(()=>{if(typeof document>"u")return;const F=()=>{var J;(J=O.current)==null||J.applyTheme()};F();const L=new MutationObserver(J=>{J.some(V=>V.attributeName==="data-theme")&&F()});return L.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{L.disconnect()}},[i==null?void 0:i.id]),y.useEffect(()=>{var J;if((J=O.current)==null||J.dispose(),O.current=null,v(e,null),!(i!=null&&i.id)||!U.current)return;const F=Xr(i.id).viewState,L=Pf({container:U.current,restoredViewState:F,fontSize:ia(r),enableTouchMomentum:a,getCursor:()=>Q.current,getHistoryPaging:()=>({beforeSeq:te.current,hasOlder:ue.current}),canResize:()=>S.current==="running"&&o,onInput:P,onResize:({cols:V,rows:Ce})=>{var Le;o&&((Le=A.current)==null||Le.resize(V,Ce))},onViewportTop:()=>{ce()},onCursorChange:V=>{Od(i.id,V)},onViewStateChange:V=>{Fd(i.id,V)}});return O.current=L,v(e,{focus:()=>{L.focus()},readPlainText:()=>L.readPlainText(),disconnect:()=>{var V;(V=A.current)==null||V.disconnect()},reconnect:()=>{var V;(V=A.current)==null||V.reconnectNow()}}),()=>{L.persistNow(),L.dispose(),O.current===L&&(O.current=null),v(e,null)}},[P,ce,o,e,v,i==null?void 0:i.id,r]),y.useEffect(()=>{var Ce,Le;if((Ce=A.current)==null||Ce.close(),A.current=null,b.current=null,(Le=O.current)==null||Le.suspendInputForwarding(),d(e,"closed"),!(i!=null&&i.id)){Q.current=null,Y.current=null,te.current=null,ue.current=!0,Z.current=!1,R.current=!1,E.current=[];return}const F=Xr(i.id),L=F.viewState,J=F.resumeCursor;Q.current=J,Y.current=(L==null?void 0:L.historyBeforeSeq)??null,te.current=(L==null?void 0:L.historyBeforeSeq)??null,ue.current=(L==null?void 0:L.historyHasOlder)===!1&&i.runtimeType==="tmux"?!0:(L==null?void 0:L.historyHasOlder)??!0,Z.current=!1,R.current=!1,E.current=[];const V=new Qd({terminalId:i.id,lastCursor:J,onConnectionChange:$=>{var j;$!=="connected"&&((j=O.current)==null||j.suspendInputForwarding()),d(e,$)},onSubscribed:()=>{var j;const $=O.current;$&&($.suspendInputForwarding(),$.reflow(),o&&V.sendCurrentDimensions($.terminal.cols,$.terminal.rows),$.resumeInputForwarding(i.runtimeType==="tmux"?nf:0)),I.current&&((j=O.current)==null||j.focus())},onBackfill:$=>{var pt,We;const j=O.current,G=Ls($.chunks),Xe=j==null?void 0:j.shouldAutoRevealLatest();j&&($.cursorReset?(Zo(j.terminal,G),Y.current=null):j.restoredFromSnapshot?Go(j.terminal,G):(Zo(j.terminal,G),Y.current=null),Xe&&j.revealLatest()),R.current=!0,G.length>0&&ee((pt=G[0])==null?void 0:pt.cursor);const de=$.latestCursor??Q.current;if(Q.current=de,j==null||j.scheduleCursorPersist(de),j&&E.current.length>0){const Ht=If(E.current,$.latestCursor);if(E.current=[],Ht.length>0){Go(j.terminal,Ht);const St=((We=Ht.at(-1))==null?void 0:We.cursor)??de;Q.current=St,j.scheduleCursorPersist(St)}}if(b.current==="idle_closed"){k(w("terminal.recoveryIdleClosed"),"warning");return}if(J){k($.truncated?w("terminal.recoveryTruncated"):w("terminal.recoveryComplete"),$.truncated?"warning":"success");return}L!=null&&L.content||k(w("terminal.connectedHint"))},onOutput:$=>{const j=O.current,G=!R.current,Xe=j==null?void 0:j.shouldAutoRevealLatest();if(G){E.current=[...E.current,$.chunk],Q.current=$.chunk.cursor,j==null||j.scheduleCursorPersist($.chunk.cursor);return}if(j&&ri()){const de=kt();j.terminal.write($.chunk.content,()=>{zi("terminal.output.rendered",{terminalId:i.id,cursor:$.chunk.cursor,charCount:$.chunk.content.length,renderMs:kt()-de})})}else j==null||j.terminal.write($.chunk.content);Xe&&(j==null||j.revealLatest()),Q.current=$.chunk.cursor,ee($.chunk.cursor),j==null||j.scheduleCursorPersist($.chunk.cursor)},onStatus:$=>{if(_({id:$.terminal.id,status:$.terminal.status,statusDetail:$.terminal.statusDetail,processId:$.terminal.processId??null}),$.terminal.id===i.id){if(S.current=$.terminal.status,$.terminal.status!=="running"&&d(e,"closed"),$.terminal.status==="closed"&&$.terminal.statusDetail==="TERMINAL_IDLE_TIMEOUT"){b.current="idle_closed",k(w("terminal.recoveryIdleClosed"),"warning");return}$.terminal.status==="error"&&$.terminal.statusDetail&&k($.terminal.statusDetail,"error")}},onError:$=>{if($.terminalId===i.id){if($.error_code==="TERMINAL_NOT_RUNNING"){m();return}$.error_code!=="INVALID_TERMINAL_SIZE"&&k($.detail,"error")}},onUnauthorized:f});return A.current=V,V.start(),()=>{V.close(),R.current=!1,E.current=[],d(e,"closed")}},[ce,k,d,m,_,f,e,i==null?void 0:i.id,i==null?void 0:i.runtimeType,o,ee]);const _e=y.useCallback(F=>{var J;if(!T||!n||!(i!=null&&i.id)||jf(F))return;const L=Uf(F.nativeEvent);L&&(F.preventDefault(),F.stopPropagation(),P(L),(J=O.current)==null||J.focus())},[n,P,i==null?void 0:i.id,T]),me=y.useCallback(F=>{var J;if(!T||!n||!(i!=null&&i.id)||dl(F.target))return;const L=F.clipboardData.getData("text");L&&(F.preventDefault(),P(L),(J=O.current)==null||J.focus())},[n,P,i==null?void 0:i.id,T]);return p.jsx("article",{className:"terminal-pane-card","data-active":n,"data-empty":!i,tabIndex:i?0:-1,onMouseDown:F=>{l(e),F.currentTarget.focus({preventScroll:!0})},onClick:()=>{var F;(F=O.current)==null||F.focus()},onKeyDown:_e,onPaste:me,onTouchStart:F=>{if(!a)return;const L=F.touches[0];L&&(N.current={x:L.clientX,y:L.clientY})},onTouchEnd:F=>{if(!a||!u){N.current=null;return}const L=N.current,J=F.changedTouches[0];if(N.current=null,!L||!J)return;const V=J.clientX-L.x,Ce=J.clientY-L.y;Math.abs(V)<hn||Math.abs(Ce)>cn||Math.abs(V)<=Math.abs(Ce)||u(V<0?"left":"right")},onTouchCancel:()=>{N.current=null},children:i?p.jsx("div",{className:"terminal-canvas",children:p.jsx("div",{ref:U,className:"terminal-xterm"})}):s?p.jsxs("div",{className:"terminal-empty-state terminal-empty-state-inline terminal-pending-state",children:[p.jsx("span",{className:"terminal-pane-label",children:t}),p.jsx("span",{className:"terminal-pending-indicator","aria-hidden":"true"}),p.jsx("h1",{children:w("terminal.creating")}),p.jsx("p",{children:w("terminal.creationPendingDescription")})]}):p.jsxs("div",{className:a?"terminal-empty-state terminal-empty-state-inline terminal-mobile-empty-state":"terminal-empty-state terminal-empty-state-inline",children:[p.jsx("span",{className:"terminal-pane-label",children:t}),p.jsx("h1",{children:a?w("terminal.mobileEmptyTitle"):w("terminal.stageEmptyTitle")}),p.jsx("p",{children:a?w("terminal.mobileEmptyDescription"):w("terminal.splitEmptySubtitle")}),a?p.jsxs("div",{className:"terminal-mobile-empty-actions",children:[p.jsx("button",{type:"button",className:"terminal-mobile-primary-action",disabled:!h,onClick:()=>{D==null||D()},children:w("terminal.createButton")}),p.jsx("button",{type:"button",className:"terminal-mobile-secondary-action",onClick:()=>{W==null||W()},children:w("terminal.mobileDrawerAction")})]}):null]})})}function Pf(e){var St,Mt,Se,ke;const t=ta(),i=new bd({cols:((St=e.restoredViewState)==null?void 0:St.cols)??af,rows:((Mt=e.restoredViewState)==null?void 0:Mt.rows)??lf,cursorBlink:!0,scrollback:2e3,allowTransparency:!1,fontFamily:'"Cascadia Mono", "Cascadia Code", "Consolas", monospace',fontSize:e.fontSize,theme:t}),s=new nh,r=new ch,n=sf(H=>{e.onInput(H)});let o=null,a=null,h=null,l=!1,u=!1,d=!1,_=i.cols,m=i.rows,f=null;const v=new Set;let k=null,D=0,W=0,U=0,N=null,A=0,O=!1;const Q=()=>{i.focus()};i.loadAddon(s),i.loadAddon(r),i.onData(H=>{n.enqueue(H)});const Y=typeof i.onScroll=="function"?i.onScroll(H=>{var K;H===0&&((K=e.onViewportTop)==null||K.call(e)),$()}):null;i.onResize(({cols:H,rows:K})=>{_=H,m=K,e.canResize()&&e.onResize({cols:H,rows:K}),$()}),e.container.replaceChildren(),i.open(e.container),ea(e.container,t);const te=e.container.querySelector(".xterm"),ue=e.container.querySelector(".xterm-viewport"),Z=ue instanceof HTMLElement?ue:te instanceof HTMLElement?te:e.container,b=te instanceof HTMLElement?te:e.container;b.addEventListener("mousedown",Q,{passive:!0}),b.addEventListener("pointerdown",Q,{passive:!0}),Z.style.touchAction="pan-y",Z.style.overscrollBehavior="contain","webkitOverflowScrolling"in Z.style&&(Z.style.webkitOverflowScrolling="touch");const S=H=>{var Ee;if(u||H.deltaY===0)return!1;const K=i.buffer.active.viewportY===0;return i.buffer.active.baseY>0?!0:(H.deltaY<0&&K&&((Ee=e.onViewportTop)==null||Ee.call(e)),!1)},R=()=>i.buffer.active.baseY>0||i.buffer.active.viewportY>0,E=()=>{N!==null&&(window.cancelAnimationFrame(N),N=null),A=0},I=H=>{var qe;if(u||H===0)return!1;const K=i.buffer.active.viewportY===0,$e=i.buffer.active.viewportY;if(R()){i.scrollLines(H);const lt=i.buffer.active.viewportY!==$e;return $(),lt}return H<0&&K&&((qe=e.onViewportTop)==null||qe.call(e)),!1},T=()=>{if(!e.enableTouchMomentum){W=0;return}if(E(),!O||!R()||Math.abs(W)<jo){W=0;return}let H=performance.now(),K=0,$e=0;const Ee=qe=>{if(u){E();return}const lt=Math.max(1,qe-H);H=qe,K+=lt,A+=W*lt;const tt=Xo(A);if(tt!==0){if($e=0,A-=tt,!I(tt)){W=0,E();return}}else $e+=1;if(W*=Math.pow(kf,lt/16),$e>=Tf||K>=Ef||Math.abs(W)<jo){W=0,E();return}N=window.requestAnimationFrame(Ee)};N=window.requestAnimationFrame(Ee)},P=H=>{const K=H.touches[0];if(E(),W=0,O=!1,U=performance.now(),!K){k=null;return}k={x:K.clientX,y:K.clientY}},ee=H=>{if(!k)return;const K=H.touches[0];if(!K)return;const $e=K.clientX-k.x,Ee=K.clientY-k.y;if(Math.abs(Ee)<=Math.abs($e)){k={x:K.clientX,y:K.clientY};return}H.preventDefault();const qe=performance.now(),lt=Math.max(1,qe-U);U=qe;const tt=-Ee/Cf;D+=tt;const bt=Xo(D);if(bt!==0){D-=bt;const ht=I(bt);if(e.enableTouchMomentum&&ht){const Gi=fl(bt/lt*xf,-Uo,Uo);W=W===0?Gi:W*.35+Gi*.65,O=!0}else ht||(W=0,O=!1)}k={x:K.clientX,y:K.clientY}},ae=()=>{k=null,D=0,T()},ne=()=>{k=null,D=0,W=0,O=!1,E()};typeof i.attachCustomWheelEventHandler=="function"&&i.attachCustomWheelEventHandler(S),b.addEventListener("touchstart",P,{passive:!0}),b.addEventListener("touchmove",ee,{passive:!1}),b.addEventListener("touchend",ae,{passive:!0}),b.addEventListener("touchcancel",ne,{passive:!0}),(Se=e.restoredViewState)!=null&&Se.content?i.write(e.restoredViewState.content,()=>{const H=e.restoredViewState;H&&H.viewportY>0&&i.scrollToLine(H.viewportY),J().then(()=>{Xe()})}):J().then(()=>{Xe()});const ce=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{window.requestAnimationFrame(()=>{j()})});ce==null||ce.observe(e.container),typeof document<"u"&&"fonts"in document&&document.fonts.ready.then(()=>{Xe()});const _e=()=>{G()},me=()=>{Xe()};typeof window<"u"&&(window.addEventListener("resize",_e),window.addEventListener("pageshow",me),(ke=window.visualViewport)==null||ke.addEventListener("resize",_e));const F=()=>{zi("terminal.persist.pagehide",{cursor:e.getCursor()}),V()},L=()=>{document.visibilityState==="hidden"&&(zi("terminal.persist.visibility_hidden",{cursor:e.getCursor()}),V())};typeof window<"u"&&window.addEventListener("pagehide",F),typeof document<"u"&&document.addEventListener("visibilitychange",L);async function J(){for(let H=0;H<10;H+=1){if(Qo(e.container))return;await new Promise(K=>{window.requestAnimationFrame(()=>K())})}}function V(){if(u)return;const H=ri()?kt():0;o!==null&&(window.clearTimeout(o),o=null);const K=Af(i,r,e.getCursor(),e.getHistoryPaging());K?(a!==null&&(window.clearTimeout(a),a=null),l=!1):Ce(e.getCursor()),e.onViewStateChange(K),ri()&&zi("terminal.persist.completed",{cursor:e.getCursor(),hasViewState:!!K,contentLength:(K==null?void 0:K.content.length)??0,historyBeforeSeq:(K==null?void 0:K.historyBeforeSeq)??null,durationMs:kt()-H})}function Ce(H){u||(a!==null&&(window.clearTimeout(a),a=null),H!==void 0&&(h=H,l=!0),l&&(e.onCursorChange(h),l=!1))}function Le(H){u||(h=H,l=!0,a!==null&&window.clearTimeout(a),a=window.setTimeout(()=>{Ce()},gf))}function $(){u||(o!==null&&window.clearTimeout(o),o=window.setTimeout(()=>{V()},vf))}function j(){var Ee,qe;if(u)return;const H=We();if(de(),!Qo(e.container))return;const K=Ff(e.container,i,s);if(!K||K.cols<al||K.rows<ll||d&&K.cols===_&&K.rows===m)return;const $e=ul(i);(i.cols!==K.cols||i.rows!==K.rows)&&((qe=(Ee=$e==null?void 0:$e._renderService)==null?void 0:Ee.clear)==null||qe.call(Ee),i.resize(K.cols,K.rows)),d=!0,_=i.cols,m=i.rows,H&&pt()}function G(){if(u)return;const H=window.requestAnimationFrame(()=>{v.delete(H),j()});v.add(H)}function Xe(){G();const H=window.requestAnimationFrame(()=>{v.delete(H),G()});v.add(H),f!==null&&window.clearTimeout(f),f=window.setTimeout(()=>{f=null,G()},of)}function de(){const H=cl(e.container.clientHeight);e.container.style.setProperty("--terminal-bottom-gap",`${H}px`)}function pt(){Of(i,Jo(e.container,i))}function We(){return Nf(i,Jo(e.container,i)+1)}function Ht(){const H=ta();i.options.theme=H,ea(e.container,H)}return{terminal:i,restoredFromSnapshot:!!e.restoredViewState,focus:()=>{i.focus()},reflow:()=>{j()},revealLatest:pt,shouldAutoRevealLatest:We,prependHistory:async(H,K=_l(H),$e={})=>{if(!H)return;const Ee=i.buffer.active.viewportY,qe=sa(i),lt=$e.replaceContent?Ts(H):Qf(H,qe);await new Promise(tt=>{i.reset(),i.write(e_(lt),()=>{const bt=Math.max(0,Ee+Math.max(K,0));bt>0&&i.scrollToLine(bt),tt()})}),$()},readPlainText:()=>sa(i),setFontSize:H=>{i.options.fontSize!==H&&(i.options.fontSize=H,j(),$())},applyTheme:Ht,persistNow:V,scheduleCursorPersist:Le,schedulePersist:$,suspendInputForwarding:()=>{n.suspend()},resumeInputForwarding:(H=0)=>{n.resume(H)},dispose:()=>{var H;u=!0,f!==null&&(window.clearTimeout(f),f=null),v.forEach(K=>{window.cancelAnimationFrame(K)}),v.clear(),n.dispose(),o!==null&&window.clearTimeout(o),a!==null&&window.clearTimeout(a),b.removeEventListener("mousedown",Q),b.removeEventListener("pointerdown",Q),b.removeEventListener("touchstart",P),b.removeEventListener("touchmove",ee),b.removeEventListener("touchend",ae),b.removeEventListener("touchcancel",ne),E(),Y==null||Y.dispose(),ce==null||ce.disconnect(),typeof window<"u"&&(window.removeEventListener("pagehide",F),window.removeEventListener("resize",_e),window.removeEventListener("pageshow",me),(H=window.visualViewport)==null||H.removeEventListener("resize",_e)),typeof document<"u"&&document.removeEventListener("visibilitychange",L),i.dispose(),e.container.replaceChildren()}}}function Xo(e){return e<0?Math.ceil(e):Math.floor(e)}function Af(e,t,i,s){const r=t.serialize({scrollback:cf});return!r||r.length>uf?null:{content:r,cursor:i,cols:e.cols,rows:e.rows,viewportY:e.buffer.active.viewportY,historyBeforeSeq:s.beforeSeq,historyHasOlder:s.hasOlder}}function Go(e,t){const i=Ls(t);i.length!==0&&e.write(i.map(s=>s.content).join(""))}function Zo(e,t){e.reset();const i=Ls(t);i.length!==0&&e.write(i.map(s=>s.content).join(""))}function Ls(e){if(e.length<2)return e;const t=e.map((i,s)=>({chunk:i,index:s,cursor:Number(i.cursor)}));return t.some(i=>!Number.isFinite(i.cursor))?e:[...t].sort((i,s)=>i.cursor===s.cursor?i.index-s.index:i.cursor-s.cursor).map(i=>i.chunk)}function If(e,t){const i=Ls(e);if(!t)return i;const s=Number(t);return Number.isFinite(s)?i.filter(r=>{const n=Number(r.cursor);return!Number.isFinite(n)||n>s}):i}function Nf(e,t=1){return e.buffer.active.baseY-e.buffer.active.viewportY<=t}function cl(e){return!Number.isFinite(e)||e<=0?Ko:Math.max(Ko,Math.ceil(e*Rf))}function Jo(e,t){if(!Number.isFinite(t.rows)||t.rows<=0)return 1;const i=cl(e.clientHeight),s=e.querySelector(".xterm-screen"),n=(s instanceof HTMLElement&&s.clientHeight>0?s.clientHeight:Math.max(t.rows,e.clientHeight-i))/t.rows;return!Number.isFinite(n)||n<=0?1:Math.max(1,Math.round(i/n))}function Of(e,t=0){const i=Number.isFinite(t)&&t>0?Math.round(t):0,s=e;if(typeof s.scrollToBottom=="function"){if(s.scrollToBottom(),i>0&&typeof s.scrollLines=="function"){s.scrollLines(-i);return}if(i<=0)return}e.scrollToLine(Math.max(0,e.buffer.active.baseY-i))}function Qo(e){return e.clientWidth>=df&&e.clientHeight>=ff}function Ff(e,t,i){const s=i.proposeDimensions(),r=e.querySelector(".xterm-viewport"),n=Hf(t);if(!(r instanceof HTMLElement)||!n)return s??null;const o=r.clientWidth,a=r.clientHeight;if(!Number.isFinite(o)||!Number.isFinite(a)||o<=0||a<=0||n.width<=0||n.height<=0)return s??null;const h=Math.floor(o/n.width),l=Math.floor(a/n.height);return!Number.isFinite(h)||!Number.isFinite(l)?s??null:{cols:Math.max(al,h),rows:Math.max(ll,l)}}function Hf(e){var r,n,o,a,h;const t=(o=(n=(r=ul(e))==null?void 0:r._renderService)==null?void 0:n.dimensions)==null?void 0:o.css,i=((a=t==null?void 0:t.cell)==null?void 0:a.width)??0,s=((h=t==null?void 0:t.cell)==null?void 0:h.height)??0;return!Number.isFinite(i)||!Number.isFinite(s)||i<=0||s<=0?null:{width:i,height:s}}function ul(e){return e._core??null}function ea(e,t){const i=t.background??"",s=t.foreground??"",r=t.cursor??s,n=t.cursorAccent??i,o=t.selectionBackground??"";e.style.background=i,e.style.setProperty("--terminal-theme-background",i),e.style.setProperty("--terminal-theme-foreground",s),e.style.setProperty("--terminal-theme-cursor",r),e.style.setProperty("--terminal-theme-cursor-accent",n),e.style.setProperty("--terminal-theme-selection",o)}function ta(){if(typeof window>"u")return{background:"#ffffff",foreground:"#1a1a1a",cursor:"#1a1a1a",cursorAccent:"#ffffff",selectionBackground:"rgba(0, 122, 255, 0.18)"};const e=window.getComputedStyle(document.documentElement),t=Pi(e,"--terminal-theme-background","#ffffff"),i=Pi(e,"--terminal-theme-foreground","#1a1a1a"),s=Pi(e,"--terminal-theme-cursor",i),r=Pi(e,"--terminal-theme-cursor-accent",t),n=Pi(e,"--terminal-theme-selection","rgba(0, 122, 255, 0.18)");return{background:t,foreground:i,cursor:s,cursorAccent:r,selectionBackground:n}}function Pi(e,t,i){return e.getPropertyValue(t).trim()||i}function zf(e,t){return[...e].sort((i,s)=>{const r=t.has(i.id),n=t.has(s.id);return r!==n?r?-1:1:i.createdAt!==s.createdAt?i.createdAt.localeCompare(s.createdAt):i.name!==s.name?i.name.localeCompare(s.name,"zh-CN-u-kn-true"):i.id.localeCompare(s.id)})}function Wf(e){return Array.isArray(e)?e.filter(t=>{if(!t||typeof t!="object")return!1;const i=t;return typeof i.id=="string"&&typeof i.label=="string"&&typeof i.shell=="string"&&typeof i.available=="boolean"}):[]}function us(e,t){var s;const i=t.trim();if(i){const r=e.find(n=>n.available&&n.shell===i);if(r)return r.shell}return((s=e.find(r=>r.available))==null?void 0:s.shell)??null}function ds(e,t){return e||(t==="windows"?"embedded-pty":"tmux")}function $f(e,t,i){return t||i!=="windows"?!1:e.filter(s=>s.available).length>1}function jf(e){if(e.nativeEvent.isComposing||dl(e.target)||e.metaKey||e.altKey)return!0;const t=e.currentTarget;return t instanceof HTMLElement&&t.dataset.empty==="true"}function dl(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"?!0:e.isContentEditable}function Uf(e){const t=e.key;if(!t||t==="Process"||t==="Dead"||t==="Unidentified")return null;if(e.ctrlKey)return Kf(t);if(t.length===1)return t;switch(t){case"Enter":return"\r";case"Backspace":return"";case"Tab":return" ";case"Escape":return"\x1B";case"ArrowUp":return"\x1B[A";case"ArrowDown":return"\x1B[B";case"ArrowRight":return"\x1B[C";case"ArrowLeft":return"\x1B[D";case"Home":return"\x1B[H";case"End":return"\x1B[F";case"Delete":return"\x1B[3~";case"Insert":return"\x1B[2~";case"PageUp":return"\x1B[5~";case"PageDown":return"\x1B[6~";default:return null}}function Kf(e){if(e.length===1){const t=e.toUpperCase();if(t>="A"&&t<="Z")return String.fromCharCode(t.charCodeAt(0)-64);switch(t){case"@":case" ":return"\0";case"[":return"\x1B";case"\\":return"";case"]":return"";case"^":return"";case"_":return"";default:return null}}switch(e){case"Enter":return`
51
+ `;case"Backspace":return"\b";case"Tab":return" ";default:return null}}function qf(e,t){return e.length>0?e.map(i=>({id:i.id,label:Vf(i),value:i.shell,description:i.shell,available:i.available,unavailableReason:i.unavailableReason})):t==="windows"?[{id:"cmd",label:"CMD",value:"cmd",description:"经典命令行",available:!0,unavailableReason:null},{id:"powershell",label:"PowerShell",value:"powershell",description:"适合脚本与系统管理",available:!0,unavailableReason:null},{id:"git-bash",label:"Git Bash",value:"git-bash",description:"更接近 Unix 命令体验",available:!0,unavailableReason:null}]:[{id:t==="linux"?"bash":"zsh",label:t==="linux"?"bash":"zsh",value:t==="linux"?"bash":"zsh",description:t==="linux"?"常见 Linux Shell":"macOS 常见默认 Shell",available:!0,unavailableReason:null}]}function Vf(e){if(e.id==="cmd")return"CMD";if(e.id==="powershell")return"PowerShell";if(e.id==="git-bash")return"Git Bash";if(e.id==="default"){const t=e.shell.split(/[\\/]/);return(t[t.length-1]??e.shell).replace(/\.exe$/i,"")||e.label}return e.label}function Yf(e){return e==="running"?"session-state-indicator is-running":e==="creating"?"session-state-indicator is-running-inferred":e==="error"?"session-state-indicator is-subagent-running":"session-state-indicator is-idle"}function un(e){return Math.min(mf,Math.max(_f,e))}function fl(e,t,i){return Math.min(i,Math.max(t,e))}function ia(e){return Math.round(hf*un(e)*10)/10}function Xf(e){return`${Math.round(un(e)*100)}%`}function Gf(e){var i;const t=Ki(e.terminalId,e.paneBindings,e.splitDirection,"primary");if(t){const s=((i=e.paneApiById[t])==null?void 0:i.readPlainText())??"";if(s.trim())return s}return Zf(e.terminalId)}function Zf(e){const t=Xr(e).viewState;return t?Jf(t.content):""}function Jf(e){return e.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g,"").replace(/\u001b\][^\u0007]*(?:\u0007|\u001b\\)/g,"").replace(/\u001bP[\s\S]*?\u001b\\/g,"").replace(/\r/g,"")}function sa(e){const t=[];for(let i=0;i<e.buffer.active.length;i+=1){const s=e.buffer.active.getLine(i);s&&t.push(s.translateToString(!0))}return t.join(`
52
+ `).trimEnd()}function Qf(e,t){const i=Ts(e),s=Ts(t);return i?s?`${i}
53
+ ${s}`:i:s}function Ts(e){return e.replace(/\r/g,"").replace(/\n+$/g,"").trimEnd()}function e_(e){return e.replace(/\r?\n/g,`\r
54
+ `)}function _l(e){const t=Ts(e);return t?t.split(`
55
+ `).length:0}function fs(e){const t=new Set(e.terminals.map(r=>r.id));let i=e.currentBindings.primary&&t.has(e.currentBindings.primary)?e.currentBindings.primary:null,s=e.splitDirection!=="single"&&e.currentBindings.secondary&&t.has(e.currentBindings.secondary)?e.currentBindings.secondary:null;return e.fallbackTerminalId&&t.has(e.fallbackTerminalId)&&(e.preferredPaneId==="secondary"&&e.splitDirection!=="single"?(s=e.fallbackTerminalId,i=i??Gr(e.terminals,s)??s):i=e.fallbackTerminalId),i=i??ml(e.terminals),e.splitDirection==="single"?{primary:i,secondary:null}:(s=s??Gr(e.terminals,i),{primary:i,secondary:s})}function dn(e){if(e.terminal.status!=="running")return e.terminal.status;const t=t_(e.terminal.id,e.paneBindings,e.paneConnectionStates);return t.includes("connected")?"running":t.includes("reconnecting")?"creating":t.length>0||e.manuallyDisconnectedTerminalIdSet.has(e.terminal.id)?"disconnected":"running"}function t_(e,t,i){const s=[];return t.primary===e&&s.push(i.primary),t.secondary===e&&s.push(i.secondary),s}function ml(e){var t,i;return((t=e.find(s=>s.status==="running"))==null?void 0:t.id)??((i=e[0])==null?void 0:i.id)??null}function Gr(e,t){var i;return((i=e.find(s=>s.id!==t))==null?void 0:i.id)??null}function i_(e,t,i){return t.primary===e?!0:i!=="single"&&t.secondary===e}function Ki(e,t,i,s){return t[s]===e?s:t.primary===e?"primary":i!=="single"&&t.secondary===e?"secondary":null}function cr(e){return`terminal-mutation-${e}`}function ra(e){return`terminal-manager.snapshot.${e}`}function s_(){return new Promise(e=>{window.setTimeout(e,pf)})}function r_(e,t){if(typeof document>"u")throw new Error(w("terminal.saveLogFailed"));const i=new Blob([t],{type:"text/plain;charset=utf-8"}),s=window.URL.createObjectURL(i),r=document.createElement("a");r.href=s,r.download=e,document.body.append(r),r.click(),r.remove(),window.URL.revokeObjectURL(s)}function n_(e){return e.trim().replace(/[\\/:*?"<>|]+/g,"-")||"terminal"}function o_(e,t){const i=e.findIndex(r=>r.id===t.id);if(i===-1)return[...e,t];const s=[...e];return s[i]=t,s}export{x_ as TerminalPage,Uf as translateKeyboardEventToTerminalInput};