dsh-zterm 0.1.19 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -1,17 +1,17 @@
1
1
  window.__ModuleLoader__.load({ id: "dsh-zterm", factory: (require) => { var module = { exports: {} }; var exports = module.exports;
2
- "use strict";var Oi=Object.create;var pt=Object.defineProperty;var Pi=Object.getOwnPropertyDescriptor;var zi=Object.getOwnPropertyNames;var Hi=Object.getPrototypeOf,Fi=Object.prototype.hasOwnProperty;var Ht=(w,S)=>()=>(S||w((S={exports:{}}).exports,S),S.exports),Ni=(w,S)=>{for(var A in S)pt(w,A,{get:S[A],enumerable:!0})},Zt=(w,S,A,B)=>{if(S&&typeof S=="object"||typeof S=="function")for(let D of zi(S))!Fi.call(w,D)&&D!==A&&pt(w,D,{get:()=>S[D],enumerable:!(B=Pi(S,D))||B.enumerable});return w};var Ft=(w,S,A)=>(A=w!=null?Oi(Hi(w)):{},Zt(S||!w||!w.__esModule?pt(A,"default",{value:w,enumerable:!0}):A,w)),Wi=w=>Zt(pt({},"__esModule",{value:!0}),w);var ri=Ht((mt,Nt)=>{(function(w,S){if(typeof mt=="object"&&typeof Nt=="object")Nt.exports=S();else if(typeof define=="function"&&define.amd)define([],S);else{var A=S();for(var B in A)(typeof mt=="object"?mt:w)[B]=A[B]}})(globalThis,(()=>(()=>{"use strict";var w={4567:function(D,r,o){var c=this&&this.__decorate||function(e,s,d,g){var p,v=arguments.length,f=v<3?s:g===null?g=Object.getOwnPropertyDescriptor(s,d):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(e,s,d,g);else for(var m=e.length-1;m>=0;m--)(p=e[m])&&(f=(v<3?p(f):v>3?p(s,d,f):p(s,d))||f);return v>3&&f&&Object.defineProperty(s,d,f),f},u=this&&this.__param||function(e,s){return function(d,g){s(d,g,e)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;let n=o(9042),a=o(9924),h=o(844),_=o(4725),l=o(2585),i=o(3656),t=r.AccessibilityManager=class extends h.Disposable{constructor(e,s,d,g){super(),this._terminal=e,this._coreBrowserService=d,this._renderService=g,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let p=0;p<this._terminal.rows;p++)this._rowElements[p]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[p]);if(this._topBoundaryFocusListener=p=>this._handleBoundaryFocus(p,0),this._bottomBoundaryFocusListener=p=>this._handleBoundaryFocus(p,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new a.TimeBasedDebouncer(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((p=>this._handleResize(p.rows)))),this.register(this._terminal.onRender((p=>this._refreshRows(p.start,p.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((p=>this._handleChar(p)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
3
- `)))),this.register(this._terminal.onA11yTab((p=>this._handleTab(p)))),this.register(this._terminal.onKey((p=>this._handleKey(p.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,i.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,h.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(e){for(let s=0;s<e;s++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
4
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=n.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,s){this._liveRegionDebouncer.refresh(e,s,this._terminal.rows)}_renderRows(e,s){let d=this._terminal.buffer,g=d.lines.length.toString();for(let p=e;p<=s;p++){let v=d.lines.get(d.ydisp+p),f=[],m=v?.translateToString(!0,void 0,void 0,f)||"",E=(d.ydisp+p+1).toString(),k=this._rowElements[p];k&&(m.length===0?(k.innerText="\xA0",this._rowColumns.set(k,[0,1])):(k.textContent=m,this._rowColumns.set(k,f)),k.setAttribute("aria-posinset",E),k.setAttribute("aria-setsize",g))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,s){let d=e.target,g=this._rowElements[s===0?1:this._rowElements.length-2];if(d.getAttribute("aria-posinset")===(s===0?"1":`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==g)return;let p,v;if(s===0?(p=d,v=this._rowElements.pop(),this._rowContainer.removeChild(v)):(p=this._rowElements.shift(),v=d,this._rowContainer.removeChild(p)),p.removeEventListener("focus",this._topBoundaryFocusListener),v.removeEventListener("focus",this._bottomBoundaryFocusListener),s===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(s===0?-1:1),this._rowElements[s===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=document.getSelection();if(!e)return;if(e.isCollapsed)return void(this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection());if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let s={node:e.anchorNode,offset:e.anchorOffset},d={node:e.focusNode,offset:e.focusOffset};if((s.node.compareDocumentPosition(d.node)&Node.DOCUMENT_POSITION_PRECEDING||s.node===d.node&&s.offset>d.offset)&&([s,d]=[d,s]),s.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(s={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(s.node))return;let g=this._rowElements.slice(-1)[0];if(d.node.compareDocumentPosition(g)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(d={node:g,offset:g.textContent?.length??0}),!this._rowContainer.contains(d.node))return;let p=({node:m,offset:E})=>{let k=m instanceof Text?m.parentNode:m,x=parseInt(k?.getAttribute("aria-posinset"),10)-1;if(isNaN(x))return console.warn("row is invalid. Race condition?"),null;let C=this._rowColumns.get(k);if(!C)return console.warn("columns is null. Race condition?"),null;let M=E<C.length?C[E]:C.slice(-1)[0]+1;return M>=this._terminal.cols&&(++x,M=0),{row:x,column:M}},v=p(s),f=p(d);if(v&&f){if(v.row>f.row||v.row===f.row&&v.column>=f.column)throw new Error("invalid range");this._terminal.select(v.column,v.row,(f.row-v.row)*this._terminal.cols-v.column+f.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let s=this._rowContainer.children.length;s<this._terminal.rows;s++)this._rowElements[s]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[s]);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){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}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])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}};r.AccessibilityManager=t=c([u(1,l.IInstantiationService),u(2,_.ICoreBrowserService),u(3,_.IRenderService)],t)},3614:(D,r)=>{function o(a){return a.replace(/\r?\n/g,"\r")}function c(a,h){return h?"\x1B[200~"+a+"\x1B[201~":a}function u(a,h,_,l){a=c(a=o(a),_.decPrivateModes.bracketedPasteMode&&l.rawOptions.ignoreBracketedPasteMode!==!0),_.triggerDataEvent(a,!0),h.value=""}function n(a,h,_){let l=_.getBoundingClientRect(),i=a.clientX-l.left-10,t=a.clientY-l.top-10;h.style.width="20px",h.style.height="20px",h.style.left=`${i}px`,h.style.top=`${t}px`,h.style.zIndex="1000",h.focus()}Object.defineProperty(r,"__esModule",{value:!0}),r.rightClickHandler=r.moveTextAreaUnderMouseCursor=r.paste=r.handlePasteEvent=r.copyHandler=r.bracketTextForPaste=r.prepareTextForTerminal=void 0,r.prepareTextForTerminal=o,r.bracketTextForPaste=c,r.copyHandler=function(a,h){a.clipboardData&&a.clipboardData.setData("text/plain",h.selectionText),a.preventDefault()},r.handlePasteEvent=function(a,h,_,l){a.stopPropagation(),a.clipboardData&&u(a.clipboardData.getData("text/plain"),h,_,l)},r.paste=u,r.moveTextAreaUnderMouseCursor=n,r.rightClickHandler=function(a,h,_,l,i){n(a,h,_),i&&l.rightClickSelect(a),h.value=l.selectionText,h.select()}},7239:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorContrastCache=void 0;let c=o(1505);r.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(u,n,a){this._css.set(u,n,a)}getCss(u,n){return this._css.get(u,n)}setColor(u,n,a){this._color.set(u,n,a)}getColor(u,n){return this._color.get(u,n)}clear(){this._color.clear(),this._css.clear()}}},3656:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.addDisposableDomListener=void 0,r.addDisposableDomListener=function(o,c,u,n){o.addEventListener(c,u,n);let a=!1;return{dispose:()=>{a||(a=!0,o.removeEventListener(c,u,n))}}}},3551:function(D,r,o){var c=this&&this.__decorate||function(t,e,s,d){var g,p=arguments.length,v=p<3?e:d===null?d=Object.getOwnPropertyDescriptor(e,s):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(t,e,s,d);else for(var f=t.length-1;f>=0;f--)(g=t[f])&&(v=(p<3?g(v):p>3?g(e,s,v):g(e,s))||v);return p>3&&v&&Object.defineProperty(e,s,v),v},u=this&&this.__param||function(t,e){return function(s,d){e(s,d,t)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Linkifier=void 0;let n=o(3656),a=o(8460),h=o(844),_=o(2585),l=o(4725),i=r.Linkifier=class extends h.Disposable{get currentLink(){return this._currentLink}constructor(t,e,s,d,g){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=d,this._linkProviderService=g,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new a.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new a.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,h.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,h.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,n.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,n.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,n.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,n.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let s=t.composedPath();for(let d=0;d<s.length;d++){let g=s[d];if(g.classList.contains("xterm"))break;if(g.classList.contains("xterm-hover"))return}this._lastBufferCell&&e.x===this._lastBufferCell.x&&e.y===this._lastBufferCell.y||(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(t,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){this._activeProviderReplies&&e||(this._activeProviderReplies?.forEach((d=>{d?.forEach((g=>{g.link.dispose&&g.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[d,g]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(d)&&(s=this._checkLinkProviderResult(d,t,s)):g.provideLinks(t.y,(p=>{if(this._isMouseOut)return;let v=p?.map((f=>({link:f})));this._activeProviderReplies?.set(d,v),s=this._checkLinkProviderResult(d,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)}))}_removeIntersectingLinks(t,e){let s=new Set;for(let d=0;d<e.size;d++){let g=e.get(d);if(g)for(let p=0;p<g.length;p++){let v=g[p],f=v.link.range.start.y<t?0:v.link.range.start.x,m=v.link.range.end.y>t?this._bufferService.cols:v.link.range.end.x;for(let E=f;E<=m;E++){if(s.has(E)){g.splice(p--,1);break}s.add(E)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let d=this._activeProviderReplies.get(t),g=!1;for(let p=0;p<t;p++)this._activeProviderReplies.has(p)&&!this._activeProviderReplies.get(p)||(g=!0);if(!g&&d){let p=d.find((v=>this._linkAtPosition(v.link,e)));p&&(s=!0,this._handleNewLink(p))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let p=0;p<this._activeProviderReplies.size;p++){let v=this._activeProviderReplies.get(p)?.find((f=>this._linkAtPosition(f.link,e)));if(v){s=!0,this._handleNewLink(v);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){this._currentLink&&this._lastMouseEvent&&(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,h.disposeArray)(this._linkCacheDisposables))}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0||t.link.decorations.underline,pointerCursor:t.link.decorations===void 0||t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((s=>{if(!this._currentLink)return;let d=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,g=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=d&&this._currentLink.link.range.end.y<=g&&(this._clearCurrentLink(d,g),this._lastMouseEvent)){let p=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);p&&this._askForLink(p,!1)}}))))}_linkHover(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(s,e.text)}_fireUnderlineEvent(t,e){let s=t.range,d=this._bufferService.buffer.ydisp,g=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-d-1,s.end.x,s.end.y-d-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(g)}_linkLeave(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(s,e.text)}_linkAtPosition(t,e){let s=t.range.start.y*this._bufferService.cols+t.range.start.x,d=t.range.end.y*this._bufferService.cols+t.range.end.x,g=e.y*this._bufferService.cols+e.x;return s<=g&&g<=d}_positionFromMouseEvent(t,e,s){let d=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(d)return{x:d[0],y:d[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,d,g){return{x1:t,y1:e,x2:s,y2:d,cols:this._bufferService.cols,fg:g}}};r.Linkifier=i=c([u(1,l.IMouseService),u(2,l.IRenderService),u(3,_.IBufferService),u(4,l.ILinkProviderService)],i)},9042:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tooMuchOutput=r.promptLabel=void 0,r.promptLabel="Terminal input",r.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(D,r,o){var c=this&&this.__decorate||function(l,i,t,e){var s,d=arguments.length,g=d<3?i:e===null?e=Object.getOwnPropertyDescriptor(i,t):e;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")g=Reflect.decorate(l,i,t,e);else for(var p=l.length-1;p>=0;p--)(s=l[p])&&(g=(d<3?s(g):d>3?s(i,t,g):s(i,t))||g);return d>3&&g&&Object.defineProperty(i,t,g),g},u=this&&this.__param||function(l,i){return function(t,e){i(t,e,l)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkProvider=void 0;let n=o(511),a=o(2585),h=r.OscLinkProvider=class{constructor(l,i,t){this._bufferService=l,this._optionsService=i,this._oscLinkService=t}provideLinks(l,i){let t=this._bufferService.buffer.lines.get(l-1);if(!t)return void i(void 0);let e=[],s=this._optionsService.rawOptions.linkHandler,d=new n.CellData,g=t.getTrimmedLength(),p=-1,v=-1,f=!1;for(let m=0;m<g;m++)if(v!==-1||t.hasContent(m)){if(t.loadCell(m,d),d.hasExtendedAttrs()&&d.extended.urlId){if(v===-1){v=m,p=d.extended.urlId;continue}f=d.extended.urlId!==p}else v!==-1&&(f=!0);if(f||v!==-1&&m===g-1){let E=this._oscLinkService.getLinkData(p)?.uri;if(E){let k={start:{x:v+1,y:l},end:{x:m+(f||m!==g-1?0:1),y:l}},x=!1;if(!s?.allowNonHttpProtocols)try{let C=new URL(E);["http:","https:"].includes(C.protocol)||(x=!0)}catch{x=!0}x||e.push({text:E,range:k,activate:(C,M)=>s?s.activate(C,M,k):_(0,M),hover:(C,M)=>s?.hover?.(C,M,k),leave:(C,M)=>s?.leave?.(C,M,k)})}f=!1,d.hasExtendedAttrs()&&d.extended.urlId?(v=m,p=d.extended.urlId):(v=-1,p=-1)}}i(e)}};function _(l,i){if(confirm(`Do you want to navigate to ${i}?
2
+ "use strict";var $i=Object.create;var pt=Object.defineProperty;var Ui=Object.getOwnPropertyDescriptor;var ji=Object.getOwnPropertyNames;var qi=Object.getPrototypeOf,Ki=Object.prototype.hasOwnProperty;var Ht=(y,S)=>()=>(S||y((S={exports:{}}).exports,S),S.exports),Vi=(y,S)=>{for(var T in S)pt(y,T,{get:S[T],enumerable:!0})},Qt=(y,S,T,M)=>{if(S&&typeof S=="object"||typeof S=="function")for(let x of ji(S))!Ki.call(y,x)&&x!==T&&pt(y,x,{get:()=>S[x],enumerable:!(M=Ui(S,x))||M.enumerable});return y};var Nt=(y,S,T)=>(T=y!=null?$i(qi(y)):{},Qt(S||!y||!y.__esModule?pt(T,"default",{value:y,enumerable:!0}):T,y)),Ji=y=>Qt(pt({},"__esModule",{value:!0}),y);var si=Ht((mt,Ft)=>{(function(y,S){if(typeof mt=="object"&&typeof Ft=="object")Ft.exports=S();else if(typeof define=="function"&&define.amd)define([],S);else{var T=S();for(var M in T)(typeof mt=="object"?mt:y)[M]=T[M]}})(globalThis,(()=>(()=>{"use strict";var y={4567:function(x,r,n){var h=this&&this.__decorate||function(e,s,d,p){var g,v=arguments.length,f=v<3?s:p===null?p=Object.getOwnPropertyDescriptor(s,d):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(e,s,d,p);else for(var m=e.length-1;m>=0;m--)(g=e[m])&&(f=(v<3?g(f):v>3?g(s,d,f):g(s,d))||f);return v>3&&f&&Object.defineProperty(s,d,f),f},u=this&&this.__param||function(e,s){return function(d,p){s(d,p,e)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;let o=n(9042),a=n(9924),c=n(844),_=n(4725),l=n(2585),i=n(3656),t=r.AccessibilityManager=class extends c.Disposable{constructor(e,s,d,p){super(),this._terminal=e,this._coreBrowserService=d,this._renderService=p,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let g=0;g<this._terminal.rows;g++)this._rowElements[g]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[g]);if(this._topBoundaryFocusListener=g=>this._handleBoundaryFocus(g,0),this._bottomBoundaryFocusListener=g=>this._handleBoundaryFocus(g,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new a.TimeBasedDebouncer(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((g=>this._handleResize(g.rows)))),this.register(this._terminal.onRender((g=>this._refreshRows(g.start,g.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((g=>this._handleChar(g)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
3
+ `)))),this.register(this._terminal.onA11yTab((g=>this._handleTab(g)))),this.register(this._terminal.onKey((g=>this._handleKey(g.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,i.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,c.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(e){for(let s=0;s<e;s++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
4
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=o.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,s){this._liveRegionDebouncer.refresh(e,s,this._terminal.rows)}_renderRows(e,s){let d=this._terminal.buffer,p=d.lines.length.toString();for(let g=e;g<=s;g++){let v=d.lines.get(d.ydisp+g),f=[],m=v?.translateToString(!0,void 0,void 0,f)||"",L=(d.ydisp+g+1).toString(),k=this._rowElements[g];k&&(m.length===0?(k.innerText="\xA0",this._rowColumns.set(k,[0,1])):(k.textContent=m,this._rowColumns.set(k,f)),k.setAttribute("aria-posinset",L),k.setAttribute("aria-setsize",p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,s){let d=e.target,p=this._rowElements[s===0?1:this._rowElements.length-2];if(d.getAttribute("aria-posinset")===(s===0?"1":`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==p)return;let g,v;if(s===0?(g=d,v=this._rowElements.pop(),this._rowContainer.removeChild(v)):(g=this._rowElements.shift(),v=d,this._rowContainer.removeChild(g)),g.removeEventListener("focus",this._topBoundaryFocusListener),v.removeEventListener("focus",this._bottomBoundaryFocusListener),s===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(s===0?-1:1),this._rowElements[s===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=document.getSelection();if(!e)return;if(e.isCollapsed)return void(this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection());if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let s={node:e.anchorNode,offset:e.anchorOffset},d={node:e.focusNode,offset:e.focusOffset};if((s.node.compareDocumentPosition(d.node)&Node.DOCUMENT_POSITION_PRECEDING||s.node===d.node&&s.offset>d.offset)&&([s,d]=[d,s]),s.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(s={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(s.node))return;let p=this._rowElements.slice(-1)[0];if(d.node.compareDocumentPosition(p)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(d={node:p,offset:p.textContent?.length??0}),!this._rowContainer.contains(d.node))return;let g=({node:m,offset:L})=>{let k=m instanceof Text?m.parentNode:m,E=parseInt(k?.getAttribute("aria-posinset"),10)-1;if(isNaN(E))return console.warn("row is invalid. Race condition?"),null;let C=this._rowColumns.get(k);if(!C)return console.warn("columns is null. Race condition?"),null;let B=L<C.length?C[L]:C.slice(-1)[0]+1;return B>=this._terminal.cols&&(++E,B=0),{row:E,column:B}},v=g(s),f=g(d);if(v&&f){if(v.row>f.row||v.row===f.row&&v.column>=f.column)throw new Error("invalid range");this._terminal.select(v.column,v.row,(f.row-v.row)*this._terminal.cols-v.column+f.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let s=this._rowContainer.children.length;s<this._terminal.rows;s++)this._rowElements[s]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[s]);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){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}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])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}};r.AccessibilityManager=t=h([u(1,l.IInstantiationService),u(2,_.ICoreBrowserService),u(3,_.IRenderService)],t)},3614:(x,r)=>{function n(a){return a.replace(/\r?\n/g,"\r")}function h(a,c){return c?"\x1B[200~"+a+"\x1B[201~":a}function u(a,c,_,l){a=h(a=n(a),_.decPrivateModes.bracketedPasteMode&&l.rawOptions.ignoreBracketedPasteMode!==!0),_.triggerDataEvent(a,!0),c.value=""}function o(a,c,_){let l=_.getBoundingClientRect(),i=a.clientX-l.left-10,t=a.clientY-l.top-10;c.style.width="20px",c.style.height="20px",c.style.left=`${i}px`,c.style.top=`${t}px`,c.style.zIndex="1000",c.focus()}Object.defineProperty(r,"__esModule",{value:!0}),r.rightClickHandler=r.moveTextAreaUnderMouseCursor=r.paste=r.handlePasteEvent=r.copyHandler=r.bracketTextForPaste=r.prepareTextForTerminal=void 0,r.prepareTextForTerminal=n,r.bracketTextForPaste=h,r.copyHandler=function(a,c){a.clipboardData&&a.clipboardData.setData("text/plain",c.selectionText),a.preventDefault()},r.handlePasteEvent=function(a,c,_,l){a.stopPropagation(),a.clipboardData&&u(a.clipboardData.getData("text/plain"),c,_,l)},r.paste=u,r.moveTextAreaUnderMouseCursor=o,r.rightClickHandler=function(a,c,_,l,i){o(a,c,_),i&&l.rightClickSelect(a),c.value=l.selectionText,c.select()}},7239:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorContrastCache=void 0;let h=n(1505);r.ColorContrastCache=class{constructor(){this._color=new h.TwoKeyMap,this._css=new h.TwoKeyMap}setCss(u,o,a){this._css.set(u,o,a)}getCss(u,o){return this._css.get(u,o)}setColor(u,o,a){this._color.set(u,o,a)}getColor(u,o){return this._color.get(u,o)}clear(){this._color.clear(),this._css.clear()}}},3656:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.addDisposableDomListener=void 0,r.addDisposableDomListener=function(n,h,u,o){n.addEventListener(h,u,o);let a=!1;return{dispose:()=>{a||(a=!0,n.removeEventListener(h,u,o))}}}},3551:function(x,r,n){var h=this&&this.__decorate||function(t,e,s,d){var p,g=arguments.length,v=g<3?e:d===null?d=Object.getOwnPropertyDescriptor(e,s):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(t,e,s,d);else for(var f=t.length-1;f>=0;f--)(p=t[f])&&(v=(g<3?p(v):g>3?p(e,s,v):p(e,s))||v);return g>3&&v&&Object.defineProperty(e,s,v),v},u=this&&this.__param||function(t,e){return function(s,d){e(s,d,t)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Linkifier=void 0;let o=n(3656),a=n(8460),c=n(844),_=n(2585),l=n(4725),i=r.Linkifier=class extends c.Disposable{get currentLink(){return this._currentLink}constructor(t,e,s,d,p){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=d,this._linkProviderService=p,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new a.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new a.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,c.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,c.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,o.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,o.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let s=t.composedPath();for(let d=0;d<s.length;d++){let p=s[d];if(p.classList.contains("xterm"))break;if(p.classList.contains("xterm-hover"))return}this._lastBufferCell&&e.x===this._lastBufferCell.x&&e.y===this._lastBufferCell.y||(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(t,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){this._activeProviderReplies&&e||(this._activeProviderReplies?.forEach((d=>{d?.forEach((p=>{p.link.dispose&&p.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[d,p]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(d)&&(s=this._checkLinkProviderResult(d,t,s)):p.provideLinks(t.y,(g=>{if(this._isMouseOut)return;let v=g?.map((f=>({link:f})));this._activeProviderReplies?.set(d,v),s=this._checkLinkProviderResult(d,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)}))}_removeIntersectingLinks(t,e){let s=new Set;for(let d=0;d<e.size;d++){let p=e.get(d);if(p)for(let g=0;g<p.length;g++){let v=p[g],f=v.link.range.start.y<t?0:v.link.range.start.x,m=v.link.range.end.y>t?this._bufferService.cols:v.link.range.end.x;for(let L=f;L<=m;L++){if(s.has(L)){p.splice(g--,1);break}s.add(L)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let d=this._activeProviderReplies.get(t),p=!1;for(let g=0;g<t;g++)this._activeProviderReplies.has(g)&&!this._activeProviderReplies.get(g)||(p=!0);if(!p&&d){let g=d.find((v=>this._linkAtPosition(v.link,e)));g&&(s=!0,this._handleNewLink(g))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let g=0;g<this._activeProviderReplies.size;g++){let v=this._activeProviderReplies.get(g)?.find((f=>this._linkAtPosition(f.link,e)));if(v){s=!0,this._handleNewLink(v);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){this._currentLink&&this._lastMouseEvent&&(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,c.disposeArray)(this._linkCacheDisposables))}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0||t.link.decorations.underline,pointerCursor:t.link.decorations===void 0||t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((s=>{if(!this._currentLink)return;let d=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,p=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=d&&this._currentLink.link.range.end.y<=p&&(this._clearCurrentLink(d,p),this._lastMouseEvent)){let g=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);g&&this._askForLink(g,!1)}}))))}_linkHover(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(s,e.text)}_fireUnderlineEvent(t,e){let s=t.range,d=this._bufferService.buffer.ydisp,p=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-d-1,s.end.x,s.end.y-d-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(p)}_linkLeave(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(s,e.text)}_linkAtPosition(t,e){let s=t.range.start.y*this._bufferService.cols+t.range.start.x,d=t.range.end.y*this._bufferService.cols+t.range.end.x,p=e.y*this._bufferService.cols+e.x;return s<=p&&p<=d}_positionFromMouseEvent(t,e,s){let d=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(d)return{x:d[0],y:d[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,d,p){return{x1:t,y1:e,x2:s,y2:d,cols:this._bufferService.cols,fg:p}}};r.Linkifier=i=h([u(1,l.IMouseService),u(2,l.IRenderService),u(3,_.IBufferService),u(4,l.ILinkProviderService)],i)},9042:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tooMuchOutput=r.promptLabel=void 0,r.promptLabel="Terminal input",r.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(x,r,n){var h=this&&this.__decorate||function(l,i,t,e){var s,d=arguments.length,p=d<3?i:e===null?e=Object.getOwnPropertyDescriptor(i,t):e;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(l,i,t,e);else for(var g=l.length-1;g>=0;g--)(s=l[g])&&(p=(d<3?s(p):d>3?s(i,t,p):s(i,t))||p);return d>3&&p&&Object.defineProperty(i,t,p),p},u=this&&this.__param||function(l,i){return function(t,e){i(t,e,l)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkProvider=void 0;let o=n(511),a=n(2585),c=r.OscLinkProvider=class{constructor(l,i,t){this._bufferService=l,this._optionsService=i,this._oscLinkService=t}provideLinks(l,i){let t=this._bufferService.buffer.lines.get(l-1);if(!t)return void i(void 0);let e=[],s=this._optionsService.rawOptions.linkHandler,d=new o.CellData,p=t.getTrimmedLength(),g=-1,v=-1,f=!1;for(let m=0;m<p;m++)if(v!==-1||t.hasContent(m)){if(t.loadCell(m,d),d.hasExtendedAttrs()&&d.extended.urlId){if(v===-1){v=m,g=d.extended.urlId;continue}f=d.extended.urlId!==g}else v!==-1&&(f=!0);if(f||v!==-1&&m===p-1){let L=this._oscLinkService.getLinkData(g)?.uri;if(L){let k={start:{x:v+1,y:l},end:{x:m+(f||m!==p-1?0:1),y:l}},E=!1;if(!s?.allowNonHttpProtocols)try{let C=new URL(L);["http:","https:"].includes(C.protocol)||(E=!0)}catch{E=!0}E||e.push({text:L,range:k,activate:(C,B)=>s?s.activate(C,B,k):_(0,B),hover:(C,B)=>s?.hover?.(C,B,k),leave:(C,B)=>s?.leave?.(C,B,k)})}f=!1,d.hasExtendedAttrs()&&d.extended.urlId?(v=m,g=d.extended.urlId):(v=-1,g=-1)}}i(e)}};function _(l,i){if(confirm(`Do you want to navigate to ${i}?
5
5
 
6
- WARNING: This link could potentially be dangerous`)){let t=window.open();if(t){try{t.opener=null}catch{}t.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}}r.OscLinkProvider=h=c([u(0,a.IBufferService),u(1,a.IOptionsService),u(2,a.IOscLinkService)],h)},6193:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.RenderDebouncer=void 0,r.RenderDebouncer=class{constructor(o,c){this._renderCallback=o,this._coreBrowserService=c,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(o,c,u){this._rowCount=u,o=o!==void 0?o:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c,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)return void this._runRefreshCallbacks();let o=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},3236:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Terminal=void 0;let c=o(3614),u=o(3656),n=o(3551),a=o(9042),h=o(3730),_=o(1680),l=o(3107),i=o(5744),t=o(2950),e=o(1296),s=o(428),d=o(4269),g=o(5114),p=o(8934),v=o(3230),f=o(9312),m=o(4725),E=o(6731),k=o(8055),x=o(8969),C=o(8460),M=o(844),z=o(6114),j=o(8437),U=o(2584),$=o(7399),b=o(5941),L=o(9074),R=o(2585),T=o(5435),H=o(4567),q=o(779);class X extends x.CoreTerminal{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}constructor(I={}){super(I),this.browser=z,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new M.MutableDisposable),this._onCursorMove=this.register(new C.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new C.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new C.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new C.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new C.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new C.EventEmitter),this._onBlur=this.register(new C.EventEmitter),this._onA11yCharEmitter=this.register(new C.EventEmitter),this._onA11yTabEmitter=this.register(new C.EventEmitter),this._onWillOpen=this.register(new C.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(L.DecorationService),this._instantiationService.setService(R.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(q.LinkProviderService),this._instantiationService.setService(m.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(h.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((y,F)=>this.refresh(y,F)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((y=>this._reportWindowsOptions(y)))),this.register(this._inputHandler.onColor((y=>this._handleColorEvent(y)))),this.register((0,C.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,C.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((y=>this._afterResize(y.cols,y.rows)))),this.register((0,M.toDisposable)((()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)})))}_handleColorEvent(I){if(this._themeService)for(let y of I){let F,N="";switch(y.index){case 256:F="foreground",N="10";break;case 257:F="background",N="11";break;case 258:F="cursor",N="12";break;default:F="ansi",N="4;"+y.index}switch(y.type){case 0:let K=k.color.toColorRGB(F==="ansi"?this._themeService.colors.ansi[y.index]:this._themeService.colors[F]);this.coreService.triggerDataEvent(`${U.C0.ESC}]${N};${(0,b.toRgbString)(K)}${U.C1_ESCAPED.ST}`);break;case 1:if(F==="ansi")this._themeService.modifyColors((V=>V.ansi[y.index]=k.channels.toColor(...y.color)));else{let V=F;this._themeService.modifyColors((ie=>ie[V]=k.channels.toColor(...y.color)))}break;case 2:this._themeService.restoreColor(y.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(I){I?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(H.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(I){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let I=this.buffer.ybase+this.buffer.y,y=this.buffer.lines.get(I);if(!y)return;let F=Math.min(this.buffer.x,this.cols-1),N=this._renderService.dimensions.css.cell.height,K=y.getWidth(F),V=this._renderService.dimensions.css.cell.width*K,ie=this.buffer.y*this._renderService.dimensions.css.cell.height,he=F*this._renderService.dimensions.css.cell.width;this.textarea.style.left=he+"px",this.textarea.style.top=ie+"px",this.textarea.style.width=V+"px",this.textarea.style.height=N+"px",this.textarea.style.lineHeight=N+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(y=>{this.hasSelection()&&(0,c.copyHandler)(y,this._selectionService)})));let I=y=>(0,c.handlePasteEvent)(y,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",I)),this.register((0,u.addDisposableDomListener)(this.element,"paste",I)),z.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(y=>{y.button===2&&(0,c.rightClickHandler)(y,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(y=>{(0,c.rightClickHandler)(y,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),z.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(y=>{y.button===1&&(0,c.moveTextAreaUnderMouseCursor)(y,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(I=>this._keyUp(I)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(I=>this._keyDown(I)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(I=>this._keyPress(I)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(I=>this._compositionHelper.compositionupdate(I)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(I=>this._inputEvent(I)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(I){if(!I)throw new Error("Terminal requires a parent element.");if(I.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=I.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"),I.appendChild(this.element);let y=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),y.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,u.addDisposableDomListener)(this.screenElement,"mousemove",(F=>this.updateCursorStyle(F)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),y.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",a.promptLabel),z.isChromeOS||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._coreBrowserService=this.register(this._instantiationService.createInstance(g.CoreBrowserService,this.textarea,I.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(m.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(F=>this._handleTextAreaFocus(F)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(s.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(m.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(E.ThemeService),this._instantiationService.setService(m.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(d.CharacterJoinerService),this._instantiationService.setService(m.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(v.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(m.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((F=>this._onRender.fire(F)))),this.onResize((F=>this._renderService.resize(F.cols,F.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(t.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(p.MouseService),this._instantiationService.setService(m.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(n.Linkifier,this.screenElement)),this.element.appendChild(y);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(_.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((F=>this.scrollLines(F.amount,F.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),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.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(f.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(m.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((F=>this.scrollLines(F.amount,F.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((F=>this._renderService.handleSelectionChanged(F.start,F.end,F.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((F=>{this.textarea.value=F,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((F=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(l.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(F=>this._selectionService.handleMouseDown(F)))),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(H.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(F=>this._handleScreenReaderModeOptionChange(F)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(i.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(F=>{!this._overviewRulerRenderer&&F&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(i.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(e.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let I=this,y=this.element;function F(V){let ie=I._mouseService.getMouseReportCoords(V,I.screenElement);if(!ie)return!1;let he,le;switch(V.overrideType||V.type){case"mousemove":le=32,V.buttons===void 0?(he=3,V.button!==void 0&&(he=V.button<3?V.button:3)):he=1&V.buttons?0:4&V.buttons?1:2&V.buttons?2:3;break;case"mouseup":le=0,he=V.button<3?V.button:3;break;case"mousedown":le=1,he=V.button<3?V.button:3;break;case"wheel":if(I._customWheelEventHandler&&I._customWheelEventHandler(V)===!1||I.viewport.getLinesScrolled(V)===0)return!1;le=V.deltaY<0?0:1,he=4;break;default:return!1}return!(le===void 0||he===void 0||he>4)&&I.coreMouseService.triggerMouseEvent({col:ie.col,row:ie.row,x:ie.x,y:ie.y,button:he,action:le,ctrl:V.ctrlKey,alt:V.altKey,shift:V.shiftKey})}let N={mouseup:null,wheel:null,mousedrag:null,mousemove:null},K={mouseup:V=>(F(V),V.buttons||(this._document.removeEventListener("mouseup",N.mouseup),N.mousedrag&&this._document.removeEventListener("mousemove",N.mousedrag)),this.cancel(V)),wheel:V=>(F(V),this.cancel(V,!0)),mousedrag:V=>{V.buttons&&F(V)},mousemove:V=>{V.buttons||F(V)}};this.register(this.coreMouseService.onProtocolChange((V=>{V?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(V)),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()),8&V?N.mousemove||(y.addEventListener("mousemove",K.mousemove),N.mousemove=K.mousemove):(y.removeEventListener("mousemove",N.mousemove),N.mousemove=null),16&V?N.wheel||(y.addEventListener("wheel",K.wheel,{passive:!1}),N.wheel=K.wheel):(y.removeEventListener("wheel",N.wheel),N.wheel=null),2&V?N.mouseup||(N.mouseup=K.mouseup):(this._document.removeEventListener("mouseup",N.mouseup),N.mouseup=null),4&V?N.mousedrag||(N.mousedrag=K.mousedrag):(this._document.removeEventListener("mousemove",N.mousedrag),N.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(y,"mousedown",(V=>{if(V.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(V))return F(V),N.mouseup&&this._document.addEventListener("mouseup",N.mouseup),N.mousedrag&&this._document.addEventListener("mousemove",N.mousedrag),this.cancel(V)}))),this.register((0,u.addDisposableDomListener)(y,"wheel",(V=>{if(!N.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(V)===!1)return!1;if(!this.buffer.hasScrollback){let ie=this.viewport.getLinesScrolled(V);if(ie===0)return;let he=U.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(V.deltaY<0?"A":"B"),le="";for(let ne=0;ne<Math.abs(ie);ne++)le+=he;return this.coreService.triggerDataEvent(le,!0),this.cancel(V,!0)}return this.viewport.handleWheel(V)?this.cancel(V):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(y,"touchstart",(V=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(V),this.cancel(V)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(y,"touchmove",(V=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(V)?void 0:this.cancel(V)}),{passive:!1}))}refresh(I,y){this._renderService?.refreshRows(I,y)}updateCursorStyle(I){this._selectionService?.shouldColumnSelect(I)?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(I,y,F=0){F===1?(super.scrollLines(I,y,F),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(I)}paste(I){(0,c.paste)(I,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(I){this._customKeyEventHandler=I}attachCustomWheelEventHandler(I){this._customWheelEventHandler=I}registerLinkProvider(I){return this._linkProviderService.registerLinkProvider(I)}registerCharacterJoiner(I){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let y=this._characterJoinerService.register(I);return this.refresh(0,this.rows-1),y}deregisterCharacterJoiner(I){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(I)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(I){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+I)}registerDecoration(I){return this._decorationService.registerDecoration(I)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(I,y,F){this._selectionService.setSelection(I,y,F)}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(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(I,y){this._selectionService?.selectLines(I,y)}_keyDown(I){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1)return!1;let y=this.browser.isMac&&this.options.macOptionIsMeta&&I.altKey;if(!y&&!this._compositionHelper.keydown(I))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;y||I.key!=="Dead"&&I.key!=="AltGraph"||(this._unprocessedDeadKey=!0);let F=(0,$.evaluateKeyboardEvent)(I,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(I),F.type===3||F.type===2){let N=this.rows-1;return this.scrollLines(F.type===2?-N:N),this.cancel(I,!0)}return F.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,I)||(F.cancel&&this.cancel(I,!0),!F.key||!!(I.key&&!I.ctrlKey&&!I.altKey&&!I.metaKey&&I.key.length===1&&I.key.charCodeAt(0)>=65&&I.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(F.key!==U.C0.ETX&&F.key!==U.C0.CR||(this.textarea.value=""),this._onKey.fire({key:F.key,domEvent:I}),this._showCursor(),this.coreService.triggerDataEvent(F.key,!0),!this.optionsService.rawOptions.screenReaderMode||I.altKey||I.ctrlKey?this.cancel(I,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(I,y){let F=I.isMac&&!this.options.macOptionIsMeta&&y.altKey&&!y.ctrlKey&&!y.metaKey||I.isWindows&&y.altKey&&y.ctrlKey&&!y.metaKey||I.isWindows&&y.getModifierState("AltGraph");return y.type==="keypress"?F:F&&(!y.keyCode||y.keyCode>47)}_keyUp(I){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1||((function(y){return y.keyCode===16||y.keyCode===17||y.keyCode===18})(I)||this.focus(),this.updateCursorStyle(I),this._keyPressHandled=!1)}_keyPress(I){let y;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1)return!1;if(this.cancel(I),I.charCode)y=I.charCode;else if(I.which===null||I.which===void 0)y=I.keyCode;else{if(I.which===0||I.charCode===0)return!1;y=I.which}return!(!y||(I.altKey||I.ctrlKey||I.metaKey)&&!this._isThirdLevelShift(this.browser,I)||(y=String.fromCharCode(y),this._onKey.fire({key:y,domEvent:I}),this._showCursor(),this.coreService.triggerDataEvent(y,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(I){if(I.data&&I.inputType==="insertText"&&(!I.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let y=I.data;return this.coreService.triggerDataEvent(y,!0),this.cancel(I),!0}return!1}resize(I,y){I!==this.cols||y!==this.rows?super.resize(I,y):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(I,y){this._charSizeService?.measure(),this.viewport?.syncScrollArea(!0)}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 I=1;I<this.rows;I++)this.buffer.lines.push(this.buffer.getBlankLine(j.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),this.viewport?.reset(),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let I=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this.viewport?.reset(),this._customKeyEventHandler=I,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(U.C0.ESC+"[I"):this.coreService.triggerDataEvent(U.C0.ESC+"[O")}_reportWindowsOptions(I){if(this._renderService)switch(I){case T.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:let y=this._renderService.dimensions.css.canvas.width.toFixed(0),F=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${U.C0.ESC}[4;${F};${y}t`);break;case T.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:let N=this._renderService.dimensions.css.cell.width.toFixed(0),K=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${U.C0.ESC}[6;${K};${N}t`)}}cancel(I,y){if(this.options.cancelEvents||y)return I.preventDefault(),I.stopPropagation(),!1}}r.Terminal=X},9924:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TimeBasedDebouncer=void 0,r.TimeBasedDebouncer=class{constructor(o,c=1e3){this._renderCallback=o,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,c,u){this._rowCount=u,o=o!==void 0?o:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c;let n=Date.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=n-this._lastRefreshMs,h=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),h)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let o=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,c)}}},1680:function(D,r,o){var c=this&&this.__decorate||function(t,e,s,d){var g,p=arguments.length,v=p<3?e:d===null?d=Object.getOwnPropertyDescriptor(e,s):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(t,e,s,d);else for(var f=t.length-1;f>=0;f--)(g=t[f])&&(v=(p<3?g(v):p>3?g(e,s,v):g(e,s))||v);return p>3&&v&&Object.defineProperty(e,s,v),v},u=this&&this.__param||function(t,e){return function(s,d){e(s,d,t)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Viewport=void 0;let n=o(3656),a=o(4725),h=o(8460),_=o(844),l=o(2585),i=r.Viewport=class extends _.Disposable{constructor(t,e,s,d,g,p,v,f){super(),this._viewportElement=t,this._scrollArea=e,this._bufferService=s,this._optionsService=d,this._charSizeService=g,this._renderService=p,this._coreBrowserService=v,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new h.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,n.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((m=>this._activeBuffer=m.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((m=>this._renderDimensions=m))),this._handleThemeChange(f.colors),this.register(f.onChangeColors((m=>this._handleThemeChange(m)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(t){this._viewportElement.style.backgroundColor=t.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(t){if(t)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;let e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}let t=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==t&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=t),this._refreshAnimationFrame=null}syncScrollArea(t=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(t);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(t)}_handleScroll(t){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});let e=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:e,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;let t=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(t*(this._smoothScrollState.target-this._smoothScrollState.origin)),t<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(t,e){let s=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(e<0&&this._viewportElement.scrollTop!==0||e>0&&s<this._lastRecordedBufferHeight)||(t.cancelable&&t.preventDefault(),!1)}handleWheel(t){let e=this._getPixelsScrolled(t);return e!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+e:this._smoothScrollState.target+=e,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=e,this._bubbleScroll(t,e))}scrollLines(t){if(t!==0)if(this._optionsService.rawOptions.smoothScrollDuration){let e=t*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+e,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:t,suppressScrollEvent:!1})}_getPixelsScrolled(t){if(t.deltaY===0||t.shiftKey)return 0;let e=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_LINE?e*=this._currentRowHeight:t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(e*=this._currentRowHeight*this._bufferService.rows),e}getBufferElements(t,e){let s,d="",g=[],p=e??this._bufferService.buffer.lines.length,v=this._bufferService.buffer.lines;for(let f=t;f<p;f++){let m=v.get(f);if(!m)continue;let E=v.get(f+1)?.isWrapped;if(d+=m.translateToString(!E),!E||f===v.length-1){let k=document.createElement("div");k.textContent=d,g.push(k),d.length>0&&(s=k),d=""}}return{bufferElements:g,cursorElement:s}}getLinesScrolled(t){if(t.deltaY===0||t.shiftKey)return 0;let e=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(e/=this._currentRowHeight+0,this._wheelPartialScroll+=e,e=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(e*=this._bufferService.rows),e}_applyScrollModifier(t,e){let s=this._optionsService.rawOptions.fastScrollModifier;return s==="alt"&&e.altKey||s==="ctrl"&&e.ctrlKey||s==="shift"&&e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(t){this._lastTouchY=t.touches[0].pageY}handleTouchMove(t){let e=this._lastTouchY-t.touches[0].pageY;return this._lastTouchY=t.touches[0].pageY,e!==0&&(this._viewportElement.scrollTop+=e,this._bubbleScroll(t,e))}};r.Viewport=i=c([u(2,l.IBufferService),u(3,l.IOptionsService),u(4,a.ICharSizeService),u(5,a.IRenderService),u(6,a.ICoreBrowserService),u(7,a.IThemeService)],i)},3107:function(D,r,o){var c=this&&this.__decorate||function(l,i,t,e){var s,d=arguments.length,g=d<3?i:e===null?e=Object.getOwnPropertyDescriptor(i,t):e;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")g=Reflect.decorate(l,i,t,e);else for(var p=l.length-1;p>=0;p--)(s=l[p])&&(g=(d<3?s(g):d>3?s(i,t,g):s(i,t))||g);return d>3&&g&&Object.defineProperty(i,t,g),g},u=this&&this.__param||function(l,i){return function(t,e){i(t,e,l)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferDecorationRenderer=void 0;let n=o(4725),a=o(844),h=o(2585),_=r.BufferDecorationRenderer=class extends a.Disposable{constructor(l,i,t,e,s){super(),this._screenElement=l,this._bufferService=i,this._coreBrowserService=t,this._decorationService=e,this._renderService=s,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((d=>this._removeDecoration(d)))),this.register((0,a.toDisposable)((()=>{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 l of this._decorationService.decorations)this._renderDecoration(l);this._dimensionsChanged=!1}_renderDecoration(l){this._refreshStyle(l),this._dimensionsChanged&&this._refreshXPosition(l)}_createElement(l){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",l?.options?.layer==="top"),i.style.width=`${Math.round((l.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=(l.options.height||1)*this._renderService.dimensions.css.cell.height+"px",i.style.top=(l.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let t=l.options.x??0;return t&&t>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(l,i),i}_refreshStyle(l){let i=l.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)l.element&&(l.element.style.display="none",l.onRenderEmitter.fire(l.element));else{let t=this._decorationElements.get(l);t||(t=this._createElement(l),l.element=t,this._decorationElements.set(l,t),this._container.appendChild(t),l.onDispose((()=>{this._decorationElements.delete(l),t.remove()}))),t.style.top=i*this._renderService.dimensions.css.cell.height+"px",t.style.display=this._altBufferIsActive?"none":"block",l.onRenderEmitter.fire(t)}}_refreshXPosition(l,i=l.element){if(!i)return;let t=l.options.x??0;(l.options.anchor||"left")==="right"?i.style.right=t?t*this._renderService.dimensions.css.cell.width+"px":"":i.style.left=t?t*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(l){this._decorationElements.get(l)?.remove(),this._decorationElements.delete(l),l.dispose()}};r.BufferDecorationRenderer=_=c([u(1,h.IBufferService),u(2,n.ICoreBrowserService),u(3,h.IDecorationService),u(4,n.IRenderService)],_)},5871:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorZoneStore=void 0,r.ColorZoneStore=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(o){if(o.options.overviewRulerOptions){for(let c of this._zones)if(c.color===o.options.overviewRulerOptions.color&&c.position===o.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,o.marker.line))return;if(this._lineAdjacentToZone(c,o.marker.line,o.options.overviewRulerOptions.position))return void this._addLineToZone(c,o.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=o.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=o.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=o.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=o.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:o.options.overviewRulerOptions.color,position:o.options.overviewRulerOptions.position,startBufferLine:o.marker.line,endBufferLine:o.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(o){this._linePadding=o}_lineIntersectsZone(o,c){return c>=o.startBufferLine&&c<=o.endBufferLine}_lineAdjacentToZone(o,c,u){return c>=o.startBufferLine-this._linePadding[u||"full"]&&c<=o.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(o,c){o.startBufferLine=Math.min(o.startBufferLine,c),o.endBufferLine=Math.max(o.endBufferLine,c)}}},5744:function(D,r,o){var c=this&&this.__decorate||function(s,d,g,p){var v,f=arguments.length,m=f<3?d:p===null?p=Object.getOwnPropertyDescriptor(d,g):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(s,d,g,p);else for(var E=s.length-1;E>=0;E--)(v=s[E])&&(m=(f<3?v(m):f>3?v(d,g,m):v(d,g))||m);return f>3&&m&&Object.defineProperty(d,g,m),m},u=this&&this.__param||function(s,d){return function(g,p){d(g,p,s)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OverviewRulerRenderer=void 0;let n=o(5871),a=o(4725),h=o(844),_=o(2585),l={full:0,left:0,center:0,right:0},i={full:0,left:0,center:0,right:0},t={full:0,left:0,center:0,right:0},e=r.OverviewRulerRenderer=class extends h.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(s,d,g,p,v,f,m){super(),this._viewportElement=s,this._screenElement=d,this._bufferService=g,this._decorationService=p,this._renderService=v,this._optionsService=f,this._coreBrowserService=m,this._colorZoneStore=new n.ColorZoneStore,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(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement);let E=this._canvas.getContext("2d");if(!E)throw new Error("Ctx cannot be null");this._ctx=E,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,h.toDisposable)((()=>{this._canvas?.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){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())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){let s=Math.floor(this._canvas.width/3),d=Math.ceil(this._canvas.width/3);i.full=this._canvas.width,i.left=s,i.center=d,i.right=s,this._refreshDrawHeightConstants(),t.full=0,t.left=0,t.center=i.left,t.right=i.left+i.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowserService.dpr);let s=this._canvas.height/this._bufferService.buffer.lines.length,d=Math.round(Math.max(Math.min(s,12),6)*this._coreBrowserService.dpr);l.left=d,l.center=d,l.right=d}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.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 d of this._decorationService.decorations)this._colorZoneStore.addDecoration(d);this._ctx.lineWidth=1;let s=this._colorZoneStore.zones;for(let d of s)d.position!=="full"&&this._renderColorZone(d);for(let d of s)d.position==="full"&&this._renderColorZone(d);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(s){this._ctx.fillStyle=s.color,this._ctx.fillRect(t[s.position||"full"],Math.round((this._canvas.height-1)*(s.startBufferLine/this._bufferService.buffers.active.lines.length)-l[s.position||"full"]/2),i[s.position||"full"],Math.round((this._canvas.height-1)*((s.endBufferLine-s.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[s.position||"full"]))}_queueRefresh(s,d){this._shouldUpdateDimensions=s||this._shouldUpdateDimensions,this._shouldUpdateAnchor=d||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};r.OverviewRulerRenderer=e=c([u(2,_.IBufferService),u(3,_.IDecorationService),u(4,a.IRenderService),u(5,_.IOptionsService),u(6,a.ICoreBrowserService)],e)},2950:function(D,r,o){var c=this&&this.__decorate||function(l,i,t,e){var s,d=arguments.length,g=d<3?i:e===null?e=Object.getOwnPropertyDescriptor(i,t):e;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")g=Reflect.decorate(l,i,t,e);else for(var p=l.length-1;p>=0;p--)(s=l[p])&&(g=(d<3?s(g):d>3?s(i,t,g):s(i,t))||g);return d>3&&g&&Object.defineProperty(i,t,g),g},u=this&&this.__param||function(l,i){return function(t,e){i(t,e,l)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CompositionHelper=void 0;let n=o(4725),a=o(2585),h=o(2584),_=r.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(l,i,t,e,s,d){this._textarea=l,this._compositionView=i,this._bufferService=t,this._optionsService=e,this._coreService=s,this._renderService=d,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(l){this._compositionView.textContent=l.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(l){if(this._isComposing||this._isSendingComposition){if(l.keyCode===229||l.keyCode===16||l.keyCode===17||l.keyCode===18)return!1;this._finalizeComposition(!1)}return l.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(l){if(this._compositionView.classList.remove("active"),this._isComposing=!1,l){let i={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let t;this._isSendingComposition=!1,i.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(i.start,i.end):this._textarea.value.substring(i.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}}),0)}else{this._isSendingComposition=!1;let i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}}_handleAnyTextareaChanges(){let l=this._textarea.value;setTimeout((()=>{if(!this._isComposing){let i=this._textarea.value,t=i.replace(l,"");this._dataAlreadySent=t,i.length>l.length?this._coreService.triggerDataEvent(t,!0):i.length<l.length?this._coreService.triggerDataEvent(`${h.C0.DEL}`,!0):i.length===l.length&&i!==l&&this._coreService.triggerDataEvent(i,!0)}}),0)}updateCompositionElements(l){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,e=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=i*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=e+"px",this._compositionView.style.height=t+"px",this._compositionView.style.lineHeight=t+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let d=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=e+"px",this._textarea.style.width=Math.max(d.width,1)+"px",this._textarea.style.height=Math.max(d.height,1)+"px",this._textarea.style.lineHeight=d.height+"px"}l||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};r.CompositionHelper=_=c([u(2,a.IBufferService),u(3,a.IOptionsService),u(4,a.ICoreService),u(5,n.IRenderService)],_)},9806:(D,r)=>{function o(c,u,n){let a=n.getBoundingClientRect(),h=c.getComputedStyle(n),_=parseInt(h.getPropertyValue("padding-left")),l=parseInt(h.getPropertyValue("padding-top"));return[u.clientX-a.left-_,u.clientY-a.top-l]}Object.defineProperty(r,"__esModule",{value:!0}),r.getCoords=r.getCoordsRelativeToElement=void 0,r.getCoordsRelativeToElement=o,r.getCoords=function(c,u,n,a,h,_,l,i,t){if(!_)return;let e=o(c,u,n);return e?(e[0]=Math.ceil((e[0]+(t?l/2:0))/l),e[1]=Math.ceil(e[1]/i),e[0]=Math.min(Math.max(e[0],1),a+(t?1:0)),e[1]=Math.min(Math.max(e[1],1),h),e):void 0}},9504:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.moveToCellSequence=void 0;let c=o(2584);function u(i,t,e,s){let d=i-n(i,e),g=t-n(t,e),p=Math.abs(d-g)-(function(v,f,m){let E=0,k=v-n(v,m),x=f-n(f,m);for(let C=0;C<Math.abs(k-x);C++){let M=a(v,f)==="A"?-1:1;m.buffer.lines.get(k+M*C)?.isWrapped&&E++}return E})(i,t,e);return l(p,_(a(i,t),s))}function n(i,t){let e=0,s=t.buffer.lines.get(i),d=s?.isWrapped;for(;d&&i>=0&&i<t.rows;)e++,s=t.buffer.lines.get(--i),d=s?.isWrapped;return e}function a(i,t){return i>t?"A":"B"}function h(i,t,e,s,d,g){let p=i,v=t,f="";for(;p!==e||v!==s;)p+=d?1:-1,d&&p>g.cols-1?(f+=g.buffer.translateBufferLineToString(v,!1,i,p),p=0,i=0,v++):!d&&p<0&&(f+=g.buffer.translateBufferLineToString(v,!1,0,i+1),p=g.cols-1,i=p,v--);return f+g.buffer.translateBufferLineToString(v,!1,i,p)}function _(i,t){let e=t?"O":"[";return c.C0.ESC+e+i}function l(i,t){i=Math.floor(i);let e="";for(let s=0;s<i;s++)e+=t;return e}r.moveToCellSequence=function(i,t,e,s){let d=e.buffer.x,g=e.buffer.y;if(!e.buffer.hasScrollback)return(function(f,m,E,k,x,C){return u(m,k,x,C).length===0?"":l(h(f,m,f,m-n(m,x),!1,x).length,_("D",C))})(d,g,0,t,e,s)+u(g,t,e,s)+(function(f,m,E,k,x,C){let M;M=u(m,k,x,C).length>0?k-n(k,x):m;let z=k,j=(function(U,$,b,L,R,T){let H;return H=u(b,L,R,T).length>0?L-n(L,R):$,U<b&&H<=L||U>=b&&H<L?"C":"D"})(f,m,E,k,x,C);return l(h(f,M,E,z,j==="C",x).length,_(j,C))})(d,g,i,t,e,s);let p;if(g===t)return p=d>i?"D":"C",l(Math.abs(d-i),_(p,s));p=g>t?"D":"C";let v=Math.abs(g-t);return l((function(f,m){return m.cols-f})(g>t?i:d,e)+(v-1)*e.cols+1+((g>t?d:i)-1),_(p,s))}},1296:function(D,r,o){var c=this&&this.__decorate||function(C,M,z,j){var U,$=arguments.length,b=$<3?M:j===null?j=Object.getOwnPropertyDescriptor(M,z):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(C,M,z,j);else for(var L=C.length-1;L>=0;L--)(U=C[L])&&(b=($<3?U(b):$>3?U(M,z,b):U(M,z))||b);return $>3&&b&&Object.defineProperty(M,z,b),b},u=this&&this.__param||function(C,M){return function(z,j){M(z,j,C)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRenderer=void 0;let n=o(3787),a=o(2550),h=o(2223),_=o(6171),l=o(6052),i=o(4725),t=o(8055),e=o(8460),s=o(844),d=o(2585),g="xterm-dom-renderer-owner-",p="xterm-rows",v="xterm-fg-",f="xterm-bg-",m="xterm-focus",E="xterm-selection",k=1,x=r.DomRenderer=class extends s.Disposable{constructor(C,M,z,j,U,$,b,L,R,T,H,q,X){super(),this._terminal=C,this._document=M,this._element=z,this._screenElement=j,this._viewportElement=U,this._helperContainer=$,this._linkifier2=b,this._charSizeService=R,this._optionsService=T,this._bufferService=H,this._coreBrowserService=q,this._themeService=X,this._terminalClass=k++,this._rowElements=[],this._selectionRenderModel=(0,l.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new e.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(p),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(E),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,_.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((Y=>this._injectCss(Y)))),this._injectCss(this._themeService.colors),this._rowFactory=L.createInstance(n.DomRendererRowFactory,document),this._element.classList.add(g+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((Y=>this._handleLinkHover(Y)))),this.register(this._linkifier2.onHideLinkUnderline((Y=>this._handleLinkLeave(Y)))),this.register((0,s.toDisposable)((()=>{this._element.classList.remove(g+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new a.WidthCache(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 C=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*C,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*C),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/C),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/C),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 z of this._rowElements)z.style.width=`${this.dimensions.css.canvas.width}px`,z.style.height=`${this.dimensions.css.cell.height}px`,z.style.lineHeight=`${this.dimensions.css.cell.height}px`,z.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let M=`${this._terminalSelector} .${p} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=M,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(C){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let M=`${this._terminalSelector} .${p} { color: ${C.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;M+=`${this._terminalSelector} .${p} .xterm-dim { color: ${t.color.multiplyOpacity(C.foreground,.5).css};}`,M+=`${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 z=`blink_underline_${this._terminalClass}`,j=`blink_bar_${this._terminalClass}`,U=`blink_block_${this._terminalClass}`;M+=`@keyframes ${z} { 50% { border-bottom-style: hidden; }}`,M+=`@keyframes ${j} { 50% { box-shadow: none; }}`,M+=`@keyframes ${U} { 0% { background-color: ${C.cursor.css}; color: ${C.cursorAccent.css}; } 50% { background-color: inherit; color: ${C.cursor.css}; }}`,M+=`${this._terminalSelector} .${p}.${m} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${z} 1s step-end infinite;}${this._terminalSelector} .${p}.${m} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${j} 1s step-end infinite;}${this._terminalSelector} .${p}.${m} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${U} 1s step-end infinite;}${this._terminalSelector} .${p} .xterm-cursor.xterm-cursor-block { background-color: ${C.cursor.css}; color: ${C.cursorAccent.css};}${this._terminalSelector} .${p} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${C.cursor.css} !important; color: ${C.cursorAccent.css} !important;}${this._terminalSelector} .${p} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${C.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${p} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${C.cursor.css} inset;}${this._terminalSelector} .${p} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${C.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,M+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${C.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${C.selectionInactiveBackgroundOpaque.css};}`;for(let[$,b]of C.ansi.entries())M+=`${this._terminalSelector} .${v}${$} { color: ${b.css}; }${this._terminalSelector} .${v}${$}.xterm-dim { color: ${t.color.multiplyOpacity(b,.5).css}; }${this._terminalSelector} .${f}${$} { background-color: ${b.css}; }`;M+=`${this._terminalSelector} .${v}${h.INVERTED_DEFAULT_COLOR} { color: ${t.color.opaque(C.background).css}; }${this._terminalSelector} .${v}${h.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${t.color.multiplyOpacity(t.color.opaque(C.background),.5).css}; }${this._terminalSelector} .${f}${h.INVERTED_DEFAULT_COLOR} { background-color: ${C.foreground.css}; }`,this._themeStyleElement.textContent=M}_setDefaultSpacing(){let C=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${C}px`,this._rowFactory.defaultSpacing=C}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(C,M){for(let z=this._rowElements.length;z<=M;z++){let j=this._document.createElement("div");this._rowContainer.appendChild(j),this._rowElements.push(j)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(C,M){this._refreshRowElements(C,M),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(m),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(m),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(C,M,z){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(C,M,z),this.renderRows(0,this._bufferService.rows-1),!C||!M)return;this._selectionRenderModel.update(this._terminal,C,M,z);let j=this._selectionRenderModel.viewportStartRow,U=this._selectionRenderModel.viewportEndRow,$=this._selectionRenderModel.viewportCappedStartRow,b=this._selectionRenderModel.viewportCappedEndRow;if($>=this._bufferService.rows||b<0)return;let L=this._document.createDocumentFragment();if(z){let R=C[0]>M[0];L.appendChild(this._createSelectionElement($,R?M[0]:C[0],R?C[0]:M[0],b-$+1))}else{let R=j===$?C[0]:0,T=$===U?M[0]:this._bufferService.cols;L.appendChild(this._createSelectionElement($,R,T));let H=b-$-1;if(L.appendChild(this._createSelectionElement($+1,0,this._bufferService.cols,H)),$!==b){let q=U===b?M[0]:this._bufferService.cols;L.appendChild(this._createSelectionElement(b,0,q))}}this._selectionContainer.appendChild(L)}_createSelectionElement(C,M,z,j=1){let U=this._document.createElement("div"),$=M*this.dimensions.css.cell.width,b=this.dimensions.css.cell.width*(z-M);return $+b>this.dimensions.css.canvas.width&&(b=this.dimensions.css.canvas.width-$),U.style.height=j*this.dimensions.css.cell.height+"px",U.style.top=C*this.dimensions.css.cell.height+"px",U.style.left=`${$}px`,U.style.width=`${b}px`,U}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 C of this._rowElements)C.replaceChildren()}renderRows(C,M){let z=this._bufferService.buffer,j=z.ybase+z.y,U=Math.min(z.x,this._bufferService.cols-1),$=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,L=this._optionsService.rawOptions.cursorInactiveStyle;for(let R=C;R<=M;R++){let T=R+z.ydisp,H=this._rowElements[R],q=z.lines.get(T);if(!H||!q)break;H.replaceChildren(...this._rowFactory.createRow(q,T,T===j,b,L,U,$,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${g}${this._terminalClass}`}_handleLinkHover(C){this._setCellUnderline(C.x1,C.x2,C.y1,C.y2,C.cols,!0)}_handleLinkLeave(C){this._setCellUnderline(C.x1,C.x2,C.y1,C.y2,C.cols,!1)}_setCellUnderline(C,M,z,j,U,$){z<0&&(C=0),j<0&&(M=0);let b=this._bufferService.rows-1;z=Math.max(Math.min(z,b),0),j=Math.max(Math.min(j,b),0),U=Math.min(U,this._bufferService.cols);let L=this._bufferService.buffer,R=L.ybase+L.y,T=Math.min(L.x,U-1),H=this._optionsService.rawOptions.cursorBlink,q=this._optionsService.rawOptions.cursorStyle,X=this._optionsService.rawOptions.cursorInactiveStyle;for(let Y=z;Y<=j;++Y){let I=Y+L.ydisp,y=this._rowElements[Y],F=L.lines.get(I);if(!y||!F)break;y.replaceChildren(...this._rowFactory.createRow(F,I,I===R,q,X,T,H,this.dimensions.css.cell.width,this._widthCache,$?Y===z?C:0:-1,$?(Y===j?M:U)-1:-1))}}};r.DomRenderer=x=c([u(7,d.IInstantiationService),u(8,i.ICharSizeService),u(9,d.IOptionsService),u(10,d.IBufferService),u(11,i.ICoreBrowserService),u(12,i.IThemeService)],x)},3787:function(D,r,o){var c=this&&this.__decorate||function(p,v,f,m){var E,k=arguments.length,x=k<3?v:m===null?m=Object.getOwnPropertyDescriptor(v,f):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(p,v,f,m);else for(var C=p.length-1;C>=0;C--)(E=p[C])&&(x=(k<3?E(x):k>3?E(v,f,x):E(v,f))||x);return k>3&&x&&Object.defineProperty(v,f,x),x},u=this&&this.__param||function(p,v){return function(f,m){v(f,m,p)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRendererRowFactory=void 0;let n=o(2223),a=o(643),h=o(511),_=o(2585),l=o(8055),i=o(4725),t=o(4269),e=o(6171),s=o(3734),d=r.DomRendererRowFactory=class{constructor(p,v,f,m,E,k,x){this._document=p,this._characterJoinerService=v,this._optionsService=f,this._coreBrowserService=m,this._coreService=E,this._decorationService=k,this._themeService=x,this._workCell=new h.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(p,v,f){this._selectionStart=p,this._selectionEnd=v,this._columnSelectMode=f}createRow(p,v,f,m,E,k,x,C,M,z,j){let U=[],$=this._characterJoinerService.getJoinedCharacters(v),b=this._themeService.colors,L,R=p.getNoBgTrimmedLength();f&&R<k+1&&(R=k+1);let T=0,H="",q=0,X=0,Y=0,I=!1,y=0,F=!1,N=0,K=[],V=z!==-1&&j!==-1;for(let ie=0;ie<R;ie++){p.loadCell(ie,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let le=!1,ne=ie,G=this._workCell;if($.length>0&&ie===$[0][0]){le=!0;let oe=$.shift();G=new t.JoinedCellData(this._workCell,p.translateToString(!0,oe[0],oe[1]),oe[1]-oe[0]),ne=oe[1]-1,he=G.getWidth()}let Fe=this._isCellInSelection(ie,v),We=f&&ie===k,qe=V&&ie>=z&&ie<=j,Ke=!1;this._decorationService.forEachDecorationAtCell(ie,v,void 0,(oe=>{Ke=!0}));let $e=G.getChars()||a.WHITESPACE_CELL_CHAR;if($e===" "&&(G.isUnderline()||G.isOverline())&&($e="\xA0"),N=he*C-M.get($e,G.isBold(),G.isItalic()),L){if(T&&(Fe&&F||!Fe&&!F&&G.bg===q)&&(Fe&&F&&b.selectionForeground||G.fg===X)&&G.extended.ext===Y&&qe===I&&N===y&&!We&&!le&&!Ke){G.isInvisible()?H+=a.WHITESPACE_CELL_CHAR:H+=$e,T++;continue}T&&(L.textContent=H),L=this._document.createElement("span"),T=0,H=""}else L=this._document.createElement("span");if(q=G.bg,X=G.fg,Y=G.extended.ext,I=qe,y=N,F=Fe,le&&k>=ie&&k<=ne&&(k=ie),!this._coreService.isCursorHidden&&We&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)x&&K.push("xterm-cursor-blink"),K.push(m==="bar"?"xterm-cursor-bar":m==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(E)switch(E){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline")}}if(G.isBold()&&K.push("xterm-bold"),G.isItalic()&&K.push("xterm-italic"),G.isDim()&&K.push("xterm-dim"),H=G.isInvisible()?a.WHITESPACE_CELL_CHAR:G.getChars()||a.WHITESPACE_CELL_CHAR,G.isUnderline()&&(K.push(`xterm-underline-${G.extended.underlineStyle}`),H===" "&&(H="\xA0"),!G.isUnderlineColorDefault()))if(G.isUnderlineColorRGB())L.style.textDecorationColor=`rgb(${s.AttributeData.toColorRGB(G.getUnderlineColor()).join(",")})`;else{let oe=G.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&G.isBold()&&oe<8&&(oe+=8),L.style.textDecorationColor=b.ansi[oe].css}G.isOverline()&&(K.push("xterm-overline"),H===" "&&(H="\xA0")),G.isStrikethrough()&&K.push("xterm-strikethrough"),qe&&(L.style.textDecoration="underline");let we=G.getFgColor(),Ae=G.getFgColorMode(),Re=G.getBgColor(),Ne=G.getBgColorMode(),tt=!!G.isInverse();if(tt){let oe=we;we=Re,Re=oe;let xe=Ae;Ae=Ne,Ne=xe}let pe,ke,Me,Te=!1;switch(this._decorationService.forEachDecorationAtCell(ie,v,void 0,(oe=>{oe.options.layer!=="top"&&Te||(oe.backgroundColorRGB&&(Ne=50331648,Re=oe.backgroundColorRGB.rgba>>8&16777215,pe=oe.backgroundColorRGB),oe.foregroundColorRGB&&(Ae=50331648,we=oe.foregroundColorRGB.rgba>>8&16777215,ke=oe.foregroundColorRGB),Te=oe.options.layer==="top")})),!Te&&Fe&&(pe=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,Re=pe.rgba>>8&16777215,Ne=50331648,Te=!0,b.selectionForeground&&(Ae=50331648,we=b.selectionForeground.rgba>>8&16777215,ke=b.selectionForeground)),Te&&K.push("xterm-decoration-top"),Ne){case 16777216:case 33554432:Me=b.ansi[Re],K.push(`xterm-bg-${Re}`);break;case 50331648:Me=l.channels.toColor(Re>>16,Re>>8&255,255&Re),this._addStyle(L,`background-color:#${g((Re>>>0).toString(16),"0",6)}`);break;default:tt?(Me=b.foreground,K.push(`xterm-bg-${n.INVERTED_DEFAULT_COLOR}`)):Me=b.background}switch(pe||G.isDim()&&(pe=l.color.multiplyOpacity(Me,.5)),Ae){case 16777216:case 33554432:G.isBold()&&we<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(we+=8),this._applyMinimumContrast(L,Me,b.ansi[we],G,pe,void 0)||K.push(`xterm-fg-${we}`);break;case 50331648:let oe=l.channels.toColor(we>>16&255,we>>8&255,255&we);this._applyMinimumContrast(L,Me,oe,G,pe,ke)||this._addStyle(L,`color:#${g(we.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(L,Me,b.foreground,G,pe,ke)||tt&&K.push(`xterm-fg-${n.INVERTED_DEFAULT_COLOR}`)}K.length&&(L.className=K.join(" "),K.length=0),We||le||Ke?L.textContent=H:T++,N!==this.defaultSpacing&&(L.style.letterSpacing=`${N}px`),U.push(L),ie=ne}return L&&T&&(L.textContent=H),U}_applyMinimumContrast(p,v,f,m,E,k){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,e.treatGlyphAsBackgroundColor)(m.getCode()))return!1;let x=this._getContrastCache(m),C;if(E||k||(C=x.getColor(v.rgba,f.rgba)),C===void 0){let M=this._optionsService.rawOptions.minimumContrastRatio/(m.isDim()?2:1);C=l.color.ensureContrastRatio(E||v,k||f,M),x.setColor((E||v).rgba,(k||f).rgba,C??null)}return!!C&&(this._addStyle(p,`color:${C.css}`),!0)}_getContrastCache(p){return p.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(p,v){p.setAttribute("style",`${p.getAttribute("style")||""}${v};`)}_isCellInSelection(p,v){let f=this._selectionStart,m=this._selectionEnd;return!(!f||!m)&&(this._columnSelectMode?f[0]<=m[0]?p>=f[0]&&v>=f[1]&&p<m[0]&&v<=m[1]:p<f[0]&&v>=f[1]&&p>=m[0]&&v<=m[1]:v>f[1]&&v<m[1]||f[1]===m[1]&&v===f[1]&&p>=f[0]&&p<m[0]||f[1]<m[1]&&v===m[1]&&p<m[0]||f[1]<m[1]&&v===f[1]&&p>=f[0])}};function g(p,v,f){for(;p.length<f;)p=v+p;return p}r.DomRendererRowFactory=d=c([u(1,i.ICharacterJoinerService),u(2,_.IOptionsService),u(3,i.ICoreBrowserService),u(4,_.ICoreService),u(5,_.IDecorationService),u(6,i.IThemeService)],d)},2550:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WidthCache=void 0,r.WidthCache=class{constructor(o,c){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=o.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 u=o.createElement("span");u.classList.add("xterm-char-measure-element");let n=o.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let a=o.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontStyle="italic";let h=o.createElement("span");h.classList.add("xterm-char-measure-element"),h.style.fontWeight="bold",h.style.fontStyle="italic",this._measureElements=[u,n,a,h],this._container.appendChild(u),this._container.appendChild(n),this._container.appendChild(a),this._container.appendChild(h),c.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(o,c,u,n){o===this._font&&c===this._fontSize&&u===this._weight&&n===this._weightBold||(this._font=o,this._fontSize=c,this._weight=u,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(o,c,u){let n=0;if(!c&&!u&&o.length===1&&(n=o.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let _=this._measure(o,0);return _>0&&(this._flat[n]=_),_}let a=o;c&&(a+="B"),u&&(a+="I");let h=this._holey.get(a);if(h===void 0){let _=0;c&&(_|=1),u&&(_|=2),h=this._measure(o,_),h>0&&this._holey.set(a,h)}return h}_measure(o,c){let u=this._measureElements[c];return u.textContent=o.repeat(32),u.offsetWidth/32}}},2223:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TEXT_BASELINE=r.DIM_OPACITY=r.INVERTED_DEFAULT_COLOR=void 0;let c=o(6114);r.INVERTED_DEFAULT_COLOR=257,r.DIM_OPACITY=.5,r.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(D,r)=>{function o(u){return 57508<=u&&u<=57558}function c(u){return u>=128512&&u<=128591||u>=127744&&u<=128511||u>=128640&&u<=128767||u>=9728&&u<=9983||u>=9984&&u<=10175||u>=65024&&u<=65039||u>=129280&&u<=129535||u>=127462&&u<=127487}Object.defineProperty(r,"__esModule",{value:!0}),r.computeNextVariantOffset=r.createRenderDimensions=r.treatGlyphAsBackgroundColor=r.allowRescaling=r.isEmoji=r.isRestrictedPowerlineGlyph=r.isPowerlineGlyph=r.throwIfFalsy=void 0,r.throwIfFalsy=function(u){if(!u)throw new Error("value must not be falsy");return u},r.isPowerlineGlyph=o,r.isRestrictedPowerlineGlyph=function(u){return 57520<=u&&u<=57527},r.isEmoji=c,r.allowRescaling=function(u,n,a,h){return n===1&&a>Math.ceil(1.5*h)&&u!==void 0&&u>255&&!c(u)&&!o(u)&&!(function(_){return 57344<=_&&_<=63743})(u)},r.treatGlyphAsBackgroundColor=function(u){return o(u)||(function(n){return 9472<=n&&n<=9631})(u)},r.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},r.computeNextVariantOffset=function(u,n,a=0){return(u-(2*Math.round(n)-a))%(2*Math.round(n))}},6052:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createSelectionRenderModel=void 0;class o{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(u,n,a,h=!1){if(this.selectionStart=n,this.selectionEnd=a,!n||!a||n[0]===a[0]&&n[1]===a[1])return void this.clear();let _=u.buffers.active.ydisp,l=n[1]-_,i=a[1]-_,t=Math.max(l,0),e=Math.min(i,u.rows-1);t>=u.rows||e<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=h,this.viewportStartRow=l,this.viewportEndRow=i,this.viewportCappedStartRow=t,this.viewportCappedEndRow=e,this.startCol=n[0],this.endCol=a[0])}isCellSelected(u,n,a){return!!this.hasSelection&&(a-=u.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?n>=this.startCol&&a>=this.viewportCappedStartRow&&n<this.endCol&&a<=this.viewportCappedEndRow:n<this.startCol&&a>=this.viewportCappedStartRow&&n>=this.endCol&&a<=this.viewportCappedEndRow:a>this.viewportStartRow&&a<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&a===this.viewportStartRow&&n>=this.startCol&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&a===this.viewportEndRow&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&a===this.viewportStartRow&&n>=this.startCol)}}r.createSelectionRenderModel=function(){return new o}},456:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionModel=void 0,r.SelectionModel=class{constructor(o){this._bufferService=o,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.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 o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?o%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)-1]:[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[o,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[Math.max(o,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let o=this.selectionStart,c=this.selectionEnd;return!(!o||!c)&&(o[1]>c[1]||o[1]===c[1]&&o[0]>c[0])}handleTrim(o){return this.selectionStart&&(this.selectionStart[1]-=o),this.selectionEnd&&(this.selectionEnd[1]-=o),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(D,r,o){var c=this&&this.__decorate||function(e,s,d,g){var p,v=arguments.length,f=v<3?s:g===null?g=Object.getOwnPropertyDescriptor(s,d):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(e,s,d,g);else for(var m=e.length-1;m>=0;m--)(p=e[m])&&(f=(v<3?p(f):v>3?p(s,d,f):p(s,d))||f);return v>3&&f&&Object.defineProperty(s,d,f),f},u=this&&this.__param||function(e,s){return function(d,g){s(d,g,e)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharSizeService=void 0;let n=o(2585),a=o(8460),h=o(844),_=r.CharSizeService=class extends h.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(e,s,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new a.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new t(this._optionsService))}catch{this._measureStrategy=this.register(new i(e,s,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}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())}};r.CharSizeService=_=c([u(2,n.IOptionsService)],_);class l extends h.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(s,d){s!==void 0&&s>0&&d!==void 0&&d>0&&(this._result.width=s,this._result.height=d)}}class i extends l{constructor(s,d,g){super(),this._document=s,this._parentElement=d,this._optionsService=g,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}}class t extends l{constructor(s){super(),this._optionsService=s,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let d=this._ctx.measureText("W");if(!("width"in d&&"fontBoundingBoxAscent"in d&&"fontBoundingBoxDescent"in d))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let s=this._ctx.measureText("W");return this._validateAndSet(s.width,s.fontBoundingBoxAscent+s.fontBoundingBoxDescent),this._result}}},4269:function(D,r,o){var c=this&&this.__decorate||function(t,e,s,d){var g,p=arguments.length,v=p<3?e:d===null?d=Object.getOwnPropertyDescriptor(e,s):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(t,e,s,d);else for(var f=t.length-1;f>=0;f--)(g=t[f])&&(v=(p<3?g(v):p>3?g(e,s,v):g(e,s))||v);return p>3&&v&&Object.defineProperty(e,s,v),v},u=this&&this.__param||function(t,e){return function(s,d){e(s,d,t)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharacterJoinerService=r.JoinedCellData=void 0;let n=o(3734),a=o(643),h=o(511),_=o(2585);class l extends n.AttributeData{constructor(e,s,d){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=s,this._width=d}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()]}}r.JoinedCellData=l;let i=r.CharacterJoinerService=class ii{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new h.CellData}register(e){let s={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(s),s.id}deregister(e){for(let s=0;s<this._characterJoiners.length;s++)if(this._characterJoiners[s].id===e)return this._characterJoiners.splice(s,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let s=this._bufferService.buffer.lines.get(e);if(!s||s.length===0)return[];let d=[],g=s.translateToString(!0),p=0,v=0,f=0,m=s.getFg(0),E=s.getBg(0);for(let k=0;k<s.getTrimmedLength();k++)if(s.loadCell(k,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==m||this._workCell.bg!==E){if(k-p>1){let x=this._getJoinedRanges(g,f,v,s,p);for(let C=0;C<x.length;C++)d.push(x[C])}p=k,f=v,m=this._workCell.fg,E=this._workCell.bg}v+=this._workCell.getChars().length||a.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-p>1){let k=this._getJoinedRanges(g,f,v,s,p);for(let x=0;x<k.length;x++)d.push(k[x])}return d}_getJoinedRanges(e,s,d,g,p){let v=e.substring(s,d),f=[];try{f=this._characterJoiners[0].handler(v)}catch(m){console.error(m)}for(let m=1;m<this._characterJoiners.length;m++)try{let E=this._characterJoiners[m].handler(v);for(let k=0;k<E.length;k++)ii._mergeRanges(f,E[k])}catch(E){console.error(E)}return this._stringRangesToCellRanges(f,g,p),f}_stringRangesToCellRanges(e,s,d){let g=0,p=!1,v=0,f=e[g];if(f){for(let m=d;m<this._bufferService.cols;m++){let E=s.getWidth(m),k=s.getString(m).length||a.WHITESPACE_CELL_CHAR.length;if(E!==0){if(!p&&f[0]<=v&&(f[0]=m,p=!0),f[1]<=v){if(f[1]=m,f=e[++g],!f)break;f[0]<=v?(f[0]=m,p=!0):p=!1}v+=k}}f&&(f[1]=this._bufferService.cols)}}static _mergeRanges(e,s){let d=!1;for(let g=0;g<e.length;g++){let p=e[g];if(d){if(s[1]<=p[0])return e[g-1][1]=s[1],e;if(s[1]<=p[1])return e[g-1][1]=Math.max(s[1],p[1]),e.splice(g,1),e;e.splice(g,1),g--}else{if(s[1]<=p[0])return e.splice(g,0,s),e;if(s[1]<=p[1])return p[0]=Math.min(s[0],p[0]),e;s[0]<p[1]&&(p[0]=Math.min(s[0],p[0]),d=!0)}}return d?e[e.length-1][1]=s[1]:e.push(s),e}};r.CharacterJoinerService=i=c([u(0,_.IBufferService)],i)},5114:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreBrowserService=void 0;let c=o(844),u=o(8460),n=o(3656);class a extends c.Disposable{constructor(l,i,t){super(),this._textarea=l,this._window=i,this.mainDocument=t,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new h(this._window),this._onDprChange=this.register(new u.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new u.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((e=>this._screenDprMonitor.setWindow(e)))),this.register((0,u.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(l){this._window!==l&&(this._window=l,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}}r.CoreBrowserService=a;class h extends c.Disposable{constructor(l){super(),this._parentWindow=l,this._windowResizeListener=this.register(new c.MutableDisposable),this._onDprChange=this.register(new u.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,c.toDisposable)((()=>this.clearListener())))}setWindow(l){this._parentWindow=l,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,n.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.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)}}},779:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.LinkProviderService=void 0;let c=o(844);class u extends c.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,c.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(a){return this.linkProviders.push(a),{dispose:()=>{let h=this.linkProviders.indexOf(a);h!==-1&&this.linkProviders.splice(h,1)}}}}r.LinkProviderService=u},8934:function(D,r,o){var c=this&&this.__decorate||function(_,l,i,t){var e,s=arguments.length,d=s<3?l:t===null?t=Object.getOwnPropertyDescriptor(l,i):t;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")d=Reflect.decorate(_,l,i,t);else for(var g=_.length-1;g>=0;g--)(e=_[g])&&(d=(s<3?e(d):s>3?e(l,i,d):e(l,i))||d);return s>3&&d&&Object.defineProperty(l,i,d),d},u=this&&this.__param||function(_,l){return function(i,t){l(i,t,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.MouseService=void 0;let n=o(4725),a=o(9806),h=r.MouseService=class{constructor(_,l){this._renderService=_,this._charSizeService=l}getCoords(_,l,i,t,e){return(0,a.getCoords)(window,_,l,i,t,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,e)}getMouseReportCoords(_,l){let i=(0,a.getCoordsRelativeToElement)(window,_,l);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])}}};r.MouseService=h=c([u(0,n.IRenderService),u(1,n.ICharSizeService)],h)},3230:function(D,r,o){var c=this&&this.__decorate||function(e,s,d,g){var p,v=arguments.length,f=v<3?s:g===null?g=Object.getOwnPropertyDescriptor(s,d):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(e,s,d,g);else for(var m=e.length-1;m>=0;m--)(p=e[m])&&(f=(v<3?p(f):v>3?p(s,d,f):p(s,d))||f);return v>3&&f&&Object.defineProperty(s,d,f),f},u=this&&this.__param||function(e,s){return function(d,g){s(d,g,e)}};Object.defineProperty(r,"__esModule",{value:!0}),r.RenderService=void 0;let n=o(6193),a=o(4725),h=o(8460),_=o(844),l=o(7226),i=o(2585),t=r.RenderService=class extends _.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(e,s,d,g,p,v,f,m){super(),this._rowCount=e,this._charSizeService=g,this._renderer=this.register(new _.MutableDisposable),this._pausedResizeTask=new l.DebouncedIdleTask,this._observerDisposable=this.register(new _.MutableDisposable),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 h.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new h.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new h.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new h.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new n.RenderDebouncer(((E,k)=>this._renderRows(E,k)),f),this.register(this._renderDebouncer),this.register(f.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(v.onResize((()=>this._fullRefresh()))),this.register(v.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this.register(d.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(p.onDecorationRegistered((()=>this._fullRefresh()))),this.register(p.onDecorationRemoved((()=>this._fullRefresh()))),this.register(d.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(v.cols,v.rows),this._fullRefresh()}))),this.register(d.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(v.buffer.y,v.buffer.y,!0)))),this.register(m.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(f.window,s),this.register(f.onWindowChange((E=>this._registerIntersectionObserver(E,s))))}_registerIntersectionObserver(e,s){if("IntersectionObserver"in e){let d=new e.IntersectionObserver((g=>this._handleIntersectionChange(g[g.length-1])),{threshold:0});d.observe(s),this._observerDisposable.value=(0,_.toDisposable)((()=>d.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,s,d=!1){this._isPaused?this._needsFullRefresh=!0:(d||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,s,this._rowCount))}_renderRows(e,s){this._renderer.value&&(e=Math.min(e,this._rowCount-1),s=Math.min(s,this._rowCount-1),this._renderer.value.renderRows(e,s),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:s}),this._onRender.fire({start:e,end:s}),this._isNextRenderRedrawOnly=!0)}resize(e,s){this._rowCount=s,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((s=>this.refreshRows(s.start,s.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(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,s){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(e,s))):this._renderer.value.handleResize(e,s),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,s,d){this._selectionState.start=e,this._selectionState.end=s,this._selectionState.columnSelectMode=d,this._renderer.value?.handleSelectionChanged(e,s,d)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};r.RenderService=t=c([u(2,i.IOptionsService),u(3,a.ICharSizeService),u(4,i.IDecorationService),u(5,i.IBufferService),u(6,a.ICoreBrowserService),u(7,a.IThemeService)],t)},9312:function(D,r,o){var c=this&&this.__decorate||function(f,m,E,k){var x,C=arguments.length,M=C<3?m:k===null?k=Object.getOwnPropertyDescriptor(m,E):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(f,m,E,k);else for(var z=f.length-1;z>=0;z--)(x=f[z])&&(M=(C<3?x(M):C>3?x(m,E,M):x(m,E))||M);return C>3&&M&&Object.defineProperty(m,E,M),M},u=this&&this.__param||function(f,m){return function(E,k){m(E,k,f)}};Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionService=void 0;let n=o(9806),a=o(9504),h=o(456),_=o(4725),l=o(8460),i=o(844),t=o(6114),e=o(4841),s=o(511),d=o(2585),g="\xA0",p=new RegExp(g,"g"),v=r.SelectionService=class extends i.Disposable{constructor(f,m,E,k,x,C,M,z,j){super(),this._element=f,this._screenElement=m,this._linkifier=E,this._bufferService=k,this._coreService=x,this._mouseService=C,this._optionsService=M,this._renderService=z,this._coreBrowserService=j,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new s.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new l.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new l.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new l.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new l.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=U=>this._handleMouseMove(U),this._mouseUpListener=U=>this._handleMouseUp(U),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((U=>this._handleTrim(U))),this.register(this._bufferService.buffers.onBufferActivate((U=>this._handleBufferActivate(U)))),this.enable(),this._model=new h.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,i.toDisposable)((()=>{this._removeMouseDownListeners()})))}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 f=this._model.finalSelectionStart,m=this._model.finalSelectionEnd;return!(!f||!m||f[0]===m[0]&&f[1]===m[1])}get selectionText(){let f=this._model.finalSelectionStart,m=this._model.finalSelectionEnd;if(!f||!m)return"";let E=this._bufferService.buffer,k=[];if(this._activeSelectionMode===3){if(f[0]===m[0])return"";let x=f[0]<m[0]?f[0]:m[0],C=f[0]<m[0]?m[0]:f[0];for(let M=f[1];M<=m[1];M++){let z=E.translateBufferLineToString(M,!0,x,C);k.push(z)}}else{let x=f[1]===m[1]?m[0]:void 0;k.push(E.translateBufferLineToString(f[1],!0,f[0],x));for(let C=f[1]+1;C<=m[1]-1;C++){let M=E.lines.get(C),z=E.translateBufferLineToString(C,!0);M?.isWrapped?k[k.length-1]+=z:k.push(z)}if(f[1]!==m[1]){let C=E.lines.get(m[1]),M=E.translateBufferLineToString(m[1],!0,0,m[0]);C&&C.isWrapped?k[k.length-1]+=M:k.push(M)}}return k.map((x=>x.replace(p," "))).join(t.isWindows?`\r
6
+ WARNING: This link could potentially be dangerous`)){let t=window.open();if(t){try{t.opener=null}catch{}t.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}}r.OscLinkProvider=c=h([u(0,a.IBufferService),u(1,a.IOptionsService),u(2,a.IOscLinkService)],c)},6193:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.RenderDebouncer=void 0,r.RenderDebouncer=class{constructor(n,h){this._renderCallback=n,this._coreBrowserService=h,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,h,u){this._rowCount=u,n=n!==void 0?n:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h,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)return void this._runRefreshCallbacks();let n=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,h),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},3236:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Terminal=void 0;let h=n(3614),u=n(3656),o=n(3551),a=n(9042),c=n(3730),_=n(1680),l=n(3107),i=n(5744),t=n(2950),e=n(1296),s=n(428),d=n(4269),p=n(5114),g=n(8934),v=n(3230),f=n(9312),m=n(4725),L=n(6731),k=n(8055),E=n(8969),C=n(8460),B=n(844),z=n(6114),j=n(8437),U=n(2584),$=n(7399),b=n(5941),D=n(9074),R=n(2585),A=n(5435),H=n(4567),q=n(779);class X extends E.CoreTerminal{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}constructor(I={}){super(I),this.browser=z,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new B.MutableDisposable),this._onCursorMove=this.register(new C.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new C.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new C.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new C.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new C.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new C.EventEmitter),this._onBlur=this.register(new C.EventEmitter),this._onA11yCharEmitter=this.register(new C.EventEmitter),this._onA11yTabEmitter=this.register(new C.EventEmitter),this._onWillOpen=this.register(new C.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(D.DecorationService),this._instantiationService.setService(R.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(q.LinkProviderService),this._instantiationService.setService(m.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(c.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((w,N)=>this.refresh(w,N)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((w=>this._reportWindowsOptions(w)))),this.register(this._inputHandler.onColor((w=>this._handleColorEvent(w)))),this.register((0,C.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,C.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((w=>this._afterResize(w.cols,w.rows)))),this.register((0,B.toDisposable)((()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)})))}_handleColorEvent(I){if(this._themeService)for(let w of I){let N,F="";switch(w.index){case 256:N="foreground",F="10";break;case 257:N="background",F="11";break;case 258:N="cursor",F="12";break;default:N="ansi",F="4;"+w.index}switch(w.type){case 0:let K=k.color.toColorRGB(N==="ansi"?this._themeService.colors.ansi[w.index]:this._themeService.colors[N]);this.coreService.triggerDataEvent(`${U.C0.ESC}]${F};${(0,b.toRgbString)(K)}${U.C1_ESCAPED.ST}`);break;case 1:if(N==="ansi")this._themeService.modifyColors((V=>V.ansi[w.index]=k.channels.toColor(...w.color)));else{let V=N;this._themeService.modifyColors((ie=>ie[V]=k.channels.toColor(...w.color)))}break;case 2:this._themeService.restoreColor(w.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(I){I?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(H.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(I){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let I=this.buffer.ybase+this.buffer.y,w=this.buffer.lines.get(I);if(!w)return;let N=Math.min(this.buffer.x,this.cols-1),F=this._renderService.dimensions.css.cell.height,K=w.getWidth(N),V=this._renderService.dimensions.css.cell.width*K,ie=this.buffer.y*this._renderService.dimensions.css.cell.height,ce=N*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ce+"px",this.textarea.style.top=ie+"px",this.textarea.style.width=V+"px",this.textarea.style.height=F+"px",this.textarea.style.lineHeight=F+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(w=>{this.hasSelection()&&(0,h.copyHandler)(w,this._selectionService)})));let I=w=>(0,h.handlePasteEvent)(w,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",I)),this.register((0,u.addDisposableDomListener)(this.element,"paste",I)),z.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(w=>{w.button===2&&(0,h.rightClickHandler)(w,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(w=>{(0,h.rightClickHandler)(w,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),z.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(w=>{w.button===1&&(0,h.moveTextAreaUnderMouseCursor)(w,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(I=>this._keyUp(I)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(I=>this._keyDown(I)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(I=>this._keyPress(I)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(I=>this._compositionHelper.compositionupdate(I)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(I=>this._inputEvent(I)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(I){if(!I)throw new Error("Terminal requires a parent element.");if(I.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=I.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"),I.appendChild(this.element);let w=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),w.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,u.addDisposableDomListener)(this.screenElement,"mousemove",(N=>this.updateCursorStyle(N)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),w.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",a.promptLabel),z.isChromeOS||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._coreBrowserService=this.register(this._instantiationService.createInstance(p.CoreBrowserService,this.textarea,I.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(m.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(N=>this._handleTextAreaFocus(N)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(s.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(m.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(L.ThemeService),this._instantiationService.setService(m.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(d.CharacterJoinerService),this._instantiationService.setService(m.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(v.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(m.IRenderService,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(t.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(g.MouseService),this._instantiationService.setService(m.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(o.Linkifier,this.screenElement)),this.element.appendChild(w);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(_.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((N=>this.scrollLines(N.amount,N.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),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.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(f.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(m.ISelectionService,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(this._onScroll.event((N=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(l.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(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(H.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(N=>this._handleScreenReaderModeOptionChange(N)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(i.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(N=>{!this._overviewRulerRenderer&&N&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(i.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(e.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let I=this,w=this.element;function N(V){let ie=I._mouseService.getMouseReportCoords(V,I.screenElement);if(!ie)return!1;let ce,le;switch(V.overrideType||V.type){case"mousemove":le=32,V.buttons===void 0?(ce=3,V.button!==void 0&&(ce=V.button<3?V.button:3)):ce=1&V.buttons?0:4&V.buttons?1:2&V.buttons?2:3;break;case"mouseup":le=0,ce=V.button<3?V.button:3;break;case"mousedown":le=1,ce=V.button<3?V.button:3;break;case"wheel":if(I._customWheelEventHandler&&I._customWheelEventHandler(V)===!1||I.viewport.getLinesScrolled(V)===0)return!1;le=V.deltaY<0?0:1,ce=4;break;default:return!1}return!(le===void 0||ce===void 0||ce>4)&&I.coreMouseService.triggerMouseEvent({col:ie.col,row:ie.row,x:ie.x,y:ie.y,button:ce,action:le,ctrl:V.ctrlKey,alt:V.altKey,shift:V.shiftKey})}let F={mouseup:null,wheel:null,mousedrag:null,mousemove:null},K={mouseup:V=>(N(V),V.buttons||(this._document.removeEventListener("mouseup",F.mouseup),F.mousedrag&&this._document.removeEventListener("mousemove",F.mousedrag)),this.cancel(V)),wheel:V=>(N(V),this.cancel(V,!0)),mousedrag:V=>{V.buttons&&N(V)},mousemove:V=>{V.buttons||N(V)}};this.register(this.coreMouseService.onProtocolChange((V=>{V?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(V)),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()),8&V?F.mousemove||(w.addEventListener("mousemove",K.mousemove),F.mousemove=K.mousemove):(w.removeEventListener("mousemove",F.mousemove),F.mousemove=null),16&V?F.wheel||(w.addEventListener("wheel",K.wheel,{passive:!1}),F.wheel=K.wheel):(w.removeEventListener("wheel",F.wheel),F.wheel=null),2&V?F.mouseup||(F.mouseup=K.mouseup):(this._document.removeEventListener("mouseup",F.mouseup),F.mouseup=null),4&V?F.mousedrag||(F.mousedrag=K.mousedrag):(this._document.removeEventListener("mousemove",F.mousedrag),F.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(w,"mousedown",(V=>{if(V.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(V))return N(V),F.mouseup&&this._document.addEventListener("mouseup",F.mouseup),F.mousedrag&&this._document.addEventListener("mousemove",F.mousedrag),this.cancel(V)}))),this.register((0,u.addDisposableDomListener)(w,"wheel",(V=>{if(!F.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(V)===!1)return!1;if(!this.buffer.hasScrollback){let ie=this.viewport.getLinesScrolled(V);if(ie===0)return;let ce=U.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(V.deltaY<0?"A":"B"),le="";for(let ne=0;ne<Math.abs(ie);ne++)le+=ce;return this.coreService.triggerDataEvent(le,!0),this.cancel(V,!0)}return this.viewport.handleWheel(V)?this.cancel(V):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(w,"touchstart",(V=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(V),this.cancel(V)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(w,"touchmove",(V=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(V)?void 0:this.cancel(V)}),{passive:!1}))}refresh(I,w){this._renderService?.refreshRows(I,w)}updateCursorStyle(I){this._selectionService?.shouldColumnSelect(I)?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(I,w,N=0){N===1?(super.scrollLines(I,w,N),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(I)}paste(I){(0,h.paste)(I,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(I){this._customKeyEventHandler=I}attachCustomWheelEventHandler(I){this._customWheelEventHandler=I}registerLinkProvider(I){return this._linkProviderService.registerLinkProvider(I)}registerCharacterJoiner(I){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let w=this._characterJoinerService.register(I);return this.refresh(0,this.rows-1),w}deregisterCharacterJoiner(I){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(I)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(I){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+I)}registerDecoration(I){return this._decorationService.registerDecoration(I)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(I,w,N){this._selectionService.setSelection(I,w,N)}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(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(I,w){this._selectionService?.selectLines(I,w)}_keyDown(I){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1)return!1;let w=this.browser.isMac&&this.options.macOptionIsMeta&&I.altKey;if(!w&&!this._compositionHelper.keydown(I))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;w||I.key!=="Dead"&&I.key!=="AltGraph"||(this._unprocessedDeadKey=!0);let N=(0,$.evaluateKeyboardEvent)(I,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(I),N.type===3||N.type===2){let F=this.rows-1;return this.scrollLines(N.type===2?-F:F),this.cancel(I,!0)}return N.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,I)||(N.cancel&&this.cancel(I,!0),!N.key||!!(I.key&&!I.ctrlKey&&!I.altKey&&!I.metaKey&&I.key.length===1&&I.key.charCodeAt(0)>=65&&I.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(N.key!==U.C0.ETX&&N.key!==U.C0.CR||(this.textarea.value=""),this._onKey.fire({key:N.key,domEvent:I}),this._showCursor(),this.coreService.triggerDataEvent(N.key,!0),!this.optionsService.rawOptions.screenReaderMode||I.altKey||I.ctrlKey?this.cancel(I,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(I,w){let N=I.isMac&&!this.options.macOptionIsMeta&&w.altKey&&!w.ctrlKey&&!w.metaKey||I.isWindows&&w.altKey&&w.ctrlKey&&!w.metaKey||I.isWindows&&w.getModifierState("AltGraph");return w.type==="keypress"?N:N&&(!w.keyCode||w.keyCode>47)}_keyUp(I){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1||((function(w){return w.keyCode===16||w.keyCode===17||w.keyCode===18})(I)||this.focus(),this.updateCursorStyle(I),this._keyPressHandled=!1)}_keyPress(I){let w;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1)return!1;if(this.cancel(I),I.charCode)w=I.charCode;else if(I.which===null||I.which===void 0)w=I.keyCode;else{if(I.which===0||I.charCode===0)return!1;w=I.which}return!(!w||(I.altKey||I.ctrlKey||I.metaKey)&&!this._isThirdLevelShift(this.browser,I)||(w=String.fromCharCode(w),this._onKey.fire({key:w,domEvent:I}),this._showCursor(),this.coreService.triggerDataEvent(w,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(I){if(I.data&&I.inputType==="insertText"&&(!I.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let w=I.data;return this.coreService.triggerDataEvent(w,!0),this.cancel(I),!0}return!1}resize(I,w){I!==this.cols||w!==this.rows?super.resize(I,w):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(I,w){this._charSizeService?.measure(),this.viewport?.syncScrollArea(!0)}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 I=1;I<this.rows;I++)this.buffer.lines.push(this.buffer.getBlankLine(j.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),this.viewport?.reset(),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let I=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this.viewport?.reset(),this._customKeyEventHandler=I,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(U.C0.ESC+"[I"):this.coreService.triggerDataEvent(U.C0.ESC+"[O")}_reportWindowsOptions(I){if(this._renderService)switch(I){case A.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:let w=this._renderService.dimensions.css.canvas.width.toFixed(0),N=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${U.C0.ESC}[4;${N};${w}t`);break;case A.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:let F=this._renderService.dimensions.css.cell.width.toFixed(0),K=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${U.C0.ESC}[6;${K};${F}t`)}}cancel(I,w){if(this.options.cancelEvents||w)return I.preventDefault(),I.stopPropagation(),!1}}r.Terminal=X},9924:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TimeBasedDebouncer=void 0,r.TimeBasedDebouncer=class{constructor(n,h=1e3){this._renderCallback=n,this._debounceThresholdMS=h,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,h,u){this._rowCount=u,n=n!==void 0?n:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h;let o=Date.now();if(o-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=o,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=o-this._lastRefreshMs,c=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let n=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,h)}}},1680:function(x,r,n){var h=this&&this.__decorate||function(t,e,s,d){var p,g=arguments.length,v=g<3?e:d===null?d=Object.getOwnPropertyDescriptor(e,s):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(t,e,s,d);else for(var f=t.length-1;f>=0;f--)(p=t[f])&&(v=(g<3?p(v):g>3?p(e,s,v):p(e,s))||v);return g>3&&v&&Object.defineProperty(e,s,v),v},u=this&&this.__param||function(t,e){return function(s,d){e(s,d,t)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Viewport=void 0;let o=n(3656),a=n(4725),c=n(8460),_=n(844),l=n(2585),i=r.Viewport=class extends _.Disposable{constructor(t,e,s,d,p,g,v,f){super(),this._viewportElement=t,this._scrollArea=e,this._bufferService=s,this._optionsService=d,this._charSizeService=p,this._renderService=g,this._coreBrowserService=v,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new c.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,o.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((m=>this._activeBuffer=m.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((m=>this._renderDimensions=m))),this._handleThemeChange(f.colors),this.register(f.onChangeColors((m=>this._handleThemeChange(m)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(t){this._viewportElement.style.backgroundColor=t.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(t){if(t)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;let e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}let t=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==t&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=t),this._refreshAnimationFrame=null}syncScrollArea(t=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(t);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(t)}_handleScroll(t){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});let e=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:e,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;let t=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(t*(this._smoothScrollState.target-this._smoothScrollState.origin)),t<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(t,e){let s=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(e<0&&this._viewportElement.scrollTop!==0||e>0&&s<this._lastRecordedBufferHeight)||(t.cancelable&&t.preventDefault(),!1)}handleWheel(t){let e=this._getPixelsScrolled(t);return e!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+e:this._smoothScrollState.target+=e,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=e,this._bubbleScroll(t,e))}scrollLines(t){if(t!==0)if(this._optionsService.rawOptions.smoothScrollDuration){let e=t*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+e,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:t,suppressScrollEvent:!1})}_getPixelsScrolled(t){if(t.deltaY===0||t.shiftKey)return 0;let e=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_LINE?e*=this._currentRowHeight:t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(e*=this._currentRowHeight*this._bufferService.rows),e}getBufferElements(t,e){let s,d="",p=[],g=e??this._bufferService.buffer.lines.length,v=this._bufferService.buffer.lines;for(let f=t;f<g;f++){let m=v.get(f);if(!m)continue;let L=v.get(f+1)?.isWrapped;if(d+=m.translateToString(!L),!L||f===v.length-1){let k=document.createElement("div");k.textContent=d,p.push(k),d.length>0&&(s=k),d=""}}return{bufferElements:p,cursorElement:s}}getLinesScrolled(t){if(t.deltaY===0||t.shiftKey)return 0;let e=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(e/=this._currentRowHeight+0,this._wheelPartialScroll+=e,e=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(e*=this._bufferService.rows),e}_applyScrollModifier(t,e){let s=this._optionsService.rawOptions.fastScrollModifier;return s==="alt"&&e.altKey||s==="ctrl"&&e.ctrlKey||s==="shift"&&e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(t){this._lastTouchY=t.touches[0].pageY}handleTouchMove(t){let e=this._lastTouchY-t.touches[0].pageY;return this._lastTouchY=t.touches[0].pageY,e!==0&&(this._viewportElement.scrollTop+=e,this._bubbleScroll(t,e))}};r.Viewport=i=h([u(2,l.IBufferService),u(3,l.IOptionsService),u(4,a.ICharSizeService),u(5,a.IRenderService),u(6,a.ICoreBrowserService),u(7,a.IThemeService)],i)},3107:function(x,r,n){var h=this&&this.__decorate||function(l,i,t,e){var s,d=arguments.length,p=d<3?i:e===null?e=Object.getOwnPropertyDescriptor(i,t):e;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(l,i,t,e);else for(var g=l.length-1;g>=0;g--)(s=l[g])&&(p=(d<3?s(p):d>3?s(i,t,p):s(i,t))||p);return d>3&&p&&Object.defineProperty(i,t,p),p},u=this&&this.__param||function(l,i){return function(t,e){i(t,e,l)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferDecorationRenderer=void 0;let o=n(4725),a=n(844),c=n(2585),_=r.BufferDecorationRenderer=class extends a.Disposable{constructor(l,i,t,e,s){super(),this._screenElement=l,this._bufferService=i,this._coreBrowserService=t,this._decorationService=e,this._renderService=s,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((d=>this._removeDecoration(d)))),this.register((0,a.toDisposable)((()=>{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 l of this._decorationService.decorations)this._renderDecoration(l);this._dimensionsChanged=!1}_renderDecoration(l){this._refreshStyle(l),this._dimensionsChanged&&this._refreshXPosition(l)}_createElement(l){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",l?.options?.layer==="top"),i.style.width=`${Math.round((l.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=(l.options.height||1)*this._renderService.dimensions.css.cell.height+"px",i.style.top=(l.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let t=l.options.x??0;return t&&t>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(l,i),i}_refreshStyle(l){let i=l.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)l.element&&(l.element.style.display="none",l.onRenderEmitter.fire(l.element));else{let t=this._decorationElements.get(l);t||(t=this._createElement(l),l.element=t,this._decorationElements.set(l,t),this._container.appendChild(t),l.onDispose((()=>{this._decorationElements.delete(l),t.remove()}))),t.style.top=i*this._renderService.dimensions.css.cell.height+"px",t.style.display=this._altBufferIsActive?"none":"block",l.onRenderEmitter.fire(t)}}_refreshXPosition(l,i=l.element){if(!i)return;let t=l.options.x??0;(l.options.anchor||"left")==="right"?i.style.right=t?t*this._renderService.dimensions.css.cell.width+"px":"":i.style.left=t?t*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(l){this._decorationElements.get(l)?.remove(),this._decorationElements.delete(l),l.dispose()}};r.BufferDecorationRenderer=_=h([u(1,c.IBufferService),u(2,o.ICoreBrowserService),u(3,c.IDecorationService),u(4,o.IRenderService)],_)},5871:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorZoneStore=void 0,r.ColorZoneStore=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(n){if(n.options.overviewRulerOptions){for(let h of this._zones)if(h.color===n.options.overviewRulerOptions.color&&h.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(h,n.marker.line))return;if(this._lineAdjacentToZone(h,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(h,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,h){return h>=n.startBufferLine&&h<=n.endBufferLine}_lineAdjacentToZone(n,h,u){return h>=n.startBufferLine-this._linePadding[u||"full"]&&h<=n.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(n,h){n.startBufferLine=Math.min(n.startBufferLine,h),n.endBufferLine=Math.max(n.endBufferLine,h)}}},5744:function(x,r,n){var h=this&&this.__decorate||function(s,d,p,g){var v,f=arguments.length,m=f<3?d:g===null?g=Object.getOwnPropertyDescriptor(d,p):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(s,d,p,g);else for(var L=s.length-1;L>=0;L--)(v=s[L])&&(m=(f<3?v(m):f>3?v(d,p,m):v(d,p))||m);return f>3&&m&&Object.defineProperty(d,p,m),m},u=this&&this.__param||function(s,d){return function(p,g){d(p,g,s)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OverviewRulerRenderer=void 0;let o=n(5871),a=n(4725),c=n(844),_=n(2585),l={full:0,left:0,center:0,right:0},i={full:0,left:0,center:0,right:0},t={full:0,left:0,center:0,right:0},e=r.OverviewRulerRenderer=class extends c.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(s,d,p,g,v,f,m){super(),this._viewportElement=s,this._screenElement=d,this._bufferService=p,this._decorationService=g,this._renderService=v,this._optionsService=f,this._coreBrowserService=m,this._colorZoneStore=new o.ColorZoneStore,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(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement);let L=this._canvas.getContext("2d");if(!L)throw new Error("Ctx cannot be null");this._ctx=L,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,c.toDisposable)((()=>{this._canvas?.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){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())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){let s=Math.floor(this._canvas.width/3),d=Math.ceil(this._canvas.width/3);i.full=this._canvas.width,i.left=s,i.center=d,i.right=s,this._refreshDrawHeightConstants(),t.full=0,t.left=0,t.center=i.left,t.right=i.left+i.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowserService.dpr);let s=this._canvas.height/this._bufferService.buffer.lines.length,d=Math.round(Math.max(Math.min(s,12),6)*this._coreBrowserService.dpr);l.left=d,l.center=d,l.right=d}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.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 d of this._decorationService.decorations)this._colorZoneStore.addDecoration(d);this._ctx.lineWidth=1;let s=this._colorZoneStore.zones;for(let d of s)d.position!=="full"&&this._renderColorZone(d);for(let d of s)d.position==="full"&&this._renderColorZone(d);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(s){this._ctx.fillStyle=s.color,this._ctx.fillRect(t[s.position||"full"],Math.round((this._canvas.height-1)*(s.startBufferLine/this._bufferService.buffers.active.lines.length)-l[s.position||"full"]/2),i[s.position||"full"],Math.round((this._canvas.height-1)*((s.endBufferLine-s.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[s.position||"full"]))}_queueRefresh(s,d){this._shouldUpdateDimensions=s||this._shouldUpdateDimensions,this._shouldUpdateAnchor=d||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};r.OverviewRulerRenderer=e=h([u(2,_.IBufferService),u(3,_.IDecorationService),u(4,a.IRenderService),u(5,_.IOptionsService),u(6,a.ICoreBrowserService)],e)},2950:function(x,r,n){var h=this&&this.__decorate||function(l,i,t,e){var s,d=arguments.length,p=d<3?i:e===null?e=Object.getOwnPropertyDescriptor(i,t):e;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(l,i,t,e);else for(var g=l.length-1;g>=0;g--)(s=l[g])&&(p=(d<3?s(p):d>3?s(i,t,p):s(i,t))||p);return d>3&&p&&Object.defineProperty(i,t,p),p},u=this&&this.__param||function(l,i){return function(t,e){i(t,e,l)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CompositionHelper=void 0;let o=n(4725),a=n(2585),c=n(2584),_=r.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(l,i,t,e,s,d){this._textarea=l,this._compositionView=i,this._bufferService=t,this._optionsService=e,this._coreService=s,this._renderService=d,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(l){this._compositionView.textContent=l.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(l){if(this._isComposing||this._isSendingComposition){if(l.keyCode===229||l.keyCode===16||l.keyCode===17||l.keyCode===18)return!1;this._finalizeComposition(!1)}return l.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(l){if(this._compositionView.classList.remove("active"),this._isComposing=!1,l){let i={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let t;this._isSendingComposition=!1,i.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(i.start,i.end):this._textarea.value.substring(i.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}}),0)}else{this._isSendingComposition=!1;let i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}}_handleAnyTextareaChanges(){let l=this._textarea.value;setTimeout((()=>{if(!this._isComposing){let i=this._textarea.value,t=i.replace(l,"");this._dataAlreadySent=t,i.length>l.length?this._coreService.triggerDataEvent(t,!0):i.length<l.length?this._coreService.triggerDataEvent(`${c.C0.DEL}`,!0):i.length===l.length&&i!==l&&this._coreService.triggerDataEvent(i,!0)}}),0)}updateCompositionElements(l){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,e=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=i*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=e+"px",this._compositionView.style.height=t+"px",this._compositionView.style.lineHeight=t+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let d=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=e+"px",this._textarea.style.width=Math.max(d.width,1)+"px",this._textarea.style.height=Math.max(d.height,1)+"px",this._textarea.style.lineHeight=d.height+"px"}l||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};r.CompositionHelper=_=h([u(2,a.IBufferService),u(3,a.IOptionsService),u(4,a.ICoreService),u(5,o.IRenderService)],_)},9806:(x,r)=>{function n(h,u,o){let a=o.getBoundingClientRect(),c=h.getComputedStyle(o),_=parseInt(c.getPropertyValue("padding-left")),l=parseInt(c.getPropertyValue("padding-top"));return[u.clientX-a.left-_,u.clientY-a.top-l]}Object.defineProperty(r,"__esModule",{value:!0}),r.getCoords=r.getCoordsRelativeToElement=void 0,r.getCoordsRelativeToElement=n,r.getCoords=function(h,u,o,a,c,_,l,i,t){if(!_)return;let e=n(h,u,o);return e?(e[0]=Math.ceil((e[0]+(t?l/2:0))/l),e[1]=Math.ceil(e[1]/i),e[0]=Math.min(Math.max(e[0],1),a+(t?1:0)),e[1]=Math.min(Math.max(e[1],1),c),e):void 0}},9504:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.moveToCellSequence=void 0;let h=n(2584);function u(i,t,e,s){let d=i-o(i,e),p=t-o(t,e),g=Math.abs(d-p)-(function(v,f,m){let L=0,k=v-o(v,m),E=f-o(f,m);for(let C=0;C<Math.abs(k-E);C++){let B=a(v,f)==="A"?-1:1;m.buffer.lines.get(k+B*C)?.isWrapped&&L++}return L})(i,t,e);return l(g,_(a(i,t),s))}function o(i,t){let e=0,s=t.buffer.lines.get(i),d=s?.isWrapped;for(;d&&i>=0&&i<t.rows;)e++,s=t.buffer.lines.get(--i),d=s?.isWrapped;return e}function a(i,t){return i>t?"A":"B"}function c(i,t,e,s,d,p){let g=i,v=t,f="";for(;g!==e||v!==s;)g+=d?1:-1,d&&g>p.cols-1?(f+=p.buffer.translateBufferLineToString(v,!1,i,g),g=0,i=0,v++):!d&&g<0&&(f+=p.buffer.translateBufferLineToString(v,!1,0,i+1),g=p.cols-1,i=g,v--);return f+p.buffer.translateBufferLineToString(v,!1,i,g)}function _(i,t){let e=t?"O":"[";return h.C0.ESC+e+i}function l(i,t){i=Math.floor(i);let e="";for(let s=0;s<i;s++)e+=t;return e}r.moveToCellSequence=function(i,t,e,s){let d=e.buffer.x,p=e.buffer.y;if(!e.buffer.hasScrollback)return(function(f,m,L,k,E,C){return u(m,k,E,C).length===0?"":l(c(f,m,f,m-o(m,E),!1,E).length,_("D",C))})(d,p,0,t,e,s)+u(p,t,e,s)+(function(f,m,L,k,E,C){let B;B=u(m,k,E,C).length>0?k-o(k,E):m;let z=k,j=(function(U,$,b,D,R,A){let H;return H=u(b,D,R,A).length>0?D-o(D,R):$,U<b&&H<=D||U>=b&&H<D?"C":"D"})(f,m,L,k,E,C);return l(c(f,B,L,z,j==="C",E).length,_(j,C))})(d,p,i,t,e,s);let g;if(p===t)return g=d>i?"D":"C",l(Math.abs(d-i),_(g,s));g=p>t?"D":"C";let v=Math.abs(p-t);return l((function(f,m){return m.cols-f})(p>t?i:d,e)+(v-1)*e.cols+1+((p>t?d:i)-1),_(g,s))}},1296:function(x,r,n){var h=this&&this.__decorate||function(C,B,z,j){var U,$=arguments.length,b=$<3?B:j===null?j=Object.getOwnPropertyDescriptor(B,z):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(C,B,z,j);else for(var D=C.length-1;D>=0;D--)(U=C[D])&&(b=($<3?U(b):$>3?U(B,z,b):U(B,z))||b);return $>3&&b&&Object.defineProperty(B,z,b),b},u=this&&this.__param||function(C,B){return function(z,j){B(z,j,C)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRenderer=void 0;let o=n(3787),a=n(2550),c=n(2223),_=n(6171),l=n(6052),i=n(4725),t=n(8055),e=n(8460),s=n(844),d=n(2585),p="xterm-dom-renderer-owner-",g="xterm-rows",v="xterm-fg-",f="xterm-bg-",m="xterm-focus",L="xterm-selection",k=1,E=r.DomRenderer=class extends s.Disposable{constructor(C,B,z,j,U,$,b,D,R,A,H,q,X){super(),this._terminal=C,this._document=B,this._element=z,this._screenElement=j,this._viewportElement=U,this._helperContainer=$,this._linkifier2=b,this._charSizeService=R,this._optionsService=A,this._bufferService=H,this._coreBrowserService=q,this._themeService=X,this._terminalClass=k++,this._rowElements=[],this._selectionRenderModel=(0,l.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new e.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(g),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(L),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,_.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((Y=>this._injectCss(Y)))),this._injectCss(this._themeService.colors),this._rowFactory=D.createInstance(o.DomRendererRowFactory,document),this._element.classList.add(p+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((Y=>this._handleLinkHover(Y)))),this.register(this._linkifier2.onHideLinkUnderline((Y=>this._handleLinkLeave(Y)))),this.register((0,s.toDisposable)((()=>{this._element.classList.remove(p+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new a.WidthCache(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 C=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*C,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*C),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/C),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/C),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 z of this._rowElements)z.style.width=`${this.dimensions.css.canvas.width}px`,z.style.height=`${this.dimensions.css.cell.height}px`,z.style.lineHeight=`${this.dimensions.css.cell.height}px`,z.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let B=`${this._terminalSelector} .${g} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=B,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(C){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let B=`${this._terminalSelector} .${g} { color: ${C.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;B+=`${this._terminalSelector} .${g} .xterm-dim { color: ${t.color.multiplyOpacity(C.foreground,.5).css};}`,B+=`${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 z=`blink_underline_${this._terminalClass}`,j=`blink_bar_${this._terminalClass}`,U=`blink_block_${this._terminalClass}`;B+=`@keyframes ${z} { 50% { border-bottom-style: hidden; }}`,B+=`@keyframes ${j} { 50% { box-shadow: none; }}`,B+=`@keyframes ${U} { 0% { background-color: ${C.cursor.css}; color: ${C.cursorAccent.css}; } 50% { background-color: inherit; color: ${C.cursor.css}; }}`,B+=`${this._terminalSelector} .${g}.${m} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${z} 1s step-end infinite;}${this._terminalSelector} .${g}.${m} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${j} 1s step-end infinite;}${this._terminalSelector} .${g}.${m} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${U} 1s step-end infinite;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block { background-color: ${C.cursor.css}; color: ${C.cursorAccent.css};}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${C.cursor.css} !important; color: ${C.cursorAccent.css} !important;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${C.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${C.cursor.css} inset;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${C.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,B+=`${this._terminalSelector} .${L} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${L} div { position: absolute; background-color: ${C.selectionBackgroundOpaque.css};}${this._terminalSelector} .${L} div { position: absolute; background-color: ${C.selectionInactiveBackgroundOpaque.css};}`;for(let[$,b]of C.ansi.entries())B+=`${this._terminalSelector} .${v}${$} { color: ${b.css}; }${this._terminalSelector} .${v}${$}.xterm-dim { color: ${t.color.multiplyOpacity(b,.5).css}; }${this._terminalSelector} .${f}${$} { background-color: ${b.css}; }`;B+=`${this._terminalSelector} .${v}${c.INVERTED_DEFAULT_COLOR} { color: ${t.color.opaque(C.background).css}; }${this._terminalSelector} .${v}${c.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${t.color.multiplyOpacity(t.color.opaque(C.background),.5).css}; }${this._terminalSelector} .${f}${c.INVERTED_DEFAULT_COLOR} { background-color: ${C.foreground.css}; }`,this._themeStyleElement.textContent=B}_setDefaultSpacing(){let C=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${C}px`,this._rowFactory.defaultSpacing=C}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(C,B){for(let z=this._rowElements.length;z<=B;z++){let j=this._document.createElement("div");this._rowContainer.appendChild(j),this._rowElements.push(j)}for(;this._rowElements.length>B;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(C,B){this._refreshRowElements(C,B),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(m),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(m),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(C,B,z){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(C,B,z),this.renderRows(0,this._bufferService.rows-1),!C||!B)return;this._selectionRenderModel.update(this._terminal,C,B,z);let j=this._selectionRenderModel.viewportStartRow,U=this._selectionRenderModel.viewportEndRow,$=this._selectionRenderModel.viewportCappedStartRow,b=this._selectionRenderModel.viewportCappedEndRow;if($>=this._bufferService.rows||b<0)return;let D=this._document.createDocumentFragment();if(z){let R=C[0]>B[0];D.appendChild(this._createSelectionElement($,R?B[0]:C[0],R?C[0]:B[0],b-$+1))}else{let R=j===$?C[0]:0,A=$===U?B[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement($,R,A));let H=b-$-1;if(D.appendChild(this._createSelectionElement($+1,0,this._bufferService.cols,H)),$!==b){let q=U===b?B[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement(b,0,q))}}this._selectionContainer.appendChild(D)}_createSelectionElement(C,B,z,j=1){let U=this._document.createElement("div"),$=B*this.dimensions.css.cell.width,b=this.dimensions.css.cell.width*(z-B);return $+b>this.dimensions.css.canvas.width&&(b=this.dimensions.css.canvas.width-$),U.style.height=j*this.dimensions.css.cell.height+"px",U.style.top=C*this.dimensions.css.cell.height+"px",U.style.left=`${$}px`,U.style.width=`${b}px`,U}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 C of this._rowElements)C.replaceChildren()}renderRows(C,B){let z=this._bufferService.buffer,j=z.ybase+z.y,U=Math.min(z.x,this._bufferService.cols-1),$=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,D=this._optionsService.rawOptions.cursorInactiveStyle;for(let R=C;R<=B;R++){let A=R+z.ydisp,H=this._rowElements[R],q=z.lines.get(A);if(!H||!q)break;H.replaceChildren(...this._rowFactory.createRow(q,A,A===j,b,D,U,$,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${p}${this._terminalClass}`}_handleLinkHover(C){this._setCellUnderline(C.x1,C.x2,C.y1,C.y2,C.cols,!0)}_handleLinkLeave(C){this._setCellUnderline(C.x1,C.x2,C.y1,C.y2,C.cols,!1)}_setCellUnderline(C,B,z,j,U,$){z<0&&(C=0),j<0&&(B=0);let b=this._bufferService.rows-1;z=Math.max(Math.min(z,b),0),j=Math.max(Math.min(j,b),0),U=Math.min(U,this._bufferService.cols);let D=this._bufferService.buffer,R=D.ybase+D.y,A=Math.min(D.x,U-1),H=this._optionsService.rawOptions.cursorBlink,q=this._optionsService.rawOptions.cursorStyle,X=this._optionsService.rawOptions.cursorInactiveStyle;for(let Y=z;Y<=j;++Y){let I=Y+D.ydisp,w=this._rowElements[Y],N=D.lines.get(I);if(!w||!N)break;w.replaceChildren(...this._rowFactory.createRow(N,I,I===R,q,X,A,H,this.dimensions.css.cell.width,this._widthCache,$?Y===z?C:0:-1,$?(Y===j?B:U)-1:-1))}}};r.DomRenderer=E=h([u(7,d.IInstantiationService),u(8,i.ICharSizeService),u(9,d.IOptionsService),u(10,d.IBufferService),u(11,i.ICoreBrowserService),u(12,i.IThemeService)],E)},3787:function(x,r,n){var h=this&&this.__decorate||function(g,v,f,m){var L,k=arguments.length,E=k<3?v:m===null?m=Object.getOwnPropertyDescriptor(v,f):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(g,v,f,m);else for(var C=g.length-1;C>=0;C--)(L=g[C])&&(E=(k<3?L(E):k>3?L(v,f,E):L(v,f))||E);return k>3&&E&&Object.defineProperty(v,f,E),E},u=this&&this.__param||function(g,v){return function(f,m){v(f,m,g)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRendererRowFactory=void 0;let o=n(2223),a=n(643),c=n(511),_=n(2585),l=n(8055),i=n(4725),t=n(4269),e=n(6171),s=n(3734),d=r.DomRendererRowFactory=class{constructor(g,v,f,m,L,k,E){this._document=g,this._characterJoinerService=v,this._optionsService=f,this._coreBrowserService=m,this._coreService=L,this._decorationService=k,this._themeService=E,this._workCell=new c.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(g,v,f){this._selectionStart=g,this._selectionEnd=v,this._columnSelectMode=f}createRow(g,v,f,m,L,k,E,C,B,z,j){let U=[],$=this._characterJoinerService.getJoinedCharacters(v),b=this._themeService.colors,D,R=g.getNoBgTrimmedLength();f&&R<k+1&&(R=k+1);let A=0,H="",q=0,X=0,Y=0,I=!1,w=0,N=!1,F=0,K=[],V=z!==-1&&j!==-1;for(let ie=0;ie<R;ie++){g.loadCell(ie,this._workCell);let ce=this._workCell.getWidth();if(ce===0)continue;let le=!1,ne=ie,G=this._workCell;if($.length>0&&ie===$[0][0]){le=!0;let oe=$.shift();G=new t.JoinedCellData(this._workCell,g.translateToString(!0,oe[0],oe[1]),oe[1]-oe[0]),ne=oe[1]-1,ce=G.getWidth()}let Ne=this._isCellInSelection(ie,v),We=f&&ie===k,qe=V&&ie>=z&&ie<=j,Ke=!1;this._decorationService.forEachDecorationAtCell(ie,v,void 0,(oe=>{Ke=!0}));let $e=G.getChars()||a.WHITESPACE_CELL_CHAR;if($e===" "&&(G.isUnderline()||G.isOverline())&&($e="\xA0"),F=ce*C-B.get($e,G.isBold(),G.isItalic()),D){if(A&&(Ne&&N||!Ne&&!N&&G.bg===q)&&(Ne&&N&&b.selectionForeground||G.fg===X)&&G.extended.ext===Y&&qe===I&&F===w&&!We&&!le&&!Ke){G.isInvisible()?H+=a.WHITESPACE_CELL_CHAR:H+=$e,A++;continue}A&&(D.textContent=H),D=this._document.createElement("span"),A=0,H=""}else D=this._document.createElement("span");if(q=G.bg,X=G.fg,Y=G.extended.ext,I=qe,w=F,N=Ne,le&&k>=ie&&k<=ne&&(k=ie),!this._coreService.isCursorHidden&&We&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)E&&K.push("xterm-cursor-blink"),K.push(m==="bar"?"xterm-cursor-bar":m==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(L)switch(L){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline")}}if(G.isBold()&&K.push("xterm-bold"),G.isItalic()&&K.push("xterm-italic"),G.isDim()&&K.push("xterm-dim"),H=G.isInvisible()?a.WHITESPACE_CELL_CHAR:G.getChars()||a.WHITESPACE_CELL_CHAR,G.isUnderline()&&(K.push(`xterm-underline-${G.extended.underlineStyle}`),H===" "&&(H="\xA0"),!G.isUnderlineColorDefault()))if(G.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${s.AttributeData.toColorRGB(G.getUnderlineColor()).join(",")})`;else{let oe=G.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&G.isBold()&&oe<8&&(oe+=8),D.style.textDecorationColor=b.ansi[oe].css}G.isOverline()&&(K.push("xterm-overline"),H===" "&&(H="\xA0")),G.isStrikethrough()&&K.push("xterm-strikethrough"),qe&&(D.style.textDecoration="underline");let ye=G.getFgColor(),Ae=G.getFgColorMode(),Re=G.getBgColor(),Fe=G.getBgColorMode(),tt=!!G.isInverse();if(tt){let oe=ye;ye=Re,Re=oe;let xe=Ae;Ae=Fe,Fe=xe}let pe,ke,Me,Te=!1;switch(this._decorationService.forEachDecorationAtCell(ie,v,void 0,(oe=>{oe.options.layer!=="top"&&Te||(oe.backgroundColorRGB&&(Fe=50331648,Re=oe.backgroundColorRGB.rgba>>8&16777215,pe=oe.backgroundColorRGB),oe.foregroundColorRGB&&(Ae=50331648,ye=oe.foregroundColorRGB.rgba>>8&16777215,ke=oe.foregroundColorRGB),Te=oe.options.layer==="top")})),!Te&&Ne&&(pe=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,Re=pe.rgba>>8&16777215,Fe=50331648,Te=!0,b.selectionForeground&&(Ae=50331648,ye=b.selectionForeground.rgba>>8&16777215,ke=b.selectionForeground)),Te&&K.push("xterm-decoration-top"),Fe){case 16777216:case 33554432:Me=b.ansi[Re],K.push(`xterm-bg-${Re}`);break;case 50331648:Me=l.channels.toColor(Re>>16,Re>>8&255,255&Re),this._addStyle(D,`background-color:#${p((Re>>>0).toString(16),"0",6)}`);break;default:tt?(Me=b.foreground,K.push(`xterm-bg-${o.INVERTED_DEFAULT_COLOR}`)):Me=b.background}switch(pe||G.isDim()&&(pe=l.color.multiplyOpacity(Me,.5)),Ae){case 16777216:case 33554432:G.isBold()&&ye<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ye+=8),this._applyMinimumContrast(D,Me,b.ansi[ye],G,pe,void 0)||K.push(`xterm-fg-${ye}`);break;case 50331648:let oe=l.channels.toColor(ye>>16&255,ye>>8&255,255&ye);this._applyMinimumContrast(D,Me,oe,G,pe,ke)||this._addStyle(D,`color:#${p(ye.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,Me,b.foreground,G,pe,ke)||tt&&K.push(`xterm-fg-${o.INVERTED_DEFAULT_COLOR}`)}K.length&&(D.className=K.join(" "),K.length=0),We||le||Ke?D.textContent=H:A++,F!==this.defaultSpacing&&(D.style.letterSpacing=`${F}px`),U.push(D),ie=ne}return D&&A&&(D.textContent=H),U}_applyMinimumContrast(g,v,f,m,L,k){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,e.treatGlyphAsBackgroundColor)(m.getCode()))return!1;let E=this._getContrastCache(m),C;if(L||k||(C=E.getColor(v.rgba,f.rgba)),C===void 0){let B=this._optionsService.rawOptions.minimumContrastRatio/(m.isDim()?2:1);C=l.color.ensureContrastRatio(L||v,k||f,B),E.setColor((L||v).rgba,(k||f).rgba,C??null)}return!!C&&(this._addStyle(g,`color:${C.css}`),!0)}_getContrastCache(g){return g.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(g,v){g.setAttribute("style",`${g.getAttribute("style")||""}${v};`)}_isCellInSelection(g,v){let f=this._selectionStart,m=this._selectionEnd;return!(!f||!m)&&(this._columnSelectMode?f[0]<=m[0]?g>=f[0]&&v>=f[1]&&g<m[0]&&v<=m[1]:g<f[0]&&v>=f[1]&&g>=m[0]&&v<=m[1]:v>f[1]&&v<m[1]||f[1]===m[1]&&v===f[1]&&g>=f[0]&&g<m[0]||f[1]<m[1]&&v===m[1]&&g<m[0]||f[1]<m[1]&&v===f[1]&&g>=f[0])}};function p(g,v,f){for(;g.length<f;)g=v+g;return g}r.DomRendererRowFactory=d=h([u(1,i.ICharacterJoinerService),u(2,_.IOptionsService),u(3,i.ICoreBrowserService),u(4,_.ICoreService),u(5,_.IDecorationService),u(6,i.IThemeService)],d)},2550:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WidthCache=void 0,r.WidthCache=class{constructor(n,h){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.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 u=n.createElement("span");u.classList.add("xterm-char-measure-element");let o=n.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold";let a=n.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontStyle="italic";let c=n.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[u,o,a,c],this._container.appendChild(u),this._container.appendChild(o),this._container.appendChild(a),this._container.appendChild(c),h.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(n,h,u,o){n===this._font&&h===this._fontSize&&u===this._weight&&o===this._weightBold||(this._font=n,this._fontSize=h,this._weight=u,this._weightBold=o,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${o}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${o}`,this.clear())}get(n,h,u){let o=0;if(!h&&!u&&n.length===1&&(o=n.charCodeAt(0))<256){if(this._flat[o]!==-9999)return this._flat[o];let _=this._measure(n,0);return _>0&&(this._flat[o]=_),_}let a=n;h&&(a+="B"),u&&(a+="I");let c=this._holey.get(a);if(c===void 0){let _=0;h&&(_|=1),u&&(_|=2),c=this._measure(n,_),c>0&&this._holey.set(a,c)}return c}_measure(n,h){let u=this._measureElements[h];return u.textContent=n.repeat(32),u.offsetWidth/32}}},2223:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TEXT_BASELINE=r.DIM_OPACITY=r.INVERTED_DEFAULT_COLOR=void 0;let h=n(6114);r.INVERTED_DEFAULT_COLOR=257,r.DIM_OPACITY=.5,r.TEXT_BASELINE=h.isFirefox||h.isLegacyEdge?"bottom":"ideographic"},6171:(x,r)=>{function n(u){return 57508<=u&&u<=57558}function h(u){return u>=128512&&u<=128591||u>=127744&&u<=128511||u>=128640&&u<=128767||u>=9728&&u<=9983||u>=9984&&u<=10175||u>=65024&&u<=65039||u>=129280&&u<=129535||u>=127462&&u<=127487}Object.defineProperty(r,"__esModule",{value:!0}),r.computeNextVariantOffset=r.createRenderDimensions=r.treatGlyphAsBackgroundColor=r.allowRescaling=r.isEmoji=r.isRestrictedPowerlineGlyph=r.isPowerlineGlyph=r.throwIfFalsy=void 0,r.throwIfFalsy=function(u){if(!u)throw new Error("value must not be falsy");return u},r.isPowerlineGlyph=n,r.isRestrictedPowerlineGlyph=function(u){return 57520<=u&&u<=57527},r.isEmoji=h,r.allowRescaling=function(u,o,a,c){return o===1&&a>Math.ceil(1.5*c)&&u!==void 0&&u>255&&!h(u)&&!n(u)&&!(function(_){return 57344<=_&&_<=63743})(u)},r.treatGlyphAsBackgroundColor=function(u){return n(u)||(function(o){return 9472<=o&&o<=9631})(u)},r.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},r.computeNextVariantOffset=function(u,o,a=0){return(u-(2*Math.round(o)-a))%(2*Math.round(o))}},6052:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createSelectionRenderModel=void 0;class n{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(u,o,a,c=!1){if(this.selectionStart=o,this.selectionEnd=a,!o||!a||o[0]===a[0]&&o[1]===a[1])return void this.clear();let _=u.buffers.active.ydisp,l=o[1]-_,i=a[1]-_,t=Math.max(l,0),e=Math.min(i,u.rows-1);t>=u.rows||e<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=c,this.viewportStartRow=l,this.viewportEndRow=i,this.viewportCappedStartRow=t,this.viewportCappedEndRow=e,this.startCol=o[0],this.endCol=a[0])}isCellSelected(u,o,a){return!!this.hasSelection&&(a-=u.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?o>=this.startCol&&a>=this.viewportCappedStartRow&&o<this.endCol&&a<=this.viewportCappedEndRow:o<this.startCol&&a>=this.viewportCappedStartRow&&o>=this.endCol&&a<=this.viewportCappedEndRow:a>this.viewportStartRow&&a<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&a===this.viewportStartRow&&o>=this.startCol&&o<this.endCol||this.viewportStartRow<this.viewportEndRow&&a===this.viewportEndRow&&o<this.endCol||this.viewportStartRow<this.viewportEndRow&&a===this.viewportStartRow&&o>=this.startCol)}}r.createSelectionRenderModel=function(){return new n}},456:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionModel=void 0,r.SelectionModel=class{constructor(n){this._bufferService=n,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.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 n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let n=this.selectionStart,h=this.selectionEnd;return!(!n||!h)&&(n[1]>h[1]||n[1]===h[1]&&n[0]>h[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(x,r,n){var h=this&&this.__decorate||function(e,s,d,p){var g,v=arguments.length,f=v<3?s:p===null?p=Object.getOwnPropertyDescriptor(s,d):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(e,s,d,p);else for(var m=e.length-1;m>=0;m--)(g=e[m])&&(f=(v<3?g(f):v>3?g(s,d,f):g(s,d))||f);return v>3&&f&&Object.defineProperty(s,d,f),f},u=this&&this.__param||function(e,s){return function(d,p){s(d,p,e)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharSizeService=void 0;let o=n(2585),a=n(8460),c=n(844),_=r.CharSizeService=class extends c.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(e,s,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new a.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new t(this._optionsService))}catch{this._measureStrategy=this.register(new i(e,s,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}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())}};r.CharSizeService=_=h([u(2,o.IOptionsService)],_);class l extends c.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(s,d){s!==void 0&&s>0&&d!==void 0&&d>0&&(this._result.width=s,this._result.height=d)}}class i extends l{constructor(s,d,p){super(),this._document=s,this._parentElement=d,this._optionsService=p,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}}class t extends l{constructor(s){super(),this._optionsService=s,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let d=this._ctx.measureText("W");if(!("width"in d&&"fontBoundingBoxAscent"in d&&"fontBoundingBoxDescent"in d))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let s=this._ctx.measureText("W");return this._validateAndSet(s.width,s.fontBoundingBoxAscent+s.fontBoundingBoxDescent),this._result}}},4269:function(x,r,n){var h=this&&this.__decorate||function(t,e,s,d){var p,g=arguments.length,v=g<3?e:d===null?d=Object.getOwnPropertyDescriptor(e,s):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(t,e,s,d);else for(var f=t.length-1;f>=0;f--)(p=t[f])&&(v=(g<3?p(v):g>3?p(e,s,v):p(e,s))||v);return g>3&&v&&Object.defineProperty(e,s,v),v},u=this&&this.__param||function(t,e){return function(s,d){e(s,d,t)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharacterJoinerService=r.JoinedCellData=void 0;let o=n(3734),a=n(643),c=n(511),_=n(2585);class l extends o.AttributeData{constructor(e,s,d){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=s,this._width=d}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()]}}r.JoinedCellData=l;let i=r.CharacterJoinerService=class ri{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new c.CellData}register(e){let s={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(s),s.id}deregister(e){for(let s=0;s<this._characterJoiners.length;s++)if(this._characterJoiners[s].id===e)return this._characterJoiners.splice(s,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let s=this._bufferService.buffer.lines.get(e);if(!s||s.length===0)return[];let d=[],p=s.translateToString(!0),g=0,v=0,f=0,m=s.getFg(0),L=s.getBg(0);for(let k=0;k<s.getTrimmedLength();k++)if(s.loadCell(k,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==m||this._workCell.bg!==L){if(k-g>1){let E=this._getJoinedRanges(p,f,v,s,g);for(let C=0;C<E.length;C++)d.push(E[C])}g=k,f=v,m=this._workCell.fg,L=this._workCell.bg}v+=this._workCell.getChars().length||a.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-g>1){let k=this._getJoinedRanges(p,f,v,s,g);for(let E=0;E<k.length;E++)d.push(k[E])}return d}_getJoinedRanges(e,s,d,p,g){let v=e.substring(s,d),f=[];try{f=this._characterJoiners[0].handler(v)}catch(m){console.error(m)}for(let m=1;m<this._characterJoiners.length;m++)try{let L=this._characterJoiners[m].handler(v);for(let k=0;k<L.length;k++)ri._mergeRanges(f,L[k])}catch(L){console.error(L)}return this._stringRangesToCellRanges(f,p,g),f}_stringRangesToCellRanges(e,s,d){let p=0,g=!1,v=0,f=e[p];if(f){for(let m=d;m<this._bufferService.cols;m++){let L=s.getWidth(m),k=s.getString(m).length||a.WHITESPACE_CELL_CHAR.length;if(L!==0){if(!g&&f[0]<=v&&(f[0]=m,g=!0),f[1]<=v){if(f[1]=m,f=e[++p],!f)break;f[0]<=v?(f[0]=m,g=!0):g=!1}v+=k}}f&&(f[1]=this._bufferService.cols)}}static _mergeRanges(e,s){let d=!1;for(let p=0;p<e.length;p++){let g=e[p];if(d){if(s[1]<=g[0])return e[p-1][1]=s[1],e;if(s[1]<=g[1])return e[p-1][1]=Math.max(s[1],g[1]),e.splice(p,1),e;e.splice(p,1),p--}else{if(s[1]<=g[0])return e.splice(p,0,s),e;if(s[1]<=g[1])return g[0]=Math.min(s[0],g[0]),e;s[0]<g[1]&&(g[0]=Math.min(s[0],g[0]),d=!0)}}return d?e[e.length-1][1]=s[1]:e.push(s),e}};r.CharacterJoinerService=i=h([u(0,_.IBufferService)],i)},5114:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreBrowserService=void 0;let h=n(844),u=n(8460),o=n(3656);class a extends h.Disposable{constructor(l,i,t){super(),this._textarea=l,this._window=i,this.mainDocument=t,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new c(this._window),this._onDprChange=this.register(new u.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new u.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((e=>this._screenDprMonitor.setWindow(e)))),this.register((0,u.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(l){this._window!==l&&(this._window=l,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}}r.CoreBrowserService=a;class c extends h.Disposable{constructor(l){super(),this._parentWindow=l,this._windowResizeListener=this.register(new h.MutableDisposable),this._onDprChange=this.register(new u.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,h.toDisposable)((()=>this.clearListener())))}setWindow(l){this._parentWindow=l,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,o.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.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)}}},779:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.LinkProviderService=void 0;let h=n(844);class u extends h.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,h.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(a){return this.linkProviders.push(a),{dispose:()=>{let c=this.linkProviders.indexOf(a);c!==-1&&this.linkProviders.splice(c,1)}}}}r.LinkProviderService=u},8934:function(x,r,n){var h=this&&this.__decorate||function(_,l,i,t){var e,s=arguments.length,d=s<3?l:t===null?t=Object.getOwnPropertyDescriptor(l,i):t;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")d=Reflect.decorate(_,l,i,t);else for(var p=_.length-1;p>=0;p--)(e=_[p])&&(d=(s<3?e(d):s>3?e(l,i,d):e(l,i))||d);return s>3&&d&&Object.defineProperty(l,i,d),d},u=this&&this.__param||function(_,l){return function(i,t){l(i,t,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.MouseService=void 0;let o=n(4725),a=n(9806),c=r.MouseService=class{constructor(_,l){this._renderService=_,this._charSizeService=l}getCoords(_,l,i,t,e){return(0,a.getCoords)(window,_,l,i,t,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,e)}getMouseReportCoords(_,l){let i=(0,a.getCoordsRelativeToElement)(window,_,l);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])}}};r.MouseService=c=h([u(0,o.IRenderService),u(1,o.ICharSizeService)],c)},3230:function(x,r,n){var h=this&&this.__decorate||function(e,s,d,p){var g,v=arguments.length,f=v<3?s:p===null?p=Object.getOwnPropertyDescriptor(s,d):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(e,s,d,p);else for(var m=e.length-1;m>=0;m--)(g=e[m])&&(f=(v<3?g(f):v>3?g(s,d,f):g(s,d))||f);return v>3&&f&&Object.defineProperty(s,d,f),f},u=this&&this.__param||function(e,s){return function(d,p){s(d,p,e)}};Object.defineProperty(r,"__esModule",{value:!0}),r.RenderService=void 0;let o=n(6193),a=n(4725),c=n(8460),_=n(844),l=n(7226),i=n(2585),t=r.RenderService=class extends _.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(e,s,d,p,g,v,f,m){super(),this._rowCount=e,this._charSizeService=p,this._renderer=this.register(new _.MutableDisposable),this._pausedResizeTask=new l.DebouncedIdleTask,this._observerDisposable=this.register(new _.MutableDisposable),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 c.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new c.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new c.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new c.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new o.RenderDebouncer(((L,k)=>this._renderRows(L,k)),f),this.register(this._renderDebouncer),this.register(f.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(v.onResize((()=>this._fullRefresh()))),this.register(v.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this.register(d.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(g.onDecorationRegistered((()=>this._fullRefresh()))),this.register(g.onDecorationRemoved((()=>this._fullRefresh()))),this.register(d.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(v.cols,v.rows),this._fullRefresh()}))),this.register(d.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(v.buffer.y,v.buffer.y,!0)))),this.register(m.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(f.window,s),this.register(f.onWindowChange((L=>this._registerIntersectionObserver(L,s))))}_registerIntersectionObserver(e,s){if("IntersectionObserver"in e){let d=new e.IntersectionObserver((p=>this._handleIntersectionChange(p[p.length-1])),{threshold:0});d.observe(s),this._observerDisposable.value=(0,_.toDisposable)((()=>d.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,s,d=!1){this._isPaused?this._needsFullRefresh=!0:(d||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,s,this._rowCount))}_renderRows(e,s){this._renderer.value&&(e=Math.min(e,this._rowCount-1),s=Math.min(s,this._rowCount-1),this._renderer.value.renderRows(e,s),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:s}),this._onRender.fire({start:e,end:s}),this._isNextRenderRedrawOnly=!0)}resize(e,s){this._rowCount=s,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((s=>this.refreshRows(s.start,s.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(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,s){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(e,s))):this._renderer.value.handleResize(e,s),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,s,d){this._selectionState.start=e,this._selectionState.end=s,this._selectionState.columnSelectMode=d,this._renderer.value?.handleSelectionChanged(e,s,d)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};r.RenderService=t=h([u(2,i.IOptionsService),u(3,a.ICharSizeService),u(4,i.IDecorationService),u(5,i.IBufferService),u(6,a.ICoreBrowserService),u(7,a.IThemeService)],t)},9312:function(x,r,n){var h=this&&this.__decorate||function(f,m,L,k){var E,C=arguments.length,B=C<3?m:k===null?k=Object.getOwnPropertyDescriptor(m,L):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(f,m,L,k);else for(var z=f.length-1;z>=0;z--)(E=f[z])&&(B=(C<3?E(B):C>3?E(m,L,B):E(m,L))||B);return C>3&&B&&Object.defineProperty(m,L,B),B},u=this&&this.__param||function(f,m){return function(L,k){m(L,k,f)}};Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionService=void 0;let o=n(9806),a=n(9504),c=n(456),_=n(4725),l=n(8460),i=n(844),t=n(6114),e=n(4841),s=n(511),d=n(2585),p="\xA0",g=new RegExp(p,"g"),v=r.SelectionService=class extends i.Disposable{constructor(f,m,L,k,E,C,B,z,j){super(),this._element=f,this._screenElement=m,this._linkifier=L,this._bufferService=k,this._coreService=E,this._mouseService=C,this._optionsService=B,this._renderService=z,this._coreBrowserService=j,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new s.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new l.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new l.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new l.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new l.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=U=>this._handleMouseMove(U),this._mouseUpListener=U=>this._handleMouseUp(U),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((U=>this._handleTrim(U))),this.register(this._bufferService.buffers.onBufferActivate((U=>this._handleBufferActivate(U)))),this.enable(),this._model=new c.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,i.toDisposable)((()=>{this._removeMouseDownListeners()})))}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 f=this._model.finalSelectionStart,m=this._model.finalSelectionEnd;return!(!f||!m||f[0]===m[0]&&f[1]===m[1])}get selectionText(){let f=this._model.finalSelectionStart,m=this._model.finalSelectionEnd;if(!f||!m)return"";let L=this._bufferService.buffer,k=[];if(this._activeSelectionMode===3){if(f[0]===m[0])return"";let E=f[0]<m[0]?f[0]:m[0],C=f[0]<m[0]?m[0]:f[0];for(let B=f[1];B<=m[1];B++){let z=L.translateBufferLineToString(B,!0,E,C);k.push(z)}}else{let E=f[1]===m[1]?m[0]:void 0;k.push(L.translateBufferLineToString(f[1],!0,f[0],E));for(let C=f[1]+1;C<=m[1]-1;C++){let B=L.lines.get(C),z=L.translateBufferLineToString(C,!0);B?.isWrapped?k[k.length-1]+=z:k.push(z)}if(f[1]!==m[1]){let C=L.lines.get(m[1]),B=L.translateBufferLineToString(m[1],!0,0,m[0]);C&&C.isWrapped?k[k.length-1]+=B:k.push(B)}}return k.map((E=>E.replace(g," "))).join(t.isWindows?`\r
7
7
  `:`
8
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(f){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),t.isLinux&&f&&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(f){let m=this._getMouseBufferCoords(f),E=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!!(E&&k&&m)&&this._areCoordsInSelection(m,E,k)}isCellInSelection(f,m){let E=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!(!E||!k)&&this._areCoordsInSelection([f,m],E,k)}_areCoordsInSelection(f,m,E){return f[1]>m[1]&&f[1]<E[1]||m[1]===E[1]&&f[1]===m[1]&&f[0]>=m[0]&&f[0]<E[0]||m[1]<E[1]&&f[1]===E[1]&&f[0]<E[0]||m[1]<E[1]&&f[1]===m[1]&&f[0]>=m[0]}_selectWordAtCursor(f,m){let E=this._linkifier.currentLink?.link?.range;if(E)return this._model.selectionStart=[E.start.x-1,E.start.y-1],this._model.selectionStartLength=(0,e.getRangeLength)(E,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let k=this._getMouseBufferCoords(f);return!!k&&(this._selectWordAt(k,m),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(f,m){this._model.clearSelection(),f=Math.max(f,0),m=Math.min(m,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,f],this._model.selectionEnd=[this._bufferService.cols,m],this.refresh(),this._onSelectionChange.fire()}_handleTrim(f){this._model.handleTrim(f)&&this.refresh()}_getMouseBufferCoords(f){let m=this._mouseService.getCoords(f,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(m)return m[0]--,m[1]--,m[1]+=this._bufferService.buffer.ydisp,m}_getMouseEventScrollAmount(f){let m=(0,n.getCoordsRelativeToElement)(this._coreBrowserService.window,f,this._screenElement)[1],E=this._renderService.dimensions.css.canvas.height;return m>=0&&m<=E?0:(m>E&&(m-=E),m=Math.min(Math.max(m,-50),50),m/=50,m/Math.abs(m)+Math.round(14*m))}shouldForceSelection(f){return t.isMac?f.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:f.shiftKey}handleMouseDown(f){if(this._mouseDownTimeStamp=f.timeStamp,(f.button!==2||!this.hasSelection)&&f.button===0){if(!this._enabled){if(!this.shouldForceSelection(f))return;f.stopPropagation()}f.preventDefault(),this._dragScrollAmount=0,this._enabled&&f.shiftKey?this._handleIncrementalClick(f):f.detail===1?this._handleSingleClick(f):f.detail===2?this._handleDoubleClick(f):f.detail===3&&this._handleTripleClick(f),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()),50)}_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(f){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(f))}_handleSingleClick(f){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(f)?3:0,this._model.selectionStart=this._getMouseBufferCoords(f),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let m=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);m&&m.length!==this._model.selectionStart[0]&&m.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(f){this._selectWordAtCursor(f,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(f){let m=this._getMouseBufferCoords(f);m&&(this._activeSelectionMode=2,this._selectLineAt(m[1]))}shouldColumnSelect(f){return f.altKey&&!(t.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(f){if(f.stopImmediatePropagation(),!this._model.selectionStart)return;let m=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(f),!this._model.selectionEnd)return void this.refresh(!0);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(f),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let E=this._bufferService.buffer;if(this._model.selectionEnd[1]<E.lines.length){let k=E.lines.get(this._model.selectionEnd[1]);k&&k.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}m&&m[0]===this._model.selectionEnd[0]&&m[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 f=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(f.ydisp+this._bufferService.rows,f.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=f.ydisp),this.refresh()}}_handleMouseUp(f){let m=f.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&m<500&&f.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let E=this._mouseService.getCoords(f,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(E&&E[0]!==void 0&&E[1]!==void 0){let k=(0,a.moveToCellSequence)(E[0]-1,E[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(k,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let f=this._model.finalSelectionStart,m=this._model.finalSelectionEnd,E=!(!f||!m||f[0]===m[0]&&f[1]===m[1]);E?f&&m&&(this._oldSelectionStart&&this._oldSelectionEnd&&f[0]===this._oldSelectionStart[0]&&f[1]===this._oldSelectionStart[1]&&m[0]===this._oldSelectionEnd[0]&&m[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(f,m,E)):this._oldHasSelection&&this._fireOnSelectionChange(f,m,E)}_fireOnSelectionChange(f,m,E){this._oldSelectionStart=f,this._oldSelectionEnd=m,this._oldHasSelection=E,this._onSelectionChange.fire()}_handleBufferActivate(f){this.clearSelection(),this._trimListener.dispose(),this._trimListener=f.activeBuffer.lines.onTrim((m=>this._handleTrim(m)))}_convertViewportColToCharacterIndex(f,m){let E=m;for(let k=0;m>=k;k++){let x=f.loadCell(k,this._workCell).getChars().length;this._workCell.getWidth()===0?E--:x>1&&m!==k&&(E+=x-1)}return E}setSelection(f,m,E){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[f,m],this._model.selectionStartLength=E,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(f){this._isClickInSelection(f)||(this._selectWordAtCursor(f,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(f,m,E=!0,k=!0){if(f[0]>=this._bufferService.cols)return;let x=this._bufferService.buffer,C=x.lines.get(f[1]);if(!C)return;let M=x.translateBufferLineToString(f[1],!1),z=this._convertViewportColToCharacterIndex(C,f[0]),j=z,U=f[0]-z,$=0,b=0,L=0,R=0;if(M.charAt(z)===" "){for(;z>0&&M.charAt(z-1)===" ";)z--;for(;j<M.length&&M.charAt(j+1)===" ";)j++}else{let q=f[0],X=f[0];C.getWidth(q)===0&&($++,q--),C.getWidth(X)===2&&(b++,X++);let Y=C.getString(X).length;for(Y>1&&(R+=Y-1,j+=Y-1);q>0&&z>0&&!this._isCharWordSeparator(C.loadCell(q-1,this._workCell));){C.loadCell(q-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?($++,q--):I>1&&(L+=I-1,z-=I-1),z--,q--}for(;X<C.length&&j+1<M.length&&!this._isCharWordSeparator(C.loadCell(X+1,this._workCell));){C.loadCell(X+1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,X++):I>1&&(R+=I-1,j+=I-1),j++,X++}}j++;let T=z+U-$+L,H=Math.min(this._bufferService.cols,j-z+$+b-L-R);if(m||M.slice(z,j).trim()!==""){if(E&&T===0&&C.getCodePoint(0)!==32){let q=x.lines.get(f[1]-1);if(q&&C.isWrapped&&q.getCodePoint(this._bufferService.cols-1)!==32){let X=this._getWordAt([this._bufferService.cols-1,f[1]-1],!1,!0,!1);if(X){let Y=this._bufferService.cols-X.start;T-=Y,H+=Y}}}if(k&&T+H===this._bufferService.cols&&C.getCodePoint(this._bufferService.cols-1)!==32){let q=x.lines.get(f[1]+1);if(q?.isWrapped&&q.getCodePoint(0)!==32){let X=this._getWordAt([0,f[1]+1],!1,!1,!0);X&&(H+=X.length)}}return{start:T,length:H}}}_selectWordAt(f,m){let E=this._getWordAt(f,m);if(E){for(;E.start<0;)E.start+=this._bufferService.cols,f[1]--;this._model.selectionStart=[E.start,f[1]],this._model.selectionStartLength=E.length}}_selectToWordAt(f){let m=this._getWordAt(f,!0);if(m){let E=f[1];for(;m.start<0;)m.start+=this._bufferService.cols,E--;if(!this._model.areSelectionValuesReversed())for(;m.start+m.length>this._bufferService.cols;)m.length-=this._bufferService.cols,E++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?m.start:m.start+m.length,E]}}_isCharWordSeparator(f){return f.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(f.getChars())>=0}_selectLineAt(f){let m=this._bufferService.buffer.getWrappedRangeForLine(f),E={start:{x:0,y:m.first},end:{x:this._bufferService.cols-1,y:m.last}};this._model.selectionStart=[0,m.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,e.getRangeLength)(E,this._bufferService.cols)}};r.SelectionService=v=c([u(3,d.IBufferService),u(4,d.ICoreService),u(5,_.IMouseService),u(6,d.IOptionsService),u(7,_.IRenderService),u(8,_.ICoreBrowserService)],v)},4725:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ILinkProviderService=r.IThemeService=r.ICharacterJoinerService=r.ISelectionService=r.IRenderService=r.IMouseService=r.ICoreBrowserService=r.ICharSizeService=void 0;let c=o(8343);r.ICharSizeService=(0,c.createDecorator)("CharSizeService"),r.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),r.IMouseService=(0,c.createDecorator)("MouseService"),r.IRenderService=(0,c.createDecorator)("RenderService"),r.ISelectionService=(0,c.createDecorator)("SelectionService"),r.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),r.IThemeService=(0,c.createDecorator)("ThemeService"),r.ILinkProviderService=(0,c.createDecorator)("LinkProviderService")},6731:function(D,r,o){var c=this&&this.__decorate||function(v,f,m,E){var k,x=arguments.length,C=x<3?f:E===null?E=Object.getOwnPropertyDescriptor(f,m):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(v,f,m,E);else for(var M=v.length-1;M>=0;M--)(k=v[M])&&(C=(x<3?k(C):x>3?k(f,m,C):k(f,m))||C);return x>3&&C&&Object.defineProperty(f,m,C),C},u=this&&this.__param||function(v,f){return function(m,E){f(m,E,v)}};Object.defineProperty(r,"__esModule",{value:!0}),r.ThemeService=r.DEFAULT_ANSI_COLORS=void 0;let n=o(7239),a=o(8055),h=o(8460),_=o(844),l=o(2585),i=a.css.toColor("#ffffff"),t=a.css.toColor("#000000"),e=a.css.toColor("#ffffff"),s=a.css.toColor("#000000"),d={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{let v=[a.css.toColor("#2e3436"),a.css.toColor("#cc0000"),a.css.toColor("#4e9a06"),a.css.toColor("#c4a000"),a.css.toColor("#3465a4"),a.css.toColor("#75507b"),a.css.toColor("#06989a"),a.css.toColor("#d3d7cf"),a.css.toColor("#555753"),a.css.toColor("#ef2929"),a.css.toColor("#8ae234"),a.css.toColor("#fce94f"),a.css.toColor("#729fcf"),a.css.toColor("#ad7fa8"),a.css.toColor("#34e2e2"),a.css.toColor("#eeeeec")],f=[0,95,135,175,215,255];for(let m=0;m<216;m++){let E=f[m/36%6|0],k=f[m/6%6|0],x=f[m%6];v.push({css:a.channels.toCss(E,k,x),rgba:a.channels.toRgba(E,k,x)})}for(let m=0;m<24;m++){let E=8+10*m;v.push({css:a.channels.toCss(E,E,E),rgba:a.channels.toRgba(E,E,E)})}return v})());let g=r.ThemeService=class extends _.Disposable{get colors(){return this._colors}constructor(v){super(),this._optionsService=v,this._contrastCache=new n.ColorContrastCache,this._halfContrastCache=new n.ColorContrastCache,this._onChangeColors=this.register(new h.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:i,background:t,cursor:e,cursorAccent:s,selectionForeground:void 0,selectionBackgroundTransparent:d,selectionBackgroundOpaque:a.color.blend(t,d),selectionInactiveBackgroundTransparent:d,selectionInactiveBackgroundOpaque:a.color.blend(t,d),ansi:r.DEFAULT_ANSI_COLORS.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))))}_setTheme(v={}){let f=this._colors;if(f.foreground=p(v.foreground,i),f.background=p(v.background,t),f.cursor=p(v.cursor,e),f.cursorAccent=p(v.cursorAccent,s),f.selectionBackgroundTransparent=p(v.selectionBackground,d),f.selectionBackgroundOpaque=a.color.blend(f.background,f.selectionBackgroundTransparent),f.selectionInactiveBackgroundTransparent=p(v.selectionInactiveBackground,f.selectionBackgroundTransparent),f.selectionInactiveBackgroundOpaque=a.color.blend(f.background,f.selectionInactiveBackgroundTransparent),f.selectionForeground=v.selectionForeground?p(v.selectionForeground,a.NULL_COLOR):void 0,f.selectionForeground===a.NULL_COLOR&&(f.selectionForeground=void 0),a.color.isOpaque(f.selectionBackgroundTransparent)&&(f.selectionBackgroundTransparent=a.color.opacity(f.selectionBackgroundTransparent,.3)),a.color.isOpaque(f.selectionInactiveBackgroundTransparent)&&(f.selectionInactiveBackgroundTransparent=a.color.opacity(f.selectionInactiveBackgroundTransparent,.3)),f.ansi=r.DEFAULT_ANSI_COLORS.slice(),f.ansi[0]=p(v.black,r.DEFAULT_ANSI_COLORS[0]),f.ansi[1]=p(v.red,r.DEFAULT_ANSI_COLORS[1]),f.ansi[2]=p(v.green,r.DEFAULT_ANSI_COLORS[2]),f.ansi[3]=p(v.yellow,r.DEFAULT_ANSI_COLORS[3]),f.ansi[4]=p(v.blue,r.DEFAULT_ANSI_COLORS[4]),f.ansi[5]=p(v.magenta,r.DEFAULT_ANSI_COLORS[5]),f.ansi[6]=p(v.cyan,r.DEFAULT_ANSI_COLORS[6]),f.ansi[7]=p(v.white,r.DEFAULT_ANSI_COLORS[7]),f.ansi[8]=p(v.brightBlack,r.DEFAULT_ANSI_COLORS[8]),f.ansi[9]=p(v.brightRed,r.DEFAULT_ANSI_COLORS[9]),f.ansi[10]=p(v.brightGreen,r.DEFAULT_ANSI_COLORS[10]),f.ansi[11]=p(v.brightYellow,r.DEFAULT_ANSI_COLORS[11]),f.ansi[12]=p(v.brightBlue,r.DEFAULT_ANSI_COLORS[12]),f.ansi[13]=p(v.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),f.ansi[14]=p(v.brightCyan,r.DEFAULT_ANSI_COLORS[14]),f.ansi[15]=p(v.brightWhite,r.DEFAULT_ANSI_COLORS[15]),v.extendedAnsi){let m=Math.min(f.ansi.length-16,v.extendedAnsi.length);for(let E=0;E<m;E++)f.ansi[E+16]=p(v.extendedAnsi[E],r.DEFAULT_ANSI_COLORS[E+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(v){this._restoreColor(v),this._onChangeColors.fire(this.colors)}_restoreColor(v){if(v!==void 0)switch(v){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[v]=this._restoreColors.ansi[v]}else for(let f=0;f<this._restoreColors.ansi.length;++f)this._colors.ansi[f]=this._restoreColors.ansi[f]}modifyColors(v){v(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()}}};function p(v,f){if(v!==void 0)try{return a.css.toColor(v)}catch{}return f}r.ThemeService=g=c([u(0,l.IOptionsService)],g)},6349:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CircularList=void 0;let c=o(8460),u=o(844);class n extends u.Disposable{constructor(h){super(),this._maxLength=h,this.onDeleteEmitter=this.register(new c.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new c.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new c.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(h){if(this._maxLength===h)return;let _=new Array(h);for(let l=0;l<Math.min(h,this.length);l++)_[l]=this._array[this._getCyclicIndex(l)];this._array=_,this._maxLength=h,this._startIndex=0}get length(){return this._length}set length(h){if(h>this._length)for(let _=this._length;_<h;_++)this._array[_]=void 0;this._length=h}get(h){return this._array[this._getCyclicIndex(h)]}set(h,_){this._array[this._getCyclicIndex(h)]=_}push(h){this._array[this._getCyclicIndex(this._length)]=h,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(h,_,...l){if(_){for(let i=h;i<this._length-_;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+_)];this._length-=_,this.onDeleteEmitter.fire({index:h,amount:_})}for(let i=this._length-1;i>=h;i--)this._array[this._getCyclicIndex(i+l.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<l.length;i++)this._array[this._getCyclicIndex(h+i)]=l[i];if(l.length&&this.onInsertEmitter.fire({index:h,amount:l.length}),this._length+l.length>this._maxLength){let i=this._length+l.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=l.length}trimStart(h){h>this._length&&(h=this._length),this._startIndex+=h,this._length-=h,this.onTrimEmitter.fire(h)}shiftElements(h,_,l){if(!(_<=0)){if(h<0||h>=this._length)throw new Error("start argument out of range");if(h+l<0)throw new Error("Cannot shift elements in list beyond index 0");if(l>0){for(let t=_-1;t>=0;t--)this.set(h+t+l,this.get(h+t));let i=h+_+l-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<_;i++)this.set(h+i+l,this.get(h+i))}}_getCyclicIndex(h){return(this._startIndex+h)%this._maxLength}}r.CircularList=n},1439:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.clone=void 0,r.clone=function o(c,u=5){if(typeof c!="object")return c;let n=Array.isArray(c)?[]:{};for(let a in c)n[a]=u<=1?c[a]:c[a]&&o(c[a],u-1);return n}},8055:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.contrastRatio=r.toPaddedHex=r.rgba=r.rgb=r.css=r.color=r.channels=r.NULL_COLOR=void 0;let o=0,c=0,u=0,n=0;var a,h,_,l,i;function t(s){let d=s.toString(16);return d.length<2?"0"+d:d}function e(s,d){return s<d?(d+.05)/(s+.05):(s+.05)/(d+.05)}r.NULL_COLOR={css:"#00000000",rgba:0},(function(s){s.toCss=function(d,g,p,v){return v!==void 0?`#${t(d)}${t(g)}${t(p)}${t(v)}`:`#${t(d)}${t(g)}${t(p)}`},s.toRgba=function(d,g,p,v=255){return(d<<24|g<<16|p<<8|v)>>>0},s.toColor=function(d,g,p,v){return{css:s.toCss(d,g,p,v),rgba:s.toRgba(d,g,p,v)}}})(a||(r.channels=a={})),(function(s){function d(g,p){return n=Math.round(255*p),[o,c,u]=i.toChannels(g.rgba),{css:a.toCss(o,c,u,n),rgba:a.toRgba(o,c,u,n)}}s.blend=function(g,p){if(n=(255&p.rgba)/255,n===1)return{css:p.css,rgba:p.rgba};let v=p.rgba>>24&255,f=p.rgba>>16&255,m=p.rgba>>8&255,E=g.rgba>>24&255,k=g.rgba>>16&255,x=g.rgba>>8&255;return o=E+Math.round((v-E)*n),c=k+Math.round((f-k)*n),u=x+Math.round((m-x)*n),{css:a.toCss(o,c,u),rgba:a.toRgba(o,c,u)}},s.isOpaque=function(g){return(255&g.rgba)==255},s.ensureContrastRatio=function(g,p,v){let f=i.ensureContrastRatio(g.rgba,p.rgba,v);if(f)return a.toColor(f>>24&255,f>>16&255,f>>8&255)},s.opaque=function(g){let p=(255|g.rgba)>>>0;return[o,c,u]=i.toChannels(p),{css:a.toCss(o,c,u),rgba:p}},s.opacity=d,s.multiplyOpacity=function(g,p){return n=255&g.rgba,d(g,n*p/255)},s.toColorRGB=function(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}})(h||(r.color=h={})),(function(s){let d,g;try{let p=document.createElement("canvas");p.width=1,p.height=1;let v=p.getContext("2d",{willReadFrequently:!0});v&&(d=v,d.globalCompositeOperation="copy",g=d.createLinearGradient(0,0,1,1))}catch{}s.toColor=function(p){if(p.match(/#[\da-f]{3,8}/i))switch(p.length){case 4:return o=parseInt(p.slice(1,2).repeat(2),16),c=parseInt(p.slice(2,3).repeat(2),16),u=parseInt(p.slice(3,4).repeat(2),16),a.toColor(o,c,u);case 5:return o=parseInt(p.slice(1,2).repeat(2),16),c=parseInt(p.slice(2,3).repeat(2),16),u=parseInt(p.slice(3,4).repeat(2),16),n=parseInt(p.slice(4,5).repeat(2),16),a.toColor(o,c,u,n);case 7:return{css:p,rgba:(parseInt(p.slice(1),16)<<8|255)>>>0};case 9:return{css:p,rgba:parseInt(p.slice(1),16)>>>0}}let v=p.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(v)return o=parseInt(v[1]),c=parseInt(v[2]),u=parseInt(v[3]),n=Math.round(255*(v[5]===void 0?1:parseFloat(v[5]))),a.toColor(o,c,u,n);if(!d||!g)throw new Error("css.toColor: Unsupported css format");if(d.fillStyle=g,d.fillStyle=p,typeof d.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(d.fillRect(0,0,1,1),[o,c,u,n]=d.getImageData(0,0,1,1).data,n!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:a.toRgba(o,c,u,n),css:p}}})(_||(r.css=_={})),(function(s){function d(g,p,v){let f=g/255,m=p/255,E=v/255;return .2126*(f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4))+.7152*(m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4))+.0722*(E<=.03928?E/12.92:Math.pow((E+.055)/1.055,2.4))}s.relativeLuminance=function(g){return d(g>>16&255,g>>8&255,255&g)},s.relativeLuminance2=d})(l||(r.rgb=l={})),(function(s){function d(p,v,f){let m=p>>24&255,E=p>>16&255,k=p>>8&255,x=v>>24&255,C=v>>16&255,M=v>>8&255,z=e(l.relativeLuminance2(x,C,M),l.relativeLuminance2(m,E,k));for(;z<f&&(x>0||C>0||M>0);)x-=Math.max(0,Math.ceil(.1*x)),C-=Math.max(0,Math.ceil(.1*C)),M-=Math.max(0,Math.ceil(.1*M)),z=e(l.relativeLuminance2(x,C,M),l.relativeLuminance2(m,E,k));return(x<<24|C<<16|M<<8|255)>>>0}function g(p,v,f){let m=p>>24&255,E=p>>16&255,k=p>>8&255,x=v>>24&255,C=v>>16&255,M=v>>8&255,z=e(l.relativeLuminance2(x,C,M),l.relativeLuminance2(m,E,k));for(;z<f&&(x<255||C<255||M<255);)x=Math.min(255,x+Math.ceil(.1*(255-x))),C=Math.min(255,C+Math.ceil(.1*(255-C))),M=Math.min(255,M+Math.ceil(.1*(255-M))),z=e(l.relativeLuminance2(x,C,M),l.relativeLuminance2(m,E,k));return(x<<24|C<<16|M<<8|255)>>>0}s.blend=function(p,v){if(n=(255&v)/255,n===1)return v;let f=v>>24&255,m=v>>16&255,E=v>>8&255,k=p>>24&255,x=p>>16&255,C=p>>8&255;return o=k+Math.round((f-k)*n),c=x+Math.round((m-x)*n),u=C+Math.round((E-C)*n),a.toRgba(o,c,u)},s.ensureContrastRatio=function(p,v,f){let m=l.relativeLuminance(p>>8),E=l.relativeLuminance(v>>8);if(e(m,E)<f){if(E<m){let C=d(p,v,f),M=e(m,l.relativeLuminance(C>>8));if(M<f){let z=g(p,v,f);return M>e(m,l.relativeLuminance(z>>8))?C:z}return C}let k=g(p,v,f),x=e(m,l.relativeLuminance(k>>8));if(x<f){let C=d(p,v,f);return x>e(m,l.relativeLuminance(C>>8))?k:C}return k}},s.reduceLuminance=d,s.increaseLuminance=g,s.toChannels=function(p){return[p>>24&255,p>>16&255,p>>8&255,255&p]}})(i||(r.rgba=i={})),r.toPaddedHex=t,r.contrastRatio=e},8969:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreTerminal=void 0;let c=o(844),u=o(2585),n=o(4348),a=o(7866),h=o(744),_=o(7302),l=o(6975),i=o(8460),t=o(1753),e=o(1480),s=o(7994),d=o(9282),g=o(5435),p=o(5981),v=o(2660),f=!1;class m extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new i.EventEmitter),this._onScroll.event((k=>{this._onScrollApi?.fire(k.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(k){for(let x in k)this.optionsService.options[x]=k[x]}constructor(k){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new i.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new i.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new i.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new i.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new i.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new i.EventEmitter),this._instantiationService=new n.InstantiationService,this.optionsService=this.register(new _.OptionsService(k)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(h.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(a.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(l.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(t.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(e.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(s.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(v.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new g.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,i.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,i.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,i.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,i.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((x=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((x=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new p.WriteBuffer(((x,C)=>this._inputHandler.parse(x,C)))),this.register((0,i.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(k,x){this._writeBuffer.write(k,x)}writeSync(k,x){this._logService.logLevel<=u.LogLevelEnum.WARN&&!f&&(this._logService.warn("writeSync is unreliable and will be removed soon."),f=!0),this._writeBuffer.writeSync(k,x)}input(k,x=!0){this.coreService.triggerDataEvent(k,x)}resize(k,x){isNaN(k)||isNaN(x)||(k=Math.max(k,h.MINIMUM_COLS),x=Math.max(x,h.MINIMUM_ROWS),this._bufferService.resize(k,x))}scroll(k,x=!1){this._bufferService.scroll(k,x)}scrollLines(k,x,C){this._bufferService.scrollLines(k,x,C)}scrollPages(k){this.scrollLines(k*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(k){let x=k-this._bufferService.buffer.ydisp;x!==0&&this.scrollLines(x)}registerEscHandler(k,x){return this._inputHandler.registerEscHandler(k,x)}registerDcsHandler(k,x){return this._inputHandler.registerDcsHandler(k,x)}registerCsiHandler(k,x){return this._inputHandler.registerCsiHandler(k,x)}registerOscHandler(k,x){return this._inputHandler.registerOscHandler(k,x)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let k=!1,x=this.optionsService.rawOptions.windowsPty;x&&x.buildNumber!==void 0&&x.buildNumber!==void 0?k=x.backend==="conpty"&&x.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(k=!0),k?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let k=[];k.push(this.onLineFeed(d.updateWindowsModeWrappedState.bind(null,this._bufferService))),k.push(this.registerCsiHandler({final:"H"},(()=>((0,d.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(let x of k)x.dispose()}))}}}r.CoreTerminal=m},8460:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.runAndSubscribe=r.forwardEvent=r.EventEmitter=void 0,r.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===o)return void this._listeners.splice(c,1)}}})),this._event}fire(o,c){let u=[];for(let n=0;n<this._listeners.length;n++)u.push(this._listeners[n]);for(let n=0;n<u.length;n++)u[n].call(void 0,o,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(o,c){return o((u=>c.fire(u)))},r.runAndSubscribe=function(o,c){return c(void 0),o((u=>c(u)))}},5435:function(D,r,o){var c=this&&this.__decorate||function($,b,L,R){var T,H=arguments.length,q=H<3?b:R===null?R=Object.getOwnPropertyDescriptor(b,L):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")q=Reflect.decorate($,b,L,R);else for(var X=$.length-1;X>=0;X--)(T=$[X])&&(q=(H<3?T(q):H>3?T(b,L,q):T(b,L))||q);return H>3&&q&&Object.defineProperty(b,L,q),q},u=this&&this.__param||function($,b){return function(L,R){b(L,R,$)}};Object.defineProperty(r,"__esModule",{value:!0}),r.InputHandler=r.WindowsOptionsReportType=void 0;let n=o(2584),a=o(7116),h=o(2015),_=o(844),l=o(482),i=o(8437),t=o(8460),e=o(643),s=o(511),d=o(3734),g=o(2585),p=o(1480),v=o(6242),f=o(6351),m=o(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},k=131072;function x($,b){if($>24)return b.setWinLines||!1;switch($){case 1:return!!b.restoreWin;case 2:return!!b.minimizeWin;case 3:return!!b.setWinPosition;case 4:return!!b.setWinSizePixels;case 5:return!!b.raiseWin;case 6:return!!b.lowerWin;case 7:return!!b.refreshWin;case 8:return!!b.setWinSizeChars;case 9:return!!b.maximizeWin;case 10:return!!b.fullscreenWin;case 11:return!!b.getWinState;case 13:return!!b.getWinPosition;case 14:return!!b.getWinSizePixels;case 15:return!!b.getScreenSizePixels;case 16:return!!b.getCellSizePixels;case 18:return!!b.getWinSizeChars;case 19:return!!b.getScreenSizeChars;case 20:return!!b.getIconTitle;case 21:return!!b.getWinTitle;case 22:return!!b.pushTitle;case 23:return!!b.popTitle;case 24:return!!b.setWinLines}return!1}var C;(function($){$[$.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",$[$.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(C||(r.WindowsOptionsReportType=C={}));let M=0;class z extends _.Disposable{getAttrData(){return this._curAttrData}constructor(b,L,R,T,H,q,X,Y,I=new h.EscapeSequenceParser){super(),this._bufferService=b,this._charsetService=L,this._coreService=R,this._logService=T,this._optionsService=H,this._oscLinkService=q,this._coreMouseService=X,this._unicodeService=Y,this._parser=I,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new l.StringToUtf32,this._utf8Decoder=new l.Utf8ToUtf32,this._workCell=new s.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new t.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new t.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new t.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new t.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new t.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new t.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new t.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new t.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new t.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new t.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new t.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new t.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new t.EventEmitter),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 j(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((y=>this._activeBuffer=y.activeBuffer))),this._parser.setCsiHandlerFallback(((y,F)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(y),params:F.toArray()})})),this._parser.setEscHandlerFallback((y=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(y)})})),this._parser.setExecuteHandlerFallback((y=>{this._logService.debug("Unknown EXECUTE code: ",{code:y})})),this._parser.setOscHandlerFallback(((y,F,N)=>{this._logService.debug("Unknown OSC code: ",{identifier:y,action:F,data:N})})),this._parser.setDcsHandlerFallback(((y,F,N)=>{F==="HOOK"&&(N=N.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(y),action:F,payload:N})})),this._parser.setPrintHandler(((y,F,N)=>this.print(y,F,N))),this._parser.registerCsiHandler({final:"@"},(y=>this.insertChars(y))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(y=>this.scrollLeft(y))),this._parser.registerCsiHandler({final:"A"},(y=>this.cursorUp(y))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(y=>this.scrollRight(y))),this._parser.registerCsiHandler({final:"B"},(y=>this.cursorDown(y))),this._parser.registerCsiHandler({final:"C"},(y=>this.cursorForward(y))),this._parser.registerCsiHandler({final:"D"},(y=>this.cursorBackward(y))),this._parser.registerCsiHandler({final:"E"},(y=>this.cursorNextLine(y))),this._parser.registerCsiHandler({final:"F"},(y=>this.cursorPrecedingLine(y))),this._parser.registerCsiHandler({final:"G"},(y=>this.cursorCharAbsolute(y))),this._parser.registerCsiHandler({final:"H"},(y=>this.cursorPosition(y))),this._parser.registerCsiHandler({final:"I"},(y=>this.cursorForwardTab(y))),this._parser.registerCsiHandler({final:"J"},(y=>this.eraseInDisplay(y,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(y=>this.eraseInDisplay(y,!0))),this._parser.registerCsiHandler({final:"K"},(y=>this.eraseInLine(y,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(y=>this.eraseInLine(y,!0))),this._parser.registerCsiHandler({final:"L"},(y=>this.insertLines(y))),this._parser.registerCsiHandler({final:"M"},(y=>this.deleteLines(y))),this._parser.registerCsiHandler({final:"P"},(y=>this.deleteChars(y))),this._parser.registerCsiHandler({final:"S"},(y=>this.scrollUp(y))),this._parser.registerCsiHandler({final:"T"},(y=>this.scrollDown(y))),this._parser.registerCsiHandler({final:"X"},(y=>this.eraseChars(y))),this._parser.registerCsiHandler({final:"Z"},(y=>this.cursorBackwardTab(y))),this._parser.registerCsiHandler({final:"`"},(y=>this.charPosAbsolute(y))),this._parser.registerCsiHandler({final:"a"},(y=>this.hPositionRelative(y))),this._parser.registerCsiHandler({final:"b"},(y=>this.repeatPrecedingCharacter(y))),this._parser.registerCsiHandler({final:"c"},(y=>this.sendDeviceAttributesPrimary(y))),this._parser.registerCsiHandler({prefix:">",final:"c"},(y=>this.sendDeviceAttributesSecondary(y))),this._parser.registerCsiHandler({final:"d"},(y=>this.linePosAbsolute(y))),this._parser.registerCsiHandler({final:"e"},(y=>this.vPositionRelative(y))),this._parser.registerCsiHandler({final:"f"},(y=>this.hVPosition(y))),this._parser.registerCsiHandler({final:"g"},(y=>this.tabClear(y))),this._parser.registerCsiHandler({final:"h"},(y=>this.setMode(y))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(y=>this.setModePrivate(y))),this._parser.registerCsiHandler({final:"l"},(y=>this.resetMode(y))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(y=>this.resetModePrivate(y))),this._parser.registerCsiHandler({final:"m"},(y=>this.charAttributes(y))),this._parser.registerCsiHandler({final:"n"},(y=>this.deviceStatus(y))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(y=>this.deviceStatusPrivate(y))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(y=>this.softReset(y))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(y=>this.setCursorStyle(y))),this._parser.registerCsiHandler({final:"r"},(y=>this.setScrollRegion(y))),this._parser.registerCsiHandler({final:"s"},(y=>this.saveCursor(y))),this._parser.registerCsiHandler({final:"t"},(y=>this.windowOptions(y))),this._parser.registerCsiHandler({final:"u"},(y=>this.restoreCursor(y))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(y=>this.insertColumns(y))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(y=>this.deleteColumns(y))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(y=>this.selectProtected(y))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(y=>this.requestMode(y,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(y=>this.requestMode(y,!1))),this._parser.setExecuteHandler(n.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(n.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(n.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(n.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(n.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(n.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(n.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(n.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(n.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(n.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(n.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(n.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new v.OscHandler((y=>(this.setTitle(y),this.setIconName(y),!0)))),this._parser.registerOscHandler(1,new v.OscHandler((y=>this.setIconName(y)))),this._parser.registerOscHandler(2,new v.OscHandler((y=>this.setTitle(y)))),this._parser.registerOscHandler(4,new v.OscHandler((y=>this.setOrReportIndexedColor(y)))),this._parser.registerOscHandler(8,new v.OscHandler((y=>this.setHyperlink(y)))),this._parser.registerOscHandler(10,new v.OscHandler((y=>this.setOrReportFgColor(y)))),this._parser.registerOscHandler(11,new v.OscHandler((y=>this.setOrReportBgColor(y)))),this._parser.registerOscHandler(12,new v.OscHandler((y=>this.setOrReportCursorColor(y)))),this._parser.registerOscHandler(104,new v.OscHandler((y=>this.restoreIndexedColor(y)))),this._parser.registerOscHandler(110,new v.OscHandler((y=>this.restoreFgColor(y)))),this._parser.registerOscHandler(111,new v.OscHandler((y=>this.restoreBgColor(y)))),this._parser.registerOscHandler(112,new v.OscHandler((y=>this.restoreCursorColor(y)))),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 y in a.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:y},(()=>this.selectCharset("("+y))),this._parser.registerEscHandler({intermediates:")",final:y},(()=>this.selectCharset(")"+y))),this._parser.registerEscHandler({intermediates:"*",final:y},(()=>this.selectCharset("*"+y))),this._parser.registerEscHandler({intermediates:"+",final:y},(()=>this.selectCharset("+"+y))),this._parser.registerEscHandler({intermediates:"-",final:y},(()=>this.selectCharset("-"+y))),this._parser.registerEscHandler({intermediates:".",final:y},(()=>this.selectCharset("."+y))),this._parser.registerEscHandler({intermediates:"/",final:y},(()=>this.selectCharset("/"+y)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((y=>(this._logService.error("Parsing error: ",y),y))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new f.DcsHandler(((y,F)=>this.requestStatusString(y,F))))}_preserveStack(b,L,R,T){this._parseStack.paused=!0,this._parseStack.cursorStartX=b,this._parseStack.cursorStartY=L,this._parseStack.decodedLength=R,this._parseStack.position=T}_logSlowResolvingAsync(b){this._logService.logLevel<=g.LogLevelEnum.WARN&&Promise.race([b,new Promise(((L,R)=>setTimeout((()=>R("#SLOW_TIMEOUT")),5e3)))]).catch((L=>{if(L!=="#SLOW_TIMEOUT")throw L;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(b,L){let R,T=this._activeBuffer.x,H=this._activeBuffer.y,q=0,X=this._parseStack.paused;if(X){if(R=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,L))return this._logSlowResolvingAsync(R),R;T=this._parseStack.cursorStartX,H=this._parseStack.cursorStartY,this._parseStack.paused=!1,b.length>k&&(q=this._parseStack.position+k)}if(this._logService.logLevel<=g.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof b=="string"?` "${b}"`:` "${Array.prototype.map.call(b,(y=>String.fromCharCode(y))).join("")}"`),typeof b=="string"?b.split("").map((y=>y.charCodeAt(0))):b),this._parseBuffer.length<b.length&&this._parseBuffer.length<k&&(this._parseBuffer=new Uint32Array(Math.min(b.length,k))),X||this._dirtyRowTracker.clearRange(),b.length>k)for(let y=q;y<b.length;y+=k){let F=y+k<b.length?y+k:b.length,N=typeof b=="string"?this._stringDecoder.decode(b.substring(y,F),this._parseBuffer):this._utf8Decoder.decode(b.subarray(y,F),this._parseBuffer);if(R=this._parser.parse(this._parseBuffer,N))return this._preserveStack(T,H,N,y),this._logSlowResolvingAsync(R),R}else if(!X){let y=typeof b=="string"?this._stringDecoder.decode(b,this._parseBuffer):this._utf8Decoder.decode(b,this._parseBuffer);if(R=this._parser.parse(this._parseBuffer,y))return this._preserveStack(T,H,y,0),this._logSlowResolvingAsync(R),R}this._activeBuffer.x===T&&this._activeBuffer.y===H||this._onCursorMove.fire();let Y=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),I=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);I<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(I,this._bufferService.rows-1),Math.min(Y,this._bufferService.rows-1))}print(b,L,R){let T,H,q=this._charsetService.charset,X=this._optionsService.rawOptions.screenReaderMode,Y=this._bufferService.cols,I=this._coreService.decPrivateModes.wraparound,y=this._coreService.modes.insertMode,F=this._curAttrData,N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&R-L>0&&N.getWidth(this._activeBuffer.x-1)===2&&N.setCellFromCodepoint(this._activeBuffer.x-1,0,1,F);let K=this._parser.precedingJoinState;for(let V=L;V<R;++V){if(T=b[V],T<127&&q){let ne=q[String.fromCharCode(T)];ne&&(T=ne.charCodeAt(0))}let ie=this._unicodeService.charProperties(T,K);H=p.UnicodeService.extractWidth(ie);let he=p.UnicodeService.extractShouldJoin(ie),le=he?p.UnicodeService.extractWidth(K):0;if(K=ie,X&&this._onA11yChar.fire((0,l.stringFromCodePoint)(T)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+H-le>Y){if(I){let ne=N,G=this._activeBuffer.x-le;for(this._activeBuffer.x=le,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),N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),le>0&&N instanceof i.BufferLine&&N.copyCellsFrom(ne,G,0,le,!1);G<Y;)ne.setCellFromCodepoint(G++,0,1,F)}else if(this._activeBuffer.x=Y-1,H===2)continue}if(he&&this._activeBuffer.x){let ne=N.getWidth(this._activeBuffer.x-1)?1:2;N.addCodepointToCell(this._activeBuffer.x-ne,T,H);for(let G=H-le;--G>=0;)N.setCellFromCodepoint(this._activeBuffer.x++,0,0,F)}else if(y&&(N.insertCells(this._activeBuffer.x,H-le,this._activeBuffer.getNullCell(F)),N.getWidth(Y-1)===2&&N.setCellFromCodepoint(Y-1,e.NULL_CELL_CODE,e.NULL_CELL_WIDTH,F)),N.setCellFromCodepoint(this._activeBuffer.x++,T,H,F),H>0)for(;--H;)N.setCellFromCodepoint(this._activeBuffer.x++,0,0,F)}this._parser.precedingJoinState=K,this._activeBuffer.x<Y&&R-L>0&&N.getWidth(this._activeBuffer.x)===0&&!N.hasContent(this._activeBuffer.x)&&N.setCellFromCodepoint(this._activeBuffer.x,0,1,F),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(b,L){return b.final!=="t"||b.prefix||b.intermediates?this._parser.registerCsiHandler(b,L):this._parser.registerCsiHandler(b,(R=>!x(R.params[0],this._optionsService.rawOptions.windowOptions)||L(R)))}registerDcsHandler(b,L){return this._parser.registerDcsHandler(b,new f.DcsHandler(L))}registerEscHandler(b,L){return this._parser.registerEscHandler(b,L)}registerOscHandler(b,L){return this._parser.registerOscHandler(b,new v.OscHandler(L))}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(){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&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);b.hasWidth(this._activeBuffer.x)&&!b.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-b),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(b=this._bufferService.cols-1){this._activeBuffer.x=Math.min(b,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(b,L){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=b,this._activeBuffer.y=this._activeBuffer.scrollTop+L):(this._activeBuffer.x=b,this._activeBuffer.y=L),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(b,L){this._restrictCursor(),this._setCursor(this._activeBuffer.x+b,this._activeBuffer.y+L)}cursorUp(b){let L=this._activeBuffer.y-this._activeBuffer.scrollTop;return L>=0?this._moveCursor(0,-Math.min(L,b.params[0]||1)):this._moveCursor(0,-(b.params[0]||1)),!0}cursorDown(b){let L=this._activeBuffer.scrollBottom-this._activeBuffer.y;return L>=0?this._moveCursor(0,Math.min(L,b.params[0]||1)):this._moveCursor(0,b.params[0]||1),!0}cursorForward(b){return this._moveCursor(b.params[0]||1,0),!0}cursorBackward(b){return this._moveCursor(-(b.params[0]||1),0),!0}cursorNextLine(b){return this.cursorDown(b),this._activeBuffer.x=0,!0}cursorPrecedingLine(b){return this.cursorUp(b),this._activeBuffer.x=0,!0}cursorCharAbsolute(b){return this._setCursor((b.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(b){return this._setCursor(b.length>=2?(b.params[1]||1)-1:0,(b.params[0]||1)-1),!0}charPosAbsolute(b){return this._setCursor((b.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(b){return this._moveCursor(b.params[0]||1,0),!0}linePosAbsolute(b){return this._setCursor(this._activeBuffer.x,(b.params[0]||1)-1),!0}vPositionRelative(b){return this._moveCursor(0,b.params[0]||1),!0}hVPosition(b){return this.cursorPosition(b),!0}tabClear(b){let L=b.params[0];return L===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:L===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(b){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let L=b.params[0]||1;for(;L--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(b){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let L=b.params[0]||1;for(;L--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(b){let L=b.params[0];return L===1&&(this._curAttrData.bg|=536870912),L!==2&&L!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(b,L,R,T=!1,H=!1){let q=this._activeBuffer.lines.get(this._activeBuffer.ybase+b);q.replaceCells(L,R,this._activeBuffer.getNullCell(this._eraseAttrData()),H),T&&(q.isWrapped=!1)}_resetBufferLine(b,L=!1){let R=this._activeBuffer.lines.get(this._activeBuffer.ybase+b);R&&(R.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),L),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+b),R.isWrapped=!1)}eraseInDisplay(b,L=!1){let R;switch(this._restrictCursor(this._bufferService.cols),b.params[0]){case 0:for(R=this._activeBuffer.y,this._dirtyRowTracker.markDirty(R),this._eraseInBufferLine(R++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,L);R<this._bufferService.rows;R++)this._resetBufferLine(R,L);this._dirtyRowTracker.markDirty(R);break;case 1:for(R=this._activeBuffer.y,this._dirtyRowTracker.markDirty(R),this._eraseInBufferLine(R,0,this._activeBuffer.x+1,!0,L),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(R+1).isWrapped=!1);R--;)this._resetBufferLine(R,L);this._dirtyRowTracker.markDirty(0);break;case 2:for(R=this._bufferService.rows,this._dirtyRowTracker.markDirty(R-1);R--;)this._resetBufferLine(R,L);this._dirtyRowTracker.markDirty(0);break;case 3:let T=this._activeBuffer.lines.length-this._bufferService.rows;T>0&&(this._activeBuffer.lines.trimStart(T),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-T,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-T,0),this._onScroll.fire(0))}return!0}eraseInLine(b,L=!1){switch(this._restrictCursor(this._bufferService.cols),b.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,L);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,L);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,L)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(b){this._restrictCursor();let L=b.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let R=this._activeBuffer.ybase+this._activeBuffer.y,T=this._bufferService.rows-1-this._activeBuffer.scrollBottom,H=this._bufferService.rows-1+this._activeBuffer.ybase-T+1;for(;L--;)this._activeBuffer.lines.splice(H-1,1),this._activeBuffer.lines.splice(R,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(b){this._restrictCursor();let L=b.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let R=this._activeBuffer.ybase+this._activeBuffer.y,T;for(T=this._bufferService.rows-1-this._activeBuffer.scrollBottom,T=this._bufferService.rows-1+this._activeBuffer.ybase-T;L--;)this._activeBuffer.lines.splice(R,1),this._activeBuffer.lines.splice(T,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(b){this._restrictCursor();let L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.insertCells(this._activeBuffer.x,b.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(b){this._restrictCursor();let L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.deleteCells(this._activeBuffer.x,b.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(b){let L=b.params[0]||1;for(;L--;)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(b){let L=b.params[0]||1;for(;L--;)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(i.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let L=b.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){let T=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);T.deleteCells(0,L,this._activeBuffer.getNullCell(this._eraseAttrData())),T.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let L=b.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){let T=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);T.insertCells(0,L,this._activeBuffer.getNullCell(this._eraseAttrData())),T.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let L=b.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){let T=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);T.insertCells(this._activeBuffer.x,L,this._activeBuffer.getNullCell(this._eraseAttrData())),T.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let L=b.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){let T=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);T.deleteCells(this._activeBuffer.x,L,this._activeBuffer.getNullCell(this._eraseAttrData())),T.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(b){this._restrictCursor();let L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(b.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(b){let L=this._parser.precedingJoinState;if(!L)return!0;let R=b.params[0]||1,T=p.UnicodeService.extractWidth(L),H=this._activeBuffer.x-T,q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(H),X=new Uint32Array(q.length*R),Y=0;for(let y=0;y<q.length;){let F=q.codePointAt(y)||0;X[Y++]=F,y+=F>65535?2:1}let I=Y;for(let y=1;y<R;++y)X.copyWithin(I,0,Y),I+=Y;return this.print(X,0,I),!0}sendDeviceAttributesPrimary(b){return b.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(n.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(n.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(b){return b.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(n.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(n.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(b.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(n.C0.ESC+"[>83;40003;0c")),!0}_is(b){return(this._optionsService.rawOptions.termName+"").indexOf(b)===0}setMode(b){for(let L=0;L<b.length;L++)switch(b.params[L]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(b){for(let L=0;L<b.length;L++)switch(b.params[L]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,a.DEFAULT_CHARSET),this._charsetService.setgCharset(1,a.DEFAULT_CHARSET),this._charsetService.setgCharset(2,a.DEFAULT_CHARSET),this._charsetService.setgCharset(3,a.DEFAULT_CHARSET);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(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(b){for(let L=0;L<b.length;L++)switch(b.params[L]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(b){for(let L=0;L<b.length;L++)switch(b.params[L]){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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),b.params[L]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(b,L){let R=this._coreService.decPrivateModes,{activeProtocol:T,activeEncoding:H}=this._coreMouseService,q=this._coreService,{buffers:X,cols:Y}=this._bufferService,{active:I,alt:y}=X,F=this._optionsService.rawOptions,N=he=>he?1:2,K=b.params[0];return V=K,ie=L?K===2?4:K===4?N(q.modes.insertMode):K===12?3:K===20?N(F.convertEol):0:K===1?N(R.applicationCursorKeys):K===3?F.windowOptions.setWinLines?Y===80?2:Y===132?1:0:0:K===6?N(R.origin):K===7?N(R.wraparound):K===8?3:K===9?N(T==="X10"):K===12?N(F.cursorBlink):K===25?N(!q.isCursorHidden):K===45?N(R.reverseWraparound):K===66?N(R.applicationKeypad):K===67?4:K===1e3?N(T==="VT200"):K===1002?N(T==="DRAG"):K===1003?N(T==="ANY"):K===1004?N(R.sendFocus):K===1005?4:K===1006?N(H==="SGR"):K===1015?4:K===1016?N(H==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?N(I===y):K===2004?N(R.bracketedPasteMode):0,q.triggerDataEvent(`${n.C0.ESC}[${L?"":"?"}${V};${ie}$y`),!0;var V,ie}_updateAttrColor(b,L,R,T,H){return L===2?(b|=50331648,b&=-16777216,b|=d.AttributeData.fromColorRGB([R,T,H])):L===5&&(b&=-50331904,b|=33554432|255&R),b}_extractColor(b,L,R){let T=[0,0,-1,0,0,0],H=0,q=0;do{if(T[q+H]=b.params[L+q],b.hasSubParams(L+q)){let X=b.getSubParams(L+q),Y=0;do T[1]===5&&(H=1),T[q+Y+1+H]=X[Y];while(++Y<X.length&&Y+q+1+H<T.length);break}if(T[1]===5&&q+H>=2||T[1]===2&&q+H>=5)break;T[1]&&(H=1)}while(++q+L<b.length&&q+H<T.length);for(let X=2;X<T.length;++X)T[X]===-1&&(T[X]=0);switch(T[0]){case 38:R.fg=this._updateAttrColor(R.fg,T[1],T[3],T[4],T[5]);break;case 48:R.bg=this._updateAttrColor(R.bg,T[1],T[3],T[4],T[5]);break;case 58:R.extended=R.extended.clone(),R.extended.underlineColor=this._updateAttrColor(R.extended.underlineColor,T[1],T[3],T[4],T[5])}return q}_processUnderline(b,L){L.extended=L.extended.clone(),(!~b||b>5)&&(b=1),L.extended.underlineStyle=b,L.fg|=268435456,b===0&&(L.fg&=-268435457),L.updateExtended()}_processSGR0(b){b.fg=i.DEFAULT_ATTR_DATA.fg,b.bg=i.DEFAULT_ATTR_DATA.bg,b.extended=b.extended.clone(),b.extended.underlineStyle=0,b.extended.underlineColor&=-67108864,b.updateExtended()}charAttributes(b){if(b.length===1&&b.params[0]===0)return this._processSGR0(this._curAttrData),!0;let L=b.length,R,T=this._curAttrData;for(let H=0;H<L;H++)R=b.params[H],R>=30&&R<=37?(T.fg&=-50331904,T.fg|=16777216|R-30):R>=40&&R<=47?(T.bg&=-50331904,T.bg|=16777216|R-40):R>=90&&R<=97?(T.fg&=-50331904,T.fg|=16777224|R-90):R>=100&&R<=107?(T.bg&=-50331904,T.bg|=16777224|R-100):R===0?this._processSGR0(T):R===1?T.fg|=134217728:R===3?T.bg|=67108864:R===4?(T.fg|=268435456,this._processUnderline(b.hasSubParams(H)?b.getSubParams(H)[0]:1,T)):R===5?T.fg|=536870912:R===7?T.fg|=67108864:R===8?T.fg|=1073741824:R===9?T.fg|=2147483648:R===2?T.bg|=134217728:R===21?this._processUnderline(2,T):R===22?(T.fg&=-134217729,T.bg&=-134217729):R===23?T.bg&=-67108865:R===24?(T.fg&=-268435457,this._processUnderline(0,T)):R===25?T.fg&=-536870913:R===27?T.fg&=-67108865:R===28?T.fg&=-1073741825:R===29?T.fg&=2147483647:R===39?(T.fg&=-67108864,T.fg|=16777215&i.DEFAULT_ATTR_DATA.fg):R===49?(T.bg&=-67108864,T.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):R===38||R===48||R===58?H+=this._extractColor(b,H,T):R===53?T.bg|=1073741824:R===55?T.bg&=-1073741825:R===59?(T.extended=T.extended.clone(),T.extended.underlineColor=-1,T.updateExtended()):R===100?(T.fg&=-67108864,T.fg|=16777215&i.DEFAULT_ATTR_DATA.fg,T.bg&=-67108864,T.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",R);return!0}deviceStatus(b){switch(b.params[0]){case 5:this._coreService.triggerDataEvent(`${n.C0.ESC}[0n`);break;case 6:let L=this._activeBuffer.y+1,R=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n.C0.ESC}[${L};${R}R`)}return!0}deviceStatusPrivate(b){if(b.params[0]===6){let L=this._activeBuffer.y+1,R=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n.C0.ESC}[?${L};${R}R`)}return!0}softReset(b){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=i.DEFAULT_ATTR_DATA.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(b){let L=b.params[0]||1;switch(L){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}let R=L%2==1;return this._optionsService.options.cursorBlink=R,!0}setScrollRegion(b){let L=b.params[0]||1,R;return(b.length<2||(R=b.params[1])>this._bufferService.rows||R===0)&&(R=this._bufferService.rows),R>L&&(this._activeBuffer.scrollTop=L-1,this._activeBuffer.scrollBottom=R-1,this._setCursor(0,0)),!0}windowOptions(b){if(!x(b.params[0],this._optionsService.rawOptions.windowOptions))return!0;let L=b.length>1?b.params[1]:0;switch(b.params[0]){case 14:L!==2&&this._onRequestWindowsOptionsReport.fire(C.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(C.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${n.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:L!==0&&L!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),L!==0&&L!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:L!==0&&L!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),L!==0&&L!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(b){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(b){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(b){return this._windowTitle=b,this._onTitleChange.fire(b),!0}setIconName(b){return this._iconName=b,!0}setOrReportIndexedColor(b){let L=[],R=b.split(";");for(;R.length>1;){let T=R.shift(),H=R.shift();if(/^\d+$/.exec(T)){let q=parseInt(T);if(U(q))if(H==="?")L.push({type:0,index:q});else{let X=(0,m.parseColor)(H);X&&L.push({type:1,index:q,color:X})}}}return L.length&&this._onColor.fire(L),!0}setHyperlink(b){let L=b.split(";");return!(L.length<2)&&(L[1]?this._createHyperlink(L[0],L[1]):!L[0]&&this._finishHyperlink())}_createHyperlink(b,L){this._getCurrentLinkId()&&this._finishHyperlink();let R=b.split(":"),T,H=R.findIndex((q=>q.startsWith("id=")));return H!==-1&&(T=R[H].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:T,uri:L}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(b,L){let R=b.split(";");for(let T=0;T<R.length&&!(L>=this._specialColors.length);++T,++L)if(R[T]==="?")this._onColor.fire([{type:0,index:this._specialColors[L]}]);else{let H=(0,m.parseColor)(R[T]);H&&this._onColor.fire([{type:1,index:this._specialColors[L],color:H}])}return!0}setOrReportFgColor(b){return this._setOrReportSpecialColor(b,0)}setOrReportBgColor(b){return this._setOrReportSpecialColor(b,1)}setOrReportCursorColor(b){return this._setOrReportSpecialColor(b,2)}restoreIndexedColor(b){if(!b)return this._onColor.fire([{type:2}]),!0;let L=[],R=b.split(";");for(let T=0;T<R.length;++T)if(/^\d+$/.exec(R[T])){let H=parseInt(R[T]);U(H)&&L.push({type:2,index:H})}return L.length&&this._onColor.fire(L),!0}restoreFgColor(b){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(b){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(b){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,a.DEFAULT_CHARSET),!0}selectCharset(b){return b.length!==2?(this.selectDefaultCharset(),!0):(b[0]==="/"||this._charsetService.setgCharset(E[b[0]],a.CHARSETS[b[1]]||a.DEFAULT_CHARSET),!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 b=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,b,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=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(b){return this._charsetService.setgLevel(b),!0}screenAlignmentPattern(){let b=new s.CellData;b.content=4194373,b.fg=this._curAttrData.fg,b.bg=this._curAttrData.bg,this._setCursor(0,0);for(let L=0;L<this._bufferService.rows;++L){let R=this._activeBuffer.ybase+this._activeBuffer.y+L,T=this._activeBuffer.lines.get(R);T&&(T.fill(b),T.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(b,L){let R=this._bufferService.buffer,T=this._optionsService.rawOptions;return(H=>(this._coreService.triggerDataEvent(`${n.C0.ESC}${H}${n.C0.ESC}\\`),!0))(b==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:b==='"p'?'P1$r61;1"p':b==="r"?`P1$r${R.scrollTop+1};${R.scrollBottom+1}r`:b==="m"?"P1$r0m":b===" q"?`P1$r${{block:2,underline:4,bar:6}[T.cursorStyle]-(T.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(b,L){this._dirtyRowTracker.markRangeDirty(b,L)}}r.InputHandler=z;let j=class{constructor($){this._bufferService=$,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty($){$<this.start?this.start=$:$>this.end&&(this.end=$)}markRangeDirty($,b){$>b&&(M=$,$=b,b=M),$<this.start&&(this.start=$),b>this.end&&(this.end=b)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function U($){return 0<=$&&$<256}j=c([u(0,g.IBufferService)],j)},844:(D,r)=>{function o(c){for(let u of c)u.dispose();c.length=0}Object.defineProperty(r,"__esModule",{value:!0}),r.getDisposeArrayDisposable=r.disposeArray=r.toDisposable=r.MutableDisposable=r.Disposable=void 0,r.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){let u=this._disposables.indexOf(c);u!==-1&&this._disposables.splice(u,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){this._isDisposed||c===this._value||(this._value?.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},r.toDisposable=function(c){return{dispose:c}},r.disposeArray=o,r.getDisposeArrayDisposable=function(c){return{dispose:()=>o(c)}}},1505:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FourKeyMap=r.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(u,n,a){this._data[u]||(this._data[u]={}),this._data[u][n]=a}get(u,n){return this._data[u]?this._data[u][n]:void 0}clear(){this._data={}}}r.TwoKeyMap=o,r.FourKeyMap=class{constructor(){this._data=new o}set(c,u,n,a,h){this._data.get(c,u)||this._data.set(c,u,new o),this._data.get(c,u).set(n,a,h)}get(c,u,n,a){return this._data.get(c,u)?.get(n,a)}clear(){this._data.clear()}}},6114:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isChromeOS=r.isLinux=r.isWindows=r.isIphone=r.isIpad=r.isMac=r.getSafariVersion=r.isSafari=r.isLegacyEdge=r.isFirefox=r.isNode=void 0,r.isNode=typeof process<"u"&&"title"in process;let o=r.isNode?"node":navigator.userAgent,c=r.isNode?"node":navigator.platform;r.isFirefox=o.includes("Firefox"),r.isLegacyEdge=o.includes("Edge"),r.isSafari=/^((?!chrome|android).)*safari/i.test(o),r.getSafariVersion=function(){if(!r.isSafari)return 0;let u=o.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},r.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),r.isIpad=c==="iPad",r.isIphone=c==="iPhone",r.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),r.isLinux=c.indexOf("Linux")>=0,r.isChromeOS=/\bCrOS\b/.test(o)},6106:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SortedList=void 0;let o=0;r.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(o=this._search(this._getKey(c)),this._array.splice(o,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;let u=this._getKey(c);if(u===void 0||(o=this._search(u),o===-1)||this._getKey(this._array[o])!==u)return!1;do if(this._array[o]===c)return this._array.splice(o,1),!0;while(++o<this._array.length&&this._getKey(this._array[o])===u);return!1}*getKeyIterator(c){if(this._array.length!==0&&(o=this._search(c),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===c))do yield this._array[o];while(++o<this._array.length&&this._getKey(this._array[o])===c)}forEachByKey(c,u){if(this._array.length!==0&&(o=this._search(c),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===c))do u(this._array[o]);while(++o<this._array.length&&this._getKey(this._array[o])===c)}values(){return[...this._array].values()}_search(c){let u=0,n=this._array.length-1;for(;n>=u;){let a=u+n>>1,h=this._getKey(this._array[a]);if(h>c)n=a-1;else{if(!(h<c)){for(;a>0&&this._getKey(this._array[a-1])===c;)a--;return a}u=a+1}}return u}}},7226:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DebouncedIdleTask=r.IdleTaskQueue=r.PriorityTaskQueue=void 0;let c=o(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(h){this._tasks.push(h),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(h){this._idleCallback=void 0;let _=0,l=0,i=h.timeRemaining(),t=0;for(;this._i<this._tasks.length;){if(_=Date.now(),this._tasks[this._i]()||this._i++,_=Math.max(1,Date.now()-_),l=Math.max(_,l),t=h.timeRemaining(),1.5*l>t)return i-_<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-_))}ms`),void this._start();i=t}this.clear()}}class n extends u{_requestCallback(h){return setTimeout((()=>h(this._createDeadline(16))))}_cancelCallback(h){clearTimeout(h)}_createDeadline(h){let _=Date.now()+h;return{timeRemaining:()=>Math.max(0,_-Date.now())}}}r.PriorityTaskQueue=n,r.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(a){return requestIdleCallback(a)}_cancelCallback(a){cancelIdleCallback(a)}}:n,r.DebouncedIdleTask=class{constructor(){this._queue=new r.IdleTaskQueue}set(a){this._queue.clear(),this._queue.enqueue(a)}flush(){this._queue.flush()}}},9282:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.updateWindowsModeWrappedState=void 0;let c=o(643);r.updateWindowsModeWrappedState=function(u){let n=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),a=n?.get(u.cols-1),h=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);h&&a&&(h.isWrapped=a[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&a[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedAttrs=r.AttributeData=void 0;class o{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(n){return[n>>>16&255,n>>>8&255,255&n]}static fromColorRGB(n){return(255&n[0])<<16|(255&n[1])<<8|255&n[2]}clone(){let n=new o;return n.fg=this.fg,n.bg=this.bg,n.extended=this.extended.clone(),n}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}r.AttributeData=o;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(n){this._ext=n}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(n){this._ext&=-469762049,this._ext|=n<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(n){this._ext&=-67108864,this._ext|=67108863&n}get urlId(){return this._urlId}set urlId(n){this._urlId=n}get underlineVariantOffset(){let n=(3758096384&this._ext)>>29;return n<0?4294967288^n:n}set underlineVariantOffset(n){this._ext&=536870911,this._ext|=n<<29&3758096384}constructor(n=0,a=0){this._ext=0,this._urlId=0,this._ext=n,this._urlId=a}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}r.ExtendedAttrs=c},9092:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Buffer=r.MAX_BUFFER_SIZE=void 0;let c=o(6349),u=o(7226),n=o(3734),a=o(8437),h=o(4634),_=o(511),l=o(643),i=o(4863),t=o(7116);r.MAX_BUFFER_SIZE=4294967295,r.Buffer=class{constructor(e,s,d){this._hasScrollback=e,this._optionsService=s,this._bufferService=d,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=a.DEFAULT_ATTR_DATA.clone(),this.savedCharset=t.DEFAULT_CHARSET,this.markers=[],this._nullCell=_.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]),this._whitespaceCell=_.CellData.fromCharData([0,l.WHITESPACE_CELL_CHAR,l.WHITESPACE_CELL_WIDTH,l.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new u.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c.CircularList(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 n.ExtendedAttrs),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 n.ExtendedAttrs),this._whitespaceCell}getBlankLine(e,s){return new a.BufferLine(this._bufferService.cols,this.getNullCell(e),s)}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 s=e+this._optionsService.rawOptions.scrollback;return s>r.MAX_BUFFER_SIZE?r.MAX_BUFFER_SIZE:s}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=a.DEFAULT_ATTR_DATA);let s=this._rows;for(;s--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,s){let d=this.getNullCell(a.DEFAULT_ATTR_DATA),g=0,p=this._getCorrectBufferLength(s);if(p>this.lines.maxLength&&(this.lines.maxLength=p),this.lines.length>0){if(this._cols<e)for(let f=0;f<this.lines.length;f++)g+=+this.lines.get(f).resize(e,d);let v=0;if(this._rows<s)for(let f=this._rows;f<s;f++)this.lines.length<s+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new a.BufferLine(e,d)):this.ybase>0&&this.lines.length<=this.ybase+this.y+v+1?(this.ybase--,v++,this.ydisp>0&&this.ydisp--):this.lines.push(new a.BufferLine(e,d)));else for(let f=this._rows;f>s;f--)this.lines.length>s+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(p<this.lines.maxLength){let f=this.lines.length-p;f>0&&(this.lines.trimStart(f),this.ybase=Math.max(this.ybase-f,0),this.ydisp=Math.max(this.ydisp-f,0),this.savedY=Math.max(this.savedY-f,0)),this.lines.maxLength=p}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,s-1),v&&(this.y+=v),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=s-1,this._isReflowEnabled&&(this._reflow(e,s),this._cols>e))for(let v=0;v<this.lines.length;v++)g+=+this.lines.get(v).resize(e,d);this._cols=e,this._rows=s,this._memoryCleanupQueue.clear(),g>.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 s=0;for(;this._memoryCleanupPosition<this.lines.length;)if(s+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),s>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,s){this._cols!==e&&(e>this._cols?this._reflowLarger(e,s):this._reflowSmaller(e,s))}_reflowLarger(e,s){let d=(0,h.reflowLargerGetLinesToRemove)(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(a.DEFAULT_ATTR_DATA));if(d.length>0){let g=(0,h.reflowLargerCreateNewLayout)(this.lines,d);(0,h.reflowLargerApplyNewLayout)(this.lines,g.layout),this._reflowLargerAdjustViewport(e,s,g.countRemoved)}}_reflowLargerAdjustViewport(e,s,d){let g=this.getNullCell(a.DEFAULT_ATTR_DATA),p=d;for(;p-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<s&&this.lines.push(new a.BufferLine(e,g))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-d,0)}_reflowSmaller(e,s){let d=this.getNullCell(a.DEFAULT_ATTR_DATA),g=[],p=0;for(let v=this.lines.length-1;v>=0;v--){let f=this.lines.get(v);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let m=[f];for(;f.isWrapped&&v>0;)f=this.lines.get(--v),m.unshift(f);let E=this.ybase+this.y;if(E>=v&&E<v+m.length)continue;let k=m[m.length-1].getTrimmedLength(),x=(0,h.reflowSmallerGetNewLineLengths)(m,this._cols,e),C=x.length-m.length,M;M=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+C):Math.max(0,this.lines.length-this.lines.maxLength+C);let z=[];for(let R=0;R<C;R++){let T=this.getBlankLine(a.DEFAULT_ATTR_DATA,!0);z.push(T)}z.length>0&&(g.push({start:v+m.length+p,newLines:z}),p+=z.length),m.push(...z);let j=x.length-1,U=x[j];U===0&&(j--,U=x[j]);let $=m.length-C-1,b=k;for(;$>=0;){let R=Math.min(b,U);if(m[j]===void 0)break;if(m[j].copyCellsFrom(m[$],b-R,U-R,R,!0),U-=R,U===0&&(j--,U=x[j]),b-=R,b===0){$--;let T=Math.max($,0);b=(0,h.getWrappedLineTrimmedLength)(m,T,this._cols)}}for(let R=0;R<m.length;R++)x[R]<e&&m[R].setCell(x[R],d);let L=C-M;for(;L-- >0;)this.ybase===0?this.y<s-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+p)-s&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+C,this.ybase+s-1)}if(g.length>0){let v=[],f=[];for(let j=0;j<this.lines.length;j++)f.push(this.lines.get(j));let m=this.lines.length,E=m-1,k=0,x=g[k];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+p);let C=0;for(let j=Math.min(this.lines.maxLength-1,m+p-1);j>=0;j--)if(x&&x.start>E+C){for(let U=x.newLines.length-1;U>=0;U--)this.lines.set(j--,x.newLines[U]);j++,v.push({index:E+1,amount:x.newLines.length}),C+=x.newLines.length,x=g[++k]}else this.lines.set(j,f[E--]);let M=0;for(let j=v.length-1;j>=0;j--)v[j].index+=M,this.lines.onInsertEmitter.fire(v[j]),M+=v[j].amount;let z=Math.max(0,m+p-this.lines.maxLength);z>0&&this.lines.onTrimEmitter.fire(z)}}translateBufferLineToString(e,s,d=0,g){let p=this.lines.get(e);return p?p.translateToString(s,d,g):""}getWrappedRangeForLine(e){let s=e,d=e;for(;s>0&&this.lines.get(s).isWrapped;)s--;for(;d+1<this.lines.length&&this.lines.get(d+1).isWrapped;)d++;return{first:s,last:d}}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 s=0;s<this.markers.length;s++)this.markers[s].line===e&&(this.markers[s].dispose(),this.markers.splice(s--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose(),this.markers.splice(e--,1);this._isClearing=!1}addMarker(e){let s=new i.Marker(e);return this.markers.push(s),s.register(this.lines.onTrim((d=>{s.line-=d,s.line<0&&s.dispose()}))),s.register(this.lines.onInsert((d=>{s.line>=d.index&&(s.line+=d.amount)}))),s.register(this.lines.onDelete((d=>{s.line>=d.index&&s.line<d.index+d.amount&&s.dispose(),s.line>d.index&&(s.line-=d.amount)}))),s.register(s.onDispose((()=>this._removeMarker(s)))),s}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}}},8437:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLine=r.DEFAULT_ATTR_DATA=void 0;let c=o(3734),u=o(511),n=o(643),a=o(482);r.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let h=0;class _{constructor(i,t,e=!1){this.isWrapped=e,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*i);let s=t||u.CellData.fromCharData([0,n.NULL_CELL_CHAR,n.NULL_CELL_WIDTH,n.NULL_CELL_CODE]);for(let d=0;d<i;++d)this.setCell(d,s);this.length=i}get(i){let t=this._data[3*i+0],e=2097151&t;return[this._data[3*i+1],2097152&t?this._combined[i]:e?(0,a.stringFromCodePoint)(e):"",t>>22,2097152&t?this._combined[i].charCodeAt(this._combined[i].length-1):e]}set(i,t){this._data[3*i+1]=t[n.CHAR_DATA_ATTR_INDEX],t[n.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[i]=t[1],this._data[3*i+0]=2097152|i|t[n.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*i+0]=t[n.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[n.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(i){return this._data[3*i+0]>>22}hasWidth(i){return 12582912&this._data[3*i+0]}getFg(i){return this._data[3*i+1]}getBg(i){return this._data[3*i+2]}hasContent(i){return 4194303&this._data[3*i+0]}getCodePoint(i){let t=this._data[3*i+0];return 2097152&t?this._combined[i].charCodeAt(this._combined[i].length-1):2097151&t}isCombined(i){return 2097152&this._data[3*i+0]}getString(i){let t=this._data[3*i+0];return 2097152&t?this._combined[i]:2097151&t?(0,a.stringFromCodePoint)(2097151&t):""}isProtected(i){return 536870912&this._data[3*i+2]}loadCell(i,t){return h=3*i,t.content=this._data[h+0],t.fg=this._data[h+1],t.bg=this._data[h+2],2097152&t.content&&(t.combinedData=this._combined[i]),268435456&t.bg&&(t.extended=this._extendedAttrs[i]),t}setCell(i,t){2097152&t.content&&(this._combined[i]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[i]=t.extended),this._data[3*i+0]=t.content,this._data[3*i+1]=t.fg,this._data[3*i+2]=t.bg}setCellFromCodepoint(i,t,e,s){268435456&s.bg&&(this._extendedAttrs[i]=s.extended),this._data[3*i+0]=t|e<<22,this._data[3*i+1]=s.fg,this._data[3*i+2]=s.bg}addCodepointToCell(i,t,e){let s=this._data[3*i+0];2097152&s?this._combined[i]+=(0,a.stringFromCodePoint)(t):2097151&s?(this._combined[i]=(0,a.stringFromCodePoint)(2097151&s)+(0,a.stringFromCodePoint)(t),s&=-2097152,s|=2097152):s=t|4194304,e&&(s&=-12582913,s|=e<<22),this._data[3*i+0]=s}insertCells(i,t,e){if((i%=this.length)&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i-1,0,1,e),t<this.length-i){let s=new u.CellData;for(let d=this.length-i-t-1;d>=0;--d)this.setCell(i+t+d,this.loadCell(i+d,s));for(let d=0;d<t;++d)this.setCell(i+d,e)}else for(let s=i;s<this.length;++s)this.setCell(s,e);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,e)}deleteCells(i,t,e){if(i%=this.length,t<this.length-i){let s=new u.CellData;for(let d=0;d<this.length-i-t;++d)this.setCell(i+d,this.loadCell(i+t+d,s));for(let d=this.length-t;d<this.length;++d)this.setCell(d,e)}else for(let s=i;s<this.length;++s)this.setCell(s,e);i&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i-1,0,1,e),this.getWidth(i)!==0||this.hasContent(i)||this.setCellFromCodepoint(i,0,1,e)}replaceCells(i,t,e,s=!1){if(s)for(i&&this.getWidth(i-1)===2&&!this.isProtected(i-1)&&this.setCellFromCodepoint(i-1,0,1,e),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,e);i<t&&i<this.length;)this.isProtected(i)||this.setCell(i,e),i++;else for(i&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i-1,0,1,e),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,e);i<t&&i<this.length;)this.setCell(i++,e)}resize(i,t){if(i===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let e=3*i;if(i>this.length){if(this._data.buffer.byteLength>=4*e)this._data=new Uint32Array(this._data.buffer,0,e);else{let s=new Uint32Array(e);s.set(this._data),this._data=s}for(let s=this.length;s<i;++s)this.setCell(s,t)}else{this._data=this._data.subarray(0,e);let s=Object.keys(this._combined);for(let g=0;g<s.length;g++){let p=parseInt(s[g],10);p>=i&&delete this._combined[p]}let d=Object.keys(this._extendedAttrs);for(let g=0;g<d.length;g++){let p=parseInt(d[g],10);p>=i&&delete this._extendedAttrs[p]}}return this.length=i,4*e*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let i=new Uint32Array(this._data.length);return i.set(this._data),this._data=i,1}return 0}fill(i,t=!1){if(t)for(let e=0;e<this.length;++e)this.isProtected(e)||this.setCell(e,i);else{this._combined={},this._extendedAttrs={};for(let e=0;e<this.length;++e)this.setCell(e,i)}}copyFrom(i){this.length!==i.length?this._data=new Uint32Array(i._data):this._data.set(i._data),this.length=i.length,this._combined={};for(let t in i._combined)this._combined[t]=i._combined[t];this._extendedAttrs={};for(let t in i._extendedAttrs)this._extendedAttrs[t]=i._extendedAttrs[t];this.isWrapped=i.isWrapped}clone(){let i=new _(0);i._data=new Uint32Array(this._data),i.length=this.length;for(let t in this._combined)i._combined[t]=this._combined[t];for(let t in this._extendedAttrs)i._extendedAttrs[t]=this._extendedAttrs[t];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let i=this.length-1;i>=0;--i)if(4194303&this._data[3*i+0])return i+(this._data[3*i+0]>>22);return 0}getNoBgTrimmedLength(){for(let i=this.length-1;i>=0;--i)if(4194303&this._data[3*i+0]||50331648&this._data[3*i+2])return i+(this._data[3*i+0]>>22);return 0}copyCellsFrom(i,t,e,s,d){let g=i._data;if(d)for(let v=s-1;v>=0;v--){for(let f=0;f<3;f++)this._data[3*(e+v)+f]=g[3*(t+v)+f];268435456&g[3*(t+v)+2]&&(this._extendedAttrs[e+v]=i._extendedAttrs[t+v])}else for(let v=0;v<s;v++){for(let f=0;f<3;f++)this._data[3*(e+v)+f]=g[3*(t+v)+f];268435456&g[3*(t+v)+2]&&(this._extendedAttrs[e+v]=i._extendedAttrs[t+v])}let p=Object.keys(i._combined);for(let v=0;v<p.length;v++){let f=parseInt(p[v],10);f>=t&&(this._combined[f-t+e]=i._combined[f])}}translateToString(i,t,e,s){t=t??0,e=e??this.length,i&&(e=Math.min(e,this.getTrimmedLength())),s&&(s.length=0);let d="";for(;t<e;){let g=this._data[3*t+0],p=2097151&g,v=2097152&g?this._combined[t]:p?(0,a.stringFromCodePoint)(p):n.WHITESPACE_CELL_CHAR;if(d+=v,s)for(let f=0;f<v.length;++f)s.push(t);t+=g>>22||1}return s&&s.push(t),d}}r.BufferLine=_},4841:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getRangeLength=void 0,r.getRangeLength=function(o,c){if(o.start.y>o.end.y)throw new Error(`Buffer range end (${o.end.x}, ${o.end.y}) cannot be before start (${o.start.x}, ${o.start.y})`);return c*(o.end.y-o.start.y)+(o.end.x-o.start.x+1)}},4634:(D,r)=>{function o(c,u,n){if(u===c.length-1)return c[u].getTrimmedLength();let a=!c[u].hasContent(n-1)&&c[u].getWidth(n-1)===1,h=c[u+1].getWidth(0)===2;return a&&h?n-1:n}Object.defineProperty(r,"__esModule",{value:!0}),r.getWrappedLineTrimmedLength=r.reflowSmallerGetNewLineLengths=r.reflowLargerApplyNewLayout=r.reflowLargerCreateNewLayout=r.reflowLargerGetLinesToRemove=void 0,r.reflowLargerGetLinesToRemove=function(c,u,n,a,h){let _=[];for(let l=0;l<c.length-1;l++){let i=l,t=c.get(++i);if(!t.isWrapped)continue;let e=[c.get(l)];for(;i<c.length&&t.isWrapped;)e.push(t),t=c.get(++i);if(a>=l&&a<i){l+=e.length-1;continue}let s=0,d=o(e,s,u),g=1,p=0;for(;g<e.length;){let f=o(e,g,u),m=f-p,E=n-d,k=Math.min(m,E);e[s].copyCellsFrom(e[g],p,d,k,!1),d+=k,d===n&&(s++,d=0),p+=k,p===f&&(g++,p=0),d===0&&s!==0&&e[s-1].getWidth(n-1)===2&&(e[s].copyCellsFrom(e[s-1],n-1,d++,1,!1),e[s-1].setCell(n-1,h))}e[s].replaceCells(d,n,h);let v=0;for(let f=e.length-1;f>0&&(f>s||e[f].getTrimmedLength()===0);f--)v++;v>0&&(_.push(l+e.length-v),_.push(v)),l+=e.length-1}return _},r.reflowLargerCreateNewLayout=function(c,u){let n=[],a=0,h=u[a],_=0;for(let l=0;l<c.length;l++)if(h===l){let i=u[++a];c.onDeleteEmitter.fire({index:l-_,amount:i}),l+=i-1,_+=i,h=u[++a]}else n.push(l);return{layout:n,countRemoved:_}},r.reflowLargerApplyNewLayout=function(c,u){let n=[];for(let a=0;a<u.length;a++)n.push(c.get(u[a]));for(let a=0;a<n.length;a++)c.set(a,n[a]);c.length=u.length},r.reflowSmallerGetNewLineLengths=function(c,u,n){let a=[],h=c.map(((t,e)=>o(c,e,u))).reduce(((t,e)=>t+e)),_=0,l=0,i=0;for(;i<h;){if(h-i<n){a.push(h-i);break}_+=n;let t=o(c,l,u);_>t&&(_-=t,l++);let e=c[l].getWidth(_-1)===2;e&&_--;let s=e?n-1:n;a.push(s),i+=s}return a},r.getWrappedLineTrimmedLength=o},5295:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferSet=void 0;let c=o(8460),u=o(844),n=o(9092);class a extends u.Disposable{constructor(_,l){super(),this._optionsService=_,this._bufferService=l,this._onBufferActivate=this.register(new c.EventEmitter),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 n.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new n.Buffer(!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(_){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(_),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(_,l){this._normal.resize(_,l),this._alt.resize(_,l),this.setupTabStops(_)}setupTabStops(_){this._normal.setupTabStops(_),this._alt.setupTabStops(_)}}r.BufferSet=a},511:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CellData=void 0;let c=o(482),u=o(643),n=o(3734);class a extends n.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new n.ExtendedAttrs,this.combinedData=""}static fromCharData(_){let l=new a;return l.setFromCharData(_),l}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(_){this.fg=_[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let l=!1;if(_[u.CHAR_DATA_CHAR_INDEX].length>2)l=!0;else if(_[u.CHAR_DATA_CHAR_INDEX].length===2){let i=_[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=i&&i<=56319){let t=_[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=t&&t<=57343?this.content=1024*(i-55296)+t-56320+65536|_[u.CHAR_DATA_WIDTH_INDEX]<<22:l=!0}else l=!0}else this.content=_[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|_[u.CHAR_DATA_WIDTH_INDEX]<<22;l&&(this.combinedData=_[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|_[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.CellData=a},643:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WHITESPACE_CELL_CODE=r.WHITESPACE_CELL_WIDTH=r.WHITESPACE_CELL_CHAR=r.NULL_CELL_CODE=r.NULL_CELL_WIDTH=r.NULL_CELL_CHAR=r.CHAR_DATA_CODE_INDEX=r.CHAR_DATA_WIDTH_INDEX=r.CHAR_DATA_CHAR_INDEX=r.CHAR_DATA_ATTR_INDEX=r.DEFAULT_EXT=r.DEFAULT_ATTR=r.DEFAULT_COLOR=void 0,r.DEFAULT_COLOR=0,r.DEFAULT_ATTR=256|r.DEFAULT_COLOR<<9,r.DEFAULT_EXT=0,r.CHAR_DATA_ATTR_INDEX=0,r.CHAR_DATA_CHAR_INDEX=1,r.CHAR_DATA_WIDTH_INDEX=2,r.CHAR_DATA_CODE_INDEX=3,r.NULL_CELL_CHAR="",r.NULL_CELL_WIDTH=1,r.NULL_CELL_CODE=0,r.WHITESPACE_CELL_CHAR=" ",r.WHITESPACE_CELL_WIDTH=1,r.WHITESPACE_CELL_CODE=32},4863:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Marker=void 0;let c=o(8460),u=o(844);class n{get id(){return this._id}constructor(h){this.line=h,this.isDisposed=!1,this._disposables=[],this._id=n._nextId++,this._onDispose=this.register(new c.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,u.disposeArray)(this._disposables),this._disposables.length=0)}register(h){return this._disposables.push(h),h}}r.Marker=n,n._nextId=1},7116:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DEFAULT_CHARSET=r.CHARSETS=void 0,r.CHARSETS={},r.DEFAULT_CHARSET=r.CHARSETS.B,r.CHARSETS[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"},r.CHARSETS.A={"#":"\xA3"},r.CHARSETS.B=void 0,r.CHARSETS[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"},r.CHARSETS.C=r.CHARSETS[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},r.CHARSETS.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"},r.CHARSETS.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"},r.CHARSETS.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"},r.CHARSETS.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"},r.CHARSETS.E=r.CHARSETS[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"},r.CHARSETS.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"},r.CHARSETS.H=r.CHARSETS[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},r.CHARSETS["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"}},2584:(D,r)=>{var o,c,u;Object.defineProperty(r,"__esModule",{value:!0}),r.C1_ESCAPED=r.C1=r.C0=void 0,(function(n){n.NUL="\0",n.SOH="",n.STX="",n.ETX="",n.EOT="",n.ENQ="",n.ACK="",n.BEL="\x07",n.BS="\b",n.HT=" ",n.LF=`
9
- `,n.VT="\v",n.FF="\f",n.CR="\r",n.SO="",n.SI="",n.DLE="",n.DC1="",n.DC2="",n.DC3="",n.DC4="",n.NAK="",n.SYN="",n.ETB="",n.CAN="",n.EM="",n.SUB="",n.ESC="\x1B",n.FS="",n.GS="",n.RS="",n.US="",n.SP=" ",n.DEL="\x7F"})(o||(r.C0=o={})),(function(n){n.PAD="\x80",n.HOP="\x81",n.BPH="\x82",n.NBH="\x83",n.IND="\x84",n.NEL="\x85",n.SSA="\x86",n.ESA="\x87",n.HTS="\x88",n.HTJ="\x89",n.VTS="\x8A",n.PLD="\x8B",n.PLU="\x8C",n.RI="\x8D",n.SS2="\x8E",n.SS3="\x8F",n.DCS="\x90",n.PU1="\x91",n.PU2="\x92",n.STS="\x93",n.CCH="\x94",n.MW="\x95",n.SPA="\x96",n.EPA="\x97",n.SOS="\x98",n.SGCI="\x99",n.SCI="\x9A",n.CSI="\x9B",n.ST="\x9C",n.OSC="\x9D",n.PM="\x9E",n.APC="\x9F"})(c||(r.C1=c={})),(function(n){n.ST=`${o.ESC}\\`})(u||(r.C1_ESCAPED=u={}))},7399:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.evaluateKeyboardEvent=void 0;let c=o(2584),u={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:["'",'"']};r.evaluateKeyboardEvent=function(n,a,h,_){let l={type:0,cancel:!1,key:void 0},i=(n.shiftKey?1:0)|(n.altKey?2:0)|(n.ctrlKey?4:0)|(n.metaKey?8:0);switch(n.keyCode){case 0:n.key==="UIKeyInputUpArrow"?l.key=a?c.C0.ESC+"OA":c.C0.ESC+"[A":n.key==="UIKeyInputLeftArrow"?l.key=a?c.C0.ESC+"OD":c.C0.ESC+"[D":n.key==="UIKeyInputRightArrow"?l.key=a?c.C0.ESC+"OC":c.C0.ESC+"[C":n.key==="UIKeyInputDownArrow"&&(l.key=a?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:l.key=n.ctrlKey?"\b":c.C0.DEL,n.altKey&&(l.key=c.C0.ESC+l.key);break;case 9:if(n.shiftKey){l.key=c.C0.ESC+"[Z";break}l.key=c.C0.HT,l.cancel=!0;break;case 13:l.key=n.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,l.cancel=!0;break;case 27:l.key=c.C0.ESC,n.altKey&&(l.key=c.C0.ESC+c.C0.ESC),l.cancel=!0;break;case 37:if(n.metaKey)break;i?(l.key=c.C0.ESC+"[1;"+(i+1)+"D",l.key===c.C0.ESC+"[1;3D"&&(l.key=c.C0.ESC+(h?"b":"[1;5D"))):l.key=a?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(n.metaKey)break;i?(l.key=c.C0.ESC+"[1;"+(i+1)+"C",l.key===c.C0.ESC+"[1;3C"&&(l.key=c.C0.ESC+(h?"f":"[1;5C"))):l.key=a?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(n.metaKey)break;i?(l.key=c.C0.ESC+"[1;"+(i+1)+"A",h||l.key!==c.C0.ESC+"[1;3A"||(l.key=c.C0.ESC+"[1;5A")):l.key=a?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(n.metaKey)break;i?(l.key=c.C0.ESC+"[1;"+(i+1)+"B",h||l.key!==c.C0.ESC+"[1;3B"||(l.key=c.C0.ESC+"[1;5B")):l.key=a?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:n.shiftKey||n.ctrlKey||(l.key=c.C0.ESC+"[2~");break;case 46:l.key=i?c.C0.ESC+"[3;"+(i+1)+"~":c.C0.ESC+"[3~";break;case 36:l.key=i?c.C0.ESC+"[1;"+(i+1)+"H":a?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:l.key=i?c.C0.ESC+"[1;"+(i+1)+"F":a?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:n.shiftKey?l.type=2:n.ctrlKey?l.key=c.C0.ESC+"[5;"+(i+1)+"~":l.key=c.C0.ESC+"[5~";break;case 34:n.shiftKey?l.type=3:n.ctrlKey?l.key=c.C0.ESC+"[6;"+(i+1)+"~":l.key=c.C0.ESC+"[6~";break;case 112:l.key=i?c.C0.ESC+"[1;"+(i+1)+"P":c.C0.ESC+"OP";break;case 113:l.key=i?c.C0.ESC+"[1;"+(i+1)+"Q":c.C0.ESC+"OQ";break;case 114:l.key=i?c.C0.ESC+"[1;"+(i+1)+"R":c.C0.ESC+"OR";break;case 115:l.key=i?c.C0.ESC+"[1;"+(i+1)+"S":c.C0.ESC+"OS";break;case 116:l.key=i?c.C0.ESC+"[15;"+(i+1)+"~":c.C0.ESC+"[15~";break;case 117:l.key=i?c.C0.ESC+"[17;"+(i+1)+"~":c.C0.ESC+"[17~";break;case 118:l.key=i?c.C0.ESC+"[18;"+(i+1)+"~":c.C0.ESC+"[18~";break;case 119:l.key=i?c.C0.ESC+"[19;"+(i+1)+"~":c.C0.ESC+"[19~";break;case 120:l.key=i?c.C0.ESC+"[20;"+(i+1)+"~":c.C0.ESC+"[20~";break;case 121:l.key=i?c.C0.ESC+"[21;"+(i+1)+"~":c.C0.ESC+"[21~";break;case 122:l.key=i?c.C0.ESC+"[23;"+(i+1)+"~":c.C0.ESC+"[23~";break;case 123:l.key=i?c.C0.ESC+"[24;"+(i+1)+"~":c.C0.ESC+"[24~";break;default:if(!n.ctrlKey||n.shiftKey||n.altKey||n.metaKey)if(h&&!_||!n.altKey||n.metaKey)!h||n.altKey||n.ctrlKey||n.shiftKey||!n.metaKey?n.key&&!n.ctrlKey&&!n.altKey&&!n.metaKey&&n.keyCode>=48&&n.key.length===1?l.key=n.key:n.key&&n.ctrlKey&&(n.key==="_"&&(l.key=c.C0.US),n.key==="@"&&(l.key=c.C0.NUL)):n.keyCode===65&&(l.type=1);else{let t=u[n.keyCode],e=t?.[n.shiftKey?1:0];if(e)l.key=c.C0.ESC+e;else if(n.keyCode>=65&&n.keyCode<=90){let s=n.ctrlKey?n.keyCode-64:n.keyCode+32,d=String.fromCharCode(s);n.shiftKey&&(d=d.toUpperCase()),l.key=c.C0.ESC+d}else if(n.keyCode===32)l.key=c.C0.ESC+(n.ctrlKey?c.C0.NUL:" ");else if(n.key==="Dead"&&n.code.startsWith("Key")){let s=n.code.slice(3,4);n.shiftKey||(s=s.toLowerCase()),l.key=c.C0.ESC+s,l.cancel=!0}}else n.keyCode>=65&&n.keyCode<=90?l.key=String.fromCharCode(n.keyCode-64):n.keyCode===32?l.key=c.C0.NUL:n.keyCode>=51&&n.keyCode<=55?l.key=String.fromCharCode(n.keyCode-51+27):n.keyCode===56?l.key=c.C0.DEL:n.keyCode===219?l.key=c.C0.ESC:n.keyCode===220?l.key=c.C0.FS:n.keyCode===221&&(l.key=c.C0.GS)}return l}},482:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Utf8ToUtf32=r.StringToUtf32=r.utf32ToString=r.stringFromCodePoint=void 0,r.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},r.utf32ToString=function(o,c=0,u=o.length){let n="";for(let a=c;a<u;++a){let h=o[a];h>65535?(h-=65536,n+=String.fromCharCode(55296+(h>>10))+String.fromCharCode(h%1024+56320)):n+=String.fromCharCode(h)}return n},r.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(o,c){let u=o.length;if(!u)return 0;let n=0,a=0;if(this._interim){let h=o.charCodeAt(a++);56320<=h&&h<=57343?c[n++]=1024*(this._interim-55296)+h-56320+65536:(c[n++]=this._interim,c[n++]=h),this._interim=0}for(let h=a;h<u;++h){let _=o.charCodeAt(h);if(55296<=_&&_<=56319){if(++h>=u)return this._interim=_,n;let l=o.charCodeAt(h);56320<=l&&l<=57343?c[n++]=1024*(_-55296)+l-56320+65536:(c[n++]=_,c[n++]=l)}else _!==65279&&(c[n++]=_)}return n}},r.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,c){let u=o.length;if(!u)return 0;let n,a,h,_,l=0,i=0,t=0;if(this.interim[0]){let d=!1,g=this.interim[0];g&=(224&g)==192?31:(240&g)==224?15:7;let p,v=0;for(;(p=63&this.interim[++v])&&v<4;)g<<=6,g|=p;let f=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,m=f-v;for(;t<m;){if(t>=u)return 0;if(p=o[t++],(192&p)!=128){t--,d=!0;break}this.interim[v++]=p,g<<=6,g|=63&p}d||(f===2?g<128?t--:c[l++]=g:f===3?g<2048||g>=55296&&g<=57343||g===65279||(c[l++]=g):g<65536||g>1114111||(c[l++]=g)),this.interim.fill(0)}let e=u-4,s=t;for(;s<u;){for(;!(!(s<e)||128&(n=o[s])||128&(a=o[s+1])||128&(h=o[s+2])||128&(_=o[s+3]));)c[l++]=n,c[l++]=a,c[l++]=h,c[l++]=_,s+=4;if(n=o[s++],n<128)c[l++]=n;else if((224&n)==192){if(s>=u)return this.interim[0]=n,l;if(a=o[s++],(192&a)!=128){s--;continue}if(i=(31&n)<<6|63&a,i<128){s--;continue}c[l++]=i}else if((240&n)==224){if(s>=u)return this.interim[0]=n,l;if(a=o[s++],(192&a)!=128){s--;continue}if(s>=u)return this.interim[0]=n,this.interim[1]=a,l;if(h=o[s++],(192&h)!=128){s--;continue}if(i=(15&n)<<12|(63&a)<<6|63&h,i<2048||i>=55296&&i<=57343||i===65279)continue;c[l++]=i}else if((248&n)==240){if(s>=u)return this.interim[0]=n,l;if(a=o[s++],(192&a)!=128){s--;continue}if(s>=u)return this.interim[0]=n,this.interim[1]=a,l;if(h=o[s++],(192&h)!=128){s--;continue}if(s>=u)return this.interim[0]=n,this.interim[1]=a,this.interim[2]=h,l;if(_=o[s++],(192&_)!=128){s--;continue}if(i=(7&n)<<18|(63&a)<<12|(63&h)<<6|63&_,i<65536||i>1114111)continue;c[l++]=i}}return l}}},225:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeV6=void 0;let c=o(1480),u=[[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]],n=[[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]],a;r.UnicodeV6=class{constructor(){if(this.version="6",!a){a=new Uint8Array(65536),a.fill(1),a[0]=0,a.fill(0,1,32),a.fill(0,127,160),a.fill(2,4352,4448),a[9001]=2,a[9002]=2,a.fill(2,11904,42192),a[12351]=1,a.fill(2,44032,55204),a.fill(2,63744,64256),a.fill(2,65040,65050),a.fill(2,65072,65136),a.fill(2,65280,65377),a.fill(2,65504,65511);for(let h=0;h<u.length;++h)a.fill(0,u[h][0],u[h][1]+1)}}wcwidth(h){return h<32?0:h<127?1:h<65536?a[h]:(function(_,l){let i,t=0,e=l.length-1;if(_<l[0][0]||_>l[e][1])return!1;for(;e>=t;)if(i=t+e>>1,_>l[i][1])t=i+1;else{if(!(_<l[i][0]))return!0;e=i-1}return!1})(h,n)?0:h>=131072&&h<=196605||h>=196608&&h<=262141?2:1}charProperties(h,_){let l=this.wcwidth(h),i=l===0&&_!==0;if(i){let t=c.UnicodeService.extractWidth(_);t===0?i=!1:t>l&&(l=t)}return c.UnicodeService.createPropertyValue(0,l,i)}}},5981:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WriteBuffer=void 0;let c=o(8460),u=o(844);class n extends u.Disposable{constructor(h){super(),this._action=h,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new c.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(h,_){if(_!==void 0&&this._syncCalls>_)return void(this._syncCalls=0);if(this._pendingData+=h.length,this._writeBuffer.push(h),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let l;for(this._isSyncWriting=!0;l=this._writeBuffer.shift();){this._action(l);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(h,_){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=h.length,this._writeBuffer.push(h),this._callbacks.push(_),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=h.length,this._writeBuffer.push(h),this._callbacks.push(_)}_innerWrite(h=0,_=!0){let l=h||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],t=this._action(i,_);if(t){let s=d=>Date.now()-l>=12?setTimeout((()=>this._innerWrite(0,d))):this._innerWrite(l,d);return void t.catch((d=>(queueMicrotask((()=>{throw d})),Promise.resolve(!1)))).then(s)}let e=this._callbacks[this._bufferOffset];if(e&&e(),this._bufferOffset++,this._pendingData-=i.length,Date.now()-l>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(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()}}r.WriteBuffer=n},5941:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toRgbString=r.parseColor=void 0;let o=/^([\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})$/,c=/^[\da-f]+$/;function u(n,a){let h=n.toString(16),_=h.length<2?"0"+h:h;switch(a){case 4:return h[0];case 8:return _;case 12:return(_+_).slice(0,3);default:return _+_}}r.parseColor=function(n){if(!n)return;let a=n.toLowerCase();if(a.indexOf("rgb:")===0){a=a.slice(4);let h=o.exec(a);if(h){let _=h[1]?15:h[4]?255:h[7]?4095:65535;return[Math.round(parseInt(h[1]||h[4]||h[7]||h[10],16)/_*255),Math.round(parseInt(h[2]||h[5]||h[8]||h[11],16)/_*255),Math.round(parseInt(h[3]||h[6]||h[9]||h[12],16)/_*255)]}}else if(a.indexOf("#")===0&&(a=a.slice(1),c.exec(a)&&[3,6,9,12].includes(a.length))){let h=a.length/3,_=[0,0,0];for(let l=0;l<3;++l){let i=parseInt(a.slice(h*l,h*l+h),16);_[l]=h===1?i<<4:h===2?i:h===3?i>>4:i>>8}return _}},r.toRgbString=function(n,a=16){let[h,_,l]=n;return`rgb:${u(h,a)}/${u(_,a)}/${u(l,a)}`}},5770:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PAYLOAD_LIMIT=void 0,r.PAYLOAD_LIMIT=1e7},6351:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DcsHandler=r.DcsParser=void 0;let c=o(482),u=o(8742),n=o(5770),a=[];r.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=a,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a}registerHandler(_,l){this._handlers[_]===void 0&&(this._handlers[_]=[]);let i=this._handlers[_];return i.push(l),{dispose:()=>{let t=i.indexOf(l);t!==-1&&i.splice(t,1)}}}clearHandler(_){this._handlers[_]&&delete this._handlers[_]}setHandlerFallback(_){this._handlerFb=_}reset(){if(this._active.length)for(let _=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;_>=0;--_)this._active[_].unhook(!1);this._stack.paused=!1,this._active=a,this._ident=0}hook(_,l){if(this.reset(),this._ident=_,this._active=this._handlers[_]||a,this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(l);else this._handlerFb(this._ident,"HOOK",l)}put(_,l,i){if(this._active.length)for(let t=this._active.length-1;t>=0;t--)this._active[t].put(_,l,i);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(_,l,i))}unhook(_,l=!0){if(this._active.length){let i=!1,t=this._active.length-1,e=!1;if(this._stack.paused&&(t=this._stack.loopPosition-1,i=l,e=this._stack.fallThrough,this._stack.paused=!1),!e&&i===!1){for(;t>=0&&(i=this._active[t].unhook(_),i!==!0);t--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=t,this._stack.fallThrough=!1,i;t--}for(;t>=0;t--)if(i=this._active[t].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=t,this._stack.fallThrough=!0,i}else this._handlerFb(this._ident,"UNHOOK",_);this._active=a,this._ident=0}};let h=new u.Params;h.addParam(0),r.DcsHandler=class{constructor(_){this._handler=_,this._data="",this._params=h,this._hitLimit=!1}hook(_){this._params=_.length>1||_.params[0]?_.clone():h,this._data="",this._hitLimit=!1}put(_,l,i){this._hitLimit||(this._data+=(0,c.utf32ToString)(_,l,i),this._data.length>n.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(_){let l=!1;if(this._hitLimit)l=!1;else if(_&&(l=this._handler(this._data,this._params),l instanceof Promise))return l.then((i=>(this._params=h,this._data="",this._hitLimit=!1,i)));return this._params=h,this._data="",this._hitLimit=!1,l}}},2015:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.EscapeSequenceParser=r.VT500_TRANSITION_TABLE=r.TransitionTable=void 0;let c=o(844),u=o(8742),n=o(6242),a=o(6351);class h{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,d){this.table[e<<8|t]=s<<4|d}addMany(t,e,s,d){for(let g=0;g<t.length;g++)this.table[e<<8|t[g]]=s<<4|d}}r.TransitionTable=h;let _=160;r.VT500_TRANSITION_TABLE=(function(){let i=new h(4095),t=Array.apply(null,Array(256)).map(((v,f)=>f)),e=(v,f)=>t.slice(v,f),s=e(32,127),d=e(0,24);d.push(25),d.push.apply(d,e(28,32));let g=e(0,14),p;for(p in i.setDefault(1,0),i.addMany(s,0,2,0),g)i.addMany([24,26,153,154],p,3,0),i.addMany(e(128,144),p,3,0),i.addMany(e(144,152),p,3,0),i.add(156,p,0,0),i.add(27,p,11,1),i.add(157,p,4,8),i.addMany([152,158,159],p,0,7),i.add(155,p,11,3),i.add(144,p,11,9);return i.addMany(d,0,3,0),i.addMany(d,1,3,1),i.add(127,1,0,1),i.addMany(d,8,0,8),i.addMany(d,3,3,3),i.add(127,3,0,3),i.addMany(d,4,3,4),i.add(127,4,0,4),i.addMany(d,6,3,6),i.addMany(d,5,3,5),i.add(127,5,0,5),i.addMany(d,2,3,2),i.add(127,2,0,2),i.add(93,1,4,8),i.addMany(s,8,5,8),i.add(127,8,5,8),i.addMany([156,27,24,26,7],8,6,0),i.addMany(e(28,32),8,0,8),i.addMany([88,94,95],1,0,7),i.addMany(s,7,0,7),i.addMany(d,7,0,7),i.add(156,7,0,0),i.add(127,7,0,7),i.add(91,1,11,3),i.addMany(e(64,127),3,7,0),i.addMany(e(48,60),3,8,4),i.addMany([60,61,62,63],3,9,4),i.addMany(e(48,60),4,8,4),i.addMany(e(64,127),4,7,0),i.addMany([60,61,62,63],4,0,6),i.addMany(e(32,64),6,0,6),i.add(127,6,0,6),i.addMany(e(64,127),6,0,0),i.addMany(e(32,48),3,9,5),i.addMany(e(32,48),5,9,5),i.addMany(e(48,64),5,0,6),i.addMany(e(64,127),5,7,0),i.addMany(e(32,48),4,9,5),i.addMany(e(32,48),1,9,2),i.addMany(e(32,48),2,9,2),i.addMany(e(48,127),2,10,0),i.addMany(e(48,80),1,10,0),i.addMany(e(81,88),1,10,0),i.addMany([89,90,92],1,10,0),i.addMany(e(96,127),1,10,0),i.add(80,1,11,9),i.addMany(d,9,0,9),i.add(127,9,0,9),i.addMany(e(28,32),9,0,9),i.addMany(e(32,48),9,9,12),i.addMany(e(48,60),9,8,10),i.addMany([60,61,62,63],9,9,10),i.addMany(d,11,0,11),i.addMany(e(32,128),11,0,11),i.addMany(e(28,32),11,0,11),i.addMany(d,10,0,10),i.add(127,10,0,10),i.addMany(e(28,32),10,0,10),i.addMany(e(48,60),10,8,10),i.addMany([60,61,62,63],10,0,11),i.addMany(e(32,48),10,9,12),i.addMany(d,12,0,12),i.add(127,12,0,12),i.addMany(e(28,32),12,0,12),i.addMany(e(32,48),12,9,12),i.addMany(e(48,64),12,0,11),i.addMany(e(64,127),12,12,13),i.addMany(e(64,127),10,12,13),i.addMany(e(64,127),9,12,13),i.addMany(d,13,13,13),i.addMany(s,13,13,13),i.add(127,13,0,13),i.addMany([27,156,24,26],13,14,0),i.add(_,0,2,0),i.add(_,8,5,8),i.add(_,6,0,6),i.add(_,11,0,11),i.add(_,13,13,13),i})();class l extends c.Disposable{constructor(t=r.VT500_TRANSITION_TABLE){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new u.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,d)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,s)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,c.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new n.OscParser),this._dcsParser=this.register(new a.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(t,e=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let g=0;g<t.intermediates.length;++g){let p=t.intermediates.charCodeAt(g);if(32>p||p>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=p}}if(t.final.length!==1)throw new Error("final must be a single byte");let d=t.final.charCodeAt(0);if(e[0]>d||d>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=d,s}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(255&t)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let s=this._identifier(t,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let d=this._escHandlers[s];return d.push(e),{dispose:()=>{let g=d.indexOf(e);g!==-1&&d.splice(g,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let s=this._identifier(t);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let d=this._csiHandlers[s];return d.push(e),{dispose:()=>{let g=d.indexOf(e);g!==-1&&d.splice(g,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}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(t,e,s,d,g){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=d,this._parseStack.chunkPos=g}parse(t,e,s){let d,g=0,p=0,v=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,v=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&m>-1){for(;m>=0&&(d=f[m](this._params),d!==!0);m--)if(d instanceof Promise)return this._parseStack.handlerPos=m,d}this._parseStack.handlers=[];break;case 4:if(s===!1&&m>-1){for(;m>=0&&(d=f[m](),d!==!0);m--)if(d instanceof Promise)return this._parseStack.handlerPos=m,d}this._parseStack.handlers=[];break;case 6:if(g=t[this._parseStack.chunkPos],d=this._dcsParser.unhook(g!==24&&g!==26,s),d)return d;g===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(g=t[this._parseStack.chunkPos],d=this._oscParser.end(g!==24&&g!==26,s),d)return d;g===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,v=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let f=v;f<e;++f){switch(g=t[f],p=this._transitions.table[this.currentState<<8|(g<160?g:_)],p>>4){case 2:for(let C=f+1;;++C){if(C>=e||(g=t[C])<32||g>126&&g<_){this._printHandler(t,f,C),f=C-1;break}if(++C>=e||(g=t[C])<32||g>126&&g<_){this._printHandler(t,f,C),f=C-1;break}if(++C>=e||(g=t[C])<32||g>126&&g<_){this._printHandler(t,f,C),f=C-1;break}if(++C>=e||(g=t[C])<32||g>126&&g<_){this._printHandler(t,f,C),f=C-1;break}}break;case 3:this._executeHandlers[g]?this._executeHandlers[g]():this._executeHandlerFb(g),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:g,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let m=this._csiHandlers[this._collect<<8|g],E=m?m.length-1:-1;for(;E>=0&&(d=m[E](this._params),d!==!0);E--)if(d instanceof Promise)return this._preserveStack(3,m,E,p,f),d;E<0&&this._csiHandlerFb(this._collect<<8|g,this._params),this.precedingJoinState=0;break;case 8:do switch(g){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(g-48)}while(++f<e&&(g=t[f])>47&&g<60);f--;break;case 9:this._collect<<=8,this._collect|=g;break;case 10:let k=this._escHandlers[this._collect<<8|g],x=k?k.length-1:-1;for(;x>=0&&(d=k[x](),d!==!0);x--)if(d instanceof Promise)return this._preserveStack(4,k,x,p,f),d;x<0&&this._escHandlerFb(this._collect<<8|g),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|g,this._params);break;case 13:for(let C=f+1;;++C)if(C>=e||(g=t[C])===24||g===26||g===27||g>127&&g<_){this._dcsParser.put(t,f,C),f=C-1;break}break;case 14:if(d=this._dcsParser.unhook(g!==24&&g!==26),d)return this._preserveStack(6,[],0,p,f),d;g===27&&(p|=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 C=f+1;;C++)if(C>=e||(g=t[C])<32||g>127&&g<_){this._oscParser.put(t,f,C),f=C-1;break}break;case 6:if(d=this._oscParser.end(g!==24&&g!==26),d)return this._preserveStack(5,[],0,p,f),d;g===27&&(p|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&p}}}r.EscapeSequenceParser=l},6242:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OscHandler=r.OscParser=void 0;let c=o(5770),u=o(482),n=[];r.OscParser=class{constructor(){this._state=0,this._active=n,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(a,h){this._handlers[a]===void 0&&(this._handlers[a]=[]);let _=this._handlers[a];return _.push(h),{dispose:()=>{let l=_.indexOf(h);l!==-1&&_.splice(l,1)}}}clearHandler(a){this._handlers[a]&&delete this._handlers[a]}setHandlerFallback(a){this._handlerFb=a}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=n}reset(){if(this._state===2)for(let a=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;a>=0;--a)this._active[a].end(!1);this._stack.paused=!1,this._active=n,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||n,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].start();else this._handlerFb(this._id,"START")}_put(a,h,_){if(this._active.length)for(let l=this._active.length-1;l>=0;l--)this._active[l].put(a,h,_);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(a,h,_))}start(){this.reset(),this._state=1}put(a,h,_){if(this._state!==3){if(this._state===1)for(;h<_;){let l=a[h++];if(l===59){this._state=2,this._start();break}if(l<48||57<l)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+l-48}this._state===2&&_-h>0&&this._put(a,h,_)}}end(a,h=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let _=!1,l=this._active.length-1,i=!1;if(this._stack.paused&&(l=this._stack.loopPosition-1,_=h,i=this._stack.fallThrough,this._stack.paused=!1),!i&&_===!1){for(;l>=0&&(_=this._active[l].end(a),_!==!0);l--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=l,this._stack.fallThrough=!1,_;l--}for(;l>=0;l--)if(_=this._active[l].end(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=l,this._stack.fallThrough=!0,_}else this._handlerFb(this._id,"END",a);this._active=n,this._id=-1,this._state=0}}},r.OscHandler=class{constructor(a){this._handler=a,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(a,h,_){this._hitLimit||(this._data+=(0,u.utf32ToString)(a,h,_),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(a){let h=!1;if(this._hitLimit)h=!1;else if(a&&(h=this._handler(this._data),h instanceof Promise))return h.then((_=>(this._data="",this._hitLimit=!1,_)));return this._data="",this._hitLimit=!1,h}}},8742:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Params=void 0;let o=2147483647;class c{static fromArray(n){let a=new c;if(!n.length)return a;for(let h=Array.isArray(n[0])?1:0;h<n.length;++h){let _=n[h];if(Array.isArray(_))for(let l=0;l<_.length;++l)a.addSubParam(_[l]);else a.addParam(_)}return a}constructor(n=32,a=32){if(this.maxLength=n,this.maxSubParamsLength=a,a>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(n),this.length=0,this._subParams=new Int32Array(a),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(n),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){let n=new c(this.maxLength,this.maxSubParamsLength);return n.params.set(this.params),n.length=this.length,n._subParams.set(this._subParams),n._subParamsLength=this._subParamsLength,n._subParamsIdx.set(this._subParamsIdx),n._rejectDigits=this._rejectDigits,n._rejectSubDigits=this._rejectSubDigits,n._digitIsSub=this._digitIsSub,n}toArray(){let n=[];for(let a=0;a<this.length;++a){n.push(this.params[a]);let h=this._subParamsIdx[a]>>8,_=255&this._subParamsIdx[a];_-h>0&&n.push(Array.prototype.slice.call(this._subParams,h,_))}return n}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(n){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(n<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=n>o?o:n}}addSubParam(n){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(n<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=n>o?o:n,this._subParamsIdx[this.length-1]++}}hasSubParams(n){return(255&this._subParamsIdx[n])-(this._subParamsIdx[n]>>8)>0}getSubParams(n){let a=this._subParamsIdx[n]>>8,h=255&this._subParamsIdx[n];return h-a>0?this._subParams.subarray(a,h):null}getSubParamsAll(){let n={};for(let a=0;a<this.length;++a){let h=this._subParamsIdx[a]>>8,_=255&this._subParamsIdx[a];_-h>0&&(n[a]=this._subParams.slice(h,_))}return n}addDigit(n){let a;if(this._rejectDigits||!(a=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let h=this._digitIsSub?this._subParams:this.params,_=h[a-1];h[a-1]=~_?Math.min(10*_+n,o):n}}r.Params=c},5741:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.AddonManager=void 0,r.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let o=this._addons.length-1;o>=0;o--)this._addons[o].instance.dispose()}loadAddon(o,c){let u={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(u),c.dispose=()=>this._wrappedAddonDispose(u),c.activate(o)}_wrappedAddonDispose(o){if(o.isDisposed)return;let c=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===o){c=u;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");o.isDisposed=!0,o.dispose.apply(o.instance),this._addons.splice(c,1)}}},8771:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferApiView=void 0;let c=o(3785),u=o(511);r.BufferApiView=class{constructor(n,a){this._buffer=n,this.type=a}init(n){return this._buffer=n,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(n){let a=this._buffer.lines.get(n);if(a)return new c.BufferLineApiView(a)}getNullCell(){return new u.CellData}}},3785:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLineApiView=void 0;let c=o(511);r.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,n){if(!(u<0||u>=this._line.length))return n?(this._line.loadCell(u,n),n):this._line.loadCell(u,new c.CellData)}translateToString(u,n,a){return this._line.translateToString(u,n,a)}}},8285:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferNamespaceApi=void 0;let c=o(8771),u=o(8460),n=o(844);class a extends n.Disposable{constructor(_){super(),this._core=_,this._onBufferChange=this.register(new u.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new c.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new c.BufferApiView(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)}}r.BufferNamespaceApi=a},7975:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ParserApi=void 0,r.ParserApi=class{constructor(o){this._core=o}registerCsiHandler(o,c){return this._core.registerCsiHandler(o,(u=>c(u.toArray())))}addCsiHandler(o,c){return this.registerCsiHandler(o,c)}registerDcsHandler(o,c){return this._core.registerDcsHandler(o,((u,n)=>c(u,n.toArray())))}addDcsHandler(o,c){return this.registerDcsHandler(o,c)}registerEscHandler(o,c){return this._core.registerEscHandler(o,c)}addEscHandler(o,c){return this.registerEscHandler(o,c)}registerOscHandler(o,c){return this._core.registerOscHandler(o,c)}addOscHandler(o,c){return this.registerOscHandler(o,c)}}},7090:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeApi=void 0,r.UnicodeApi=class{constructor(o){this._core=o}register(o){this._core.unicodeService.register(o)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(o){this._core.unicodeService.activeVersion=o}}},744:function(D,r,o){var c=this&&this.__decorate||function(i,t,e,s){var d,g=arguments.length,p=g<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(i,t,e,s);else for(var v=i.length-1;v>=0;v--)(d=i[v])&&(p=(g<3?d(p):g>3?d(t,e,p):d(t,e))||p);return g>3&&p&&Object.defineProperty(t,e,p),p},u=this&&this.__param||function(i,t){return function(e,s){t(e,s,i)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferService=r.MINIMUM_ROWS=r.MINIMUM_COLS=void 0;let n=o(8460),a=o(844),h=o(5295),_=o(2585);r.MINIMUM_COLS=2,r.MINIMUM_ROWS=1;let l=r.BufferService=class extends a.Disposable{get buffer(){return this.buffers.active}constructor(i){super(),this.isUserScrolling=!1,this._onResize=this.register(new n.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new n.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(i.rawOptions.cols||0,r.MINIMUM_COLS),this.rows=Math.max(i.rawOptions.rows||0,r.MINIMUM_ROWS),this.buffers=this.register(new h.BufferSet(i,this))}resize(i,t){this.cols=i,this.rows=t,this.buffers.resize(i,t),this._onResize.fire({cols:i,rows:t})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(i,t=!1){let e=this.buffer,s;s=this._cachedBlankLine,s&&s.length===this.cols&&s.getFg(0)===i.fg&&s.getBg(0)===i.bg||(s=e.getBlankLine(i,t),this._cachedBlankLine=s),s.isWrapped=t;let d=e.ybase+e.scrollTop,g=e.ybase+e.scrollBottom;if(e.scrollTop===0){let p=e.lines.isFull;g===e.lines.length-1?p?e.lines.recycle().copyFrom(s):e.lines.push(s.clone()):e.lines.splice(g+1,0,s.clone()),p?this.isUserScrolling&&(e.ydisp=Math.max(e.ydisp-1,0)):(e.ybase++,this.isUserScrolling||e.ydisp++)}else{let p=g-d+1;e.lines.shiftElements(d+1,p-1,-1),e.lines.set(g,s.clone())}this.isUserScrolling||(e.ydisp=e.ybase),this._onScroll.fire(e.ydisp)}scrollLines(i,t,e){let s=this.buffer;if(i<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else i+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let d=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+i,s.ybase),0),d!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};r.BufferService=l=c([u(0,_.IOptionsService)],l)},7994:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CharsetService=void 0,r.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(o){this.glevel=o,this.charset=this._charsets[o]}setgCharset(o,c){this._charsets[o]=c,this.glevel===o&&(this.charset=c)}}},1753:function(D,r,o){var c=this&&this.__decorate||function(s,d,g,p){var v,f=arguments.length,m=f<3?d:p===null?p=Object.getOwnPropertyDescriptor(d,g):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(s,d,g,p);else for(var E=s.length-1;E>=0;E--)(v=s[E])&&(m=(f<3?v(m):f>3?v(d,g,m):v(d,g))||m);return f>3&&m&&Object.defineProperty(d,g,m),m},u=this&&this.__param||function(s,d){return function(g,p){d(g,p,s)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreMouseService=void 0;let n=o(2585),a=o(8460),h=o(844),_={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:s=>s.button!==4&&s.action===1&&(s.ctrl=!1,s.alt=!1,s.shift=!1,!0)},VT200:{events:19,restrict:s=>s.action!==32},DRAG:{events:23,restrict:s=>s.action!==32||s.button!==3},ANY:{events:31,restrict:s=>!0}};function l(s,d){let g=(s.ctrl?16:0)|(s.shift?4:0)|(s.alt?8:0);return s.button===4?(g|=64,g|=s.action):(g|=3&s.button,4&s.button&&(g|=64),8&s.button&&(g|=128),s.action===32?g|=32:s.action!==0||d||(g|=3)),g}let i=String.fromCharCode,t={DEFAULT:s=>{let d=[l(s,!1)+32,s.col+32,s.row+32];return d[0]>255||d[1]>255||d[2]>255?"":`\x1B[M${i(d[0])}${i(d[1])}${i(d[2])}`},SGR:s=>{let d=s.action===0&&s.button!==4?"m":"M";return`\x1B[<${l(s,!0)};${s.col};${s.row}${d}`},SGR_PIXELS:s=>{let d=s.action===0&&s.button!==4?"m":"M";return`\x1B[<${l(s,!0)};${s.x};${s.y}${d}`}},e=r.CoreMouseService=class extends h.Disposable{constructor(s,d){super(),this._bufferService=s,this._coreService=d,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new a.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(let g of Object.keys(_))this.addProtocol(g,_[g]);for(let g of Object.keys(t))this.addEncoding(g,t[g]);this.reset()}addProtocol(s,d){this._protocols[s]=d}addEncoding(s,d){this._encodings[s]=d}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(s){if(!this._protocols[s])throw new Error(`unknown protocol "${s}"`);this._activeProtocol=s,this._onProtocolChange.fire(this._protocols[s].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(s){if(!this._encodings[s])throw new Error(`unknown encoding "${s}"`);this._activeEncoding=s}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(s){if(s.col<0||s.col>=this._bufferService.cols||s.row<0||s.row>=this._bufferService.rows||s.button===4&&s.action===32||s.button===3&&s.action!==32||s.button!==4&&(s.action===2||s.action===3)||(s.col++,s.row++,s.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,s,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(s))return!1;let d=this._encodings[this._activeEncoding](s);return d&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(d):this._coreService.triggerDataEvent(d,!0)),this._lastEvent=s,!0}explainEvents(s){return{down:!!(1&s),up:!!(2&s),drag:!!(4&s),move:!!(8&s),wheel:!!(16&s)}}_equalEvents(s,d,g){if(g){if(s.x!==d.x||s.y!==d.y)return!1}else if(s.col!==d.col||s.row!==d.row)return!1;return s.button===d.button&&s.action===d.action&&s.ctrl===d.ctrl&&s.alt===d.alt&&s.shift===d.shift}};r.CoreMouseService=e=c([u(0,n.IBufferService),u(1,n.ICoreService)],e)},6975:function(D,r,o){var c=this&&this.__decorate||function(e,s,d,g){var p,v=arguments.length,f=v<3?s:g===null?g=Object.getOwnPropertyDescriptor(s,d):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(e,s,d,g);else for(var m=e.length-1;m>=0;m--)(p=e[m])&&(f=(v<3?p(f):v>3?p(s,d,f):p(s,d))||f);return v>3&&f&&Object.defineProperty(s,d,f),f},u=this&&this.__param||function(e,s){return function(d,g){s(d,g,e)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreService=void 0;let n=o(1439),a=o(8460),h=o(844),_=o(2585),l=Object.freeze({insertMode:!1}),i=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0}),t=r.CoreService=class extends h.Disposable{constructor(e,s,d){super(),this._bufferService=e,this._logService=s,this._optionsService=d,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new a.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new a.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,n.clone)(l),this.decPrivateModes=(0,n.clone)(i)}reset(){this.modes=(0,n.clone)(l),this.decPrivateModes=(0,n.clone)(i)}triggerDataEvent(e,s=!1){if(this._optionsService.rawOptions.disableStdin)return;let d=this._bufferService.buffer;s&&this._optionsService.rawOptions.scrollOnUserInput&&d.ybase!==d.ydisp&&this._onRequestScrollToBottom.fire(),s&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`,(()=>e.split("").map((g=>g.charCodeAt(0))))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`,(()=>e.split("").map((s=>s.charCodeAt(0))))),this._onBinary.fire(e))}};r.CoreService=t=c([u(0,_.IBufferService),u(1,_.ILogService),u(2,_.IOptionsService)],t)},9074:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DecorationService=void 0;let c=o(8055),u=o(8460),n=o(844),a=o(6106),h=0,_=0;class l extends n.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new a.SortedList((e=>e?.marker.line)),this._onDecorationRegistered=this.register(new u.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new u.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,n.toDisposable)((()=>this.reset())))}registerDecoration(e){if(e.marker.isDisposed)return;let s=new i(e);if(s){let d=s.marker.onDispose((()=>s.dispose()));s.onDispose((()=>{s&&(this._decorations.delete(s)&&this._onDecorationRemoved.fire(s),d.dispose())})),this._decorations.insert(s),this._onDecorationRegistered.fire(s)}return s}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,s,d){let g=0,p=0;for(let v of this._decorations.getKeyIterator(s))g=v.options.x??0,p=g+(v.options.width??1),e>=g&&e<p&&(!d||(v.options.layer??"bottom")===d)&&(yield v)}forEachDecorationAtCell(e,s,d,g){this._decorations.forEachByKey(s,(p=>{h=p.options.x??0,_=h+(p.options.width??1),e>=h&&e<_&&(!d||(p.options.layer??"bottom")===d)&&g(p)}))}}r.DecorationService=l;class i extends n.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=c.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=c.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(e){super(),this.options=e,this.onRenderEmitter=this.register(new u.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new u.EventEmitter),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")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.InstantiationService=r.ServiceCollection=void 0;let c=o(2585),u=o(8343);class n{constructor(...h){this._entries=new Map;for(let[_,l]of h)this.set(_,l)}set(h,_){let l=this._entries.get(h);return this._entries.set(h,_),l}forEach(h){for(let[_,l]of this._entries.entries())h(_,l)}has(h){return this._entries.has(h)}get(h){return this._entries.get(h)}}r.ServiceCollection=n,r.InstantiationService=class{constructor(){this._services=new n,this._services.set(c.IInstantiationService,this)}setService(a,h){this._services.set(a,h)}getService(a){return this._services.get(a)}createInstance(a,...h){let _=(0,u.getServiceDependencies)(a).sort(((t,e)=>t.index-e.index)),l=[];for(let t of _){let e=this._services.get(t.id);if(!e)throw new Error(`[createInstance] ${a.name} depends on UNKNOWN service ${t.id}.`);l.push(e)}let i=_.length>0?_[0].index:h.length;if(h.length!==i)throw new Error(`[createInstance] First service dependency of ${a.name} at position ${i+1} conflicts with ${h.length} static arguments`);return new a(...h,...l)}}},7866:function(D,r,o){var c=this&&this.__decorate||function(i,t,e,s){var d,g=arguments.length,p=g<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(i,t,e,s);else for(var v=i.length-1;v>=0;v--)(d=i[v])&&(p=(g<3?d(p):g>3?d(t,e,p):d(t,e))||p);return g>3&&p&&Object.defineProperty(t,e,p),p},u=this&&this.__param||function(i,t){return function(e,s){t(e,s,i)}};Object.defineProperty(r,"__esModule",{value:!0}),r.traceCall=r.setTraceLogger=r.LogService=void 0;let n=o(844),a=o(2585),h={trace:a.LogLevelEnum.TRACE,debug:a.LogLevelEnum.DEBUG,info:a.LogLevelEnum.INFO,warn:a.LogLevelEnum.WARN,error:a.LogLevelEnum.ERROR,off:a.LogLevelEnum.OFF},_,l=r.LogService=class extends n.Disposable{get logLevel(){return this._logLevel}constructor(i){super(),this._optionsService=i,this._logLevel=a.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),_=this}_updateLogLevel(){this._logLevel=h[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(i){for(let t=0;t<i.length;t++)typeof i[t]=="function"&&(i[t]=i[t]())}_log(i,t,e){this._evalLazyOptionalParams(e),i.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t,...e)}trace(i,...t){this._logLevel<=a.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,i,t)}debug(i,...t){this._logLevel<=a.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,i,t)}info(i,...t){this._logLevel<=a.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,i,t)}warn(i,...t){this._logLevel<=a.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,i,t)}error(i,...t){this._logLevel<=a.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,i,t)}};r.LogService=l=c([u(0,a.IOptionsService)],l),r.setTraceLogger=function(i){_=i},r.traceCall=function(i,t,e){if(typeof e.value!="function")throw new Error("not supported");let s=e.value;e.value=function(...d){if(_.logLevel!==a.LogLevelEnum.TRACE)return s.apply(this,d);_.trace(`GlyphRenderer#${s.name}(${d.map((p=>JSON.stringify(p))).join(", ")})`);let g=s.apply(this,d);return _.trace(`GlyphRenderer#${s.name} return`,g),g}}},7302:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OptionsService=r.DEFAULT_OPTIONS=void 0;let c=o(8460),u=o(844),n=o(6114);r.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:n.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};let a=["normal","bold","100","200","300","400","500","600","700","800","900"];class h extends u.Disposable{constructor(l){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;let i={...r.DEFAULT_OPTIONS};for(let t in l)if(t in i)try{let e=l[t];i[t]=this._sanitizeAndValidateOption(t,e)}catch(e){console.error(e)}this.rawOptions=i,this.options={...i},this._setupOptions(),this.register((0,u.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(l,i){return this.onOptionChange((t=>{t===l&&i(this.rawOptions[l])}))}onMultipleOptionChange(l,i){return this.onOptionChange((t=>{l.indexOf(t)!==-1&&i()}))}_setupOptions(){let l=t=>{if(!(t in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${t}"`);return this.rawOptions[t]},i=(t,e)=>{if(!(t in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${t}"`);e=this._sanitizeAndValidateOption(t,e),this.rawOptions[t]!==e&&(this.rawOptions[t]=e,this._onOptionChange.fire(t))};for(let t in this.rawOptions){let e={get:l.bind(this,t),set:i.bind(this,t)};Object.defineProperty(this.options,t,e)}}_sanitizeAndValidateOption(l,i){switch(l){case"cursorStyle":if(i||(i=r.DEFAULT_OPTIONS[l]),!(function(t){return t==="block"||t==="underline"||t==="bar"})(i))throw new Error(`"${i}" is not a valid value for ${l}`);break;case"wordSeparator":i||(i=r.DEFAULT_OPTIONS[l]);break;case"fontWeight":case"fontWeightBold":if(typeof i=="number"&&1<=i&&i<=1e3)break;i=a.includes(i)?i:r.DEFAULT_OPTIONS[l];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new Error(`${l} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,4294967295))<0)throw new Error(`${l} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${l} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&i!==0)throw new Error(`${l} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}}r.OptionsService=h},2660:function(D,r,o){var c=this&&this.__decorate||function(h,_,l,i){var t,e=arguments.length,s=e<3?_:i===null?i=Object.getOwnPropertyDescriptor(_,l):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(h,_,l,i);else for(var d=h.length-1;d>=0;d--)(t=h[d])&&(s=(e<3?t(s):e>3?t(_,l,s):t(_,l))||s);return e>3&&s&&Object.defineProperty(_,l,s),s},u=this&&this.__param||function(h,_){return function(l,i){_(l,i,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkService=void 0;let n=o(2585),a=r.OscLinkService=class{constructor(h){this._bufferService=h,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(h){let _=this._bufferService.buffer;if(h.id===void 0){let d=_.addMarker(_.ybase+_.y),g={data:h,id:this._nextId++,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(g,d))),this._dataByLinkId.set(g.id,g),g.id}let l=h,i=this._getEntryIdKey(l),t=this._entriesWithId.get(i);if(t)return this.addLineToLink(t.id,_.ybase+_.y),t.id;let e=_.addMarker(_.ybase+_.y),s={id:this._nextId++,key:this._getEntryIdKey(l),data:l,lines:[e]};return e.onDispose((()=>this._removeMarkerFromLink(s,e))),this._entriesWithId.set(s.key,s),this._dataByLinkId.set(s.id,s),s.id}addLineToLink(h,_){let l=this._dataByLinkId.get(h);if(l&&l.lines.every((i=>i.line!==_))){let i=this._bufferService.buffer.addMarker(_);l.lines.push(i),i.onDispose((()=>this._removeMarkerFromLink(l,i)))}}getLinkData(h){return this._dataByLinkId.get(h)?.data}_getEntryIdKey(h){return`${h.id};;${h.uri}`}_removeMarkerFromLink(h,_){let l=h.lines.indexOf(_);l!==-1&&(h.lines.splice(l,1),h.lines.length===0&&(h.data.id!==void 0&&this._entriesWithId.delete(h.key),this._dataByLinkId.delete(h.id)))}};r.OscLinkService=a=c([u(0,n.IBufferService)],a)},8343:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createDecorator=r.getServiceDependencies=r.serviceRegistry=void 0;let o="di$target",c="di$dependencies";r.serviceRegistry=new Map,r.getServiceDependencies=function(u){return u[c]||[]},r.createDecorator=function(u){if(r.serviceRegistry.has(u))return r.serviceRegistry.get(u);let n=function(a,h,_){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(l,i,t){i[o]===i?i[c].push({id:l,index:t}):(i[c]=[{id:l,index:t}],i[o]=i)})(n,a,_)};return n.toString=()=>u,r.serviceRegistry.set(u,n),n}},2585:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IDecorationService=r.IUnicodeService=r.IOscLinkService=r.IOptionsService=r.ILogService=r.LogLevelEnum=r.IInstantiationService=r.ICharsetService=r.ICoreService=r.ICoreMouseService=r.IBufferService=void 0;let c=o(8343);var u;r.IBufferService=(0,c.createDecorator)("BufferService"),r.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),r.ICoreService=(0,c.createDecorator)("CoreService"),r.ICharsetService=(0,c.createDecorator)("CharsetService"),r.IInstantiationService=(0,c.createDecorator)("InstantiationService"),(function(n){n[n.TRACE=0]="TRACE",n[n.DEBUG=1]="DEBUG",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.OFF=5]="OFF"})(u||(r.LogLevelEnum=u={})),r.ILogService=(0,c.createDecorator)("LogService"),r.IOptionsService=(0,c.createDecorator)("OptionsService"),r.IOscLinkService=(0,c.createDecorator)("OscLinkService"),r.IUnicodeService=(0,c.createDecorator)("UnicodeService"),r.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(D,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeService=void 0;let c=o(8460),u=o(225);class n{static extractShouldJoin(h){return(1&h)!=0}static extractWidth(h){return h>>1&3}static extractCharKind(h){return h>>3}static createPropertyValue(h,_,l=!1){return(16777215&h)<<3|(3&_)<<1|(l?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;let h=new u.UnicodeV6;this.register(h),this._active=h.version,this._activeProvider=h}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(h){if(!this._providers[h])throw new Error(`unknown Unicode version "${h}"`);this._active=h,this._activeProvider=this._providers[h],this._onChange.fire(h)}register(h){this._providers[h.version]=h}wcwidth(h){return this._activeProvider.wcwidth(h)}getStringCellWidth(h){let _=0,l=0,i=h.length;for(let t=0;t<i;++t){let e=h.charCodeAt(t);if(55296<=e&&e<=56319){if(++t>=i)return _+this.wcwidth(e);let g=h.charCodeAt(t);56320<=g&&g<=57343?e=1024*(e-55296)+g-56320+65536:_+=this.wcwidth(g)}let s=this.charProperties(e,l),d=n.extractWidth(s);n.extractShouldJoin(s)&&(d-=n.extractWidth(l)),_+=d,l=s}return _}charProperties(h,_){return this._activeProvider.charProperties(h,_)}}r.UnicodeService=n}},S={};function A(D){var r=S[D];if(r!==void 0)return r.exports;var o=S[D]={exports:{}};return w[D].call(o.exports,o,o.exports,A),o.exports}var B={};return(()=>{var D=B;Object.defineProperty(D,"__esModule",{value:!0}),D.Terminal=void 0;let r=A(9042),o=A(3236),c=A(844),u=A(5741),n=A(8285),a=A(7975),h=A(7090),_=["cols","rows"];class l extends c.Disposable{constructor(t){super(),this._core=this.register(new o.Terminal(t)),this._addonManager=this.register(new u.AddonManager),this._publicOptions={...this._core.options};let e=d=>this._core.options[d],s=(d,g)=>{this._checkReadonlyOptions(d),this._core.options[d]=g};for(let d in this._core.options){let g={get:e.bind(this,d),set:s.bind(this,d)};Object.defineProperty(this._publicOptions,d,g)}}_checkReadonlyOptions(t){if(_.includes(t))throw new Error(`Option "${t}" 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 a.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new h.UnicodeApi(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 n.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any"}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,s){this._verifyIntegers(t,e,s),this._core.select(t,e,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
10
- `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return r}_verifyIntegers(...t){for(let e of t)if(e===1/0||isNaN(e)||e%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(let e of t)if(e&&(e===1/0||isNaN(e)||e%1!=0||e<0))throw new Error("This API only accepts positive integers")}}D.Terminal=l})(),B})()))});var si=Ht((bt,Wt)=>{(function(w,S){typeof bt=="object"&&typeof Wt=="object"?Wt.exports=S():typeof define=="function"&&define.amd?define([],S):typeof bt=="object"?bt.FitAddon=S():w.FitAddon=S()})(self,(()=>(()=>{"use strict";var w={};return(()=>{var S=w;Object.defineProperty(S,"__esModule",{value:!0}),S.FitAddon=void 0,S.FitAddon=class{activate(A){this._terminal=A}dispose(){}fit(){let A=this.proposeDimensions();if(!A||!this._terminal||isNaN(A.cols)||isNaN(A.rows))return;let B=this._terminal._core;this._terminal.rows===A.rows&&this._terminal.cols===A.cols||(B._renderService.clear(),this._terminal.resize(A.cols,A.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let A=this._terminal._core,B=A._renderService.dimensions;if(B.css.cell.width===0||B.css.cell.height===0)return;let D=this._terminal.options.scrollback===0?0:A.viewport.scrollBarWidth,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),c=Math.max(0,parseInt(r.getPropertyValue("width"))),u=window.getComputedStyle(this._terminal.element),n=o-(parseInt(u.getPropertyValue("padding-top"))+parseInt(u.getPropertyValue("padding-bottom"))),a=c-(parseInt(u.getPropertyValue("padding-right"))+parseInt(u.getPropertyValue("padding-left")))-D;return{cols:Math.max(2,Math.floor(a/B.css.cell.width)),rows:Math.max(1,Math.floor(n/B.css.cell.height))}}}})(),w})()))});var ni=Ht((St,$t)=>{(function(w,S){typeof St=="object"&&typeof $t=="object"?$t.exports=S():typeof define=="function"&&define.amd?define([],S):typeof St=="object"?St.SearchAddon=S():w.SearchAddon=S()})(self,(()=>(()=>{"use strict";var w={345:(D,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.runAndSubscribe=r.forwardEvent=r.EventEmitter=void 0,r.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===o)return void this._listeners.splice(c,1)}}})),this._event}fire(o,c){let u=[];for(let n=0;n<this._listeners.length;n++)u.push(this._listeners[n]);for(let n=0;n<u.length;n++)u[n].call(void 0,o,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(o,c){return o((u=>c.fire(u)))},r.runAndSubscribe=function(o,c){return c(void 0),o((u=>c(u)))}},859:(D,r)=>{function o(c){for(let u of c)u.dispose();c.length=0}Object.defineProperty(r,"__esModule",{value:!0}),r.getDisposeArrayDisposable=r.disposeArray=r.toDisposable=r.MutableDisposable=r.Disposable=void 0,r.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){let u=this._disposables.indexOf(c);u!==-1&&this._disposables.splice(u,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){this._isDisposed||c===this._value||(this._value?.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},r.toDisposable=function(c){return{dispose:c}},r.disposeArray=o,r.getDisposeArrayDisposable=function(c){return{dispose:()=>o(c)}}}},S={};function A(D){var r=S[D];if(r!==void 0)return r.exports;var o=S[D]={exports:{}};return w[D](o,o.exports,A),o.exports}var B={};return(()=>{var D=B;Object.defineProperty(D,"__esModule",{value:!0}),D.SearchAddon=void 0;let r=A(345),o=A(859),c=" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?";class u extends o.Disposable{constructor(a){super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new o.MutableDisposable),this._linesCacheTimeoutId=0,this._linesCacheDisposables=new o.MutableDisposable,this._onDidChangeResults=this.register(new r.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=a?.highlightLimit??1e3}activate(a){this._terminal=a,this.register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this.register(this._terminal.onResize((()=>this._updateMatches()))),this.register((0,o.toDisposable)((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout((()=>{let a=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(a,{...this._lastSearchOptions,incremental:!0,noScroll:!0})}),200))}clearDecorations(a){this._selectedDecoration.clear(),(0,o.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),a||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(a,h){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let _=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,h);this._lastSearchOptions=h,h?.decorations&&(this._cachedSearchTerm===void 0||a!==this._cachedSearchTerm||_)&&this._highlightAllMatches(a,h);let l=this._findNextAndSelect(a,h);return this._fireResults(h),this._cachedSearchTerm=a,l}_highlightAllMatches(a,h){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!a||a.length===0)return void this.clearDecorations();h=h||{},this.clearDecorations(!0);let _=[],l,i=this._find(a,0,0,h);for(;i&&(l?.row!==i.row||l?.col!==i.col)&&!(_.length>=this._highlightLimit);)l=i,_.push(l),i=this._find(a,l.col+l.term.length>=this._terminal.cols?l.row+1:l.row,l.col+l.term.length>=this._terminal.cols?0:l.col+1,h);for(let t of _){let e=this._createResultDecoration(t,h.decorations);e&&(this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}}))}}_find(a,h,_,l){if(!this._terminal||!a||a.length===0)return this._terminal?.clearSelection(),void this.clearDecorations();if(_>this._terminal.cols)throw new Error(`Invalid col: ${_} to search in terminal of ${this._terminal.cols} cols`);let i;this._initLinesCache();let t={startRow:h,startCol:_};if(i=this._findInLine(a,t,l),!i)for(let e=h+1;e<this._terminal.buffer.active.baseY+this._terminal.rows&&(t.startRow=e,t.startCol=0,i=this._findInLine(a,t,l),!i);e++);return i}_findNextAndSelect(a,h){if(!this._terminal||!a||a.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let _=this._terminal.getSelectionPosition();this._terminal.clearSelection();let l=0,i=0;_&&(this._cachedSearchTerm===a?(l=_.end.x,i=_.end.y):(l=_.start.x,i=_.start.y)),this._initLinesCache();let t={startRow:i,startCol:l},e=this._findInLine(a,t,h);if(!e)for(let s=i+1;s<this._terminal.buffer.active.baseY+this._terminal.rows&&(t.startRow=s,t.startCol=0,e=this._findInLine(a,t,h),!e);s++);if(!e&&i!==0)for(let s=0;s<i&&(t.startRow=s,t.startCol=0,e=this._findInLine(a,t,h),!e);s++);return!e&&_&&(t.startRow=_.start.y,t.startCol=0,e=this._findInLine(a,t,h)),this._selectResult(e,h?.decorations,h?.noScroll)}findPrevious(a,h){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let _=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,h);this._lastSearchOptions=h,h?.decorations&&(this._cachedSearchTerm===void 0||a!==this._cachedSearchTerm||_)&&this._highlightAllMatches(a,h);let l=this._findPreviousAndSelect(a,h);return this._fireResults(h),this._cachedSearchTerm=a,l}_didOptionsChange(a,h){return!!h&&(a.caseSensitive!==h.caseSensitive||a.regex!==h.regex||a.wholeWord!==h.wholeWord)}_fireResults(a){if(a?.decorations){let h=-1;if(this._selectedDecoration.value){let _=this._selectedDecoration.value.match;for(let l=0;l<this._highlightDecorations.length;l++){let i=this._highlightDecorations[l].match;if(i.row===_.row&&i.col===_.col&&i.size===_.size){h=l;break}}}this._onDidChangeResults.fire({resultIndex:h,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(a,h){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!this._terminal||!a||a.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let _=this._terminal.getSelectionPosition();this._terminal.clearSelection();let l=this._terminal.buffer.active.baseY+this._terminal.rows-1,i=this._terminal.cols,t=!0;this._initLinesCache();let e={startRow:l,startCol:i},s;if(_&&(e.startRow=l=_.start.y,e.startCol=i=_.start.x,this._cachedSearchTerm!==a&&(s=this._findInLine(a,e,h,!1),s||(e.startRow=l=_.end.y,e.startCol=i=_.end.x))),s||(s=this._findInLine(a,e,h,t)),!s){e.startCol=Math.max(e.startCol,this._terminal.cols);for(let d=l-1;d>=0&&(e.startRow=d,s=this._findInLine(a,e,h,t),!s);d--);}if(!s&&l!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let d=this._terminal.buffer.active.baseY+this._terminal.rows-1;d>=l&&(e.startRow=d,s=this._findInLine(a,e,h,t),!s);d--);return this._selectResult(s,h?.decorations,h?.noScroll)}_initLinesCache(){let a=this._terminal;this._linesCache||(this._linesCache=new Array(a.buffer.active.length),this._linesCacheDisposables.value=(0,o.getDisposeArrayDisposable)([a.onLineFeed((()=>this._destroyLinesCache())),a.onCursorMove((()=>this._destroyLinesCache())),a.onResize((()=>this._destroyLinesCache()))])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&(window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=0)}_isWholeWord(a,h,_){return(a===0||c.includes(h[a-1]))&&(a+_.length===h.length||c.includes(h[a+_.length]))}_findInLine(a,h,_={},l=!1){let i=this._terminal,t=h.startRow,e=h.startCol;if(i.buffer.active.getLine(t)?.isWrapped)return l?void(h.startCol+=i.cols):(h.startRow--,h.startCol+=i.cols,this._findInLine(a,h,_));let d=this._linesCache?.[t];d||(d=this._translateBufferLineToStringWithWrap(t,!0),this._linesCache&&(this._linesCache[t]=d));let[g,p]=d,v=this._bufferColsToStringOffset(t,e),f=_.caseSensitive?a:a.toLowerCase(),m=_.caseSensitive?g:g.toLowerCase(),E=-1;if(_.regex){let k=RegExp(f,"g"),x;if(l)for(;x=k.exec(m.slice(0,v));)E=k.lastIndex-x[0].length,a=x[0],k.lastIndex-=a.length-1;else x=k.exec(m.slice(v)),x&&x[0].length>0&&(E=v+(k.lastIndex-x[0].length),a=x[0])}else l?v-f.length>=0&&(E=m.lastIndexOf(f,v-f.length)):E=m.indexOf(f,v);if(E>=0){if(_.wholeWord&&!this._isWholeWord(E,m,a))return;let k=0;for(;k<p.length-1&&E>=p[k+1];)k++;let x=k;for(;x<p.length-1&&E+a.length>=p[x+1];)x++;let C=E-p[k],M=E+a.length-p[x],z=this._stringLengthToBufferSize(t+k,C);return{term:a,col:z,row:t+k,size:this._stringLengthToBufferSize(t+x,M)-z+i.cols*(x-k)}}}_stringLengthToBufferSize(a,h){let _=this._terminal.buffer.active.getLine(a);if(!_)return 0;for(let l=0;l<h;l++){let i=_.getCell(l);if(!i)break;let t=i.getChars();t.length>1&&(h-=t.length-1);let e=_.getCell(l+1);e&&e.getWidth()===0&&h++}return h}_bufferColsToStringOffset(a,h){let _=this._terminal,l=a,i=0,t=_.buffer.active.getLine(l);for(;h>0&&t;){for(let e=0;e<h&&e<_.cols;e++){let s=t.getCell(e);if(!s)break;s.getWidth()&&(i+=s.getCode()===0?1:s.getChars().length)}if(l++,t=_.buffer.active.getLine(l),t&&!t.isWrapped)break;h-=_.cols}return i}_translateBufferLineToStringWithWrap(a,h){let _=this._terminal,l=[],i=[0],t=_.buffer.active.getLine(a);for(;t;){let e=_.buffer.active.getLine(a+1),s=!!e&&e.isWrapped,d=t.translateToString(!s&&h);if(s&&e){let g=t.getCell(t.length-1);g&&g.getCode()===0&&g.getWidth()===1&&e.getCell(0)?.getWidth()===2&&(d=d.slice(0,-1))}if(l.push(d),!s)break;i.push(i[i.length-1]+d.length),a++,t=e}return[l.join(""),i]}_selectResult(a,h,_){let l=this._terminal;if(this._selectedDecoration.clear(),!a)return l.clearSelection(),!1;if(l.select(a.col,a.row,a.size),h){let i=l.registerMarker(-l.buffer.active.baseY-l.buffer.active.cursorY+a.row);if(i){let t=l.registerDecoration({marker:i,x:a.col,width:a.size,backgroundColor:h.activeMatchBackground,layer:"top",overviewRulerOptions:{color:h.activeMatchColorOverviewRuler}});if(t){let e=[];e.push(i),e.push(t.onRender((s=>this._applyStyles(s,h.activeMatchBorder,!0)))),e.push(t.onDispose((()=>(0,o.disposeArray)(e)))),this._selectedDecoration.value={decoration:t,match:a,dispose(){t.dispose()}}}}}if(!_&&(a.row>=l.buffer.active.viewportY+l.rows||a.row<l.buffer.active.viewportY)){let i=a.row-l.buffer.active.viewportY;i-=Math.floor(l.rows/2),l.scrollLines(i)}return!0}_applyStyles(a,h,_){a.classList.contains("xterm-find-result-decoration")||(a.classList.add("xterm-find-result-decoration"),h&&(a.style.outline=`1px solid ${h}`)),_&&a.classList.add("xterm-find-active-result-decoration")}_createResultDecoration(a,h){let _=this._terminal,l=_.registerMarker(-_.buffer.active.baseY-_.buffer.active.cursorY+a.row);if(!l)return;let i=_.registerDecoration({marker:l,x:a.col,width:a.size,backgroundColor:h.matchBackground,overviewRulerOptions:this._highlightedLines.has(l.line)?void 0:{color:h.matchOverviewRuler,position:"center"}});if(i){let t=[];t.push(l),t.push(i.onRender((e=>this._applyStyles(e,h.matchBorder,!1)))),t.push(i.onDispose((()=>(0,o.disposeArray)(t))))}return i}}D.SearchAddon=u})(),B})()))});var tr={};Ni(tr,{apply:()=>Qi,inject:()=>Yi});module.exports=Wi(tr);var ye=require("react");var Z=require("react");var de="zTerm";async function te(w,S,A={},B){let D=w.connection;if(!D?.rpc?.call)throw new Error("\u5F53\u524D DSH \u7F3A\u5C11 Connection RPC\uFF0C\u8BF7\u4F7F\u7528\u5DF2\u652F\u6301\u7684\u5BBF\u4E3B\u7248\u672C");let r=await D.rpc.call("/api",`zterm/${S}`,A,B);if(!r.ok)throw new Error(r.error?.message||`${de} \u8BF7\u6C42\u5931\u8D25`);return r.value}function gt(w,S,A="text/plain;charset=utf-8"){let B=URL.createObjectURL(new Blob([S],{type:A})),D=document.createElement("a");D.href=B,D.download=w,D.click(),URL.revokeObjectURL(B)}function vt(){return new Date().toISOString().replace(/[-:]/g,"").replace(/T/,"-").slice(0,15)}function ei(w,S=Date.now()){if(!w)return;let A=Date.parse(w);if(!Number.isFinite(A))return;let B=Math.floor((S-A)/1e3);if(!(B<2))return B<60?`\u5DF2 ${B} \u79D2`:`\u5DF2 ${Math.floor(B/60)} \u5206 ${B%60} \u79D2`}var Qt=0;function ti(w,S){let A=new Map(w);if(S.reset){A.clear();for(let r of S.snapshots??[])A.set(r.terminalId,{generation:r.generation,text:r.text,seq:S.cursor,epoch:++Qt,end:r.text.length})}let B=new Map,D=r=>({generation:r,seq:Number.NEGATIVE_INFINITY,base:"",parts:[],epoch:++Qt,end:0});for(let r of S.output??[]){let o=A.get(r.terminalId),c=B.get(r.terminalId);c?c.generation!==r.generation&&(c=D(r.generation),B.set(r.terminalId,c)):(c=o&&o.generation===r.generation?{generation:r.generation,seq:o.seq,base:o.text,parts:[],epoch:o.epoch,end:o.end}:D(r.generation),B.set(r.terminalId,c)),!(r.seq<=c.seq)&&(c.seq=r.seq,c.parts.push(r.text),c.end+=r.text.length)}for(let[r,o]of B)o.parts.length&&A.set(r,{generation:o.generation,text:`${o.base}${o.parts.join("")}`.slice(-5e5),seq:o.seq,epoch:o.epoch,end:o.end});for(let r of A.keys())S.workspace.terminals.some(o=>o.id===r)||A.delete(r);return A}var ue=require("react"),ui=Ft(ri(),1),fi=Ft(si(),1),_i=Ft(ni(),1);var Xe=require("react");function rt(w,S,A,B){try{let D=localStorage.getItem(w),r=D===null?S:Number(D);return Number.isFinite(r)?Math.max(A,Math.min(B,r)):S}catch{return S}}function st(w,S){try{localStorage.setItem(w,String(S))}catch{}}var Ge=12,Ct=8,yt=32,Ut="dsh-zterm.terminal-font-size",it=new Set,wt;function ai(w){return Number.isInteger(w)&&w>=Ct&&w<=yt}function jt(){try{let w=localStorage.getItem(Ut),S=w===null?Ge:Number(w);return ai(S)?S:Ge}catch{return wt??Ge}}function li(){return wt??=jt()}function ci(w){w!==li()&&(wt=w,it.forEach(S=>S()))}function hi(w){ai(w)&&(ci(w),st(Ut,w))}function oi(w){(w.key===Ut||w.key===null)&&ci(jt())}function $i(w){return!it.size&&typeof window<"u"&&(wt=jt(),window.addEventListener("storage",oi)),it.add(w),()=>{it.delete(w),!it.size&&typeof window<"u"&&window.removeEventListener("storage",oi)}}function xt(){return(0,Xe.useSyncExternalStore)($i,li,()=>Ge)}function Et(){let w=(0,Xe.useRef)(()=>{});return(0,Xe.useEffect)(()=>()=>w.current(),[]),(S,A)=>{S.preventDefault(),w.current();let B=()=>{window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",B),w.current=()=>{}};w.current=B,window.addEventListener("mousemove",A),window.addEventListener("mouseup",B,{once:!0})}}var He=require("react/jsx-runtime"),Ui=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.userAgentData?.platform||navigator.platform||"");function ji(w){return(/^[a-z]$/i.test(w.key)?w.key.toLowerCase()==="f":w.code==="KeyF")&&!w.altKey&&(Ui?w.metaKey&&!w.ctrlKey&&!w.shiftKey:w.ctrlKey&&w.shiftKey&&!w.metaKey)}var qi=/^(?:\x1b\[[?>]?[\d;]*[cnRt]|\x1b\[\??\d+;\d+\$y|\x1bP[01]\$r[^\x1b]*\x1b\\|\x1b\][\d;]+;rgb:[\da-fA-F/]+(?:\x1b\\|\x07))+$/,di={epoch:-1,end:0,text:""};function pi({ctx:w,sessionId:S,terminal:A,buffer:B,visible:D,onError:r}){let o=(0,ue.useRef)(null),c=(0,ue.useRef)(),u=(0,ue.useRef)(),n=(0,ue.useRef)(),a=(0,ue.useRef)(di),h=(0,ue.useRef)(A),_=(0,ue.useRef)(r),l=(0,ue.useRef)(Promise.resolve()),i=(0,ue.useRef)(()=>{}),t=(0,ue.useRef)(()=>{}),e=(0,ue.useRef)(()=>{}),s=(0,ue.useRef)(!1),[d,g]=(0,ue.useState)(""),p=xt(),v=(0,ue.useRef)(p),f=(0,ue.useRef)(B);v.current=p,f.current=B,h.current=A,_.current=r;let m=()=>{let k=c.current,x=f.current,C=s.current;if(s.current=!1,!k||!x||x.generation!==h.current.generation)return;let M=a.current;if(M.epoch===x.epoch&&M.end===x.end)return;let z=M.epoch===x.epoch?M.end-(x.end-x.text.length):-1;z>=0&&z<=x.text.length?e.current(x.text.slice(z),C):x.text.startsWith(M.text)?e.current(x.text.slice(M.text.length),C||!!M.text):(k.reset(),e.current(x.text,!0)),a.current={epoch:x.epoch,end:x.end,text:x.text}},E=()=>{if(c.current||!o.current)return;let k=o.current,x=new ui.Terminal({cursorBlink:!0,fontSize:v.current,fontFamily:"Menlo, Consolas, monospace",scrollback:5e3,allowProposedApi:!1,convertEol:!1,theme:{background:"#12161d",foreground:"#dce3ed",cursor:"#e4edf8",selectionBackground:"#334b66"}}),C=new fi.FitAddon,M=new _i.SearchAddon;x.loadAddon(C),x.loadAddon(M),x.open(k),c.current=x,n.current=C,u.current=M,a.current=di;let z=!1,j=0;e.current=(T,H)=>{if(T){if(!H){x.write(T);return}j++,x.write(T,()=>{j--})}};let U=x.onData(T=>{let H=h.current;H.state==="ready"&&(j>0&&qi.test(T)||(l.current=l.current.catch(()=>{}).then(async()=>{z||await te(w,"input",{sessionId:S,terminalId:H.id,generation:H.generation,data:T})}).catch(q=>{z||_.current(q.message)})))}),$;i.current=()=>{if(z||!o.current?.clientWidth)return;C.fit();let T=h.current;T.state==="ready"&&te(w,"resize",{sessionId:S,terminalId:T.id,generation:T.generation,cols:x.cols,rows:x.rows}).catch(H=>{z||_.current(H.message)})};let b=()=>{clearTimeout($),$=setTimeout(()=>i.current(),80)},L=new ResizeObserver(b);L.observe(k),b();let R=T=>{ji(T)&&(T.preventDefault(),T.stopPropagation(),document.getElementById(`zterm-find-${A.id}`)?.focus())};k.addEventListener("keydown",R,!0),t.current=()=>{z=!0,i.current=()=>{},e.current=()=>{},clearTimeout($),L.disconnect(),U.dispose(),k.removeEventListener("keydown",R,!0),x.dispose(),c.current=void 0}};return(0,ue.useLayoutEffect)(()=>()=>{t.current(),t.current=()=>{}},[w,S,A.id,A.generation]),(0,ue.useLayoutEffect)(()=>{D&&(E(),s.current=!0,m())},[D,w,S,A.id,A.generation]),(0,ue.useEffect)(()=>{D&&m()},[B,A.generation]),(0,ue.useLayoutEffect)(()=>{let k=c.current;!D||!k||k.options.fontSize===p||(k.options.fontSize=p,i.current())},[p,D]),(0,ue.useEffect)(()=>{D&&(i.current(),c.current?.focus())},[D,A.state,A.generation]),(0,He.jsxs)("div",{className:"zt-terminal-screen",style:{display:D?"flex":"none"},children:[(0,He.jsxs)("div",{className:"zt-terminal-search",children:[(0,He.jsx)("input",{id:`zterm-find-${A.id}`,"aria-label":"\u641C\u7D22\u7EC8\u7AEF\u8F93\u51FA",placeholder:"\u641C\u7D22\u7EC8\u7AEF\u8F93\u51FA",value:d,onChange:k=>{g(k.target.value),u.current?.findNext(k.target.value)},onKeyDown:k=>{k.key==="Enter"&&u.current?.findNext(d),k.key==="Escape"&&(g(""),c.current?.focus())}}),(0,He.jsx)("button",{title:"\u4E0A\u4E00\u4E2A\u5339\u914D",onClick:()=>u.current?.findPrevious(d),children:"\u2191"}),(0,He.jsx)("button",{title:"\u4E0B\u4E00\u4E2A\u5339\u914D",onClick:()=>u.current?.findNext(d),children:"\u2193"}),(0,He.jsx)("span",{children:"\u7EC8\u7AEF\u8F93\u5165\u76F4\u63A5\u64CD\u4F5C\u5F53\u524D\u673A\u5668"})]}),(0,He.jsx)("div",{className:"zt-terminal-canvas",ref:o})]})}var _e=require("react");var Ue={password:"\u5BC6\u7801",key:"\u79C1\u94A5\u5185\u5BB9","key-file":"\u79C1\u94A5\u6587\u4EF6"};var Ie=require("react");var nt=class{expanded;scroll=new Map;pages=new Map;pending=new Map;listeners=new Set;version=0;onChange;constructor(S=[]){this.expanded=new Set(S)}subscribe=S=>(this.listeners.add(S),()=>{this.listeners.delete(S)});snapshot=()=>this.version;changed(){this.version++,this.listeners.forEach(S=>S()),this.onChange?.()}setScroll(S,A){this.scroll.set(S,A),S==="tree"&&this.onChange?.()}restore(S){this.expanded.clear(),S.expanded.forEach(A=>this.expanded.add(A)),this.scroll.set("tree",S.scroll);for(let[A,B]of S.pages)this.pages.set(A,{...B,status:"ready",stale:!0})}export(){return{expanded:[...this.expanded],scroll:this.scroll.get("tree")??0,pages:[...this.pages].flatMap(([S,A])=>!S.startsWith("search:")&&A.data?[[S,{offset:A.offset,data:A.data}]]:[])}}page(S){return this.pages.get(S)}toggle(S){this.expanded.has(S)?this.expanded.delete(S):this.expanded.add(S),this.changed()}reveal(S){S.forEach(A=>this.expanded.add(A)),this.changed()}retain(S){for(let A of this.expanded)S.has(A)||this.expanded.delete(A)}seed(S,A){(this.pages.get(S)?.offset??0)===0&&(this.cancel(S),this.pages.set(S,{offset:0,status:"ready",data:A,updatedAt:Date.now()}),this.changed())}async load(S,A,B=this.pages.get(S)?.offset??0){this.pending.get(S)?.abort();let D=this.pages.get(S),r=D?.offset===B?D.data:void 0,o=new AbortController;this.pending.set(S,o),this.pages.set(S,{offset:B,status:r?"ready":"loading",data:r,refreshing:!0}),this.changed();try{let c=await A(B,o.signal);if(o.signal.aborted||this.pending.get(S)!==o||(B>0&&!c.items.length&&(B=0,c=await A(0,o.signal)),o.signal.aborted||this.pending.get(S)!==o))return;this.pages.set(S,{offset:B,status:"ready",data:c,updatedAt:Date.now()})}catch(c){if(o.signal.aborted||this.pending.get(S)!==o)return;this.pages.set(S,{offset:r?D.offset:B,status:r?"ready":"error",data:r,error:c instanceof Error?c.message:"\u8BFB\u53D6\u5931\u8D25"})}finally{this.pending.get(S)===o&&(this.pending.delete(S),this.changed())}}ensure(S,A,B=!1){let D=this.pages.get(S);!this.pending.has(S)&&(!D||D.status==="idle"||D.stale||B&&Date.now()-(D.updatedAt??0)>=3e3)&&this.load(S,A)}cancel(S){let A=this.pending.get(S);if(!A)return;A.abort(),this.pending.delete(S);let B=this.pages.get(S);this.pages.set(S,B.data?{...B,status:"ready",refreshing:!1,stale:!0}:{offset:B.offset,status:"idle"}),this.changed()}forget(S){this.cancel(S),this.pages.delete(S)&&this.changed()}invalidate(S=!1){this.pending.forEach(A=>A.abort()),this.pending.clear();for(let[A,B]of this.pages)this.pages.set(A,!S&&B.data?{...B,stale:!0,refreshing:!1,error:void 0}:{offset:B.offset,status:"idle"});this.changed()}dispose(){this.pending.forEach(S=>S.abort()),this.pending.clear(),this.listeners.clear()}};function kt(w,S,A,B,D=500){let r=w.slice().reverse().map(n=>({node:n,depth:0,content:!1})),o=[],c=new Set,u=!1;for(;r.length;){let n=r.pop(),a=S(n.node);if(n.content){o.push(n);continue}if(!c.has(a)){if(c.size>=D){u=!0;continue}if(c.add(a),o.push(n),!!B.has(a)){r.push({...n,content:!0});for(let h of A(n.node).slice().reverse())r.push({node:h,depth:n.depth+1,content:!1})}}}return{rows:o,truncated:u}}function Dt(w,S){let A=new Set;return w.filter(B=>{let D=S(B);return A.has(D)?!1:(A.add(D),!0)})}var Be=require("react"),be=require("react/jsx-runtime"),ot=w=>({paddingLeft:`min(${Math.min(8,w)*12}px, 25%)`});function at(w){return(0,Be.useSyncExternalStore)(w.subscribe,w.snapshot,w.snapshot)}function Ye(w,S,A,B=!0,D=!1){let r=at(w),o=(0,Be.useRef)(A);return o.current=A,(0,Be.useEffect)(()=>{B&&w.ensure(S,(c,u)=>o.current(c,u),!0)},[w,S,B]),(0,Be.useEffect)(()=>{B&&w.ensure(S,(c,u)=>o.current(c,u))},[w,S,B,r]),(0,Be.useEffect)(()=>()=>{D?w.forget(S):w.cancel(S)},[w,S,D]),{page:w.page(S),load:c=>{w.load(S,(u,n)=>o.current(u,n),c)}}}function Lt({state:w,view:S,label:A,children:B}){let D=(0,Be.useRef)(null);return(0,Be.useLayoutEffect)(()=>{D.current&&(D.current.scrollTop=w.scroll.get(S)??0)},[w,S]),(0,be.jsx)("nav",{ref:D,className:"zt-asset-tree","aria-label":A,onScroll:r=>w.setScroll(S,r.currentTarget.scrollTop),children:B})}function lt({label:w,expanded:S,depth:A,selected:B,onToggle:D,actions:r}){return(0,be.jsxs)("div",{className:`zt-directory-row${B?" active":""}`,style:ot(A),children:[(0,be.jsxs)("button",{className:"zt-directory-name","aria-expanded":S,"aria-label":`${S?"\u6536\u8D77":"\u5C55\u5F00"}\u6587\u4EF6\u5939 ${w}`,title:w,onClick:D,children:[(0,be.jsx)("span",{className:"zt-directory-arrow","aria-hidden":"true",children:S?"\u25BE":"\u25B8"}),(0,be.jsxs)("span",{className:"zt-directory-label",children:["\u25B1 ",w]})]}),r]})}function Ze({page:w,label:S,retry:A}){return w?.data?w.error?(0,be.jsxs)("div",{className:"zt-tree-message",role:"status",children:[(0,be.jsxs)("span",{title:w.error,children:[S,"\u66F4\u65B0\u5931\u8D25\uFF0C\u5F53\u524D\u663E\u793A\u7F13\u5B58"]}),(0,be.jsx)("button",{onClick:A,children:"\u91CD\u8BD5"})]}):null:!w||w.status==="idle"||w.status==="loading"?(0,be.jsxs)("p",{className:"zt-tree-message",role:"status",children:["\u6B63\u5728\u52A0\u8F7D",S,"\u2026"]}):w.status==="error"?(0,be.jsxs)("div",{className:"zt-tree-message zt-error",role:"alert",children:[(0,be.jsxs)("span",{children:[S,"\uFF1A",w.error]}),(0,be.jsx)("button",{onClick:A,children:"\u91CD\u8BD5"})]}):null}function Rt({page:w,size:S,label:A,load:B}){return w?.status!=="ready"||!w.offset&&!w.data?.hasMore?null:(0,be.jsxs)("div",{className:"zt-pagination","aria-label":`${A}\u5206\u9875`,children:[(0,be.jsxs)("span",{children:[w.data?.total??0," \u53F0 \xB7 \u7B2C ",Math.floor(w.offset/S)+1," \u9875"]}),(0,be.jsx)("button",{"aria-label":`${A}\u4E0A\u4E00\u9875`,disabled:!w.offset,onClick:()=>B(Math.max(0,w.offset-S)),children:"\u2039"}),(0,be.jsx)("button",{"aria-label":`${A}\u4E0B\u4E00\u9875`,disabled:!w.data?.hasMore,onClick:()=>B(w.offset+S),children:"\u203A"})]})}var se=require("react/jsx-runtime");function Tt(w){let S=new Map;for(let r of w){let o=r.parentId??"";S.set(o,[...S.get(o)??[],r])}let A=(S.get("")??[]).slice().reverse().map(r=>({...r,depth:0})),B=[],D=new Set;for(;A.length;){let r=A.pop();if(!D.has(r.id)){D.add(r.id),B.push(r);for(let o of(S.get(r.id)??[]).slice().reverse())A.push({...o,depth:r.depth+1})}}return B}function Ki({folder:w,busy:S,onEdit:A,onDelete:B}){let D=(0,Ie.useRef)(null),r=(0,Ie.useRef)(null),o=(0,Ie.useId)(),[c,u]=(0,Ie.useState)(!1);(0,Ie.useEffect)(()=>{let h=D.current;h.setAttribute("popover","auto"),r.current.setAttribute("popovertarget",o);let _=()=>{let l=h.matches(":popover-open");if(u(l),!l)return;let i=r.current.getBoundingClientRect();h.style.left=`${Math.max(8,Math.min(i.right-h.offsetWidth,window.innerWidth-h.offsetWidth-8))}px`,h.style.top=`${Math.max(8,i.bottom+h.offsetHeight+4<=window.innerHeight-8?i.bottom+4:i.top-h.offsetHeight-4)}px`,h.querySelector("button")?.focus({preventScroll:!0})};return h.addEventListener("toggle",_),()=>h.removeEventListener("toggle",_)},[o]),(0,Ie.useEffect)(()=>{if(!c)return;let h=()=>D.current?.hidePopover();return window.addEventListener("resize",h),document.addEventListener("scroll",h,!0),()=>{window.removeEventListener("resize",h),document.removeEventListener("scroll",h,!0)}},[c]);let n=h=>{D.current?.hidePopover(),h(w)},a=h=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(h.key))return;h.preventDefault();let _=[...h.currentTarget.querySelectorAll("button")],l=_.indexOf(document.activeElement),i=h.key==="Home"?0:h.key==="End"?_.length-1:(l+(h.key==="ArrowUp"?-1:1)+_.length)%_.length;_[i]?.focus()};return(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)("button",{ref:r,disabled:S,className:"zt-folder-action","aria-label":`\u6587\u4EF6\u5939\u64CD\u4F5C ${w.label}`,title:"\u6587\u4EF6\u5939\u64CD\u4F5C","aria-haspopup":"menu","aria-controls":o,"aria-expanded":c,children:"\u22EF"}),(0,se.jsxs)("div",{ref:D,id:o,className:"zt-folder-menu",role:"menu","aria-label":`\u6587\u4EF6\u5939\u64CD\u4F5C ${w.label}`,onKeyDown:a,children:[(0,se.jsx)("button",{role:"menuitem",disabled:S,onClick:()=>n(A),children:"\u66F4\u540D"}),(0,se.jsx)("button",{role:"menuitem",disabled:S,onClick:()=>n(B),children:"\u5220\u9664"})]})]})}function gi({props:w,folder:S,depth:A,hasChildren:B=!1}){let{ctx:D,state:r,query:o,busy:c,onConnect:u,onHostEdit:n,onHostDelete:a}=w,h=S?`hosts:${S.id}`:`search:${o}`,_=S?.label??"\u641C\u7D22\u7ED3\u679C",{page:l,load:i}=Ye(r,h,async(t,e)=>{let s=await te(D,"catalog",{offset:t,query:S?void 0:o,folderId:S?S.id||"root":void 0},e);return{items:s.hosts,total:s.total,hasMore:t+200<s.total}},!0,!S);return(0,se.jsxs)("div",{className:"zt-tree-content",style:ot(A),"data-host-folder":S?.id??"search",children:[(0,se.jsx)(Ze,{page:l,label:_,retry:()=>i()}),l?.status==="ready"&&(0,se.jsxs)(se.Fragment,{children:[l.data?.items.map(t=>(0,se.jsxs)("div",{className:"zt-host-row",children:[(0,se.jsxs)("button",{className:"zt-host-connect",disabled:c,onClick:()=>u(t),title:`\u8FDE\u63A5 ${t.username}@${t.host}:${t.port}`,children:[(0,se.jsx)("span",{className:"zt-host-glyph",children:"\u25A4"}),(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{children:t.label}),(0,se.jsxs)("small",{children:[t.username,"@",t.host]})]})]}),(0,se.jsx)("button",{disabled:c,title:"\u7F16\u8F91\u4E3B\u673A","aria-label":`\u7F16\u8F91\u4E3B\u673A ${t.label}`,onClick:()=>n(t),children:"\u22EF"}),(0,se.jsx)("button",{disabled:c,title:"\u79FB\u9664\u4E3B\u673A\u914D\u7F6E","aria-label":`\u79FB\u9664\u4E3B\u673A ${t.label}`,onClick:()=>a(t),children:"\xD7"})]},t.id)),!l.data?.items.length&&!B&&(0,se.jsx)("p",{className:"zt-tree-message",children:S?"\u6B64\u76EE\u5F55\u4E3A\u7A7A":"\u6CA1\u6709\u5339\u914D\u7684\u4E3B\u673A"})]}),(0,se.jsx)(Rt,{page:l,size:200,label:_,load:i})]})}function vi(w){let{state:S,folders:A,query:B,selected:D,onSelect:r,onEdit:o,onDelete:c}=w;at(S);let u=(0,Ie.useMemo)(()=>{let a=new Map;for(let h of A){let _=h.parentId??"";a.has(_)||a.set(_,[]),a.get(_).push(h)}return a},[A]),{rows:n}=kt([{id:"",label:"\u6839\u76EE\u5F55"}],a=>a.id,a=>u.get(a.id)??[],S.expanded,Number.MAX_SAFE_INTEGER);return(0,se.jsx)(Lt,{state:S,view:B?`search:${B}`:"tree",label:B?"\u4E3B\u673A\u641C\u7D22\u7ED3\u679C":"\u4E3B\u673A\u6587\u4EF6\u5939",children:B?(0,se.jsx)(gi,{props:w,depth:0},`search:${B}`):n.map(({node:a,depth:h,content:_})=>_?(0,se.jsx)(gi,{props:w,folder:a,depth:h+1,hasChildren:!!u.get(a.id)?.length},`content:${a.id}`):(0,se.jsx)(lt,{label:a.label,depth:h,selected:D===a.id,expanded:S.expanded.has(a.id),onToggle:()=>{r(a.id),S.toggle(a.id)},actions:a.id?(0,se.jsx)(Ki,{folder:a,busy:w.busy,onEdit:o,onDelete:c}):void 0},`directory:${a.id}`))})}var W=require("react/jsx-runtime");function je({title:w,children:S,onClose:A}){let B=(0,_e.useRef)(null),D=(0,_e.useRef)(A);return D.current=A,(0,_e.useEffect)(()=>{let r=document.activeElement,o=B.current;(o?.querySelector("input,select,textarea")??o?.querySelector("button")??o)?.focus();let c=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),D.current();return}if(u.key!=="Tab")return;let n=[...o?.querySelectorAll('button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex="0"]')??[]].filter(_=>_.offsetParent!==null),a=n[0],h=n.at(-1);a?u.shiftKey&&(document.activeElement===a||document.activeElement===o)?(u.preventDefault(),h?.focus()):!u.shiftKey&&document.activeElement===h&&(u.preventDefault(),a.focus()):(u.preventDefault(),o?.focus())};return o?.addEventListener("keydown",c),()=>{o?.removeEventListener("keydown",c),r?.isConnected&&r.focus()}},[]),(0,W.jsx)("div",{className:"zt-modal-shade",onMouseDown:r=>{r.target===r.currentTarget&&A()},children:(0,W.jsxs)("section",{ref:B,tabIndex:-1,className:"zt-modal",role:"dialog","aria-modal":"true","aria-label":w,children:[(0,W.jsxs)("header",{children:[(0,W.jsx)("strong",{children:w}),(0,W.jsx)("button",{"aria-label":"\u5173\u95ED\u5BF9\u8BDD\u6846",onClick:A,children:"\xD7"})]}),S]})})}function Se({title:w,children:S}){return(0,W.jsxs)("label",{className:"zt-field",children:[(0,W.jsx)("span",{children:w}),S]})}function mi({ctx:w,host:S,defaultFolderId:A="",folders:B,credentials:D=[],defaultCredentialId:r,revision:o,onClose:c,onSaved:u}){let[n,a]=(0,_e.useState)({label:S?.label??"",host:S?.host??"",port:String(S?.port??22),username:S?.username??"",authType:S?.authType??"key-file",privateKeyPath:S?.privateKeyPath??"",folderId:S?S.folderId??"":A}),[h,_]=(0,_e.useState)(""),[l,i]=(0,_e.useState)(""),[t,e]=(0,_e.useState)(!1),[s,d]=(0,_e.useState)(""),[g,p]=(0,_e.useState)(!1),[v,f]=(0,_e.useState)(S?.credentialId||!S&&D.length?"saved":S?.authType??"key-file"),[m,E]=(0,_e.useState)(S?.credentialId||r||D[0]?.id||""),k=S&&!S.credentialId&&S.authType===v,x=(C,M)=>a(z=>({...z,[C]:M}));return(0,W.jsx)(je,{title:S?"\u7F16\u8F91\u8FDC\u7A0B\u4E3B\u673A":"\u6DFB\u52A0\u8FDC\u7A0B\u4E3B\u673A",onClose:c,children:(0,W.jsxs)("form",{onSubmit:C=>{C.preventDefault(),p(!0),d(""),te(w,"host/save",{host:{...S,...n,credentialId:v==="saved"?m:void 0,folderId:n.folderId||void 0,port:Number(n.port),kind:"ssh"},secret:v==="saved"?"":h,passphrase:v==="saved"?"":l,clearPassphrase:t,revision:o}).then(()=>{_(""),i(""),u(n.folderId),c()}).catch(M=>d(M.message)).finally(()=>p(!1))},children:[(0,W.jsx)(Se,{title:"\u540D\u79F0",children:(0,W.jsx)("input",{required:!0,value:n.label,onChange:C=>x("label",C.target.value)})}),(0,W.jsxs)("div",{className:"zt-form-row",children:[(0,W.jsx)(Se,{title:"\u4E3B\u673A\u5730\u5740",children:(0,W.jsx)("input",{required:!0,value:n.host,placeholder:"\u4E3B\u673A\u540D\u6216 IP",onChange:C=>x("host",C.target.value)})}),(0,W.jsx)(Se,{title:"\u7AEF\u53E3",children:(0,W.jsx)("input",{type:"number",required:!0,min:"1",max:"65535",value:n.port,onChange:C=>x("port",C.target.value)})})]}),(0,W.jsx)(Se,{title:"\u767B\u5F55\u8D26\u53F7",children:(0,W.jsx)("input",{required:!0,value:n.username,onChange:C=>x("username",C.target.value)})}),(0,W.jsx)(Se,{title:"\u6587\u4EF6\u5939",children:(0,W.jsxs)("select",{value:n.folderId,onChange:C=>x("folderId",C.target.value),children:[(0,W.jsx)("option",{value:"",children:"\u6839\u76EE\u5F55"}),Tt(B).map(C=>(0,W.jsxs)("option",{value:C.id,children:["\u3000".repeat(Math.min(8,C.depth)),C.label]},C.id))]})}),(0,W.jsx)(Se,{title:"\u8BA4\u8BC1\u65B9\u5F0F",children:(0,W.jsxs)("select",{value:v,onChange:C=>{f(C.target.value),C.target.value!=="saved"&&x("authType",C.target.value),_(""),i(""),e(!1)},children:[(0,W.jsx)("option",{value:"saved",children:"\u9009\u62E9\u5DF2\u4FDD\u5B58\u51ED\u8BC1"}),(0,W.jsx)("option",{value:"password",children:"\u5BC6\u7801"}),(0,W.jsx)("option",{value:"key",children:"\u79C1\u94A5\u5185\u5BB9"}),(0,W.jsx)("option",{value:"key-file",children:"\u79C1\u94A5\u6587\u4EF6"})]})}),v==="saved"&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Se,{title:"\u767B\u5F55\u51ED\u8BC1",children:(0,W.jsxs)("select",{required:!0,value:m,onChange:C=>E(C.target.value),children:[(0,W.jsx)("option",{value:"",children:"\u8BF7\u9009\u62E9\u51ED\u8BC1"}),D.map(C=>(0,W.jsxs)("option",{value:C.id,children:[C.label," \xB7 ",Ue[C.authType]]},C.id))]})}),(0,W.jsx)("p",{className:"zt-hint",children:"\u51ED\u8BC1\u5728\u300C\u8BBE\u7F6E \u2192 zTerm \u2192 \u7BA1\u7406\u51ED\u8BC1\u300D\u4E2D\u4FDD\u5B58\uFF0C\u6B64\u5904\u65E0\u9700\u518D\u586B\u5185\u5BB9\u6216\u8DEF\u5F84\u3002"})]}),["password","key"].includes(v)&&(0,W.jsx)(Se,{title:n.authType==="key"?"\u79C1\u94A5\u5185\u5BB9":"\u5BC6\u7801",children:n.authType==="key"?(0,W.jsx)("textarea",{rows:5,value:h,placeholder:k?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u79C1\u94A5":"\u7C98\u8D34\u79C1\u94A5\u5185\u5BB9",onChange:C=>_(C.target.value),spellCheck:!1,required:!k}):(0,W.jsx)("input",{type:"password",value:h,autoComplete:"new-password",placeholder:k?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u5BC6\u7801":"\u8F93\u5165\u5BC6\u7801",onChange:C=>_(C.target.value),required:!k})}),v==="key-file"&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Se,{title:"\u79C1\u94A5\u6587\u4EF6\u8DEF\u5F84",children:(0,W.jsx)("input",{value:n.privateKeyPath,placeholder:"\u7559\u7A7A\u4F7F\u7528\u9ED8\u8BA4 SSH \u79C1\u94A5\u6587\u4EF6",onChange:C=>x("privateKeyPath",C.target.value)})}),(0,W.jsx)("p",{className:"zt-hint",children:"\u586B\u5199 DSH \u5BBF\u4E3B\u4E0A\u7684\u7EDD\u5BF9\u8DEF\u5F84\u6216 ~/ \u8DEF\u5F84\u3002DSH \u90E8\u7F72\u5728\u8FDC\u7AEF\u65F6\uFF0C\u586B\u5199\u8FDC\u7AEF\u7684\u6587\u4EF6\u8DEF\u5F84\u3002"})]}),["key","key-file"].includes(v)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Se,{title:"\u79C1\u94A5\u53E3\u4EE4\uFF08\u53EF\u9009\uFF09",children:(0,W.jsx)("input",{type:"password",disabled:t,value:l,placeholder:"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u53E3\u4EE4",onChange:C=>i(C.target.value)})}),S?.passphraseRef&&(0,W.jsxs)("label",{className:"zt-check",children:[(0,W.jsx)("input",{type:"checkbox",checked:t,onChange:C=>e(C.target.checked)}),"\u79FB\u9664\u6B64\u4E3B\u673A\u7684\u79C1\u94A5\u53E3\u4EE4\u5F15\u7528"]})]}),(0,W.jsx)("p",{className:"zt-hint",children:"\u5BC6\u7801\u3001\u79C1\u94A5\u5185\u5BB9\u548C\u53E3\u4EE4\u4FDD\u5B58\u5728 DSH \u51ED\u636E\u5E93\uFF1B\u79C1\u94A5\u6587\u4EF6\u7531\u5BBF\u4E3B\u8BFB\u53D6\u3002\u6240\u6709\u65B0\u8FDE\u63A5\u9ED8\u8BA4\u8BFB\u6A21\u5F0F\u3002"}),s&&(0,W.jsx)("p",{className:"zt-error",role:"alert",children:s}),(0,W.jsxs)("footer",{children:[(0,W.jsx)("button",{type:"button",onClick:c,children:"\u53D6\u6D88"}),(0,W.jsx)("button",{className:"zt-primary",disabled:g,children:g?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58\u4E3B\u673A"})]})]})})}function bi({ctx:w,profile:S,revision:A,onClose:B,onSaved:D}){let[r,o]=(0,_e.useState)({label:S?.label??"",baseUrl:S?.baseUrl??"",authMode:S?.authMode??"access_key",username:S?.username??"",verifyTls:S?.verifyTls??!0}),[c,u]=(0,_e.useState)(""),[n,a]=(0,_e.useState)(""),[h,_]=(0,_e.useState)(""),[l,i]=(0,_e.useState)(!1);return(0,W.jsx)(je,{title:S?"\u7F16\u8F91 JumpServer":"\u6DFB\u52A0 JumpServer",onClose:B,children:(0,W.jsxs)("form",{onSubmit:t=>{t.preventDefault(),i(!0),_(""),te(w,"jump/save",{profile:{...S,...r},secret:c,accessKeyId:n,revision:A}).then(()=>{u(""),a(""),D(),B()}).catch(e=>_(e.message)).finally(()=>i(!1))},children:[(0,W.jsx)(Se,{title:"\u540D\u79F0",children:(0,W.jsx)("input",{required:!0,value:r.label,onChange:t=>o({...r,label:t.target.value})})}),(0,W.jsx)(Se,{title:"\u670D\u52A1\u5730\u5740",children:(0,W.jsx)("input",{required:!0,type:"url",value:r.baseUrl,placeholder:"https://jump.example.com",onChange:t=>o({...r,baseUrl:t.target.value})})}),(0,W.jsx)(Se,{title:"\u8BA4\u8BC1\u65B9\u5F0F",children:(0,W.jsxs)("select",{value:r.authMode,onChange:t=>o({...r,authMode:t.target.value}),children:[(0,W.jsx)("option",{value:"access_key",children:"Access Key"}),(0,W.jsx)("option",{value:"token",children:"Token"}),(0,W.jsx)("option",{value:"password",children:"\u8D26\u53F7\u5BC6\u7801"})]})}),r.authMode==="access_key"&&(0,W.jsx)(Se,{title:"Access Key ID",children:(0,W.jsx)("input",{type:"password",value:n,placeholder:S?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u503C":"",onChange:t=>a(t.target.value)})}),r.authMode==="password"&&(0,W.jsx)(Se,{title:"\u8D26\u53F7",children:(0,W.jsx)("input",{required:!0,value:r.username,onChange:t=>o({...r,username:t.target.value})})}),(0,W.jsx)(Se,{title:r.authMode==="access_key"?"Access Key Secret":r.authMode==="token"?"Token":"\u5BC6\u7801",children:(0,W.jsx)("input",{type:"password",value:c,placeholder:S?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u503C":"",onChange:t=>u(t.target.value)})}),(0,W.jsxs)("label",{className:"zt-check",children:[(0,W.jsx)("input",{type:"checkbox",checked:r.verifyTls,onChange:t=>o({...r,verifyTls:t.target.checked})}),"\u9A8C\u8BC1 TLS \u8BC1\u4E66"]}),(0,W.jsx)("p",{className:"zt-hint",children:"\u8FDE\u63A5\u4F7F\u7528\u8D44\u4EA7\u4E0E\u8D26\u53F7\u7684\u7A33\u5B9A ID\uFF0C\u4EE4\u724C\u4EC5\u5728\u5BBF\u4E3B\u5185\u90E8\u5904\u7406\u3002"}),h&&(0,W.jsx)("p",{className:"zt-error",role:"alert",children:h}),(0,W.jsxs)("footer",{children:[(0,W.jsx)("button",{type:"button",onClick:B,children:"\u53D6\u6D88"}),(0,W.jsx)("button",{className:"zt-primary",disabled:l,children:l?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58\u5B9E\u4F8B"})]})]})})}function Si({ctx:w,folder:S,defaultParentId:A="",folders:B,revision:D,onClose:r,onSaved:o}){let[c,u]=(0,_e.useState)(S?.label??""),[n,a]=(0,_e.useState)(S?S.parentId??"":A),[h,_]=(0,_e.useState)(""),[l,i]=(0,_e.useState)(!1),t=new Set;if(S){t.add(S.id);for(let e of Tt(B))e.parentId&&t.has(e.parentId)&&t.add(e.id)}return(0,W.jsx)(je,{title:S?"\u7F16\u8F91\u4E3B\u673A\u6587\u4EF6\u5939":"\u65B0\u5EFA\u4E3B\u673A\u6587\u4EF6\u5939",onClose:r,children:(0,W.jsxs)("form",{onSubmit:e=>{e.preventDefault(),i(!0),te(w,"folder/save",{folder:{id:S?.id,label:c,parentId:n||void 0},revision:D}).then(()=>{o(n),r()}).catch(s=>_(s.message)).finally(()=>i(!1))},children:[(0,W.jsx)(Se,{title:"\u540D\u79F0",children:(0,W.jsx)("input",{required:!0,value:c,onChange:e=>u(e.target.value)})}),(0,W.jsx)(Se,{title:"\u7236\u6587\u4EF6\u5939",children:(0,W.jsxs)("select",{value:n,onChange:e=>a(e.target.value),children:[(0,W.jsx)("option",{value:"",children:"\u6839\u76EE\u5F55"}),Tt(B).filter(e=>!t.has(e.id)).map(e=>(0,W.jsxs)("option",{value:e.id,children:["\u3000".repeat(Math.min(8,e.depth)),e.label]},e.id))]})}),h&&(0,W.jsx)("p",{className:"zt-error",role:"alert",children:h}),(0,W.jsxs)("footer",{children:[(0,W.jsx)("button",{type:"button",onClick:r,children:"\u53D6\u6D88"}),(0,W.jsx)("button",{disabled:l,className:"zt-primary",children:l?"\u4FDD\u5B58\u4E2D\u2026":S?"\u4FDD\u5B58":"\u521B\u5EFA"})]})]})})}var ce=require("react/jsx-runtime"),ct={nodeId:"",key:"",name:"\u5168\u90E8\u8D44\u4EA7",hasChildren:!1,assetCount:0};function qt({props:w,node:S,depth:A}){let{ctx:B,instanceId:D,state:r,query:o,onChoose:c}=w,u=Ye(r,`children:${S?.nodeId}`,async(_,l)=>{let i=await te(B,"jump/query",{instanceId:D,operation:"nodes",parentKey:S.key||S.nodeId},l);return{items:Dt(i.nodes??[],t=>t.nodeId),total:i.nodes?.length??0,hasMore:!1,truncated:i.truncated}},!!S?.hasChildren),{page:n,load:a}=Ye(r,S?`assets:${S.nodeId}`:`search:${o}`,async(_,l)=>{let i=await te(B,"jump/query",{instanceId:D,operation:"assets",nodeId:S?.nodeId||void 0,query:S?void 0:o,offset:_,limit:100},l);return{items:Dt(i.assets??[],t=>t.assetId),total:i.total,hasMore:i.hasMore}},!0,!S),h=S?.name??"\u641C\u7D22\u7ED3\u679C";return(0,ce.jsxs)("div",{className:"zt-tree-content",style:ot(A),"data-asset-node":S?.nodeId??"search",children:[S?.hasChildren&&(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(Ze,{page:u.page,label:`${h}\u5B50\u76EE\u5F55`,retry:()=>u.load()}),u.page?.data?.truncated&&(0,ce.jsx)("p",{className:"zt-tree-message",children:"\u5B50\u76EE\u5F55\u8D85\u8FC7\u8BFB\u53D6\u4E0A\u9650\uFF0C\u53EF\u901A\u8FC7\u641C\u7D22\u67E5\u627E\u8D44\u4EA7\u3002"})]}),(0,ce.jsx)(Ze,{page:n,label:h,retry:()=>a()}),n?.status==="ready"&&(0,ce.jsxs)(ce.Fragment,{children:[n.data?.items.map(_=>(0,ce.jsxs)("button",{className:"zt-asset-row",onClick:()=>c(_),title:`${_.name} \xB7 ${_.address}`,children:[(0,ce.jsxs)("strong",{children:["\u25A4 ",_.name]}),(0,ce.jsxs)("small",{children:[_.address," \xB7 ",_.platform]})]},_.assetId)),!n.data?.items.length&&(!S?.hasChildren||u.page?.status==="ready"&&!u.page.data?.items.length)&&(0,ce.jsx)("p",{className:"zt-tree-message",children:S?"\u6B64\u76EE\u5F55\u4E3A\u7A7A":"\u6CA1\u6709\u5339\u914D\u7684\u8D44\u4EA7"})]}),(0,ce.jsx)(Rt,{page:n,size:100,label:h,load:a})]})}function Ci(w){let{ctx:S,instanceId:A,state:B,query:D}=w;at(B);let{page:r,load:o}=Ye(B,"nodes",async(n,a)=>{let h=await te(S,"jump/query",{instanceId:A,operation:"nodes"},a);return{items:Dt(h.nodes??[],_=>_.nodeId),total:h.nodes?.length??0,hasMore:!1,truncated:h.truncated}},!D),{rows:c,truncated:u}=kt(r?.data?.items??[],n=>n.nodeId,n=>n.hasChildren?B.page(`children:${n.nodeId}`)?.data?.items??[]:[],B.expanded);return(0,ce.jsx)(Lt,{state:B,view:D?`search:${D}`:"tree",label:D?"JumpServer \u641C\u7D22\u7ED3\u679C":"JumpServer \u8D44\u4EA7\u76EE\u5F55",children:D?(0,ce.jsx)(qt,{props:w,depth:0},`search:${D}`):(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(Ze,{page:r,label:"\u8D44\u4EA7\u76EE\u5F55",retry:()=>o()}),c.map(({node:n,depth:a,content:h})=>h?(0,ce.jsx)(qt,{props:w,node:n,depth:a+1},`content:${n.nodeId}`):(0,ce.jsx)(lt,{label:n.name,depth:a,expanded:B.expanded.has(n.nodeId),onToggle:()=>B.toggle(n.nodeId)},`directory:${n.nodeId}`)),(u||r?.data?.truncated)&&(0,ce.jsx)("p",{className:"zt-tree-message",children:"\u76EE\u5F55\u663E\u793A\u5DF2\u8FBE 500 \u9879\uFF0C\u8BF7\u6536\u8D77\u90E8\u5206\u76EE\u5F55\u6216\u641C\u7D22\u8D44\u4EA7\u3002"}),(0,ce.jsx)(lt,{label:ct.name,depth:0,expanded:B.expanded.has(ct.nodeId),onToggle:()=>B.toggle(ct.nodeId)}),B.expanded.has(ct.nodeId)&&(0,ce.jsx)(qt,{props:w,node:ct,depth:1})]})})}var yi="dsh-zterm.asset-tree-cache.v1:",Vi=1440*60*1e3,Kt=6e5,xi=64,Qe=w=>!!(w&&typeof w=="object"&&!Array.isArray(w)),Ce=w=>typeof w=="string"&&w.length<=4096,ht=w=>Number.isFinite(w)&&w>=0,It=w=>w==="nodes"?2:typeof w=="string"&&w.startsWith("children:")?1:0;function et(w,S,A=[],B=[]){if(!Qe(w))return;let D={};for(let r of S)Ce(w[r])&&(D[r]=w[r]);for(let r of A)ht(w[r])&&(D[r]=w[r]);for(let r of B)typeof w[r]=="boolean"&&(D[r]=w[r]);return D}function Vt(w,S,A){return Array.isArray(w)?w.slice(0,S).map(A).filter(Boolean):[]}function wi(w){if(!(!Qe(w)||!Array.isArray(w.folders)||!Array.isArray(w.jumpservers)))return{...et(w,[],["revision"],["temporarilyDisabled"]),folders:Vt(w.folders,2e3,S=>Ce(S?.id)&&Ce(S?.label)?et(S,["id","label","parentId"]):void 0),jumpservers:Vt(w.jumpservers,32,S=>Ce(S?.id)&&Ce(S?.label)?et(S,["id","label"]):void 0)}}function At(w,S){if(!Qe(w)||!Array.isArray(w.expanded)||!Array.isArray(w.pages))return;let A=[];for(let B of w.pages.slice().sort((D,r)=>It(r?.[0])-It(D?.[0])).slice(0,xi)){if(!Array.isArray(B)||B.length!==2)continue;let[D,r]=B;if(!Ce(D)||!Qe(r)||!Number.isInteger(r.offset)||r.offset<0||!Qe(r.data)||!Array.isArray(r.data.items)||!ht(r.data.total))continue;let o=!S&&(D==="nodes"||D.startsWith("children:"));if(S?!D.startsWith("hosts:"):!o&&!D.startsWith("assets:"))continue;let c=Vt(r.data.items,o?500:S?200:100,u=>S?Ce(u?.id)&&Ce(u?.label)&&Ce(u?.host)&&Ce(u?.username)&&ht(u?.port)?et(u,["id","label","folderId","kind","host","username"],["port"]):void 0:o?Ce(u?.nodeId)&&Ce(u?.key)&&Ce(u?.name)?et(u,["nodeId","key","name"],["assetCount"],["hasChildren"]):void 0:Ce(u?.assetId)&&Ce(u?.name)&&Ce(u?.address)&&Ce(u?.platform)?et(u,["assetId","name","address","platform"]):void 0);c.length===r.data.items.length&&A.push([D,{offset:r.offset,data:{items:c,total:r.data.total,hasMore:!!r.data.hasMore,truncated:!!r.data.truncated}}])}return{expanded:w.expanded.filter(Ce).slice(0,2001),scroll:ht(w.scroll)?w.scroll:0,pages:A}}function Ji(){try{return localStorage}catch{return}}var Mt=class{constructor(S,A=Ji(),B=()=>Date.now()){this.storage=A;this.now=B;this.key=yi+encodeURIComponent(S);try{let D=A?.getItem(this.key);if(D&&D.length<=Kt){let r=JSON.parse(D);if(r.schema===1&&ht(r.writtenAt)&&this.now()-r.writtenAt>=0&&this.now()-r.writtenAt<Vi&&(this.catalog=wi(r.catalog),this.catalog)){let o=At(r.host,!0);o&&this.host.restore(o);for(let u of Array.isArray(r.jumps)?r.jumps.slice(0,32):[]){if(!Array.isArray(u)||!this.catalog.jumpservers.some(a=>a.id===u[0]))continue;let n=At(u[1],!1);n&&this.jump(u[0]).restore(n)}let c=r.preferences;Qe(c)&&(this.preferences={source:c.source==="jumpserver"?"jumpserver":"ssh",instanceId:this.catalog.jumpservers.some(u=>u.id===c.instanceId)?c.instanceId:this.catalog.jumpservers[0]?.id??"",folder:this.catalog.folders.some(u=>u.id===c.folder)?c.folder:""})}}}catch{}this.host.onChange=this.schedule}host=new nt([""]);jumps=new Map;key;catalog;preferences={source:"ssh",instanceId:"",folder:""};timer;jump(S){let A=this.jumps.get(S);return A||(A=new nt,A.onChange=this.schedule,this.jumps.set(S,A)),A}schedule=()=>{this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},200))};flush(){if(!(!this.catalog||!this.storage))try{let S=At(this.host.export(),!0),A=[...this.jumps].map(([a,h])=>[a,At(h.export(),!1)]),B={schema:1,writtenAt:this.now(),catalog:wi(this.catalog),preferences:this.preferences,host:S,jumps:A},D=[S,...A.map(([,a])=>a)],r=D.flatMap(a=>a.pages.map(h=>({tree:a,page:h})));D.forEach(a=>{a.pages=[]});let o=JSON.stringify(B).length,c=0;for(let{tree:a,page:h}of r.sort((_,l)=>It(l.page[0])-It(_.page[0]))){let _=JSON.stringify(h).length+1;c<xi&&o+_<Kt&&(a.pages.push(h),o+=_,c++)}let u=JSON.stringify(B);if(u.length>Kt)return;let n=[];for(let a=0;a<this.storage.length;a++){let h=this.storage.key(a);if(h?.startsWith(yi)&&h!==this.key){let _=0;try{_=JSON.parse(this.storage.getItem(h)??"{}").writtenAt??0}catch{}n.push({key:h,time:_})}}n.sort((a,h)=>h.time-a.time).slice(2).forEach(({key:a})=>this.storage.removeItem(a)),this.storage.setItem(this.key,u)}catch{}}dispose(){clearTimeout(this.timer),this.flush(),this.host.onChange=void 0,this.host.dispose(),this.jumps.forEach(S=>{S.onChange=void 0,S.dispose()})}};var P=require("react/jsx-runtime"),Ei={terminals:[],operations:[],revision:0,capabilities:{local:!1,external:!1},hostPlatform:""},ki={connecting:"\u8FDE\u63A5\u4E2D",ready:"\u5DF2\u8FDE\u63A5",disconnected:"\u5DF2\u65AD\u5F00",error:"\u8FDE\u63A5\u5931\u8D25",executing:"\u6267\u884C\u4E2D",completed:"\u5B8C\u6210",failed:"\u5931\u8D25",unknown:"\u7ED3\u679C\u4E0D\u660E",blocked:"\u5DF2\u62D2\u7EDD",not_sent:"\u672A\u4E0B\u53D1"},Bt=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`page-${Date.now()}-${Math.random()}`;function Jt({ctx:w,sessionId:S,visible:A=!0,onClose:B}){let[D]=(0,Z.useState)(()=>new Mt(S)),[r,o]=(0,Z.useState)(Ei),[c,u]=(0,Z.useState)(new Map),[n,a]=(0,Z.useState)(""),[h,_]=(0,Z.useState)(""),[l,i]=(0,Z.useState)(D.catalog),[t,e]=(0,Z.useState)(""),[s,d]=(0,Z.useState)(""),[g,p]=(0,Z.useState)(""),[v,f]=(0,Z.useState)(D.preferences.folder),[m,E]=(0,Z.useState)(D.preferences.source),[k,x]=(0,Z.useState)(!1),[C,M]=(0,Z.useState)(!1),[z,j]=(0,Z.useState)(!1),[U,$]=(0,Z.useState)(D.preferences.instanceId),[b,L]=(0,Z.useState)(),[R,T]=(0,Z.useState)(),H=D.host,q=D.jumps;U&&D.jump(U);let[X,Y]=(0,Z.useState)(!1),[I,y]=(0,Z.useState)(!1),[F,N]=(0,Z.useState)(()=>rt("dsh-zterm.list-width",240,180,440)),[K,V]=(0,Z.useState)(!1),[ie,he]=(0,Z.useState)(!1),[le,ne]=(0,Z.useState)(),G=(0,Z.useRef)(!0),Fe=(0,Z.useRef)(A),We=(0,Z.useRef)(-1),qe=(0,Z.useRef)(async()=>{}),Ke=(0,Z.useRef)(n),$e=(0,Z.useRef)(0),we=(0,Z.useRef)(0),Ae=(0,Z.useRef)(0),Re=(0,Z.useRef)(null),Ne=(0,Z.useRef)(null),tt=Et();Fe.current=A,Ke.current=n;let pe=(0,Z.useCallback)(O=>_(O),[]);(0,Z.useEffect)(()=>{let O=setTimeout(()=>p(s.trim()),150);return()=>clearTimeout(O)},[s]),(0,Z.useEffect)(()=>()=>D.dispose(),[D]),(0,Z.useEffect)(()=>{D.preferences={source:m,instanceId:U,folder:v},D.schedule()},[D,m,U,v]),(0,Z.useEffect)(()=>{G.current=!0,o(Ei),u(new Map),We.current=-1;let O=!1,ee=!1,fe,ae,ve=new AbortController,me=async()=>{try{ee||(await te(w,"client/attach",{sessionId:S,pageId:Bt},ve.signal),ee=!0);let Pe=await te(w,"poll",{sessionId:S,cursor:We.current},ve.signal);if(O)return;We.current=Pe.cursor,o(Pe.workspace),u(zt=>ti(zt,Pe)),Pe.workspace.terminals.some(zt=>zt.id===Ke.current)||a(Pe.workspace.terminals[0]?.id??"")}catch(Pe){O||_(Pe instanceof Error?Pe.message:"\u65E0\u6CD5\u8BFB\u53D6\u7EC8\u7AEF\u72B6\u6001")}},ze=()=>ae||(ae=me().finally(()=>{ae=void 0}),ae),_t=async()=>{await ze(),O||(fe=setTimeout(_t,Fe.current?200:1e3))};return qe.current=ze,_t(),te(w,"saved-workspace",{sessionId:S}).then(Pe=>{O||he(Pe.length>0)}).catch(()=>{}),()=>{O=!0,G.current=!1,clearTimeout(fe),ve.abort()}},[w,S]);let ke=(0,Z.useCallback)(async(O,ee=!0)=>{let fe=++$e.current;ee&&(H.invalidate(),q.forEach(me=>me.invalidate()));let ae=await te(w,"catalog",{folderId:"root"},O);if(O?.aborted||fe!==$e.current||!G.current)return;let ve=D.catalog&&D.catalog.revision!==ae.revision;return ve&&H.invalidate(),H.retain(new Set(["",...ae.folders.map(me=>me.id)])),H.seed("hosts:",{items:ae.hosts,total:ae.total,hasMore:ae.total>200}),q.forEach((me,ze)=>{ae.jumpservers.some(_t=>_t.id===ze)?ve&&me.invalidate():(me.dispose(),q.delete(ze))}),D.catalog=ae,D.schedule(),e(""),i(ae),f(me=>ae.folders.some(ze=>ze.id===me)?me:""),$(me=>ae.jumpservers.some(ze=>ze.id===me)?me:ae.jumpservers[0]?.id??""),ae},[w,H,q,D]),Me=(0,Z.useRef)(A&&!I);(0,Z.useEffect)(()=>{let O=A&&!I;O&&!Me.current&&(H.invalidate(),q.forEach(ee=>ee.invalidate())),Me.current=O},[A,I,H,q]),(0,Z.useEffect)(()=>{if(!A||I)return;let O=new AbortController;return ke(O.signal,!1).catch(ee=>{O.signal.aborted||e(ee.message)}),()=>O.abort()},[ke,A,I,r.catalogRevision]);let Te=async(O,ee)=>{let fe=++Ae.current;V(!0);try{let ae=await ke(void 0,!1);if(!ae||fe!==Ae.current||!G.current)return;if(O==="host"){let ve=ee?(await te(w,"catalog",{targetId:ee.id})).hosts.find(me=>me.id===ee.id):null;if(fe!==Ae.current||!G.current)return;if(ee&&!ve)throw new Error("\u4E3B\u673A\u5DF2\u79FB\u9664\uFF0C\u8BF7\u5237\u65B0\u5217\u8868");x(ve)}else{let ve=ee?ae[O==="folder"?"folders":"jumpservers"].find(me=>me.id===ee.id):null;if(ee&&!ve)throw new Error("\u914D\u7F6E\u5DF2\u79FB\u9664\uFF0C\u8BF7\u5237\u65B0\u5217\u8868");O==="folder"?j(ve):M(ve)}}catch(ae){G.current&&fe===Ae.current&&pe(ae.message)}finally{G.current&&fe===Ae.current&&V(!1)}},oe=()=>{Ae.current++,V(!1),x(!1),M(!1),j(!1)},xe=(0,Z.useCallback)(async(O,ee={})=>{V(!0),_("");try{let fe=await te(w,O,{sessionId:S,pageId:Bt,...ee});if(G.current)return await qe.current(),fe}catch(fe){G.current&&pe(fe instanceof Error?fe.message:"\u64CD\u4F5C\u5931\u8D25")}finally{G.current&&V(!1)}},[w,S,pe]),Pt=async O=>{let ee=await xe("connect",{target:O});ee?.id&&a(ee.id)};(0,Z.useEffect)(()=>{if(!A||!Re.current)return;let O=()=>Ne.current?.scrollIntoView({block:"nearest",inline:"nearest"});O();let ee=new ResizeObserver(O);return ee.observe(Re.current),()=>ee.disconnect()},[n,A,r.terminals.length]);let re=r.terminals.find(O=>O.id===n),Oe=r.binding,dt=re&&Oe?.terminalId===re.id&&Oe.generation===re.generation,Ee=r.terminals.find(O=>O.trust),Ve=Ee?{terminalId:Ee.id,generation:Ee.generation}:{},ut=O=>O.target.source==="local"?O.target.label:`${O.target.username??""}@${O.target.host??O.target.label}${O.target.port?`:${O.target.port}`:""}`,Je=re?{terminalId:re.id,generation:re.generation}:{},Ii=re?r.operations.filter(O=>O.status==="executing"&&O.terminalId===re.id).at(-1)?.startedAt??(re.state==="connecting"?re.createdAt:void 0):void 0,Xt=ei(Ii),ft=l?.jumpservers?.find(O=>O.id===U),Yt=(O="")=>{let ee=[""],fe=new Set,ae=new Map((l?.folders??[]).map(ve=>[ve.id,ve]));for(;O&&!fe.has(O);)fe.add(O),ee.push(O),O=ae.get(O)?.parentId??"";H.reveal(ee)};(0,Z.useEffect)(()=>{we.current++,L(void 0)},[U,m]);let Mi=async O=>{let ee=++we.current;T(O),L(void 0);try{let fe=await te(w,"jump/query",{instanceId:U,operation:"accounts",assetId:O.assetId});ee===we.current&&G.current&&L(fe.accounts)}catch(fe){ee===we.current&&G.current&&pe(fe.message)}},Bi=O=>{let ee=O.clientX,fe=F;tt(O,ae=>{let ve=Math.max(180,Math.min(440,fe+ee-ae.clientX));N(ve),st("dsh-zterm.list-width",ve)})};return(0,P.jsxs)("div",{className:"zt-workbench",children:[l?.temporarilyDisabled&&(0,P.jsx)("div",{className:"zt-workbench-notice",role:"status",children:"zTerm \u5DF2\u4E34\u65F6\u7981\u7528\uFF1AAI \u4E0D\u4F1A\u6536\u5230\u672C\u63D2\u4EF6\u63D0\u793A\uFF0C\u4E5F\u4E0D\u80FD\u8C03\u7528 zterm_* \u5DE5\u5177\uFF1B\u624B\u5DE5\u8FDE\u63A5\u3001\u7EC8\u7AEF\u548C\u914D\u7F6E\u7BA1\u7406\u4ECD\u53EF\u4F7F\u7528\u3002\u53EF\u5728\u300C\u8BBE\u7F6E \u2192 zTerm\u300D\u6062\u590D\u3002"}),h&&(0,P.jsxs)("div",{className:"zt-error-banner",role:"alert",children:[(0,P.jsx)("span",{children:h}),(0,P.jsx)("button",{"aria-label":"\u5173\u95ED\u9519\u8BEF\u63D0\u793A",onClick:()=>_(""),children:"\xD7"})]}),(0,P.jsxs)("div",{className:"zt-workbench-body",children:[(0,P.jsxs)("main",{className:"zt-terminal-area",children:[(0,P.jsxs)("div",{className:"zt-terminal-topbar",children:[(0,P.jsx)("nav",{ref:Re,className:"zt-terminal-tabs","aria-label":"\u7EC8\u7AEF\u6807\u7B7E",children:r.terminals.map(O=>(0,P.jsxs)("div",{ref:O.id===n?Ne:void 0,className:`zt-tab ${O.id===n?"active":""}`,children:[(0,P.jsxs)("button",{onClick:()=>a(O.id),title:ut(O),children:[(0,P.jsx)("i",{className:`zt-state-dot ${O.state}`}),O.target.label]}),(0,P.jsx)("button",{"aria-label":`\u5173\u95ED\u7EC8\u7AEF ${O.target.label}`,onClick:()=>ne({text:`\u5173\u95ED\u300C${O.target.label}\u300D\u7684\u7EC8\u7AEF\u8FDE\u63A5\uFF1F`,act:()=>{xe("close",{terminalId:O.id}),ne(void 0)}}),children:"\xD7"})]},O.id))}),(0,P.jsxs)("div",{className:"zt-terminal-controls",children:[(0,P.jsx)("button",{disabled:!r.capabilities.local||K,title:r.capabilities.local?"\u6BCF\u6B21\u70B9\u51FB\u65B0\u5F00\u4E00\u4E2A\u7EC8\u7AEF\uFF0C\u8FD0\u884C\u5728 DSH \u6240\u5728\u7684\u673A\u5668\u4E0A":`\u8BF7\u5728 ${de} \u8BBE\u7F6E\u4E2D\u542F\u7528\u672C\u5730\u7EC8\u7AEF\u5E76\u4FDD\u5B58`,onClick:()=>void Pt({kind:"local"}),children:"\u6253\u5F00\u672C\u673A\u7EC8\u7AEF"}),(0,P.jsx)("button",{title:"\u64CD\u4F5C\u8BB0\u5F55",onClick:()=>Y(!X),children:"\u8BB0\u5F55"}),I&&(0,P.jsx)("button",{title:"\u663E\u793A\u673A\u5668\u5217\u8868","aria-expanded":!1,onClick:()=>y(!1),children:"\u673A\u5668\u5217\u8868"}),B&&(0,P.jsx)("button",{"aria-label":`\u6536\u8D77 ${de}`,onClick:B,children:"\xD7"})]})]}),re?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("div",{className:"zt-terminal-toolbar",children:[(0,P.jsxs)("div",{className:"zt-target",title:ut(re),children:[ut(re),(0,P.jsxs)("span",{children:[ki[re.state],re.busy?" \xB7 AI \u6267\u884C\u4E2D":"",Xt?` \xB7 ${Xt}`:""]})]}),(0,P.jsxs)("div",{className:"zt-actions",children:[(0,P.jsx)("button",{disabled:K||re.state!=="ready"||!re.agentReady||re.uncertain,onClick:()=>void xe("bind",Je),children:dt?"\u5DF2\u7ED1\u5B9A AI":"\u7ED1\u5B9A AI"}),(0,P.jsxs)("label",{className:`zt-mode ${dt&&Oe.mode==="readwrite"?"write":""}`,title:"\u672A\u52FE\u9009\uFF1A\u8BFB\u6A21\u5F0F\uFF0CAI \u4EC5\u53EF\u4F7F\u7528\u5185\u7F6E\u67E5\u8BE2\u5DE5\u5177\uFF1B\u52FE\u9009\uFF1A\u8BFB\u5199\u6A21\u5F0F\uFF0CAI \u53EF\u6267\u884C\u5DF2\u6388\u6743\u7684\u547D\u4EE4\u3002",children:[(0,P.jsx)("input",{type:"checkbox","aria-label":"\u5141\u8BB8AI\u5199\u64CD\u4F5C",checked:!!(dt&&Oe.mode==="readwrite"),disabled:!dt||K||!re.agentReady||re.uncertain,onChange:O=>void xe("mode",{...Je,mode:O.target.checked?"readwrite":"read"})}),"\u5141\u8BB8AI\u5199\u64CD\u4F5C"]}),(0,P.jsx)("button",{disabled:!re.busy,onClick:()=>void xe("stop",Je),children:"\u505C\u6B62"}),(0,P.jsx)("button",{disabled:K||re.busy,onClick:()=>void xe(re.state==="ready"?"disconnect":"reconnect",Je),children:re.state==="ready"?"\u65AD\u5F00":"\u91CD\u8FDE"})]})]}),!re.agentReady&&re.state==="ready"&&!re.uncertain&&(0,P.jsxs)("div",{className:"zt-notice",children:["\u624B\u5DE5\u8F93\u5165\u540E\uFF0CAI \u5DF2\u6682\u505C\u64CD\u4F5C\u3002\u786E\u8BA4\u7EC8\u7AEF\u56DE\u5230\u7A7A\u95F2 Shell \u540E\uFF1A",(0,P.jsx)("button",{onClick:()=>void xe("shell-ready",Je),children:"\u786E\u8BA4\u7A7A\u95F2 Shell"})]}),re.uncertain&&(0,P.jsxs)("div",{className:"zt-notice danger",children:["\u524D\u6B21\u64CD\u4F5C\u7ED3\u679C\u4E0D\u660E\uFF0C\u5DF2\u505C\u6B62\u81EA\u52A8\u4E0B\u53D1\u3002\u6838\u5B9E\u673A\u5668\u72B6\u6001\u540E\u91CD\u65B0\u5EFA\u7ACB\u8FDE\u63A5\u3002",(0,P.jsx)("button",{disabled:K||re.busy,onClick:()=>ne({text:`\u91CD\u5EFA\u300C${re.target.label}\u300D\u7684\u8FDE\u63A5\uFF1F\u5F53\u524D Shell \u4F1A\u65AD\u5F00\uFF0C\u4ECD\u5728\u524D\u53F0\u8FD0\u884C\u7684\u547D\u4EE4\u53EF\u80FD\u968F\u4E4B\u7EC8\u6B62\uFF0C\u8BF7\u5148\u5728\u7EC8\u7AEF\u6838\u5B9E\u8FDC\u7AEF\u72B6\u6001\u3002`,act:()=>{xe("reconnect",Je),ne(void 0)}}),children:"\u91CD\u5EFA\u8FDE\u63A5"})]}),re.error&&(0,P.jsx)("div",{className:"zt-notice danger",children:re.error})]}):(0,P.jsxs)("div",{className:"zt-empty",children:[(0,P.jsx)("div",{className:"zt-terminal-mark",children:">_"}),(0,P.jsx)("h3",{children:"\u8FDE\u63A5\u4E00\u53F0\u673A\u5668"}),(0,P.jsxs)("p",{children:["\u4ECE\u53F3\u4FA7\u9009\u62E9\u4E3B\u673A\u6216 JumpServer \u8D44\u4EA7\u3002",(0,P.jsx)("br",{}),"\u8FDE\u63A5\u540E\u53EF\u624B\u5DE5\u64CD\u4F5C\uFF0C\u6216\u7ED1\u5B9A\u7ED9\u5F53\u524D DSH \u5BF9\u8BDD\u4E2D\u7684 AI\u3002"]}),r.capabilities.automatic&&(0,P.jsx)("p",{children:"\u4E5F\u53EF\u5728\u5BF9\u8BDD\u4E2D\u6307\u5B9A\u4E3B\u673A\u540D\u6216 IP\uFF0CAI \u4F1A\u5148\u67E5\u8FDC\u7A0B\u4E3B\u673A\uFF0C\u518D\u67E5 JumpServer\uFF0C\u6700\u540E\u4F7F\u7528\u9ED8\u8BA4 SSH \u79C1\u94A5\u3002"}),(0,P.jsx)("button",{className:"zt-primary",disabled:K,onClick:()=>void Te("host"),children:"\u6DFB\u52A0\u8FDC\u7A0B\u4E3B\u673A"}),ie&&(0,P.jsx)("button",{onClick:()=>void xe("restore"),children:"\u6062\u590D\u4E0A\u6B21\u7EC8\u7AEF\u5217\u8868\uFF08\u9ED8\u8BA4\u53EA\u8BFB\uFF09"})]}),(0,P.jsx)("div",{className:"zt-screens",children:r.terminals.map(O=>(0,P.jsx)(pi,{ctx:w,sessionId:S,terminal:O,buffer:c.get(O.id),visible:A&&O.id===n,onError:pe},`${O.id}:${O.generation}`))}),(0,P.jsxs)("footer",{className:"zt-statusbar",children:[(0,P.jsxs)("div",{className:"zt-status-info",children:[(0,P.jsx)("span",{children:Oe?`AI \u7ED1\u5B9A\uFF1A${r.terminals.find(O=>O.id===Oe.terminalId)?.target.label??Oe.terminalId} \xB7 ${Oe.mode==="readwrite"?`\u8BFB\u5199 ${Oe.writeCalls}/${Oe.maxWriteCalls}`:"\u53EA\u8BFB"}`:"AI \u5C1A\u672A\u7ED1\u5B9A\u7EC8\u7AEF"}),(0,P.jsxs)("span",{className:"zt-host-platform",title:"\u7EC8\u7AEF\u8FDE\u63A5\u4E0E\u547D\u4EE4\u4ECE DSH \u5BBF\u4E3B\u53D1\u8D77",children:["DSH \u5BBF\u4E3B \xB7 ",r.hostPlatform||"\u6B63\u5728\u8FDE\u63A5"]})]}),re&&(0,P.jsx)("button",{onClick:()=>{te(w,"terminal/export",{sessionId:S,terminalId:re.id}).then(O=>gt(`zterm-${vt()}-\u7EC8\u7AEF.txt`,`\u7EC8\u7AEF\uFF1A${ut(re)}
8
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(f){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),t.isLinux&&f&&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(f){let m=this._getMouseBufferCoords(f),L=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!!(L&&k&&m)&&this._areCoordsInSelection(m,L,k)}isCellInSelection(f,m){let L=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!(!L||!k)&&this._areCoordsInSelection([f,m],L,k)}_areCoordsInSelection(f,m,L){return f[1]>m[1]&&f[1]<L[1]||m[1]===L[1]&&f[1]===m[1]&&f[0]>=m[0]&&f[0]<L[0]||m[1]<L[1]&&f[1]===L[1]&&f[0]<L[0]||m[1]<L[1]&&f[1]===m[1]&&f[0]>=m[0]}_selectWordAtCursor(f,m){let L=this._linkifier.currentLink?.link?.range;if(L)return this._model.selectionStart=[L.start.x-1,L.start.y-1],this._model.selectionStartLength=(0,e.getRangeLength)(L,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let k=this._getMouseBufferCoords(f);return!!k&&(this._selectWordAt(k,m),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(f,m){this._model.clearSelection(),f=Math.max(f,0),m=Math.min(m,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,f],this._model.selectionEnd=[this._bufferService.cols,m],this.refresh(),this._onSelectionChange.fire()}_handleTrim(f){this._model.handleTrim(f)&&this.refresh()}_getMouseBufferCoords(f){let m=this._mouseService.getCoords(f,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(m)return m[0]--,m[1]--,m[1]+=this._bufferService.buffer.ydisp,m}_getMouseEventScrollAmount(f){let m=(0,o.getCoordsRelativeToElement)(this._coreBrowserService.window,f,this._screenElement)[1],L=this._renderService.dimensions.css.canvas.height;return m>=0&&m<=L?0:(m>L&&(m-=L),m=Math.min(Math.max(m,-50),50),m/=50,m/Math.abs(m)+Math.round(14*m))}shouldForceSelection(f){return t.isMac?f.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:f.shiftKey}handleMouseDown(f){if(this._mouseDownTimeStamp=f.timeStamp,(f.button!==2||!this.hasSelection)&&f.button===0){if(!this._enabled){if(!this.shouldForceSelection(f))return;f.stopPropagation()}f.preventDefault(),this._dragScrollAmount=0,this._enabled&&f.shiftKey?this._handleIncrementalClick(f):f.detail===1?this._handleSingleClick(f):f.detail===2?this._handleDoubleClick(f):f.detail===3&&this._handleTripleClick(f),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()),50)}_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(f){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(f))}_handleSingleClick(f){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(f)?3:0,this._model.selectionStart=this._getMouseBufferCoords(f),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let m=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);m&&m.length!==this._model.selectionStart[0]&&m.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(f){this._selectWordAtCursor(f,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(f){let m=this._getMouseBufferCoords(f);m&&(this._activeSelectionMode=2,this._selectLineAt(m[1]))}shouldColumnSelect(f){return f.altKey&&!(t.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(f){if(f.stopImmediatePropagation(),!this._model.selectionStart)return;let m=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(f),!this._model.selectionEnd)return void this.refresh(!0);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(f),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let L=this._bufferService.buffer;if(this._model.selectionEnd[1]<L.lines.length){let k=L.lines.get(this._model.selectionEnd[1]);k&&k.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}m&&m[0]===this._model.selectionEnd[0]&&m[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 f=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(f.ydisp+this._bufferService.rows,f.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=f.ydisp),this.refresh()}}_handleMouseUp(f){let m=f.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&m<500&&f.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let L=this._mouseService.getCoords(f,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(L&&L[0]!==void 0&&L[1]!==void 0){let k=(0,a.moveToCellSequence)(L[0]-1,L[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(k,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let f=this._model.finalSelectionStart,m=this._model.finalSelectionEnd,L=!(!f||!m||f[0]===m[0]&&f[1]===m[1]);L?f&&m&&(this._oldSelectionStart&&this._oldSelectionEnd&&f[0]===this._oldSelectionStart[0]&&f[1]===this._oldSelectionStart[1]&&m[0]===this._oldSelectionEnd[0]&&m[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(f,m,L)):this._oldHasSelection&&this._fireOnSelectionChange(f,m,L)}_fireOnSelectionChange(f,m,L){this._oldSelectionStart=f,this._oldSelectionEnd=m,this._oldHasSelection=L,this._onSelectionChange.fire()}_handleBufferActivate(f){this.clearSelection(),this._trimListener.dispose(),this._trimListener=f.activeBuffer.lines.onTrim((m=>this._handleTrim(m)))}_convertViewportColToCharacterIndex(f,m){let L=m;for(let k=0;m>=k;k++){let E=f.loadCell(k,this._workCell).getChars().length;this._workCell.getWidth()===0?L--:E>1&&m!==k&&(L+=E-1)}return L}setSelection(f,m,L){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[f,m],this._model.selectionStartLength=L,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(f){this._isClickInSelection(f)||(this._selectWordAtCursor(f,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(f,m,L=!0,k=!0){if(f[0]>=this._bufferService.cols)return;let E=this._bufferService.buffer,C=E.lines.get(f[1]);if(!C)return;let B=E.translateBufferLineToString(f[1],!1),z=this._convertViewportColToCharacterIndex(C,f[0]),j=z,U=f[0]-z,$=0,b=0,D=0,R=0;if(B.charAt(z)===" "){for(;z>0&&B.charAt(z-1)===" ";)z--;for(;j<B.length&&B.charAt(j+1)===" ";)j++}else{let q=f[0],X=f[0];C.getWidth(q)===0&&($++,q--),C.getWidth(X)===2&&(b++,X++);let Y=C.getString(X).length;for(Y>1&&(R+=Y-1,j+=Y-1);q>0&&z>0&&!this._isCharWordSeparator(C.loadCell(q-1,this._workCell));){C.loadCell(q-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?($++,q--):I>1&&(D+=I-1,z-=I-1),z--,q--}for(;X<C.length&&j+1<B.length&&!this._isCharWordSeparator(C.loadCell(X+1,this._workCell));){C.loadCell(X+1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,X++):I>1&&(R+=I-1,j+=I-1),j++,X++}}j++;let A=z+U-$+D,H=Math.min(this._bufferService.cols,j-z+$+b-D-R);if(m||B.slice(z,j).trim()!==""){if(L&&A===0&&C.getCodePoint(0)!==32){let q=E.lines.get(f[1]-1);if(q&&C.isWrapped&&q.getCodePoint(this._bufferService.cols-1)!==32){let X=this._getWordAt([this._bufferService.cols-1,f[1]-1],!1,!0,!1);if(X){let Y=this._bufferService.cols-X.start;A-=Y,H+=Y}}}if(k&&A+H===this._bufferService.cols&&C.getCodePoint(this._bufferService.cols-1)!==32){let q=E.lines.get(f[1]+1);if(q?.isWrapped&&q.getCodePoint(0)!==32){let X=this._getWordAt([0,f[1]+1],!1,!1,!0);X&&(H+=X.length)}}return{start:A,length:H}}}_selectWordAt(f,m){let L=this._getWordAt(f,m);if(L){for(;L.start<0;)L.start+=this._bufferService.cols,f[1]--;this._model.selectionStart=[L.start,f[1]],this._model.selectionStartLength=L.length}}_selectToWordAt(f){let m=this._getWordAt(f,!0);if(m){let L=f[1];for(;m.start<0;)m.start+=this._bufferService.cols,L--;if(!this._model.areSelectionValuesReversed())for(;m.start+m.length>this._bufferService.cols;)m.length-=this._bufferService.cols,L++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?m.start:m.start+m.length,L]}}_isCharWordSeparator(f){return f.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(f.getChars())>=0}_selectLineAt(f){let m=this._bufferService.buffer.getWrappedRangeForLine(f),L={start:{x:0,y:m.first},end:{x:this._bufferService.cols-1,y:m.last}};this._model.selectionStart=[0,m.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,e.getRangeLength)(L,this._bufferService.cols)}};r.SelectionService=v=h([u(3,d.IBufferService),u(4,d.ICoreService),u(5,_.IMouseService),u(6,d.IOptionsService),u(7,_.IRenderService),u(8,_.ICoreBrowserService)],v)},4725:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ILinkProviderService=r.IThemeService=r.ICharacterJoinerService=r.ISelectionService=r.IRenderService=r.IMouseService=r.ICoreBrowserService=r.ICharSizeService=void 0;let h=n(8343);r.ICharSizeService=(0,h.createDecorator)("CharSizeService"),r.ICoreBrowserService=(0,h.createDecorator)("CoreBrowserService"),r.IMouseService=(0,h.createDecorator)("MouseService"),r.IRenderService=(0,h.createDecorator)("RenderService"),r.ISelectionService=(0,h.createDecorator)("SelectionService"),r.ICharacterJoinerService=(0,h.createDecorator)("CharacterJoinerService"),r.IThemeService=(0,h.createDecorator)("ThemeService"),r.ILinkProviderService=(0,h.createDecorator)("LinkProviderService")},6731:function(x,r,n){var h=this&&this.__decorate||function(v,f,m,L){var k,E=arguments.length,C=E<3?f:L===null?L=Object.getOwnPropertyDescriptor(f,m):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(v,f,m,L);else for(var B=v.length-1;B>=0;B--)(k=v[B])&&(C=(E<3?k(C):E>3?k(f,m,C):k(f,m))||C);return E>3&&C&&Object.defineProperty(f,m,C),C},u=this&&this.__param||function(v,f){return function(m,L){f(m,L,v)}};Object.defineProperty(r,"__esModule",{value:!0}),r.ThemeService=r.DEFAULT_ANSI_COLORS=void 0;let o=n(7239),a=n(8055),c=n(8460),_=n(844),l=n(2585),i=a.css.toColor("#ffffff"),t=a.css.toColor("#000000"),e=a.css.toColor("#ffffff"),s=a.css.toColor("#000000"),d={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{let v=[a.css.toColor("#2e3436"),a.css.toColor("#cc0000"),a.css.toColor("#4e9a06"),a.css.toColor("#c4a000"),a.css.toColor("#3465a4"),a.css.toColor("#75507b"),a.css.toColor("#06989a"),a.css.toColor("#d3d7cf"),a.css.toColor("#555753"),a.css.toColor("#ef2929"),a.css.toColor("#8ae234"),a.css.toColor("#fce94f"),a.css.toColor("#729fcf"),a.css.toColor("#ad7fa8"),a.css.toColor("#34e2e2"),a.css.toColor("#eeeeec")],f=[0,95,135,175,215,255];for(let m=0;m<216;m++){let L=f[m/36%6|0],k=f[m/6%6|0],E=f[m%6];v.push({css:a.channels.toCss(L,k,E),rgba:a.channels.toRgba(L,k,E)})}for(let m=0;m<24;m++){let L=8+10*m;v.push({css:a.channels.toCss(L,L,L),rgba:a.channels.toRgba(L,L,L)})}return v})());let p=r.ThemeService=class extends _.Disposable{get colors(){return this._colors}constructor(v){super(),this._optionsService=v,this._contrastCache=new o.ColorContrastCache,this._halfContrastCache=new o.ColorContrastCache,this._onChangeColors=this.register(new c.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:i,background:t,cursor:e,cursorAccent:s,selectionForeground:void 0,selectionBackgroundTransparent:d,selectionBackgroundOpaque:a.color.blend(t,d),selectionInactiveBackgroundTransparent:d,selectionInactiveBackgroundOpaque:a.color.blend(t,d),ansi:r.DEFAULT_ANSI_COLORS.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))))}_setTheme(v={}){let f=this._colors;if(f.foreground=g(v.foreground,i),f.background=g(v.background,t),f.cursor=g(v.cursor,e),f.cursorAccent=g(v.cursorAccent,s),f.selectionBackgroundTransparent=g(v.selectionBackground,d),f.selectionBackgroundOpaque=a.color.blend(f.background,f.selectionBackgroundTransparent),f.selectionInactiveBackgroundTransparent=g(v.selectionInactiveBackground,f.selectionBackgroundTransparent),f.selectionInactiveBackgroundOpaque=a.color.blend(f.background,f.selectionInactiveBackgroundTransparent),f.selectionForeground=v.selectionForeground?g(v.selectionForeground,a.NULL_COLOR):void 0,f.selectionForeground===a.NULL_COLOR&&(f.selectionForeground=void 0),a.color.isOpaque(f.selectionBackgroundTransparent)&&(f.selectionBackgroundTransparent=a.color.opacity(f.selectionBackgroundTransparent,.3)),a.color.isOpaque(f.selectionInactiveBackgroundTransparent)&&(f.selectionInactiveBackgroundTransparent=a.color.opacity(f.selectionInactiveBackgroundTransparent,.3)),f.ansi=r.DEFAULT_ANSI_COLORS.slice(),f.ansi[0]=g(v.black,r.DEFAULT_ANSI_COLORS[0]),f.ansi[1]=g(v.red,r.DEFAULT_ANSI_COLORS[1]),f.ansi[2]=g(v.green,r.DEFAULT_ANSI_COLORS[2]),f.ansi[3]=g(v.yellow,r.DEFAULT_ANSI_COLORS[3]),f.ansi[4]=g(v.blue,r.DEFAULT_ANSI_COLORS[4]),f.ansi[5]=g(v.magenta,r.DEFAULT_ANSI_COLORS[5]),f.ansi[6]=g(v.cyan,r.DEFAULT_ANSI_COLORS[6]),f.ansi[7]=g(v.white,r.DEFAULT_ANSI_COLORS[7]),f.ansi[8]=g(v.brightBlack,r.DEFAULT_ANSI_COLORS[8]),f.ansi[9]=g(v.brightRed,r.DEFAULT_ANSI_COLORS[9]),f.ansi[10]=g(v.brightGreen,r.DEFAULT_ANSI_COLORS[10]),f.ansi[11]=g(v.brightYellow,r.DEFAULT_ANSI_COLORS[11]),f.ansi[12]=g(v.brightBlue,r.DEFAULT_ANSI_COLORS[12]),f.ansi[13]=g(v.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),f.ansi[14]=g(v.brightCyan,r.DEFAULT_ANSI_COLORS[14]),f.ansi[15]=g(v.brightWhite,r.DEFAULT_ANSI_COLORS[15]),v.extendedAnsi){let m=Math.min(f.ansi.length-16,v.extendedAnsi.length);for(let L=0;L<m;L++)f.ansi[L+16]=g(v.extendedAnsi[L],r.DEFAULT_ANSI_COLORS[L+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(v){this._restoreColor(v),this._onChangeColors.fire(this.colors)}_restoreColor(v){if(v!==void 0)switch(v){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[v]=this._restoreColors.ansi[v]}else for(let f=0;f<this._restoreColors.ansi.length;++f)this._colors.ansi[f]=this._restoreColors.ansi[f]}modifyColors(v){v(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()}}};function g(v,f){if(v!==void 0)try{return a.css.toColor(v)}catch{}return f}r.ThemeService=p=h([u(0,l.IOptionsService)],p)},6349:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CircularList=void 0;let h=n(8460),u=n(844);class o extends u.Disposable{constructor(c){super(),this._maxLength=c,this.onDeleteEmitter=this.register(new h.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new h.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new h.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(c){if(this._maxLength===c)return;let _=new Array(c);for(let l=0;l<Math.min(c,this.length);l++)_[l]=this._array[this._getCyclicIndex(l)];this._array=_,this._maxLength=c,this._startIndex=0}get length(){return this._length}set length(c){if(c>this._length)for(let _=this._length;_<c;_++)this._array[_]=void 0;this._length=c}get(c){return this._array[this._getCyclicIndex(c)]}set(c,_){this._array[this._getCyclicIndex(c)]=_}push(c){this._array[this._getCyclicIndex(this._length)]=c,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(c,_,...l){if(_){for(let i=c;i<this._length-_;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+_)];this._length-=_,this.onDeleteEmitter.fire({index:c,amount:_})}for(let i=this._length-1;i>=c;i--)this._array[this._getCyclicIndex(i+l.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<l.length;i++)this._array[this._getCyclicIndex(c+i)]=l[i];if(l.length&&this.onInsertEmitter.fire({index:c,amount:l.length}),this._length+l.length>this._maxLength){let i=this._length+l.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=l.length}trimStart(c){c>this._length&&(c=this._length),this._startIndex+=c,this._length-=c,this.onTrimEmitter.fire(c)}shiftElements(c,_,l){if(!(_<=0)){if(c<0||c>=this._length)throw new Error("start argument out of range");if(c+l<0)throw new Error("Cannot shift elements in list beyond index 0");if(l>0){for(let t=_-1;t>=0;t--)this.set(c+t+l,this.get(c+t));let i=c+_+l-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<_;i++)this.set(c+i+l,this.get(c+i))}}_getCyclicIndex(c){return(this._startIndex+c)%this._maxLength}}r.CircularList=o},1439:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.clone=void 0,r.clone=function n(h,u=5){if(typeof h!="object")return h;let o=Array.isArray(h)?[]:{};for(let a in h)o[a]=u<=1?h[a]:h[a]&&n(h[a],u-1);return o}},8055:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.contrastRatio=r.toPaddedHex=r.rgba=r.rgb=r.css=r.color=r.channels=r.NULL_COLOR=void 0;let n=0,h=0,u=0,o=0;var a,c,_,l,i;function t(s){let d=s.toString(16);return d.length<2?"0"+d:d}function e(s,d){return s<d?(d+.05)/(s+.05):(s+.05)/(d+.05)}r.NULL_COLOR={css:"#00000000",rgba:0},(function(s){s.toCss=function(d,p,g,v){return v!==void 0?`#${t(d)}${t(p)}${t(g)}${t(v)}`:`#${t(d)}${t(p)}${t(g)}`},s.toRgba=function(d,p,g,v=255){return(d<<24|p<<16|g<<8|v)>>>0},s.toColor=function(d,p,g,v){return{css:s.toCss(d,p,g,v),rgba:s.toRgba(d,p,g,v)}}})(a||(r.channels=a={})),(function(s){function d(p,g){return o=Math.round(255*g),[n,h,u]=i.toChannels(p.rgba),{css:a.toCss(n,h,u,o),rgba:a.toRgba(n,h,u,o)}}s.blend=function(p,g){if(o=(255&g.rgba)/255,o===1)return{css:g.css,rgba:g.rgba};let v=g.rgba>>24&255,f=g.rgba>>16&255,m=g.rgba>>8&255,L=p.rgba>>24&255,k=p.rgba>>16&255,E=p.rgba>>8&255;return n=L+Math.round((v-L)*o),h=k+Math.round((f-k)*o),u=E+Math.round((m-E)*o),{css:a.toCss(n,h,u),rgba:a.toRgba(n,h,u)}},s.isOpaque=function(p){return(255&p.rgba)==255},s.ensureContrastRatio=function(p,g,v){let f=i.ensureContrastRatio(p.rgba,g.rgba,v);if(f)return a.toColor(f>>24&255,f>>16&255,f>>8&255)},s.opaque=function(p){let g=(255|p.rgba)>>>0;return[n,h,u]=i.toChannels(g),{css:a.toCss(n,h,u),rgba:g}},s.opacity=d,s.multiplyOpacity=function(p,g){return o=255&p.rgba,d(p,o*g/255)},s.toColorRGB=function(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}})(c||(r.color=c={})),(function(s){let d,p;try{let g=document.createElement("canvas");g.width=1,g.height=1;let v=g.getContext("2d",{willReadFrequently:!0});v&&(d=v,d.globalCompositeOperation="copy",p=d.createLinearGradient(0,0,1,1))}catch{}s.toColor=function(g){if(g.match(/#[\da-f]{3,8}/i))switch(g.length){case 4:return n=parseInt(g.slice(1,2).repeat(2),16),h=parseInt(g.slice(2,3).repeat(2),16),u=parseInt(g.slice(3,4).repeat(2),16),a.toColor(n,h,u);case 5:return n=parseInt(g.slice(1,2).repeat(2),16),h=parseInt(g.slice(2,3).repeat(2),16),u=parseInt(g.slice(3,4).repeat(2),16),o=parseInt(g.slice(4,5).repeat(2),16),a.toColor(n,h,u,o);case 7:return{css:g,rgba:(parseInt(g.slice(1),16)<<8|255)>>>0};case 9:return{css:g,rgba:parseInt(g.slice(1),16)>>>0}}let v=g.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(v)return n=parseInt(v[1]),h=parseInt(v[2]),u=parseInt(v[3]),o=Math.round(255*(v[5]===void 0?1:parseFloat(v[5]))),a.toColor(n,h,u,o);if(!d||!p)throw new Error("css.toColor: Unsupported css format");if(d.fillStyle=p,d.fillStyle=g,typeof d.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(d.fillRect(0,0,1,1),[n,h,u,o]=d.getImageData(0,0,1,1).data,o!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:a.toRgba(n,h,u,o),css:g}}})(_||(r.css=_={})),(function(s){function d(p,g,v){let f=p/255,m=g/255,L=v/255;return .2126*(f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4))+.7152*(m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4))+.0722*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))}s.relativeLuminance=function(p){return d(p>>16&255,p>>8&255,255&p)},s.relativeLuminance2=d})(l||(r.rgb=l={})),(function(s){function d(g,v,f){let m=g>>24&255,L=g>>16&255,k=g>>8&255,E=v>>24&255,C=v>>16&255,B=v>>8&255,z=e(l.relativeLuminance2(E,C,B),l.relativeLuminance2(m,L,k));for(;z<f&&(E>0||C>0||B>0);)E-=Math.max(0,Math.ceil(.1*E)),C-=Math.max(0,Math.ceil(.1*C)),B-=Math.max(0,Math.ceil(.1*B)),z=e(l.relativeLuminance2(E,C,B),l.relativeLuminance2(m,L,k));return(E<<24|C<<16|B<<8|255)>>>0}function p(g,v,f){let m=g>>24&255,L=g>>16&255,k=g>>8&255,E=v>>24&255,C=v>>16&255,B=v>>8&255,z=e(l.relativeLuminance2(E,C,B),l.relativeLuminance2(m,L,k));for(;z<f&&(E<255||C<255||B<255);)E=Math.min(255,E+Math.ceil(.1*(255-E))),C=Math.min(255,C+Math.ceil(.1*(255-C))),B=Math.min(255,B+Math.ceil(.1*(255-B))),z=e(l.relativeLuminance2(E,C,B),l.relativeLuminance2(m,L,k));return(E<<24|C<<16|B<<8|255)>>>0}s.blend=function(g,v){if(o=(255&v)/255,o===1)return v;let f=v>>24&255,m=v>>16&255,L=v>>8&255,k=g>>24&255,E=g>>16&255,C=g>>8&255;return n=k+Math.round((f-k)*o),h=E+Math.round((m-E)*o),u=C+Math.round((L-C)*o),a.toRgba(n,h,u)},s.ensureContrastRatio=function(g,v,f){let m=l.relativeLuminance(g>>8),L=l.relativeLuminance(v>>8);if(e(m,L)<f){if(L<m){let C=d(g,v,f),B=e(m,l.relativeLuminance(C>>8));if(B<f){let z=p(g,v,f);return B>e(m,l.relativeLuminance(z>>8))?C:z}return C}let k=p(g,v,f),E=e(m,l.relativeLuminance(k>>8));if(E<f){let C=d(g,v,f);return E>e(m,l.relativeLuminance(C>>8))?k:C}return k}},s.reduceLuminance=d,s.increaseLuminance=p,s.toChannels=function(g){return[g>>24&255,g>>16&255,g>>8&255,255&g]}})(i||(r.rgba=i={})),r.toPaddedHex=t,r.contrastRatio=e},8969:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreTerminal=void 0;let h=n(844),u=n(2585),o=n(4348),a=n(7866),c=n(744),_=n(7302),l=n(6975),i=n(8460),t=n(1753),e=n(1480),s=n(7994),d=n(9282),p=n(5435),g=n(5981),v=n(2660),f=!1;class m extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new i.EventEmitter),this._onScroll.event((k=>{this._onScrollApi?.fire(k.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(k){for(let E in k)this.optionsService.options[E]=k[E]}constructor(k){super(),this._windowsWrappingHeuristics=this.register(new h.MutableDisposable),this._onBinary=this.register(new i.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new i.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new i.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new i.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new i.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new i.EventEmitter),this._instantiationService=new o.InstantiationService,this.optionsService=this.register(new _.OptionsService(k)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(c.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(a.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(l.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(t.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(e.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(s.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(v.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new p.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,i.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,i.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,i.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,i.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((E=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((E=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new g.WriteBuffer(((E,C)=>this._inputHandler.parse(E,C)))),this.register((0,i.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(k,E){this._writeBuffer.write(k,E)}writeSync(k,E){this._logService.logLevel<=u.LogLevelEnum.WARN&&!f&&(this._logService.warn("writeSync is unreliable and will be removed soon."),f=!0),this._writeBuffer.writeSync(k,E)}input(k,E=!0){this.coreService.triggerDataEvent(k,E)}resize(k,E){isNaN(k)||isNaN(E)||(k=Math.max(k,c.MINIMUM_COLS),E=Math.max(E,c.MINIMUM_ROWS),this._bufferService.resize(k,E))}scroll(k,E=!1){this._bufferService.scroll(k,E)}scrollLines(k,E,C){this._bufferService.scrollLines(k,E,C)}scrollPages(k){this.scrollLines(k*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(k){let E=k-this._bufferService.buffer.ydisp;E!==0&&this.scrollLines(E)}registerEscHandler(k,E){return this._inputHandler.registerEscHandler(k,E)}registerDcsHandler(k,E){return this._inputHandler.registerDcsHandler(k,E)}registerCsiHandler(k,E){return this._inputHandler.registerCsiHandler(k,E)}registerOscHandler(k,E){return this._inputHandler.registerOscHandler(k,E)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let k=!1,E=this.optionsService.rawOptions.windowsPty;E&&E.buildNumber!==void 0&&E.buildNumber!==void 0?k=E.backend==="conpty"&&E.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(k=!0),k?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let k=[];k.push(this.onLineFeed(d.updateWindowsModeWrappedState.bind(null,this._bufferService))),k.push(this.registerCsiHandler({final:"H"},(()=>((0,d.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(let E of k)E.dispose()}))}}}r.CoreTerminal=m},8460:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.runAndSubscribe=r.forwardEvent=r.EventEmitter=void 0,r.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let h=0;h<this._listeners.length;h++)if(this._listeners[h]===n)return void this._listeners.splice(h,1)}}})),this._event}fire(n,h){let u=[];for(let o=0;o<this._listeners.length;o++)u.push(this._listeners[o]);for(let o=0;o<u.length;o++)u[o].call(void 0,n,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(n,h){return n((u=>h.fire(u)))},r.runAndSubscribe=function(n,h){return h(void 0),n((u=>h(u)))}},5435:function(x,r,n){var h=this&&this.__decorate||function($,b,D,R){var A,H=arguments.length,q=H<3?b:R===null?R=Object.getOwnPropertyDescriptor(b,D):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")q=Reflect.decorate($,b,D,R);else for(var X=$.length-1;X>=0;X--)(A=$[X])&&(q=(H<3?A(q):H>3?A(b,D,q):A(b,D))||q);return H>3&&q&&Object.defineProperty(b,D,q),q},u=this&&this.__param||function($,b){return function(D,R){b(D,R,$)}};Object.defineProperty(r,"__esModule",{value:!0}),r.InputHandler=r.WindowsOptionsReportType=void 0;let o=n(2584),a=n(7116),c=n(2015),_=n(844),l=n(482),i=n(8437),t=n(8460),e=n(643),s=n(511),d=n(3734),p=n(2585),g=n(1480),v=n(6242),f=n(6351),m=n(5941),L={"(":0,")":1,"*":2,"+":3,"-":1,".":2},k=131072;function E($,b){if($>24)return b.setWinLines||!1;switch($){case 1:return!!b.restoreWin;case 2:return!!b.minimizeWin;case 3:return!!b.setWinPosition;case 4:return!!b.setWinSizePixels;case 5:return!!b.raiseWin;case 6:return!!b.lowerWin;case 7:return!!b.refreshWin;case 8:return!!b.setWinSizeChars;case 9:return!!b.maximizeWin;case 10:return!!b.fullscreenWin;case 11:return!!b.getWinState;case 13:return!!b.getWinPosition;case 14:return!!b.getWinSizePixels;case 15:return!!b.getScreenSizePixels;case 16:return!!b.getCellSizePixels;case 18:return!!b.getWinSizeChars;case 19:return!!b.getScreenSizeChars;case 20:return!!b.getIconTitle;case 21:return!!b.getWinTitle;case 22:return!!b.pushTitle;case 23:return!!b.popTitle;case 24:return!!b.setWinLines}return!1}var C;(function($){$[$.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",$[$.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(C||(r.WindowsOptionsReportType=C={}));let B=0;class z extends _.Disposable{getAttrData(){return this._curAttrData}constructor(b,D,R,A,H,q,X,Y,I=new c.EscapeSequenceParser){super(),this._bufferService=b,this._charsetService=D,this._coreService=R,this._logService=A,this._optionsService=H,this._oscLinkService=q,this._coreMouseService=X,this._unicodeService=Y,this._parser=I,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new l.StringToUtf32,this._utf8Decoder=new l.Utf8ToUtf32,this._workCell=new s.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new t.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new t.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new t.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new t.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new t.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new t.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new t.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new t.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new t.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new t.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new t.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new t.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new t.EventEmitter),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 j(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((w=>this._activeBuffer=w.activeBuffer))),this._parser.setCsiHandlerFallback(((w,N)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(w),params:N.toArray()})})),this._parser.setEscHandlerFallback((w=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(w)})})),this._parser.setExecuteHandlerFallback((w=>{this._logService.debug("Unknown EXECUTE code: ",{code:w})})),this._parser.setOscHandlerFallback(((w,N,F)=>{this._logService.debug("Unknown OSC code: ",{identifier:w,action:N,data:F})})),this._parser.setDcsHandlerFallback(((w,N,F)=>{N==="HOOK"&&(F=F.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(w),action:N,payload:F})})),this._parser.setPrintHandler(((w,N,F)=>this.print(w,N,F))),this._parser.registerCsiHandler({final:"@"},(w=>this.insertChars(w))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(w=>this.scrollLeft(w))),this._parser.registerCsiHandler({final:"A"},(w=>this.cursorUp(w))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(w=>this.scrollRight(w))),this._parser.registerCsiHandler({final:"B"},(w=>this.cursorDown(w))),this._parser.registerCsiHandler({final:"C"},(w=>this.cursorForward(w))),this._parser.registerCsiHandler({final:"D"},(w=>this.cursorBackward(w))),this._parser.registerCsiHandler({final:"E"},(w=>this.cursorNextLine(w))),this._parser.registerCsiHandler({final:"F"},(w=>this.cursorPrecedingLine(w))),this._parser.registerCsiHandler({final:"G"},(w=>this.cursorCharAbsolute(w))),this._parser.registerCsiHandler({final:"H"},(w=>this.cursorPosition(w))),this._parser.registerCsiHandler({final:"I"},(w=>this.cursorForwardTab(w))),this._parser.registerCsiHandler({final:"J"},(w=>this.eraseInDisplay(w,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(w=>this.eraseInDisplay(w,!0))),this._parser.registerCsiHandler({final:"K"},(w=>this.eraseInLine(w,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(w=>this.eraseInLine(w,!0))),this._parser.registerCsiHandler({final:"L"},(w=>this.insertLines(w))),this._parser.registerCsiHandler({final:"M"},(w=>this.deleteLines(w))),this._parser.registerCsiHandler({final:"P"},(w=>this.deleteChars(w))),this._parser.registerCsiHandler({final:"S"},(w=>this.scrollUp(w))),this._parser.registerCsiHandler({final:"T"},(w=>this.scrollDown(w))),this._parser.registerCsiHandler({final:"X"},(w=>this.eraseChars(w))),this._parser.registerCsiHandler({final:"Z"},(w=>this.cursorBackwardTab(w))),this._parser.registerCsiHandler({final:"`"},(w=>this.charPosAbsolute(w))),this._parser.registerCsiHandler({final:"a"},(w=>this.hPositionRelative(w))),this._parser.registerCsiHandler({final:"b"},(w=>this.repeatPrecedingCharacter(w))),this._parser.registerCsiHandler({final:"c"},(w=>this.sendDeviceAttributesPrimary(w))),this._parser.registerCsiHandler({prefix:">",final:"c"},(w=>this.sendDeviceAttributesSecondary(w))),this._parser.registerCsiHandler({final:"d"},(w=>this.linePosAbsolute(w))),this._parser.registerCsiHandler({final:"e"},(w=>this.vPositionRelative(w))),this._parser.registerCsiHandler({final:"f"},(w=>this.hVPosition(w))),this._parser.registerCsiHandler({final:"g"},(w=>this.tabClear(w))),this._parser.registerCsiHandler({final:"h"},(w=>this.setMode(w))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(w=>this.setModePrivate(w))),this._parser.registerCsiHandler({final:"l"},(w=>this.resetMode(w))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(w=>this.resetModePrivate(w))),this._parser.registerCsiHandler({final:"m"},(w=>this.charAttributes(w))),this._parser.registerCsiHandler({final:"n"},(w=>this.deviceStatus(w))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(w=>this.deviceStatusPrivate(w))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(w=>this.softReset(w))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(w=>this.setCursorStyle(w))),this._parser.registerCsiHandler({final:"r"},(w=>this.setScrollRegion(w))),this._parser.registerCsiHandler({final:"s"},(w=>this.saveCursor(w))),this._parser.registerCsiHandler({final:"t"},(w=>this.windowOptions(w))),this._parser.registerCsiHandler({final:"u"},(w=>this.restoreCursor(w))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(w=>this.insertColumns(w))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(w=>this.deleteColumns(w))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(w=>this.selectProtected(w))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(w=>this.requestMode(w,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(w=>this.requestMode(w,!1))),this._parser.setExecuteHandler(o.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(o.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(o.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(o.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(o.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(o.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(o.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(o.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(o.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new v.OscHandler((w=>(this.setTitle(w),this.setIconName(w),!0)))),this._parser.registerOscHandler(1,new v.OscHandler((w=>this.setIconName(w)))),this._parser.registerOscHandler(2,new v.OscHandler((w=>this.setTitle(w)))),this._parser.registerOscHandler(4,new v.OscHandler((w=>this.setOrReportIndexedColor(w)))),this._parser.registerOscHandler(8,new v.OscHandler((w=>this.setHyperlink(w)))),this._parser.registerOscHandler(10,new v.OscHandler((w=>this.setOrReportFgColor(w)))),this._parser.registerOscHandler(11,new v.OscHandler((w=>this.setOrReportBgColor(w)))),this._parser.registerOscHandler(12,new v.OscHandler((w=>this.setOrReportCursorColor(w)))),this._parser.registerOscHandler(104,new v.OscHandler((w=>this.restoreIndexedColor(w)))),this._parser.registerOscHandler(110,new v.OscHandler((w=>this.restoreFgColor(w)))),this._parser.registerOscHandler(111,new v.OscHandler((w=>this.restoreBgColor(w)))),this._parser.registerOscHandler(112,new v.OscHandler((w=>this.restoreCursorColor(w)))),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 w in a.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:w},(()=>this.selectCharset("("+w))),this._parser.registerEscHandler({intermediates:")",final:w},(()=>this.selectCharset(")"+w))),this._parser.registerEscHandler({intermediates:"*",final:w},(()=>this.selectCharset("*"+w))),this._parser.registerEscHandler({intermediates:"+",final:w},(()=>this.selectCharset("+"+w))),this._parser.registerEscHandler({intermediates:"-",final:w},(()=>this.selectCharset("-"+w))),this._parser.registerEscHandler({intermediates:".",final:w},(()=>this.selectCharset("."+w))),this._parser.registerEscHandler({intermediates:"/",final:w},(()=>this.selectCharset("/"+w)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((w=>(this._logService.error("Parsing error: ",w),w))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new f.DcsHandler(((w,N)=>this.requestStatusString(w,N))))}_preserveStack(b,D,R,A){this._parseStack.paused=!0,this._parseStack.cursorStartX=b,this._parseStack.cursorStartY=D,this._parseStack.decodedLength=R,this._parseStack.position=A}_logSlowResolvingAsync(b){this._logService.logLevel<=p.LogLevelEnum.WARN&&Promise.race([b,new Promise(((D,R)=>setTimeout((()=>R("#SLOW_TIMEOUT")),5e3)))]).catch((D=>{if(D!=="#SLOW_TIMEOUT")throw D;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(b,D){let R,A=this._activeBuffer.x,H=this._activeBuffer.y,q=0,X=this._parseStack.paused;if(X){if(R=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,D))return this._logSlowResolvingAsync(R),R;A=this._parseStack.cursorStartX,H=this._parseStack.cursorStartY,this._parseStack.paused=!1,b.length>k&&(q=this._parseStack.position+k)}if(this._logService.logLevel<=p.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof b=="string"?` "${b}"`:` "${Array.prototype.map.call(b,(w=>String.fromCharCode(w))).join("")}"`),typeof b=="string"?b.split("").map((w=>w.charCodeAt(0))):b),this._parseBuffer.length<b.length&&this._parseBuffer.length<k&&(this._parseBuffer=new Uint32Array(Math.min(b.length,k))),X||this._dirtyRowTracker.clearRange(),b.length>k)for(let w=q;w<b.length;w+=k){let N=w+k<b.length?w+k:b.length,F=typeof b=="string"?this._stringDecoder.decode(b.substring(w,N),this._parseBuffer):this._utf8Decoder.decode(b.subarray(w,N),this._parseBuffer);if(R=this._parser.parse(this._parseBuffer,F))return this._preserveStack(A,H,F,w),this._logSlowResolvingAsync(R),R}else if(!X){let w=typeof b=="string"?this._stringDecoder.decode(b,this._parseBuffer):this._utf8Decoder.decode(b,this._parseBuffer);if(R=this._parser.parse(this._parseBuffer,w))return this._preserveStack(A,H,w,0),this._logSlowResolvingAsync(R),R}this._activeBuffer.x===A&&this._activeBuffer.y===H||this._onCursorMove.fire();let Y=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),I=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);I<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(I,this._bufferService.rows-1),Math.min(Y,this._bufferService.rows-1))}print(b,D,R){let A,H,q=this._charsetService.charset,X=this._optionsService.rawOptions.screenReaderMode,Y=this._bufferService.cols,I=this._coreService.decPrivateModes.wraparound,w=this._coreService.modes.insertMode,N=this._curAttrData,F=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&R-D>0&&F.getWidth(this._activeBuffer.x-1)===2&&F.setCellFromCodepoint(this._activeBuffer.x-1,0,1,N);let K=this._parser.precedingJoinState;for(let V=D;V<R;++V){if(A=b[V],A<127&&q){let ne=q[String.fromCharCode(A)];ne&&(A=ne.charCodeAt(0))}let ie=this._unicodeService.charProperties(A,K);H=g.UnicodeService.extractWidth(ie);let ce=g.UnicodeService.extractShouldJoin(ie),le=ce?g.UnicodeService.extractWidth(K):0;if(K=ie,X&&this._onA11yChar.fire((0,l.stringFromCodePoint)(A)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+H-le>Y){if(I){let ne=F,G=this._activeBuffer.x-le;for(this._activeBuffer.x=le,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),F=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),le>0&&F instanceof i.BufferLine&&F.copyCellsFrom(ne,G,0,le,!1);G<Y;)ne.setCellFromCodepoint(G++,0,1,N)}else if(this._activeBuffer.x=Y-1,H===2)continue}if(ce&&this._activeBuffer.x){let ne=F.getWidth(this._activeBuffer.x-1)?1:2;F.addCodepointToCell(this._activeBuffer.x-ne,A,H);for(let G=H-le;--G>=0;)F.setCellFromCodepoint(this._activeBuffer.x++,0,0,N)}else if(w&&(F.insertCells(this._activeBuffer.x,H-le,this._activeBuffer.getNullCell(N)),F.getWidth(Y-1)===2&&F.setCellFromCodepoint(Y-1,e.NULL_CELL_CODE,e.NULL_CELL_WIDTH,N)),F.setCellFromCodepoint(this._activeBuffer.x++,A,H,N),H>0)for(;--H;)F.setCellFromCodepoint(this._activeBuffer.x++,0,0,N)}this._parser.precedingJoinState=K,this._activeBuffer.x<Y&&R-D>0&&F.getWidth(this._activeBuffer.x)===0&&!F.hasContent(this._activeBuffer.x)&&F.setCellFromCodepoint(this._activeBuffer.x,0,1,N),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(b,D){return b.final!=="t"||b.prefix||b.intermediates?this._parser.registerCsiHandler(b,D):this._parser.registerCsiHandler(b,(R=>!E(R.params[0],this._optionsService.rawOptions.windowOptions)||D(R)))}registerDcsHandler(b,D){return this._parser.registerDcsHandler(b,new f.DcsHandler(D))}registerEscHandler(b,D){return this._parser.registerEscHandler(b,D)}registerOscHandler(b,D){return this._parser.registerOscHandler(b,new v.OscHandler(D))}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(){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&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);b.hasWidth(this._activeBuffer.x)&&!b.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-b),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(b=this._bufferService.cols-1){this._activeBuffer.x=Math.min(b,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(b,D){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=b,this._activeBuffer.y=this._activeBuffer.scrollTop+D):(this._activeBuffer.x=b,this._activeBuffer.y=D),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(b,D){this._restrictCursor(),this._setCursor(this._activeBuffer.x+b,this._activeBuffer.y+D)}cursorUp(b){let D=this._activeBuffer.y-this._activeBuffer.scrollTop;return D>=0?this._moveCursor(0,-Math.min(D,b.params[0]||1)):this._moveCursor(0,-(b.params[0]||1)),!0}cursorDown(b){let D=this._activeBuffer.scrollBottom-this._activeBuffer.y;return D>=0?this._moveCursor(0,Math.min(D,b.params[0]||1)):this._moveCursor(0,b.params[0]||1),!0}cursorForward(b){return this._moveCursor(b.params[0]||1,0),!0}cursorBackward(b){return this._moveCursor(-(b.params[0]||1),0),!0}cursorNextLine(b){return this.cursorDown(b),this._activeBuffer.x=0,!0}cursorPrecedingLine(b){return this.cursorUp(b),this._activeBuffer.x=0,!0}cursorCharAbsolute(b){return this._setCursor((b.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(b){return this._setCursor(b.length>=2?(b.params[1]||1)-1:0,(b.params[0]||1)-1),!0}charPosAbsolute(b){return this._setCursor((b.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(b){return this._moveCursor(b.params[0]||1,0),!0}linePosAbsolute(b){return this._setCursor(this._activeBuffer.x,(b.params[0]||1)-1),!0}vPositionRelative(b){return this._moveCursor(0,b.params[0]||1),!0}hVPosition(b){return this.cursorPosition(b),!0}tabClear(b){let D=b.params[0];return D===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:D===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(b){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=b.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(b){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=b.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(b){let D=b.params[0];return D===1&&(this._curAttrData.bg|=536870912),D!==2&&D!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(b,D,R,A=!1,H=!1){let q=this._activeBuffer.lines.get(this._activeBuffer.ybase+b);q.replaceCells(D,R,this._activeBuffer.getNullCell(this._eraseAttrData()),H),A&&(q.isWrapped=!1)}_resetBufferLine(b,D=!1){let R=this._activeBuffer.lines.get(this._activeBuffer.ybase+b);R&&(R.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),D),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+b),R.isWrapped=!1)}eraseInDisplay(b,D=!1){let R;switch(this._restrictCursor(this._bufferService.cols),b.params[0]){case 0:for(R=this._activeBuffer.y,this._dirtyRowTracker.markDirty(R),this._eraseInBufferLine(R++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,D);R<this._bufferService.rows;R++)this._resetBufferLine(R,D);this._dirtyRowTracker.markDirty(R);break;case 1:for(R=this._activeBuffer.y,this._dirtyRowTracker.markDirty(R),this._eraseInBufferLine(R,0,this._activeBuffer.x+1,!0,D),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(R+1).isWrapped=!1);R--;)this._resetBufferLine(R,D);this._dirtyRowTracker.markDirty(0);break;case 2:for(R=this._bufferService.rows,this._dirtyRowTracker.markDirty(R-1);R--;)this._resetBufferLine(R,D);this._dirtyRowTracker.markDirty(0);break;case 3:let A=this._activeBuffer.lines.length-this._bufferService.rows;A>0&&(this._activeBuffer.lines.trimStart(A),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-A,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-A,0),this._onScroll.fire(0))}return!0}eraseInLine(b,D=!1){switch(this._restrictCursor(this._bufferService.cols),b.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,D);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,D);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,D)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(b){this._restrictCursor();let D=b.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let R=this._activeBuffer.ybase+this._activeBuffer.y,A=this._bufferService.rows-1-this._activeBuffer.scrollBottom,H=this._bufferService.rows-1+this._activeBuffer.ybase-A+1;for(;D--;)this._activeBuffer.lines.splice(H-1,1),this._activeBuffer.lines.splice(R,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(b){this._restrictCursor();let D=b.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let R=this._activeBuffer.ybase+this._activeBuffer.y,A;for(A=this._bufferService.rows-1-this._activeBuffer.scrollBottom,A=this._bufferService.rows-1+this._activeBuffer.ybase-A;D--;)this._activeBuffer.lines.splice(R,1),this._activeBuffer.lines.splice(A,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(b){this._restrictCursor();let D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.insertCells(this._activeBuffer.x,b.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(b){this._restrictCursor();let D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.deleteCells(this._activeBuffer.x,b.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(b){let D=b.params[0]||1;for(;D--;)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(b){let D=b.params[0]||1;for(;D--;)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(i.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let D=b.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){let A=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);A.deleteCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData())),A.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let D=b.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){let A=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);A.insertCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData())),A.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let D=b.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){let A=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);A.insertCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData())),A.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let D=b.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){let A=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);A.deleteCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData())),A.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(b){this._restrictCursor();let D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(b.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(b){let D=this._parser.precedingJoinState;if(!D)return!0;let R=b.params[0]||1,A=g.UnicodeService.extractWidth(D),H=this._activeBuffer.x-A,q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(H),X=new Uint32Array(q.length*R),Y=0;for(let w=0;w<q.length;){let N=q.codePointAt(w)||0;X[Y++]=N,w+=N>65535?2:1}let I=Y;for(let w=1;w<R;++w)X.copyWithin(I,0,Y),I+=Y;return this.print(X,0,I),!0}sendDeviceAttributesPrimary(b){return b.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(o.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(o.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(b){return b.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(o.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(o.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(b.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(o.C0.ESC+"[>83;40003;0c")),!0}_is(b){return(this._optionsService.rawOptions.termName+"").indexOf(b)===0}setMode(b){for(let D=0;D<b.length;D++)switch(b.params[D]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(b){for(let D=0;D<b.length;D++)switch(b.params[D]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,a.DEFAULT_CHARSET),this._charsetService.setgCharset(1,a.DEFAULT_CHARSET),this._charsetService.setgCharset(2,a.DEFAULT_CHARSET),this._charsetService.setgCharset(3,a.DEFAULT_CHARSET);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(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(b){for(let D=0;D<b.length;D++)switch(b.params[D]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(b){for(let D=0;D<b.length;D++)switch(b.params[D]){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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),b.params[D]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(b,D){let R=this._coreService.decPrivateModes,{activeProtocol:A,activeEncoding:H}=this._coreMouseService,q=this._coreService,{buffers:X,cols:Y}=this._bufferService,{active:I,alt:w}=X,N=this._optionsService.rawOptions,F=ce=>ce?1:2,K=b.params[0];return V=K,ie=D?K===2?4:K===4?F(q.modes.insertMode):K===12?3:K===20?F(N.convertEol):0:K===1?F(R.applicationCursorKeys):K===3?N.windowOptions.setWinLines?Y===80?2:Y===132?1:0:0:K===6?F(R.origin):K===7?F(R.wraparound):K===8?3:K===9?F(A==="X10"):K===12?F(N.cursorBlink):K===25?F(!q.isCursorHidden):K===45?F(R.reverseWraparound):K===66?F(R.applicationKeypad):K===67?4:K===1e3?F(A==="VT200"):K===1002?F(A==="DRAG"):K===1003?F(A==="ANY"):K===1004?F(R.sendFocus):K===1005?4:K===1006?F(H==="SGR"):K===1015?4:K===1016?F(H==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?F(I===w):K===2004?F(R.bracketedPasteMode):0,q.triggerDataEvent(`${o.C0.ESC}[${D?"":"?"}${V};${ie}$y`),!0;var V,ie}_updateAttrColor(b,D,R,A,H){return D===2?(b|=50331648,b&=-16777216,b|=d.AttributeData.fromColorRGB([R,A,H])):D===5&&(b&=-50331904,b|=33554432|255&R),b}_extractColor(b,D,R){let A=[0,0,-1,0,0,0],H=0,q=0;do{if(A[q+H]=b.params[D+q],b.hasSubParams(D+q)){let X=b.getSubParams(D+q),Y=0;do A[1]===5&&(H=1),A[q+Y+1+H]=X[Y];while(++Y<X.length&&Y+q+1+H<A.length);break}if(A[1]===5&&q+H>=2||A[1]===2&&q+H>=5)break;A[1]&&(H=1)}while(++q+D<b.length&&q+H<A.length);for(let X=2;X<A.length;++X)A[X]===-1&&(A[X]=0);switch(A[0]){case 38:R.fg=this._updateAttrColor(R.fg,A[1],A[3],A[4],A[5]);break;case 48:R.bg=this._updateAttrColor(R.bg,A[1],A[3],A[4],A[5]);break;case 58:R.extended=R.extended.clone(),R.extended.underlineColor=this._updateAttrColor(R.extended.underlineColor,A[1],A[3],A[4],A[5])}return q}_processUnderline(b,D){D.extended=D.extended.clone(),(!~b||b>5)&&(b=1),D.extended.underlineStyle=b,D.fg|=268435456,b===0&&(D.fg&=-268435457),D.updateExtended()}_processSGR0(b){b.fg=i.DEFAULT_ATTR_DATA.fg,b.bg=i.DEFAULT_ATTR_DATA.bg,b.extended=b.extended.clone(),b.extended.underlineStyle=0,b.extended.underlineColor&=-67108864,b.updateExtended()}charAttributes(b){if(b.length===1&&b.params[0]===0)return this._processSGR0(this._curAttrData),!0;let D=b.length,R,A=this._curAttrData;for(let H=0;H<D;H++)R=b.params[H],R>=30&&R<=37?(A.fg&=-50331904,A.fg|=16777216|R-30):R>=40&&R<=47?(A.bg&=-50331904,A.bg|=16777216|R-40):R>=90&&R<=97?(A.fg&=-50331904,A.fg|=16777224|R-90):R>=100&&R<=107?(A.bg&=-50331904,A.bg|=16777224|R-100):R===0?this._processSGR0(A):R===1?A.fg|=134217728:R===3?A.bg|=67108864:R===4?(A.fg|=268435456,this._processUnderline(b.hasSubParams(H)?b.getSubParams(H)[0]:1,A)):R===5?A.fg|=536870912:R===7?A.fg|=67108864:R===8?A.fg|=1073741824:R===9?A.fg|=2147483648:R===2?A.bg|=134217728:R===21?this._processUnderline(2,A):R===22?(A.fg&=-134217729,A.bg&=-134217729):R===23?A.bg&=-67108865:R===24?(A.fg&=-268435457,this._processUnderline(0,A)):R===25?A.fg&=-536870913:R===27?A.fg&=-67108865:R===28?A.fg&=-1073741825:R===29?A.fg&=2147483647:R===39?(A.fg&=-67108864,A.fg|=16777215&i.DEFAULT_ATTR_DATA.fg):R===49?(A.bg&=-67108864,A.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):R===38||R===48||R===58?H+=this._extractColor(b,H,A):R===53?A.bg|=1073741824:R===55?A.bg&=-1073741825:R===59?(A.extended=A.extended.clone(),A.extended.underlineColor=-1,A.updateExtended()):R===100?(A.fg&=-67108864,A.fg|=16777215&i.DEFAULT_ATTR_DATA.fg,A.bg&=-67108864,A.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",R);return!0}deviceStatus(b){switch(b.params[0]){case 5:this._coreService.triggerDataEvent(`${o.C0.ESC}[0n`);break;case 6:let D=this._activeBuffer.y+1,R=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[${D};${R}R`)}return!0}deviceStatusPrivate(b){if(b.params[0]===6){let D=this._activeBuffer.y+1,R=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[?${D};${R}R`)}return!0}softReset(b){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=i.DEFAULT_ATTR_DATA.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(b){let D=b.params[0]||1;switch(D){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}let R=D%2==1;return this._optionsService.options.cursorBlink=R,!0}setScrollRegion(b){let D=b.params[0]||1,R;return(b.length<2||(R=b.params[1])>this._bufferService.rows||R===0)&&(R=this._bufferService.rows),R>D&&(this._activeBuffer.scrollTop=D-1,this._activeBuffer.scrollBottom=R-1,this._setCursor(0,0)),!0}windowOptions(b){if(!E(b.params[0],this._optionsService.rawOptions.windowOptions))return!0;let D=b.length>1?b.params[1]:0;switch(b.params[0]){case 14:D!==2&&this._onRequestWindowsOptionsReport.fire(C.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(C.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${o.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:D!==0&&D!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),D!==0&&D!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:D!==0&&D!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),D!==0&&D!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(b){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(b){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(b){return this._windowTitle=b,this._onTitleChange.fire(b),!0}setIconName(b){return this._iconName=b,!0}setOrReportIndexedColor(b){let D=[],R=b.split(";");for(;R.length>1;){let A=R.shift(),H=R.shift();if(/^\d+$/.exec(A)){let q=parseInt(A);if(U(q))if(H==="?")D.push({type:0,index:q});else{let X=(0,m.parseColor)(H);X&&D.push({type:1,index:q,color:X})}}}return D.length&&this._onColor.fire(D),!0}setHyperlink(b){let D=b.split(";");return!(D.length<2)&&(D[1]?this._createHyperlink(D[0],D[1]):!D[0]&&this._finishHyperlink())}_createHyperlink(b,D){this._getCurrentLinkId()&&this._finishHyperlink();let R=b.split(":"),A,H=R.findIndex((q=>q.startsWith("id=")));return H!==-1&&(A=R[H].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:A,uri:D}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(b,D){let R=b.split(";");for(let A=0;A<R.length&&!(D>=this._specialColors.length);++A,++D)if(R[A]==="?")this._onColor.fire([{type:0,index:this._specialColors[D]}]);else{let H=(0,m.parseColor)(R[A]);H&&this._onColor.fire([{type:1,index:this._specialColors[D],color:H}])}return!0}setOrReportFgColor(b){return this._setOrReportSpecialColor(b,0)}setOrReportBgColor(b){return this._setOrReportSpecialColor(b,1)}setOrReportCursorColor(b){return this._setOrReportSpecialColor(b,2)}restoreIndexedColor(b){if(!b)return this._onColor.fire([{type:2}]),!0;let D=[],R=b.split(";");for(let A=0;A<R.length;++A)if(/^\d+$/.exec(R[A])){let H=parseInt(R[A]);U(H)&&D.push({type:2,index:H})}return D.length&&this._onColor.fire(D),!0}restoreFgColor(b){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(b){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(b){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,a.DEFAULT_CHARSET),!0}selectCharset(b){return b.length!==2?(this.selectDefaultCharset(),!0):(b[0]==="/"||this._charsetService.setgCharset(L[b[0]],a.CHARSETS[b[1]]||a.DEFAULT_CHARSET),!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 b=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,b,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=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(b){return this._charsetService.setgLevel(b),!0}screenAlignmentPattern(){let b=new s.CellData;b.content=4194373,b.fg=this._curAttrData.fg,b.bg=this._curAttrData.bg,this._setCursor(0,0);for(let D=0;D<this._bufferService.rows;++D){let R=this._activeBuffer.ybase+this._activeBuffer.y+D,A=this._activeBuffer.lines.get(R);A&&(A.fill(b),A.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(b,D){let R=this._bufferService.buffer,A=this._optionsService.rawOptions;return(H=>(this._coreService.triggerDataEvent(`${o.C0.ESC}${H}${o.C0.ESC}\\`),!0))(b==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:b==='"p'?'P1$r61;1"p':b==="r"?`P1$r${R.scrollTop+1};${R.scrollBottom+1}r`:b==="m"?"P1$r0m":b===" q"?`P1$r${{block:2,underline:4,bar:6}[A.cursorStyle]-(A.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(b,D){this._dirtyRowTracker.markRangeDirty(b,D)}}r.InputHandler=z;let j=class{constructor($){this._bufferService=$,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty($){$<this.start?this.start=$:$>this.end&&(this.end=$)}markRangeDirty($,b){$>b&&(B=$,$=b,b=B),$<this.start&&(this.start=$),b>this.end&&(this.end=b)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function U($){return 0<=$&&$<256}j=h([u(0,p.IBufferService)],j)},844:(x,r)=>{function n(h){for(let u of h)u.dispose();h.length=0}Object.defineProperty(r,"__esModule",{value:!0}),r.getDisposeArrayDisposable=r.disposeArray=r.toDisposable=r.MutableDisposable=r.Disposable=void 0,r.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){let u=this._disposables.indexOf(h);u!==-1&&this._disposables.splice(u,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){this._isDisposed||h===this._value||(this._value?.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},r.toDisposable=function(h){return{dispose:h}},r.disposeArray=n,r.getDisposeArrayDisposable=function(h){return{dispose:()=>n(h)}}},1505:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FourKeyMap=r.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(u,o,a){this._data[u]||(this._data[u]={}),this._data[u][o]=a}get(u,o){return this._data[u]?this._data[u][o]:void 0}clear(){this._data={}}}r.TwoKeyMap=n,r.FourKeyMap=class{constructor(){this._data=new n}set(h,u,o,a,c){this._data.get(h,u)||this._data.set(h,u,new n),this._data.get(h,u).set(o,a,c)}get(h,u,o,a){return this._data.get(h,u)?.get(o,a)}clear(){this._data.clear()}}},6114:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isChromeOS=r.isLinux=r.isWindows=r.isIphone=r.isIpad=r.isMac=r.getSafariVersion=r.isSafari=r.isLegacyEdge=r.isFirefox=r.isNode=void 0,r.isNode=typeof process<"u"&&"title"in process;let n=r.isNode?"node":navigator.userAgent,h=r.isNode?"node":navigator.platform;r.isFirefox=n.includes("Firefox"),r.isLegacyEdge=n.includes("Edge"),r.isSafari=/^((?!chrome|android).)*safari/i.test(n),r.getSafariVersion=function(){if(!r.isSafari)return 0;let u=n.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},r.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(h),r.isIpad=h==="iPad",r.isIphone=h==="iPhone",r.isWindows=["Windows","Win16","Win32","WinCE"].includes(h),r.isLinux=h.indexOf("Linux")>=0,r.isChromeOS=/\bCrOS\b/.test(n)},6106:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SortedList=void 0;let n=0;r.SortedList=class{constructor(h){this._getKey=h,this._array=[]}clear(){this._array.length=0}insert(h){this._array.length!==0?(n=this._search(this._getKey(h)),this._array.splice(n,0,h)):this._array.push(h)}delete(h){if(this._array.length===0)return!1;let u=this._getKey(h);if(u===void 0||(n=this._search(u),n===-1)||this._getKey(this._array[n])!==u)return!1;do if(this._array[n]===h)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===u);return!1}*getKeyIterator(h){if(this._array.length!==0&&(n=this._search(h),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===h))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===h)}forEachByKey(h,u){if(this._array.length!==0&&(n=this._search(h),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===h))do u(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===h)}values(){return[...this._array].values()}_search(h){let u=0,o=this._array.length-1;for(;o>=u;){let a=u+o>>1,c=this._getKey(this._array[a]);if(c>h)o=a-1;else{if(!(c<h)){for(;a>0&&this._getKey(this._array[a-1])===h;)a--;return a}u=a+1}}return u}}},7226:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DebouncedIdleTask=r.IdleTaskQueue=r.PriorityTaskQueue=void 0;let h=n(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(c){this._tasks.push(c),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(c){this._idleCallback=void 0;let _=0,l=0,i=c.timeRemaining(),t=0;for(;this._i<this._tasks.length;){if(_=Date.now(),this._tasks[this._i]()||this._i++,_=Math.max(1,Date.now()-_),l=Math.max(_,l),t=c.timeRemaining(),1.5*l>t)return i-_<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-_))}ms`),void this._start();i=t}this.clear()}}class o extends u{_requestCallback(c){return setTimeout((()=>c(this._createDeadline(16))))}_cancelCallback(c){clearTimeout(c)}_createDeadline(c){let _=Date.now()+c;return{timeRemaining:()=>Math.max(0,_-Date.now())}}}r.PriorityTaskQueue=o,r.IdleTaskQueue=!h.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(a){return requestIdleCallback(a)}_cancelCallback(a){cancelIdleCallback(a)}}:o,r.DebouncedIdleTask=class{constructor(){this._queue=new r.IdleTaskQueue}set(a){this._queue.clear(),this._queue.enqueue(a)}flush(){this._queue.flush()}}},9282:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.updateWindowsModeWrappedState=void 0;let h=n(643);r.updateWindowsModeWrappedState=function(u){let o=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),a=o?.get(u.cols-1),c=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);c&&a&&(c.isWrapped=a[h.CHAR_DATA_CODE_INDEX]!==h.NULL_CELL_CODE&&a[h.CHAR_DATA_CODE_INDEX]!==h.WHITESPACE_CELL_CODE)}},3734:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedAttrs=r.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new h}static toColorRGB(o){return[o>>>16&255,o>>>8&255,255&o]}static fromColorRGB(o){return(255&o[0])<<16|(255&o[1])<<8|255&o[2]}clone(){let o=new n;return o.fg=this.fg,o.bg=this.bg,o.extended=this.extended.clone(),o}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}r.AttributeData=n;class h{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(o){this._ext=o}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(o){this._ext&=-469762049,this._ext|=o<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(o){this._ext&=-67108864,this._ext|=67108863&o}get urlId(){return this._urlId}set urlId(o){this._urlId=o}get underlineVariantOffset(){let o=(3758096384&this._ext)>>29;return o<0?4294967288^o:o}set underlineVariantOffset(o){this._ext&=536870911,this._ext|=o<<29&3758096384}constructor(o=0,a=0){this._ext=0,this._urlId=0,this._ext=o,this._urlId=a}clone(){return new h(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}r.ExtendedAttrs=h},9092:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Buffer=r.MAX_BUFFER_SIZE=void 0;let h=n(6349),u=n(7226),o=n(3734),a=n(8437),c=n(4634),_=n(511),l=n(643),i=n(4863),t=n(7116);r.MAX_BUFFER_SIZE=4294967295,r.Buffer=class{constructor(e,s,d){this._hasScrollback=e,this._optionsService=s,this._bufferService=d,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=a.DEFAULT_ATTR_DATA.clone(),this.savedCharset=t.DEFAULT_CHARSET,this.markers=[],this._nullCell=_.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]),this._whitespaceCell=_.CellData.fromCharData([0,l.WHITESPACE_CELL_CHAR,l.WHITESPACE_CELL_WIDTH,l.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new u.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new h.CircularList(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 o.ExtendedAttrs),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 o.ExtendedAttrs),this._whitespaceCell}getBlankLine(e,s){return new a.BufferLine(this._bufferService.cols,this.getNullCell(e),s)}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 s=e+this._optionsService.rawOptions.scrollback;return s>r.MAX_BUFFER_SIZE?r.MAX_BUFFER_SIZE:s}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=a.DEFAULT_ATTR_DATA);let s=this._rows;for(;s--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,s){let d=this.getNullCell(a.DEFAULT_ATTR_DATA),p=0,g=this._getCorrectBufferLength(s);if(g>this.lines.maxLength&&(this.lines.maxLength=g),this.lines.length>0){if(this._cols<e)for(let f=0;f<this.lines.length;f++)p+=+this.lines.get(f).resize(e,d);let v=0;if(this._rows<s)for(let f=this._rows;f<s;f++)this.lines.length<s+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new a.BufferLine(e,d)):this.ybase>0&&this.lines.length<=this.ybase+this.y+v+1?(this.ybase--,v++,this.ydisp>0&&this.ydisp--):this.lines.push(new a.BufferLine(e,d)));else for(let f=this._rows;f>s;f--)this.lines.length>s+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(g<this.lines.maxLength){let f=this.lines.length-g;f>0&&(this.lines.trimStart(f),this.ybase=Math.max(this.ybase-f,0),this.ydisp=Math.max(this.ydisp-f,0),this.savedY=Math.max(this.savedY-f,0)),this.lines.maxLength=g}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,s-1),v&&(this.y+=v),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=s-1,this._isReflowEnabled&&(this._reflow(e,s),this._cols>e))for(let v=0;v<this.lines.length;v++)p+=+this.lines.get(v).resize(e,d);this._cols=e,this._rows=s,this._memoryCleanupQueue.clear(),p>.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 s=0;for(;this._memoryCleanupPosition<this.lines.length;)if(s+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),s>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,s){this._cols!==e&&(e>this._cols?this._reflowLarger(e,s):this._reflowSmaller(e,s))}_reflowLarger(e,s){let d=(0,c.reflowLargerGetLinesToRemove)(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(a.DEFAULT_ATTR_DATA));if(d.length>0){let p=(0,c.reflowLargerCreateNewLayout)(this.lines,d);(0,c.reflowLargerApplyNewLayout)(this.lines,p.layout),this._reflowLargerAdjustViewport(e,s,p.countRemoved)}}_reflowLargerAdjustViewport(e,s,d){let p=this.getNullCell(a.DEFAULT_ATTR_DATA),g=d;for(;g-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<s&&this.lines.push(new a.BufferLine(e,p))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-d,0)}_reflowSmaller(e,s){let d=this.getNullCell(a.DEFAULT_ATTR_DATA),p=[],g=0;for(let v=this.lines.length-1;v>=0;v--){let f=this.lines.get(v);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let m=[f];for(;f.isWrapped&&v>0;)f=this.lines.get(--v),m.unshift(f);let L=this.ybase+this.y;if(L>=v&&L<v+m.length)continue;let k=m[m.length-1].getTrimmedLength(),E=(0,c.reflowSmallerGetNewLineLengths)(m,this._cols,e),C=E.length-m.length,B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+C):Math.max(0,this.lines.length-this.lines.maxLength+C);let z=[];for(let R=0;R<C;R++){let A=this.getBlankLine(a.DEFAULT_ATTR_DATA,!0);z.push(A)}z.length>0&&(p.push({start:v+m.length+g,newLines:z}),g+=z.length),m.push(...z);let j=E.length-1,U=E[j];U===0&&(j--,U=E[j]);let $=m.length-C-1,b=k;for(;$>=0;){let R=Math.min(b,U);if(m[j]===void 0)break;if(m[j].copyCellsFrom(m[$],b-R,U-R,R,!0),U-=R,U===0&&(j--,U=E[j]),b-=R,b===0){$--;let A=Math.max($,0);b=(0,c.getWrappedLineTrimmedLength)(m,A,this._cols)}}for(let R=0;R<m.length;R++)E[R]<e&&m[R].setCell(E[R],d);let D=C-B;for(;D-- >0;)this.ybase===0?this.y<s-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+g)-s&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+C,this.ybase+s-1)}if(p.length>0){let v=[],f=[];for(let j=0;j<this.lines.length;j++)f.push(this.lines.get(j));let m=this.lines.length,L=m-1,k=0,E=p[k];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+g);let C=0;for(let j=Math.min(this.lines.maxLength-1,m+g-1);j>=0;j--)if(E&&E.start>L+C){for(let U=E.newLines.length-1;U>=0;U--)this.lines.set(j--,E.newLines[U]);j++,v.push({index:L+1,amount:E.newLines.length}),C+=E.newLines.length,E=p[++k]}else this.lines.set(j,f[L--]);let B=0;for(let j=v.length-1;j>=0;j--)v[j].index+=B,this.lines.onInsertEmitter.fire(v[j]),B+=v[j].amount;let z=Math.max(0,m+g-this.lines.maxLength);z>0&&this.lines.onTrimEmitter.fire(z)}}translateBufferLineToString(e,s,d=0,p){let g=this.lines.get(e);return g?g.translateToString(s,d,p):""}getWrappedRangeForLine(e){let s=e,d=e;for(;s>0&&this.lines.get(s).isWrapped;)s--;for(;d+1<this.lines.length&&this.lines.get(d+1).isWrapped;)d++;return{first:s,last:d}}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 s=0;s<this.markers.length;s++)this.markers[s].line===e&&(this.markers[s].dispose(),this.markers.splice(s--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose(),this.markers.splice(e--,1);this._isClearing=!1}addMarker(e){let s=new i.Marker(e);return this.markers.push(s),s.register(this.lines.onTrim((d=>{s.line-=d,s.line<0&&s.dispose()}))),s.register(this.lines.onInsert((d=>{s.line>=d.index&&(s.line+=d.amount)}))),s.register(this.lines.onDelete((d=>{s.line>=d.index&&s.line<d.index+d.amount&&s.dispose(),s.line>d.index&&(s.line-=d.amount)}))),s.register(s.onDispose((()=>this._removeMarker(s)))),s}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}}},8437:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLine=r.DEFAULT_ATTR_DATA=void 0;let h=n(3734),u=n(511),o=n(643),a=n(482);r.DEFAULT_ATTR_DATA=Object.freeze(new h.AttributeData);let c=0;class _{constructor(i,t,e=!1){this.isWrapped=e,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*i);let s=t||u.CellData.fromCharData([0,o.NULL_CELL_CHAR,o.NULL_CELL_WIDTH,o.NULL_CELL_CODE]);for(let d=0;d<i;++d)this.setCell(d,s);this.length=i}get(i){let t=this._data[3*i+0],e=2097151&t;return[this._data[3*i+1],2097152&t?this._combined[i]:e?(0,a.stringFromCodePoint)(e):"",t>>22,2097152&t?this._combined[i].charCodeAt(this._combined[i].length-1):e]}set(i,t){this._data[3*i+1]=t[o.CHAR_DATA_ATTR_INDEX],t[o.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[i]=t[1],this._data[3*i+0]=2097152|i|t[o.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*i+0]=t[o.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[o.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(i){return this._data[3*i+0]>>22}hasWidth(i){return 12582912&this._data[3*i+0]}getFg(i){return this._data[3*i+1]}getBg(i){return this._data[3*i+2]}hasContent(i){return 4194303&this._data[3*i+0]}getCodePoint(i){let t=this._data[3*i+0];return 2097152&t?this._combined[i].charCodeAt(this._combined[i].length-1):2097151&t}isCombined(i){return 2097152&this._data[3*i+0]}getString(i){let t=this._data[3*i+0];return 2097152&t?this._combined[i]:2097151&t?(0,a.stringFromCodePoint)(2097151&t):""}isProtected(i){return 536870912&this._data[3*i+2]}loadCell(i,t){return c=3*i,t.content=this._data[c+0],t.fg=this._data[c+1],t.bg=this._data[c+2],2097152&t.content&&(t.combinedData=this._combined[i]),268435456&t.bg&&(t.extended=this._extendedAttrs[i]),t}setCell(i,t){2097152&t.content&&(this._combined[i]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[i]=t.extended),this._data[3*i+0]=t.content,this._data[3*i+1]=t.fg,this._data[3*i+2]=t.bg}setCellFromCodepoint(i,t,e,s){268435456&s.bg&&(this._extendedAttrs[i]=s.extended),this._data[3*i+0]=t|e<<22,this._data[3*i+1]=s.fg,this._data[3*i+2]=s.bg}addCodepointToCell(i,t,e){let s=this._data[3*i+0];2097152&s?this._combined[i]+=(0,a.stringFromCodePoint)(t):2097151&s?(this._combined[i]=(0,a.stringFromCodePoint)(2097151&s)+(0,a.stringFromCodePoint)(t),s&=-2097152,s|=2097152):s=t|4194304,e&&(s&=-12582913,s|=e<<22),this._data[3*i+0]=s}insertCells(i,t,e){if((i%=this.length)&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i-1,0,1,e),t<this.length-i){let s=new u.CellData;for(let d=this.length-i-t-1;d>=0;--d)this.setCell(i+t+d,this.loadCell(i+d,s));for(let d=0;d<t;++d)this.setCell(i+d,e)}else for(let s=i;s<this.length;++s)this.setCell(s,e);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,e)}deleteCells(i,t,e){if(i%=this.length,t<this.length-i){let s=new u.CellData;for(let d=0;d<this.length-i-t;++d)this.setCell(i+d,this.loadCell(i+t+d,s));for(let d=this.length-t;d<this.length;++d)this.setCell(d,e)}else for(let s=i;s<this.length;++s)this.setCell(s,e);i&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i-1,0,1,e),this.getWidth(i)!==0||this.hasContent(i)||this.setCellFromCodepoint(i,0,1,e)}replaceCells(i,t,e,s=!1){if(s)for(i&&this.getWidth(i-1)===2&&!this.isProtected(i-1)&&this.setCellFromCodepoint(i-1,0,1,e),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,e);i<t&&i<this.length;)this.isProtected(i)||this.setCell(i,e),i++;else for(i&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i-1,0,1,e),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,e);i<t&&i<this.length;)this.setCell(i++,e)}resize(i,t){if(i===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let e=3*i;if(i>this.length){if(this._data.buffer.byteLength>=4*e)this._data=new Uint32Array(this._data.buffer,0,e);else{let s=new Uint32Array(e);s.set(this._data),this._data=s}for(let s=this.length;s<i;++s)this.setCell(s,t)}else{this._data=this._data.subarray(0,e);let s=Object.keys(this._combined);for(let p=0;p<s.length;p++){let g=parseInt(s[p],10);g>=i&&delete this._combined[g]}let d=Object.keys(this._extendedAttrs);for(let p=0;p<d.length;p++){let g=parseInt(d[p],10);g>=i&&delete this._extendedAttrs[g]}}return this.length=i,4*e*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let i=new Uint32Array(this._data.length);return i.set(this._data),this._data=i,1}return 0}fill(i,t=!1){if(t)for(let e=0;e<this.length;++e)this.isProtected(e)||this.setCell(e,i);else{this._combined={},this._extendedAttrs={};for(let e=0;e<this.length;++e)this.setCell(e,i)}}copyFrom(i){this.length!==i.length?this._data=new Uint32Array(i._data):this._data.set(i._data),this.length=i.length,this._combined={};for(let t in i._combined)this._combined[t]=i._combined[t];this._extendedAttrs={};for(let t in i._extendedAttrs)this._extendedAttrs[t]=i._extendedAttrs[t];this.isWrapped=i.isWrapped}clone(){let i=new _(0);i._data=new Uint32Array(this._data),i.length=this.length;for(let t in this._combined)i._combined[t]=this._combined[t];for(let t in this._extendedAttrs)i._extendedAttrs[t]=this._extendedAttrs[t];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let i=this.length-1;i>=0;--i)if(4194303&this._data[3*i+0])return i+(this._data[3*i+0]>>22);return 0}getNoBgTrimmedLength(){for(let i=this.length-1;i>=0;--i)if(4194303&this._data[3*i+0]||50331648&this._data[3*i+2])return i+(this._data[3*i+0]>>22);return 0}copyCellsFrom(i,t,e,s,d){let p=i._data;if(d)for(let v=s-1;v>=0;v--){for(let f=0;f<3;f++)this._data[3*(e+v)+f]=p[3*(t+v)+f];268435456&p[3*(t+v)+2]&&(this._extendedAttrs[e+v]=i._extendedAttrs[t+v])}else for(let v=0;v<s;v++){for(let f=0;f<3;f++)this._data[3*(e+v)+f]=p[3*(t+v)+f];268435456&p[3*(t+v)+2]&&(this._extendedAttrs[e+v]=i._extendedAttrs[t+v])}let g=Object.keys(i._combined);for(let v=0;v<g.length;v++){let f=parseInt(g[v],10);f>=t&&(this._combined[f-t+e]=i._combined[f])}}translateToString(i,t,e,s){t=t??0,e=e??this.length,i&&(e=Math.min(e,this.getTrimmedLength())),s&&(s.length=0);let d="";for(;t<e;){let p=this._data[3*t+0],g=2097151&p,v=2097152&p?this._combined[t]:g?(0,a.stringFromCodePoint)(g):o.WHITESPACE_CELL_CHAR;if(d+=v,s)for(let f=0;f<v.length;++f)s.push(t);t+=p>>22||1}return s&&s.push(t),d}}r.BufferLine=_},4841:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getRangeLength=void 0,r.getRangeLength=function(n,h){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return h*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(x,r)=>{function n(h,u,o){if(u===h.length-1)return h[u].getTrimmedLength();let a=!h[u].hasContent(o-1)&&h[u].getWidth(o-1)===1,c=h[u+1].getWidth(0)===2;return a&&c?o-1:o}Object.defineProperty(r,"__esModule",{value:!0}),r.getWrappedLineTrimmedLength=r.reflowSmallerGetNewLineLengths=r.reflowLargerApplyNewLayout=r.reflowLargerCreateNewLayout=r.reflowLargerGetLinesToRemove=void 0,r.reflowLargerGetLinesToRemove=function(h,u,o,a,c){let _=[];for(let l=0;l<h.length-1;l++){let i=l,t=h.get(++i);if(!t.isWrapped)continue;let e=[h.get(l)];for(;i<h.length&&t.isWrapped;)e.push(t),t=h.get(++i);if(a>=l&&a<i){l+=e.length-1;continue}let s=0,d=n(e,s,u),p=1,g=0;for(;p<e.length;){let f=n(e,p,u),m=f-g,L=o-d,k=Math.min(m,L);e[s].copyCellsFrom(e[p],g,d,k,!1),d+=k,d===o&&(s++,d=0),g+=k,g===f&&(p++,g=0),d===0&&s!==0&&e[s-1].getWidth(o-1)===2&&(e[s].copyCellsFrom(e[s-1],o-1,d++,1,!1),e[s-1].setCell(o-1,c))}e[s].replaceCells(d,o,c);let v=0;for(let f=e.length-1;f>0&&(f>s||e[f].getTrimmedLength()===0);f--)v++;v>0&&(_.push(l+e.length-v),_.push(v)),l+=e.length-1}return _},r.reflowLargerCreateNewLayout=function(h,u){let o=[],a=0,c=u[a],_=0;for(let l=0;l<h.length;l++)if(c===l){let i=u[++a];h.onDeleteEmitter.fire({index:l-_,amount:i}),l+=i-1,_+=i,c=u[++a]}else o.push(l);return{layout:o,countRemoved:_}},r.reflowLargerApplyNewLayout=function(h,u){let o=[];for(let a=0;a<u.length;a++)o.push(h.get(u[a]));for(let a=0;a<o.length;a++)h.set(a,o[a]);h.length=u.length},r.reflowSmallerGetNewLineLengths=function(h,u,o){let a=[],c=h.map(((t,e)=>n(h,e,u))).reduce(((t,e)=>t+e)),_=0,l=0,i=0;for(;i<c;){if(c-i<o){a.push(c-i);break}_+=o;let t=n(h,l,u);_>t&&(_-=t,l++);let e=h[l].getWidth(_-1)===2;e&&_--;let s=e?o-1:o;a.push(s),i+=s}return a},r.getWrappedLineTrimmedLength=n},5295:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferSet=void 0;let h=n(8460),u=n(844),o=n(9092);class a extends u.Disposable{constructor(_,l){super(),this._optionsService=_,this._bufferService=l,this._onBufferActivate=this.register(new h.EventEmitter),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.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new o.Buffer(!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(_){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(_),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(_,l){this._normal.resize(_,l),this._alt.resize(_,l),this.setupTabStops(_)}setupTabStops(_){this._normal.setupTabStops(_),this._alt.setupTabStops(_)}}r.BufferSet=a},511:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CellData=void 0;let h=n(482),u=n(643),o=n(3734);class a extends o.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new o.ExtendedAttrs,this.combinedData=""}static fromCharData(_){let l=new a;return l.setFromCharData(_),l}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,h.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(_){this.fg=_[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let l=!1;if(_[u.CHAR_DATA_CHAR_INDEX].length>2)l=!0;else if(_[u.CHAR_DATA_CHAR_INDEX].length===2){let i=_[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=i&&i<=56319){let t=_[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=t&&t<=57343?this.content=1024*(i-55296)+t-56320+65536|_[u.CHAR_DATA_WIDTH_INDEX]<<22:l=!0}else l=!0}else this.content=_[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|_[u.CHAR_DATA_WIDTH_INDEX]<<22;l&&(this.combinedData=_[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|_[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.CellData=a},643:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WHITESPACE_CELL_CODE=r.WHITESPACE_CELL_WIDTH=r.WHITESPACE_CELL_CHAR=r.NULL_CELL_CODE=r.NULL_CELL_WIDTH=r.NULL_CELL_CHAR=r.CHAR_DATA_CODE_INDEX=r.CHAR_DATA_WIDTH_INDEX=r.CHAR_DATA_CHAR_INDEX=r.CHAR_DATA_ATTR_INDEX=r.DEFAULT_EXT=r.DEFAULT_ATTR=r.DEFAULT_COLOR=void 0,r.DEFAULT_COLOR=0,r.DEFAULT_ATTR=256|r.DEFAULT_COLOR<<9,r.DEFAULT_EXT=0,r.CHAR_DATA_ATTR_INDEX=0,r.CHAR_DATA_CHAR_INDEX=1,r.CHAR_DATA_WIDTH_INDEX=2,r.CHAR_DATA_CODE_INDEX=3,r.NULL_CELL_CHAR="",r.NULL_CELL_WIDTH=1,r.NULL_CELL_CODE=0,r.WHITESPACE_CELL_CHAR=" ",r.WHITESPACE_CELL_WIDTH=1,r.WHITESPACE_CELL_CODE=32},4863:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Marker=void 0;let h=n(8460),u=n(844);class o{get id(){return this._id}constructor(c){this.line=c,this.isDisposed=!1,this._disposables=[],this._id=o._nextId++,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,u.disposeArray)(this._disposables),this._disposables.length=0)}register(c){return this._disposables.push(c),c}}r.Marker=o,o._nextId=1},7116:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DEFAULT_CHARSET=r.CHARSETS=void 0,r.CHARSETS={},r.DEFAULT_CHARSET=r.CHARSETS.B,r.CHARSETS[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"},r.CHARSETS.A={"#":"\xA3"},r.CHARSETS.B=void 0,r.CHARSETS[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"},r.CHARSETS.C=r.CHARSETS[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},r.CHARSETS.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"},r.CHARSETS.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"},r.CHARSETS.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"},r.CHARSETS.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"},r.CHARSETS.E=r.CHARSETS[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"},r.CHARSETS.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"},r.CHARSETS.H=r.CHARSETS[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},r.CHARSETS["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"}},2584:(x,r)=>{var n,h,u;Object.defineProperty(r,"__esModule",{value:!0}),r.C1_ESCAPED=r.C1=r.C0=void 0,(function(o){o.NUL="\0",o.SOH="",o.STX="",o.ETX="",o.EOT="",o.ENQ="",o.ACK="",o.BEL="\x07",o.BS="\b",o.HT=" ",o.LF=`
9
+ `,o.VT="\v",o.FF="\f",o.CR="\r",o.SO="",o.SI="",o.DLE="",o.DC1="",o.DC2="",o.DC3="",o.DC4="",o.NAK="",o.SYN="",o.ETB="",o.CAN="",o.EM="",o.SUB="",o.ESC="\x1B",o.FS="",o.GS="",o.RS="",o.US="",o.SP=" ",o.DEL="\x7F"})(n||(r.C0=n={})),(function(o){o.PAD="\x80",o.HOP="\x81",o.BPH="\x82",o.NBH="\x83",o.IND="\x84",o.NEL="\x85",o.SSA="\x86",o.ESA="\x87",o.HTS="\x88",o.HTJ="\x89",o.VTS="\x8A",o.PLD="\x8B",o.PLU="\x8C",o.RI="\x8D",o.SS2="\x8E",o.SS3="\x8F",o.DCS="\x90",o.PU1="\x91",o.PU2="\x92",o.STS="\x93",o.CCH="\x94",o.MW="\x95",o.SPA="\x96",o.EPA="\x97",o.SOS="\x98",o.SGCI="\x99",o.SCI="\x9A",o.CSI="\x9B",o.ST="\x9C",o.OSC="\x9D",o.PM="\x9E",o.APC="\x9F"})(h||(r.C1=h={})),(function(o){o.ST=`${n.ESC}\\`})(u||(r.C1_ESCAPED=u={}))},7399:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.evaluateKeyboardEvent=void 0;let h=n(2584),u={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:["'",'"']};r.evaluateKeyboardEvent=function(o,a,c,_){let l={type:0,cancel:!1,key:void 0},i=(o.shiftKey?1:0)|(o.altKey?2:0)|(o.ctrlKey?4:0)|(o.metaKey?8:0);switch(o.keyCode){case 0:o.key==="UIKeyInputUpArrow"?l.key=a?h.C0.ESC+"OA":h.C0.ESC+"[A":o.key==="UIKeyInputLeftArrow"?l.key=a?h.C0.ESC+"OD":h.C0.ESC+"[D":o.key==="UIKeyInputRightArrow"?l.key=a?h.C0.ESC+"OC":h.C0.ESC+"[C":o.key==="UIKeyInputDownArrow"&&(l.key=a?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:l.key=o.ctrlKey?"\b":h.C0.DEL,o.altKey&&(l.key=h.C0.ESC+l.key);break;case 9:if(o.shiftKey){l.key=h.C0.ESC+"[Z";break}l.key=h.C0.HT,l.cancel=!0;break;case 13:l.key=o.altKey?h.C0.ESC+h.C0.CR:h.C0.CR,l.cancel=!0;break;case 27:l.key=h.C0.ESC,o.altKey&&(l.key=h.C0.ESC+h.C0.ESC),l.cancel=!0;break;case 37:if(o.metaKey)break;i?(l.key=h.C0.ESC+"[1;"+(i+1)+"D",l.key===h.C0.ESC+"[1;3D"&&(l.key=h.C0.ESC+(c?"b":"[1;5D"))):l.key=a?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:if(o.metaKey)break;i?(l.key=h.C0.ESC+"[1;"+(i+1)+"C",l.key===h.C0.ESC+"[1;3C"&&(l.key=h.C0.ESC+(c?"f":"[1;5C"))):l.key=a?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(o.metaKey)break;i?(l.key=h.C0.ESC+"[1;"+(i+1)+"A",c||l.key!==h.C0.ESC+"[1;3A"||(l.key=h.C0.ESC+"[1;5A")):l.key=a?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:if(o.metaKey)break;i?(l.key=h.C0.ESC+"[1;"+(i+1)+"B",c||l.key!==h.C0.ESC+"[1;3B"||(l.key=h.C0.ESC+"[1;5B")):l.key=a?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45:o.shiftKey||o.ctrlKey||(l.key=h.C0.ESC+"[2~");break;case 46:l.key=i?h.C0.ESC+"[3;"+(i+1)+"~":h.C0.ESC+"[3~";break;case 36:l.key=i?h.C0.ESC+"[1;"+(i+1)+"H":a?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:l.key=i?h.C0.ESC+"[1;"+(i+1)+"F":a?h.C0.ESC+"OF":h.C0.ESC+"[F";break;case 33:o.shiftKey?l.type=2:o.ctrlKey?l.key=h.C0.ESC+"[5;"+(i+1)+"~":l.key=h.C0.ESC+"[5~";break;case 34:o.shiftKey?l.type=3:o.ctrlKey?l.key=h.C0.ESC+"[6;"+(i+1)+"~":l.key=h.C0.ESC+"[6~";break;case 112:l.key=i?h.C0.ESC+"[1;"+(i+1)+"P":h.C0.ESC+"OP";break;case 113:l.key=i?h.C0.ESC+"[1;"+(i+1)+"Q":h.C0.ESC+"OQ";break;case 114:l.key=i?h.C0.ESC+"[1;"+(i+1)+"R":h.C0.ESC+"OR";break;case 115:l.key=i?h.C0.ESC+"[1;"+(i+1)+"S":h.C0.ESC+"OS";break;case 116:l.key=i?h.C0.ESC+"[15;"+(i+1)+"~":h.C0.ESC+"[15~";break;case 117:l.key=i?h.C0.ESC+"[17;"+(i+1)+"~":h.C0.ESC+"[17~";break;case 118:l.key=i?h.C0.ESC+"[18;"+(i+1)+"~":h.C0.ESC+"[18~";break;case 119:l.key=i?h.C0.ESC+"[19;"+(i+1)+"~":h.C0.ESC+"[19~";break;case 120:l.key=i?h.C0.ESC+"[20;"+(i+1)+"~":h.C0.ESC+"[20~";break;case 121:l.key=i?h.C0.ESC+"[21;"+(i+1)+"~":h.C0.ESC+"[21~";break;case 122:l.key=i?h.C0.ESC+"[23;"+(i+1)+"~":h.C0.ESC+"[23~";break;case 123:l.key=i?h.C0.ESC+"[24;"+(i+1)+"~":h.C0.ESC+"[24~";break;default:if(!o.ctrlKey||o.shiftKey||o.altKey||o.metaKey)if(c&&!_||!o.altKey||o.metaKey)!c||o.altKey||o.ctrlKey||o.shiftKey||!o.metaKey?o.key&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&o.keyCode>=48&&o.key.length===1?l.key=o.key:o.key&&o.ctrlKey&&(o.key==="_"&&(l.key=h.C0.US),o.key==="@"&&(l.key=h.C0.NUL)):o.keyCode===65&&(l.type=1);else{let t=u[o.keyCode],e=t?.[o.shiftKey?1:0];if(e)l.key=h.C0.ESC+e;else if(o.keyCode>=65&&o.keyCode<=90){let s=o.ctrlKey?o.keyCode-64:o.keyCode+32,d=String.fromCharCode(s);o.shiftKey&&(d=d.toUpperCase()),l.key=h.C0.ESC+d}else if(o.keyCode===32)l.key=h.C0.ESC+(o.ctrlKey?h.C0.NUL:" ");else if(o.key==="Dead"&&o.code.startsWith("Key")){let s=o.code.slice(3,4);o.shiftKey||(s=s.toLowerCase()),l.key=h.C0.ESC+s,l.cancel=!0}}else o.keyCode>=65&&o.keyCode<=90?l.key=String.fromCharCode(o.keyCode-64):o.keyCode===32?l.key=h.C0.NUL:o.keyCode>=51&&o.keyCode<=55?l.key=String.fromCharCode(o.keyCode-51+27):o.keyCode===56?l.key=h.C0.DEL:o.keyCode===219?l.key=h.C0.ESC:o.keyCode===220?l.key=h.C0.FS:o.keyCode===221&&(l.key=h.C0.GS)}return l}},482:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Utf8ToUtf32=r.StringToUtf32=r.utf32ToString=r.stringFromCodePoint=void 0,r.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},r.utf32ToString=function(n,h=0,u=n.length){let o="";for(let a=h;a<u;++a){let c=n[a];c>65535?(c-=65536,o+=String.fromCharCode(55296+(c>>10))+String.fromCharCode(c%1024+56320)):o+=String.fromCharCode(c)}return o},r.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,h){let u=n.length;if(!u)return 0;let o=0,a=0;if(this._interim){let c=n.charCodeAt(a++);56320<=c&&c<=57343?h[o++]=1024*(this._interim-55296)+c-56320+65536:(h[o++]=this._interim,h[o++]=c),this._interim=0}for(let c=a;c<u;++c){let _=n.charCodeAt(c);if(55296<=_&&_<=56319){if(++c>=u)return this._interim=_,o;let l=n.charCodeAt(c);56320<=l&&l<=57343?h[o++]=1024*(_-55296)+l-56320+65536:(h[o++]=_,h[o++]=l)}else _!==65279&&(h[o++]=_)}return o}},r.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,h){let u=n.length;if(!u)return 0;let o,a,c,_,l=0,i=0,t=0;if(this.interim[0]){let d=!1,p=this.interim[0];p&=(224&p)==192?31:(240&p)==224?15:7;let g,v=0;for(;(g=63&this.interim[++v])&&v<4;)p<<=6,p|=g;let f=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,m=f-v;for(;t<m;){if(t>=u)return 0;if(g=n[t++],(192&g)!=128){t--,d=!0;break}this.interim[v++]=g,p<<=6,p|=63&g}d||(f===2?p<128?t--:h[l++]=p:f===3?p<2048||p>=55296&&p<=57343||p===65279||(h[l++]=p):p<65536||p>1114111||(h[l++]=p)),this.interim.fill(0)}let e=u-4,s=t;for(;s<u;){for(;!(!(s<e)||128&(o=n[s])||128&(a=n[s+1])||128&(c=n[s+2])||128&(_=n[s+3]));)h[l++]=o,h[l++]=a,h[l++]=c,h[l++]=_,s+=4;if(o=n[s++],o<128)h[l++]=o;else if((224&o)==192){if(s>=u)return this.interim[0]=o,l;if(a=n[s++],(192&a)!=128){s--;continue}if(i=(31&o)<<6|63&a,i<128){s--;continue}h[l++]=i}else if((240&o)==224){if(s>=u)return this.interim[0]=o,l;if(a=n[s++],(192&a)!=128){s--;continue}if(s>=u)return this.interim[0]=o,this.interim[1]=a,l;if(c=n[s++],(192&c)!=128){s--;continue}if(i=(15&o)<<12|(63&a)<<6|63&c,i<2048||i>=55296&&i<=57343||i===65279)continue;h[l++]=i}else if((248&o)==240){if(s>=u)return this.interim[0]=o,l;if(a=n[s++],(192&a)!=128){s--;continue}if(s>=u)return this.interim[0]=o,this.interim[1]=a,l;if(c=n[s++],(192&c)!=128){s--;continue}if(s>=u)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=c,l;if(_=n[s++],(192&_)!=128){s--;continue}if(i=(7&o)<<18|(63&a)<<12|(63&c)<<6|63&_,i<65536||i>1114111)continue;h[l++]=i}}return l}}},225:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeV6=void 0;let h=n(1480),u=[[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]],o=[[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]],a;r.UnicodeV6=class{constructor(){if(this.version="6",!a){a=new Uint8Array(65536),a.fill(1),a[0]=0,a.fill(0,1,32),a.fill(0,127,160),a.fill(2,4352,4448),a[9001]=2,a[9002]=2,a.fill(2,11904,42192),a[12351]=1,a.fill(2,44032,55204),a.fill(2,63744,64256),a.fill(2,65040,65050),a.fill(2,65072,65136),a.fill(2,65280,65377),a.fill(2,65504,65511);for(let c=0;c<u.length;++c)a.fill(0,u[c][0],u[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?a[c]:(function(_,l){let i,t=0,e=l.length-1;if(_<l[0][0]||_>l[e][1])return!1;for(;e>=t;)if(i=t+e>>1,_>l[i][1])t=i+1;else{if(!(_<l[i][0]))return!0;e=i-1}return!1})(c,o)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}charProperties(c,_){let l=this.wcwidth(c),i=l===0&&_!==0;if(i){let t=h.UnicodeService.extractWidth(_);t===0?i=!1:t>l&&(l=t)}return h.UnicodeService.createPropertyValue(0,l,i)}}},5981:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WriteBuffer=void 0;let h=n(8460),u=n(844);class o extends u.Disposable{constructor(c){super(),this._action=c,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new h.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(c,_){if(_!==void 0&&this._syncCalls>_)return void(this._syncCalls=0);if(this._pendingData+=c.length,this._writeBuffer.push(c),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let l;for(this._isSyncWriting=!0;l=this._writeBuffer.shift();){this._action(l);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(c,_){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=c.length,this._writeBuffer.push(c),this._callbacks.push(_),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=c.length,this._writeBuffer.push(c),this._callbacks.push(_)}_innerWrite(c=0,_=!0){let l=c||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],t=this._action(i,_);if(t){let s=d=>Date.now()-l>=12?setTimeout((()=>this._innerWrite(0,d))):this._innerWrite(l,d);return void t.catch((d=>(queueMicrotask((()=>{throw d})),Promise.resolve(!1)))).then(s)}let e=this._callbacks[this._bufferOffset];if(e&&e(),this._bufferOffset++,this._pendingData-=i.length,Date.now()-l>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(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()}}r.WriteBuffer=o},5941:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toRgbString=r.parseColor=void 0;let n=/^([\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})$/,h=/^[\da-f]+$/;function u(o,a){let c=o.toString(16),_=c.length<2?"0"+c:c;switch(a){case 4:return c[0];case 8:return _;case 12:return(_+_).slice(0,3);default:return _+_}}r.parseColor=function(o){if(!o)return;let a=o.toLowerCase();if(a.indexOf("rgb:")===0){a=a.slice(4);let c=n.exec(a);if(c){let _=c[1]?15:c[4]?255:c[7]?4095:65535;return[Math.round(parseInt(c[1]||c[4]||c[7]||c[10],16)/_*255),Math.round(parseInt(c[2]||c[5]||c[8]||c[11],16)/_*255),Math.round(parseInt(c[3]||c[6]||c[9]||c[12],16)/_*255)]}}else if(a.indexOf("#")===0&&(a=a.slice(1),h.exec(a)&&[3,6,9,12].includes(a.length))){let c=a.length/3,_=[0,0,0];for(let l=0;l<3;++l){let i=parseInt(a.slice(c*l,c*l+c),16);_[l]=c===1?i<<4:c===2?i:c===3?i>>4:i>>8}return _}},r.toRgbString=function(o,a=16){let[c,_,l]=o;return`rgb:${u(c,a)}/${u(_,a)}/${u(l,a)}`}},5770:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PAYLOAD_LIMIT=void 0,r.PAYLOAD_LIMIT=1e7},6351:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DcsHandler=r.DcsParser=void 0;let h=n(482),u=n(8742),o=n(5770),a=[];r.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=a,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a}registerHandler(_,l){this._handlers[_]===void 0&&(this._handlers[_]=[]);let i=this._handlers[_];return i.push(l),{dispose:()=>{let t=i.indexOf(l);t!==-1&&i.splice(t,1)}}}clearHandler(_){this._handlers[_]&&delete this._handlers[_]}setHandlerFallback(_){this._handlerFb=_}reset(){if(this._active.length)for(let _=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;_>=0;--_)this._active[_].unhook(!1);this._stack.paused=!1,this._active=a,this._ident=0}hook(_,l){if(this.reset(),this._ident=_,this._active=this._handlers[_]||a,this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(l);else this._handlerFb(this._ident,"HOOK",l)}put(_,l,i){if(this._active.length)for(let t=this._active.length-1;t>=0;t--)this._active[t].put(_,l,i);else this._handlerFb(this._ident,"PUT",(0,h.utf32ToString)(_,l,i))}unhook(_,l=!0){if(this._active.length){let i=!1,t=this._active.length-1,e=!1;if(this._stack.paused&&(t=this._stack.loopPosition-1,i=l,e=this._stack.fallThrough,this._stack.paused=!1),!e&&i===!1){for(;t>=0&&(i=this._active[t].unhook(_),i!==!0);t--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=t,this._stack.fallThrough=!1,i;t--}for(;t>=0;t--)if(i=this._active[t].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=t,this._stack.fallThrough=!0,i}else this._handlerFb(this._ident,"UNHOOK",_);this._active=a,this._ident=0}};let c=new u.Params;c.addParam(0),r.DcsHandler=class{constructor(_){this._handler=_,this._data="",this._params=c,this._hitLimit=!1}hook(_){this._params=_.length>1||_.params[0]?_.clone():c,this._data="",this._hitLimit=!1}put(_,l,i){this._hitLimit||(this._data+=(0,h.utf32ToString)(_,l,i),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(_){let l=!1;if(this._hitLimit)l=!1;else if(_&&(l=this._handler(this._data,this._params),l instanceof Promise))return l.then((i=>(this._params=c,this._data="",this._hitLimit=!1,i)));return this._params=c,this._data="",this._hitLimit=!1,l}}},2015:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.EscapeSequenceParser=r.VT500_TRANSITION_TABLE=r.TransitionTable=void 0;let h=n(844),u=n(8742),o=n(6242),a=n(6351);class c{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,d){this.table[e<<8|t]=s<<4|d}addMany(t,e,s,d){for(let p=0;p<t.length;p++)this.table[e<<8|t[p]]=s<<4|d}}r.TransitionTable=c;let _=160;r.VT500_TRANSITION_TABLE=(function(){let i=new c(4095),t=Array.apply(null,Array(256)).map(((v,f)=>f)),e=(v,f)=>t.slice(v,f),s=e(32,127),d=e(0,24);d.push(25),d.push.apply(d,e(28,32));let p=e(0,14),g;for(g in i.setDefault(1,0),i.addMany(s,0,2,0),p)i.addMany([24,26,153,154],g,3,0),i.addMany(e(128,144),g,3,0),i.addMany(e(144,152),g,3,0),i.add(156,g,0,0),i.add(27,g,11,1),i.add(157,g,4,8),i.addMany([152,158,159],g,0,7),i.add(155,g,11,3),i.add(144,g,11,9);return i.addMany(d,0,3,0),i.addMany(d,1,3,1),i.add(127,1,0,1),i.addMany(d,8,0,8),i.addMany(d,3,3,3),i.add(127,3,0,3),i.addMany(d,4,3,4),i.add(127,4,0,4),i.addMany(d,6,3,6),i.addMany(d,5,3,5),i.add(127,5,0,5),i.addMany(d,2,3,2),i.add(127,2,0,2),i.add(93,1,4,8),i.addMany(s,8,5,8),i.add(127,8,5,8),i.addMany([156,27,24,26,7],8,6,0),i.addMany(e(28,32),8,0,8),i.addMany([88,94,95],1,0,7),i.addMany(s,7,0,7),i.addMany(d,7,0,7),i.add(156,7,0,0),i.add(127,7,0,7),i.add(91,1,11,3),i.addMany(e(64,127),3,7,0),i.addMany(e(48,60),3,8,4),i.addMany([60,61,62,63],3,9,4),i.addMany(e(48,60),4,8,4),i.addMany(e(64,127),4,7,0),i.addMany([60,61,62,63],4,0,6),i.addMany(e(32,64),6,0,6),i.add(127,6,0,6),i.addMany(e(64,127),6,0,0),i.addMany(e(32,48),3,9,5),i.addMany(e(32,48),5,9,5),i.addMany(e(48,64),5,0,6),i.addMany(e(64,127),5,7,0),i.addMany(e(32,48),4,9,5),i.addMany(e(32,48),1,9,2),i.addMany(e(32,48),2,9,2),i.addMany(e(48,127),2,10,0),i.addMany(e(48,80),1,10,0),i.addMany(e(81,88),1,10,0),i.addMany([89,90,92],1,10,0),i.addMany(e(96,127),1,10,0),i.add(80,1,11,9),i.addMany(d,9,0,9),i.add(127,9,0,9),i.addMany(e(28,32),9,0,9),i.addMany(e(32,48),9,9,12),i.addMany(e(48,60),9,8,10),i.addMany([60,61,62,63],9,9,10),i.addMany(d,11,0,11),i.addMany(e(32,128),11,0,11),i.addMany(e(28,32),11,0,11),i.addMany(d,10,0,10),i.add(127,10,0,10),i.addMany(e(28,32),10,0,10),i.addMany(e(48,60),10,8,10),i.addMany([60,61,62,63],10,0,11),i.addMany(e(32,48),10,9,12),i.addMany(d,12,0,12),i.add(127,12,0,12),i.addMany(e(28,32),12,0,12),i.addMany(e(32,48),12,9,12),i.addMany(e(48,64),12,0,11),i.addMany(e(64,127),12,12,13),i.addMany(e(64,127),10,12,13),i.addMany(e(64,127),9,12,13),i.addMany(d,13,13,13),i.addMany(s,13,13,13),i.add(127,13,0,13),i.addMany([27,156,24,26],13,14,0),i.add(_,0,2,0),i.add(_,8,5,8),i.add(_,6,0,6),i.add(_,11,0,11),i.add(_,13,13,13),i})();class l extends h.Disposable{constructor(t=r.VT500_TRANSITION_TABLE){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new u.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,d)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,s)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,h.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new o.OscParser),this._dcsParser=this.register(new a.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(t,e=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let p=0;p<t.intermediates.length;++p){let g=t.intermediates.charCodeAt(p);if(32>g||g>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=g}}if(t.final.length!==1)throw new Error("final must be a single byte");let d=t.final.charCodeAt(0);if(e[0]>d||d>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=d,s}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(255&t)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let s=this._identifier(t,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let d=this._escHandlers[s];return d.push(e),{dispose:()=>{let p=d.indexOf(e);p!==-1&&d.splice(p,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let s=this._identifier(t);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let d=this._csiHandlers[s];return d.push(e),{dispose:()=>{let p=d.indexOf(e);p!==-1&&d.splice(p,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}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(t,e,s,d,p){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=d,this._parseStack.chunkPos=p}parse(t,e,s){let d,p=0,g=0,v=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,v=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&m>-1){for(;m>=0&&(d=f[m](this._params),d!==!0);m--)if(d instanceof Promise)return this._parseStack.handlerPos=m,d}this._parseStack.handlers=[];break;case 4:if(s===!1&&m>-1){for(;m>=0&&(d=f[m](),d!==!0);m--)if(d instanceof Promise)return this._parseStack.handlerPos=m,d}this._parseStack.handlers=[];break;case 6:if(p=t[this._parseStack.chunkPos],d=this._dcsParser.unhook(p!==24&&p!==26,s),d)return d;p===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(p=t[this._parseStack.chunkPos],d=this._oscParser.end(p!==24&&p!==26,s),d)return d;p===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,v=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let f=v;f<e;++f){switch(p=t[f],g=this._transitions.table[this.currentState<<8|(p<160?p:_)],g>>4){case 2:for(let C=f+1;;++C){if(C>=e||(p=t[C])<32||p>126&&p<_){this._printHandler(t,f,C),f=C-1;break}if(++C>=e||(p=t[C])<32||p>126&&p<_){this._printHandler(t,f,C),f=C-1;break}if(++C>=e||(p=t[C])<32||p>126&&p<_){this._printHandler(t,f,C),f=C-1;break}if(++C>=e||(p=t[C])<32||p>126&&p<_){this._printHandler(t,f,C),f=C-1;break}}break;case 3:this._executeHandlers[p]?this._executeHandlers[p]():this._executeHandlerFb(p),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:p,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let m=this._csiHandlers[this._collect<<8|p],L=m?m.length-1:-1;for(;L>=0&&(d=m[L](this._params),d!==!0);L--)if(d instanceof Promise)return this._preserveStack(3,m,L,g,f),d;L<0&&this._csiHandlerFb(this._collect<<8|p,this._params),this.precedingJoinState=0;break;case 8:do switch(p){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(p-48)}while(++f<e&&(p=t[f])>47&&p<60);f--;break;case 9:this._collect<<=8,this._collect|=p;break;case 10:let k=this._escHandlers[this._collect<<8|p],E=k?k.length-1:-1;for(;E>=0&&(d=k[E](),d!==!0);E--)if(d instanceof Promise)return this._preserveStack(4,k,E,g,f),d;E<0&&this._escHandlerFb(this._collect<<8|p),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|p,this._params);break;case 13:for(let C=f+1;;++C)if(C>=e||(p=t[C])===24||p===26||p===27||p>127&&p<_){this._dcsParser.put(t,f,C),f=C-1;break}break;case 14:if(d=this._dcsParser.unhook(p!==24&&p!==26),d)return this._preserveStack(6,[],0,g,f),d;p===27&&(g|=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 C=f+1;;C++)if(C>=e||(p=t[C])<32||p>127&&p<_){this._oscParser.put(t,f,C),f=C-1;break}break;case 6:if(d=this._oscParser.end(p!==24&&p!==26),d)return this._preserveStack(5,[],0,g,f),d;p===27&&(g|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&g}}}r.EscapeSequenceParser=l},6242:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OscHandler=r.OscParser=void 0;let h=n(5770),u=n(482),o=[];r.OscParser=class{constructor(){this._state=0,this._active=o,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(a,c){this._handlers[a]===void 0&&(this._handlers[a]=[]);let _=this._handlers[a];return _.push(c),{dispose:()=>{let l=_.indexOf(c);l!==-1&&_.splice(l,1)}}}clearHandler(a){this._handlers[a]&&delete this._handlers[a]}setHandlerFallback(a){this._handlerFb=a}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o}reset(){if(this._state===2)for(let a=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;a>=0;--a)this._active[a].end(!1);this._stack.paused=!1,this._active=o,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||o,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].start();else this._handlerFb(this._id,"START")}_put(a,c,_){if(this._active.length)for(let l=this._active.length-1;l>=0;l--)this._active[l].put(a,c,_);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(a,c,_))}start(){this.reset(),this._state=1}put(a,c,_){if(this._state!==3){if(this._state===1)for(;c<_;){let l=a[c++];if(l===59){this._state=2,this._start();break}if(l<48||57<l)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+l-48}this._state===2&&_-c>0&&this._put(a,c,_)}}end(a,c=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let _=!1,l=this._active.length-1,i=!1;if(this._stack.paused&&(l=this._stack.loopPosition-1,_=c,i=this._stack.fallThrough,this._stack.paused=!1),!i&&_===!1){for(;l>=0&&(_=this._active[l].end(a),_!==!0);l--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=l,this._stack.fallThrough=!1,_;l--}for(;l>=0;l--)if(_=this._active[l].end(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=l,this._stack.fallThrough=!0,_}else this._handlerFb(this._id,"END",a);this._active=o,this._id=-1,this._state=0}}},r.OscHandler=class{constructor(a){this._handler=a,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(a,c,_){this._hitLimit||(this._data+=(0,u.utf32ToString)(a,c,_),this._data.length>h.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(a){let c=!1;if(this._hitLimit)c=!1;else if(a&&(c=this._handler(this._data),c instanceof Promise))return c.then((_=>(this._data="",this._hitLimit=!1,_)));return this._data="",this._hitLimit=!1,c}}},8742:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Params=void 0;let n=2147483647;class h{static fromArray(o){let a=new h;if(!o.length)return a;for(let c=Array.isArray(o[0])?1:0;c<o.length;++c){let _=o[c];if(Array.isArray(_))for(let l=0;l<_.length;++l)a.addSubParam(_[l]);else a.addParam(_)}return a}constructor(o=32,a=32){if(this.maxLength=o,this.maxSubParamsLength=a,a>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(o),this.length=0,this._subParams=new Int32Array(a),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(o),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){let o=new h(this.maxLength,this.maxSubParamsLength);return o.params.set(this.params),o.length=this.length,o._subParams.set(this._subParams),o._subParamsLength=this._subParamsLength,o._subParamsIdx.set(this._subParamsIdx),o._rejectDigits=this._rejectDigits,o._rejectSubDigits=this._rejectSubDigits,o._digitIsSub=this._digitIsSub,o}toArray(){let o=[];for(let a=0;a<this.length;++a){o.push(this.params[a]);let c=this._subParamsIdx[a]>>8,_=255&this._subParamsIdx[a];_-c>0&&o.push(Array.prototype.slice.call(this._subParams,c,_))}return o}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(o){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(o<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=o>n?n:o}}addSubParam(o){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(o<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=o>n?n:o,this._subParamsIdx[this.length-1]++}}hasSubParams(o){return(255&this._subParamsIdx[o])-(this._subParamsIdx[o]>>8)>0}getSubParams(o){let a=this._subParamsIdx[o]>>8,c=255&this._subParamsIdx[o];return c-a>0?this._subParams.subarray(a,c):null}getSubParamsAll(){let o={};for(let a=0;a<this.length;++a){let c=this._subParamsIdx[a]>>8,_=255&this._subParamsIdx[a];_-c>0&&(o[a]=this._subParams.slice(c,_))}return o}addDigit(o){let a;if(this._rejectDigits||!(a=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let c=this._digitIsSub?this._subParams:this.params,_=c[a-1];c[a-1]=~_?Math.min(10*_+o,n):o}}r.Params=h},5741:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.AddonManager=void 0,r.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,h){let u={instance:h,dispose:h.dispose,isDisposed:!1};this._addons.push(u),h.dispose=()=>this._wrappedAddonDispose(u),h.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let h=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===n){h=u;break}if(h===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(h,1)}}},8771:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferApiView=void 0;let h=n(3785),u=n(511);r.BufferApiView=class{constructor(o,a){this._buffer=o,this.type=a}init(o){return this._buffer=o,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(o){let a=this._buffer.lines.get(o);if(a)return new h.BufferLineApiView(a)}getNullCell(){return new u.CellData}}},3785:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLineApiView=void 0;let h=n(511);r.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,o){if(!(u<0||u>=this._line.length))return o?(this._line.loadCell(u,o),o):this._line.loadCell(u,new h.CellData)}translateToString(u,o,a){return this._line.translateToString(u,o,a)}}},8285:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferNamespaceApi=void 0;let h=n(8771),u=n(8460),o=n(844);class a extends o.Disposable{constructor(_){super(),this._core=_,this._onBufferChange=this.register(new u.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new h.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new h.BufferApiView(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)}}r.BufferNamespaceApi=a},7975:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ParserApi=void 0,r.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,h){return this._core.registerCsiHandler(n,(u=>h(u.toArray())))}addCsiHandler(n,h){return this.registerCsiHandler(n,h)}registerDcsHandler(n,h){return this._core.registerDcsHandler(n,((u,o)=>h(u,o.toArray())))}addDcsHandler(n,h){return this.registerDcsHandler(n,h)}registerEscHandler(n,h){return this._core.registerEscHandler(n,h)}addEscHandler(n,h){return this.registerEscHandler(n,h)}registerOscHandler(n,h){return this._core.registerOscHandler(n,h)}addOscHandler(n,h){return this.registerOscHandler(n,h)}}},7090:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeApi=void 0,r.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(x,r,n){var h=this&&this.__decorate||function(i,t,e,s){var d,p=arguments.length,g=p<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")g=Reflect.decorate(i,t,e,s);else for(var v=i.length-1;v>=0;v--)(d=i[v])&&(g=(p<3?d(g):p>3?d(t,e,g):d(t,e))||g);return p>3&&g&&Object.defineProperty(t,e,g),g},u=this&&this.__param||function(i,t){return function(e,s){t(e,s,i)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferService=r.MINIMUM_ROWS=r.MINIMUM_COLS=void 0;let o=n(8460),a=n(844),c=n(5295),_=n(2585);r.MINIMUM_COLS=2,r.MINIMUM_ROWS=1;let l=r.BufferService=class extends a.Disposable{get buffer(){return this.buffers.active}constructor(i){super(),this.isUserScrolling=!1,this._onResize=this.register(new o.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new o.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(i.rawOptions.cols||0,r.MINIMUM_COLS),this.rows=Math.max(i.rawOptions.rows||0,r.MINIMUM_ROWS),this.buffers=this.register(new c.BufferSet(i,this))}resize(i,t){this.cols=i,this.rows=t,this.buffers.resize(i,t),this._onResize.fire({cols:i,rows:t})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(i,t=!1){let e=this.buffer,s;s=this._cachedBlankLine,s&&s.length===this.cols&&s.getFg(0)===i.fg&&s.getBg(0)===i.bg||(s=e.getBlankLine(i,t),this._cachedBlankLine=s),s.isWrapped=t;let d=e.ybase+e.scrollTop,p=e.ybase+e.scrollBottom;if(e.scrollTop===0){let g=e.lines.isFull;p===e.lines.length-1?g?e.lines.recycle().copyFrom(s):e.lines.push(s.clone()):e.lines.splice(p+1,0,s.clone()),g?this.isUserScrolling&&(e.ydisp=Math.max(e.ydisp-1,0)):(e.ybase++,this.isUserScrolling||e.ydisp++)}else{let g=p-d+1;e.lines.shiftElements(d+1,g-1,-1),e.lines.set(p,s.clone())}this.isUserScrolling||(e.ydisp=e.ybase),this._onScroll.fire(e.ydisp)}scrollLines(i,t,e){let s=this.buffer;if(i<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else i+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let d=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+i,s.ybase),0),d!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};r.BufferService=l=h([u(0,_.IOptionsService)],l)},7994:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CharsetService=void 0,r.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,h){this._charsets[n]=h,this.glevel===n&&(this.charset=h)}}},1753:function(x,r,n){var h=this&&this.__decorate||function(s,d,p,g){var v,f=arguments.length,m=f<3?d:g===null?g=Object.getOwnPropertyDescriptor(d,p):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(s,d,p,g);else for(var L=s.length-1;L>=0;L--)(v=s[L])&&(m=(f<3?v(m):f>3?v(d,p,m):v(d,p))||m);return f>3&&m&&Object.defineProperty(d,p,m),m},u=this&&this.__param||function(s,d){return function(p,g){d(p,g,s)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreMouseService=void 0;let o=n(2585),a=n(8460),c=n(844),_={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:s=>s.button!==4&&s.action===1&&(s.ctrl=!1,s.alt=!1,s.shift=!1,!0)},VT200:{events:19,restrict:s=>s.action!==32},DRAG:{events:23,restrict:s=>s.action!==32||s.button!==3},ANY:{events:31,restrict:s=>!0}};function l(s,d){let p=(s.ctrl?16:0)|(s.shift?4:0)|(s.alt?8:0);return s.button===4?(p|=64,p|=s.action):(p|=3&s.button,4&s.button&&(p|=64),8&s.button&&(p|=128),s.action===32?p|=32:s.action!==0||d||(p|=3)),p}let i=String.fromCharCode,t={DEFAULT:s=>{let d=[l(s,!1)+32,s.col+32,s.row+32];return d[0]>255||d[1]>255||d[2]>255?"":`\x1B[M${i(d[0])}${i(d[1])}${i(d[2])}`},SGR:s=>{let d=s.action===0&&s.button!==4?"m":"M";return`\x1B[<${l(s,!0)};${s.col};${s.row}${d}`},SGR_PIXELS:s=>{let d=s.action===0&&s.button!==4?"m":"M";return`\x1B[<${l(s,!0)};${s.x};${s.y}${d}`}},e=r.CoreMouseService=class extends c.Disposable{constructor(s,d){super(),this._bufferService=s,this._coreService=d,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new a.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(let p of Object.keys(_))this.addProtocol(p,_[p]);for(let p of Object.keys(t))this.addEncoding(p,t[p]);this.reset()}addProtocol(s,d){this._protocols[s]=d}addEncoding(s,d){this._encodings[s]=d}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(s){if(!this._protocols[s])throw new Error(`unknown protocol "${s}"`);this._activeProtocol=s,this._onProtocolChange.fire(this._protocols[s].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(s){if(!this._encodings[s])throw new Error(`unknown encoding "${s}"`);this._activeEncoding=s}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(s){if(s.col<0||s.col>=this._bufferService.cols||s.row<0||s.row>=this._bufferService.rows||s.button===4&&s.action===32||s.button===3&&s.action!==32||s.button!==4&&(s.action===2||s.action===3)||(s.col++,s.row++,s.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,s,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(s))return!1;let d=this._encodings[this._activeEncoding](s);return d&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(d):this._coreService.triggerDataEvent(d,!0)),this._lastEvent=s,!0}explainEvents(s){return{down:!!(1&s),up:!!(2&s),drag:!!(4&s),move:!!(8&s),wheel:!!(16&s)}}_equalEvents(s,d,p){if(p){if(s.x!==d.x||s.y!==d.y)return!1}else if(s.col!==d.col||s.row!==d.row)return!1;return s.button===d.button&&s.action===d.action&&s.ctrl===d.ctrl&&s.alt===d.alt&&s.shift===d.shift}};r.CoreMouseService=e=h([u(0,o.IBufferService),u(1,o.ICoreService)],e)},6975:function(x,r,n){var h=this&&this.__decorate||function(e,s,d,p){var g,v=arguments.length,f=v<3?s:p===null?p=Object.getOwnPropertyDescriptor(s,d):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(e,s,d,p);else for(var m=e.length-1;m>=0;m--)(g=e[m])&&(f=(v<3?g(f):v>3?g(s,d,f):g(s,d))||f);return v>3&&f&&Object.defineProperty(s,d,f),f},u=this&&this.__param||function(e,s){return function(d,p){s(d,p,e)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreService=void 0;let o=n(1439),a=n(8460),c=n(844),_=n(2585),l=Object.freeze({insertMode:!1}),i=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0}),t=r.CoreService=class extends c.Disposable{constructor(e,s,d){super(),this._bufferService=e,this._logService=s,this._optionsService=d,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new a.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new a.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,o.clone)(l),this.decPrivateModes=(0,o.clone)(i)}reset(){this.modes=(0,o.clone)(l),this.decPrivateModes=(0,o.clone)(i)}triggerDataEvent(e,s=!1){if(this._optionsService.rawOptions.disableStdin)return;let d=this._bufferService.buffer;s&&this._optionsService.rawOptions.scrollOnUserInput&&d.ybase!==d.ydisp&&this._onRequestScrollToBottom.fire(),s&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`,(()=>e.split("").map((p=>p.charCodeAt(0))))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`,(()=>e.split("").map((s=>s.charCodeAt(0))))),this._onBinary.fire(e))}};r.CoreService=t=h([u(0,_.IBufferService),u(1,_.ILogService),u(2,_.IOptionsService)],t)},9074:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DecorationService=void 0;let h=n(8055),u=n(8460),o=n(844),a=n(6106),c=0,_=0;class l extends o.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new a.SortedList((e=>e?.marker.line)),this._onDecorationRegistered=this.register(new u.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new u.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,o.toDisposable)((()=>this.reset())))}registerDecoration(e){if(e.marker.isDisposed)return;let s=new i(e);if(s){let d=s.marker.onDispose((()=>s.dispose()));s.onDispose((()=>{s&&(this._decorations.delete(s)&&this._onDecorationRemoved.fire(s),d.dispose())})),this._decorations.insert(s),this._onDecorationRegistered.fire(s)}return s}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,s,d){let p=0,g=0;for(let v of this._decorations.getKeyIterator(s))p=v.options.x??0,g=p+(v.options.width??1),e>=p&&e<g&&(!d||(v.options.layer??"bottom")===d)&&(yield v)}forEachDecorationAtCell(e,s,d,p){this._decorations.forEachByKey(s,(g=>{c=g.options.x??0,_=c+(g.options.width??1),e>=c&&e<_&&(!d||(g.options.layer??"bottom")===d)&&p(g)}))}}r.DecorationService=l;class i extends o.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=h.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=h.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(e){super(),this.options=e,this.onRenderEmitter=this.register(new u.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new u.EventEmitter),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")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.InstantiationService=r.ServiceCollection=void 0;let h=n(2585),u=n(8343);class o{constructor(...c){this._entries=new Map;for(let[_,l]of c)this.set(_,l)}set(c,_){let l=this._entries.get(c);return this._entries.set(c,_),l}forEach(c){for(let[_,l]of this._entries.entries())c(_,l)}has(c){return this._entries.has(c)}get(c){return this._entries.get(c)}}r.ServiceCollection=o,r.InstantiationService=class{constructor(){this._services=new o,this._services.set(h.IInstantiationService,this)}setService(a,c){this._services.set(a,c)}getService(a){return this._services.get(a)}createInstance(a,...c){let _=(0,u.getServiceDependencies)(a).sort(((t,e)=>t.index-e.index)),l=[];for(let t of _){let e=this._services.get(t.id);if(!e)throw new Error(`[createInstance] ${a.name} depends on UNKNOWN service ${t.id}.`);l.push(e)}let i=_.length>0?_[0].index:c.length;if(c.length!==i)throw new Error(`[createInstance] First service dependency of ${a.name} at position ${i+1} conflicts with ${c.length} static arguments`);return new a(...c,...l)}}},7866:function(x,r,n){var h=this&&this.__decorate||function(i,t,e,s){var d,p=arguments.length,g=p<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")g=Reflect.decorate(i,t,e,s);else for(var v=i.length-1;v>=0;v--)(d=i[v])&&(g=(p<3?d(g):p>3?d(t,e,g):d(t,e))||g);return p>3&&g&&Object.defineProperty(t,e,g),g},u=this&&this.__param||function(i,t){return function(e,s){t(e,s,i)}};Object.defineProperty(r,"__esModule",{value:!0}),r.traceCall=r.setTraceLogger=r.LogService=void 0;let o=n(844),a=n(2585),c={trace:a.LogLevelEnum.TRACE,debug:a.LogLevelEnum.DEBUG,info:a.LogLevelEnum.INFO,warn:a.LogLevelEnum.WARN,error:a.LogLevelEnum.ERROR,off:a.LogLevelEnum.OFF},_,l=r.LogService=class extends o.Disposable{get logLevel(){return this._logLevel}constructor(i){super(),this._optionsService=i,this._logLevel=a.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),_=this}_updateLogLevel(){this._logLevel=c[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(i){for(let t=0;t<i.length;t++)typeof i[t]=="function"&&(i[t]=i[t]())}_log(i,t,e){this._evalLazyOptionalParams(e),i.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t,...e)}trace(i,...t){this._logLevel<=a.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,i,t)}debug(i,...t){this._logLevel<=a.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,i,t)}info(i,...t){this._logLevel<=a.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,i,t)}warn(i,...t){this._logLevel<=a.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,i,t)}error(i,...t){this._logLevel<=a.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,i,t)}};r.LogService=l=h([u(0,a.IOptionsService)],l),r.setTraceLogger=function(i){_=i},r.traceCall=function(i,t,e){if(typeof e.value!="function")throw new Error("not supported");let s=e.value;e.value=function(...d){if(_.logLevel!==a.LogLevelEnum.TRACE)return s.apply(this,d);_.trace(`GlyphRenderer#${s.name}(${d.map((g=>JSON.stringify(g))).join(", ")})`);let p=s.apply(this,d);return _.trace(`GlyphRenderer#${s.name} return`,p),p}}},7302:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OptionsService=r.DEFAULT_OPTIONS=void 0;let h=n(8460),u=n(844),o=n(6114);r.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:o.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};let a=["normal","bold","100","200","300","400","500","600","700","800","900"];class c extends u.Disposable{constructor(l){super(),this._onOptionChange=this.register(new h.EventEmitter),this.onOptionChange=this._onOptionChange.event;let i={...r.DEFAULT_OPTIONS};for(let t in l)if(t in i)try{let e=l[t];i[t]=this._sanitizeAndValidateOption(t,e)}catch(e){console.error(e)}this.rawOptions=i,this.options={...i},this._setupOptions(),this.register((0,u.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(l,i){return this.onOptionChange((t=>{t===l&&i(this.rawOptions[l])}))}onMultipleOptionChange(l,i){return this.onOptionChange((t=>{l.indexOf(t)!==-1&&i()}))}_setupOptions(){let l=t=>{if(!(t in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${t}"`);return this.rawOptions[t]},i=(t,e)=>{if(!(t in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${t}"`);e=this._sanitizeAndValidateOption(t,e),this.rawOptions[t]!==e&&(this.rawOptions[t]=e,this._onOptionChange.fire(t))};for(let t in this.rawOptions){let e={get:l.bind(this,t),set:i.bind(this,t)};Object.defineProperty(this.options,t,e)}}_sanitizeAndValidateOption(l,i){switch(l){case"cursorStyle":if(i||(i=r.DEFAULT_OPTIONS[l]),!(function(t){return t==="block"||t==="underline"||t==="bar"})(i))throw new Error(`"${i}" is not a valid value for ${l}`);break;case"wordSeparator":i||(i=r.DEFAULT_OPTIONS[l]);break;case"fontWeight":case"fontWeightBold":if(typeof i=="number"&&1<=i&&i<=1e3)break;i=a.includes(i)?i:r.DEFAULT_OPTIONS[l];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new Error(`${l} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,4294967295))<0)throw new Error(`${l} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${l} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&i!==0)throw new Error(`${l} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}}r.OptionsService=c},2660:function(x,r,n){var h=this&&this.__decorate||function(c,_,l,i){var t,e=arguments.length,s=e<3?_:i===null?i=Object.getOwnPropertyDescriptor(_,l):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,_,l,i);else for(var d=c.length-1;d>=0;d--)(t=c[d])&&(s=(e<3?t(s):e>3?t(_,l,s):t(_,l))||s);return e>3&&s&&Object.defineProperty(_,l,s),s},u=this&&this.__param||function(c,_){return function(l,i){_(l,i,c)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkService=void 0;let o=n(2585),a=r.OscLinkService=class{constructor(c){this._bufferService=c,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(c){let _=this._bufferService.buffer;if(c.id===void 0){let d=_.addMarker(_.ybase+_.y),p={data:c,id:this._nextId++,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(p,d))),this._dataByLinkId.set(p.id,p),p.id}let l=c,i=this._getEntryIdKey(l),t=this._entriesWithId.get(i);if(t)return this.addLineToLink(t.id,_.ybase+_.y),t.id;let e=_.addMarker(_.ybase+_.y),s={id:this._nextId++,key:this._getEntryIdKey(l),data:l,lines:[e]};return e.onDispose((()=>this._removeMarkerFromLink(s,e))),this._entriesWithId.set(s.key,s),this._dataByLinkId.set(s.id,s),s.id}addLineToLink(c,_){let l=this._dataByLinkId.get(c);if(l&&l.lines.every((i=>i.line!==_))){let i=this._bufferService.buffer.addMarker(_);l.lines.push(i),i.onDispose((()=>this._removeMarkerFromLink(l,i)))}}getLinkData(c){return this._dataByLinkId.get(c)?.data}_getEntryIdKey(c){return`${c.id};;${c.uri}`}_removeMarkerFromLink(c,_){let l=c.lines.indexOf(_);l!==-1&&(c.lines.splice(l,1),c.lines.length===0&&(c.data.id!==void 0&&this._entriesWithId.delete(c.key),this._dataByLinkId.delete(c.id)))}};r.OscLinkService=a=h([u(0,o.IBufferService)],a)},8343:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createDecorator=r.getServiceDependencies=r.serviceRegistry=void 0;let n="di$target",h="di$dependencies";r.serviceRegistry=new Map,r.getServiceDependencies=function(u){return u[h]||[]},r.createDecorator=function(u){if(r.serviceRegistry.has(u))return r.serviceRegistry.get(u);let o=function(a,c,_){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(l,i,t){i[n]===i?i[h].push({id:l,index:t}):(i[h]=[{id:l,index:t}],i[n]=i)})(o,a,_)};return o.toString=()=>u,r.serviceRegistry.set(u,o),o}},2585:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IDecorationService=r.IUnicodeService=r.IOscLinkService=r.IOptionsService=r.ILogService=r.LogLevelEnum=r.IInstantiationService=r.ICharsetService=r.ICoreService=r.ICoreMouseService=r.IBufferService=void 0;let h=n(8343);var u;r.IBufferService=(0,h.createDecorator)("BufferService"),r.ICoreMouseService=(0,h.createDecorator)("CoreMouseService"),r.ICoreService=(0,h.createDecorator)("CoreService"),r.ICharsetService=(0,h.createDecorator)("CharsetService"),r.IInstantiationService=(0,h.createDecorator)("InstantiationService"),(function(o){o[o.TRACE=0]="TRACE",o[o.DEBUG=1]="DEBUG",o[o.INFO=2]="INFO",o[o.WARN=3]="WARN",o[o.ERROR=4]="ERROR",o[o.OFF=5]="OFF"})(u||(r.LogLevelEnum=u={})),r.ILogService=(0,h.createDecorator)("LogService"),r.IOptionsService=(0,h.createDecorator)("OptionsService"),r.IOscLinkService=(0,h.createDecorator)("OscLinkService"),r.IUnicodeService=(0,h.createDecorator)("UnicodeService"),r.IDecorationService=(0,h.createDecorator)("DecorationService")},1480:(x,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeService=void 0;let h=n(8460),u=n(225);class o{static extractShouldJoin(c){return(1&c)!=0}static extractWidth(c){return c>>1&3}static extractCharKind(c){return c>>3}static createPropertyValue(c,_,l=!1){return(16777215&c)<<3|(3&_)<<1|(l?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new h.EventEmitter,this.onChange=this._onChange.event;let c=new u.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let _=0,l=0,i=c.length;for(let t=0;t<i;++t){let e=c.charCodeAt(t);if(55296<=e&&e<=56319){if(++t>=i)return _+this.wcwidth(e);let p=c.charCodeAt(t);56320<=p&&p<=57343?e=1024*(e-55296)+p-56320+65536:_+=this.wcwidth(p)}let s=this.charProperties(e,l),d=o.extractWidth(s);o.extractShouldJoin(s)&&(d-=o.extractWidth(l)),_+=d,l=s}return _}charProperties(c,_){return this._activeProvider.charProperties(c,_)}}r.UnicodeService=o}},S={};function T(x){var r=S[x];if(r!==void 0)return r.exports;var n=S[x]={exports:{}};return y[x].call(n.exports,n,n.exports,T),n.exports}var M={};return(()=>{var x=M;Object.defineProperty(x,"__esModule",{value:!0}),x.Terminal=void 0;let r=T(9042),n=T(3236),h=T(844),u=T(5741),o=T(8285),a=T(7975),c=T(7090),_=["cols","rows"];class l extends h.Disposable{constructor(t){super(),this._core=this.register(new n.Terminal(t)),this._addonManager=this.register(new u.AddonManager),this._publicOptions={...this._core.options};let e=d=>this._core.options[d],s=(d,p)=>{this._checkReadonlyOptions(d),this._core.options[d]=p};for(let d in this._core.options){let p={get:e.bind(this,d),set:s.bind(this,d)};Object.defineProperty(this._publicOptions,d,p)}}_checkReadonlyOptions(t){if(_.includes(t))throw new Error(`Option "${t}" 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 a.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new c.UnicodeApi(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 o.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any"}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,s){this._verifyIntegers(t,e,s),this._core.select(t,e,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
10
+ `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return r}_verifyIntegers(...t){for(let e of t)if(e===1/0||isNaN(e)||e%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(let e of t)if(e&&(e===1/0||isNaN(e)||e%1!=0||e<0))throw new Error("This API only accepts positive integers")}}x.Terminal=l})(),M})()))});var ni=Ht((bt,Wt)=>{(function(y,S){typeof bt=="object"&&typeof Wt=="object"?Wt.exports=S():typeof define=="function"&&define.amd?define([],S):typeof bt=="object"?bt.FitAddon=S():y.FitAddon=S()})(self,(()=>(()=>{"use strict";var y={};return(()=>{var S=y;Object.defineProperty(S,"__esModule",{value:!0}),S.FitAddon=void 0,S.FitAddon=class{activate(T){this._terminal=T}dispose(){}fit(){let T=this.proposeDimensions();if(!T||!this._terminal||isNaN(T.cols)||isNaN(T.rows))return;let M=this._terminal._core;this._terminal.rows===T.rows&&this._terminal.cols===T.cols||(M._renderService.clear(),this._terminal.resize(T.cols,T.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let T=this._terminal._core,M=T._renderService.dimensions;if(M.css.cell.width===0||M.css.cell.height===0)return;let x=this._terminal.options.scrollback===0?0:T.viewport.scrollBarWidth,r=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(r.getPropertyValue("height")),h=Math.max(0,parseInt(r.getPropertyValue("width"))),u=window.getComputedStyle(this._terminal.element),o=n-(parseInt(u.getPropertyValue("padding-top"))+parseInt(u.getPropertyValue("padding-bottom"))),a=h-(parseInt(u.getPropertyValue("padding-right"))+parseInt(u.getPropertyValue("padding-left")))-x;return{cols:Math.max(2,Math.floor(a/M.css.cell.width)),rows:Math.max(1,Math.floor(o/M.css.cell.height))}}}})(),y})()))});var oi=Ht((St,$t)=>{(function(y,S){typeof St=="object"&&typeof $t=="object"?$t.exports=S():typeof define=="function"&&define.amd?define([],S):typeof St=="object"?St.SearchAddon=S():y.SearchAddon=S()})(self,(()=>(()=>{"use strict";var y={345:(x,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.runAndSubscribe=r.forwardEvent=r.EventEmitter=void 0,r.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let h=0;h<this._listeners.length;h++)if(this._listeners[h]===n)return void this._listeners.splice(h,1)}}})),this._event}fire(n,h){let u=[];for(let o=0;o<this._listeners.length;o++)u.push(this._listeners[o]);for(let o=0;o<u.length;o++)u[o].call(void 0,n,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(n,h){return n((u=>h.fire(u)))},r.runAndSubscribe=function(n,h){return h(void 0),n((u=>h(u)))}},859:(x,r)=>{function n(h){for(let u of h)u.dispose();h.length=0}Object.defineProperty(r,"__esModule",{value:!0}),r.getDisposeArrayDisposable=r.disposeArray=r.toDisposable=r.MutableDisposable=r.Disposable=void 0,r.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){let u=this._disposables.indexOf(h);u!==-1&&this._disposables.splice(u,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){this._isDisposed||h===this._value||(this._value?.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},r.toDisposable=function(h){return{dispose:h}},r.disposeArray=n,r.getDisposeArrayDisposable=function(h){return{dispose:()=>n(h)}}}},S={};function T(x){var r=S[x];if(r!==void 0)return r.exports;var n=S[x]={exports:{}};return y[x](n,n.exports,T),n.exports}var M={};return(()=>{var x=M;Object.defineProperty(x,"__esModule",{value:!0}),x.SearchAddon=void 0;let r=T(345),n=T(859),h=" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?";class u extends n.Disposable{constructor(a){super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new n.MutableDisposable),this._linesCacheTimeoutId=0,this._linesCacheDisposables=new n.MutableDisposable,this._onDidChangeResults=this.register(new r.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=a?.highlightLimit??1e3}activate(a){this._terminal=a,this.register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this.register(this._terminal.onResize((()=>this._updateMatches()))),this.register((0,n.toDisposable)((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout((()=>{let a=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(a,{...this._lastSearchOptions,incremental:!0,noScroll:!0})}),200))}clearDecorations(a){this._selectedDecoration.clear(),(0,n.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),a||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(a,c){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let _=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,c);this._lastSearchOptions=c,c?.decorations&&(this._cachedSearchTerm===void 0||a!==this._cachedSearchTerm||_)&&this._highlightAllMatches(a,c);let l=this._findNextAndSelect(a,c);return this._fireResults(c),this._cachedSearchTerm=a,l}_highlightAllMatches(a,c){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!a||a.length===0)return void this.clearDecorations();c=c||{},this.clearDecorations(!0);let _=[],l,i=this._find(a,0,0,c);for(;i&&(l?.row!==i.row||l?.col!==i.col)&&!(_.length>=this._highlightLimit);)l=i,_.push(l),i=this._find(a,l.col+l.term.length>=this._terminal.cols?l.row+1:l.row,l.col+l.term.length>=this._terminal.cols?0:l.col+1,c);for(let t of _){let e=this._createResultDecoration(t,c.decorations);e&&(this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}}))}}_find(a,c,_,l){if(!this._terminal||!a||a.length===0)return this._terminal?.clearSelection(),void this.clearDecorations();if(_>this._terminal.cols)throw new Error(`Invalid col: ${_} to search in terminal of ${this._terminal.cols} cols`);let i;this._initLinesCache();let t={startRow:c,startCol:_};if(i=this._findInLine(a,t,l),!i)for(let e=c+1;e<this._terminal.buffer.active.baseY+this._terminal.rows&&(t.startRow=e,t.startCol=0,i=this._findInLine(a,t,l),!i);e++);return i}_findNextAndSelect(a,c){if(!this._terminal||!a||a.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let _=this._terminal.getSelectionPosition();this._terminal.clearSelection();let l=0,i=0;_&&(this._cachedSearchTerm===a?(l=_.end.x,i=_.end.y):(l=_.start.x,i=_.start.y)),this._initLinesCache();let t={startRow:i,startCol:l},e=this._findInLine(a,t,c);if(!e)for(let s=i+1;s<this._terminal.buffer.active.baseY+this._terminal.rows&&(t.startRow=s,t.startCol=0,e=this._findInLine(a,t,c),!e);s++);if(!e&&i!==0)for(let s=0;s<i&&(t.startRow=s,t.startCol=0,e=this._findInLine(a,t,c),!e);s++);return!e&&_&&(t.startRow=_.start.y,t.startCol=0,e=this._findInLine(a,t,c)),this._selectResult(e,c?.decorations,c?.noScroll)}findPrevious(a,c){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let _=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,c);this._lastSearchOptions=c,c?.decorations&&(this._cachedSearchTerm===void 0||a!==this._cachedSearchTerm||_)&&this._highlightAllMatches(a,c);let l=this._findPreviousAndSelect(a,c);return this._fireResults(c),this._cachedSearchTerm=a,l}_didOptionsChange(a,c){return!!c&&(a.caseSensitive!==c.caseSensitive||a.regex!==c.regex||a.wholeWord!==c.wholeWord)}_fireResults(a){if(a?.decorations){let c=-1;if(this._selectedDecoration.value){let _=this._selectedDecoration.value.match;for(let l=0;l<this._highlightDecorations.length;l++){let i=this._highlightDecorations[l].match;if(i.row===_.row&&i.col===_.col&&i.size===_.size){c=l;break}}}this._onDidChangeResults.fire({resultIndex:c,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(a,c){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!this._terminal||!a||a.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let _=this._terminal.getSelectionPosition();this._terminal.clearSelection();let l=this._terminal.buffer.active.baseY+this._terminal.rows-1,i=this._terminal.cols,t=!0;this._initLinesCache();let e={startRow:l,startCol:i},s;if(_&&(e.startRow=l=_.start.y,e.startCol=i=_.start.x,this._cachedSearchTerm!==a&&(s=this._findInLine(a,e,c,!1),s||(e.startRow=l=_.end.y,e.startCol=i=_.end.x))),s||(s=this._findInLine(a,e,c,t)),!s){e.startCol=Math.max(e.startCol,this._terminal.cols);for(let d=l-1;d>=0&&(e.startRow=d,s=this._findInLine(a,e,c,t),!s);d--);}if(!s&&l!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let d=this._terminal.buffer.active.baseY+this._terminal.rows-1;d>=l&&(e.startRow=d,s=this._findInLine(a,e,c,t),!s);d--);return this._selectResult(s,c?.decorations,c?.noScroll)}_initLinesCache(){let a=this._terminal;this._linesCache||(this._linesCache=new Array(a.buffer.active.length),this._linesCacheDisposables.value=(0,n.getDisposeArrayDisposable)([a.onLineFeed((()=>this._destroyLinesCache())),a.onCursorMove((()=>this._destroyLinesCache())),a.onResize((()=>this._destroyLinesCache()))])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&(window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=0)}_isWholeWord(a,c,_){return(a===0||h.includes(c[a-1]))&&(a+_.length===c.length||h.includes(c[a+_.length]))}_findInLine(a,c,_={},l=!1){let i=this._terminal,t=c.startRow,e=c.startCol;if(i.buffer.active.getLine(t)?.isWrapped)return l?void(c.startCol+=i.cols):(c.startRow--,c.startCol+=i.cols,this._findInLine(a,c,_));let d=this._linesCache?.[t];d||(d=this._translateBufferLineToStringWithWrap(t,!0),this._linesCache&&(this._linesCache[t]=d));let[p,g]=d,v=this._bufferColsToStringOffset(t,e),f=_.caseSensitive?a:a.toLowerCase(),m=_.caseSensitive?p:p.toLowerCase(),L=-1;if(_.regex){let k=RegExp(f,"g"),E;if(l)for(;E=k.exec(m.slice(0,v));)L=k.lastIndex-E[0].length,a=E[0],k.lastIndex-=a.length-1;else E=k.exec(m.slice(v)),E&&E[0].length>0&&(L=v+(k.lastIndex-E[0].length),a=E[0])}else l?v-f.length>=0&&(L=m.lastIndexOf(f,v-f.length)):L=m.indexOf(f,v);if(L>=0){if(_.wholeWord&&!this._isWholeWord(L,m,a))return;let k=0;for(;k<g.length-1&&L>=g[k+1];)k++;let E=k;for(;E<g.length-1&&L+a.length>=g[E+1];)E++;let C=L-g[k],B=L+a.length-g[E],z=this._stringLengthToBufferSize(t+k,C);return{term:a,col:z,row:t+k,size:this._stringLengthToBufferSize(t+E,B)-z+i.cols*(E-k)}}}_stringLengthToBufferSize(a,c){let _=this._terminal.buffer.active.getLine(a);if(!_)return 0;for(let l=0;l<c;l++){let i=_.getCell(l);if(!i)break;let t=i.getChars();t.length>1&&(c-=t.length-1);let e=_.getCell(l+1);e&&e.getWidth()===0&&c++}return c}_bufferColsToStringOffset(a,c){let _=this._terminal,l=a,i=0,t=_.buffer.active.getLine(l);for(;c>0&&t;){for(let e=0;e<c&&e<_.cols;e++){let s=t.getCell(e);if(!s)break;s.getWidth()&&(i+=s.getCode()===0?1:s.getChars().length)}if(l++,t=_.buffer.active.getLine(l),t&&!t.isWrapped)break;c-=_.cols}return i}_translateBufferLineToStringWithWrap(a,c){let _=this._terminal,l=[],i=[0],t=_.buffer.active.getLine(a);for(;t;){let e=_.buffer.active.getLine(a+1),s=!!e&&e.isWrapped,d=t.translateToString(!s&&c);if(s&&e){let p=t.getCell(t.length-1);p&&p.getCode()===0&&p.getWidth()===1&&e.getCell(0)?.getWidth()===2&&(d=d.slice(0,-1))}if(l.push(d),!s)break;i.push(i[i.length-1]+d.length),a++,t=e}return[l.join(""),i]}_selectResult(a,c,_){let l=this._terminal;if(this._selectedDecoration.clear(),!a)return l.clearSelection(),!1;if(l.select(a.col,a.row,a.size),c){let i=l.registerMarker(-l.buffer.active.baseY-l.buffer.active.cursorY+a.row);if(i){let t=l.registerDecoration({marker:i,x:a.col,width:a.size,backgroundColor:c.activeMatchBackground,layer:"top",overviewRulerOptions:{color:c.activeMatchColorOverviewRuler}});if(t){let e=[];e.push(i),e.push(t.onRender((s=>this._applyStyles(s,c.activeMatchBorder,!0)))),e.push(t.onDispose((()=>(0,n.disposeArray)(e)))),this._selectedDecoration.value={decoration:t,match:a,dispose(){t.dispose()}}}}}if(!_&&(a.row>=l.buffer.active.viewportY+l.rows||a.row<l.buffer.active.viewportY)){let i=a.row-l.buffer.active.viewportY;i-=Math.floor(l.rows/2),l.scrollLines(i)}return!0}_applyStyles(a,c,_){a.classList.contains("xterm-find-result-decoration")||(a.classList.add("xterm-find-result-decoration"),c&&(a.style.outline=`1px solid ${c}`)),_&&a.classList.add("xterm-find-active-result-decoration")}_createResultDecoration(a,c){let _=this._terminal,l=_.registerMarker(-_.buffer.active.baseY-_.buffer.active.cursorY+a.row);if(!l)return;let i=_.registerDecoration({marker:l,x:a.col,width:a.size,backgroundColor:c.matchBackground,overviewRulerOptions:this._highlightedLines.has(l.line)?void 0:{color:c.matchOverviewRuler,position:"center"}});if(i){let t=[];t.push(l),t.push(i.onRender((e=>this._applyStyles(e,c.matchBorder,!1)))),t.push(i.onDispose((()=>(0,n.disposeArray)(t))))}return i}}x.SearchAddon=u})(),M})()))});var hr={};Vi(hr,{apply:()=>ar,inject:()=>nr});module.exports=Ji(hr);var me=require("react");var Z=require("react");var de="zTerm";async function te(y,S,T={},M){let x=y.connection;if(!x?.rpc?.call)throw new Error("\u5F53\u524D DSH \u7F3A\u5C11 Connection RPC\uFF0C\u8BF7\u4F7F\u7528\u5DF2\u652F\u6301\u7684\u5BBF\u4E3B\u7248\u672C");let r=await x.rpc.call("/api",`zterm/${S}`,T,M);if(!r.ok)throw new Error(r.error?.message||`${de} \u8BF7\u6C42\u5931\u8D25`);return r.value}function gt(y,S,T="text/plain;charset=utf-8"){let M=URL.createObjectURL(new Blob([S],{type:T})),x=document.createElement("a");x.href=M,x.download=y,x.click(),URL.revokeObjectURL(M)}function vt(){return new Date().toISOString().replace(/[-:]/g,"").replace(/T/,"-").slice(0,15)}function ti(y,S=Date.now()){if(!y)return;let T=Date.parse(y);if(!Number.isFinite(T))return;let M=Math.floor((S-T)/1e3);if(!(M<2))return M<60?`\u5DF2 ${M} \u79D2`:`\u5DF2 ${Math.floor(M/60)} \u5206 ${M%60} \u79D2`}var ei=0;function ii(y,S){let T=new Map(y);if(S.reset){T.clear();for(let r of S.snapshots??[])T.set(r.terminalId,{generation:r.generation,text:r.text,seq:S.cursor,epoch:++ei,end:r.text.length})}let M=new Map,x=r=>({generation:r,seq:Number.NEGATIVE_INFINITY,base:"",parts:[],epoch:++ei,end:0});for(let r of S.output??[]){let n=T.get(r.terminalId),h=M.get(r.terminalId);h?h.generation!==r.generation&&(h=x(r.generation),M.set(r.terminalId,h)):(h=n&&n.generation===r.generation?{generation:r.generation,seq:n.seq,base:n.text,parts:[],epoch:n.epoch,end:n.end}:x(r.generation),M.set(r.terminalId,h)),!(r.seq<=h.seq)&&(h.seq=r.seq,h.parts.push(r.text),h.end+=r.text.length)}for(let[r,n]of M)n.parts.length&&T.set(r,{generation:n.generation,text:`${n.base}${n.parts.join("")}`.slice(-5e5),seq:n.seq,epoch:n.epoch,end:n.end});for(let r of T.keys())S.workspace.terminals.some(n=>n.id===r)||T.delete(r);return T}var ue=require("react"),fi=Nt(si(),1),_i=Nt(ni(),1),pi=Nt(oi(),1);var Xe=require("react");function rt(y,S,T,M){try{let x=localStorage.getItem(y),r=x===null?S:Number(x);return Number.isFinite(r)?Math.max(T,Math.min(M,r)):S}catch{return S}}function st(y,S){try{localStorage.setItem(y,String(S))}catch{}}var Ge=12,Ct=8,wt=32,Ut="dsh-zterm.terminal-font-size",it=new Set,yt;function li(y){return Number.isInteger(y)&&y>=Ct&&y<=wt}function jt(){try{let y=localStorage.getItem(Ut),S=y===null?Ge:Number(y);return li(S)?S:Ge}catch{return yt??Ge}}function hi(){return yt??=jt()}function ci(y){y!==hi()&&(yt=y,it.forEach(S=>S()))}function di(y){li(y)&&(ci(y),st(Ut,y))}function ai(y){(y.key===Ut||y.key===null)&&ci(jt())}function Gi(y){return!it.size&&typeof window<"u"&&(yt=jt(),window.addEventListener("storage",ai)),it.add(y),()=>{it.delete(y),!it.size&&typeof window<"u"&&window.removeEventListener("storage",ai)}}function xt(){return(0,Xe.useSyncExternalStore)(Gi,hi,()=>Ge)}function Et(){let y=(0,Xe.useRef)(()=>{});return(0,Xe.useEffect)(()=>()=>y.current(),[]),(S,T)=>{S.preventDefault(),y.current();let M=()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",M),y.current=()=>{}};y.current=M,window.addEventListener("mousemove",T),window.addEventListener("mouseup",M,{once:!0})}}var He=require("react/jsx-runtime"),Xi=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.userAgentData?.platform||navigator.platform||"");function Yi(y){return(/^[a-z]$/i.test(y.key)?y.key.toLowerCase()==="f":y.code==="KeyF")&&!y.altKey&&(Xi?y.metaKey&&!y.ctrlKey&&!y.shiftKey:y.ctrlKey&&y.shiftKey&&!y.metaKey)}var Zi=/^(?:\x1b\[[?>]?[\d;]*[cnRt]|\x1b\[\??\d+;\d+\$y|\x1bP[01]\$r[^\x1b]*\x1b\\|\x1b\][\d;]+;rgb:[\da-fA-F/]+(?:\x1b\\|\x07))+$/,ui={epoch:-1,end:0,text:""};function gi({ctx:y,sessionId:S,terminal:T,buffer:M,visible:x,onError:r}){let n=(0,ue.useRef)(null),h=(0,ue.useRef)(),u=(0,ue.useRef)(),o=(0,ue.useRef)(),a=(0,ue.useRef)(ui),c=(0,ue.useRef)(T),_=(0,ue.useRef)(r),l=(0,ue.useRef)(Promise.resolve()),i=(0,ue.useRef)(()=>{}),t=(0,ue.useRef)(()=>{}),e=(0,ue.useRef)(()=>{}),s=(0,ue.useRef)(!1),[d,p]=(0,ue.useState)(""),g=xt(),v=(0,ue.useRef)(g),f=(0,ue.useRef)(M);v.current=g,f.current=M,c.current=T,_.current=r;let m=()=>{let k=h.current,E=f.current,C=s.current;if(s.current=!1,!k||!E||E.generation!==c.current.generation)return;let B=a.current;if(B.epoch===E.epoch&&B.end===E.end)return;let z=B.epoch===E.epoch?B.end-(E.end-E.text.length):-1;z>=0&&z<=E.text.length?e.current(E.text.slice(z),C):E.text.startsWith(B.text)?e.current(E.text.slice(B.text.length),C||!!B.text):(k.reset(),e.current(E.text,!0)),a.current={epoch:E.epoch,end:E.end,text:E.text}},L=()=>{if(h.current||!n.current)return;let k=n.current,E=new fi.Terminal({cursorBlink:!0,fontSize:v.current,fontFamily:"Menlo, Consolas, monospace",scrollback:5e3,allowProposedApi:!1,convertEol:!1,theme:{background:"#12161d",foreground:"#dce3ed",cursor:"#e4edf8",selectionBackground:"#334b66"}}),C=new _i.FitAddon,B=new pi.SearchAddon;E.loadAddon(C),E.loadAddon(B),E.open(k),h.current=E,o.current=C,u.current=B,a.current=ui;let z=!1,j=0;e.current=(A,H)=>{if(A){if(!H){E.write(A);return}j++,E.write(A,()=>{j--})}};let U=E.onData(A=>{let H=c.current;H.state==="ready"&&(j>0&&Zi.test(A)||(l.current=l.current.catch(()=>{}).then(async()=>{z||await te(y,"input",{sessionId:S,terminalId:H.id,generation:H.generation,data:A})}).catch(q=>{z||_.current(q.message)})))}),$;i.current=()=>{if(z||!n.current?.clientWidth)return;C.fit();let A=c.current;A.state==="ready"&&te(y,"resize",{sessionId:S,terminalId:A.id,generation:A.generation,cols:E.cols,rows:E.rows}).catch(H=>{z||_.current(H.message)})};let b=()=>{clearTimeout($),$=setTimeout(()=>i.current(),80)},D=new ResizeObserver(b);D.observe(k),b();let R=A=>{Yi(A)&&(A.preventDefault(),A.stopPropagation(),document.getElementById(`zterm-find-${T.id}`)?.focus())};k.addEventListener("keydown",R,!0),t.current=()=>{z=!0,i.current=()=>{},e.current=()=>{},clearTimeout($),D.disconnect(),U.dispose(),k.removeEventListener("keydown",R,!0),E.dispose(),h.current=void 0}};return(0,ue.useLayoutEffect)(()=>()=>{t.current(),t.current=()=>{}},[y,S,T.id,T.generation]),(0,ue.useLayoutEffect)(()=>{x&&(L(),s.current=!0,m())},[x,y,S,T.id,T.generation]),(0,ue.useEffect)(()=>{x&&m()},[M,T.generation]),(0,ue.useLayoutEffect)(()=>{let k=h.current;!x||!k||k.options.fontSize===g||(k.options.fontSize=g,i.current())},[g,x]),(0,ue.useEffect)(()=>{x&&(i.current(),h.current?.focus())},[x,T.state,T.generation]),(0,He.jsxs)("div",{className:"zt-terminal-screen",style:{display:x?"flex":"none"},children:[(0,He.jsxs)("div",{className:"zt-terminal-search",children:[(0,He.jsx)("input",{id:`zterm-find-${T.id}`,"aria-label":"\u641C\u7D22\u7EC8\u7AEF\u8F93\u51FA",placeholder:"\u641C\u7D22\u7EC8\u7AEF\u8F93\u51FA",value:d,onChange:k=>{p(k.target.value),u.current?.findNext(k.target.value)},onKeyDown:k=>{k.key==="Enter"&&u.current?.findNext(d),k.key==="Escape"&&(p(""),h.current?.focus())}}),(0,He.jsx)("button",{title:"\u4E0A\u4E00\u4E2A\u5339\u914D",onClick:()=>u.current?.findPrevious(d),children:"\u2191"}),(0,He.jsx)("button",{title:"\u4E0B\u4E00\u4E2A\u5339\u914D",onClick:()=>u.current?.findNext(d),children:"\u2193"}),(0,He.jsx)("span",{children:"\u7EC8\u7AEF\u8F93\u5165\u76F4\u63A5\u64CD\u4F5C\u5F53\u524D\u673A\u5668"})]}),(0,He.jsx)("div",{className:"zt-terminal-canvas",ref:n})]})}var _e=require("react");var Ue={password:"\u5BC6\u7801",key:"\u79C1\u94A5\u5185\u5BB9","key-file":"\u79C1\u94A5\u6587\u4EF6"};var Ie=require("react");var nt=class{expanded;scroll=new Map;pages=new Map;pending=new Map;listeners=new Set;version=0;onChange;constructor(S=[]){this.expanded=new Set(S)}subscribe=S=>(this.listeners.add(S),()=>{this.listeners.delete(S)});snapshot=()=>this.version;changed(){this.version++,this.listeners.forEach(S=>S()),this.onChange?.()}setScroll(S,T){this.scroll.set(S,T),S==="tree"&&this.onChange?.()}restore(S){this.expanded.clear(),S.expanded.forEach(T=>this.expanded.add(T)),this.scroll.set("tree",S.scroll);for(let[T,M]of S.pages)this.pages.set(T,{...M,status:"ready",stale:!0})}export(){return{expanded:[...this.expanded],scroll:this.scroll.get("tree")??0,pages:[...this.pages].flatMap(([S,T])=>!S.startsWith("search:")&&T.data?[[S,{offset:T.offset,data:T.data}]]:[])}}page(S){return this.pages.get(S)}toggle(S){this.expanded.has(S)?this.expanded.delete(S):this.expanded.add(S),this.changed()}reveal(S){S.forEach(T=>this.expanded.add(T)),this.changed()}retain(S){for(let T of this.expanded)S.has(T)||this.expanded.delete(T)}seed(S,T){(this.pages.get(S)?.offset??0)===0&&(this.cancel(S),this.pages.set(S,{offset:0,status:"ready",data:T,updatedAt:Date.now()}),this.changed())}async load(S,T,M=this.pages.get(S)?.offset??0){this.pending.get(S)?.abort();let x=this.pages.get(S),r=x?.offset===M?x.data:void 0,n=new AbortController;this.pending.set(S,n),this.pages.set(S,{offset:M,status:r?"ready":"loading",data:r,refreshing:!0}),this.changed();try{let h=await T(M,n.signal);if(n.signal.aborted||this.pending.get(S)!==n||(M>0&&!h.items.length&&(M=0,h=await T(0,n.signal)),n.signal.aborted||this.pending.get(S)!==n))return;this.pages.set(S,{offset:M,status:"ready",data:h,updatedAt:Date.now()})}catch(h){if(n.signal.aborted||this.pending.get(S)!==n)return;this.pages.set(S,{offset:r?x.offset:M,status:r?"ready":"error",data:r,error:h instanceof Error?h.message:"\u8BFB\u53D6\u5931\u8D25"})}finally{this.pending.get(S)===n&&(this.pending.delete(S),this.changed())}}ensure(S,T,M=!1){let x=this.pages.get(S);!this.pending.has(S)&&(!x||x.status==="idle"||x.stale||M&&Date.now()-(x.updatedAt??0)>=3e3)&&this.load(S,T)}cancel(S){let T=this.pending.get(S);if(!T)return;T.abort(),this.pending.delete(S);let M=this.pages.get(S);this.pages.set(S,M.data?{...M,status:"ready",refreshing:!1,stale:!0}:{offset:M.offset,status:"idle"}),this.changed()}forget(S){this.cancel(S),this.pages.delete(S)&&this.changed()}invalidate(S=!1){this.pending.forEach(T=>T.abort()),this.pending.clear();for(let[T,M]of this.pages)this.pages.set(T,!S&&M.data?{...M,stale:!0,refreshing:!1,error:void 0}:{offset:M.offset,status:"idle"});this.changed()}dispose(){this.pending.forEach(S=>S.abort()),this.pending.clear(),this.listeners.clear()}};function kt(y,S,T,M,x=500){let r=y.slice().reverse().map(o=>({node:o,depth:0,content:!1})),n=[],h=new Set,u=!1;for(;r.length;){let o=r.pop(),a=S(o.node);if(o.content){n.push(o);continue}if(!h.has(a)){if(h.size>=x){u=!0;continue}if(h.add(a),n.push(o),!!M.has(a)){r.push({...o,content:!0});for(let c of T(o.node).slice().reverse())r.push({node:c,depth:o.depth+1,content:!1})}}}return{rows:n,truncated:u}}function Dt(y,S){let T=new Set;return y.filter(M=>{let x=S(M);return T.has(x)?!1:(T.add(x),!0)})}var Be=require("react"),Se=require("react/jsx-runtime"),ot=y=>({paddingLeft:`min(${Math.min(8,y)*12}px, 25%)`});function at(y){return(0,Be.useSyncExternalStore)(y.subscribe,y.snapshot,y.snapshot)}function Ye(y,S,T,M=!0,x=!1){let r=at(y),n=(0,Be.useRef)(T);return n.current=T,(0,Be.useEffect)(()=>{M&&y.ensure(S,(h,u)=>n.current(h,u),!0)},[y,S,M]),(0,Be.useEffect)(()=>{M&&y.ensure(S,(h,u)=>n.current(h,u))},[y,S,M,r]),(0,Be.useEffect)(()=>()=>{x?y.forget(S):y.cancel(S)},[y,S,x]),{page:y.page(S),load:h=>{y.load(S,(u,o)=>n.current(u,o),h)}}}function Lt({state:y,view:S,label:T,children:M}){let x=(0,Be.useRef)(null);return(0,Be.useLayoutEffect)(()=>{x.current&&(x.current.scrollTop=y.scroll.get(S)??0)},[y,S]),(0,Se.jsx)("nav",{ref:x,className:"zt-asset-tree","aria-label":T,onScroll:r=>y.setScroll(S,r.currentTarget.scrollTop),children:M})}function lt({label:y,expanded:S,depth:T,selected:M,onToggle:x,actions:r}){return(0,Se.jsxs)("div",{className:`zt-directory-row${M?" active":""}`,style:ot(T),children:[(0,Se.jsxs)("button",{className:"zt-directory-name","aria-expanded":S,"aria-label":`${S?"\u6536\u8D77":"\u5C55\u5F00"}\u6587\u4EF6\u5939 ${y}`,title:y,onClick:x,children:[(0,Se.jsx)("span",{className:"zt-directory-arrow","aria-hidden":"true",children:S?"\u25BE":"\u25B8"}),(0,Se.jsxs)("span",{className:"zt-directory-label",children:["\u25B1 ",y]})]}),r]})}function Ze({page:y,label:S,retry:T}){return y?.data?y.error?(0,Se.jsxs)("div",{className:"zt-tree-message",role:"status",children:[(0,Se.jsxs)("span",{title:y.error,children:[S,"\u66F4\u65B0\u5931\u8D25\uFF0C\u5F53\u524D\u663E\u793A\u7F13\u5B58"]}),(0,Se.jsx)("button",{onClick:T,children:"\u91CD\u8BD5"})]}):null:!y||y.status==="idle"||y.status==="loading"?(0,Se.jsxs)("p",{className:"zt-tree-message",role:"status",children:["\u6B63\u5728\u52A0\u8F7D",S,"\u2026"]}):y.status==="error"?(0,Se.jsxs)("div",{className:"zt-tree-message zt-error",role:"alert",children:[(0,Se.jsxs)("span",{children:[S,"\uFF1A",y.error]}),(0,Se.jsx)("button",{onClick:T,children:"\u91CD\u8BD5"})]}):null}function Rt({page:y,size:S,label:T,load:M}){return y?.status!=="ready"||!y.offset&&!y.data?.hasMore?null:(0,Se.jsxs)("div",{className:"zt-pagination","aria-label":`${T}\u5206\u9875`,children:[(0,Se.jsxs)("span",{children:[y.data?.total??0," \u53F0 \xB7 \u7B2C ",Math.floor(y.offset/S)+1," \u9875"]}),(0,Se.jsx)("button",{"aria-label":`${T}\u4E0A\u4E00\u9875`,disabled:!y.offset,onClick:()=>M(Math.max(0,y.offset-S)),children:"\u2039"}),(0,Se.jsx)("button",{"aria-label":`${T}\u4E0B\u4E00\u9875`,disabled:!y.data?.hasMore,onClick:()=>M(y.offset+S),children:"\u203A"})]})}var se=require("react/jsx-runtime");function Tt(y){let S=new Map;for(let r of y){let n=r.parentId??"";S.set(n,[...S.get(n)??[],r])}let T=(S.get("")??[]).slice().reverse().map(r=>({...r,depth:0})),M=[],x=new Set;for(;T.length;){let r=T.pop();if(!x.has(r.id)){x.add(r.id),M.push(r);for(let n of(S.get(r.id)??[]).slice().reverse())T.push({...n,depth:r.depth+1})}}return M}function Qi({folder:y,busy:S,onEdit:T,onDelete:M}){let x=(0,Ie.useRef)(null),r=(0,Ie.useRef)(null),n=(0,Ie.useId)(),[h,u]=(0,Ie.useState)(!1);(0,Ie.useEffect)(()=>{let c=x.current;c.setAttribute("popover","auto"),r.current.setAttribute("popovertarget",n);let _=()=>{let l=c.matches(":popover-open");if(u(l),!l)return;let i=r.current.getBoundingClientRect();c.style.left=`${Math.max(8,Math.min(i.right-c.offsetWidth,window.innerWidth-c.offsetWidth-8))}px`,c.style.top=`${Math.max(8,i.bottom+c.offsetHeight+4<=window.innerHeight-8?i.bottom+4:i.top-c.offsetHeight-4)}px`,c.querySelector("button")?.focus({preventScroll:!0})};return c.addEventListener("toggle",_),()=>c.removeEventListener("toggle",_)},[n]),(0,Ie.useEffect)(()=>{if(!h)return;let c=()=>x.current?.hidePopover();return window.addEventListener("resize",c),document.addEventListener("scroll",c,!0),()=>{window.removeEventListener("resize",c),document.removeEventListener("scroll",c,!0)}},[h]);let o=c=>{x.current?.hidePopover(),c(y)},a=c=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(c.key))return;c.preventDefault();let _=[...c.currentTarget.querySelectorAll("button")],l=_.indexOf(document.activeElement),i=c.key==="Home"?0:c.key==="End"?_.length-1:(l+(c.key==="ArrowUp"?-1:1)+_.length)%_.length;_[i]?.focus()};return(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)("button",{ref:r,disabled:S,className:"zt-folder-action","aria-label":`\u6587\u4EF6\u5939\u64CD\u4F5C ${y.label}`,title:"\u6587\u4EF6\u5939\u64CD\u4F5C","aria-haspopup":"menu","aria-controls":n,"aria-expanded":h,children:"\u22EF"}),(0,se.jsxs)("div",{ref:x,id:n,className:"zt-folder-menu",role:"menu","aria-label":`\u6587\u4EF6\u5939\u64CD\u4F5C ${y.label}`,onKeyDown:a,children:[(0,se.jsx)("button",{role:"menuitem",disabled:S,onClick:()=>o(T),children:"\u66F4\u540D"}),(0,se.jsx)("button",{role:"menuitem",disabled:S,onClick:()=>o(M),children:"\u5220\u9664"})]})]})}function vi({props:y,folder:S,depth:T,hasChildren:M=!1}){let{ctx:x,state:r,query:n,busy:h,onConnect:u,onHostEdit:o,onHostDelete:a}=y,c=S?`hosts:${S.id}`:`search:${n}`,_=S?.label??"\u641C\u7D22\u7ED3\u679C",{page:l,load:i}=Ye(r,c,async(t,e)=>{let s=await te(x,"catalog",{offset:t,query:S?void 0:n,folderId:S?S.id||"root":void 0},e);return{items:s.hosts,total:s.total,hasMore:t+200<s.total}},!0,!S);return(0,se.jsxs)("div",{className:"zt-tree-content",style:ot(T),"data-host-folder":S?.id??"search",children:[(0,se.jsx)(Ze,{page:l,label:_,retry:()=>i()}),l?.status==="ready"&&(0,se.jsxs)(se.Fragment,{children:[l.data?.items.map(t=>(0,se.jsxs)("div",{className:"zt-host-row",children:[(0,se.jsxs)("button",{className:"zt-host-connect",disabled:h,onClick:()=>u(t),title:`\u8FDE\u63A5 ${t.username}@${t.host}:${t.port}`,children:[(0,se.jsx)("span",{className:"zt-host-glyph",children:"\u25A4"}),(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{children:t.label}),(0,se.jsxs)("small",{children:[t.username,"@",t.host]})]})]}),(0,se.jsx)("button",{disabled:h,title:"\u7F16\u8F91\u4E3B\u673A","aria-label":`\u7F16\u8F91\u4E3B\u673A ${t.label}`,onClick:()=>o(t),children:"\u22EF"}),(0,se.jsx)("button",{disabled:h,title:"\u79FB\u9664\u4E3B\u673A\u914D\u7F6E","aria-label":`\u79FB\u9664\u4E3B\u673A ${t.label}`,onClick:()=>a(t),children:"\xD7"})]},t.id)),!l.data?.items.length&&!M&&(0,se.jsx)("p",{className:"zt-tree-message",children:S?"\u6B64\u76EE\u5F55\u4E3A\u7A7A":"\u6CA1\u6709\u5339\u914D\u7684\u4E3B\u673A"})]}),(0,se.jsx)(Rt,{page:l,size:200,label:_,load:i})]})}function mi(y){let{state:S,folders:T,query:M,selected:x,onSelect:r,onEdit:n,onDelete:h}=y;at(S);let u=(0,Ie.useMemo)(()=>{let a=new Map;for(let c of T){let _=c.parentId??"";a.has(_)||a.set(_,[]),a.get(_).push(c)}return a},[T]),{rows:o}=kt([{id:"",label:"\u6839\u76EE\u5F55"}],a=>a.id,a=>u.get(a.id)??[],S.expanded,Number.MAX_SAFE_INTEGER);return(0,se.jsx)(Lt,{state:S,view:M?`search:${M}`:"tree",label:M?"\u4E3B\u673A\u641C\u7D22\u7ED3\u679C":"\u4E3B\u673A\u6587\u4EF6\u5939",children:M?(0,se.jsx)(vi,{props:y,depth:0},`search:${M}`):o.map(({node:a,depth:c,content:_})=>_?(0,se.jsx)(vi,{props:y,folder:a,depth:c+1,hasChildren:!!u.get(a.id)?.length},`content:${a.id}`):(0,se.jsx)(lt,{label:a.label,depth:c,selected:x===a.id,expanded:S.expanded.has(a.id),onToggle:()=>{r(a.id),S.toggle(a.id)},actions:a.id?(0,se.jsx)(Qi,{folder:a,busy:y.busy,onEdit:n,onDelete:h}):void 0},`directory:${a.id}`))})}var W=require("react/jsx-runtime");function je({title:y,children:S,onClose:T}){let M=(0,_e.useRef)(null),x=(0,_e.useRef)(T);return x.current=T,(0,_e.useEffect)(()=>{let r=document.activeElement,n=M.current;(n?.querySelector("input,select,textarea")??n?.querySelector("button")??n)?.focus();let h=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),x.current();return}if(u.key!=="Tab")return;let o=[...n?.querySelectorAll('button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex="0"]')??[]].filter(_=>_.offsetParent!==null),a=o[0],c=o.at(-1);a?u.shiftKey&&(document.activeElement===a||document.activeElement===n)?(u.preventDefault(),c?.focus()):!u.shiftKey&&document.activeElement===c&&(u.preventDefault(),a.focus()):(u.preventDefault(),n?.focus())};return n?.addEventListener("keydown",h),()=>{n?.removeEventListener("keydown",h),r?.isConnected&&r.focus()}},[]),(0,W.jsx)("div",{className:"zt-modal-shade",onMouseDown:r=>{r.target===r.currentTarget&&T()},children:(0,W.jsxs)("section",{ref:M,tabIndex:-1,className:"zt-modal",role:"dialog","aria-modal":"true","aria-label":y,children:[(0,W.jsxs)("header",{children:[(0,W.jsx)("strong",{children:y}),(0,W.jsx)("button",{"aria-label":"\u5173\u95ED\u5BF9\u8BDD\u6846",onClick:T,children:"\xD7"})]}),S]})})}function Ce({title:y,children:S}){return(0,W.jsxs)("label",{className:"zt-field",children:[(0,W.jsx)("span",{children:y}),S]})}function bi({ctx:y,host:S,defaultFolderId:T="",folders:M,credentials:x=[],defaultCredentialId:r,revision:n,onClose:h,onSaved:u}){let[o,a]=(0,_e.useState)({label:S?.label??"",host:S?.host??"",port:String(S?.port??22),username:S?.username??"",authType:S?.authType??"key-file",privateKeyPath:S?.privateKeyPath??"",folderId:S?S.folderId??"":T}),[c,_]=(0,_e.useState)(""),[l,i]=(0,_e.useState)(""),[t,e]=(0,_e.useState)(!1),[s,d]=(0,_e.useState)(""),[p,g]=(0,_e.useState)(!1),[v,f]=(0,_e.useState)(S?.credentialId||!S&&x.length?"saved":S?.authType??"key-file"),[m,L]=(0,_e.useState)(S?.credentialId||r||x[0]?.id||""),k=S&&!S.credentialId&&S.authType===v,E=(C,B)=>a(z=>({...z,[C]:B}));return(0,W.jsx)(je,{title:S?"\u7F16\u8F91\u8FDC\u7A0B\u4E3B\u673A":"\u6DFB\u52A0\u8FDC\u7A0B\u4E3B\u673A",onClose:h,children:(0,W.jsxs)("form",{onSubmit:C=>{C.preventDefault(),g(!0),d(""),te(y,"host/save",{host:{...S,...o,credentialId:v==="saved"?m:void 0,folderId:o.folderId||void 0,port:Number(o.port),kind:"ssh"},secret:v==="saved"?"":c,passphrase:v==="saved"?"":l,clearPassphrase:t,revision:n}).then(()=>{_(""),i(""),u(o.folderId),h()}).catch(B=>d(B.message)).finally(()=>g(!1))},children:[(0,W.jsx)(Ce,{title:"\u540D\u79F0",children:(0,W.jsx)("input",{required:!0,value:o.label,onChange:C=>E("label",C.target.value)})}),(0,W.jsxs)("div",{className:"zt-form-row",children:[(0,W.jsx)(Ce,{title:"\u4E3B\u673A\u5730\u5740",children:(0,W.jsx)("input",{required:!0,value:o.host,placeholder:"\u4E3B\u673A\u540D\u6216 IP",onChange:C=>E("host",C.target.value)})}),(0,W.jsx)(Ce,{title:"\u7AEF\u53E3",children:(0,W.jsx)("input",{type:"number",required:!0,min:"1",max:"65535",value:o.port,onChange:C=>E("port",C.target.value)})})]}),(0,W.jsx)(Ce,{title:"\u767B\u5F55\u8D26\u53F7",children:(0,W.jsx)("input",{required:!0,value:o.username,onChange:C=>E("username",C.target.value)})}),(0,W.jsx)(Ce,{title:"\u6587\u4EF6\u5939",children:(0,W.jsxs)("select",{value:o.folderId,onChange:C=>E("folderId",C.target.value),children:[(0,W.jsx)("option",{value:"",children:"\u6839\u76EE\u5F55"}),Tt(M).map(C=>(0,W.jsxs)("option",{value:C.id,children:["\u3000".repeat(Math.min(8,C.depth)),C.label]},C.id))]})}),(0,W.jsx)(Ce,{title:"\u8BA4\u8BC1\u65B9\u5F0F",children:(0,W.jsxs)("select",{value:v,onChange:C=>{f(C.target.value),C.target.value!=="saved"&&E("authType",C.target.value),_(""),i(""),e(!1)},children:[(0,W.jsx)("option",{value:"saved",children:"\u9009\u62E9\u5DF2\u4FDD\u5B58\u51ED\u8BC1"}),(0,W.jsx)("option",{value:"password",children:"\u5BC6\u7801"}),(0,W.jsx)("option",{value:"key",children:"\u79C1\u94A5\u5185\u5BB9"}),(0,W.jsx)("option",{value:"key-file",children:"\u79C1\u94A5\u6587\u4EF6"})]})}),v==="saved"&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ce,{title:"\u767B\u5F55\u51ED\u8BC1",children:(0,W.jsxs)("select",{required:!0,value:m,onChange:C=>L(C.target.value),children:[(0,W.jsx)("option",{value:"",children:"\u8BF7\u9009\u62E9\u51ED\u8BC1"}),x.map(C=>(0,W.jsxs)("option",{value:C.id,children:[C.label," \xB7 ",Ue[C.authType]]},C.id))]})}),(0,W.jsx)("p",{className:"zt-hint",children:"\u51ED\u8BC1\u5728\u300C\u8BBE\u7F6E \u2192 zTerm \u2192 \u7BA1\u7406\u51ED\u8BC1\u300D\u4E2D\u4FDD\u5B58\uFF0C\u6B64\u5904\u65E0\u9700\u518D\u586B\u5185\u5BB9\u6216\u8DEF\u5F84\u3002"})]}),["password","key"].includes(v)&&(0,W.jsx)(Ce,{title:o.authType==="key"?"\u79C1\u94A5\u5185\u5BB9":"\u5BC6\u7801",children:o.authType==="key"?(0,W.jsx)("textarea",{rows:5,value:c,placeholder:k?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u79C1\u94A5":"\u7C98\u8D34\u79C1\u94A5\u5185\u5BB9",onChange:C=>_(C.target.value),spellCheck:!1,required:!k}):(0,W.jsx)("input",{type:"password",value:c,autoComplete:"new-password",placeholder:k?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u5BC6\u7801":"\u8F93\u5165\u5BC6\u7801",onChange:C=>_(C.target.value),required:!k})}),v==="key-file"&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ce,{title:"\u79C1\u94A5\u6587\u4EF6\u8DEF\u5F84",children:(0,W.jsx)("input",{value:o.privateKeyPath,placeholder:"\u7559\u7A7A\u4F7F\u7528\u9ED8\u8BA4 SSH \u79C1\u94A5\u6587\u4EF6",onChange:C=>E("privateKeyPath",C.target.value)})}),(0,W.jsx)("p",{className:"zt-hint",children:"\u586B\u5199 DSH \u5BBF\u4E3B\u4E0A\u7684\u7EDD\u5BF9\u8DEF\u5F84\u6216 ~/ \u8DEF\u5F84\u3002DSH \u90E8\u7F72\u5728\u8FDC\u7AEF\u65F6\uFF0C\u586B\u5199\u8FDC\u7AEF\u7684\u6587\u4EF6\u8DEF\u5F84\u3002"})]}),["key","key-file"].includes(v)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ce,{title:"\u79C1\u94A5\u53E3\u4EE4\uFF08\u53EF\u9009\uFF09",children:(0,W.jsx)("input",{type:"password",disabled:t,value:l,placeholder:"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u53E3\u4EE4",onChange:C=>i(C.target.value)})}),S?.passphraseRef&&(0,W.jsxs)("label",{className:"zt-check",children:[(0,W.jsx)("input",{type:"checkbox",checked:t,onChange:C=>e(C.target.checked)}),"\u79FB\u9664\u6B64\u4E3B\u673A\u7684\u79C1\u94A5\u53E3\u4EE4\u5F15\u7528"]})]}),(0,W.jsx)("p",{className:"zt-hint",children:"\u5BC6\u7801\u3001\u79C1\u94A5\u5185\u5BB9\u548C\u53E3\u4EE4\u4FDD\u5B58\u5728 DSH \u51ED\u636E\u5E93\uFF1B\u79C1\u94A5\u6587\u4EF6\u7531\u5BBF\u4E3B\u8BFB\u53D6\u3002\u6240\u6709\u65B0\u8FDE\u63A5\u9ED8\u8BA4\u8BFB\u6A21\u5F0F\u3002"}),s&&(0,W.jsx)("p",{className:"zt-error",role:"alert",children:s}),(0,W.jsxs)("footer",{children:[(0,W.jsx)("button",{type:"button",onClick:h,children:"\u53D6\u6D88"}),(0,W.jsx)("button",{className:"zt-primary",disabled:p,children:p?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58\u4E3B\u673A"})]})]})})}function Si({ctx:y,profile:S,revision:T,onClose:M,onSaved:x}){let[r,n]=(0,_e.useState)({label:S?.label??"",baseUrl:S?.baseUrl??"",authMode:S?.authMode??"access_key",username:S?.username??"",verifyTls:S?.verifyTls??!0}),[h,u]=(0,_e.useState)(""),[o,a]=(0,_e.useState)(""),[c,_]=(0,_e.useState)(""),[l,i]=(0,_e.useState)(!1);return(0,W.jsx)(je,{title:S?"\u7F16\u8F91 JumpServer":"\u6DFB\u52A0 JumpServer",onClose:M,children:(0,W.jsxs)("form",{onSubmit:t=>{t.preventDefault(),i(!0),_(""),te(y,"jump/save",{profile:{...S,...r},secret:h,accessKeyId:o,revision:T}).then(()=>{u(""),a(""),x(),M()}).catch(e=>_(e.message)).finally(()=>i(!1))},children:[(0,W.jsx)(Ce,{title:"\u540D\u79F0",children:(0,W.jsx)("input",{required:!0,value:r.label,onChange:t=>n({...r,label:t.target.value})})}),(0,W.jsx)(Ce,{title:"\u670D\u52A1\u5730\u5740",children:(0,W.jsx)("input",{required:!0,type:"url",value:r.baseUrl,placeholder:"https://jump.example.com",onChange:t=>n({...r,baseUrl:t.target.value})})}),(0,W.jsx)(Ce,{title:"\u8BA4\u8BC1\u65B9\u5F0F",children:(0,W.jsxs)("select",{value:r.authMode,onChange:t=>n({...r,authMode:t.target.value}),children:[(0,W.jsx)("option",{value:"access_key",children:"Access Key"}),(0,W.jsx)("option",{value:"token",children:"Token"}),(0,W.jsx)("option",{value:"password",children:"\u8D26\u53F7\u5BC6\u7801"})]})}),r.authMode==="access_key"&&(0,W.jsx)(Ce,{title:"Access Key ID",children:(0,W.jsx)("input",{type:"password",value:o,placeholder:S?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u503C":"",onChange:t=>a(t.target.value)})}),r.authMode==="password"&&(0,W.jsx)(Ce,{title:"\u8D26\u53F7",children:(0,W.jsx)("input",{required:!0,value:r.username,onChange:t=>n({...r,username:t.target.value})})}),(0,W.jsx)(Ce,{title:r.authMode==="access_key"?"Access Key Secret":r.authMode==="token"?"Token":"\u5BC6\u7801",children:(0,W.jsx)("input",{type:"password",value:h,placeholder:S?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u503C":"",onChange:t=>u(t.target.value)})}),(0,W.jsxs)("label",{className:"zt-check",children:[(0,W.jsx)("input",{type:"checkbox",checked:r.verifyTls,onChange:t=>n({...r,verifyTls:t.target.checked})}),"\u9A8C\u8BC1 TLS \u8BC1\u4E66"]}),(0,W.jsx)("p",{className:"zt-hint",children:"\u8FDE\u63A5\u4F7F\u7528\u8D44\u4EA7\u4E0E\u8D26\u53F7\u7684\u7A33\u5B9A ID\uFF0C\u4EE4\u724C\u4EC5\u5728\u5BBF\u4E3B\u5185\u90E8\u5904\u7406\u3002"}),c&&(0,W.jsx)("p",{className:"zt-error",role:"alert",children:c}),(0,W.jsxs)("footer",{children:[(0,W.jsx)("button",{type:"button",onClick:M,children:"\u53D6\u6D88"}),(0,W.jsx)("button",{className:"zt-primary",disabled:l,children:l?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58\u5B9E\u4F8B"})]})]})})}function Ci({ctx:y,folder:S,defaultParentId:T="",folders:M,revision:x,onClose:r,onSaved:n}){let[h,u]=(0,_e.useState)(S?.label??""),[o,a]=(0,_e.useState)(S?S.parentId??"":T),[c,_]=(0,_e.useState)(""),[l,i]=(0,_e.useState)(!1),t=new Set;if(S){t.add(S.id);for(let e of Tt(M))e.parentId&&t.has(e.parentId)&&t.add(e.id)}return(0,W.jsx)(je,{title:S?"\u7F16\u8F91\u4E3B\u673A\u6587\u4EF6\u5939":"\u65B0\u5EFA\u4E3B\u673A\u6587\u4EF6\u5939",onClose:r,children:(0,W.jsxs)("form",{onSubmit:e=>{e.preventDefault(),i(!0),te(y,"folder/save",{folder:{id:S?.id,label:h,parentId:o||void 0},revision:x}).then(()=>{n(o),r()}).catch(s=>_(s.message)).finally(()=>i(!1))},children:[(0,W.jsx)(Ce,{title:"\u540D\u79F0",children:(0,W.jsx)("input",{required:!0,value:h,onChange:e=>u(e.target.value)})}),(0,W.jsx)(Ce,{title:"\u7236\u6587\u4EF6\u5939",children:(0,W.jsxs)("select",{value:o,onChange:e=>a(e.target.value),children:[(0,W.jsx)("option",{value:"",children:"\u6839\u76EE\u5F55"}),Tt(M).filter(e=>!t.has(e.id)).map(e=>(0,W.jsxs)("option",{value:e.id,children:["\u3000".repeat(Math.min(8,e.depth)),e.label]},e.id))]})}),c&&(0,W.jsx)("p",{className:"zt-error",role:"alert",children:c}),(0,W.jsxs)("footer",{children:[(0,W.jsx)("button",{type:"button",onClick:r,children:"\u53D6\u6D88"}),(0,W.jsx)("button",{disabled:l,className:"zt-primary",children:l?"\u4FDD\u5B58\u4E2D\u2026":S?"\u4FDD\u5B58":"\u521B\u5EFA"})]})]})})}var he=require("react/jsx-runtime"),ht={nodeId:"",key:"",name:"\u5168\u90E8\u8D44\u4EA7",hasChildren:!1,assetCount:0};function qt({props:y,node:S,depth:T}){let{ctx:M,instanceId:x,state:r,query:n,onChoose:h}=y,u=Ye(r,`children:${S?.nodeId}`,async(_,l)=>{let i=await te(M,"jump/query",{instanceId:x,operation:"nodes",parentKey:S.key||S.nodeId},l);return{items:Dt(i.nodes??[],t=>t.nodeId),total:i.nodes?.length??0,hasMore:!1,truncated:i.truncated}},!!S?.hasChildren),{page:o,load:a}=Ye(r,S?`assets:${S.nodeId}`:`search:${n}`,async(_,l)=>{let i=await te(M,"jump/query",{instanceId:x,operation:"assets",nodeId:S?.nodeId||void 0,query:S?void 0:n,offset:_,limit:100},l);return{items:Dt(i.assets??[],t=>t.assetId),total:i.total,hasMore:i.hasMore}},!0,!S),c=S?.name??"\u641C\u7D22\u7ED3\u679C";return(0,he.jsxs)("div",{className:"zt-tree-content",style:ot(T),"data-asset-node":S?.nodeId??"search",children:[S?.hasChildren&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsx)(Ze,{page:u.page,label:`${c}\u5B50\u76EE\u5F55`,retry:()=>u.load()}),u.page?.data?.truncated&&(0,he.jsx)("p",{className:"zt-tree-message",children:"\u5B50\u76EE\u5F55\u8D85\u8FC7\u8BFB\u53D6\u4E0A\u9650\uFF0C\u53EF\u901A\u8FC7\u641C\u7D22\u67E5\u627E\u8D44\u4EA7\u3002"})]}),(0,he.jsx)(Ze,{page:o,label:c,retry:()=>a()}),o?.status==="ready"&&(0,he.jsxs)(he.Fragment,{children:[o.data?.items.map(_=>(0,he.jsxs)("button",{className:"zt-asset-row",onClick:()=>h(_),title:`${_.name} \xB7 ${_.address}`,children:[(0,he.jsxs)("strong",{children:["\u25A4 ",_.name]}),(0,he.jsxs)("small",{children:[_.address," \xB7 ",_.platform]})]},_.assetId)),!o.data?.items.length&&(!S?.hasChildren||u.page?.status==="ready"&&!u.page.data?.items.length)&&(0,he.jsx)("p",{className:"zt-tree-message",children:S?"\u6B64\u76EE\u5F55\u4E3A\u7A7A":"\u6CA1\u6709\u5339\u914D\u7684\u8D44\u4EA7"})]}),(0,he.jsx)(Rt,{page:o,size:100,label:c,load:a})]})}function wi(y){let{ctx:S,instanceId:T,state:M,query:x}=y;at(M);let{page:r,load:n}=Ye(M,"nodes",async(o,a)=>{let c=await te(S,"jump/query",{instanceId:T,operation:"nodes"},a);return{items:Dt(c.nodes??[],_=>_.nodeId),total:c.nodes?.length??0,hasMore:!1,truncated:c.truncated}},!x),{rows:h,truncated:u}=kt(r?.data?.items??[],o=>o.nodeId,o=>o.hasChildren?M.page(`children:${o.nodeId}`)?.data?.items??[]:[],M.expanded);return(0,he.jsx)(Lt,{state:M,view:x?`search:${x}`:"tree",label:x?"JumpServer \u641C\u7D22\u7ED3\u679C":"JumpServer \u8D44\u4EA7\u76EE\u5F55",children:x?(0,he.jsx)(qt,{props:y,depth:0},`search:${x}`):(0,he.jsxs)(he.Fragment,{children:[(0,he.jsx)(Ze,{page:r,label:"\u8D44\u4EA7\u76EE\u5F55",retry:()=>n()}),h.map(({node:o,depth:a,content:c})=>c?(0,he.jsx)(qt,{props:y,node:o,depth:a+1},`content:${o.nodeId}`):(0,he.jsx)(lt,{label:o.name,depth:a,expanded:M.expanded.has(o.nodeId),onToggle:()=>M.toggle(o.nodeId)},`directory:${o.nodeId}`)),(u||r?.data?.truncated)&&(0,he.jsx)("p",{className:"zt-tree-message",children:"\u76EE\u5F55\u663E\u793A\u5DF2\u8FBE 500 \u9879\uFF0C\u8BF7\u6536\u8D77\u90E8\u5206\u76EE\u5F55\u6216\u641C\u7D22\u8D44\u4EA7\u3002"}),(0,he.jsx)(lt,{label:ht.name,depth:0,expanded:M.expanded.has(ht.nodeId),onToggle:()=>M.toggle(ht.nodeId)}),M.expanded.has(ht.nodeId)&&(0,he.jsx)(qt,{props:y,node:ht,depth:1})]})})}var yi="dsh-zterm.asset-tree-cache.v1:",er=1440*60*1e3,Kt=6e5,Ei=64,Qe=y=>!!(y&&typeof y=="object"&&!Array.isArray(y)),we=y=>typeof y=="string"&&y.length<=4096,ct=y=>Number.isFinite(y)&&y>=0,It=y=>y==="nodes"?2:typeof y=="string"&&y.startsWith("children:")?1:0;function et(y,S,T=[],M=[]){if(!Qe(y))return;let x={};for(let r of S)we(y[r])&&(x[r]=y[r]);for(let r of T)ct(y[r])&&(x[r]=y[r]);for(let r of M)typeof y[r]=="boolean"&&(x[r]=y[r]);return x}function Vt(y,S,T){return Array.isArray(y)?y.slice(0,S).map(T).filter(Boolean):[]}function xi(y){if(!(!Qe(y)||!Array.isArray(y.folders)||!Array.isArray(y.jumpservers)))return{...et(y,[],["revision"],["temporarilyDisabled"]),folders:Vt(y.folders,2e3,S=>we(S?.id)&&we(S?.label)?et(S,["id","label","parentId"]):void 0),jumpservers:Vt(y.jumpservers,32,S=>we(S?.id)&&we(S?.label)?et(S,["id","label"]):void 0)}}function At(y,S){if(!Qe(y)||!Array.isArray(y.expanded)||!Array.isArray(y.pages))return;let T=[];for(let M of y.pages.slice().sort((x,r)=>It(r?.[0])-It(x?.[0])).slice(0,Ei)){if(!Array.isArray(M)||M.length!==2)continue;let[x,r]=M;if(!we(x)||!Qe(r)||!Number.isInteger(r.offset)||r.offset<0||!Qe(r.data)||!Array.isArray(r.data.items)||!ct(r.data.total))continue;let n=!S&&(x==="nodes"||x.startsWith("children:"));if(S?!x.startsWith("hosts:"):!n&&!x.startsWith("assets:"))continue;let h=Vt(r.data.items,n?500:S?200:100,u=>S?we(u?.id)&&we(u?.label)&&we(u?.host)&&we(u?.username)&&ct(u?.port)?et(u,["id","label","folderId","kind","host","username"],["port"]):void 0:n?we(u?.nodeId)&&we(u?.key)&&we(u?.name)?et(u,["nodeId","key","name"],["assetCount"],["hasChildren"]):void 0:we(u?.assetId)&&we(u?.name)&&we(u?.address)&&we(u?.platform)?et(u,["assetId","name","address","platform"]):void 0);h.length===r.data.items.length&&T.push([x,{offset:r.offset,data:{items:h,total:r.data.total,hasMore:!!r.data.hasMore,truncated:!!r.data.truncated}}])}return{expanded:y.expanded.filter(we).slice(0,2001),scroll:ct(y.scroll)?y.scroll:0,pages:T}}function tr(){try{return localStorage}catch{return}}var Mt=class{constructor(S,T=tr(),M=()=>Date.now()){this.storage=T;this.now=M;this.key=yi+encodeURIComponent(S);try{let x=T?.getItem(this.key);if(x&&x.length<=Kt){let r=JSON.parse(x);if(r.schema===1&&ct(r.writtenAt)&&this.now()-r.writtenAt>=0&&this.now()-r.writtenAt<er&&(this.catalog=xi(r.catalog),this.catalog)){let n=At(r.host,!0);n&&this.host.restore(n);for(let u of Array.isArray(r.jumps)?r.jumps.slice(0,32):[]){if(!Array.isArray(u)||!this.catalog.jumpservers.some(a=>a.id===u[0]))continue;let o=At(u[1],!1);o&&this.jump(u[0]).restore(o)}let h=r.preferences;Qe(h)&&(this.preferences={source:h.source==="jumpserver"?"jumpserver":"ssh",instanceId:this.catalog.jumpservers.some(u=>u.id===h.instanceId)?h.instanceId:this.catalog.jumpservers[0]?.id??"",folder:this.catalog.folders.some(u=>u.id===h.folder)?h.folder:""})}}}catch{}this.host.onChange=this.schedule}host=new nt([""]);jumps=new Map;key;catalog;preferences={source:"ssh",instanceId:"",folder:""};timer;jump(S){let T=this.jumps.get(S);return T||(T=new nt,T.onChange=this.schedule,this.jumps.set(S,T)),T}schedule=()=>{this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},200))};flush(){if(!(!this.catalog||!this.storage))try{let S=At(this.host.export(),!0),T=[...this.jumps].map(([a,c])=>[a,At(c.export(),!1)]),M={schema:1,writtenAt:this.now(),catalog:xi(this.catalog),preferences:this.preferences,host:S,jumps:T},x=[S,...T.map(([,a])=>a)],r=x.flatMap(a=>a.pages.map(c=>({tree:a,page:c})));x.forEach(a=>{a.pages=[]});let n=JSON.stringify(M).length,h=0;for(let{tree:a,page:c}of r.sort((_,l)=>It(l.page[0])-It(_.page[0]))){let _=JSON.stringify(c).length+1;h<Ei&&n+_<Kt&&(a.pages.push(c),n+=_,h++)}let u=JSON.stringify(M);if(u.length>Kt)return;let o=[];for(let a=0;a<this.storage.length;a++){let c=this.storage.key(a);if(c?.startsWith(yi)&&c!==this.key){let _=0;try{_=JSON.parse(this.storage.getItem(c)??"{}").writtenAt??0}catch{}o.push({key:c,time:_})}}o.sort((a,c)=>c.time-a.time).slice(2).forEach(({key:a})=>this.storage.removeItem(a)),this.storage.setItem(this.key,u)}catch{}}dispose(){clearTimeout(this.timer),this.flush(),this.host.onChange=void 0,this.host.dispose(),this.jumps.forEach(S=>{S.onChange=void 0,S.dispose()})}};var O=require("react/jsx-runtime"),ki={terminals:[],operations:[],revision:0,capabilities:{local:!1,external:!1},hostPlatform:""},Di={connecting:"\u8FDE\u63A5\u4E2D",ready:"\u5DF2\u8FDE\u63A5",disconnected:"\u5DF2\u65AD\u5F00",error:"\u8FDE\u63A5\u5931\u8D25",executing:"\u6267\u884C\u4E2D",completed:"\u5B8C\u6210",failed:"\u5931\u8D25",unknown:"\u7ED3\u679C\u4E0D\u660E",blocked:"\u5DF2\u62D2\u7EDD",not_sent:"\u672A\u4E0B\u53D1"},Bt=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`page-${Date.now()}-${Math.random()}`;function Jt({ctx:y,sessionId:S,visible:T=!0,onClose:M}){let[x]=(0,Z.useState)(()=>new Mt(S)),[r,n]=(0,Z.useState)(ki),[h,u]=(0,Z.useState)(new Map),[o,a]=(0,Z.useState)(""),[c,_]=(0,Z.useState)(""),[l,i]=(0,Z.useState)(x.catalog),[t,e]=(0,Z.useState)(""),[s,d]=(0,Z.useState)(""),[p,g]=(0,Z.useState)(""),[v,f]=(0,Z.useState)(x.preferences.folder),[m,L]=(0,Z.useState)(x.preferences.source),[k,E]=(0,Z.useState)(!1),[C,B]=(0,Z.useState)(!1),[z,j]=(0,Z.useState)(!1),[U,$]=(0,Z.useState)(x.preferences.instanceId),[b,D]=(0,Z.useState)(),[R,A]=(0,Z.useState)(),H=x.host,q=x.jumps;U&&x.jump(U);let[X,Y]=(0,Z.useState)(!1),[I,w]=(0,Z.useState)(!1),[N,F]=(0,Z.useState)(()=>rt("dsh-zterm.list-width",240,180,440)),[K,V]=(0,Z.useState)(!1),[ie,ce]=(0,Z.useState)(!1),[le,ne]=(0,Z.useState)(),G=(0,Z.useRef)(!0),Ne=(0,Z.useRef)(T),We=(0,Z.useRef)(-1),qe=(0,Z.useRef)(async()=>{}),Ke=(0,Z.useRef)(o),$e=(0,Z.useRef)(0),ye=(0,Z.useRef)(0),Ae=(0,Z.useRef)(0),Re=(0,Z.useRef)(null),Fe=(0,Z.useRef)(null),tt=Et();Ne.current=T,Ke.current=o;let pe=(0,Z.useCallback)(P=>_(P),[]);(0,Z.useEffect)(()=>{let P=setTimeout(()=>g(s.trim()),150);return()=>clearTimeout(P)},[s]),(0,Z.useEffect)(()=>()=>x.dispose(),[x]),(0,Z.useEffect)(()=>{x.preferences={source:m,instanceId:U,folder:v},x.schedule()},[x,m,U,v]),(0,Z.useEffect)(()=>{G.current=!0,n(ki),u(new Map),We.current=-1;let P=!1,ee=!1,fe,ae,ve=new AbortController,be=async()=>{try{ee||(await te(y,"client/attach",{sessionId:S,pageId:Bt},ve.signal),ee=!0);let Oe=await te(y,"poll",{sessionId:S,cursor:We.current},ve.signal);if(P)return;We.current=Oe.cursor,n(Oe.workspace),u(zt=>ii(zt,Oe)),Oe.workspace.terminals.some(zt=>zt.id===Ke.current)||a(Oe.workspace.terminals[0]?.id??"")}catch(Oe){P||_(Oe instanceof Error?Oe.message:"\u65E0\u6CD5\u8BFB\u53D6\u7EC8\u7AEF\u72B6\u6001")}},ze=()=>ae||(ae=be().finally(()=>{ae=void 0}),ae),_t=async()=>{await ze(),P||(fe=setTimeout(_t,Ne.current?200:1e3))};return qe.current=ze,_t(),te(y,"saved-workspace",{sessionId:S}).then(Oe=>{P||ce(Oe.length>0)}).catch(()=>{}),()=>{P=!0,G.current=!1,clearTimeout(fe),ve.abort()}},[y,S]);let ke=(0,Z.useCallback)(async(P,ee=!0)=>{let fe=++$e.current;ee&&(H.invalidate(),q.forEach(be=>be.invalidate()));let ae=await te(y,"catalog",{folderId:"root"},P);if(P?.aborted||fe!==$e.current||!G.current)return;let ve=x.catalog&&x.catalog.revision!==ae.revision;return ve&&H.invalidate(),H.retain(new Set(["",...ae.folders.map(be=>be.id)])),H.seed("hosts:",{items:ae.hosts,total:ae.total,hasMore:ae.total>200}),q.forEach((be,ze)=>{ae.jumpservers.some(_t=>_t.id===ze)?ve&&be.invalidate():(be.dispose(),q.delete(ze))}),x.catalog=ae,x.schedule(),e(""),i(ae),f(be=>ae.folders.some(ze=>ze.id===be)?be:""),$(be=>ae.jumpservers.some(ze=>ze.id===be)?be:ae.jumpservers[0]?.id??""),ae},[y,H,q,x]),Me=(0,Z.useRef)(T&&!I);(0,Z.useEffect)(()=>{let P=T&&!I;P&&!Me.current&&(H.invalidate(),q.forEach(ee=>ee.invalidate())),Me.current=P},[T,I,H,q]),(0,Z.useEffect)(()=>{if(!T||I)return;let P=new AbortController;return ke(P.signal,!1).catch(ee=>{P.signal.aborted||e(ee.message)}),()=>P.abort()},[ke,T,I,r.catalogRevision]);let Te=async(P,ee)=>{let fe=++Ae.current;V(!0);try{let ae=await ke(void 0,!1);if(!ae||fe!==Ae.current||!G.current)return;if(P==="host"){let ve=ee?(await te(y,"catalog",{targetId:ee.id})).hosts.find(be=>be.id===ee.id):null;if(fe!==Ae.current||!G.current)return;if(ee&&!ve)throw new Error("\u4E3B\u673A\u5DF2\u79FB\u9664\uFF0C\u8BF7\u5237\u65B0\u5217\u8868");E(ve)}else{let ve=ee?ae[P==="folder"?"folders":"jumpservers"].find(be=>be.id===ee.id):null;if(ee&&!ve)throw new Error("\u914D\u7F6E\u5DF2\u79FB\u9664\uFF0C\u8BF7\u5237\u65B0\u5217\u8868");P==="folder"?j(ve):B(ve)}}catch(ae){G.current&&fe===Ae.current&&pe(ae.message)}finally{G.current&&fe===Ae.current&&V(!1)}},oe=()=>{Ae.current++,V(!1),E(!1),B(!1),j(!1)},xe=(0,Z.useCallback)(async(P,ee={})=>{V(!0),_("");try{let fe=await te(y,P,{sessionId:S,pageId:Bt,...ee});if(G.current)return await qe.current(),fe}catch(fe){G.current&&pe(fe instanceof Error?fe.message:"\u64CD\u4F5C\u5931\u8D25")}finally{G.current&&V(!1)}},[y,S,pe]),Ot=async P=>{let ee=await xe("connect",{target:P});ee?.id&&a(ee.id)};(0,Z.useEffect)(()=>{if(!T||!Re.current)return;let P=()=>Fe.current?.scrollIntoView({block:"nearest",inline:"nearest"});P();let ee=new ResizeObserver(P);return ee.observe(Re.current),()=>ee.disconnect()},[o,T,r.terminals.length]);let re=r.terminals.find(P=>P.id===o),Pe=r.binding,dt=re&&Pe?.terminalId===re.id&&Pe.generation===re.generation,Ee=r.terminals.find(P=>P.trust),Ve=Ee?{terminalId:Ee.id,generation:Ee.generation}:{},ut=P=>P.target.source==="local"?P.target.label:`${P.target.username??""}@${P.target.host??P.target.label}${P.target.port?`:${P.target.port}`:""}`,Je=re?{terminalId:re.id,generation:re.generation}:{},Ni=re?r.operations.filter(P=>P.status==="executing"&&P.terminalId===re.id).at(-1)?.startedAt??(re.state==="connecting"?re.createdAt:void 0):void 0,Yt=ti(Ni),ft=l?.jumpservers?.find(P=>P.id===U),Zt=(P="")=>{let ee=[""],fe=new Set,ae=new Map((l?.folders??[]).map(ve=>[ve.id,ve]));for(;P&&!fe.has(P);)fe.add(P),ee.push(P),P=ae.get(P)?.parentId??"";H.reveal(ee)};(0,Z.useEffect)(()=>{ye.current++,D(void 0)},[U,m]);let Fi=async P=>{let ee=++ye.current;A(P),D(void 0);try{let fe=await te(y,"jump/query",{instanceId:U,operation:"accounts",assetId:P.assetId});ee===ye.current&&G.current&&D(fe.accounts)}catch(fe){ee===ye.current&&G.current&&pe(fe.message)}},Wi=P=>{let ee=P.clientX,fe=N;tt(P,ae=>{let ve=Math.max(180,Math.min(440,fe+ee-ae.clientX));F(ve),st("dsh-zterm.list-width",ve)})};return(0,O.jsxs)("div",{className:"zt-workbench",children:[l?.temporarilyDisabled&&(0,O.jsx)("div",{className:"zt-workbench-notice",role:"status",children:"zTerm \u5DF2\u4E34\u65F6\u7981\u7528\uFF1AAI \u4E0D\u4F1A\u6536\u5230\u672C\u63D2\u4EF6\u63D0\u793A\uFF0C\u4E5F\u4E0D\u80FD\u8C03\u7528 zterm_* \u5DE5\u5177\uFF1B\u624B\u5DE5\u8FDE\u63A5\u3001\u7EC8\u7AEF\u548C\u914D\u7F6E\u7BA1\u7406\u4ECD\u53EF\u4F7F\u7528\u3002\u53EF\u5728\u300C\u8BBE\u7F6E \u2192 zTerm\u300D\u6062\u590D\u3002"}),c&&(0,O.jsxs)("div",{className:"zt-error-banner",role:"alert",children:[(0,O.jsx)("span",{children:c}),(0,O.jsx)("button",{"aria-label":"\u5173\u95ED\u9519\u8BEF\u63D0\u793A",onClick:()=>_(""),children:"\xD7"})]}),(0,O.jsxs)("div",{className:"zt-workbench-body",children:[(0,O.jsxs)("main",{className:"zt-terminal-area",children:[(0,O.jsxs)("div",{className:"zt-terminal-topbar",children:[(0,O.jsx)("nav",{ref:Re,className:"zt-terminal-tabs","aria-label":"\u7EC8\u7AEF\u6807\u7B7E",children:r.terminals.map(P=>(0,O.jsxs)("div",{ref:P.id===o?Fe:void 0,className:`zt-tab ${P.id===o?"active":""}`,children:[(0,O.jsxs)("button",{onClick:()=>a(P.id),title:ut(P),children:[(0,O.jsx)("i",{className:`zt-state-dot ${P.state}`}),P.target.label]}),(0,O.jsx)("button",{"aria-label":`\u5173\u95ED\u7EC8\u7AEF ${P.target.label}`,onClick:()=>ne({text:`\u5173\u95ED\u300C${P.target.label}\u300D\u7684\u7EC8\u7AEF\u8FDE\u63A5\uFF1F`,act:()=>{xe("close",{terminalId:P.id}),ne(void 0)}}),children:"\xD7"})]},P.id))}),(0,O.jsxs)("div",{className:"zt-terminal-controls",children:[(0,O.jsx)("button",{disabled:!r.capabilities.local||K,title:r.capabilities.local?"\u6BCF\u6B21\u70B9\u51FB\u65B0\u5F00\u4E00\u4E2A\u7EC8\u7AEF\uFF0C\u8FD0\u884C\u5728 DSH \u6240\u5728\u7684\u673A\u5668\u4E0A":`\u8BF7\u5728 ${de} \u8BBE\u7F6E\u4E2D\u542F\u7528\u672C\u5730\u7EC8\u7AEF\u5E76\u4FDD\u5B58`,onClick:()=>void Ot({kind:"local"}),children:"\u6253\u5F00\u672C\u673A\u7EC8\u7AEF"}),(0,O.jsx)("button",{title:"\u64CD\u4F5C\u8BB0\u5F55",onClick:()=>Y(!X),children:"\u8BB0\u5F55"}),I&&(0,O.jsx)("button",{title:"\u663E\u793A\u673A\u5668\u5217\u8868","aria-expanded":!1,onClick:()=>w(!1),children:"\u673A\u5668\u5217\u8868"}),M&&(0,O.jsx)("button",{"aria-label":`\u6536\u8D77 ${de}`,onClick:M,children:"\xD7"})]})]}),re?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)("div",{className:"zt-terminal-toolbar",children:[(0,O.jsxs)("div",{className:"zt-target",title:ut(re),children:[ut(re),(0,O.jsxs)("span",{children:[Di[re.state],re.busy?" \xB7 AI \u6267\u884C\u4E2D":"",Yt?` \xB7 ${Yt}`:""]})]}),(0,O.jsxs)("div",{className:"zt-actions",children:[(0,O.jsx)("button",{disabled:K||re.state!=="ready"||!re.agentReady||re.uncertain,onClick:()=>void xe("bind",Je),children:dt?"\u5DF2\u7ED1\u5B9A AI":"\u7ED1\u5B9A AI"}),(0,O.jsxs)("label",{className:`zt-mode ${dt&&Pe.mode==="readwrite"?"write":""}`,title:"\u672A\u52FE\u9009\uFF1A\u8BFB\u6A21\u5F0F\uFF0CAI \u4EC5\u53EF\u4F7F\u7528\u5185\u7F6E\u67E5\u8BE2\u5DE5\u5177\uFF1B\u52FE\u9009\uFF1A\u8BFB\u5199\u6A21\u5F0F\uFF0CAI \u53EF\u6267\u884C\u5DF2\u6388\u6743\u7684\u547D\u4EE4\u3002",children:[(0,O.jsx)("input",{type:"checkbox","aria-label":"\u5141\u8BB8AI\u5199\u64CD\u4F5C",checked:!!(dt&&Pe.mode==="readwrite"),disabled:!dt||K||!re.agentReady||re.uncertain,onChange:P=>void xe("mode",{...Je,mode:P.target.checked?"readwrite":"read"})}),"\u5141\u8BB8AI\u5199\u64CD\u4F5C"]}),(0,O.jsx)("button",{disabled:!re.busy,onClick:()=>void xe("stop",Je),children:"\u505C\u6B62"}),(0,O.jsx)("button",{disabled:K||re.busy,onClick:()=>void xe(re.state==="ready"?"disconnect":"reconnect",Je),children:re.state==="ready"?"\u65AD\u5F00":"\u91CD\u8FDE"})]})]}),!re.agentReady&&re.state==="ready"&&!re.uncertain&&(0,O.jsxs)("div",{className:"zt-notice",children:["\u624B\u5DE5\u8F93\u5165\u540E\uFF0CAI \u5DF2\u6682\u505C\u64CD\u4F5C\u3002\u786E\u8BA4\u7EC8\u7AEF\u56DE\u5230\u7A7A\u95F2 Shell \u540E\uFF1A",(0,O.jsx)("button",{onClick:()=>void xe("shell-ready",Je),children:"\u786E\u8BA4\u7A7A\u95F2 Shell"})]}),re.uncertain&&(0,O.jsxs)("div",{className:"zt-notice danger",children:["\u524D\u6B21\u64CD\u4F5C\u7ED3\u679C\u4E0D\u660E\uFF0C\u5DF2\u505C\u6B62\u81EA\u52A8\u4E0B\u53D1\u3002\u6838\u5B9E\u673A\u5668\u72B6\u6001\u540E\u91CD\u65B0\u5EFA\u7ACB\u8FDE\u63A5\u3002",(0,O.jsx)("button",{disabled:K||re.busy,onClick:()=>ne({text:`\u91CD\u5EFA\u300C${re.target.label}\u300D\u7684\u8FDE\u63A5\uFF1F\u5F53\u524D Shell \u4F1A\u65AD\u5F00\uFF0C\u4ECD\u5728\u524D\u53F0\u8FD0\u884C\u7684\u547D\u4EE4\u53EF\u80FD\u968F\u4E4B\u7EC8\u6B62\uFF0C\u8BF7\u5148\u5728\u7EC8\u7AEF\u6838\u5B9E\u8FDC\u7AEF\u72B6\u6001\u3002`,act:()=>{xe("reconnect",Je),ne(void 0)}}),children:"\u91CD\u5EFA\u8FDE\u63A5"})]}),re.error&&(0,O.jsx)("div",{className:"zt-notice danger",children:re.error})]}):(0,O.jsxs)("div",{className:"zt-empty",children:[(0,O.jsx)("div",{className:"zt-terminal-mark",children:">_"}),(0,O.jsx)("h3",{children:"\u8FDE\u63A5\u4E00\u53F0\u673A\u5668"}),(0,O.jsxs)("p",{children:["\u4ECE\u53F3\u4FA7\u9009\u62E9\u4E3B\u673A\u6216 JumpServer \u8D44\u4EA7\u3002",(0,O.jsx)("br",{}),"\u8FDE\u63A5\u540E\u53EF\u624B\u5DE5\u64CD\u4F5C\uFF0C\u6216\u7ED1\u5B9A\u7ED9\u5F53\u524D DSH \u5BF9\u8BDD\u4E2D\u7684 AI\u3002"]}),r.capabilities.automatic&&(0,O.jsx)("p",{children:"\u4E5F\u53EF\u5728\u5BF9\u8BDD\u4E2D\u6307\u5B9A\u4E3B\u673A\u540D\u6216 IP\uFF0CAI \u4F1A\u5148\u67E5\u8FDC\u7A0B\u4E3B\u673A\uFF0C\u518D\u67E5 JumpServer\uFF0C\u6700\u540E\u4F7F\u7528\u9ED8\u8BA4 SSH \u79C1\u94A5\u3002"}),(0,O.jsx)("button",{className:"zt-primary",disabled:K,onClick:()=>void Te("host"),children:"\u6DFB\u52A0\u8FDC\u7A0B\u4E3B\u673A"}),ie&&(0,O.jsx)("button",{onClick:()=>void xe("restore"),children:"\u6062\u590D\u4E0A\u6B21\u7EC8\u7AEF\u5217\u8868\uFF08\u9ED8\u8BA4\u53EA\u8BFB\uFF09"})]}),(0,O.jsx)("div",{className:"zt-screens",children:r.terminals.map(P=>(0,O.jsx)(gi,{ctx:y,sessionId:S,terminal:P,buffer:h.get(P.id),visible:T&&P.id===o,onError:pe},`${P.id}:${P.generation}`))}),(0,O.jsxs)("footer",{className:"zt-statusbar",children:[(0,O.jsxs)("div",{className:"zt-status-info",children:[(0,O.jsx)("span",{children:Pe?`AI \u7ED1\u5B9A\uFF1A${r.terminals.find(P=>P.id===Pe.terminalId)?.target.label??Pe.terminalId} \xB7 ${Pe.mode==="readwrite"?`\u8BFB\u5199 ${Pe.writeCalls}/${Pe.maxWriteCalls}`:"\u53EA\u8BFB"}`:"AI \u5C1A\u672A\u7ED1\u5B9A\u7EC8\u7AEF"}),(0,O.jsxs)("span",{className:"zt-host-platform",title:"\u7EC8\u7AEF\u8FDE\u63A5\u4E0E\u547D\u4EE4\u4ECE DSH \u5BBF\u4E3B\u53D1\u8D77",children:["DSH \u5BBF\u4E3B \xB7 ",r.hostPlatform||"\u6B63\u5728\u8FDE\u63A5"]})]}),re&&(0,O.jsx)("button",{onClick:()=>{te(y,"terminal/export",{sessionId:S,terminalId:re.id}).then(P=>gt(`zterm-${vt()}-\u7EC8\u7AEF.txt`,`\u7EC8\u7AEF\uFF1A${ut(re)}
11
11
  \u8BF4\u660E\uFF1A\u4EC5\u5305\u542B\u6709\u754C\u5386\u53F2\u7F13\u51B2\uFF0C\u53EF\u80FD\u5DF2\u622A\u65AD\u3002
12
12
 
13
- ${O}`)).catch(O=>pe(O.message))},children:"\u5BFC\u51FA\u7EC8\u7AEF"})]}),X&&(0,P.jsxs)("div",{className:"zt-records",children:[(0,P.jsxs)("header",{children:[(0,P.jsx)("strong",{children:"\u5B9E\u9645\u64CD\u4F5C\u8BB0\u5F55"}),(0,P.jsx)("button",{onClick:()=>{te(w,"results",{sessionId:S,limit:200}).then(O=>gt(`zterm-${vt()}-\u64CD\u4F5C\u8BB0\u5F55.json`,JSON.stringify({version:1,sessionId:S,historyLimited:!0,records:O},null,2),"application/json")).catch(O=>pe(O.message))},children:"\u5BFC\u51FA JSON"})]}),!r.operations.length&&(0,P.jsx)("p",{className:"zt-hint",children:"\u7ED1\u5B9A\u7EC8\u7AEF\u5E76\u8C03\u7528\u5DE5\u5177\u540E\uFF0C\u5B9E\u9645\u64CD\u4F5C\u8BB0\u5F55\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002"}),r.operations.slice().reverse().map(O=>(0,P.jsxs)("details",{children:[(0,P.jsxs)("summary",{children:[(0,P.jsx)("span",{className:`zt-record-status ${O.status}`,children:ki[O.status]}),(0,P.jsx)("span",{children:O.label}),(0,P.jsx)("time",{children:new Date(O.startedAt).toLocaleTimeString("zh-CN")})]}),(0,P.jsxs)("p",{className:"zt-hint",children:[O.target.label," \xB7 \u9000\u51FA\u7801 ",O.exitCode??"\u672A\u77E5"," \xB7 ",O.completion??"\u672A\u6838\u9A8C",O.truncated?" \xB7 \u8BB0\u5F55\u5DF2\u622A\u65AD":""]}),(0,P.jsx)("pre",{children:O.error||O.output||"\uFF08\u65E0\u8F93\u51FA\uFF09"})]},O.id))]})]}),!I&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)("div",{className:"zt-list-handle",role:"separator","aria-label":"\u8C03\u6574\u673A\u5668\u5217\u8868\u5BBD\u5EA6","aria-orientation":"vertical",onMouseDown:Bi}),(0,P.jsxs)("aside",{className:"zt-hosts",style:{width:F},children:[(0,P.jsxs)("div",{className:"zt-list-header",children:[(0,P.jsx)("strong",{children:"\u4E3B\u673A\u4E0E\u8D44\u4EA7"}),(0,P.jsxs)("div",{className:"zt-list-header-actions",children:[(0,P.jsx)("button",{"aria-label":"\u5237\u65B0\u673A\u5668\u5217\u8868",title:"\u5237\u65B0\u673A\u5668\u5217\u8868",onClick:()=>void ke().catch(O=>e(O.message)),children:"\u21BB"}),(0,P.jsx)("button",{title:"\u6536\u8D77\u673A\u5668\u5217\u8868","aria-expanded":!0,onClick:()=>y(!0),children:"\u6536\u8D77\u5217\u8868"})]})]}),t&&(0,P.jsxs)("div",{className:"zt-tree-message",role:"status",children:[(0,P.jsx)("span",{title:t,children:l?"\u66F4\u65B0\u5931\u8D25\uFF0C\u5F53\u524D\u663E\u793A\u7F13\u5B58":"\u76EE\u5F55\u52A0\u8F7D\u5931\u8D25"}),(0,P.jsx)("button",{onClick:()=>void ke().catch(O=>e(O.message)),children:"\u91CD\u8BD5"})]}),(0,P.jsxs)("div",{className:"zt-source-tabs",children:[(0,P.jsx)("button",{className:m==="ssh"?"active":"",onClick:()=>{E("ssh"),d(""),p("")},children:"\u8FDC\u7A0B\u4E3B\u673A"}),(0,P.jsx)("button",{className:m==="jumpserver"?"active":"",onClick:()=>{E("jumpserver"),d(""),p("")},children:"JumpServer"})]}),(0,P.jsx)("input",{className:"zt-list-search","aria-label":"\u641C\u7D22\u4E3B\u673A\u6216\u8D44\u4EA7",placeholder:"\u641C\u7D22\u540D\u79F0\u6216\u5730\u5740",value:s,onChange:O=>d(O.target.value)}),m==="ssh"?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("div",{className:"zt-list-actions",children:[(0,P.jsx)("button",{disabled:K,onClick:()=>void Te("host"),children:"\uFF0B \u4E3B\u673A"}),(0,P.jsx)("button",{disabled:K,onClick:()=>void Te("folder"),children:"\uFF0B \u6587\u4EF6\u5939"}),(0,P.jsx)("button",{onClick:()=>void te(w,"hosts/export").then(O=>gt(`zterm-${vt()}-ssh-config`,O)).catch(O=>pe(O.message)),children:"\u5BFC\u51FA"})]}),(0,P.jsx)("div",{className:"zt-host-browser",children:l?(0,P.jsx)(vi,{ctx:w,state:H,folders:l.folders,query:g,selected:v,busy:K,onSelect:f,onEdit:O=>void Te("folder",O),onConnect:O=>void Pt({targetId:O.id}),onHostEdit:O=>void Te("host",O),onHostDelete:O=>ne({text:`\u79FB\u9664\u300C${O.label}\u300D\u7684\u914D\u7F6E\uFF1F\u5DF2\u6709\u7EC8\u7AEF\u8FDE\u63A5\u4FDD\u6301\u539F\u76EE\u6807\u3002`,act:()=>{te(w,"host/delete",{id:O.id,revision:l.revision}).then(()=>ke()).catch(ee=>pe(ee.message)),ne(void 0)}}),onDelete:O=>ne({text:`\u5220\u9664\u6587\u4EF6\u5939\u300C${O.label}\u300D\uFF1F\u6587\u4EF6\u5939\u5FC5\u987B\u4E3A\u7A7A\u3002`,act:()=>{te(w,"folder/delete",{id:O.id,revision:l.revision}).then(()=>ke()).catch(ee=>pe(ee.message)),ne(void 0)}})}):(0,P.jsx)("p",{className:"zt-tree-message",role:"status",children:"\u6B63\u5728\u52A0\u8F7D\u4E3B\u673A\u76EE\u5F55\u2026"})})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("div",{className:"zt-list-actions",children:[(0,P.jsx)("button",{disabled:K,onClick:()=>void Te("jump"),children:"\uFF0B \u5B9E\u4F8B"}),ft&&(0,P.jsx)("button",{disabled:K,onClick:()=>void Te("jump",ft),children:"\u7F16\u8F91"}),ft&&(0,P.jsx)("button",{onClick:()=>ne({text:`\u79FB\u9664\u300C${ft.label}\u300D\u7684\u914D\u7F6E\uFF1F`,act:()=>{te(w,"jump/delete",{id:U,revision:l.revision}).then(()=>{$(""),ke()}).catch(O=>pe(O.message)),ne(void 0)}}),children:"\u79FB\u9664"})]}),(0,P.jsxs)("select",{"aria-label":"JumpServer \u5B9E\u4F8B",value:U,onChange:O=>{$(O.target.value),d(""),p("")},children:[(0,P.jsx)("option",{value:"",children:"\u9009\u62E9\u5B9E\u4F8B"}),l?.jumpservers.map(O=>(0,P.jsx)("option",{value:O.id,children:O.label},O.id))]}),(0,P.jsx)("div",{className:"zt-host-browser",children:U?(0,P.jsx)(Ci,{ctx:w,instanceId:U,state:q.get(U),query:g,onChoose:O=>void Mi(O)},U):(0,P.jsx)("p",{className:"zt-list-empty",children:l?.jumpservers.length?"\u8BF7\u9009\u62E9 JumpServer \u5B9E\u4F8B":"\u5148\u6DFB\u52A0 JumpServer \u5B9E\u4F8B"})})]})]})]})]}),k!==!1&&(0,P.jsx)(mi,{ctx:w,host:k??void 0,defaultFolderId:v,folders:l?.folders??[],credentials:l?.credentials??[],defaultCredentialId:l?.defaultCredentialId,revision:l?.revision,onClose:oe,onSaved:O=>{Yt(O),ke().catch(ee=>pe(ee.message))}},k?.id??"new"),C!==!1&&(0,P.jsx)(bi,{ctx:w,profile:C??void 0,revision:l?.revision,onClose:oe,onSaved:()=>void ke()},C?.id??"new"),z!==!1&&(0,P.jsx)(Si,{ctx:w,folder:z??void 0,defaultParentId:v,folders:l?.folders??[],revision:l?.revision,onClose:oe,onSaved:O=>{Yt(O),ke().catch(ee=>pe(ee.message))}},z?.id??"new"),b&&(0,P.jsx)(je,{title:`\u9009\u62E9\u8D26\u53F7 \xB7 ${R?.name??""}`,onClose:()=>L(void 0),children:(0,P.jsxs)("div",{className:"zt-account-list",children:[b.map(O=>(0,P.jsxs)("button",{disabled:!O.canConnect||K,onClick:()=>{Pt({kind:"jumpserver",instanceId:U,assetId:R.assetId,accountId:O.accountId,label:R.name,accountName:O.name||O.username}),L(void 0)},children:[(0,P.jsx)("strong",{children:O.name}),(0,P.jsxs)("span",{children:[O.username,O.canConnect?"":" \xB7 \u65E0\u8FDE\u63A5\u6743\u9650"]})]},O.accountId)),!b.length&&(0,P.jsx)("p",{children:"\u6CA1\u6709\u53EF\u7528\u8D26\u53F7"})]})}),A&&Ee?.trust&&(0,P.jsx)(je,{title:Ee.trust.kind==="changed"?"SSH \u4E3B\u673A\u6307\u7EB9\u5DF2\u53D8\u66F4":"\u6838\u5B9E SSH \u4E3B\u673A\u8EAB\u4EFD",onClose:()=>{xe("disconnect",Ve)},children:(0,P.jsxs)("div",{className:"zt-trust",children:[(0,P.jsxs)("p",{children:[Ee.target.label," \xB7 ",Ee.trust.username,"@",Ee.trust.host,":",Ee.trust.port]}),(0,P.jsxs)("pre",{children:[Ee.trust.algorithm,`
14
- `,Ee.trust.fingerprint]}),Ee.trust.trustedFingerprint&&(0,P.jsxs)("p",{children:["\u539F\u6307\u7EB9\uFF1A",Ee.trust.trustedFingerprint]}),(0,P.jsx)("p",{className:"zt-hint",children:"\u901A\u8FC7\u72EC\u7ACB\u53EF\u4FE1\u6E20\u9053\u6838\u5B9E\u6307\u7EB9\u540E\u518D\u7EE7\u7EED\u3002"}),(0,P.jsx)("footer",{children:Ee.trust.kind==="changed"?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)("button",{onClick:()=>void xe("disconnect",Ve),children:"\u53D6\u6D88\u8FDE\u63A5"}),(0,P.jsx)("button",{onClick:()=>{xe("trust/reset",Ve)},children:"\u5DF2\u6838\u5B9E\u53D8\u66F4\uFF0C\u6E05\u9664\u65E7\u8BB0\u5F55"})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)("button",{onClick:()=>void xe("trust",{...Ve,requestId:Ee.trust.requestId,decision:"reject"}),children:"\u62D2\u7EDD"}),(0,P.jsx)("button",{onClick:()=>void xe("trust",{...Ve,requestId:Ee.trust.requestId,decision:"trust-once"}),children:"\u4EC5\u4FE1\u4EFB\u6B64\u6B21\u8FDE\u63A5"}),(0,P.jsx)("button",{className:"zt-primary",onClick:()=>void xe("trust",{...Ve,requestId:Ee.trust.requestId,decision:"trust-always"}),children:"\u4FE1\u4EFB\u5E76\u4FDD\u5B58"})]})})]})}),le&&(0,P.jsxs)(je,{title:"\u786E\u8BA4\u64CD\u4F5C",onClose:()=>ne(void 0),children:[(0,P.jsx)("p",{children:le.text}),(0,P.jsxs)("footer",{children:[(0,P.jsx)("button",{onClick:()=>ne(void 0),children:"\u53D6\u6D88"}),(0,P.jsx)("button",{className:"zt-primary",onClick:le.act,children:"\u786E\u8BA4"})]})]})]})}var De=require("react");var Le=require("react");var Q=require("react/jsx-runtime");function Di({ctx:w,credentials:S,revision:A,onSaved:B}){let[D,r]=(0,Le.useState)(),[o,c]=(0,Le.useState)(""),[u,n]=(0,Le.useState)("key"),[a,h]=(0,Le.useState)(""),[_,l]=(0,Le.useState)(""),[i,t]=(0,Le.useState)(!1),[e,s]=(0,Le.useState)(!1),[d,g]=(0,Le.useState)(!1),[p,v]=(0,Le.useState)(""),[f,m]=(0,Le.useState)(""),E=(0,Le.useRef)(0);(0,Le.useEffect)(()=>()=>{E.current++},[]);let k=x=>{E.current++,g(!1),r(x),c(x?.label??""),n(x?.authType??"key"),h(x?.privateKeyPath??""),l(""),t(!1),v(""),m("")};return(0,Q.jsxs)("section",{className:"zt-settings-card zt-credential-manager","aria-label":"\u7BA1\u7406\u51ED\u8BC1",children:[(0,Q.jsxs)("div",{className:"zt-credential-header",children:[(0,Q.jsx)("strong",{children:"\u7BA1\u7406\u51ED\u8BC1"}),(0,Q.jsx)("button",{type:"button",disabled:e,onClick:()=>{B().then(()=>v("")).catch(x=>v(x.message))},children:"\u5237\u65B0\u51ED\u8BC1\u5217\u8868"})]}),(0,Q.jsx)("p",{className:"zt-hint",children:"\u4FDD\u5B58\u4E00\u6B21\uFF0C\u4E3B\u673A\u6309\u540D\u79F0\u9009\u7528\u3002"}),(0,Q.jsx)("div",{className:"zt-credential-list",role:"list","aria-label":"\u51ED\u8BC1\u5217\u8868",children:S.length?S.map(x=>(0,Q.jsxs)("div",{className:"zt-credential-row",role:"listitem",children:[(0,Q.jsxs)("span",{children:[(0,Q.jsx)("b",{children:x.label}),(0,Q.jsx)("small",{children:Ue[x.authType]})]}),(0,Q.jsx)("button",{type:"button",disabled:e,"aria-label":`\u7F16\u8F91\u51ED\u8BC1 ${x.label}`,onClick:()=>k(x),children:"\u7F16\u8F91"})]},x.id)):(0,Q.jsx)("p",{className:"zt-hint",children:"\u6682\u65E0\u51ED\u8BC1\uFF0C\u5728\u4E0B\u65B9\u65B0\u589E\u3002"})}),(0,Q.jsx)("form",{onSubmit:x=>{x.preventDefault(),!(e||d)&&(s(!0),v(""),m(""),E.current++,te(w,"credential/save",{credential:{id:D?.id,label:o,authType:u},content:a,passphrase:_,clearPassphrase:i,revision:A}).then(async()=>{k(),await B(),m("\u51ED\u8BC1\u5DF2\u4FDD\u5B58\uFF0C\u53EF\u5728\u4E3B\u673A\u4E2D\u6309\u540D\u79F0\u9009\u62E9\u3002")}).catch(C=>v(C.message)).finally(()=>s(!1)))},children:(0,Q.jsxs)("fieldset",{disabled:e,className:"zt-credential-fields",children:[(0,Q.jsx)("h3",{children:D?"\u7F16\u8F91\u51ED\u8BC1":"\u65B0\u589E\u51ED\u8BC1"}),(0,Q.jsxs)("div",{className:"zt-credential-meta",children:[(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u51ED\u8BC1\u540D\u79F0"}),(0,Q.jsx)("input",{required:!0,maxLength:200,value:o,placeholder:"\u4F8B\u5982\uFF1A\u8FD0\u7EF4\u79C1\u94A5",onChange:x=>c(x.target.value)})]}),(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u51ED\u8BC1\u7C7B\u578B"}),(0,Q.jsx)("select",{value:u,onChange:x=>{E.current++,g(!1),n(x.target.value),h(""),l(""),t(!1),v("")},children:Object.entries(Ue).map(([x,C])=>(0,Q.jsx)("option",{value:x,children:C},x))})]})]}),(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u51ED\u8BC1\u5185\u5BB9"}),u==="key"?(0,Q.jsx)("textarea",{rows:3,value:a,spellCheck:!1,autoComplete:"off",required:!D||D.authType!==u,placeholder:D?.authType===u?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u79C1\u94A5\uFF1B\u4E5F\u53EF\u9009\u62E9\u6587\u4EF6\u5BFC\u5165":"\u7C98\u8D34\u79C1\u94A5\u5185\u5BB9\uFF0C\u6216\u5728\u4E0B\u65B9\u9009\u62E9\u79C1\u94A5\u6587\u4EF6",onChange:x=>{E.current++,g(!1),h(x.target.value)}}):(0,Q.jsx)("input",{type:u==="password"?"password":"text",value:a,autoComplete:"new-password",required:u==="key-file"||!D||D.authType!==u,placeholder:u==="key-file"?"\u5BBF\u4E3B\u6587\u4EF6\u8DEF\u5F84\uFF0C\u4F8B\u5982 ~/.ssh/id_ed25519":D?.authType===u?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u5BC6\u7801":"\u8F93\u5165\u5BC6\u7801",onChange:x=>h(x.target.value)})]}),u==="key"&&(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u9009\u62E9\u79C1\u94A5\u6587\u4EF6"}),(0,Q.jsx)("input",{type:"file","aria-label":"\u9009\u62E9\u79C1\u94A5\u6587\u4EF6",disabled:e,onChange:x=>{let C=x.target.files?.[0],M=++E.current;if(x.target.value="",g(!1),!!C){if(C.size>1e5){v("\u79C1\u94A5\u6587\u4EF6\u4E0D\u80FD\u8D85\u8FC7 100 KB");return}g(!0),C.text().then(z=>{E.current===M&&(h(z),c(j=>j||C.name.slice(0,200)),v(""))}).catch(()=>{E.current===M&&v("\u8BFB\u53D6\u79C1\u94A5\u6587\u4EF6\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9")}).finally(()=>{E.current===M&&g(!1)})}}}),(0,Q.jsx)("small",{className:"zt-hint",children:"\u76F4\u63A5\u5BFC\u5165\u6587\u4EF6\uFF0C\u65E0\u9700\u586B\u5199\u8DEF\u5F84\u3002"})]}),u==="key-file"&&(0,Q.jsx)("p",{className:"zt-hint",children:"\u586B\u5199\u8FD0\u884C DSH \u7684\u673A\u5668\u4E0A\u7684\u79C1\u94A5\u8DEF\u5F84\uFF0C\u4EC5\u5728\u8FD9\u91CC\u586B\u5199\u4E00\u6B21\u3002\u8FDC\u7AEF\u90E8\u7F72\u65F6\u4F7F\u7528\u8FDC\u7AEF\u8DEF\u5F84\u3002"}),u!=="password"&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u79C1\u94A5\u53E3\u4EE4\uFF08\u53EF\u9009\uFF09"}),(0,Q.jsx)("input",{type:"password",autoComplete:"new-password",disabled:i,value:_,onChange:x=>l(x.target.value),placeholder:D?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u53E3\u4EE4":"\u79C1\u94A5\u6709\u53E3\u4EE4\u65F6\u586B\u5199"})]}),D?.passphraseRef&&(0,Q.jsxs)("label",{className:"zt-check",children:[(0,Q.jsx)("input",{type:"checkbox",checked:i,onChange:x=>t(x.target.checked)}),"\u6E05\u9664\u79C1\u94A5\u53E3\u4EE4"]})]}),p&&(0,Q.jsx)("p",{role:"alert",className:"zt-error",children:p}),f&&(0,Q.jsx)("p",{role:"status",className:"zt-success",children:f}),(0,Q.jsxs)("div",{className:"zt-actions",children:[D&&(0,Q.jsx)("button",{type:"button",disabled:e,onClick:()=>k(),children:"\u53D6\u6D88\u7F16\u8F91"}),(0,Q.jsx)("button",{className:"zt-primary",disabled:e||d,children:e?"\u4FDD\u5B58\u4E2D\u2026":d?"\u8BFB\u53D6\u6587\u4EF6\u2026":"\u4FDD\u5B58\u51ED\u8BC1"})]})]})})]})}var J=require("react/jsx-runtime"),Li=["allowLocalTerminal","defaultSshUsername","defaultPrivateKeyPath","defaultCredentialId","defaultPanelWidth","maxSessions","maxWriteCalls","commandTimeoutMs"];function Ri({ctx:w}){let[S,A]=(0,De.useState)(),[B,D]=(0,De.useState)(""),[r,o]=(0,De.useState)(!1),[c,u]=(0,De.useState)(""),[n,a]=(0,De.useState)(!1),[h,_]=(0,De.useState)(""),l=xt(),[i,t]=(0,De.useState)(String(l)),e=(0,De.useRef)(),s=(0,De.useRef)(!0),d=(0,De.useCallback)(async()=>{let v=await te(w,"catalog");if(!s.current)return;let f=e.current;e.current=v,A(m=>({...v,...Object.fromEntries(Li.filter(E=>f&&m?.[E]!==f[E]).map(E=>[E,m[E]]))}))},[w]);(0,De.useEffect)(()=>t(String(l)),[l]),(0,De.useEffect)(()=>(s.current=!0,d().catch(v=>{s.current&&D(v.message)}),()=>{s.current=!1}),[d]);let g=(v,f)=>{A({...S,[v]:f}),u("")},p=async v=>{if(!S||n)return;let f=!!S.temporarilyDisabled;a(!0),_(""),u(""),A({...S,temporarilyDisabled:v});try{await te(w,"config",{patch:{temporarilyDisabled:v},revision:S.revision})}catch(m){A(E=>({...E,temporarilyDisabled:f})),_(m instanceof Error?m.message:"\u5207\u6362\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),a(!1);return}window.dispatchEvent(new CustomEvent("dsh-zterm:state")),a(!1);try{await d()}catch(m){_(m instanceof Error?m.message:"\u5DF2\u5207\u6362\uFF0C\u4F46\u5237\u65B0\u914D\u7F6E\u5931\u8D25")}};return(0,J.jsxs)("section",{className:"zt-settings",children:[(0,J.jsx)("h2",{children:de}),(0,J.jsxs)("div",{className:`zt-settings-card zt-switch-card${S?.temporarilyDisabled?" active":""}`,children:[(0,J.jsx)("strong",{children:"\u4E34\u65F6\u7981\u7528 zTerm"}),(0,J.jsxs)("label",{className:"zt-check",children:[(0,J.jsx)("input",{type:"checkbox",role:"switch","aria-label":"\u4E34\u65F6\u7981\u7528 zTerm",checked:!!S?.temporarilyDisabled,disabled:!S||n,onChange:v=>void p(v.target.checked)}),"AI \u6682\u65F6\u4E0D\u4F7F\u7528 zTerm"]}),(0,J.jsx)("p",{className:"zt-hint",children:"\u63D2\u4EF6\u4FDD\u6301\u542F\u7528\uFF0C\u53EA\u8BA9 AI \u6682\u65F6\u770B\u4E0D\u5230\u3001\u4E5F\u7528\u4E0D\u4E86 zTerm \u5DE5\u5177\uFF0C\u5E76\u505C\u6B62\u6CE8\u5165 zTerm \u63D0\u793A\uFF1B\u5DE5\u4F5C\u53F0\u3001\u624B\u5DE5\u7EC8\u7AEF\u548C\u4E3B\u673A\uFF0F\u51ED\u636E\u7BA1\u7406\u4E0D\u53D7\u5F71\u54CD\u3002\u70B9\u51FB\u7ACB\u5373\u751F\u6548\uFF0C\u65E0\u9700\u4FDD\u5B58\u8BBE\u7F6E\u3002"}),S?.temporarilyDisabled&&(0,J.jsx)("p",{className:"zt-switch-status",role:"status",children:"\u5DF2\u4E34\u65F6\u7981\u7528\uFF1AAI \u4E0D\u4F1A\u6536\u5230 zTerm \u63D0\u793A\uFF0C\u4E5F\u4E0D\u80FD\u8C03\u7528 zterm_* \u5DE5\u5177\u3002"}),h&&(0,J.jsx)("p",{className:"zt-error",role:"alert",children:h})]}),(0,J.jsx)("p",{children:"\u5728 DSH \u5BF9\u8BDD\u53F3\u4FA7\u8FDE\u63A5\u771F\u5B9E\u673A\u5668\u3002\u9ED8\u8BA4\u8BFB\u6A21\u5F0F\uFF0C\u7531\u4EBA\u7C7B\u5728\u5DF2\u7ED1\u5B9A\u7EC8\u7AEF\u7684\u5DE5\u5177\u680F\u5F00\u542F\u8BFB\u5199\u3002"}),(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u7EC8\u7AEF\u5916\u89C2"}),(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:"\u7EC8\u7AEF\u5B57\u4F53\u5927\u5C0F\uFF08px\uFF09"}),(0,J.jsx)("input",{type:"number",min:Ct,max:yt,step:1,value:i,onChange:v=>{t(v.target.value),hi(Number(v.target.value))},onBlur:()=>t(String(l))})]}),(0,J.jsxs)("p",{className:"zt-hint",children:["\u9ED8\u8BA4 ",Ge,"px\uFF0C\u53EF\u8C03 ",Ct,"\u2013",yt,"px\u3002\u4FEE\u6539\u7ACB\u5373\u5E94\u7528\u5230\u5DF2\u6253\u5F00\u7684\u7EC8\u7AEF\uFF0C\u4FDD\u5B58\u5728\u5F53\u524D\u6D4F\u89C8\u5668\u3002"]})]}),B&&(0,J.jsx)("p",{className:"zt-error",role:"alert",children:B}),c&&(0,J.jsx)("p",{className:"zt-success",role:"status",children:c}),S?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("form",{onSubmit:v=>{v.preventDefault(),o(!0),D(""),u(""),te(w,"config",{patch:Object.fromEntries(Li.map(f=>[f,S[f]])),revision:S.revision}).then(()=>te(w,"catalog")).then(f=>{e.current=f,A(f),u(f.allowLocalTerminal?`\u914D\u7F6E\u5DF2\u4FDD\u5B58\u3002\u672C\u5730\u7EC8\u7AEF\u5DF2\u542F\u7528\uFF1A\u6253\u5F00 ${de}\uFF0C\u70B9\u51FB\u300C\u6253\u5F00\u672C\u673A\u7EC8\u7AEF\u300D\u3002`:"\u914D\u7F6E\u5DF2\u4FDD\u5B58\uFF0C\u672C\u5730\u7EC8\u7AEF\u672A\u542F\u7528\u3002")}).catch(f=>D(f.message)).finally(()=>o(!1))},children:[(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u672C\u5730\u7EC8\u7AEF"}),(0,J.jsxs)("label",{className:"zt-check",children:[(0,J.jsx)("input",{type:"checkbox",checked:S.allowLocalTerminal,onChange:v=>g("allowLocalTerminal",v.target.checked)}),"\u5141\u8BB8\u6253\u5F00\u8FD0\u884C DSH \u7684\u673A\u5668\u4E0A\u7684\u7EC8\u7AEF"]}),(0,J.jsx)("p",{className:"zt-hint",children:"DSH \u5728\u4F60\u7684\u7535\u8111\u4E0A\u8FD0\u884C\uFF0C\u5C31\u6253\u5F00\u8FD9\u53F0\u7535\u8111\u7684\u7EC8\u7AEF\uFF1BDSH \u5728\u670D\u52A1\u5668\u4E0A\u8FD0\u884C\uFF0C\u5C31\u6253\u5F00\u670D\u52A1\u5668\u7684\u7EC8\u7AEF\u3002"}),(0,J.jsxs)("p",{className:"zt-hint",children:["\u52FE\u9009\u540E\u70B9\u51FB\u4E0B\u65B9\u7684\u300C\u4FDD\u5B58\u8BBE\u7F6E\u300D\u624D\u4F1A\u751F\u6548\u3002\u7136\u540E\u4ECE\u804A\u5929\u9876\u90E8\u6253\u5F00\u300C",de,"\u300D\uFF0C\u70B9\u51FB\u9762\u677F\u53F3\u4E0A\u65B9\u7684\u300C\u6253\u5F00\u672C\u673A\u7EC8\u7AEF\u300D\u3002\u6BCF\u6B21\u70B9\u51FB\u90FD\u4F1A\u65B0\u5F00\u4E00\u4E2A\u7EC8\u7AEF\u6807\u7B7E\u3002"]})]}),(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u901A\u8FC7\u5BF9\u8BDD\u8FDE\u63A5\u8FDC\u7A0B\u673A\u5668"}),(0,J.jsx)("p",{children:"\u544A\u8BC9 AI \u8981\u8FDE\u63A5\u7684\u4E3B\u673A\u540D\u6216 IP\uFF0C\u4F8B\u5982\u300C\u8FDE\u63A5 192.0.2.21\u300D\u3002AI \u4F1A\u6309\u4EE5\u4E0B\u987A\u5E8F\u67E5\u627E\uFF1A"}),(0,J.jsxs)("ol",{className:"zt-hint",children:[(0,J.jsx)("li",{children:"\u5148\u627E\u4E3B\u673A\u5217\u8868\u91CC\u5DF2\u4FDD\u5B58\u7684\u673A\u5668\u3002"}),(0,J.jsx)("li",{children:"\u6CA1\u627E\u5230\uFF0C\u518D\u67E5 JumpServer\uFF08\u5821\u5792\u673A\uFF09\u91CC\u4F60\u6709\u6743\u9650\u8BBF\u95EE\u7684\u673A\u5668\u3002"}),(0,J.jsx)("li",{children:"\u90FD\u6CA1\u627E\u5230\uFF0C\u5C31\u4FDD\u5B58\u4E3A\u65B0\u4E3B\u673A\uFF0C\u5E76\u5C1D\u8BD5\u7528\u4E0B\u65B9\u7684\u8D26\u53F7\u548C SSH \u79C1\u94A5\u8FDE\u63A5\u3002"})]}),(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:"\u65B0\u4E3B\u673A\u9ED8\u8BA4\u767B\u5F55\u8D26\u53F7"}),(0,J.jsx)("input",{value:S.defaultSshUsername??"",placeholder:"\u7559\u7A7A\u4F7F\u7528\u8FD0\u884C DSH \u7684\u8D26\u53F7",onChange:v=>g("defaultSshUsername",v.target.value)})]}),(0,J.jsx)("p",{className:"zt-hint",children:"\u5BF9\u8BDD\u91CC\u6307\u5B9A\u4E86\u767B\u5F55\u8D26\u53F7\u65F6\uFF0C\u4F18\u5148\u4F7F\u7528\u4F60\u6307\u5B9A\u7684\u8D26\u53F7\u3002"}),(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:"\u9ED8\u8BA4 SSH \u51ED\u8BC1"}),(0,J.jsxs)("select",{value:S.defaultCredentialId??"",onChange:v=>g("defaultCredentialId",v.target.value),children:[(0,J.jsx)("option",{value:"",children:"\u81EA\u52A8\u67E5\u627E\u5BBF\u4E3B\u9ED8\u8BA4\u79C1\u94A5\u6587\u4EF6"}),(S.credentials??[]).filter(v=>v.authType!=="password").map(v=>(0,J.jsxs)("option",{value:v.id,children:[v.label," \xB7 ",Ue[v.authType]]},v.id))]})]}),(0,J.jsx)("p",{className:"zt-hint",children:"\u5728\u4E0B\u65B9\u300C\u7BA1\u7406\u51ED\u8BC1\u300D\u4FDD\u5B58\u79C1\u94A5\u540E\uFF0C\u6309\u540D\u79F0\u9009\u62E9\u9ED8\u8BA4\u51ED\u8BC1\u3002\u79C1\u94A5\u5185\u5BB9\u4E0D\u4F1A\u53D1\u9001\u7ED9 AI\u3002"}),!S.defaultCredentialId&&(0,J.jsxs)("details",{children:[(0,J.jsx)("summary",{children:"\u6307\u5B9A\u5DF2\u6709\u7684\u5BBF\u4E3B\u79C1\u94A5\u6587\u4EF6\uFF08\u53EF\u9009\uFF09"}),(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:"\u9ED8\u8BA4 SSH \u79C1\u94A5\u6587\u4EF6"}),(0,J.jsx)("input",{value:S.defaultPrivateKeyPath??"",placeholder:"\u7559\u7A7A\u81EA\u52A8\u67E5\u627E ~/.ssh \u4E0B\u7684\u9ED8\u8BA4\u79C1\u94A5",onChange:v=>g("defaultPrivateKeyPath",v.target.value)})]}),(0,J.jsx)("p",{className:"zt-hint",children:"\u4F7F\u7528\u8FD0\u884C DSH \u7684\u673A\u5668\u4E0A\u7684\u8DEF\u5F84\uFF1B\u8FDC\u7AEF\u90E8\u7F72\u65F6\u4F7F\u7528\u8FDC\u7AEF\u8DEF\u5F84\u3002"})]})]}),(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u6267\u884C\u4E0E\u5E03\u5C40"}),[["defaultPanelWidth","\u72EC\u7ACB\u9762\u677F\u9ED8\u8BA4\u5BBD\u5EA6\uFF08\u767E\u5206\u6BD4\uFF09",30,80],["maxSessions","\u6BCF\u4F1A\u8BDD\u7EC8\u7AEF\u4E0A\u9650",1,32],["maxWriteCalls","\u6BCF\u6B21\u8BFB\u5199\u6388\u6743\u7684\u547D\u4EE4\u4E0A\u9650",1,1e3],["commandTimeoutMs","\u5355\u6B21\u547D\u4EE4\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",1e3,12e4]].map(([v,f,m,E])=>(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:f}),(0,J.jsx)("input",{type:"number",min:m,max:E,required:!0,value:S[v],onChange:k=>g(String(v),Number(k.target.value))})]},v))]}),(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u4E3B\u673A\u4E0E\u51ED\u636E"}),(0,J.jsxs)("p",{children:["\u4E3B\u673A\u3001\u6587\u4EF6\u5939\u3001JumpServer \u5B9E\u4F8B\u548C\u8D26\u53F7\u4ECE\u4F1A\u8BDD\u4E2D\u7684\u300C",de,"\u300D\u5165\u53E3\u7BA1\u7406\u3002\u5BC6\u7801\u3001\u79C1\u94A5\u5185\u5BB9\u548C\u53E3\u4EE4\u5199\u5165 DSH \u51ED\u636E\u5E93\uFF1B\u79C1\u94A5\u6587\u4EF6\u76F4\u63A5\u4ECE\u5BBF\u4E3B\u8BFB\u53D6\uFF0C\u5DE5\u5177\u7ED3\u679C\u4E0D\u5305\u542B\u51ED\u636E\u503C\u3002"]}),(0,J.jsxs)("p",{className:"zt-hint",children:["\u5DF2\u914D\u7F6E ",S.total," \u53F0\u4E3B\u673A\u3001",S.jumpservers.length," \u4E2A JumpServer \u5B9E\u4F8B\u3002"]})]}),(0,J.jsx)("button",{className:"zt-primary",disabled:r,children:r?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58\u8BBE\u7F6E"})]}),(0,J.jsx)(Di,{ctx:w,credentials:S.credentials??[],revision:S.revision,onSaved:d})]}):(0,J.jsx)("p",{className:"zt-hint",children:"\u6B63\u5728\u8BFB\u53D6\u914D\u7F6E\u2026"})]})}var Ti=`.zt-workbench,.zt-settings,.zt-modal{--zt-bg:var(--dsw-alias-bg-base,#fff);--zt-layer:var(--dsw-alias-bg-layer-2,#f4f6f8);--zt-text:var(--dsw-alias-label-primary,#252b36);--zt-muted:var(--dsw-alias-label-secondary,#687284);--zt-border:var(--dsw-alias-border-l2,#dfe3e9);--zt-accent:var(--dsw-alias-state-business-primary,#3764d6);color:var(--zt-text);font:13px/1.5 system-ui,sans-serif;box-sizing:border-box}
13
+ ${P}`)).catch(P=>pe(P.message))},children:"\u5BFC\u51FA\u7EC8\u7AEF"})]}),X&&(0,O.jsxs)("div",{className:"zt-records",children:[(0,O.jsxs)("header",{children:[(0,O.jsx)("strong",{children:"\u5B9E\u9645\u64CD\u4F5C\u8BB0\u5F55"}),(0,O.jsx)("button",{onClick:()=>{te(y,"results",{sessionId:S,limit:200}).then(P=>gt(`zterm-${vt()}-\u64CD\u4F5C\u8BB0\u5F55.json`,JSON.stringify({version:1,sessionId:S,historyLimited:!0,records:P},null,2),"application/json")).catch(P=>pe(P.message))},children:"\u5BFC\u51FA JSON"})]}),!r.operations.length&&(0,O.jsx)("p",{className:"zt-hint",children:"\u7ED1\u5B9A\u7EC8\u7AEF\u5E76\u8C03\u7528\u5DE5\u5177\u540E\uFF0C\u5B9E\u9645\u64CD\u4F5C\u8BB0\u5F55\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002"}),r.operations.slice().reverse().map(P=>(0,O.jsxs)("details",{children:[(0,O.jsxs)("summary",{children:[(0,O.jsx)("span",{className:`zt-record-status ${P.status}`,children:Di[P.status]}),(0,O.jsx)("span",{children:P.label}),(0,O.jsx)("time",{children:new Date(P.startedAt).toLocaleTimeString("zh-CN")})]}),(0,O.jsxs)("p",{className:"zt-hint",children:[P.target.label," \xB7 \u9000\u51FA\u7801 ",P.exitCode??"\u672A\u77E5"," \xB7 ",P.completion??"\u672A\u6838\u9A8C",P.truncated?" \xB7 \u8BB0\u5F55\u5DF2\u622A\u65AD":""]}),(0,O.jsx)("pre",{children:P.error||P.output||"\uFF08\u65E0\u8F93\u51FA\uFF09"})]},P.id))]})]}),!I&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("div",{className:"zt-list-handle",role:"separator","aria-label":"\u8C03\u6574\u673A\u5668\u5217\u8868\u5BBD\u5EA6","aria-orientation":"vertical",onMouseDown:Wi}),(0,O.jsxs)("aside",{className:"zt-hosts",style:{width:N},children:[(0,O.jsxs)("div",{className:"zt-list-header",children:[(0,O.jsx)("strong",{children:"\u4E3B\u673A\u4E0E\u8D44\u4EA7"}),(0,O.jsxs)("div",{className:"zt-list-header-actions",children:[(0,O.jsx)("button",{"aria-label":"\u5237\u65B0\u673A\u5668\u5217\u8868",title:"\u5237\u65B0\u673A\u5668\u5217\u8868",onClick:()=>void ke().catch(P=>e(P.message)),children:"\u21BB"}),(0,O.jsx)("button",{title:"\u6536\u8D77\u673A\u5668\u5217\u8868","aria-expanded":!0,onClick:()=>w(!0),children:"\u6536\u8D77\u5217\u8868"})]})]}),t&&(0,O.jsxs)("div",{className:"zt-tree-message",role:"status",children:[(0,O.jsx)("span",{title:t,children:l?"\u66F4\u65B0\u5931\u8D25\uFF0C\u5F53\u524D\u663E\u793A\u7F13\u5B58":"\u76EE\u5F55\u52A0\u8F7D\u5931\u8D25"}),(0,O.jsx)("button",{onClick:()=>void ke().catch(P=>e(P.message)),children:"\u91CD\u8BD5"})]}),(0,O.jsxs)("div",{className:"zt-source-tabs",children:[(0,O.jsx)("button",{className:m==="ssh"?"active":"",onClick:()=>{L("ssh"),d(""),g("")},children:"\u8FDC\u7A0B\u4E3B\u673A"}),(0,O.jsx)("button",{className:m==="jumpserver"?"active":"",onClick:()=>{L("jumpserver"),d(""),g("")},children:"JumpServer"})]}),(0,O.jsx)("input",{className:"zt-list-search","aria-label":"\u641C\u7D22\u4E3B\u673A\u6216\u8D44\u4EA7",placeholder:"\u641C\u7D22\u540D\u79F0\u6216\u5730\u5740",value:s,onChange:P=>d(P.target.value)}),m==="ssh"?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)("div",{className:"zt-list-actions",children:[(0,O.jsx)("button",{disabled:K,onClick:()=>void Te("host"),children:"\uFF0B \u4E3B\u673A"}),(0,O.jsx)("button",{disabled:K,onClick:()=>void Te("folder"),children:"\uFF0B \u6587\u4EF6\u5939"}),(0,O.jsx)("button",{onClick:()=>void te(y,"hosts/export").then(P=>gt(`zterm-${vt()}-ssh-config`,P)).catch(P=>pe(P.message)),children:"\u5BFC\u51FA"})]}),(0,O.jsx)("div",{className:"zt-host-browser",children:l?(0,O.jsx)(mi,{ctx:y,state:H,folders:l.folders,query:p,selected:v,busy:K,onSelect:f,onEdit:P=>void Te("folder",P),onConnect:P=>void Ot({targetId:P.id}),onHostEdit:P=>void Te("host",P),onHostDelete:P=>ne({text:`\u79FB\u9664\u300C${P.label}\u300D\u7684\u914D\u7F6E\uFF1F\u5DF2\u6709\u7EC8\u7AEF\u8FDE\u63A5\u4FDD\u6301\u539F\u76EE\u6807\u3002`,act:()=>{te(y,"host/delete",{id:P.id,revision:l.revision}).then(()=>ke()).catch(ee=>pe(ee.message)),ne(void 0)}}),onDelete:P=>ne({text:`\u5220\u9664\u6587\u4EF6\u5939\u300C${P.label}\u300D\uFF1F\u6587\u4EF6\u5939\u5FC5\u987B\u4E3A\u7A7A\u3002`,act:()=>{te(y,"folder/delete",{id:P.id,revision:l.revision}).then(()=>ke()).catch(ee=>pe(ee.message)),ne(void 0)}})}):(0,O.jsx)("p",{className:"zt-tree-message",role:"status",children:"\u6B63\u5728\u52A0\u8F7D\u4E3B\u673A\u76EE\u5F55\u2026"})})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)("div",{className:"zt-list-actions",children:[(0,O.jsx)("button",{disabled:K,onClick:()=>void Te("jump"),children:"\uFF0B \u5B9E\u4F8B"}),ft&&(0,O.jsx)("button",{disabled:K,onClick:()=>void Te("jump",ft),children:"\u7F16\u8F91"}),ft&&(0,O.jsx)("button",{onClick:()=>ne({text:`\u79FB\u9664\u300C${ft.label}\u300D\u7684\u914D\u7F6E\uFF1F`,act:()=>{te(y,"jump/delete",{id:U,revision:l.revision}).then(()=>{$(""),ke()}).catch(P=>pe(P.message)),ne(void 0)}}),children:"\u79FB\u9664"})]}),(0,O.jsxs)("select",{"aria-label":"JumpServer \u5B9E\u4F8B",value:U,onChange:P=>{$(P.target.value),d(""),g("")},children:[(0,O.jsx)("option",{value:"",children:"\u9009\u62E9\u5B9E\u4F8B"}),l?.jumpservers.map(P=>(0,O.jsx)("option",{value:P.id,children:P.label},P.id))]}),(0,O.jsx)("div",{className:"zt-host-browser",children:U?(0,O.jsx)(wi,{ctx:y,instanceId:U,state:q.get(U),query:p,onChoose:P=>void Fi(P)},U):(0,O.jsx)("p",{className:"zt-list-empty",children:l?.jumpservers.length?"\u8BF7\u9009\u62E9 JumpServer \u5B9E\u4F8B":"\u5148\u6DFB\u52A0 JumpServer \u5B9E\u4F8B"})})]})]})]})]}),k!==!1&&(0,O.jsx)(bi,{ctx:y,host:k??void 0,defaultFolderId:v,folders:l?.folders??[],credentials:l?.credentials??[],defaultCredentialId:l?.defaultCredentialId,revision:l?.revision,onClose:oe,onSaved:P=>{Zt(P),ke().catch(ee=>pe(ee.message))}},k?.id??"new"),C!==!1&&(0,O.jsx)(Si,{ctx:y,profile:C??void 0,revision:l?.revision,onClose:oe,onSaved:()=>void ke()},C?.id??"new"),z!==!1&&(0,O.jsx)(Ci,{ctx:y,folder:z??void 0,defaultParentId:v,folders:l?.folders??[],revision:l?.revision,onClose:oe,onSaved:P=>{Zt(P),ke().catch(ee=>pe(ee.message))}},z?.id??"new"),b&&(0,O.jsx)(je,{title:`\u9009\u62E9\u8D26\u53F7 \xB7 ${R?.name??""}`,onClose:()=>D(void 0),children:(0,O.jsxs)("div",{className:"zt-account-list",children:[b.map(P=>(0,O.jsxs)("button",{disabled:!P.canConnect||K,onClick:()=>{Ot({kind:"jumpserver",instanceId:U,assetId:R.assetId,accountId:P.accountId,label:R.name,accountName:P.name||P.username}),D(void 0)},children:[(0,O.jsx)("strong",{children:P.name}),(0,O.jsxs)("span",{children:[P.username,P.canConnect?"":" \xB7 \u65E0\u8FDE\u63A5\u6743\u9650"]})]},P.accountId)),!b.length&&(0,O.jsx)("p",{children:"\u6CA1\u6709\u53EF\u7528\u8D26\u53F7"})]})}),T&&Ee?.trust&&(0,O.jsx)(je,{title:Ee.trust.kind==="changed"?"SSH \u4E3B\u673A\u6307\u7EB9\u5DF2\u53D8\u66F4":"\u6838\u5B9E SSH \u4E3B\u673A\u8EAB\u4EFD",onClose:()=>{xe("disconnect",Ve)},children:(0,O.jsxs)("div",{className:"zt-trust",children:[(0,O.jsxs)("p",{children:[Ee.target.label," \xB7 ",Ee.trust.username,"@",Ee.trust.host,":",Ee.trust.port]}),(0,O.jsxs)("pre",{children:[Ee.trust.algorithm,`
14
+ `,Ee.trust.fingerprint]}),Ee.trust.trustedFingerprint&&(0,O.jsxs)("p",{children:["\u539F\u6307\u7EB9\uFF1A",Ee.trust.trustedFingerprint]}),(0,O.jsx)("p",{className:"zt-hint",children:"\u901A\u8FC7\u72EC\u7ACB\u53EF\u4FE1\u6E20\u9053\u6838\u5B9E\u6307\u7EB9\u540E\u518D\u7EE7\u7EED\u3002"}),(0,O.jsx)("footer",{children:Ee.trust.kind==="changed"?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("button",{onClick:()=>void xe("disconnect",Ve),children:"\u53D6\u6D88\u8FDE\u63A5"}),(0,O.jsx)("button",{onClick:()=>{xe("trust/reset",Ve)},children:"\u5DF2\u6838\u5B9E\u53D8\u66F4\uFF0C\u6E05\u9664\u65E7\u8BB0\u5F55"})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("button",{onClick:()=>void xe("trust",{...Ve,requestId:Ee.trust.requestId,decision:"reject"}),children:"\u62D2\u7EDD"}),(0,O.jsx)("button",{onClick:()=>void xe("trust",{...Ve,requestId:Ee.trust.requestId,decision:"trust-once"}),children:"\u4EC5\u4FE1\u4EFB\u6B64\u6B21\u8FDE\u63A5"}),(0,O.jsx)("button",{className:"zt-primary",onClick:()=>void xe("trust",{...Ve,requestId:Ee.trust.requestId,decision:"trust-always"}),children:"\u4FE1\u4EFB\u5E76\u4FDD\u5B58"})]})})]})}),le&&(0,O.jsxs)(je,{title:"\u786E\u8BA4\u64CD\u4F5C",onClose:()=>ne(void 0),children:[(0,O.jsx)("p",{children:le.text}),(0,O.jsxs)("footer",{children:[(0,O.jsx)("button",{onClick:()=>ne(void 0),children:"\u53D6\u6D88"}),(0,O.jsx)("button",{className:"zt-primary",onClick:le.act,children:"\u786E\u8BA4"})]})]})]})}var De=require("react");var Le=require("react");var Q=require("react/jsx-runtime");function Li({ctx:y,credentials:S,revision:T,onSaved:M}){let[x,r]=(0,Le.useState)(),[n,h]=(0,Le.useState)(""),[u,o]=(0,Le.useState)("key"),[a,c]=(0,Le.useState)(""),[_,l]=(0,Le.useState)(""),[i,t]=(0,Le.useState)(!1),[e,s]=(0,Le.useState)(!1),[d,p]=(0,Le.useState)(!1),[g,v]=(0,Le.useState)(""),[f,m]=(0,Le.useState)(""),L=(0,Le.useRef)(0);(0,Le.useEffect)(()=>()=>{L.current++},[]);let k=E=>{L.current++,p(!1),r(E),h(E?.label??""),o(E?.authType??"key"),c(E?.privateKeyPath??""),l(""),t(!1),v(""),m("")};return(0,Q.jsxs)("section",{className:"zt-settings-card zt-credential-manager","aria-label":"\u7BA1\u7406\u51ED\u8BC1",children:[(0,Q.jsxs)("div",{className:"zt-credential-header",children:[(0,Q.jsx)("strong",{children:"\u7BA1\u7406\u51ED\u8BC1"}),(0,Q.jsx)("button",{type:"button",disabled:e,onClick:()=>{M().then(()=>v("")).catch(E=>v(E.message))},children:"\u5237\u65B0\u51ED\u8BC1\u5217\u8868"})]}),(0,Q.jsx)("p",{className:"zt-hint",children:"\u4FDD\u5B58\u4E00\u6B21\uFF0C\u4E3B\u673A\u6309\u540D\u79F0\u9009\u7528\u3002"}),(0,Q.jsx)("div",{className:"zt-credential-list",role:"list","aria-label":"\u51ED\u8BC1\u5217\u8868",children:S.length?S.map(E=>(0,Q.jsxs)("div",{className:"zt-credential-row",role:"listitem",children:[(0,Q.jsxs)("span",{children:[(0,Q.jsx)("b",{children:E.label}),(0,Q.jsx)("small",{children:Ue[E.authType]})]}),(0,Q.jsx)("button",{type:"button",disabled:e,"aria-label":`\u7F16\u8F91\u51ED\u8BC1 ${E.label}`,onClick:()=>k(E),children:"\u7F16\u8F91"})]},E.id)):(0,Q.jsx)("p",{className:"zt-hint",children:"\u6682\u65E0\u51ED\u8BC1\uFF0C\u5728\u4E0B\u65B9\u65B0\u589E\u3002"})}),(0,Q.jsx)("form",{onSubmit:E=>{E.preventDefault(),!(e||d)&&(s(!0),v(""),m(""),L.current++,te(y,"credential/save",{credential:{id:x?.id,label:n,authType:u},content:a,passphrase:_,clearPassphrase:i,revision:T}).then(async()=>{k(),await M(),m("\u51ED\u8BC1\u5DF2\u4FDD\u5B58\uFF0C\u53EF\u5728\u4E3B\u673A\u4E2D\u6309\u540D\u79F0\u9009\u62E9\u3002")}).catch(C=>v(C.message)).finally(()=>s(!1)))},children:(0,Q.jsxs)("fieldset",{disabled:e,className:"zt-credential-fields",children:[(0,Q.jsx)("h3",{children:x?"\u7F16\u8F91\u51ED\u8BC1":"\u65B0\u589E\u51ED\u8BC1"}),(0,Q.jsxs)("div",{className:"zt-credential-meta",children:[(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u51ED\u8BC1\u540D\u79F0"}),(0,Q.jsx)("input",{required:!0,maxLength:200,value:n,placeholder:"\u4F8B\u5982\uFF1A\u8FD0\u7EF4\u79C1\u94A5",onChange:E=>h(E.target.value)})]}),(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u51ED\u8BC1\u7C7B\u578B"}),(0,Q.jsx)("select",{value:u,onChange:E=>{L.current++,p(!1),o(E.target.value),c(""),l(""),t(!1),v("")},children:Object.entries(Ue).map(([E,C])=>(0,Q.jsx)("option",{value:E,children:C},E))})]})]}),(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u51ED\u8BC1\u5185\u5BB9"}),u==="key"?(0,Q.jsx)("textarea",{rows:3,value:a,spellCheck:!1,autoComplete:"off",required:!x||x.authType!==u,placeholder:x?.authType===u?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u79C1\u94A5\uFF1B\u4E5F\u53EF\u9009\u62E9\u6587\u4EF6\u5BFC\u5165":"\u7C98\u8D34\u79C1\u94A5\u5185\u5BB9\uFF0C\u6216\u5728\u4E0B\u65B9\u9009\u62E9\u79C1\u94A5\u6587\u4EF6",onChange:E=>{L.current++,p(!1),c(E.target.value)}}):(0,Q.jsx)("input",{type:u==="password"?"password":"text",value:a,autoComplete:"new-password",required:u==="key-file"||!x||x.authType!==u,placeholder:u==="key-file"?"\u5BBF\u4E3B\u6587\u4EF6\u8DEF\u5F84\uFF0C\u4F8B\u5982 ~/.ssh/id_ed25519":x?.authType===u?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u5BC6\u7801":"\u8F93\u5165\u5BC6\u7801",onChange:E=>c(E.target.value)})]}),u==="key"&&(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u9009\u62E9\u79C1\u94A5\u6587\u4EF6"}),(0,Q.jsx)("input",{type:"file","aria-label":"\u9009\u62E9\u79C1\u94A5\u6587\u4EF6",disabled:e,onChange:E=>{let C=E.target.files?.[0],B=++L.current;if(E.target.value="",p(!1),!!C){if(C.size>1e5){v("\u79C1\u94A5\u6587\u4EF6\u4E0D\u80FD\u8D85\u8FC7 100 KB");return}p(!0),C.text().then(z=>{L.current===B&&(c(z),h(j=>j||C.name.slice(0,200)),v(""))}).catch(()=>{L.current===B&&v("\u8BFB\u53D6\u79C1\u94A5\u6587\u4EF6\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9")}).finally(()=>{L.current===B&&p(!1)})}}}),(0,Q.jsx)("small",{className:"zt-hint",children:"\u76F4\u63A5\u5BFC\u5165\u6587\u4EF6\uFF0C\u65E0\u9700\u586B\u5199\u8DEF\u5F84\u3002"})]}),u==="key-file"&&(0,Q.jsx)("p",{className:"zt-hint",children:"\u586B\u5199\u8FD0\u884C DSH \u7684\u673A\u5668\u4E0A\u7684\u79C1\u94A5\u8DEF\u5F84\uFF0C\u4EC5\u5728\u8FD9\u91CC\u586B\u5199\u4E00\u6B21\u3002\u8FDC\u7AEF\u90E8\u7F72\u65F6\u4F7F\u7528\u8FDC\u7AEF\u8DEF\u5F84\u3002"}),u!=="password"&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)("label",{className:"zt-field",children:[(0,Q.jsx)("span",{children:"\u79C1\u94A5\u53E3\u4EE4\uFF08\u53EF\u9009\uFF09"}),(0,Q.jsx)("input",{type:"password",autoComplete:"new-password",disabled:i,value:_,onChange:E=>l(E.target.value),placeholder:x?"\u7559\u7A7A\u4FDD\u7559\u73B0\u6709\u53E3\u4EE4":"\u79C1\u94A5\u6709\u53E3\u4EE4\u65F6\u586B\u5199"})]}),x?.passphraseRef&&(0,Q.jsxs)("label",{className:"zt-check",children:[(0,Q.jsx)("input",{type:"checkbox",checked:i,onChange:E=>t(E.target.checked)}),"\u6E05\u9664\u79C1\u94A5\u53E3\u4EE4"]})]}),g&&(0,Q.jsx)("p",{role:"alert",className:"zt-error",children:g}),f&&(0,Q.jsx)("p",{role:"status",className:"zt-success",children:f}),(0,Q.jsxs)("div",{className:"zt-actions",children:[x&&(0,Q.jsx)("button",{type:"button",disabled:e,onClick:()=>k(),children:"\u53D6\u6D88\u7F16\u8F91"}),(0,Q.jsx)("button",{className:"zt-primary",disabled:e||d,children:e?"\u4FDD\u5B58\u4E2D\u2026":d?"\u8BFB\u53D6\u6587\u4EF6\u2026":"\u4FDD\u5B58\u51ED\u8BC1"})]})]})})]})}var J=require("react/jsx-runtime"),Ri=["allowLocalTerminal","defaultSshUsername","defaultPrivateKeyPath","defaultCredentialId","defaultPanelWidth","maxSessions","maxWriteCalls","commandTimeoutMs"];function Ti({ctx:y}){let[S,T]=(0,De.useState)(),[M,x]=(0,De.useState)(""),[r,n]=(0,De.useState)(!1),[h,u]=(0,De.useState)(""),[o,a]=(0,De.useState)(!1),[c,_]=(0,De.useState)(""),l=xt(),[i,t]=(0,De.useState)(String(l)),e=(0,De.useRef)(),s=(0,De.useRef)(!0),d=(0,De.useCallback)(async()=>{let v=await te(y,"catalog");if(!s.current)return;let f=e.current;e.current=v,T(m=>({...v,...Object.fromEntries(Ri.filter(L=>f&&m?.[L]!==f[L]).map(L=>[L,m[L]]))}))},[y]);(0,De.useEffect)(()=>t(String(l)),[l]),(0,De.useEffect)(()=>(s.current=!0,d().catch(v=>{s.current&&x(v.message)}),()=>{s.current=!1}),[d]);let p=(v,f)=>{T({...S,[v]:f}),u("")},g=async v=>{if(!S||o)return;let f=!!S.temporarilyDisabled;a(!0),_(""),u(""),T({...S,temporarilyDisabled:v});try{await te(y,"config",{patch:{temporarilyDisabled:v},revision:S.revision})}catch(m){T(L=>({...L,temporarilyDisabled:f})),_(m instanceof Error?m.message:"\u5207\u6362\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),a(!1);return}window.dispatchEvent(new CustomEvent("dsh-zterm:state")),a(!1);try{await d()}catch(m){_(m instanceof Error?m.message:"\u5DF2\u5207\u6362\uFF0C\u4F46\u5237\u65B0\u914D\u7F6E\u5931\u8D25")}};return(0,J.jsxs)("section",{className:"zt-settings",children:[(0,J.jsx)("h2",{children:de}),(0,J.jsxs)("div",{className:`zt-settings-card zt-switch-card${S?.temporarilyDisabled?" active":""}`,children:[(0,J.jsx)("strong",{children:"\u4E34\u65F6\u7981\u7528 zTerm"}),(0,J.jsxs)("label",{className:"zt-check",children:[(0,J.jsx)("input",{type:"checkbox",role:"switch","aria-label":"\u4E34\u65F6\u7981\u7528 zTerm",checked:!!S?.temporarilyDisabled,disabled:!S||o,onChange:v=>void g(v.target.checked)}),"AI \u6682\u65F6\u4E0D\u4F7F\u7528 zTerm"]}),(0,J.jsx)("p",{className:"zt-hint",children:"\u63D2\u4EF6\u4FDD\u6301\u542F\u7528\uFF0C\u53EA\u8BA9 AI \u6682\u65F6\u770B\u4E0D\u5230\u3001\u4E5F\u7528\u4E0D\u4E86 zTerm \u5DE5\u5177\uFF0C\u5E76\u505C\u6B62\u6CE8\u5165 zTerm \u63D0\u793A\uFF1B\u5DE5\u4F5C\u53F0\u3001\u624B\u5DE5\u7EC8\u7AEF\u548C\u4E3B\u673A\uFF0F\u51ED\u636E\u7BA1\u7406\u4E0D\u53D7\u5F71\u54CD\u3002\u70B9\u51FB\u7ACB\u5373\u751F\u6548\uFF0C\u65E0\u9700\u4FDD\u5B58\u8BBE\u7F6E\u3002"}),S?.temporarilyDisabled&&(0,J.jsx)("p",{className:"zt-switch-status",role:"status",children:"\u5DF2\u4E34\u65F6\u7981\u7528\uFF1AAI \u4E0D\u4F1A\u6536\u5230 zTerm \u63D0\u793A\uFF0C\u4E5F\u4E0D\u80FD\u8C03\u7528 zterm_* \u5DE5\u5177\u3002"}),c&&(0,J.jsx)("p",{className:"zt-error",role:"alert",children:c})]}),(0,J.jsx)("p",{children:"\u5728 DSH \u5BF9\u8BDD\u53F3\u4FA7\u8FDE\u63A5\u771F\u5B9E\u673A\u5668\u3002\u9ED8\u8BA4\u8BFB\u6A21\u5F0F\uFF0C\u7531\u4EBA\u7C7B\u5728\u5DF2\u7ED1\u5B9A\u7EC8\u7AEF\u7684\u5DE5\u5177\u680F\u5F00\u542F\u8BFB\u5199\u3002"}),(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u7EC8\u7AEF\u5916\u89C2"}),(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:"\u7EC8\u7AEF\u5B57\u4F53\u5927\u5C0F\uFF08px\uFF09"}),(0,J.jsx)("input",{type:"number",min:Ct,max:wt,step:1,value:i,onChange:v=>{t(v.target.value),di(Number(v.target.value))},onBlur:()=>t(String(l))})]}),(0,J.jsxs)("p",{className:"zt-hint",children:["\u9ED8\u8BA4 ",Ge,"px\uFF0C\u53EF\u8C03 ",Ct,"\u2013",wt,"px\u3002\u4FEE\u6539\u7ACB\u5373\u5E94\u7528\u5230\u5DF2\u6253\u5F00\u7684\u7EC8\u7AEF\uFF0C\u4FDD\u5B58\u5728\u5F53\u524D\u6D4F\u89C8\u5668\u3002"]})]}),M&&(0,J.jsx)("p",{className:"zt-error",role:"alert",children:M}),h&&(0,J.jsx)("p",{className:"zt-success",role:"status",children:h}),S?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("form",{onSubmit:v=>{v.preventDefault(),n(!0),x(""),u(""),te(y,"config",{patch:Object.fromEntries(Ri.map(f=>[f,S[f]])),revision:S.revision}).then(()=>te(y,"catalog")).then(f=>{e.current=f,T(f),u(f.allowLocalTerminal?`\u914D\u7F6E\u5DF2\u4FDD\u5B58\u3002\u672C\u5730\u7EC8\u7AEF\u5DF2\u542F\u7528\uFF1A\u6253\u5F00 ${de}\uFF0C\u70B9\u51FB\u300C\u6253\u5F00\u672C\u673A\u7EC8\u7AEF\u300D\u3002`:"\u914D\u7F6E\u5DF2\u4FDD\u5B58\uFF0C\u672C\u5730\u7EC8\u7AEF\u672A\u542F\u7528\u3002")}).catch(f=>x(f.message)).finally(()=>n(!1))},children:[(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u672C\u5730\u7EC8\u7AEF"}),(0,J.jsxs)("label",{className:"zt-check",children:[(0,J.jsx)("input",{type:"checkbox",checked:S.allowLocalTerminal,onChange:v=>p("allowLocalTerminal",v.target.checked)}),"\u5141\u8BB8\u6253\u5F00\u8FD0\u884C DSH \u7684\u673A\u5668\u4E0A\u7684\u7EC8\u7AEF"]}),(0,J.jsx)("p",{className:"zt-hint",children:"DSH \u5728\u4F60\u7684\u7535\u8111\u4E0A\u8FD0\u884C\uFF0C\u5C31\u6253\u5F00\u8FD9\u53F0\u7535\u8111\u7684\u7EC8\u7AEF\uFF1BDSH \u5728\u670D\u52A1\u5668\u4E0A\u8FD0\u884C\uFF0C\u5C31\u6253\u5F00\u670D\u52A1\u5668\u7684\u7EC8\u7AEF\u3002"}),(0,J.jsxs)("p",{className:"zt-hint",children:["\u52FE\u9009\u540E\u70B9\u51FB\u4E0B\u65B9\u7684\u300C\u4FDD\u5B58\u8BBE\u7F6E\u300D\u624D\u4F1A\u751F\u6548\u3002\u7136\u540E\u4ECE\u804A\u5929\u9876\u90E8\u6253\u5F00\u300C",de,"\u300D\uFF0C\u70B9\u51FB\u9762\u677F\u53F3\u4E0A\u65B9\u7684\u300C\u6253\u5F00\u672C\u673A\u7EC8\u7AEF\u300D\u3002\u6BCF\u6B21\u70B9\u51FB\u90FD\u4F1A\u65B0\u5F00\u4E00\u4E2A\u7EC8\u7AEF\u6807\u7B7E\u3002"]})]}),(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u901A\u8FC7\u5BF9\u8BDD\u8FDE\u63A5\u8FDC\u7A0B\u673A\u5668"}),(0,J.jsx)("p",{children:"\u544A\u8BC9 AI \u8981\u8FDE\u63A5\u7684\u4E3B\u673A\u540D\u6216 IP\uFF0C\u4F8B\u5982\u300C\u8FDE\u63A5 192.0.2.21\u300D\u3002AI \u4F1A\u6309\u4EE5\u4E0B\u987A\u5E8F\u67E5\u627E\uFF1A"}),(0,J.jsxs)("ol",{className:"zt-hint",children:[(0,J.jsx)("li",{children:"\u5148\u627E\u4E3B\u673A\u5217\u8868\u91CC\u5DF2\u4FDD\u5B58\u7684\u673A\u5668\u3002"}),(0,J.jsx)("li",{children:"\u6CA1\u627E\u5230\uFF0C\u518D\u67E5 JumpServer\uFF08\u5821\u5792\u673A\uFF09\u91CC\u4F60\u6709\u6743\u9650\u8BBF\u95EE\u7684\u673A\u5668\u3002"}),(0,J.jsx)("li",{children:"\u90FD\u6CA1\u627E\u5230\uFF0C\u5C31\u4FDD\u5B58\u4E3A\u65B0\u4E3B\u673A\uFF0C\u5E76\u5C1D\u8BD5\u7528\u4E0B\u65B9\u7684\u8D26\u53F7\u548C SSH \u79C1\u94A5\u8FDE\u63A5\u3002"})]}),(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:"\u65B0\u4E3B\u673A\u9ED8\u8BA4\u767B\u5F55\u8D26\u53F7"}),(0,J.jsx)("input",{value:S.defaultSshUsername??"",placeholder:"\u7559\u7A7A\u4F7F\u7528\u8FD0\u884C DSH \u7684\u8D26\u53F7",onChange:v=>p("defaultSshUsername",v.target.value)})]}),(0,J.jsx)("p",{className:"zt-hint",children:"\u5BF9\u8BDD\u91CC\u6307\u5B9A\u4E86\u767B\u5F55\u8D26\u53F7\u65F6\uFF0C\u4F18\u5148\u4F7F\u7528\u4F60\u6307\u5B9A\u7684\u8D26\u53F7\u3002"}),(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:"\u9ED8\u8BA4 SSH \u51ED\u8BC1"}),(0,J.jsxs)("select",{value:S.defaultCredentialId??"",onChange:v=>p("defaultCredentialId",v.target.value),children:[(0,J.jsx)("option",{value:"",children:"\u81EA\u52A8\u67E5\u627E\u5BBF\u4E3B\u9ED8\u8BA4\u79C1\u94A5\u6587\u4EF6"}),(S.credentials??[]).filter(v=>v.authType!=="password").map(v=>(0,J.jsxs)("option",{value:v.id,children:[v.label," \xB7 ",Ue[v.authType]]},v.id))]})]}),(0,J.jsx)("p",{className:"zt-hint",children:"\u5728\u4E0B\u65B9\u300C\u7BA1\u7406\u51ED\u8BC1\u300D\u4FDD\u5B58\u79C1\u94A5\u540E\uFF0C\u6309\u540D\u79F0\u9009\u62E9\u9ED8\u8BA4\u51ED\u8BC1\u3002\u79C1\u94A5\u5185\u5BB9\u4E0D\u4F1A\u53D1\u9001\u7ED9 AI\u3002"}),!S.defaultCredentialId&&(0,J.jsxs)("details",{children:[(0,J.jsx)("summary",{children:"\u6307\u5B9A\u5DF2\u6709\u7684\u5BBF\u4E3B\u79C1\u94A5\u6587\u4EF6\uFF08\u53EF\u9009\uFF09"}),(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:"\u9ED8\u8BA4 SSH \u79C1\u94A5\u6587\u4EF6"}),(0,J.jsx)("input",{value:S.defaultPrivateKeyPath??"",placeholder:"\u7559\u7A7A\u81EA\u52A8\u67E5\u627E ~/.ssh \u4E0B\u7684\u9ED8\u8BA4\u79C1\u94A5",onChange:v=>p("defaultPrivateKeyPath",v.target.value)})]}),(0,J.jsx)("p",{className:"zt-hint",children:"\u4F7F\u7528\u8FD0\u884C DSH \u7684\u673A\u5668\u4E0A\u7684\u8DEF\u5F84\uFF1B\u8FDC\u7AEF\u90E8\u7F72\u65F6\u4F7F\u7528\u8FDC\u7AEF\u8DEF\u5F84\u3002"})]})]}),(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u6267\u884C\u4E0E\u5E03\u5C40"}),[["defaultPanelWidth","\u72EC\u7ACB\u9762\u677F\u9ED8\u8BA4\u5BBD\u5EA6\uFF08\u767E\u5206\u6BD4\uFF09",30,80],["maxSessions","\u6BCF\u4F1A\u8BDD\u7EC8\u7AEF\u4E0A\u9650",1,32],["maxWriteCalls","\u6BCF\u6B21\u8BFB\u5199\u6388\u6743\u7684\u547D\u4EE4\u4E0A\u9650",1,1e3],["commandTimeoutMs","\u5355\u6B21\u547D\u4EE4\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",1e3,12e4]].map(([v,f,m,L])=>(0,J.jsxs)("label",{className:"zt-field",children:[(0,J.jsx)("span",{children:f}),(0,J.jsx)("input",{type:"number",min:m,max:L,required:!0,value:S[v],onChange:k=>p(String(v),Number(k.target.value))})]},v))]}),(0,J.jsxs)("div",{className:"zt-settings-card",children:[(0,J.jsx)("strong",{children:"\u4E3B\u673A\u4E0E\u51ED\u636E"}),(0,J.jsxs)("p",{children:["\u4E3B\u673A\u3001\u6587\u4EF6\u5939\u3001JumpServer \u5B9E\u4F8B\u548C\u8D26\u53F7\u4ECE\u4F1A\u8BDD\u4E2D\u7684\u300C",de,"\u300D\u5165\u53E3\u7BA1\u7406\u3002\u5BC6\u7801\u3001\u79C1\u94A5\u5185\u5BB9\u548C\u53E3\u4EE4\u5199\u5165 DSH \u51ED\u636E\u5E93\uFF1B\u79C1\u94A5\u6587\u4EF6\u76F4\u63A5\u4ECE\u5BBF\u4E3B\u8BFB\u53D6\uFF0C\u5DE5\u5177\u7ED3\u679C\u4E0D\u5305\u542B\u51ED\u636E\u503C\u3002"]}),(0,J.jsxs)("p",{className:"zt-hint",children:["\u5DF2\u914D\u7F6E ",S.total," \u53F0\u4E3B\u673A\u3001",S.jumpservers.length," \u4E2A JumpServer \u5B9E\u4F8B\u3002"]})]}),(0,J.jsx)("button",{className:"zt-primary",disabled:r,children:r?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58\u8BBE\u7F6E"})]}),(0,J.jsx)(Li,{ctx:y,credentials:S.credentials??[],revision:S.revision,onSaved:d})]}):(0,J.jsx)("p",{className:"zt-hint",children:"\u6B63\u5728\u8BFB\u53D6\u914D\u7F6E\u2026"})]})}var Ai=`.zt-workbench,.zt-settings,.zt-modal{--zt-bg:var(--dsw-alias-bg-base,#fff);--zt-layer:var(--dsw-alias-bg-layer-2,#f4f6f8);--zt-text:var(--dsw-alias-label-primary,#252b36);--zt-muted:var(--dsw-alias-label-secondary,#687284);--zt-border:var(--dsw-alias-border-l2,#dfe3e9);--zt-accent:var(--dsw-alias-state-business-primary,#3764d6);color:var(--zt-text);font:13px/1.5 system-ui,sans-serif;box-sizing:border-box}
15
15
  .zt-workbench *,.zt-settings *,.zt-modal *{box-sizing:border-box}
16
16
  .zt-credential-header{display:flex;align-items:center;justify-content:space-between;gap:12px}.zt-credential-meta{display:flex;gap:12px;flex-wrap:wrap}.zt-credential-meta>.zt-field{flex:1 1 160px}.zt-credential-list{max-height:220px;overflow:auto}
17
17
  .zt-settings-card.zt-credential-manager .zt-field{margin-top:8px;margin-bottom:8px}.zt-credential-manager .zt-hint{margin:8px 0}.zt-credential-header strong{font-weight:500}
@@ -44,7 +44,7 @@ ${O}`)).catch(O=>pe(O.message))},children:"\u5BFC\u51FA\u7EC8\u7AEF"})]}),X&&(0,
44
44
  .zt-host-browser{display:flex;flex-direction:column;flex:1;min-height:0}.zt-asset-tree{flex:1;min-height:0;overflow:auto;overflow-anchor:none;padding:2px 5px 7px}.zt-directory-row{display:flex;align-items:center;min-width:0;min-height:28px;border-radius:5px}.zt-directory-row.active{color:var(--zt-accent);background:var(--zt-layer)}.zt-directory-row>button{border:0;background:transparent;font-size:12px;padding:4px 5px}.zt-directory-name{display:flex;align-items:center;flex:1;min-width:0;text-align:left;gap:3px}.zt-directory-arrow{width:15px;flex:none;text-align:center}.zt-directory-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.zt-directory-row .zt-folder-action{flex:none}.zt-tree-content{min-width:0}.zt-tree-content .zt-host-connect small,.zt-asset-row strong,.zt-asset-row small{white-space:nowrap;max-width:100%}.zt-tree-message{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font-size:11px;color:var(--zt-muted);margin:5px 8px 9px;overflow-wrap:anywhere}.zt-tree-message.zt-error{color:#bc414b}.zt-tree-message button{font-size:11px;padding:1px 5px}.zt-tree-content .zt-pagination{margin:2px 0 5px;font-size:10px}.zt-asset-tree button:focus-visible{outline:2px solid var(--zt-accent);outline-offset:-2px}
45
45
  .zt-folder-tree{flex:1;min-height:0;overflow:auto;padding:2px 8px 7px}.zt-folder-tree>button{display:block;width:100%;text-align:left}.zt-folder-tree>div{display:flex;min-width:0}.zt-folder-tree button{font-size:12px;border:0;background:transparent;padding:3px 5px;text-align:left;overflow:hidden;text-overflow:ellipsis}.zt-folder-tree .zt-folder-name{flex:1;min-width:0}.zt-folder-tree .zt-folder-action{flex:none;padding:3px 5px}.zt-folder-menu{position:fixed;inset:auto;margin:0;width:110px;padding:4px;border:1px solid var(--zt-border);border-radius:6px;background:var(--zt-bg);color:var(--zt-text);box-shadow:0 4px 14px #0002}.zt-folder-menu>button{display:block;width:100%;padding:5px 8px;text-align:left;border-radius:4px}.zt-folder-tree .active{color:var(--zt-accent);background:var(--zt-layer)}.zt-folder-toggle{width:20px;flex:none}.zt-standalone{right:var(--dsh-sidebar-width,0px)}
46
46
  @media(max-width:700px){.zt-status-info{gap:6px}.zt-terminal-controls{gap:3px;padding:3px 5px}.zt-terminal-controls button{font-size:11px;padding:3px 5px}.zt-terminal-toolbar{padding:5px}.zt-terminal-search span{display:none}.zt-hosts{max-width:42%;min-width:150px}.zt-host-row>button:last-child{display:none}.zt-modal-shade{padding:8px}.zt-mode{padding:3px;font-size:11px}.zt-terminal-toolbar .zt-actions{gap:3px}.zt-terminal-toolbar button{padding:3px 5px;font-size:11px}}
47
- `;var Ai=`/**
47
+ `;var Ii=`/**
48
48
  * Copyright (c) 2014 The xterm.js authors. All rights reserved.
49
49
  * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
50
50
  * https://github.com/chjj/term.js
@@ -262,6 +262,6 @@ ${O}`)).catch(O=>pe(O.message))},children:"\u5BFC\u51FA\u7EC8\u7AEF"})]}),X&&(0,
262
262
  z-index: 2;
263
263
  position: relative;
264
264
  }
265
- `;var ge=require("react/jsx-runtime"),Yi=["slots","connection"],Gt="dsh-zterm:workbench";function Ot(w=16){return(0,ge.jsxs)("svg",{width:w,height:w,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[(0,ge.jsx)("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"2"}),(0,ge.jsx)("path",{d:"m4 6 2 2-2 2m4 0h4"})]})}function Zi({ctx:w,service:S,tab:A,scope:B,visible:D}){return(0,ye.useEffect)(()=>{A?.id&&A.title!==de&&S.updateTab?.(A.id,{title:de})},[S,A?.id,A?.title]),(0,ge.jsx)(Jt,{ctx:w,sessionId:B.sessionId,visible:D},B.sessionId)}function Qi(w){let S=new Set,A,B=()=>S.forEach(c=>c()),D=()=>(0,ye.useSyncExternalStore)(c=>(S.add(c),()=>S.delete(c)),()=>A),r=document.createElement("style");r.dataset.plugin="dsh-zterm",r.textContent=`${Ai}
266
- ${Ti}`,document.head.appendChild(r),w.effect(()=>()=>{r.remove(),S.clear()}),w.inject(["betterSidebar"],c=>{A=c.betterSidebar,B();let u=A.registerTab({id:Gt,title:()=>de,description:"\u8FDE\u63A5\u771F\u5B9E\u673A\u5668\uFF0C\u63D0\u4F9B\u8BFB\u5DE5\u5177\u548C\u4EBA\u7C7B\u5F00\u542F\u7684\u8BFB\u5199\u64CD\u4F5C\u3002",icon:Ot,single:!0,order:109,component:a=>(0,ge.jsx)(Zi,{...a,ctx:w,service:c.betterSidebar})}),n=c.slots.inject("sidebar.right.pane.tab.title",()=>c.slots.register({name:"sidebar.right.pane.tab.title",key:`dsh-better-sidebar:${Gt}`,priority:-1},()=>(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("span",{"aria-hidden":"true",children:Ot()}),de]})));return()=>{n?.(),u?.(),A=void 0,B()}});function o(c){let u=D(),[n,a]=(0,ye.useState)(!1),[h,_]=(0,ye.useState)(""),[l,i]=(0,ye.useState)(!1),t=c.sessionId??c.scope?.sessionId,e=c.scope??{sessionId:t},s=c.useChat??c.useSession,d=typeof s=="function"?s(v=>v.legacy?.nodes??v.nodes):void 0,g=(0,ye.useRef)(""),p=()=>{u?.openTab?u.openTab({type:Gt,title:de,url:"zterm://workbench"},e):parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--dsh-mindmap-width"))>0?_("\u53F3\u4FA7\u8111\u56FE\u9762\u677F\u5DF2\u5C55\u5F00\u3002\u8BF7\u5148\u6536\u8D77\u8111\u56FE\uFF0C\u6216\u4F7F\u7528 Better Sidebar \u7684 Tab \u5207\u6362\u3002"):a(!0)};return(0,ye.useEffect)(()=>{t&&te(w,"client/attach",{sessionId:t,pageId:Bt}).catch(()=>{})},[t]),(0,ye.useEffect)(()=>{let v=!0,f=()=>{te(w,"status").then(m=>{v&&i(!!m?.temporarilyDisabled)}).catch(()=>{})};return f(),window.addEventListener("dsh-zterm:state",f),()=>{v=!1,window.removeEventListener("dsh-zterm:state",f)}},[w]),(0,ye.useEffect)(()=>{if(!d)return;let v=Array.isArray(d)?[...d]:[d],f="";for(let m=0;v.length&&m<5e3;m++){let E=v.pop();if(!E||typeof E!="object")continue;let k=E.name??E.call?.name??E.toolName;if(["zterm_connect","zterm_bind"].includes(k)){f=String(E.id??E.callId??E.call?.id??k);break}for(let x of["children","nodes","body","calls","subCalls"]){let C=E[x];if(Array.isArray(C))for(let M of C){if(v.length>=5e3)break;v.push(M)}}}f&&f!==g.current&&(g.current=f,p())},[d,u,t]),(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("button",{className:"zt-header-button",title:l?`${de} \u5DF2\u4E34\u65F6\u7981\u7528\uFF1AAI \u4E0D\u4F1A\u4F7F\u7528\u672C\u63D2\u4EF6\u5DE5\u5177`:`\u6253\u5F00 ${de}`,onClick:p,children:[Ot(15),de,l&&(0,ge.jsx)("span",{className:"zt-header-badge",children:"AI\u7981\u7528"})]}),n&&!u&&t&&(0,ge.jsx)(er,{ctx:w,sessionId:t,onClose:()=>a(!1),onConflict:()=>{a(!1),_(`\u8111\u56FE\u9762\u677F\u5DF2\u5C55\u5F00\uFF0C${de} \u72EC\u7ACB\u9762\u677F\u5DF2\u6536\u8D77\u3002\u53EF\u4EE5\u4ECE ${de} \u5165\u53E3\u91CD\u65B0\u6253\u5F00\u3002`)}}),h&&(0,ge.jsxs)("div",{className:"zt-standalone-error",role:"alert",children:[h,(0,ge.jsx)("button",{onClick:()=>_(""),children:"\u5173\u95ED"})]})]})}w.slots.inject("conversation.session.header.actions",()=>w.slots.register({name:"conversation.session.header.actions",id:"dsh-zterm",order:109},o)),w.slots.inject("settings.section",()=>w.slots.register({name:"settings.section",id:"dsh-zterm",order:109,label:de,icon:Ot},()=>(0,ge.jsx)(Ri,{ctx:w})))}function er({ctx:w,sessionId:S,onClose:A,onConflict:B}){let D=n=>Math.min(window.innerWidth*.8,Math.max(Math.min(480,window.innerWidth*.8),n)),[r,o]=(0,ye.useState)(()=>D(rt("dsh-zterm.panel-width",window.innerWidth*.6,0,window.innerWidth))),c=Et();(0,ye.useEffect)(()=>{let n=!0;return te(w,"catalog").then(a=>{n&&o(D(rt("dsh-zterm.panel-width",window.innerWidth*a.defaultPanelWidth/100,0,window.innerWidth)))}).catch(()=>{}),()=>{n=!1}},[w]),(0,ye.useEffect)(()=>{let n=()=>{parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--dsh-mindmap-width"))>0&&B()},a=new MutationObserver(n);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["style"]}),n(),()=>a.disconnect()},[B]),(0,ye.useEffect)(()=>{let n=()=>o(a=>Math.min(window.innerWidth*.8,Math.max(Math.min(480,window.innerWidth*.8),a)));return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),(0,ye.useEffect)(()=>{document.documentElement.style.setProperty("--dsh-zterm-width",`${r}px`);let n=document.createElement("style");return n.dataset.plugin="dsh-zterm",n.textContent="#root{margin-right:calc(var(--dsh-zterm-width,0px) + var(--dsh-sidebar-width,0px))!important;width:calc(100% - var(--dsh-zterm-width,0px) - var(--dsh-sidebar-width,0px))!important}",document.head.appendChild(n),()=>{n.remove(),document.documentElement.style.removeProperty("--dsh-zterm-width")}},[r]);let u=n=>{let a=n.clientX,h=r;c(n,_=>{let l=D(h+a-_.clientX);o(l),st("dsh-zterm.panel-width",l)})};return(0,ge.jsxs)("section",{className:"zt-standalone",style:{width:r},"aria-label":de,children:[(0,ge.jsx)("div",{className:"zt-panel-handle",role:"separator","aria-label":`\u8C03\u6574 ${de} \u9762\u677F\u5BBD\u5EA6`,onMouseDown:u}),(0,ge.jsx)(Jt,{ctx:w,sessionId:S,onClose:A},S)]})}
265
+ `;var Gt="dsh:panel-layout",Bi="dsh-mindmap",Pi="dsh-zterm";var Oi="--dsh-zterm-width",sr="#root{margin-right:calc(var(--dsh-mindmap-width,0px) + var(--dsh-zterm-width,0px) + var(--dsh-sidebar-width,0px))!important;width:calc(100% - var(--dsh-mindmap-width,0px) - var(--dsh-zterm-width,0px) - var(--dsh-sidebar-width,0px))!important}";function Mi(y,S){window.dispatchEvent(new CustomEvent(Gt,{detail:{id:y,width:S}}))}function zi(y,S){let T=M=>{let x=M.detail;x?.id===y&&Number(x.width)>0&&S()};return window.addEventListener(Gt,T),()=>window.removeEventListener(Gt,T)}function Hi(y,S){let T=document.createElement("style");T.dataset.plugin=y,T.textContent=sr,document.head.appendChild(T);let M=!1;return{setWidth(x){M||(document.documentElement.style.setProperty(S,`${x}px`),Mi(y,x))},dispose(){M||(M=!0,T.remove(),document.documentElement.style.removeProperty(S),Mi(y,0))}}}var ge=require("react/jsx-runtime"),nr=["slots","connection"],Xt="dsh-zterm:workbench";function Pt(y=16){return(0,ge.jsxs)("svg",{width:y,height:y,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[(0,ge.jsx)("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"2"}),(0,ge.jsx)("path",{d:"m4 6 2 2-2 2m4 0h4"})]})}function or({ctx:y,service:S,tab:T,scope:M,visible:x}){return(0,me.useEffect)(()=>{T?.id&&T.title!==de&&S.updateTab?.(T.id,{title:de})},[S,T?.id,T?.title]),(0,ge.jsx)(Jt,{ctx:y,sessionId:M.sessionId,visible:x},M.sessionId)}function ar(y){let S=new Set,T,M=()=>S.forEach(h=>h()),x=()=>(0,me.useSyncExternalStore)(h=>(S.add(h),()=>S.delete(h)),()=>T),r=document.createElement("style");r.dataset.plugin="dsh-zterm",r.textContent=`${Ii}
266
+ ${Ai}`,document.head.appendChild(r),y.effect(()=>()=>{r.remove(),S.clear()}),y.inject(["betterSidebar"],h=>{T=h.betterSidebar,M();let u=T.registerTab({id:Xt,title:()=>de,description:"\u8FDE\u63A5\u771F\u5B9E\u673A\u5668\uFF0C\u63D0\u4F9B\u8BFB\u5DE5\u5177\u548C\u4EBA\u7C7B\u5F00\u542F\u7684\u8BFB\u5199\u64CD\u4F5C\u3002",icon:Pt,single:!0,order:109,component:a=>(0,ge.jsx)(or,{...a,ctx:y,service:h.betterSidebar})}),o=h.slots.inject("sidebar.right.pane.tab.title",()=>h.slots.register({name:"sidebar.right.pane.tab.title",key:`dsh-better-sidebar:${Xt}`,priority:-1},()=>(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("span",{"aria-hidden":"true",children:Pt()}),de]})));return()=>{o?.(),u?.(),T=void 0,M()}});function n(h){let u=x(),[o,a]=(0,me.useState)(),[c,_]=(0,me.useState)(""),[l,i]=(0,me.useState)(!1),t=h.sessionId??h.scope?.sessionId,e=h.scope??{sessionId:t},s=()=>{t&&(_(""),u?.openTab?u.openTab({type:Xt,title:de,url:"zterm://workbench"},e):parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--dsh-mindmap-width"))>0?_("\u53F3\u4FA7\u8111\u56FE\u9762\u677F\u5DF2\u5C55\u5F00\u3002\u8BF7\u5148\u6536\u8D77\u8111\u56FE\uFF0C\u6216\u4F7F\u7528 Better Sidebar \u7684 Tab \u5207\u6362\u3002"):a(t))};return(0,me.useEffect)(()=>{a(void 0),_("")},[t]),(0,me.useEffect)(()=>{t&&te(y,"client/attach",{sessionId:t,pageId:Bt}).catch(()=>{})},[t]),(0,me.useEffect)(()=>{let d=!0,p=()=>{te(y,"status").then(g=>{d&&i(!!g?.temporarilyDisabled)}).catch(()=>{})};return p(),window.addEventListener("dsh-zterm:state",p),()=>{d=!1,window.removeEventListener("dsh-zterm:state",p)}},[y]),(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("button",{className:"zt-header-button",title:l?`${de} \u5DF2\u4E34\u65F6\u7981\u7528\uFF1AAI \u4E0D\u4F1A\u4F7F\u7528\u672C\u63D2\u4EF6\u5DE5\u5177`:`\u6253\u5F00 ${de}`,onClick:s,children:[Pt(15),de,l&&(0,ge.jsx)("span",{className:"zt-header-badge",children:"AI\u7981\u7528"})]}),o===t&&!u&&t&&(0,ge.jsx)(lr,{ctx:y,sessionId:t,onClose:()=>a(void 0),onConflict:()=>{a(void 0),_(`\u8111\u56FE\u9762\u677F\u5DF2\u5C55\u5F00\uFF0C${de} \u72EC\u7ACB\u9762\u677F\u5DF2\u6536\u8D77\u3002\u53EF\u4EE5\u4ECE ${de} \u5165\u53E3\u91CD\u65B0\u6253\u5F00\u3002`)}}),c&&(0,ge.jsxs)("div",{className:"zt-standalone-error",role:"alert",children:[c,(0,ge.jsx)("button",{onClick:()=>_(""),children:"\u5173\u95ED"})]})]})}y.slots.inject("conversation.session.header.actions",()=>y.slots.register({name:"conversation.session.header.actions",id:"dsh-zterm",order:109},n)),y.slots.inject("settings.section",()=>y.slots.register({name:"settings.section",id:"dsh-zterm",order:109,label:de,icon:Pt},()=>(0,ge.jsx)(Ti,{ctx:y})))}function lr({ctx:y,sessionId:S,onClose:T,onConflict:M}){let x=a=>Math.min(window.innerWidth*.8,Math.max(Math.min(480,window.innerWidth*.8),a)),[r,n]=(0,me.useState)(()=>x(rt("dsh-zterm.panel-width",window.innerWidth*.6,0,window.innerWidth))),h=Et();(0,me.useEffect)(()=>{let a=!0;return te(y,"catalog").then(c=>{a&&n(x(rt("dsh-zterm.panel-width",window.innerWidth*c.defaultPanelWidth/100,0,window.innerWidth)))}).catch(()=>{}),()=>{a=!1}},[y]),(0,me.useEffect)(()=>{let a=()=>n(c=>Math.min(window.innerWidth*.8,Math.max(Math.min(480,window.innerWidth*.8),c)));return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),(0,me.useEffect)(()=>zi(Bi,M),[M]);let u=(0,me.useRef)();(0,me.useEffect)(()=>(u.current=Hi(Pi,Oi),()=>{u.current?.dispose(),u.current=void 0}),[]),(0,me.useEffect)(()=>{u.current?.setWidth(r)},[r]);let o=a=>{let c=a.clientX,_=r;h(a,l=>{let i=x(_+c-l.clientX);n(i),st("dsh-zterm.panel-width",i)})};return(0,ge.jsxs)("section",{className:"zt-standalone",style:{width:r},"aria-label":de,children:[(0,ge.jsx)("div",{className:"zt-panel-handle",role:"separator","aria-label":`\u8C03\u6574 ${de} \u9762\u677F\u5BBD\u5EA6`,onMouseDown:o}),(0,ge.jsx)(Jt,{ctx:y,sessionId:S,onClose:T},S)]})}
267
267
  return module.exports; } });