linkshell-cli 0.5.14 → 0.5.15

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.
@@ -89,6 +89,6 @@ WARNING: This link could potentially be dangerous`)){const b=window.open();if(b)
89
89
  `:`
90
90
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(N){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),b.isLinux&&N&&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(N){const L=this._getMouseBufferCoords(N),P=this._model.finalSelectionStart,H=this._model.finalSelectionEnd;return!!(P&&H&&L)&&this._areCoordsInSelection(L,P,H)}isCellInSelection(N,L){const P=this._model.finalSelectionStart,H=this._model.finalSelectionEnd;return!(!P||!H)&&this._areCoordsInSelection([N,L],P,H)}_areCoordsInSelection(N,L,P){return N[1]>L[1]&&N[1]<P[1]||L[1]===P[1]&&N[1]===L[1]&&N[0]>=L[0]&&N[0]<P[0]||L[1]<P[1]&&N[1]===P[1]&&N[0]<P[0]||L[1]<P[1]&&N[1]===L[1]&&N[0]>=L[0]}_selectWordAtCursor(N,L){var $,q;const P=(q=($=this._linkifier.currentLink)==null?void 0:$.link)==null?void 0:q.range;if(P)return this._model.selectionStart=[P.start.x-1,P.start.y-1],this._model.selectionStartLength=(0,v.getRangeLength)(P,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const H=this._getMouseBufferCoords(N);return!!H&&(this._selectWordAt(H,L),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(N,L){this._model.clearSelection(),N=Math.max(N,0),L=Math.min(L,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,N],this._model.selectionEnd=[this._bufferService.cols,L],this.refresh(),this._onSelectionChange.fire()}_handleTrim(N){this._model.handleTrim(N)&&this.refresh()}_getMouseBufferCoords(N){const L=this._mouseService.getCoords(N,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(L)return L[0]--,L[1]--,L[1]+=this._bufferService.buffer.ydisp,L}_getMouseEventScrollAmount(N){let L=(0,p.getCoordsRelativeToElement)(this._coreBrowserService.window,N,this._screenElement)[1];const P=this._renderService.dimensions.css.canvas.height;return L>=0&&L<=P?0:(L>P&&(L-=P),L=Math.min(Math.max(L,-50),50),L/=50,L/Math.abs(L)+Math.round(14*L))}shouldForceSelection(N){return b.isMac?N.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:N.shiftKey}handleMouseDown(N){if(this._mouseDownTimeStamp=N.timeStamp,(N.button!==2||!this.hasSelection)&&N.button===0){if(!this._enabled){if(!this.shouldForceSelection(N))return;N.stopPropagation()}N.preventDefault(),this._dragScrollAmount=0,this._enabled&&N.shiftKey?this._handleIncrementalClick(N):N.detail===1?this._handleSingleClick(N):N.detail===2?this._handleDoubleClick(N):N.detail===3&&this._handleTripleClick(N),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(N){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(N))}_handleSingleClick(N){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(N)?3:0,this._model.selectionStart=this._getMouseBufferCoords(N),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const L=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);L&&L.length!==this._model.selectionStart[0]&&L.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(N){this._selectWordAtCursor(N,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(N){const L=this._getMouseBufferCoords(N);L&&(this._activeSelectionMode=2,this._selectLineAt(L[1]))}shouldColumnSelect(N){return N.altKey&&!(b.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(N){if(N.stopImmediatePropagation(),!this._model.selectionStart)return;const L=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(N),!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(N),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const P=this._bufferService.buffer;if(this._model.selectionEnd[1]<P.lines.length){const H=P.lines.get(this._model.selectionEnd[1]);H&&H.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}L&&L[0]===this._model.selectionEnd[0]&&L[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});const N=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(N.ydisp+this._bufferService.rows,N.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=N.ydisp),this.refresh()}}_handleMouseUp(N){const L=N.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&L<500&&N.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const P=this._mouseService.getCoords(N,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(P&&P[0]!==void 0&&P[1]!==void 0){const H=(0,x.moveToCellSequence)(P[0]-1,P[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(H,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const N=this._model.finalSelectionStart,L=this._model.finalSelectionEnd,P=!(!N||!L||N[0]===L[0]&&N[1]===L[1]);P?N&&L&&(this._oldSelectionStart&&this._oldSelectionEnd&&N[0]===this._oldSelectionStart[0]&&N[1]===this._oldSelectionStart[1]&&L[0]===this._oldSelectionEnd[0]&&L[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(N,L,P)):this._oldHasSelection&&this._fireOnSelectionChange(N,L,P)}_fireOnSelectionChange(N,L,P){this._oldSelectionStart=N,this._oldSelectionEnd=L,this._oldHasSelection=P,this._onSelectionChange.fire()}_handleBufferActivate(N){this.clearSelection(),this._trimListener.dispose(),this._trimListener=N.activeBuffer.lines.onTrim((L=>this._handleTrim(L)))}_convertViewportColToCharacterIndex(N,L){let P=L;for(let H=0;L>=H;H++){const $=N.loadCell(H,this._workCell).getChars().length;this._workCell.getWidth()===0?P--:$>1&&L!==H&&(P+=$-1)}return P}setSelection(N,L,P){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[N,L],this._model.selectionStartLength=P,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(N){this._isClickInSelection(N)||(this._selectWordAtCursor(N,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(N,L,P=!0,H=!0){if(N[0]>=this._bufferService.cols)return;const $=this._bufferService.buffer,q=$.lines.get(N[1]);if(!q)return;const Z=$.translateBufferLineToString(N[1],!1);let K=this._convertViewportColToCharacterIndex(q,N[0]),G=K;const te=N[0]-K;let ee=0,I=0,T=0,z=0;if(Z.charAt(K)===" "){for(;K>0&&Z.charAt(K-1)===" ";)K--;for(;G<Z.length&&Z.charAt(G+1)===" ";)G++}else{let le=N[0],xe=N[0];q.getWidth(le)===0&&(ee++,le--),q.getWidth(xe)===2&&(I++,xe++);const fe=q.getString(xe).length;for(fe>1&&(z+=fe-1,G+=fe-1);le>0&&K>0&&!this._isCharWordSeparator(q.loadCell(le-1,this._workCell));){q.loadCell(le-1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(ee++,le--):Y>1&&(T+=Y-1,K-=Y-1),K--,le--}for(;xe<q.length&&G+1<Z.length&&!this._isCharWordSeparator(q.loadCell(xe+1,this._workCell));){q.loadCell(xe+1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(I++,xe++):Y>1&&(z+=Y-1,G+=Y-1),G++,xe++}}G++;let F=K+te-ee+T,B=Math.min(this._bufferService.cols,G-K+ee+I-T-z);if(L||Z.slice(K,G).trim()!==""){if(P&&F===0&&q.getCodePoint(0)!==32){const le=$.lines.get(N[1]-1);if(le&&q.isWrapped&&le.getCodePoint(this._bufferService.cols-1)!==32){const xe=this._getWordAt([this._bufferService.cols-1,N[1]-1],!1,!0,!1);if(xe){const fe=this._bufferService.cols-xe.start;F-=fe,B+=fe}}}if(H&&F+B===this._bufferService.cols&&q.getCodePoint(this._bufferService.cols-1)!==32){const le=$.lines.get(N[1]+1);if(le!=null&&le.isWrapped&&le.getCodePoint(0)!==32){const xe=this._getWordAt([0,N[1]+1],!1,!1,!0);xe&&(B+=xe.length)}}return{start:F,length:B}}}_selectWordAt(N,L){const P=this._getWordAt(N,L);if(P){for(;P.start<0;)P.start+=this._bufferService.cols,N[1]--;this._model.selectionStart=[P.start,N[1]],this._model.selectionStartLength=P.length}}_selectToWordAt(N){const L=this._getWordAt(N,!0);if(L){let P=N[1];for(;L.start<0;)L.start+=this._bufferService.cols,P--;if(!this._model.areSelectionValuesReversed())for(;L.start+L.length>this._bufferService.cols;)L.length-=this._bufferService.cols,P++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?L.start:L.start+L.length,P]}}_isCharWordSeparator(N){return N.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(N.getChars())>=0}_selectLineAt(N){const L=this._bufferService.buffer.getWrappedRangeForLine(N),P={start:{x:0,y:L.first},end:{x:this._bufferService.cols-1,y:L.last}};this._model.selectionStart=[0,L.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,v.getRangeLength)(P,this._bufferService.cols)}};o.SelectionService=O=d([m(3,A.IBufferService),m(4,A.ICoreService),m(5,C.IMouseService),m(6,A.IOptionsService),m(7,C.IRenderService),m(8,C.ICoreBrowserService)],O)},4725:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ILinkProviderService=o.IThemeService=o.ICharacterJoinerService=o.ISelectionService=o.IRenderService=o.IMouseService=o.ICoreBrowserService=o.ICharSizeService=void 0;const d=h(8343);o.ICharSizeService=(0,d.createDecorator)("CharSizeService"),o.ICoreBrowserService=(0,d.createDecorator)("CoreBrowserService"),o.IMouseService=(0,d.createDecorator)("MouseService"),o.IRenderService=(0,d.createDecorator)("RenderService"),o.ISelectionService=(0,d.createDecorator)("SelectionService"),o.ICharacterJoinerService=(0,d.createDecorator)("CharacterJoinerService"),o.IThemeService=(0,d.createDecorator)("ThemeService"),o.ILinkProviderService=(0,d.createDecorator)("LinkProviderService")},6731:function(f,o,h){var d=this&&this.__decorate||function(O,N,L,P){var H,$=arguments.length,q=$<3?N:P===null?P=Object.getOwnPropertyDescriptor(N,L):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")q=Reflect.decorate(O,N,L,P);else for(var Z=O.length-1;Z>=0;Z--)(H=O[Z])&&(q=($<3?H(q):$>3?H(N,L,q):H(N,L))||q);return $>3&&q&&Object.defineProperty(N,L,q),q},m=this&&this.__param||function(O,N){return function(L,P){N(L,P,O)}};Object.defineProperty(o,"__esModule",{value:!0}),o.ThemeService=o.DEFAULT_ANSI_COLORS=void 0;const p=h(7239),x=h(8055),S=h(8460),C=h(844),w=h(2585),_=x.css.toColor("#ffffff"),b=x.css.toColor("#000000"),v=x.css.toColor("#ffffff"),y=x.css.toColor("#000000"),A={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};o.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const O=[x.css.toColor("#2e3436"),x.css.toColor("#cc0000"),x.css.toColor("#4e9a06"),x.css.toColor("#c4a000"),x.css.toColor("#3465a4"),x.css.toColor("#75507b"),x.css.toColor("#06989a"),x.css.toColor("#d3d7cf"),x.css.toColor("#555753"),x.css.toColor("#ef2929"),x.css.toColor("#8ae234"),x.css.toColor("#fce94f"),x.css.toColor("#729fcf"),x.css.toColor("#ad7fa8"),x.css.toColor("#34e2e2"),x.css.toColor("#eeeeec")],N=[0,95,135,175,215,255];for(let L=0;L<216;L++){const P=N[L/36%6|0],H=N[L/6%6|0],$=N[L%6];O.push({css:x.channels.toCss(P,H,$),rgba:x.channels.toRgba(P,H,$)})}for(let L=0;L<24;L++){const P=8+10*L;O.push({css:x.channels.toCss(P,P,P),rgba:x.channels.toRgba(P,P,P)})}return O})());let M=o.ThemeService=class extends C.Disposable{get colors(){return this._colors}constructor(O){super(),this._optionsService=O,this._contrastCache=new p.ColorContrastCache,this._halfContrastCache=new p.ColorContrastCache,this._onChangeColors=this.register(new S.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:_,background:b,cursor:v,cursorAccent:y,selectionForeground:void 0,selectionBackgroundTransparent:A,selectionBackgroundOpaque:x.color.blend(b,A),selectionInactiveBackgroundTransparent:A,selectionInactiveBackgroundOpaque:x.color.blend(b,A),ansi:o.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(O={}){const N=this._colors;if(N.foreground=R(O.foreground,_),N.background=R(O.background,b),N.cursor=R(O.cursor,v),N.cursorAccent=R(O.cursorAccent,y),N.selectionBackgroundTransparent=R(O.selectionBackground,A),N.selectionBackgroundOpaque=x.color.blend(N.background,N.selectionBackgroundTransparent),N.selectionInactiveBackgroundTransparent=R(O.selectionInactiveBackground,N.selectionBackgroundTransparent),N.selectionInactiveBackgroundOpaque=x.color.blend(N.background,N.selectionInactiveBackgroundTransparent),N.selectionForeground=O.selectionForeground?R(O.selectionForeground,x.NULL_COLOR):void 0,N.selectionForeground===x.NULL_COLOR&&(N.selectionForeground=void 0),x.color.isOpaque(N.selectionBackgroundTransparent)&&(N.selectionBackgroundTransparent=x.color.opacity(N.selectionBackgroundTransparent,.3)),x.color.isOpaque(N.selectionInactiveBackgroundTransparent)&&(N.selectionInactiveBackgroundTransparent=x.color.opacity(N.selectionInactiveBackgroundTransparent,.3)),N.ansi=o.DEFAULT_ANSI_COLORS.slice(),N.ansi[0]=R(O.black,o.DEFAULT_ANSI_COLORS[0]),N.ansi[1]=R(O.red,o.DEFAULT_ANSI_COLORS[1]),N.ansi[2]=R(O.green,o.DEFAULT_ANSI_COLORS[2]),N.ansi[3]=R(O.yellow,o.DEFAULT_ANSI_COLORS[3]),N.ansi[4]=R(O.blue,o.DEFAULT_ANSI_COLORS[4]),N.ansi[5]=R(O.magenta,o.DEFAULT_ANSI_COLORS[5]),N.ansi[6]=R(O.cyan,o.DEFAULT_ANSI_COLORS[6]),N.ansi[7]=R(O.white,o.DEFAULT_ANSI_COLORS[7]),N.ansi[8]=R(O.brightBlack,o.DEFAULT_ANSI_COLORS[8]),N.ansi[9]=R(O.brightRed,o.DEFAULT_ANSI_COLORS[9]),N.ansi[10]=R(O.brightGreen,o.DEFAULT_ANSI_COLORS[10]),N.ansi[11]=R(O.brightYellow,o.DEFAULT_ANSI_COLORS[11]),N.ansi[12]=R(O.brightBlue,o.DEFAULT_ANSI_COLORS[12]),N.ansi[13]=R(O.brightMagenta,o.DEFAULT_ANSI_COLORS[13]),N.ansi[14]=R(O.brightCyan,o.DEFAULT_ANSI_COLORS[14]),N.ansi[15]=R(O.brightWhite,o.DEFAULT_ANSI_COLORS[15]),O.extendedAnsi){const L=Math.min(N.ansi.length-16,O.extendedAnsi.length);for(let P=0;P<L;P++)N.ansi[P+16]=R(O.extendedAnsi[P],o.DEFAULT_ANSI_COLORS[P+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(O){this._restoreColor(O),this._onChangeColors.fire(this.colors)}_restoreColor(O){if(O!==void 0)switch(O){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[O]=this._restoreColors.ansi[O]}else for(let N=0;N<this._restoreColors.ansi.length;++N)this._colors.ansi[N]=this._restoreColors.ansi[N]}modifyColors(O){O(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 R(O,N){if(O!==void 0)try{return x.css.toColor(O)}catch{}return N}o.ThemeService=M=d([m(0,w.IOptionsService)],M)},6349:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CircularList=void 0;const d=h(8460),m=h(844);class p extends m.Disposable{constructor(S){super(),this._maxLength=S,this.onDeleteEmitter=this.register(new d.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new d.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new d.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(S){if(this._maxLength===S)return;const C=new Array(S);for(let w=0;w<Math.min(S,this.length);w++)C[w]=this._array[this._getCyclicIndex(w)];this._array=C,this._maxLength=S,this._startIndex=0}get length(){return this._length}set length(S){if(S>this._length)for(let C=this._length;C<S;C++)this._array[C]=void 0;this._length=S}get(S){return this._array[this._getCyclicIndex(S)]}set(S,C){this._array[this._getCyclicIndex(S)]=C}push(S){this._array[this._getCyclicIndex(this._length)]=S,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(S,C,...w){if(C){for(let _=S;_<this._length-C;_++)this._array[this._getCyclicIndex(_)]=this._array[this._getCyclicIndex(_+C)];this._length-=C,this.onDeleteEmitter.fire({index:S,amount:C})}for(let _=this._length-1;_>=S;_--)this._array[this._getCyclicIndex(_+w.length)]=this._array[this._getCyclicIndex(_)];for(let _=0;_<w.length;_++)this._array[this._getCyclicIndex(S+_)]=w[_];if(w.length&&this.onInsertEmitter.fire({index:S,amount:w.length}),this._length+w.length>this._maxLength){const _=this._length+w.length-this._maxLength;this._startIndex+=_,this._length=this._maxLength,this.onTrimEmitter.fire(_)}else this._length+=w.length}trimStart(S){S>this._length&&(S=this._length),this._startIndex+=S,this._length-=S,this.onTrimEmitter.fire(S)}shiftElements(S,C,w){if(!(C<=0)){if(S<0||S>=this._length)throw new Error("start argument out of range");if(S+w<0)throw new Error("Cannot shift elements in list beyond index 0");if(w>0){for(let b=C-1;b>=0;b--)this.set(S+b+w,this.get(S+b));const _=S+C+w-this._length;if(_>0)for(this._length+=_;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let _=0;_<C;_++)this.set(S+_+w,this.get(S+_))}}_getCyclicIndex(S){return(this._startIndex+S)%this._maxLength}}o.CircularList=p},1439:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.clone=void 0,o.clone=function h(d,m=5){if(typeof d!="object")return d;const p=Array.isArray(d)?[]:{};for(const x in d)p[x]=m<=1?d[x]:d[x]&&h(d[x],m-1);return p}},8055:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.contrastRatio=o.toPaddedHex=o.rgba=o.rgb=o.css=o.color=o.channels=o.NULL_COLOR=void 0;let h=0,d=0,m=0,p=0;var x,S,C,w,_;function b(y){const A=y.toString(16);return A.length<2?"0"+A:A}function v(y,A){return y<A?(A+.05)/(y+.05):(y+.05)/(A+.05)}o.NULL_COLOR={css:"#00000000",rgba:0},(function(y){y.toCss=function(A,M,R,O){return O!==void 0?`#${b(A)}${b(M)}${b(R)}${b(O)}`:`#${b(A)}${b(M)}${b(R)}`},y.toRgba=function(A,M,R,O=255){return(A<<24|M<<16|R<<8|O)>>>0},y.toColor=function(A,M,R,O){return{css:y.toCss(A,M,R,O),rgba:y.toRgba(A,M,R,O)}}})(x||(o.channels=x={})),(function(y){function A(M,R){return p=Math.round(255*R),[h,d,m]=_.toChannels(M.rgba),{css:x.toCss(h,d,m,p),rgba:x.toRgba(h,d,m,p)}}y.blend=function(M,R){if(p=(255&R.rgba)/255,p===1)return{css:R.css,rgba:R.rgba};const O=R.rgba>>24&255,N=R.rgba>>16&255,L=R.rgba>>8&255,P=M.rgba>>24&255,H=M.rgba>>16&255,$=M.rgba>>8&255;return h=P+Math.round((O-P)*p),d=H+Math.round((N-H)*p),m=$+Math.round((L-$)*p),{css:x.toCss(h,d,m),rgba:x.toRgba(h,d,m)}},y.isOpaque=function(M){return(255&M.rgba)==255},y.ensureContrastRatio=function(M,R,O){const N=_.ensureContrastRatio(M.rgba,R.rgba,O);if(N)return x.toColor(N>>24&255,N>>16&255,N>>8&255)},y.opaque=function(M){const R=(255|M.rgba)>>>0;return[h,d,m]=_.toChannels(R),{css:x.toCss(h,d,m),rgba:R}},y.opacity=A,y.multiplyOpacity=function(M,R){return p=255&M.rgba,A(M,p*R/255)},y.toColorRGB=function(M){return[M.rgba>>24&255,M.rgba>>16&255,M.rgba>>8&255]}})(S||(o.color=S={})),(function(y){let A,M;try{const R=document.createElement("canvas");R.width=1,R.height=1;const O=R.getContext("2d",{willReadFrequently:!0});O&&(A=O,A.globalCompositeOperation="copy",M=A.createLinearGradient(0,0,1,1))}catch{}y.toColor=function(R){if(R.match(/#[\da-f]{3,8}/i))switch(R.length){case 4:return h=parseInt(R.slice(1,2).repeat(2),16),d=parseInt(R.slice(2,3).repeat(2),16),m=parseInt(R.slice(3,4).repeat(2),16),x.toColor(h,d,m);case 5:return h=parseInt(R.slice(1,2).repeat(2),16),d=parseInt(R.slice(2,3).repeat(2),16),m=parseInt(R.slice(3,4).repeat(2),16),p=parseInt(R.slice(4,5).repeat(2),16),x.toColor(h,d,m,p);case 7:return{css:R,rgba:(parseInt(R.slice(1),16)<<8|255)>>>0};case 9:return{css:R,rgba:parseInt(R.slice(1),16)>>>0}}const O=R.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(O)return h=parseInt(O[1]),d=parseInt(O[2]),m=parseInt(O[3]),p=Math.round(255*(O[5]===void 0?1:parseFloat(O[5]))),x.toColor(h,d,m,p);if(!A||!M)throw new Error("css.toColor: Unsupported css format");if(A.fillStyle=M,A.fillStyle=R,typeof A.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(A.fillRect(0,0,1,1),[h,d,m,p]=A.getImageData(0,0,1,1).data,p!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:x.toRgba(h,d,m,p),css:R}}})(C||(o.css=C={})),(function(y){function A(M,R,O){const N=M/255,L=R/255,P=O/255;return .2126*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))}y.relativeLuminance=function(M){return A(M>>16&255,M>>8&255,255&M)},y.relativeLuminance2=A})(w||(o.rgb=w={})),(function(y){function A(R,O,N){const L=R>>24&255,P=R>>16&255,H=R>>8&255;let $=O>>24&255,q=O>>16&255,Z=O>>8&255,K=v(w.relativeLuminance2($,q,Z),w.relativeLuminance2(L,P,H));for(;K<N&&($>0||q>0||Z>0);)$-=Math.max(0,Math.ceil(.1*$)),q-=Math.max(0,Math.ceil(.1*q)),Z-=Math.max(0,Math.ceil(.1*Z)),K=v(w.relativeLuminance2($,q,Z),w.relativeLuminance2(L,P,H));return($<<24|q<<16|Z<<8|255)>>>0}function M(R,O,N){const L=R>>24&255,P=R>>16&255,H=R>>8&255;let $=O>>24&255,q=O>>16&255,Z=O>>8&255,K=v(w.relativeLuminance2($,q,Z),w.relativeLuminance2(L,P,H));for(;K<N&&($<255||q<255||Z<255);)$=Math.min(255,$+Math.ceil(.1*(255-$))),q=Math.min(255,q+Math.ceil(.1*(255-q))),Z=Math.min(255,Z+Math.ceil(.1*(255-Z))),K=v(w.relativeLuminance2($,q,Z),w.relativeLuminance2(L,P,H));return($<<24|q<<16|Z<<8|255)>>>0}y.blend=function(R,O){if(p=(255&O)/255,p===1)return O;const N=O>>24&255,L=O>>16&255,P=O>>8&255,H=R>>24&255,$=R>>16&255,q=R>>8&255;return h=H+Math.round((N-H)*p),d=$+Math.round((L-$)*p),m=q+Math.round((P-q)*p),x.toRgba(h,d,m)},y.ensureContrastRatio=function(R,O,N){const L=w.relativeLuminance(R>>8),P=w.relativeLuminance(O>>8);if(v(L,P)<N){if(P<L){const q=A(R,O,N),Z=v(L,w.relativeLuminance(q>>8));if(Z<N){const K=M(R,O,N);return Z>v(L,w.relativeLuminance(K>>8))?q:K}return q}const H=M(R,O,N),$=v(L,w.relativeLuminance(H>>8));if($<N){const q=A(R,O,N);return $>v(L,w.relativeLuminance(q>>8))?H:q}return H}},y.reduceLuminance=A,y.increaseLuminance=M,y.toChannels=function(R){return[R>>24&255,R>>16&255,R>>8&255,255&R]}})(_||(o.rgba=_={})),o.toPaddedHex=b,o.contrastRatio=v},8969:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CoreTerminal=void 0;const d=h(844),m=h(2585),p=h(4348),x=h(7866),S=h(744),C=h(7302),w=h(6975),_=h(8460),b=h(1753),v=h(1480),y=h(7994),A=h(9282),M=h(5435),R=h(5981),O=h(2660);let N=!1;class L extends d.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new _.EventEmitter),this._onScroll.event((H=>{var $;($=this._onScrollApi)==null||$.fire(H.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(H){for(const $ in H)this.optionsService.options[$]=H[$]}constructor(H){super(),this._windowsWrappingHeuristics=this.register(new d.MutableDisposable),this._onBinary=this.register(new _.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new _.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new _.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new _.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new _.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new _.EventEmitter),this._instantiationService=new p.InstantiationService,this.optionsService=this.register(new C.OptionsService(H)),this._instantiationService.setService(m.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(S.BufferService)),this._instantiationService.setService(m.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(x.LogService)),this._instantiationService.setService(m.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(w.CoreService)),this._instantiationService.setService(m.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(b.CoreMouseService)),this._instantiationService.setService(m.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(v.UnicodeService)),this._instantiationService.setService(m.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(y.CharsetService),this._instantiationService.setService(m.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(O.OscLinkService),this._instantiationService.setService(m.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new M.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,_.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,_.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,_.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,_.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(($=>{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(($=>{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 R.WriteBuffer((($,q)=>this._inputHandler.parse($,q)))),this.register((0,_.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(H,$){this._writeBuffer.write(H,$)}writeSync(H,$){this._logService.logLevel<=m.LogLevelEnum.WARN&&!N&&(this._logService.warn("writeSync is unreliable and will be removed soon."),N=!0),this._writeBuffer.writeSync(H,$)}input(H,$=!0){this.coreService.triggerDataEvent(H,$)}resize(H,$){isNaN(H)||isNaN($)||(H=Math.max(H,S.MINIMUM_COLS),$=Math.max($,S.MINIMUM_ROWS),this._bufferService.resize(H,$))}scroll(H,$=!1){this._bufferService.scroll(H,$)}scrollLines(H,$,q){this._bufferService.scrollLines(H,$,q)}scrollPages(H){this.scrollLines(H*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(H){const $=H-this._bufferService.buffer.ydisp;$!==0&&this.scrollLines($)}registerEscHandler(H,$){return this._inputHandler.registerEscHandler(H,$)}registerDcsHandler(H,$){return this._inputHandler.registerDcsHandler(H,$)}registerCsiHandler(H,$){return this._inputHandler.registerCsiHandler(H,$)}registerOscHandler(H,$){return this._inputHandler.registerOscHandler(H,$)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let H=!1;const $=this.optionsService.rawOptions.windowsPty;$&&$.buildNumber!==void 0&&$.buildNumber!==void 0?H=$.backend==="conpty"&&$.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(H=!0),H?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const H=[];H.push(this.onLineFeed(A.updateWindowsModeWrappedState.bind(null,this._bufferService))),H.push(this.registerCsiHandler({final:"H"},(()=>((0,A.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,d.toDisposable)((()=>{for(const $ of H)$.dispose()}))}}}o.CoreTerminal=L},8460:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.runAndSubscribe=o.forwardEvent=o.EventEmitter=void 0,o.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=h=>(this._listeners.push(h),{dispose:()=>{if(!this._disposed){for(let d=0;d<this._listeners.length;d++)if(this._listeners[d]===h)return void this._listeners.splice(d,1)}}})),this._event}fire(h,d){const m=[];for(let p=0;p<this._listeners.length;p++)m.push(this._listeners[p]);for(let p=0;p<m.length;p++)m[p].call(void 0,h,d)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},o.forwardEvent=function(h,d){return h((m=>d.fire(m)))},o.runAndSubscribe=function(h,d){return d(void 0),h((m=>d(m)))}},5435:function(f,o,h){var d=this&&this.__decorate||function(ee,I,T,z){var F,B=arguments.length,le=B<3?I:z===null?z=Object.getOwnPropertyDescriptor(I,T):z;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")le=Reflect.decorate(ee,I,T,z);else for(var xe=ee.length-1;xe>=0;xe--)(F=ee[xe])&&(le=(B<3?F(le):B>3?F(I,T,le):F(I,T))||le);return B>3&&le&&Object.defineProperty(I,T,le),le},m=this&&this.__param||function(ee,I){return function(T,z){I(T,z,ee)}};Object.defineProperty(o,"__esModule",{value:!0}),o.InputHandler=o.WindowsOptionsReportType=void 0;const p=h(2584),x=h(7116),S=h(2015),C=h(844),w=h(482),_=h(8437),b=h(8460),v=h(643),y=h(511),A=h(3734),M=h(2585),R=h(1480),O=h(6242),N=h(6351),L=h(5941),P={"(":0,")":1,"*":2,"+":3,"-":1,".":2},H=131072;function $(ee,I){if(ee>24)return I.setWinLines||!1;switch(ee){case 1:return!!I.restoreWin;case 2:return!!I.minimizeWin;case 3:return!!I.setWinPosition;case 4:return!!I.setWinSizePixels;case 5:return!!I.raiseWin;case 6:return!!I.lowerWin;case 7:return!!I.refreshWin;case 8:return!!I.setWinSizeChars;case 9:return!!I.maximizeWin;case 10:return!!I.fullscreenWin;case 11:return!!I.getWinState;case 13:return!!I.getWinPosition;case 14:return!!I.getWinSizePixels;case 15:return!!I.getScreenSizePixels;case 16:return!!I.getCellSizePixels;case 18:return!!I.getWinSizeChars;case 19:return!!I.getScreenSizeChars;case 20:return!!I.getIconTitle;case 21:return!!I.getWinTitle;case 22:return!!I.pushTitle;case 23:return!!I.popTitle;case 24:return!!I.setWinLines}return!1}var q;(function(ee){ee[ee.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",ee[ee.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(q||(o.WindowsOptionsReportType=q={}));let Z=0;class K extends C.Disposable{getAttrData(){return this._curAttrData}constructor(I,T,z,F,B,le,xe,fe,Y=new S.EscapeSequenceParser){super(),this._bufferService=I,this._charsetService=T,this._coreService=z,this._logService=F,this._optionsService=B,this._oscLinkService=le,this._coreMouseService=xe,this._unicodeService=fe,this._parser=Y,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new w.StringToUtf32,this._utf8Decoder=new w.Utf8ToUtf32,this._workCell=new y.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=_.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=_.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new b.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new b.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new b.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new b.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new b.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new b.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new b.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new b.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new b.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new b.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new b.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new b.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new b.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 G(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((U=>this._activeBuffer=U.activeBuffer))),this._parser.setCsiHandlerFallback(((U,me)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(U),params:me.toArray()})})),this._parser.setEscHandlerFallback((U=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(U)})})),this._parser.setExecuteHandlerFallback((U=>{this._logService.debug("Unknown EXECUTE code: ",{code:U})})),this._parser.setOscHandlerFallback(((U,me,oe)=>{this._logService.debug("Unknown OSC code: ",{identifier:U,action:me,data:oe})})),this._parser.setDcsHandlerFallback(((U,me,oe)=>{me==="HOOK"&&(oe=oe.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(U),action:me,payload:oe})})),this._parser.setPrintHandler(((U,me,oe)=>this.print(U,me,oe))),this._parser.registerCsiHandler({final:"@"},(U=>this.insertChars(U))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(U=>this.scrollLeft(U))),this._parser.registerCsiHandler({final:"A"},(U=>this.cursorUp(U))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(U=>this.scrollRight(U))),this._parser.registerCsiHandler({final:"B"},(U=>this.cursorDown(U))),this._parser.registerCsiHandler({final:"C"},(U=>this.cursorForward(U))),this._parser.registerCsiHandler({final:"D"},(U=>this.cursorBackward(U))),this._parser.registerCsiHandler({final:"E"},(U=>this.cursorNextLine(U))),this._parser.registerCsiHandler({final:"F"},(U=>this.cursorPrecedingLine(U))),this._parser.registerCsiHandler({final:"G"},(U=>this.cursorCharAbsolute(U))),this._parser.registerCsiHandler({final:"H"},(U=>this.cursorPosition(U))),this._parser.registerCsiHandler({final:"I"},(U=>this.cursorForwardTab(U))),this._parser.registerCsiHandler({final:"J"},(U=>this.eraseInDisplay(U,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(U=>this.eraseInDisplay(U,!0))),this._parser.registerCsiHandler({final:"K"},(U=>this.eraseInLine(U,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(U=>this.eraseInLine(U,!0))),this._parser.registerCsiHandler({final:"L"},(U=>this.insertLines(U))),this._parser.registerCsiHandler({final:"M"},(U=>this.deleteLines(U))),this._parser.registerCsiHandler({final:"P"},(U=>this.deleteChars(U))),this._parser.registerCsiHandler({final:"S"},(U=>this.scrollUp(U))),this._parser.registerCsiHandler({final:"T"},(U=>this.scrollDown(U))),this._parser.registerCsiHandler({final:"X"},(U=>this.eraseChars(U))),this._parser.registerCsiHandler({final:"Z"},(U=>this.cursorBackwardTab(U))),this._parser.registerCsiHandler({final:"`"},(U=>this.charPosAbsolute(U))),this._parser.registerCsiHandler({final:"a"},(U=>this.hPositionRelative(U))),this._parser.registerCsiHandler({final:"b"},(U=>this.repeatPrecedingCharacter(U))),this._parser.registerCsiHandler({final:"c"},(U=>this.sendDeviceAttributesPrimary(U))),this._parser.registerCsiHandler({prefix:">",final:"c"},(U=>this.sendDeviceAttributesSecondary(U))),this._parser.registerCsiHandler({final:"d"},(U=>this.linePosAbsolute(U))),this._parser.registerCsiHandler({final:"e"},(U=>this.vPositionRelative(U))),this._parser.registerCsiHandler({final:"f"},(U=>this.hVPosition(U))),this._parser.registerCsiHandler({final:"g"},(U=>this.tabClear(U))),this._parser.registerCsiHandler({final:"h"},(U=>this.setMode(U))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(U=>this.setModePrivate(U))),this._parser.registerCsiHandler({final:"l"},(U=>this.resetMode(U))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(U=>this.resetModePrivate(U))),this._parser.registerCsiHandler({final:"m"},(U=>this.charAttributes(U))),this._parser.registerCsiHandler({final:"n"},(U=>this.deviceStatus(U))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(U=>this.deviceStatusPrivate(U))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(U=>this.softReset(U))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(U=>this.setCursorStyle(U))),this._parser.registerCsiHandler({final:"r"},(U=>this.setScrollRegion(U))),this._parser.registerCsiHandler({final:"s"},(U=>this.saveCursor(U))),this._parser.registerCsiHandler({final:"t"},(U=>this.windowOptions(U))),this._parser.registerCsiHandler({final:"u"},(U=>this.restoreCursor(U))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(U=>this.insertColumns(U))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(U=>this.deleteColumns(U))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(U=>this.selectProtected(U))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(U=>this.requestMode(U,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(U=>this.requestMode(U,!1))),this._parser.setExecuteHandler(p.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(p.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(p.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(p.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(p.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(p.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(p.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(p.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(p.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(p.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(p.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(p.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new O.OscHandler((U=>(this.setTitle(U),this.setIconName(U),!0)))),this._parser.registerOscHandler(1,new O.OscHandler((U=>this.setIconName(U)))),this._parser.registerOscHandler(2,new O.OscHandler((U=>this.setTitle(U)))),this._parser.registerOscHandler(4,new O.OscHandler((U=>this.setOrReportIndexedColor(U)))),this._parser.registerOscHandler(8,new O.OscHandler((U=>this.setHyperlink(U)))),this._parser.registerOscHandler(10,new O.OscHandler((U=>this.setOrReportFgColor(U)))),this._parser.registerOscHandler(11,new O.OscHandler((U=>this.setOrReportBgColor(U)))),this._parser.registerOscHandler(12,new O.OscHandler((U=>this.setOrReportCursorColor(U)))),this._parser.registerOscHandler(104,new O.OscHandler((U=>this.restoreIndexedColor(U)))),this._parser.registerOscHandler(110,new O.OscHandler((U=>this.restoreFgColor(U)))),this._parser.registerOscHandler(111,new O.OscHandler((U=>this.restoreBgColor(U)))),this._parser.registerOscHandler(112,new O.OscHandler((U=>this.restoreCursorColor(U)))),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(const U in x.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:U},(()=>this.selectCharset("("+U))),this._parser.registerEscHandler({intermediates:")",final:U},(()=>this.selectCharset(")"+U))),this._parser.registerEscHandler({intermediates:"*",final:U},(()=>this.selectCharset("*"+U))),this._parser.registerEscHandler({intermediates:"+",final:U},(()=>this.selectCharset("+"+U))),this._parser.registerEscHandler({intermediates:"-",final:U},(()=>this.selectCharset("-"+U))),this._parser.registerEscHandler({intermediates:".",final:U},(()=>this.selectCharset("."+U))),this._parser.registerEscHandler({intermediates:"/",final:U},(()=>this.selectCharset("/"+U)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((U=>(this._logService.error("Parsing error: ",U),U))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new N.DcsHandler(((U,me)=>this.requestStatusString(U,me))))}_preserveStack(I,T,z,F){this._parseStack.paused=!0,this._parseStack.cursorStartX=I,this._parseStack.cursorStartY=T,this._parseStack.decodedLength=z,this._parseStack.position=F}_logSlowResolvingAsync(I){this._logService.logLevel<=M.LogLevelEnum.WARN&&Promise.race([I,new Promise(((T,z)=>setTimeout((()=>z("#SLOW_TIMEOUT")),5e3)))]).catch((T=>{if(T!=="#SLOW_TIMEOUT")throw T;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(I,T){let z,F=this._activeBuffer.x,B=this._activeBuffer.y,le=0;const xe=this._parseStack.paused;if(xe){if(z=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,T))return this._logSlowResolvingAsync(z),z;F=this._parseStack.cursorStartX,B=this._parseStack.cursorStartY,this._parseStack.paused=!1,I.length>H&&(le=this._parseStack.position+H)}if(this._logService.logLevel<=M.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof I=="string"?` "${I}"`:` "${Array.prototype.map.call(I,(U=>String.fromCharCode(U))).join("")}"`),typeof I=="string"?I.split("").map((U=>U.charCodeAt(0))):I),this._parseBuffer.length<I.length&&this._parseBuffer.length<H&&(this._parseBuffer=new Uint32Array(Math.min(I.length,H))),xe||this._dirtyRowTracker.clearRange(),I.length>H)for(let U=le;U<I.length;U+=H){const me=U+H<I.length?U+H:I.length,oe=typeof I=="string"?this._stringDecoder.decode(I.substring(U,me),this._parseBuffer):this._utf8Decoder.decode(I.subarray(U,me),this._parseBuffer);if(z=this._parser.parse(this._parseBuffer,oe))return this._preserveStack(F,B,oe,U),this._logSlowResolvingAsync(z),z}else if(!xe){const U=typeof I=="string"?this._stringDecoder.decode(I,this._parseBuffer):this._utf8Decoder.decode(I,this._parseBuffer);if(z=this._parser.parse(this._parseBuffer,U))return this._preserveStack(F,B,U,0),this._logSlowResolvingAsync(z),z}this._activeBuffer.x===F&&this._activeBuffer.y===B||this._onCursorMove.fire();const fe=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),Y=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);Y<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(Y,this._bufferService.rows-1),Math.min(fe,this._bufferService.rows-1))}print(I,T,z){let F,B;const le=this._charsetService.charset,xe=this._optionsService.rawOptions.screenReaderMode,fe=this._bufferService.cols,Y=this._coreService.decPrivateModes.wraparound,U=this._coreService.modes.insertMode,me=this._curAttrData;let oe=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&z-T>0&&oe.getWidth(this._activeBuffer.x-1)===2&&oe.setCellFromCodepoint(this._activeBuffer.x-1,0,1,me);let J=this._parser.precedingJoinState;for(let ae=T;ae<z;++ae){if(F=I[ae],F<127&&le){const ke=le[String.fromCharCode(F)];ke&&(F=ke.charCodeAt(0))}const Me=this._unicodeService.charProperties(F,J);B=R.UnicodeService.extractWidth(Me);const He=R.UnicodeService.extractShouldJoin(Me),Te=He?R.UnicodeService.extractWidth(J):0;if(J=Me,xe&&this._onA11yChar.fire((0,w.stringFromCodePoint)(F)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+B-Te>fe){if(Y){const ke=oe;let pe=this._activeBuffer.x-Te;for(this._activeBuffer.x=Te,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),oe=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Te>0&&oe instanceof _.BufferLine&&oe.copyCellsFrom(ke,pe,0,Te,!1);pe<fe;)ke.setCellFromCodepoint(pe++,0,1,me)}else if(this._activeBuffer.x=fe-1,B===2)continue}if(He&&this._activeBuffer.x){const ke=oe.getWidth(this._activeBuffer.x-1)?1:2;oe.addCodepointToCell(this._activeBuffer.x-ke,F,B);for(let pe=B-Te;--pe>=0;)oe.setCellFromCodepoint(this._activeBuffer.x++,0,0,me)}else if(U&&(oe.insertCells(this._activeBuffer.x,B-Te,this._activeBuffer.getNullCell(me)),oe.getWidth(fe-1)===2&&oe.setCellFromCodepoint(fe-1,v.NULL_CELL_CODE,v.NULL_CELL_WIDTH,me)),oe.setCellFromCodepoint(this._activeBuffer.x++,F,B,me),B>0)for(;--B;)oe.setCellFromCodepoint(this._activeBuffer.x++,0,0,me)}this._parser.precedingJoinState=J,this._activeBuffer.x<fe&&z-T>0&&oe.getWidth(this._activeBuffer.x)===0&&!oe.hasContent(this._activeBuffer.x)&&oe.setCellFromCodepoint(this._activeBuffer.x,0,1,me),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(I,T){return I.final!=="t"||I.prefix||I.intermediates?this._parser.registerCsiHandler(I,T):this._parser.registerCsiHandler(I,(z=>!$(z.params[0],this._optionsService.rawOptions.windowOptions)||T(z)))}registerDcsHandler(I,T){return this._parser.registerDcsHandler(I,new N.DcsHandler(T))}registerEscHandler(I,T){return this._parser.registerEscHandler(I,T)}registerOscHandler(I,T){return this._parser.registerOscHandler(I,new O.OscHandler(T))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var I;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&&((I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&I.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);T.hasWidth(this._activeBuffer.x)&&!T.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const I=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-I),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(I=this._bufferService.cols-1){this._activeBuffer.x=Math.min(I,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(I,T){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=I,this._activeBuffer.y=this._activeBuffer.scrollTop+T):(this._activeBuffer.x=I,this._activeBuffer.y=T),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(I,T){this._restrictCursor(),this._setCursor(this._activeBuffer.x+I,this._activeBuffer.y+T)}cursorUp(I){const T=this._activeBuffer.y-this._activeBuffer.scrollTop;return T>=0?this._moveCursor(0,-Math.min(T,I.params[0]||1)):this._moveCursor(0,-(I.params[0]||1)),!0}cursorDown(I){const T=this._activeBuffer.scrollBottom-this._activeBuffer.y;return T>=0?this._moveCursor(0,Math.min(T,I.params[0]||1)):this._moveCursor(0,I.params[0]||1),!0}cursorForward(I){return this._moveCursor(I.params[0]||1,0),!0}cursorBackward(I){return this._moveCursor(-(I.params[0]||1),0),!0}cursorNextLine(I){return this.cursorDown(I),this._activeBuffer.x=0,!0}cursorPrecedingLine(I){return this.cursorUp(I),this._activeBuffer.x=0,!0}cursorCharAbsolute(I){return this._setCursor((I.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(I){return this._setCursor(I.length>=2?(I.params[1]||1)-1:0,(I.params[0]||1)-1),!0}charPosAbsolute(I){return this._setCursor((I.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(I){return this._moveCursor(I.params[0]||1,0),!0}linePosAbsolute(I){return this._setCursor(this._activeBuffer.x,(I.params[0]||1)-1),!0}vPositionRelative(I){return this._moveCursor(0,I.params[0]||1),!0}hVPosition(I){return this.cursorPosition(I),!0}tabClear(I){const T=I.params[0];return T===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:T===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(I){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let T=I.params[0]||1;for(;T--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(I){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let T=I.params[0]||1;for(;T--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(I){const T=I.params[0];return T===1&&(this._curAttrData.bg|=536870912),T!==2&&T!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(I,T,z,F=!1,B=!1){const le=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);le.replaceCells(T,z,this._activeBuffer.getNullCell(this._eraseAttrData()),B),F&&(le.isWrapped=!1)}_resetBufferLine(I,T=!1){const z=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);z&&(z.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),T),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+I),z.isWrapped=!1)}eraseInDisplay(I,T=!1){let z;switch(this._restrictCursor(this._bufferService.cols),I.params[0]){case 0:for(z=this._activeBuffer.y,this._dirtyRowTracker.markDirty(z),this._eraseInBufferLine(z++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,T);z<this._bufferService.rows;z++)this._resetBufferLine(z,T);this._dirtyRowTracker.markDirty(z);break;case 1:for(z=this._activeBuffer.y,this._dirtyRowTracker.markDirty(z),this._eraseInBufferLine(z,0,this._activeBuffer.x+1,!0,T),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(z+1).isWrapped=!1);z--;)this._resetBufferLine(z,T);this._dirtyRowTracker.markDirty(0);break;case 2:for(z=this._bufferService.rows,this._dirtyRowTracker.markDirty(z-1);z--;)this._resetBufferLine(z,T);this._dirtyRowTracker.markDirty(0);break;case 3:const F=this._activeBuffer.lines.length-this._bufferService.rows;F>0&&(this._activeBuffer.lines.trimStart(F),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-F,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-F,0),this._onScroll.fire(0))}return!0}eraseInLine(I,T=!1){switch(this._restrictCursor(this._bufferService.cols),I.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,T);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,T);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,T)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(I){this._restrictCursor();let T=I.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const z=this._activeBuffer.ybase+this._activeBuffer.y,F=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-F+1;for(;T--;)this._activeBuffer.lines.splice(B-1,1),this._activeBuffer.lines.splice(z,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(I){this._restrictCursor();let T=I.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const z=this._activeBuffer.ybase+this._activeBuffer.y;let F;for(F=this._bufferService.rows-1-this._activeBuffer.scrollBottom,F=this._bufferService.rows-1+this._activeBuffer.ybase-F;T--;)this._activeBuffer.lines.splice(z,1),this._activeBuffer.lines.splice(F,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(I){this._restrictCursor();const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return T&&(T.insertCells(this._activeBuffer.x,I.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(I){this._restrictCursor();const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return T&&(T.deleteCells(this._activeBuffer.x,I.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(I){let T=I.params[0]||1;for(;T--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(I){let T=I.params[0]||1;for(;T--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(_.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(I){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=I.params[0]||1;for(let z=this._activeBuffer.scrollTop;z<=this._activeBuffer.scrollBottom;++z){const F=this._activeBuffer.lines.get(this._activeBuffer.ybase+z);F.deleteCells(0,T,this._activeBuffer.getNullCell(this._eraseAttrData())),F.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(I){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=I.params[0]||1;for(let z=this._activeBuffer.scrollTop;z<=this._activeBuffer.scrollBottom;++z){const F=this._activeBuffer.lines.get(this._activeBuffer.ybase+z);F.insertCells(0,T,this._activeBuffer.getNullCell(this._eraseAttrData())),F.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(I){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=I.params[0]||1;for(let z=this._activeBuffer.scrollTop;z<=this._activeBuffer.scrollBottom;++z){const F=this._activeBuffer.lines.get(this._activeBuffer.ybase+z);F.insertCells(this._activeBuffer.x,T,this._activeBuffer.getNullCell(this._eraseAttrData())),F.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(I){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=I.params[0]||1;for(let z=this._activeBuffer.scrollTop;z<=this._activeBuffer.scrollBottom;++z){const F=this._activeBuffer.lines.get(this._activeBuffer.ybase+z);F.deleteCells(this._activeBuffer.x,T,this._activeBuffer.getNullCell(this._eraseAttrData())),F.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(I){this._restrictCursor();const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return T&&(T.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(I.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(I){const T=this._parser.precedingJoinState;if(!T)return!0;const z=I.params[0]||1,F=R.UnicodeService.extractWidth(T),B=this._activeBuffer.x-F,le=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(B),xe=new Uint32Array(le.length*z);let fe=0;for(let U=0;U<le.length;){const me=le.codePointAt(U)||0;xe[fe++]=me,U+=me>65535?2:1}let Y=fe;for(let U=1;U<z;++U)xe.copyWithin(Y,0,fe),Y+=fe;return this.print(xe,0,Y),!0}sendDeviceAttributesPrimary(I){return I.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(p.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(p.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(I){return I.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(p.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(p.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(I.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(p.C0.ESC+"[>83;40003;0c")),!0}_is(I){return(this._optionsService.rawOptions.termName+"").indexOf(I)===0}setMode(I){for(let T=0;T<I.length;T++)switch(I.params[T]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(I){for(let T=0;T<I.length;T++)switch(I.params[T]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,x.DEFAULT_CHARSET),this._charsetService.setgCharset(1,x.DEFAULT_CHARSET),this._charsetService.setgCharset(2,x.DEFAULT_CHARSET),this._charsetService.setgCharset(3,x.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(I){for(let T=0;T<I.length;T++)switch(I.params[T]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(I){for(let T=0;T<I.length;T++)switch(I.params[T]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006: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(),I.params[T]===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(I,T){const z=this._coreService.decPrivateModes,{activeProtocol:F,activeEncoding:B}=this._coreMouseService,le=this._coreService,{buffers:xe,cols:fe}=this._bufferService,{active:Y,alt:U}=xe,me=this._optionsService.rawOptions,oe=He=>He?1:2,J=I.params[0];return ae=J,Me=T?J===2?4:J===4?oe(le.modes.insertMode):J===12?3:J===20?oe(me.convertEol):0:J===1?oe(z.applicationCursorKeys):J===3?me.windowOptions.setWinLines?fe===80?2:fe===132?1:0:0:J===6?oe(z.origin):J===7?oe(z.wraparound):J===8?3:J===9?oe(F==="X10"):J===12?oe(me.cursorBlink):J===25?oe(!le.isCursorHidden):J===45?oe(z.reverseWraparound):J===66?oe(z.applicationKeypad):J===67?4:J===1e3?oe(F==="VT200"):J===1002?oe(F==="DRAG"):J===1003?oe(F==="ANY"):J===1004?oe(z.sendFocus):J===1005?4:J===1006?oe(B==="SGR"):J===1015?4:J===1016?oe(B==="SGR_PIXELS"):J===1048?1:J===47||J===1047||J===1049?oe(Y===U):J===2004?oe(z.bracketedPasteMode):0,le.triggerDataEvent(`${p.C0.ESC}[${T?"":"?"}${ae};${Me}$y`),!0;var ae,Me}_updateAttrColor(I,T,z,F,B){return T===2?(I|=50331648,I&=-16777216,I|=A.AttributeData.fromColorRGB([z,F,B])):T===5&&(I&=-50331904,I|=33554432|255&z),I}_extractColor(I,T,z){const F=[0,0,-1,0,0,0];let B=0,le=0;do{if(F[le+B]=I.params[T+le],I.hasSubParams(T+le)){const xe=I.getSubParams(T+le);let fe=0;do F[1]===5&&(B=1),F[le+fe+1+B]=xe[fe];while(++fe<xe.length&&fe+le+1+B<F.length);break}if(F[1]===5&&le+B>=2||F[1]===2&&le+B>=5)break;F[1]&&(B=1)}while(++le+T<I.length&&le+B<F.length);for(let xe=2;xe<F.length;++xe)F[xe]===-1&&(F[xe]=0);switch(F[0]){case 38:z.fg=this._updateAttrColor(z.fg,F[1],F[3],F[4],F[5]);break;case 48:z.bg=this._updateAttrColor(z.bg,F[1],F[3],F[4],F[5]);break;case 58:z.extended=z.extended.clone(),z.extended.underlineColor=this._updateAttrColor(z.extended.underlineColor,F[1],F[3],F[4],F[5])}return le}_processUnderline(I,T){T.extended=T.extended.clone(),(!~I||I>5)&&(I=1),T.extended.underlineStyle=I,T.fg|=268435456,I===0&&(T.fg&=-268435457),T.updateExtended()}_processSGR0(I){I.fg=_.DEFAULT_ATTR_DATA.fg,I.bg=_.DEFAULT_ATTR_DATA.bg,I.extended=I.extended.clone(),I.extended.underlineStyle=0,I.extended.underlineColor&=-67108864,I.updateExtended()}charAttributes(I){if(I.length===1&&I.params[0]===0)return this._processSGR0(this._curAttrData),!0;const T=I.length;let z;const F=this._curAttrData;for(let B=0;B<T;B++)z=I.params[B],z>=30&&z<=37?(F.fg&=-50331904,F.fg|=16777216|z-30):z>=40&&z<=47?(F.bg&=-50331904,F.bg|=16777216|z-40):z>=90&&z<=97?(F.fg&=-50331904,F.fg|=16777224|z-90):z>=100&&z<=107?(F.bg&=-50331904,F.bg|=16777224|z-100):z===0?this._processSGR0(F):z===1?F.fg|=134217728:z===3?F.bg|=67108864:z===4?(F.fg|=268435456,this._processUnderline(I.hasSubParams(B)?I.getSubParams(B)[0]:1,F)):z===5?F.fg|=536870912:z===7?F.fg|=67108864:z===8?F.fg|=1073741824:z===9?F.fg|=2147483648:z===2?F.bg|=134217728:z===21?this._processUnderline(2,F):z===22?(F.fg&=-134217729,F.bg&=-134217729):z===23?F.bg&=-67108865:z===24?(F.fg&=-268435457,this._processUnderline(0,F)):z===25?F.fg&=-536870913:z===27?F.fg&=-67108865:z===28?F.fg&=-1073741825:z===29?F.fg&=2147483647:z===39?(F.fg&=-67108864,F.fg|=16777215&_.DEFAULT_ATTR_DATA.fg):z===49?(F.bg&=-67108864,F.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):z===38||z===48||z===58?B+=this._extractColor(I,B,F):z===53?F.bg|=1073741824:z===55?F.bg&=-1073741825:z===59?(F.extended=F.extended.clone(),F.extended.underlineColor=-1,F.updateExtended()):z===100?(F.fg&=-67108864,F.fg|=16777215&_.DEFAULT_ATTR_DATA.fg,F.bg&=-67108864,F.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",z);return!0}deviceStatus(I){switch(I.params[0]){case 5:this._coreService.triggerDataEvent(`${p.C0.ESC}[0n`);break;case 6:const T=this._activeBuffer.y+1,z=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${p.C0.ESC}[${T};${z}R`)}return!0}deviceStatusPrivate(I){if(I.params[0]===6){const T=this._activeBuffer.y+1,z=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${p.C0.ESC}[?${T};${z}R`)}return!0}softReset(I){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=_.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(I){const T=I.params[0]||1;switch(T){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"}const z=T%2==1;return this._optionsService.options.cursorBlink=z,!0}setScrollRegion(I){const T=I.params[0]||1;let z;return(I.length<2||(z=I.params[1])>this._bufferService.rows||z===0)&&(z=this._bufferService.rows),z>T&&(this._activeBuffer.scrollTop=T-1,this._activeBuffer.scrollBottom=z-1,this._setCursor(0,0)),!0}windowOptions(I){if(!$(I.params[0],this._optionsService.rawOptions.windowOptions))return!0;const T=I.length>1?I.params[1]:0;switch(I.params[0]){case 14:T!==2&&this._onRequestWindowsOptionsReport.fire(q.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(q.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${p.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:T!==0&&T!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),T!==0&&T!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:T!==0&&T!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),T!==0&&T!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(I){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(I){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(I){return this._windowTitle=I,this._onTitleChange.fire(I),!0}setIconName(I){return this._iconName=I,!0}setOrReportIndexedColor(I){const T=[],z=I.split(";");for(;z.length>1;){const F=z.shift(),B=z.shift();if(/^\d+$/.exec(F)){const le=parseInt(F);if(te(le))if(B==="?")T.push({type:0,index:le});else{const xe=(0,L.parseColor)(B);xe&&T.push({type:1,index:le,color:xe})}}}return T.length&&this._onColor.fire(T),!0}setHyperlink(I){const T=I.split(";");return!(T.length<2)&&(T[1]?this._createHyperlink(T[0],T[1]):!T[0]&&this._finishHyperlink())}_createHyperlink(I,T){this._getCurrentLinkId()&&this._finishHyperlink();const z=I.split(":");let F;const B=z.findIndex((le=>le.startsWith("id=")));return B!==-1&&(F=z[B].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:F,uri:T}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(I,T){const z=I.split(";");for(let F=0;F<z.length&&!(T>=this._specialColors.length);++F,++T)if(z[F]==="?")this._onColor.fire([{type:0,index:this._specialColors[T]}]);else{const B=(0,L.parseColor)(z[F]);B&&this._onColor.fire([{type:1,index:this._specialColors[T],color:B}])}return!0}setOrReportFgColor(I){return this._setOrReportSpecialColor(I,0)}setOrReportBgColor(I){return this._setOrReportSpecialColor(I,1)}setOrReportCursorColor(I){return this._setOrReportSpecialColor(I,2)}restoreIndexedColor(I){if(!I)return this._onColor.fire([{type:2}]),!0;const T=[],z=I.split(";");for(let F=0;F<z.length;++F)if(/^\d+$/.exec(z[F])){const B=parseInt(z[F]);te(B)&&T.push({type:2,index:B})}return T.length&&this._onColor.fire(T),!0}restoreFgColor(I){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(I){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(I){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,x.DEFAULT_CHARSET),!0}selectCharset(I){return I.length!==2?(this.selectDefaultCharset(),!0):(I[0]==="/"||this._charsetService.setgCharset(P[I[0]],x.CHARSETS[I[1]]||x.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){const I=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,I,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=_.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=_.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(I){return this._charsetService.setgLevel(I),!0}screenAlignmentPattern(){const I=new y.CellData;I.content=4194373,I.fg=this._curAttrData.fg,I.bg=this._curAttrData.bg,this._setCursor(0,0);for(let T=0;T<this._bufferService.rows;++T){const z=this._activeBuffer.ybase+this._activeBuffer.y+T,F=this._activeBuffer.lines.get(z);F&&(F.fill(I),F.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(I,T){const z=this._bufferService.buffer,F=this._optionsService.rawOptions;return(B=>(this._coreService.triggerDataEvent(`${p.C0.ESC}${B}${p.C0.ESC}\\`),!0))(I==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:I==='"p'?'P1$r61;1"p':I==="r"?`P1$r${z.scrollTop+1};${z.scrollBottom+1}r`:I==="m"?"P1$r0m":I===" q"?`P1$r${{block:2,underline:4,bar:6}[F.cursorStyle]-(F.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(I,T){this._dirtyRowTracker.markRangeDirty(I,T)}}o.InputHandler=K;let G=class{constructor(ee){this._bufferService=ee,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(ee){ee<this.start?this.start=ee:ee>this.end&&(this.end=ee)}markRangeDirty(ee,I){ee>I&&(Z=ee,ee=I,I=Z),ee<this.start&&(this.start=ee),I>this.end&&(this.end=I)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function te(ee){return 0<=ee&&ee<256}G=d([m(0,M.IBufferService)],G)},844:(f,o)=>{function h(d){for(const m of d)m.dispose();d.length=0}Object.defineProperty(o,"__esModule",{value:!0}),o.getDisposeArrayDisposable=o.disposeArray=o.toDisposable=o.MutableDisposable=o.Disposable=void 0,o.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const d of this._disposables)d.dispose();this._disposables.length=0}register(d){return this._disposables.push(d),d}unregister(d){const m=this._disposables.indexOf(d);m!==-1&&this._disposables.splice(m,1)}},o.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(d){var m;this._isDisposed||d===this._value||((m=this._value)==null||m.dispose(),this._value=d)}clear(){this.value=void 0}dispose(){var d;this._isDisposed=!0,(d=this._value)==null||d.dispose(),this._value=void 0}},o.toDisposable=function(d){return{dispose:d}},o.disposeArray=h,o.getDisposeArrayDisposable=function(d){return{dispose:()=>h(d)}}},1505:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.FourKeyMap=o.TwoKeyMap=void 0;class h{constructor(){this._data={}}set(m,p,x){this._data[m]||(this._data[m]={}),this._data[m][p]=x}get(m,p){return this._data[m]?this._data[m][p]:void 0}clear(){this._data={}}}o.TwoKeyMap=h,o.FourKeyMap=class{constructor(){this._data=new h}set(d,m,p,x,S){this._data.get(d,m)||this._data.set(d,m,new h),this._data.get(d,m).set(p,x,S)}get(d,m,p,x){var S;return(S=this._data.get(d,m))==null?void 0:S.get(p,x)}clear(){this._data.clear()}}},6114:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.isChromeOS=o.isLinux=o.isWindows=o.isIphone=o.isIpad=o.isMac=o.getSafariVersion=o.isSafari=o.isLegacyEdge=o.isFirefox=o.isNode=void 0,o.isNode=typeof process<"u"&&"title"in process;const h=o.isNode?"node":navigator.userAgent,d=o.isNode?"node":navigator.platform;o.isFirefox=h.includes("Firefox"),o.isLegacyEdge=h.includes("Edge"),o.isSafari=/^((?!chrome|android).)*safari/i.test(h),o.getSafariVersion=function(){if(!o.isSafari)return 0;const m=h.match(/Version\/(\d+)/);return m===null||m.length<2?0:parseInt(m[1])},o.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(d),o.isIpad=d==="iPad",o.isIphone=d==="iPhone",o.isWindows=["Windows","Win16","Win32","WinCE"].includes(d),o.isLinux=d.indexOf("Linux")>=0,o.isChromeOS=/\bCrOS\b/.test(h)},6106:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.SortedList=void 0;let h=0;o.SortedList=class{constructor(d){this._getKey=d,this._array=[]}clear(){this._array.length=0}insert(d){this._array.length!==0?(h=this._search(this._getKey(d)),this._array.splice(h,0,d)):this._array.push(d)}delete(d){if(this._array.length===0)return!1;const m=this._getKey(d);if(m===void 0||(h=this._search(m),h===-1)||this._getKey(this._array[h])!==m)return!1;do if(this._array[h]===d)return this._array.splice(h,1),!0;while(++h<this._array.length&&this._getKey(this._array[h])===m);return!1}*getKeyIterator(d){if(this._array.length!==0&&(h=this._search(d),!(h<0||h>=this._array.length)&&this._getKey(this._array[h])===d))do yield this._array[h];while(++h<this._array.length&&this._getKey(this._array[h])===d)}forEachByKey(d,m){if(this._array.length!==0&&(h=this._search(d),!(h<0||h>=this._array.length)&&this._getKey(this._array[h])===d))do m(this._array[h]);while(++h<this._array.length&&this._getKey(this._array[h])===d)}values(){return[...this._array].values()}_search(d){let m=0,p=this._array.length-1;for(;p>=m;){let x=m+p>>1;const S=this._getKey(this._array[x]);if(S>d)p=x-1;else{if(!(S<d)){for(;x>0&&this._getKey(this._array[x-1])===d;)x--;return x}m=x+1}}return m}}},7226:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DebouncedIdleTask=o.IdleTaskQueue=o.PriorityTaskQueue=void 0;const d=h(6114);class m{constructor(){this._tasks=[],this._i=0}enqueue(S){this._tasks.push(S),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(S){this._idleCallback=void 0;let C=0,w=0,_=S.timeRemaining(),b=0;for(;this._i<this._tasks.length;){if(C=Date.now(),this._tasks[this._i]()||this._i++,C=Math.max(1,Date.now()-C),w=Math.max(C,w),b=S.timeRemaining(),1.5*w>b)return _-C<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(_-C))}ms`),void this._start();_=b}this.clear()}}class p extends m{_requestCallback(S){return setTimeout((()=>S(this._createDeadline(16))))}_cancelCallback(S){clearTimeout(S)}_createDeadline(S){const C=Date.now()+S;return{timeRemaining:()=>Math.max(0,C-Date.now())}}}o.PriorityTaskQueue=p,o.IdleTaskQueue=!d.isNode&&"requestIdleCallback"in window?class extends m{_requestCallback(x){return requestIdleCallback(x)}_cancelCallback(x){cancelIdleCallback(x)}}:p,o.DebouncedIdleTask=class{constructor(){this._queue=new o.IdleTaskQueue}set(x){this._queue.clear(),this._queue.enqueue(x)}flush(){this._queue.flush()}}},9282:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.updateWindowsModeWrappedState=void 0;const d=h(643);o.updateWindowsModeWrappedState=function(m){const p=m.buffer.lines.get(m.buffer.ybase+m.buffer.y-1),x=p==null?void 0:p.get(m.cols-1),S=m.buffer.lines.get(m.buffer.ybase+m.buffer.y);S&&x&&(S.isWrapped=x[d.CHAR_DATA_CODE_INDEX]!==d.NULL_CELL_CODE&&x[d.CHAR_DATA_CODE_INDEX]!==d.WHITESPACE_CELL_CODE)}},3734:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ExtendedAttrs=o.AttributeData=void 0;class h{constructor(){this.fg=0,this.bg=0,this.extended=new d}static toColorRGB(p){return[p>>>16&255,p>>>8&255,255&p]}static fromColorRGB(p){return(255&p[0])<<16|(255&p[1])<<8|255&p[2]}clone(){const p=new h;return p.fg=this.fg,p.bg=this.bg,p.extended=this.extended.clone(),p}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}}o.AttributeData=h;class d{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(p){this._ext=p}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(p){this._ext&=-469762049,this._ext|=p<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(p){this._ext&=-67108864,this._ext|=67108863&p}get urlId(){return this._urlId}set urlId(p){this._urlId=p}get underlineVariantOffset(){const p=(3758096384&this._ext)>>29;return p<0?4294967288^p:p}set underlineVariantOffset(p){this._ext&=536870911,this._ext|=p<<29&3758096384}constructor(p=0,x=0){this._ext=0,this._urlId=0,this._ext=p,this._urlId=x}clone(){return new d(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}o.ExtendedAttrs=d},9092:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Buffer=o.MAX_BUFFER_SIZE=void 0;const d=h(6349),m=h(7226),p=h(3734),x=h(8437),S=h(4634),C=h(511),w=h(643),_=h(4863),b=h(7116);o.MAX_BUFFER_SIZE=4294967295,o.Buffer=class{constructor(v,y,A){this._hasScrollback=v,this._optionsService=y,this._bufferService=A,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=x.DEFAULT_ATTR_DATA.clone(),this.savedCharset=b.DEFAULT_CHARSET,this.markers=[],this._nullCell=C.CellData.fromCharData([0,w.NULL_CELL_CHAR,w.NULL_CELL_WIDTH,w.NULL_CELL_CODE]),this._whitespaceCell=C.CellData.fromCharData([0,w.WHITESPACE_CELL_CHAR,w.WHITESPACE_CELL_WIDTH,w.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new m.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new d.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(v){return v?(this._nullCell.fg=v.fg,this._nullCell.bg=v.bg,this._nullCell.extended=v.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new p.ExtendedAttrs),this._nullCell}getWhitespaceCell(v){return v?(this._whitespaceCell.fg=v.fg,this._whitespaceCell.bg=v.bg,this._whitespaceCell.extended=v.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new p.ExtendedAttrs),this._whitespaceCell}getBlankLine(v,y){return new x.BufferLine(this._bufferService.cols,this.getNullCell(v),y)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const v=this.ybase+this.y-this.ydisp;return v>=0&&v<this._rows}_getCorrectBufferLength(v){if(!this._hasScrollback)return v;const y=v+this._optionsService.rawOptions.scrollback;return y>o.MAX_BUFFER_SIZE?o.MAX_BUFFER_SIZE:y}fillViewportRows(v){if(this.lines.length===0){v===void 0&&(v=x.DEFAULT_ATTR_DATA);let y=this._rows;for(;y--;)this.lines.push(this.getBlankLine(v))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new d.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(v,y){const A=this.getNullCell(x.DEFAULT_ATTR_DATA);let M=0;const R=this._getCorrectBufferLength(y);if(R>this.lines.maxLength&&(this.lines.maxLength=R),this.lines.length>0){if(this._cols<v)for(let N=0;N<this.lines.length;N++)M+=+this.lines.get(N).resize(v,A);let O=0;if(this._rows<y)for(let N=this._rows;N<y;N++)this.lines.length<y+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new x.BufferLine(v,A)):this.ybase>0&&this.lines.length<=this.ybase+this.y+O+1?(this.ybase--,O++,this.ydisp>0&&this.ydisp--):this.lines.push(new x.BufferLine(v,A)));else for(let N=this._rows;N>y;N--)this.lines.length>y+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(R<this.lines.maxLength){const N=this.lines.length-R;N>0&&(this.lines.trimStart(N),this.ybase=Math.max(this.ybase-N,0),this.ydisp=Math.max(this.ydisp-N,0),this.savedY=Math.max(this.savedY-N,0)),this.lines.maxLength=R}this.x=Math.min(this.x,v-1),this.y=Math.min(this.y,y-1),O&&(this.y+=O),this.savedX=Math.min(this.savedX,v-1),this.scrollTop=0}if(this.scrollBottom=y-1,this._isReflowEnabled&&(this._reflow(v,y),this._cols>v))for(let O=0;O<this.lines.length;O++)M+=+this.lines.get(O).resize(v,A);this._cols=v,this._rows=y,this._memoryCleanupQueue.clear(),M>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let v=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,v=!1);let y=0;for(;this._memoryCleanupPosition<this.lines.length;)if(y+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),y>100)return!0;return v}get _isReflowEnabled(){const v=this._optionsService.rawOptions.windowsPty;return v&&v.buildNumber?this._hasScrollback&&v.backend==="conpty"&&v.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(v,y){this._cols!==v&&(v>this._cols?this._reflowLarger(v,y):this._reflowSmaller(v,y))}_reflowLarger(v,y){const A=(0,S.reflowLargerGetLinesToRemove)(this.lines,this._cols,v,this.ybase+this.y,this.getNullCell(x.DEFAULT_ATTR_DATA));if(A.length>0){const M=(0,S.reflowLargerCreateNewLayout)(this.lines,A);(0,S.reflowLargerApplyNewLayout)(this.lines,M.layout),this._reflowLargerAdjustViewport(v,y,M.countRemoved)}}_reflowLargerAdjustViewport(v,y,A){const M=this.getNullCell(x.DEFAULT_ATTR_DATA);let R=A;for(;R-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<y&&this.lines.push(new x.BufferLine(v,M))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-A,0)}_reflowSmaller(v,y){const A=this.getNullCell(x.DEFAULT_ATTR_DATA),M=[];let R=0;for(let O=this.lines.length-1;O>=0;O--){let N=this.lines.get(O);if(!N||!N.isWrapped&&N.getTrimmedLength()<=v)continue;const L=[N];for(;N.isWrapped&&O>0;)N=this.lines.get(--O),L.unshift(N);const P=this.ybase+this.y;if(P>=O&&P<O+L.length)continue;const H=L[L.length-1].getTrimmedLength(),$=(0,S.reflowSmallerGetNewLineLengths)(L,this._cols,v),q=$.length-L.length;let Z;Z=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+q):Math.max(0,this.lines.length-this.lines.maxLength+q);const K=[];for(let z=0;z<q;z++){const F=this.getBlankLine(x.DEFAULT_ATTR_DATA,!0);K.push(F)}K.length>0&&(M.push({start:O+L.length+R,newLines:K}),R+=K.length),L.push(...K);let G=$.length-1,te=$[G];te===0&&(G--,te=$[G]);let ee=L.length-q-1,I=H;for(;ee>=0;){const z=Math.min(I,te);if(L[G]===void 0)break;if(L[G].copyCellsFrom(L[ee],I-z,te-z,z,!0),te-=z,te===0&&(G--,te=$[G]),I-=z,I===0){ee--;const F=Math.max(ee,0);I=(0,S.getWrappedLineTrimmedLength)(L,F,this._cols)}}for(let z=0;z<L.length;z++)$[z]<v&&L[z].setCell($[z],A);let T=q-Z;for(;T-- >0;)this.ybase===0?this.y<y-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+R)-y&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+q,this.ybase+y-1)}if(M.length>0){const O=[],N=[];for(let G=0;G<this.lines.length;G++)N.push(this.lines.get(G));const L=this.lines.length;let P=L-1,H=0,$=M[H];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+R);let q=0;for(let G=Math.min(this.lines.maxLength-1,L+R-1);G>=0;G--)if($&&$.start>P+q){for(let te=$.newLines.length-1;te>=0;te--)this.lines.set(G--,$.newLines[te]);G++,O.push({index:P+1,amount:$.newLines.length}),q+=$.newLines.length,$=M[++H]}else this.lines.set(G,N[P--]);let Z=0;for(let G=O.length-1;G>=0;G--)O[G].index+=Z,this.lines.onInsertEmitter.fire(O[G]),Z+=O[G].amount;const K=Math.max(0,L+R-this.lines.maxLength);K>0&&this.lines.onTrimEmitter.fire(K)}}translateBufferLineToString(v,y,A=0,M){const R=this.lines.get(v);return R?R.translateToString(y,A,M):""}getWrappedRangeForLine(v){let y=v,A=v;for(;y>0&&this.lines.get(y).isWrapped;)y--;for(;A+1<this.lines.length&&this.lines.get(A+1).isWrapped;)A++;return{first:y,last:A}}setupTabStops(v){for(v!=null?this.tabs[v]||(v=this.prevStop(v)):(this.tabs={},v=0);v<this._cols;v+=this._optionsService.rawOptions.tabStopWidth)this.tabs[v]=!0}prevStop(v){for(v==null&&(v=this.x);!this.tabs[--v]&&v>0;);return v>=this._cols?this._cols-1:v<0?0:v}nextStop(v){for(v==null&&(v=this.x);!this.tabs[++v]&&v<this._cols;);return v>=this._cols?this._cols-1:v<0?0:v}clearMarkers(v){this._isClearing=!0;for(let y=0;y<this.markers.length;y++)this.markers[y].line===v&&(this.markers[y].dispose(),this.markers.splice(y--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let v=0;v<this.markers.length;v++)this.markers[v].dispose(),this.markers.splice(v--,1);this._isClearing=!1}addMarker(v){const y=new _.Marker(v);return this.markers.push(y),y.register(this.lines.onTrim((A=>{y.line-=A,y.line<0&&y.dispose()}))),y.register(this.lines.onInsert((A=>{y.line>=A.index&&(y.line+=A.amount)}))),y.register(this.lines.onDelete((A=>{y.line>=A.index&&y.line<A.index+A.amount&&y.dispose(),y.line>A.index&&(y.line-=A.amount)}))),y.register(y.onDispose((()=>this._removeMarker(y)))),y}_removeMarker(v){this._isClearing||this.markers.splice(this.markers.indexOf(v),1)}}},8437:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLine=o.DEFAULT_ATTR_DATA=void 0;const d=h(3734),m=h(511),p=h(643),x=h(482);o.DEFAULT_ATTR_DATA=Object.freeze(new d.AttributeData);let S=0;class C{constructor(_,b,v=!1){this.isWrapped=v,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*_);const y=b||m.CellData.fromCharData([0,p.NULL_CELL_CHAR,p.NULL_CELL_WIDTH,p.NULL_CELL_CODE]);for(let A=0;A<_;++A)this.setCell(A,y);this.length=_}get(_){const b=this._data[3*_+0],v=2097151&b;return[this._data[3*_+1],2097152&b?this._combined[_]:v?(0,x.stringFromCodePoint)(v):"",b>>22,2097152&b?this._combined[_].charCodeAt(this._combined[_].length-1):v]}set(_,b){this._data[3*_+1]=b[p.CHAR_DATA_ATTR_INDEX],b[p.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[_]=b[1],this._data[3*_+0]=2097152|_|b[p.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*_+0]=b[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|b[p.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(_){return this._data[3*_+0]>>22}hasWidth(_){return 12582912&this._data[3*_+0]}getFg(_){return this._data[3*_+1]}getBg(_){return this._data[3*_+2]}hasContent(_){return 4194303&this._data[3*_+0]}getCodePoint(_){const b=this._data[3*_+0];return 2097152&b?this._combined[_].charCodeAt(this._combined[_].length-1):2097151&b}isCombined(_){return 2097152&this._data[3*_+0]}getString(_){const b=this._data[3*_+0];return 2097152&b?this._combined[_]:2097151&b?(0,x.stringFromCodePoint)(2097151&b):""}isProtected(_){return 536870912&this._data[3*_+2]}loadCell(_,b){return S=3*_,b.content=this._data[S+0],b.fg=this._data[S+1],b.bg=this._data[S+2],2097152&b.content&&(b.combinedData=this._combined[_]),268435456&b.bg&&(b.extended=this._extendedAttrs[_]),b}setCell(_,b){2097152&b.content&&(this._combined[_]=b.combinedData),268435456&b.bg&&(this._extendedAttrs[_]=b.extended),this._data[3*_+0]=b.content,this._data[3*_+1]=b.fg,this._data[3*_+2]=b.bg}setCellFromCodepoint(_,b,v,y){268435456&y.bg&&(this._extendedAttrs[_]=y.extended),this._data[3*_+0]=b|v<<22,this._data[3*_+1]=y.fg,this._data[3*_+2]=y.bg}addCodepointToCell(_,b,v){let y=this._data[3*_+0];2097152&y?this._combined[_]+=(0,x.stringFromCodePoint)(b):2097151&y?(this._combined[_]=(0,x.stringFromCodePoint)(2097151&y)+(0,x.stringFromCodePoint)(b),y&=-2097152,y|=2097152):y=b|4194304,v&&(y&=-12582913,y|=v<<22),this._data[3*_+0]=y}insertCells(_,b,v){if((_%=this.length)&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,v),b<this.length-_){const y=new m.CellData;for(let A=this.length-_-b-1;A>=0;--A)this.setCell(_+b+A,this.loadCell(_+A,y));for(let A=0;A<b;++A)this.setCell(_+A,v)}else for(let y=_;y<this.length;++y)this.setCell(y,v);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,v)}deleteCells(_,b,v){if(_%=this.length,b<this.length-_){const y=new m.CellData;for(let A=0;A<this.length-_-b;++A)this.setCell(_+A,this.loadCell(_+b+A,y));for(let A=this.length-b;A<this.length;++A)this.setCell(A,v)}else for(let y=_;y<this.length;++y)this.setCell(y,v);_&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,v),this.getWidth(_)!==0||this.hasContent(_)||this.setCellFromCodepoint(_,0,1,v)}replaceCells(_,b,v,y=!1){if(y)for(_&&this.getWidth(_-1)===2&&!this.isProtected(_-1)&&this.setCellFromCodepoint(_-1,0,1,v),b<this.length&&this.getWidth(b-1)===2&&!this.isProtected(b)&&this.setCellFromCodepoint(b,0,1,v);_<b&&_<this.length;)this.isProtected(_)||this.setCell(_,v),_++;else for(_&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,v),b<this.length&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b,0,1,v);_<b&&_<this.length;)this.setCell(_++,v)}resize(_,b){if(_===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const v=3*_;if(_>this.length){if(this._data.buffer.byteLength>=4*v)this._data=new Uint32Array(this._data.buffer,0,v);else{const y=new Uint32Array(v);y.set(this._data),this._data=y}for(let y=this.length;y<_;++y)this.setCell(y,b)}else{this._data=this._data.subarray(0,v);const y=Object.keys(this._combined);for(let M=0;M<y.length;M++){const R=parseInt(y[M],10);R>=_&&delete this._combined[R]}const A=Object.keys(this._extendedAttrs);for(let M=0;M<A.length;M++){const R=parseInt(A[M],10);R>=_&&delete this._extendedAttrs[R]}}return this.length=_,4*v*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const _=new Uint32Array(this._data.length);return _.set(this._data),this._data=_,1}return 0}fill(_,b=!1){if(b)for(let v=0;v<this.length;++v)this.isProtected(v)||this.setCell(v,_);else{this._combined={},this._extendedAttrs={};for(let v=0;v<this.length;++v)this.setCell(v,_)}}copyFrom(_){this.length!==_.length?this._data=new Uint32Array(_._data):this._data.set(_._data),this.length=_.length,this._combined={};for(const b in _._combined)this._combined[b]=_._combined[b];this._extendedAttrs={};for(const b in _._extendedAttrs)this._extendedAttrs[b]=_._extendedAttrs[b];this.isWrapped=_.isWrapped}clone(){const _=new C(0);_._data=new Uint32Array(this._data),_.length=this.length;for(const b in this._combined)_._combined[b]=this._combined[b];for(const b in this._extendedAttrs)_._extendedAttrs[b]=this._extendedAttrs[b];return _.isWrapped=this.isWrapped,_}getTrimmedLength(){for(let _=this.length-1;_>=0;--_)if(4194303&this._data[3*_+0])return _+(this._data[3*_+0]>>22);return 0}getNoBgTrimmedLength(){for(let _=this.length-1;_>=0;--_)if(4194303&this._data[3*_+0]||50331648&this._data[3*_+2])return _+(this._data[3*_+0]>>22);return 0}copyCellsFrom(_,b,v,y,A){const M=_._data;if(A)for(let O=y-1;O>=0;O--){for(let N=0;N<3;N++)this._data[3*(v+O)+N]=M[3*(b+O)+N];268435456&M[3*(b+O)+2]&&(this._extendedAttrs[v+O]=_._extendedAttrs[b+O])}else for(let O=0;O<y;O++){for(let N=0;N<3;N++)this._data[3*(v+O)+N]=M[3*(b+O)+N];268435456&M[3*(b+O)+2]&&(this._extendedAttrs[v+O]=_._extendedAttrs[b+O])}const R=Object.keys(_._combined);for(let O=0;O<R.length;O++){const N=parseInt(R[O],10);N>=b&&(this._combined[N-b+v]=_._combined[N])}}translateToString(_,b,v,y){b=b??0,v=v??this.length,_&&(v=Math.min(v,this.getTrimmedLength())),y&&(y.length=0);let A="";for(;b<v;){const M=this._data[3*b+0],R=2097151&M,O=2097152&M?this._combined[b]:R?(0,x.stringFromCodePoint)(R):p.WHITESPACE_CELL_CHAR;if(A+=O,y)for(let N=0;N<O.length;++N)y.push(b);b+=M>>22||1}return y&&y.push(b),A}}o.BufferLine=C},4841:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.getRangeLength=void 0,o.getRangeLength=function(h,d){if(h.start.y>h.end.y)throw new Error(`Buffer range end (${h.end.x}, ${h.end.y}) cannot be before start (${h.start.x}, ${h.start.y})`);return d*(h.end.y-h.start.y)+(h.end.x-h.start.x+1)}},4634:(f,o)=>{function h(d,m,p){if(m===d.length-1)return d[m].getTrimmedLength();const x=!d[m].hasContent(p-1)&&d[m].getWidth(p-1)===1,S=d[m+1].getWidth(0)===2;return x&&S?p-1:p}Object.defineProperty(o,"__esModule",{value:!0}),o.getWrappedLineTrimmedLength=o.reflowSmallerGetNewLineLengths=o.reflowLargerApplyNewLayout=o.reflowLargerCreateNewLayout=o.reflowLargerGetLinesToRemove=void 0,o.reflowLargerGetLinesToRemove=function(d,m,p,x,S){const C=[];for(let w=0;w<d.length-1;w++){let _=w,b=d.get(++_);if(!b.isWrapped)continue;const v=[d.get(w)];for(;_<d.length&&b.isWrapped;)v.push(b),b=d.get(++_);if(x>=w&&x<_){w+=v.length-1;continue}let y=0,A=h(v,y,m),M=1,R=0;for(;M<v.length;){const N=h(v,M,m),L=N-R,P=p-A,H=Math.min(L,P);v[y].copyCellsFrom(v[M],R,A,H,!1),A+=H,A===p&&(y++,A=0),R+=H,R===N&&(M++,R=0),A===0&&y!==0&&v[y-1].getWidth(p-1)===2&&(v[y].copyCellsFrom(v[y-1],p-1,A++,1,!1),v[y-1].setCell(p-1,S))}v[y].replaceCells(A,p,S);let O=0;for(let N=v.length-1;N>0&&(N>y||v[N].getTrimmedLength()===0);N--)O++;O>0&&(C.push(w+v.length-O),C.push(O)),w+=v.length-1}return C},o.reflowLargerCreateNewLayout=function(d,m){const p=[];let x=0,S=m[x],C=0;for(let w=0;w<d.length;w++)if(S===w){const _=m[++x];d.onDeleteEmitter.fire({index:w-C,amount:_}),w+=_-1,C+=_,S=m[++x]}else p.push(w);return{layout:p,countRemoved:C}},o.reflowLargerApplyNewLayout=function(d,m){const p=[];for(let x=0;x<m.length;x++)p.push(d.get(m[x]));for(let x=0;x<p.length;x++)d.set(x,p[x]);d.length=m.length},o.reflowSmallerGetNewLineLengths=function(d,m,p){const x=[],S=d.map(((b,v)=>h(d,v,m))).reduce(((b,v)=>b+v));let C=0,w=0,_=0;for(;_<S;){if(S-_<p){x.push(S-_);break}C+=p;const b=h(d,w,m);C>b&&(C-=b,w++);const v=d[w].getWidth(C-1)===2;v&&C--;const y=v?p-1:p;x.push(y),_+=y}return x},o.getWrappedLineTrimmedLength=h},5295:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferSet=void 0;const d=h(8460),m=h(844),p=h(9092);class x extends m.Disposable{constructor(C,w){super(),this._optionsService=C,this._bufferService=w,this._onBufferActivate=this.register(new d.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 p.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new p.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(C){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(C),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(C,w){this._normal.resize(C,w),this._alt.resize(C,w),this.setupTabStops(C)}setupTabStops(C){this._normal.setupTabStops(C),this._alt.setupTabStops(C)}}o.BufferSet=x},511:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CellData=void 0;const d=h(482),m=h(643),p=h(3734);class x extends p.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new p.ExtendedAttrs,this.combinedData=""}static fromCharData(C){const w=new x;return w.setFromCharData(C),w}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,d.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(C){this.fg=C[m.CHAR_DATA_ATTR_INDEX],this.bg=0;let w=!1;if(C[m.CHAR_DATA_CHAR_INDEX].length>2)w=!0;else if(C[m.CHAR_DATA_CHAR_INDEX].length===2){const _=C[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=_&&_<=56319){const b=C[m.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=b&&b<=57343?this.content=1024*(_-55296)+b-56320+65536|C[m.CHAR_DATA_WIDTH_INDEX]<<22:w=!0}else w=!0}else this.content=C[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|C[m.CHAR_DATA_WIDTH_INDEX]<<22;w&&(this.combinedData=C[m.CHAR_DATA_CHAR_INDEX],this.content=2097152|C[m.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}o.CellData=x},643:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WHITESPACE_CELL_CODE=o.WHITESPACE_CELL_WIDTH=o.WHITESPACE_CELL_CHAR=o.NULL_CELL_CODE=o.NULL_CELL_WIDTH=o.NULL_CELL_CHAR=o.CHAR_DATA_CODE_INDEX=o.CHAR_DATA_WIDTH_INDEX=o.CHAR_DATA_CHAR_INDEX=o.CHAR_DATA_ATTR_INDEX=o.DEFAULT_EXT=o.DEFAULT_ATTR=o.DEFAULT_COLOR=void 0,o.DEFAULT_COLOR=0,o.DEFAULT_ATTR=256|o.DEFAULT_COLOR<<9,o.DEFAULT_EXT=0,o.CHAR_DATA_ATTR_INDEX=0,o.CHAR_DATA_CHAR_INDEX=1,o.CHAR_DATA_WIDTH_INDEX=2,o.CHAR_DATA_CODE_INDEX=3,o.NULL_CELL_CHAR="",o.NULL_CELL_WIDTH=1,o.NULL_CELL_CODE=0,o.WHITESPACE_CELL_CHAR=" ",o.WHITESPACE_CELL_WIDTH=1,o.WHITESPACE_CELL_CODE=32},4863:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Marker=void 0;const d=h(8460),m=h(844);class p{get id(){return this._id}constructor(S){this.line=S,this.isDisposed=!1,this._disposables=[],this._id=p._nextId++,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,m.disposeArray)(this._disposables),this._disposables.length=0)}register(S){return this._disposables.push(S),S}}o.Marker=p,p._nextId=1},7116:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DEFAULT_CHARSET=o.CHARSETS=void 0,o.CHARSETS={},o.DEFAULT_CHARSET=o.CHARSETS.B,o.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},o.CHARSETS.A={"#":"£"},o.CHARSETS.B=void 0,o.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},o.CHARSETS.C=o.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},o.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},o.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},o.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},o.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},o.CHARSETS.E=o.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},o.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},o.CHARSETS.H=o.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},o.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(f,o)=>{var h,d,m;Object.defineProperty(o,"__esModule",{value:!0}),o.C1_ESCAPED=o.C1=o.C0=void 0,(function(p){p.NUL="\0",p.SOH="",p.STX="",p.ETX="",p.EOT="",p.ENQ="",p.ACK="",p.BEL="\x07",p.BS="\b",p.HT=" ",p.LF=`
91
91
  `,p.VT="\v",p.FF="\f",p.CR="\r",p.SO="",p.SI="",p.DLE="",p.DC1="",p.DC2="",p.DC3="",p.DC4="",p.NAK="",p.SYN="",p.ETB="",p.CAN="",p.EM="",p.SUB="",p.ESC="\x1B",p.FS="",p.GS="",p.RS="",p.US="",p.SP=" ",p.DEL=""})(h||(o.C0=h={})),(function(p){p.PAD="€",p.HOP="",p.BPH="‚",p.NBH="ƒ",p.IND="„",p.NEL="…",p.SSA="†",p.ESA="‡",p.HTS="ˆ",p.HTJ="‰",p.VTS="Š",p.PLD="‹",p.PLU="Œ",p.RI="",p.SS2="Ž",p.SS3="",p.DCS="",p.PU1="‘",p.PU2="’",p.STS="“",p.CCH="”",p.MW="•",p.SPA="–",p.EPA="—",p.SOS="˜",p.SGCI="™",p.SCI="š",p.CSI="›",p.ST="œ",p.OSC="",p.PM="ž",p.APC="Ÿ"})(d||(o.C1=d={})),(function(p){p.ST=`${h.ESC}\\`})(m||(o.C1_ESCAPED=m={}))},7399:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.evaluateKeyboardEvent=void 0;const d=h(2584),m={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:["'",'"']};o.evaluateKeyboardEvent=function(p,x,S,C){const w={type:0,cancel:!1,key:void 0},_=(p.shiftKey?1:0)|(p.altKey?2:0)|(p.ctrlKey?4:0)|(p.metaKey?8:0);switch(p.keyCode){case 0:p.key==="UIKeyInputUpArrow"?w.key=x?d.C0.ESC+"OA":d.C0.ESC+"[A":p.key==="UIKeyInputLeftArrow"?w.key=x?d.C0.ESC+"OD":d.C0.ESC+"[D":p.key==="UIKeyInputRightArrow"?w.key=x?d.C0.ESC+"OC":d.C0.ESC+"[C":p.key==="UIKeyInputDownArrow"&&(w.key=x?d.C0.ESC+"OB":d.C0.ESC+"[B");break;case 8:w.key=p.ctrlKey?"\b":d.C0.DEL,p.altKey&&(w.key=d.C0.ESC+w.key);break;case 9:if(p.shiftKey){w.key=d.C0.ESC+"[Z";break}w.key=d.C0.HT,w.cancel=!0;break;case 13:w.key=p.altKey?d.C0.ESC+d.C0.CR:d.C0.CR,w.cancel=!0;break;case 27:w.key=d.C0.ESC,p.altKey&&(w.key=d.C0.ESC+d.C0.ESC),w.cancel=!0;break;case 37:if(p.metaKey)break;_?(w.key=d.C0.ESC+"[1;"+(_+1)+"D",w.key===d.C0.ESC+"[1;3D"&&(w.key=d.C0.ESC+(S?"b":"[1;5D"))):w.key=x?d.C0.ESC+"OD":d.C0.ESC+"[D";break;case 39:if(p.metaKey)break;_?(w.key=d.C0.ESC+"[1;"+(_+1)+"C",w.key===d.C0.ESC+"[1;3C"&&(w.key=d.C0.ESC+(S?"f":"[1;5C"))):w.key=x?d.C0.ESC+"OC":d.C0.ESC+"[C";break;case 38:if(p.metaKey)break;_?(w.key=d.C0.ESC+"[1;"+(_+1)+"A",S||w.key!==d.C0.ESC+"[1;3A"||(w.key=d.C0.ESC+"[1;5A")):w.key=x?d.C0.ESC+"OA":d.C0.ESC+"[A";break;case 40:if(p.metaKey)break;_?(w.key=d.C0.ESC+"[1;"+(_+1)+"B",S||w.key!==d.C0.ESC+"[1;3B"||(w.key=d.C0.ESC+"[1;5B")):w.key=x?d.C0.ESC+"OB":d.C0.ESC+"[B";break;case 45:p.shiftKey||p.ctrlKey||(w.key=d.C0.ESC+"[2~");break;case 46:w.key=_?d.C0.ESC+"[3;"+(_+1)+"~":d.C0.ESC+"[3~";break;case 36:w.key=_?d.C0.ESC+"[1;"+(_+1)+"H":x?d.C0.ESC+"OH":d.C0.ESC+"[H";break;case 35:w.key=_?d.C0.ESC+"[1;"+(_+1)+"F":x?d.C0.ESC+"OF":d.C0.ESC+"[F";break;case 33:p.shiftKey?w.type=2:p.ctrlKey?w.key=d.C0.ESC+"[5;"+(_+1)+"~":w.key=d.C0.ESC+"[5~";break;case 34:p.shiftKey?w.type=3:p.ctrlKey?w.key=d.C0.ESC+"[6;"+(_+1)+"~":w.key=d.C0.ESC+"[6~";break;case 112:w.key=_?d.C0.ESC+"[1;"+(_+1)+"P":d.C0.ESC+"OP";break;case 113:w.key=_?d.C0.ESC+"[1;"+(_+1)+"Q":d.C0.ESC+"OQ";break;case 114:w.key=_?d.C0.ESC+"[1;"+(_+1)+"R":d.C0.ESC+"OR";break;case 115:w.key=_?d.C0.ESC+"[1;"+(_+1)+"S":d.C0.ESC+"OS";break;case 116:w.key=_?d.C0.ESC+"[15;"+(_+1)+"~":d.C0.ESC+"[15~";break;case 117:w.key=_?d.C0.ESC+"[17;"+(_+1)+"~":d.C0.ESC+"[17~";break;case 118:w.key=_?d.C0.ESC+"[18;"+(_+1)+"~":d.C0.ESC+"[18~";break;case 119:w.key=_?d.C0.ESC+"[19;"+(_+1)+"~":d.C0.ESC+"[19~";break;case 120:w.key=_?d.C0.ESC+"[20;"+(_+1)+"~":d.C0.ESC+"[20~";break;case 121:w.key=_?d.C0.ESC+"[21;"+(_+1)+"~":d.C0.ESC+"[21~";break;case 122:w.key=_?d.C0.ESC+"[23;"+(_+1)+"~":d.C0.ESC+"[23~";break;case 123:w.key=_?d.C0.ESC+"[24;"+(_+1)+"~":d.C0.ESC+"[24~";break;default:if(!p.ctrlKey||p.shiftKey||p.altKey||p.metaKey)if(S&&!C||!p.altKey||p.metaKey)!S||p.altKey||p.ctrlKey||p.shiftKey||!p.metaKey?p.key&&!p.ctrlKey&&!p.altKey&&!p.metaKey&&p.keyCode>=48&&p.key.length===1?w.key=p.key:p.key&&p.ctrlKey&&(p.key==="_"&&(w.key=d.C0.US),p.key==="@"&&(w.key=d.C0.NUL)):p.keyCode===65&&(w.type=1);else{const b=m[p.keyCode],v=b==null?void 0:b[p.shiftKey?1:0];if(v)w.key=d.C0.ESC+v;else if(p.keyCode>=65&&p.keyCode<=90){const y=p.ctrlKey?p.keyCode-64:p.keyCode+32;let A=String.fromCharCode(y);p.shiftKey&&(A=A.toUpperCase()),w.key=d.C0.ESC+A}else if(p.keyCode===32)w.key=d.C0.ESC+(p.ctrlKey?d.C0.NUL:" ");else if(p.key==="Dead"&&p.code.startsWith("Key")){let y=p.code.slice(3,4);p.shiftKey||(y=y.toLowerCase()),w.key=d.C0.ESC+y,w.cancel=!0}}else p.keyCode>=65&&p.keyCode<=90?w.key=String.fromCharCode(p.keyCode-64):p.keyCode===32?w.key=d.C0.NUL:p.keyCode>=51&&p.keyCode<=55?w.key=String.fromCharCode(p.keyCode-51+27):p.keyCode===56?w.key=d.C0.DEL:p.keyCode===219?w.key=d.C0.ESC:p.keyCode===220?w.key=d.C0.FS:p.keyCode===221&&(w.key=d.C0.GS)}return w}},482:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Utf8ToUtf32=o.StringToUtf32=o.utf32ToString=o.stringFromCodePoint=void 0,o.stringFromCodePoint=function(h){return h>65535?(h-=65536,String.fromCharCode(55296+(h>>10))+String.fromCharCode(h%1024+56320)):String.fromCharCode(h)},o.utf32ToString=function(h,d=0,m=h.length){let p="";for(let x=d;x<m;++x){let S=h[x];S>65535?(S-=65536,p+=String.fromCharCode(55296+(S>>10))+String.fromCharCode(S%1024+56320)):p+=String.fromCharCode(S)}return p},o.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(h,d){const m=h.length;if(!m)return 0;let p=0,x=0;if(this._interim){const S=h.charCodeAt(x++);56320<=S&&S<=57343?d[p++]=1024*(this._interim-55296)+S-56320+65536:(d[p++]=this._interim,d[p++]=S),this._interim=0}for(let S=x;S<m;++S){const C=h.charCodeAt(S);if(55296<=C&&C<=56319){if(++S>=m)return this._interim=C,p;const w=h.charCodeAt(S);56320<=w&&w<=57343?d[p++]=1024*(C-55296)+w-56320+65536:(d[p++]=C,d[p++]=w)}else C!==65279&&(d[p++]=C)}return p}},o.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(h,d){const m=h.length;if(!m)return 0;let p,x,S,C,w=0,_=0,b=0;if(this.interim[0]){let A=!1,M=this.interim[0];M&=(224&M)==192?31:(240&M)==224?15:7;let R,O=0;for(;(R=63&this.interim[++O])&&O<4;)M<<=6,M|=R;const N=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,L=N-O;for(;b<L;){if(b>=m)return 0;if(R=h[b++],(192&R)!=128){b--,A=!0;break}this.interim[O++]=R,M<<=6,M|=63&R}A||(N===2?M<128?b--:d[w++]=M:N===3?M<2048||M>=55296&&M<=57343||M===65279||(d[w++]=M):M<65536||M>1114111||(d[w++]=M)),this.interim.fill(0)}const v=m-4;let y=b;for(;y<m;){for(;!(!(y<v)||128&(p=h[y])||128&(x=h[y+1])||128&(S=h[y+2])||128&(C=h[y+3]));)d[w++]=p,d[w++]=x,d[w++]=S,d[w++]=C,y+=4;if(p=h[y++],p<128)d[w++]=p;else if((224&p)==192){if(y>=m)return this.interim[0]=p,w;if(x=h[y++],(192&x)!=128){y--;continue}if(_=(31&p)<<6|63&x,_<128){y--;continue}d[w++]=_}else if((240&p)==224){if(y>=m)return this.interim[0]=p,w;if(x=h[y++],(192&x)!=128){y--;continue}if(y>=m)return this.interim[0]=p,this.interim[1]=x,w;if(S=h[y++],(192&S)!=128){y--;continue}if(_=(15&p)<<12|(63&x)<<6|63&S,_<2048||_>=55296&&_<=57343||_===65279)continue;d[w++]=_}else if((248&p)==240){if(y>=m)return this.interim[0]=p,w;if(x=h[y++],(192&x)!=128){y--;continue}if(y>=m)return this.interim[0]=p,this.interim[1]=x,w;if(S=h[y++],(192&S)!=128){y--;continue}if(y>=m)return this.interim[0]=p,this.interim[1]=x,this.interim[2]=S,w;if(C=h[y++],(192&C)!=128){y--;continue}if(_=(7&p)<<18|(63&x)<<12|(63&S)<<6|63&C,_<65536||_>1114111)continue;d[w++]=_}}return w}}},225:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeV6=void 0;const d=h(1480),m=[[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]],p=[[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]];let x;o.UnicodeV6=class{constructor(){if(this.version="6",!x){x=new Uint8Array(65536),x.fill(1),x[0]=0,x.fill(0,1,32),x.fill(0,127,160),x.fill(2,4352,4448),x[9001]=2,x[9002]=2,x.fill(2,11904,42192),x[12351]=1,x.fill(2,44032,55204),x.fill(2,63744,64256),x.fill(2,65040,65050),x.fill(2,65072,65136),x.fill(2,65280,65377),x.fill(2,65504,65511);for(let S=0;S<m.length;++S)x.fill(0,m[S][0],m[S][1]+1)}}wcwidth(S){return S<32?0:S<127?1:S<65536?x[S]:(function(C,w){let _,b=0,v=w.length-1;if(C<w[0][0]||C>w[v][1])return!1;for(;v>=b;)if(_=b+v>>1,C>w[_][1])b=_+1;else{if(!(C<w[_][0]))return!0;v=_-1}return!1})(S,p)?0:S>=131072&&S<=196605||S>=196608&&S<=262141?2:1}charProperties(S,C){let w=this.wcwidth(S),_=w===0&&C!==0;if(_){const b=d.UnicodeService.extractWidth(C);b===0?_=!1:b>w&&(w=b)}return d.UnicodeService.createPropertyValue(0,w,_)}}},5981:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WriteBuffer=void 0;const d=h(8460),m=h(844);class p extends m.Disposable{constructor(S){super(),this._action=S,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new d.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(S,C){if(C!==void 0&&this._syncCalls>C)return void(this._syncCalls=0);if(this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let w;for(this._isSyncWriting=!0;w=this._writeBuffer.shift();){this._action(w);const _=this._callbacks.shift();_&&_()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(S,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+=S.length,this._writeBuffer.push(S),this._callbacks.push(C),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(C)}_innerWrite(S=0,C=!0){const w=S||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const _=this._writeBuffer[this._bufferOffset],b=this._action(_,C);if(b){const y=A=>Date.now()-w>=12?setTimeout((()=>this._innerWrite(0,A))):this._innerWrite(w,A);return void b.catch((A=>(queueMicrotask((()=>{throw A})),Promise.resolve(!1)))).then(y)}const v=this._callbacks[this._bufferOffset];if(v&&v(),this._bufferOffset++,this._pendingData-=_.length,Date.now()-w>=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()}}o.WriteBuffer=p},5941:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.toRgbString=o.parseColor=void 0;const h=/^([\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})$/,d=/^[\da-f]+$/;function m(p,x){const S=p.toString(16),C=S.length<2?"0"+S:S;switch(x){case 4:return S[0];case 8:return C;case 12:return(C+C).slice(0,3);default:return C+C}}o.parseColor=function(p){if(!p)return;let x=p.toLowerCase();if(x.indexOf("rgb:")===0){x=x.slice(4);const S=h.exec(x);if(S){const C=S[1]?15:S[4]?255:S[7]?4095:65535;return[Math.round(parseInt(S[1]||S[4]||S[7]||S[10],16)/C*255),Math.round(parseInt(S[2]||S[5]||S[8]||S[11],16)/C*255),Math.round(parseInt(S[3]||S[6]||S[9]||S[12],16)/C*255)]}}else if(x.indexOf("#")===0&&(x=x.slice(1),d.exec(x)&&[3,6,9,12].includes(x.length))){const S=x.length/3,C=[0,0,0];for(let w=0;w<3;++w){const _=parseInt(x.slice(S*w,S*w+S),16);C[w]=S===1?_<<4:S===2?_:S===3?_>>4:_>>8}return C}},o.toRgbString=function(p,x=16){const[S,C,w]=p;return`rgb:${m(S,x)}/${m(C,x)}/${m(w,x)}`}},5770:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.PAYLOAD_LIMIT=void 0,o.PAYLOAD_LIMIT=1e7},6351:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DcsHandler=o.DcsParser=void 0;const d=h(482),m=h(8742),p=h(5770),x=[];o.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=x,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=x}registerHandler(C,w){this._handlers[C]===void 0&&(this._handlers[C]=[]);const _=this._handlers[C];return _.push(w),{dispose:()=>{const b=_.indexOf(w);b!==-1&&_.splice(b,1)}}}clearHandler(C){this._handlers[C]&&delete this._handlers[C]}setHandlerFallback(C){this._handlerFb=C}reset(){if(this._active.length)for(let C=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;C>=0;--C)this._active[C].unhook(!1);this._stack.paused=!1,this._active=x,this._ident=0}hook(C,w){if(this.reset(),this._ident=C,this._active=this._handlers[C]||x,this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].hook(w);else this._handlerFb(this._ident,"HOOK",w)}put(C,w,_){if(this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].put(C,w,_);else this._handlerFb(this._ident,"PUT",(0,d.utf32ToString)(C,w,_))}unhook(C,w=!0){if(this._active.length){let _=!1,b=this._active.length-1,v=!1;if(this._stack.paused&&(b=this._stack.loopPosition-1,_=w,v=this._stack.fallThrough,this._stack.paused=!1),!v&&_===!1){for(;b>=0&&(_=this._active[b].unhook(C),_!==!0);b--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!1,_;b--}for(;b>=0;b--)if(_=this._active[b].unhook(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!0,_}else this._handlerFb(this._ident,"UNHOOK",C);this._active=x,this._ident=0}};const S=new m.Params;S.addParam(0),o.DcsHandler=class{constructor(C){this._handler=C,this._data="",this._params=S,this._hitLimit=!1}hook(C){this._params=C.length>1||C.params[0]?C.clone():S,this._data="",this._hitLimit=!1}put(C,w,_){this._hitLimit||(this._data+=(0,d.utf32ToString)(C,w,_),this._data.length>p.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(C){let w=!1;if(this._hitLimit)w=!1;else if(C&&(w=this._handler(this._data,this._params),w instanceof Promise))return w.then((_=>(this._params=S,this._data="",this._hitLimit=!1,_)));return this._params=S,this._data="",this._hitLimit=!1,w}}},2015:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.EscapeSequenceParser=o.VT500_TRANSITION_TABLE=o.TransitionTable=void 0;const d=h(844),m=h(8742),p=h(6242),x=h(6351);class S{constructor(b){this.table=new Uint8Array(b)}setDefault(b,v){this.table.fill(b<<4|v)}add(b,v,y,A){this.table[v<<8|b]=y<<4|A}addMany(b,v,y,A){for(let M=0;M<b.length;M++)this.table[v<<8|b[M]]=y<<4|A}}o.TransitionTable=S;const C=160;o.VT500_TRANSITION_TABLE=(function(){const _=new S(4095),b=Array.apply(null,Array(256)).map(((O,N)=>N)),v=(O,N)=>b.slice(O,N),y=v(32,127),A=v(0,24);A.push(25),A.push.apply(A,v(28,32));const M=v(0,14);let R;for(R in _.setDefault(1,0),_.addMany(y,0,2,0),M)_.addMany([24,26,153,154],R,3,0),_.addMany(v(128,144),R,3,0),_.addMany(v(144,152),R,3,0),_.add(156,R,0,0),_.add(27,R,11,1),_.add(157,R,4,8),_.addMany([152,158,159],R,0,7),_.add(155,R,11,3),_.add(144,R,11,9);return _.addMany(A,0,3,0),_.addMany(A,1,3,1),_.add(127,1,0,1),_.addMany(A,8,0,8),_.addMany(A,3,3,3),_.add(127,3,0,3),_.addMany(A,4,3,4),_.add(127,4,0,4),_.addMany(A,6,3,6),_.addMany(A,5,3,5),_.add(127,5,0,5),_.addMany(A,2,3,2),_.add(127,2,0,2),_.add(93,1,4,8),_.addMany(y,8,5,8),_.add(127,8,5,8),_.addMany([156,27,24,26,7],8,6,0),_.addMany(v(28,32),8,0,8),_.addMany([88,94,95],1,0,7),_.addMany(y,7,0,7),_.addMany(A,7,0,7),_.add(156,7,0,0),_.add(127,7,0,7),_.add(91,1,11,3),_.addMany(v(64,127),3,7,0),_.addMany(v(48,60),3,8,4),_.addMany([60,61,62,63],3,9,4),_.addMany(v(48,60),4,8,4),_.addMany(v(64,127),4,7,0),_.addMany([60,61,62,63],4,0,6),_.addMany(v(32,64),6,0,6),_.add(127,6,0,6),_.addMany(v(64,127),6,0,0),_.addMany(v(32,48),3,9,5),_.addMany(v(32,48),5,9,5),_.addMany(v(48,64),5,0,6),_.addMany(v(64,127),5,7,0),_.addMany(v(32,48),4,9,5),_.addMany(v(32,48),1,9,2),_.addMany(v(32,48),2,9,2),_.addMany(v(48,127),2,10,0),_.addMany(v(48,80),1,10,0),_.addMany(v(81,88),1,10,0),_.addMany([89,90,92],1,10,0),_.addMany(v(96,127),1,10,0),_.add(80,1,11,9),_.addMany(A,9,0,9),_.add(127,9,0,9),_.addMany(v(28,32),9,0,9),_.addMany(v(32,48),9,9,12),_.addMany(v(48,60),9,8,10),_.addMany([60,61,62,63],9,9,10),_.addMany(A,11,0,11),_.addMany(v(32,128),11,0,11),_.addMany(v(28,32),11,0,11),_.addMany(A,10,0,10),_.add(127,10,0,10),_.addMany(v(28,32),10,0,10),_.addMany(v(48,60),10,8,10),_.addMany([60,61,62,63],10,0,11),_.addMany(v(32,48),10,9,12),_.addMany(A,12,0,12),_.add(127,12,0,12),_.addMany(v(28,32),12,0,12),_.addMany(v(32,48),12,9,12),_.addMany(v(48,64),12,0,11),_.addMany(v(64,127),12,12,13),_.addMany(v(64,127),10,12,13),_.addMany(v(64,127),9,12,13),_.addMany(A,13,13,13),_.addMany(y,13,13,13),_.add(127,13,0,13),_.addMany([27,156,24,26],13,14,0),_.add(C,0,2,0),_.add(C,8,5,8),_.add(C,6,0,6),_.add(C,11,0,11),_.add(C,13,13,13),_})();class w extends d.Disposable{constructor(b=o.VT500_TRANSITION_TABLE){super(),this._transitions=b,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new m.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(v,y,A)=>{},this._executeHandlerFb=v=>{},this._csiHandlerFb=(v,y)=>{},this._escHandlerFb=v=>{},this._errorHandlerFb=v=>v,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,d.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new p.OscParser),this._dcsParser=this.register(new x.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(b,v=[64,126]){let y=0;if(b.prefix){if(b.prefix.length>1)throw new Error("only one byte as prefix supported");if(y=b.prefix.charCodeAt(0),y&&60>y||y>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(b.intermediates){if(b.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let M=0;M<b.intermediates.length;++M){const R=b.intermediates.charCodeAt(M);if(32>R||R>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");y<<=8,y|=R}}if(b.final.length!==1)throw new Error("final must be a single byte");const A=b.final.charCodeAt(0);if(v[0]>A||A>v[1])throw new Error(`final must be in range ${v[0]} .. ${v[1]}`);return y<<=8,y|=A,y}identToString(b){const v=[];for(;b;)v.push(String.fromCharCode(255&b)),b>>=8;return v.reverse().join("")}setPrintHandler(b){this._printHandler=b}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(b,v){const y=this._identifier(b,[48,126]);this._escHandlers[y]===void 0&&(this._escHandlers[y]=[]);const A=this._escHandlers[y];return A.push(v),{dispose:()=>{const M=A.indexOf(v);M!==-1&&A.splice(M,1)}}}clearEscHandler(b){this._escHandlers[this._identifier(b,[48,126])]&&delete this._escHandlers[this._identifier(b,[48,126])]}setEscHandlerFallback(b){this._escHandlerFb=b}setExecuteHandler(b,v){this._executeHandlers[b.charCodeAt(0)]=v}clearExecuteHandler(b){this._executeHandlers[b.charCodeAt(0)]&&delete this._executeHandlers[b.charCodeAt(0)]}setExecuteHandlerFallback(b){this._executeHandlerFb=b}registerCsiHandler(b,v){const y=this._identifier(b);this._csiHandlers[y]===void 0&&(this._csiHandlers[y]=[]);const A=this._csiHandlers[y];return A.push(v),{dispose:()=>{const M=A.indexOf(v);M!==-1&&A.splice(M,1)}}}clearCsiHandler(b){this._csiHandlers[this._identifier(b)]&&delete this._csiHandlers[this._identifier(b)]}setCsiHandlerFallback(b){this._csiHandlerFb=b}registerDcsHandler(b,v){return this._dcsParser.registerHandler(this._identifier(b),v)}clearDcsHandler(b){this._dcsParser.clearHandler(this._identifier(b))}setDcsHandlerFallback(b){this._dcsParser.setHandlerFallback(b)}registerOscHandler(b,v){return this._oscParser.registerHandler(b,v)}clearOscHandler(b){this._oscParser.clearHandler(b)}setOscHandlerFallback(b){this._oscParser.setHandlerFallback(b)}setErrorHandler(b){this._errorHandler=b}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(b,v,y,A,M){this._parseStack.state=b,this._parseStack.handlers=v,this._parseStack.handlerPos=y,this._parseStack.transition=A,this._parseStack.chunkPos=M}parse(b,v,y){let A,M=0,R=0,O=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,O=this._parseStack.chunkPos+1;else{if(y===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const N=this._parseStack.handlers;let L=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(y===!1&&L>-1){for(;L>=0&&(A=N[L](this._params),A!==!0);L--)if(A instanceof Promise)return this._parseStack.handlerPos=L,A}this._parseStack.handlers=[];break;case 4:if(y===!1&&L>-1){for(;L>=0&&(A=N[L](),A!==!0);L--)if(A instanceof Promise)return this._parseStack.handlerPos=L,A}this._parseStack.handlers=[];break;case 6:if(M=b[this._parseStack.chunkPos],A=this._dcsParser.unhook(M!==24&&M!==26,y),A)return A;M===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(M=b[this._parseStack.chunkPos],A=this._oscParser.end(M!==24&&M!==26,y),A)return A;M===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,O=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let N=O;N<v;++N){switch(M=b[N],R=this._transitions.table[this.currentState<<8|(M<160?M:C)],R>>4){case 2:for(let q=N+1;;++q){if(q>=v||(M=b[q])<32||M>126&&M<C){this._printHandler(b,N,q),N=q-1;break}if(++q>=v||(M=b[q])<32||M>126&&M<C){this._printHandler(b,N,q),N=q-1;break}if(++q>=v||(M=b[q])<32||M>126&&M<C){this._printHandler(b,N,q),N=q-1;break}if(++q>=v||(M=b[q])<32||M>126&&M<C){this._printHandler(b,N,q),N=q-1;break}}break;case 3:this._executeHandlers[M]?this._executeHandlers[M]():this._executeHandlerFb(M),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:N,code:M,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const L=this._csiHandlers[this._collect<<8|M];let P=L?L.length-1:-1;for(;P>=0&&(A=L[P](this._params),A!==!0);P--)if(A instanceof Promise)return this._preserveStack(3,L,P,R,N),A;P<0&&this._csiHandlerFb(this._collect<<8|M,this._params),this.precedingJoinState=0;break;case 8:do switch(M){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(M-48)}while(++N<v&&(M=b[N])>47&&M<60);N--;break;case 9:this._collect<<=8,this._collect|=M;break;case 10:const H=this._escHandlers[this._collect<<8|M];let $=H?H.length-1:-1;for(;$>=0&&(A=H[$](),A!==!0);$--)if(A instanceof Promise)return this._preserveStack(4,H,$,R,N),A;$<0&&this._escHandlerFb(this._collect<<8|M),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|M,this._params);break;case 13:for(let q=N+1;;++q)if(q>=v||(M=b[q])===24||M===26||M===27||M>127&&M<C){this._dcsParser.put(b,N,q),N=q-1;break}break;case 14:if(A=this._dcsParser.unhook(M!==24&&M!==26),A)return this._preserveStack(6,[],0,R,N),A;M===27&&(R|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let q=N+1;;q++)if(q>=v||(M=b[q])<32||M>127&&M<C){this._oscParser.put(b,N,q),N=q-1;break}break;case 6:if(A=this._oscParser.end(M!==24&&M!==26),A)return this._preserveStack(5,[],0,R,N),A;M===27&&(R|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&R}}}o.EscapeSequenceParser=w},6242:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OscHandler=o.OscParser=void 0;const d=h(5770),m=h(482),p=[];o.OscParser=class{constructor(){this._state=0,this._active=p,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(x,S){this._handlers[x]===void 0&&(this._handlers[x]=[]);const C=this._handlers[x];return C.push(S),{dispose:()=>{const w=C.indexOf(S);w!==-1&&C.splice(w,1)}}}clearHandler(x){this._handlers[x]&&delete this._handlers[x]}setHandlerFallback(x){this._handlerFb=x}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}reset(){if(this._state===2)for(let x=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;x>=0;--x)this._active[x].end(!1);this._stack.paused=!1,this._active=p,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||p,this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].start();else this._handlerFb(this._id,"START")}_put(x,S,C){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(x,S,C);else this._handlerFb(this._id,"PUT",(0,m.utf32ToString)(x,S,C))}start(){this.reset(),this._state=1}put(x,S,C){if(this._state!==3){if(this._state===1)for(;S<C;){const w=x[S++];if(w===59){this._state=2,this._start();break}if(w<48||57<w)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+w-48}this._state===2&&C-S>0&&this._put(x,S,C)}}end(x,S=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let C=!1,w=this._active.length-1,_=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,C=S,_=this._stack.fallThrough,this._stack.paused=!1),!_&&C===!1){for(;w>=0&&(C=this._active[w].end(x),C!==!0);w--)if(C instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,C;w--}for(;w>=0;w--)if(C=this._active[w].end(!1),C instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,C}else this._handlerFb(this._id,"END",x);this._active=p,this._id=-1,this._state=0}}},o.OscHandler=class{constructor(x){this._handler=x,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(x,S,C){this._hitLimit||(this._data+=(0,m.utf32ToString)(x,S,C),this._data.length>d.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(x){let S=!1;if(this._hitLimit)S=!1;else if(x&&(S=this._handler(this._data),S instanceof Promise))return S.then((C=>(this._data="",this._hitLimit=!1,C)));return this._data="",this._hitLimit=!1,S}}},8742:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Params=void 0;const h=2147483647;class d{static fromArray(p){const x=new d;if(!p.length)return x;for(let S=Array.isArray(p[0])?1:0;S<p.length;++S){const C=p[S];if(Array.isArray(C))for(let w=0;w<C.length;++w)x.addSubParam(C[w]);else x.addParam(C)}return x}constructor(p=32,x=32){if(this.maxLength=p,this.maxSubParamsLength=x,x>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(p),this.length=0,this._subParams=new Int32Array(x),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(p),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const p=new d(this.maxLength,this.maxSubParamsLength);return p.params.set(this.params),p.length=this.length,p._subParams.set(this._subParams),p._subParamsLength=this._subParamsLength,p._subParamsIdx.set(this._subParamsIdx),p._rejectDigits=this._rejectDigits,p._rejectSubDigits=this._rejectSubDigits,p._digitIsSub=this._digitIsSub,p}toArray(){const p=[];for(let x=0;x<this.length;++x){p.push(this.params[x]);const S=this._subParamsIdx[x]>>8,C=255&this._subParamsIdx[x];C-S>0&&p.push(Array.prototype.slice.call(this._subParams,S,C))}return p}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(p){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(p<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=p>h?h:p}}addSubParam(p){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(p<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=p>h?h:p,this._subParamsIdx[this.length-1]++}}hasSubParams(p){return(255&this._subParamsIdx[p])-(this._subParamsIdx[p]>>8)>0}getSubParams(p){const x=this._subParamsIdx[p]>>8,S=255&this._subParamsIdx[p];return S-x>0?this._subParams.subarray(x,S):null}getSubParamsAll(){const p={};for(let x=0;x<this.length;++x){const S=this._subParamsIdx[x]>>8,C=255&this._subParamsIdx[x];C-S>0&&(p[x]=this._subParams.slice(S,C))}return p}addDigit(p){let x;if(this._rejectDigits||!(x=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const S=this._digitIsSub?this._subParams:this.params,C=S[x-1];S[x-1]=~C?Math.min(10*C+p,h):p}}o.Params=d},5741:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.AddonManager=void 0,o.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let h=this._addons.length-1;h>=0;h--)this._addons[h].instance.dispose()}loadAddon(h,d){const m={instance:d,dispose:d.dispose,isDisposed:!1};this._addons.push(m),d.dispose=()=>this._wrappedAddonDispose(m),d.activate(h)}_wrappedAddonDispose(h){if(h.isDisposed)return;let d=-1;for(let m=0;m<this._addons.length;m++)if(this._addons[m]===h){d=m;break}if(d===-1)throw new Error("Could not dispose an addon that has not been loaded");h.isDisposed=!0,h.dispose.apply(h.instance),this._addons.splice(d,1)}}},8771:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferApiView=void 0;const d=h(3785),m=h(511);o.BufferApiView=class{constructor(p,x){this._buffer=p,this.type=x}init(p){return this._buffer=p,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(p){const x=this._buffer.lines.get(p);if(x)return new d.BufferLineApiView(x)}getNullCell(){return new m.CellData}}},3785:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLineApiView=void 0;const d=h(511);o.BufferLineApiView=class{constructor(m){this._line=m}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(m,p){if(!(m<0||m>=this._line.length))return p?(this._line.loadCell(m,p),p):this._line.loadCell(m,new d.CellData)}translateToString(m,p,x){return this._line.translateToString(m,p,x)}}},8285:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferNamespaceApi=void 0;const d=h(8771),m=h(8460),p=h(844);class x extends p.Disposable{constructor(C){super(),this._core=C,this._onBufferChange=this.register(new m.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new d.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new d.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)}}o.BufferNamespaceApi=x},7975:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ParserApi=void 0,o.ParserApi=class{constructor(h){this._core=h}registerCsiHandler(h,d){return this._core.registerCsiHandler(h,(m=>d(m.toArray())))}addCsiHandler(h,d){return this.registerCsiHandler(h,d)}registerDcsHandler(h,d){return this._core.registerDcsHandler(h,((m,p)=>d(m,p.toArray())))}addDcsHandler(h,d){return this.registerDcsHandler(h,d)}registerEscHandler(h,d){return this._core.registerEscHandler(h,d)}addEscHandler(h,d){return this.registerEscHandler(h,d)}registerOscHandler(h,d){return this._core.registerOscHandler(h,d)}addOscHandler(h,d){return this.registerOscHandler(h,d)}}},7090:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeApi=void 0,o.UnicodeApi=class{constructor(h){this._core=h}register(h){this._core.unicodeService.register(h)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(h){this._core.unicodeService.activeVersion=h}}},744:function(f,o,h){var d=this&&this.__decorate||function(_,b,v,y){var A,M=arguments.length,R=M<3?b:y===null?y=Object.getOwnPropertyDescriptor(b,v):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(_,b,v,y);else for(var O=_.length-1;O>=0;O--)(A=_[O])&&(R=(M<3?A(R):M>3?A(b,v,R):A(b,v))||R);return M>3&&R&&Object.defineProperty(b,v,R),R},m=this&&this.__param||function(_,b){return function(v,y){b(v,y,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferService=o.MINIMUM_ROWS=o.MINIMUM_COLS=void 0;const p=h(8460),x=h(844),S=h(5295),C=h(2585);o.MINIMUM_COLS=2,o.MINIMUM_ROWS=1;let w=o.BufferService=class extends x.Disposable{get buffer(){return this.buffers.active}constructor(_){super(),this.isUserScrolling=!1,this._onResize=this.register(new p.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new p.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(_.rawOptions.cols||0,o.MINIMUM_COLS),this.rows=Math.max(_.rawOptions.rows||0,o.MINIMUM_ROWS),this.buffers=this.register(new S.BufferSet(_,this))}resize(_,b){this.cols=_,this.rows=b,this.buffers.resize(_,b),this._onResize.fire({cols:_,rows:b})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(_,b=!1){const v=this.buffer;let y;y=this._cachedBlankLine,y&&y.length===this.cols&&y.getFg(0)===_.fg&&y.getBg(0)===_.bg||(y=v.getBlankLine(_,b),this._cachedBlankLine=y),y.isWrapped=b;const A=v.ybase+v.scrollTop,M=v.ybase+v.scrollBottom;if(v.scrollTop===0){const R=v.lines.isFull;M===v.lines.length-1?R?v.lines.recycle().copyFrom(y):v.lines.push(y.clone()):v.lines.splice(M+1,0,y.clone()),R?this.isUserScrolling&&(v.ydisp=Math.max(v.ydisp-1,0)):(v.ybase++,this.isUserScrolling||v.ydisp++)}else{const R=M-A+1;v.lines.shiftElements(A+1,R-1,-1),v.lines.set(M,y.clone())}this.isUserScrolling||(v.ydisp=v.ybase),this._onScroll.fire(v.ydisp)}scrollLines(_,b,v){const y=this.buffer;if(_<0){if(y.ydisp===0)return;this.isUserScrolling=!0}else _+y.ydisp>=y.ybase&&(this.isUserScrolling=!1);const A=y.ydisp;y.ydisp=Math.max(Math.min(y.ydisp+_,y.ybase),0),A!==y.ydisp&&(b||this._onScroll.fire(y.ydisp))}};o.BufferService=w=d([m(0,C.IOptionsService)],w)},7994:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CharsetService=void 0,o.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(h){this.glevel=h,this.charset=this._charsets[h]}setgCharset(h,d){this._charsets[h]=d,this.glevel===h&&(this.charset=d)}}},1753:function(f,o,h){var d=this&&this.__decorate||function(y,A,M,R){var O,N=arguments.length,L=N<3?A:R===null?R=Object.getOwnPropertyDescriptor(A,M):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(y,A,M,R);else for(var P=y.length-1;P>=0;P--)(O=y[P])&&(L=(N<3?O(L):N>3?O(A,M,L):O(A,M))||L);return N>3&&L&&Object.defineProperty(A,M,L),L},m=this&&this.__param||function(y,A){return function(M,R){A(M,R,y)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreMouseService=void 0;const p=h(2585),x=h(8460),S=h(844),C={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:y=>y.button!==4&&y.action===1&&(y.ctrl=!1,y.alt=!1,y.shift=!1,!0)},VT200:{events:19,restrict:y=>y.action!==32},DRAG:{events:23,restrict:y=>y.action!==32||y.button!==3},ANY:{events:31,restrict:y=>!0}};function w(y,A){let M=(y.ctrl?16:0)|(y.shift?4:0)|(y.alt?8:0);return y.button===4?(M|=64,M|=y.action):(M|=3&y.button,4&y.button&&(M|=64),8&y.button&&(M|=128),y.action===32?M|=32:y.action!==0||A||(M|=3)),M}const _=String.fromCharCode,b={DEFAULT:y=>{const A=[w(y,!1)+32,y.col+32,y.row+32];return A[0]>255||A[1]>255||A[2]>255?"":`\x1B[M${_(A[0])}${_(A[1])}${_(A[2])}`},SGR:y=>{const A=y.action===0&&y.button!==4?"m":"M";return`\x1B[<${w(y,!0)};${y.col};${y.row}${A}`},SGR_PIXELS:y=>{const A=y.action===0&&y.button!==4?"m":"M";return`\x1B[<${w(y,!0)};${y.x};${y.y}${A}`}};let v=o.CoreMouseService=class extends S.Disposable{constructor(y,A){super(),this._bufferService=y,this._coreService=A,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new x.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const M of Object.keys(C))this.addProtocol(M,C[M]);for(const M of Object.keys(b))this.addEncoding(M,b[M]);this.reset()}addProtocol(y,A){this._protocols[y]=A}addEncoding(y,A){this._encodings[y]=A}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(y){if(!this._protocols[y])throw new Error(`unknown protocol "${y}"`);this._activeProtocol=y,this._onProtocolChange.fire(this._protocols[y].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(y){if(!this._encodings[y])throw new Error(`unknown encoding "${y}"`);this._activeEncoding=y}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(y){if(y.col<0||y.col>=this._bufferService.cols||y.row<0||y.row>=this._bufferService.rows||y.button===4&&y.action===32||y.button===3&&y.action!==32||y.button!==4&&(y.action===2||y.action===3)||(y.col++,y.row++,y.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,y,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(y))return!1;const A=this._encodings[this._activeEncoding](y);return A&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(A):this._coreService.triggerDataEvent(A,!0)),this._lastEvent=y,!0}explainEvents(y){return{down:!!(1&y),up:!!(2&y),drag:!!(4&y),move:!!(8&y),wheel:!!(16&y)}}_equalEvents(y,A,M){if(M){if(y.x!==A.x||y.y!==A.y)return!1}else if(y.col!==A.col||y.row!==A.row)return!1;return y.button===A.button&&y.action===A.action&&y.ctrl===A.ctrl&&y.alt===A.alt&&y.shift===A.shift}};o.CoreMouseService=v=d([m(0,p.IBufferService),m(1,p.ICoreService)],v)},6975:function(f,o,h){var d=this&&this.__decorate||function(v,y,A,M){var R,O=arguments.length,N=O<3?y:M===null?M=Object.getOwnPropertyDescriptor(y,A):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(v,y,A,M);else for(var L=v.length-1;L>=0;L--)(R=v[L])&&(N=(O<3?R(N):O>3?R(y,A,N):R(y,A))||N);return O>3&&N&&Object.defineProperty(y,A,N),N},m=this&&this.__param||function(v,y){return function(A,M){y(A,M,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreService=void 0;const p=h(1439),x=h(8460),S=h(844),C=h(2585),w=Object.freeze({insertMode:!1}),_=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let b=o.CoreService=class extends S.Disposable{constructor(v,y,A){super(),this._bufferService=v,this._logService=y,this._optionsService=A,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new x.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new x.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new x.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new x.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,p.clone)(w),this.decPrivateModes=(0,p.clone)(_)}reset(){this.modes=(0,p.clone)(w),this.decPrivateModes=(0,p.clone)(_)}triggerDataEvent(v,y=!1){if(this._optionsService.rawOptions.disableStdin)return;const A=this._bufferService.buffer;y&&this._optionsService.rawOptions.scrollOnUserInput&&A.ybase!==A.ydisp&&this._onRequestScrollToBottom.fire(),y&&this._onUserInput.fire(),this._logService.debug(`sending data "${v}"`,(()=>v.split("").map((M=>M.charCodeAt(0))))),this._onData.fire(v)}triggerBinaryEvent(v){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${v}"`,(()=>v.split("").map((y=>y.charCodeAt(0))))),this._onBinary.fire(v))}};o.CoreService=b=d([m(0,C.IBufferService),m(1,C.ILogService),m(2,C.IOptionsService)],b)},9074:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DecorationService=void 0;const d=h(8055),m=h(8460),p=h(844),x=h(6106);let S=0,C=0;class w extends p.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new x.SortedList((v=>v==null?void 0:v.marker.line)),this._onDecorationRegistered=this.register(new m.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new m.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,p.toDisposable)((()=>this.reset())))}registerDecoration(v){if(v.marker.isDisposed)return;const y=new _(v);if(y){const A=y.marker.onDispose((()=>y.dispose()));y.onDispose((()=>{y&&(this._decorations.delete(y)&&this._onDecorationRemoved.fire(y),A.dispose())})),this._decorations.insert(y),this._onDecorationRegistered.fire(y)}return y}reset(){for(const v of this._decorations.values())v.dispose();this._decorations.clear()}*getDecorationsAtCell(v,y,A){let M=0,R=0;for(const O of this._decorations.getKeyIterator(y))M=O.options.x??0,R=M+(O.options.width??1),v>=M&&v<R&&(!A||(O.options.layer??"bottom")===A)&&(yield O)}forEachDecorationAtCell(v,y,A,M){this._decorations.forEachByKey(y,(R=>{S=R.options.x??0,C=S+(R.options.width??1),v>=S&&v<C&&(!A||(R.options.layer??"bottom")===A)&&M(R)}))}}o.DecorationService=w;class _ extends p.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=d.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=d.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(v){super(),this.options=v,this.onRenderEmitter=this.register(new m.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new m.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=v.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.InstantiationService=o.ServiceCollection=void 0;const d=h(2585),m=h(8343);class p{constructor(...S){this._entries=new Map;for(const[C,w]of S)this.set(C,w)}set(S,C){const w=this._entries.get(S);return this._entries.set(S,C),w}forEach(S){for(const[C,w]of this._entries.entries())S(C,w)}has(S){return this._entries.has(S)}get(S){return this._entries.get(S)}}o.ServiceCollection=p,o.InstantiationService=class{constructor(){this._services=new p,this._services.set(d.IInstantiationService,this)}setService(x,S){this._services.set(x,S)}getService(x){return this._services.get(x)}createInstance(x,...S){const C=(0,m.getServiceDependencies)(x).sort(((b,v)=>b.index-v.index)),w=[];for(const b of C){const v=this._services.get(b.id);if(!v)throw new Error(`[createInstance] ${x.name} depends on UNKNOWN service ${b.id}.`);w.push(v)}const _=C.length>0?C[0].index:S.length;if(S.length!==_)throw new Error(`[createInstance] First service dependency of ${x.name} at position ${_+1} conflicts with ${S.length} static arguments`);return new x(...S,...w)}}},7866:function(f,o,h){var d=this&&this.__decorate||function(_,b,v,y){var A,M=arguments.length,R=M<3?b:y===null?y=Object.getOwnPropertyDescriptor(b,v):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(_,b,v,y);else for(var O=_.length-1;O>=0;O--)(A=_[O])&&(R=(M<3?A(R):M>3?A(b,v,R):A(b,v))||R);return M>3&&R&&Object.defineProperty(b,v,R),R},m=this&&this.__param||function(_,b){return function(v,y){b(v,y,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.traceCall=o.setTraceLogger=o.LogService=void 0;const p=h(844),x=h(2585),S={trace:x.LogLevelEnum.TRACE,debug:x.LogLevelEnum.DEBUG,info:x.LogLevelEnum.INFO,warn:x.LogLevelEnum.WARN,error:x.LogLevelEnum.ERROR,off:x.LogLevelEnum.OFF};let C,w=o.LogService=class extends p.Disposable{get logLevel(){return this._logLevel}constructor(_){super(),this._optionsService=_,this._logLevel=x.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),C=this}_updateLogLevel(){this._logLevel=S[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(_){for(let b=0;b<_.length;b++)typeof _[b]=="function"&&(_[b]=_[b]())}_log(_,b,v){this._evalLazyOptionalParams(v),_.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+b,...v)}trace(_,...b){var v;this._logLevel<=x.LogLevelEnum.TRACE&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.trace.bind(this._optionsService.options.logger))??console.log,_,b)}debug(_,...b){var v;this._logLevel<=x.LogLevelEnum.DEBUG&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.debug.bind(this._optionsService.options.logger))??console.log,_,b)}info(_,...b){var v;this._logLevel<=x.LogLevelEnum.INFO&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.info.bind(this._optionsService.options.logger))??console.info,_,b)}warn(_,...b){var v;this._logLevel<=x.LogLevelEnum.WARN&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.warn.bind(this._optionsService.options.logger))??console.warn,_,b)}error(_,...b){var v;this._logLevel<=x.LogLevelEnum.ERROR&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.error.bind(this._optionsService.options.logger))??console.error,_,b)}};o.LogService=w=d([m(0,x.IOptionsService)],w),o.setTraceLogger=function(_){C=_},o.traceCall=function(_,b,v){if(typeof v.value!="function")throw new Error("not supported");const y=v.value;v.value=function(...A){if(C.logLevel!==x.LogLevelEnum.TRACE)return y.apply(this,A);C.trace(`GlyphRenderer#${y.name}(${A.map((R=>JSON.stringify(R))).join(", ")})`);const M=y.apply(this,A);return C.trace(`GlyphRenderer#${y.name} return`,M),M}}},7302:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OptionsService=o.DEFAULT_OPTIONS=void 0;const d=h(8460),m=h(844),p=h(6114);o.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:p.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const x=["normal","bold","100","200","300","400","500","600","700","800","900"];class S extends m.Disposable{constructor(w){super(),this._onOptionChange=this.register(new d.EventEmitter),this.onOptionChange=this._onOptionChange.event;const _={...o.DEFAULT_OPTIONS};for(const b in w)if(b in _)try{const v=w[b];_[b]=this._sanitizeAndValidateOption(b,v)}catch(v){console.error(v)}this.rawOptions=_,this.options={..._},this._setupOptions(),this.register((0,m.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(w,_){return this.onOptionChange((b=>{b===w&&_(this.rawOptions[w])}))}onMultipleOptionChange(w,_){return this.onOptionChange((b=>{w.indexOf(b)!==-1&&_()}))}_setupOptions(){const w=b=>{if(!(b in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${b}"`);return this.rawOptions[b]},_=(b,v)=>{if(!(b in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${b}"`);v=this._sanitizeAndValidateOption(b,v),this.rawOptions[b]!==v&&(this.rawOptions[b]=v,this._onOptionChange.fire(b))};for(const b in this.rawOptions){const v={get:w.bind(this,b),set:_.bind(this,b)};Object.defineProperty(this.options,b,v)}}_sanitizeAndValidateOption(w,_){switch(w){case"cursorStyle":if(_||(_=o.DEFAULT_OPTIONS[w]),!(function(b){return b==="block"||b==="underline"||b==="bar"})(_))throw new Error(`"${_}" is not a valid value for ${w}`);break;case"wordSeparator":_||(_=o.DEFAULT_OPTIONS[w]);break;case"fontWeight":case"fontWeightBold":if(typeof _=="number"&&1<=_&&_<=1e3)break;_=x.includes(_)?_:o.DEFAULT_OPTIONS[w];break;case"cursorWidth":_=Math.floor(_);case"lineHeight":case"tabStopWidth":if(_<1)throw new Error(`${w} cannot be less than 1, value: ${_}`);break;case"minimumContrastRatio":_=Math.max(1,Math.min(21,Math.round(10*_)/10));break;case"scrollback":if((_=Math.min(_,4294967295))<0)throw new Error(`${w} cannot be less than 0, value: ${_}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(_<=0)throw new Error(`${w} cannot be less than or equal to 0, value: ${_}`);break;case"rows":case"cols":if(!_&&_!==0)throw new Error(`${w} must be numeric, value: ${_}`);break;case"windowsPty":_=_??{}}return _}}o.OptionsService=S},2660:function(f,o,h){var d=this&&this.__decorate||function(S,C,w,_){var b,v=arguments.length,y=v<3?C:_===null?_=Object.getOwnPropertyDescriptor(C,w):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(S,C,w,_);else for(var A=S.length-1;A>=0;A--)(b=S[A])&&(y=(v<3?b(y):v>3?b(C,w,y):b(C,w))||y);return v>3&&y&&Object.defineProperty(C,w,y),y},m=this&&this.__param||function(S,C){return function(w,_){C(w,_,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkService=void 0;const p=h(2585);let x=o.OscLinkService=class{constructor(S){this._bufferService=S,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(S){const C=this._bufferService.buffer;if(S.id===void 0){const A=C.addMarker(C.ybase+C.y),M={data:S,id:this._nextId++,lines:[A]};return A.onDispose((()=>this._removeMarkerFromLink(M,A))),this._dataByLinkId.set(M.id,M),M.id}const w=S,_=this._getEntryIdKey(w),b=this._entriesWithId.get(_);if(b)return this.addLineToLink(b.id,C.ybase+C.y),b.id;const v=C.addMarker(C.ybase+C.y),y={id:this._nextId++,key:this._getEntryIdKey(w),data:w,lines:[v]};return v.onDispose((()=>this._removeMarkerFromLink(y,v))),this._entriesWithId.set(y.key,y),this._dataByLinkId.set(y.id,y),y.id}addLineToLink(S,C){const w=this._dataByLinkId.get(S);if(w&&w.lines.every((_=>_.line!==C))){const _=this._bufferService.buffer.addMarker(C);w.lines.push(_),_.onDispose((()=>this._removeMarkerFromLink(w,_)))}}getLinkData(S){var C;return(C=this._dataByLinkId.get(S))==null?void 0:C.data}_getEntryIdKey(S){return`${S.id};;${S.uri}`}_removeMarkerFromLink(S,C){const w=S.lines.indexOf(C);w!==-1&&(S.lines.splice(w,1),S.lines.length===0&&(S.data.id!==void 0&&this._entriesWithId.delete(S.key),this._dataByLinkId.delete(S.id)))}};o.OscLinkService=x=d([m(0,p.IBufferService)],x)},8343:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.createDecorator=o.getServiceDependencies=o.serviceRegistry=void 0;const h="di$target",d="di$dependencies";o.serviceRegistry=new Map,o.getServiceDependencies=function(m){return m[d]||[]},o.createDecorator=function(m){if(o.serviceRegistry.has(m))return o.serviceRegistry.get(m);const p=function(x,S,C){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(w,_,b){_[h]===_?_[d].push({id:w,index:b}):(_[d]=[{id:w,index:b}],_[h]=_)})(p,x,C)};return p.toString=()=>m,o.serviceRegistry.set(m,p),p}},2585:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.IDecorationService=o.IUnicodeService=o.IOscLinkService=o.IOptionsService=o.ILogService=o.LogLevelEnum=o.IInstantiationService=o.ICharsetService=o.ICoreService=o.ICoreMouseService=o.IBufferService=void 0;const d=h(8343);var m;o.IBufferService=(0,d.createDecorator)("BufferService"),o.ICoreMouseService=(0,d.createDecorator)("CoreMouseService"),o.ICoreService=(0,d.createDecorator)("CoreService"),o.ICharsetService=(0,d.createDecorator)("CharsetService"),o.IInstantiationService=(0,d.createDecorator)("InstantiationService"),(function(p){p[p.TRACE=0]="TRACE",p[p.DEBUG=1]="DEBUG",p[p.INFO=2]="INFO",p[p.WARN=3]="WARN",p[p.ERROR=4]="ERROR",p[p.OFF=5]="OFF"})(m||(o.LogLevelEnum=m={})),o.ILogService=(0,d.createDecorator)("LogService"),o.IOptionsService=(0,d.createDecorator)("OptionsService"),o.IOscLinkService=(0,d.createDecorator)("OscLinkService"),o.IUnicodeService=(0,d.createDecorator)("UnicodeService"),o.IDecorationService=(0,d.createDecorator)("DecorationService")},1480:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeService=void 0;const d=h(8460),m=h(225);class p{static extractShouldJoin(S){return(1&S)!=0}static extractWidth(S){return S>>1&3}static extractCharKind(S){return S>>3}static createPropertyValue(S,C,w=!1){return(16777215&S)<<3|(3&C)<<1|(w?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new d.EventEmitter,this.onChange=this._onChange.event;const S=new m.UnicodeV6;this.register(S),this._active=S.version,this._activeProvider=S}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(S){if(!this._providers[S])throw new Error(`unknown Unicode version "${S}"`);this._active=S,this._activeProvider=this._providers[S],this._onChange.fire(S)}register(S){this._providers[S.version]=S}wcwidth(S){return this._activeProvider.wcwidth(S)}getStringCellWidth(S){let C=0,w=0;const _=S.length;for(let b=0;b<_;++b){let v=S.charCodeAt(b);if(55296<=v&&v<=56319){if(++b>=_)return C+this.wcwidth(v);const M=S.charCodeAt(b);56320<=M&&M<=57343?v=1024*(v-55296)+M-56320+65536:C+=this.wcwidth(M)}const y=this.charProperties(v,w);let A=p.extractWidth(y);p.extractShouldJoin(y)&&(A-=p.extractWidth(w)),C+=A,w=y}return C}charProperties(S,C){return this._activeProvider.charProperties(S,C)}}o.UnicodeService=p}},a={};function l(f){var o=a[f];if(o!==void 0)return o.exports;var h=a[f]={exports:{}};return r[f].call(h.exports,h,h.exports,l),h.exports}var u={};return(()=>{var f=u;Object.defineProperty(f,"__esModule",{value:!0}),f.Terminal=void 0;const o=l(9042),h=l(3236),d=l(844),m=l(5741),p=l(8285),x=l(7975),S=l(7090),C=["cols","rows"];class w extends d.Disposable{constructor(b){super(),this._core=this.register(new h.Terminal(b)),this._addonManager=this.register(new m.AddonManager),this._publicOptions={...this._core.options};const v=A=>this._core.options[A],y=(A,M)=>{this._checkReadonlyOptions(A),this._core.options[A]=M};for(const A in this._core.options){const M={get:v.bind(this,A),set:y.bind(this,A)};Object.defineProperty(this._publicOptions,A,M)}}_checkReadonlyOptions(b){if(C.includes(b))throw new Error(`Option "${b}" 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 x.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new S.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 p.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const b=this._core.coreService.decPrivateModes;let v="none";switch(this._core.coreMouseService.activeProtocol){case"X10":v="x10";break;case"VT200":v="vt200";break;case"DRAG":v="drag";break;case"ANY":v="any"}return{applicationCursorKeysMode:b.applicationCursorKeys,applicationKeypadMode:b.applicationKeypad,bracketedPasteMode:b.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:v,originMode:b.origin,reverseWraparoundMode:b.reverseWraparound,sendFocusMode:b.sendFocus,wraparoundMode:b.wraparound}}get options(){return this._publicOptions}set options(b){for(const v in b)this._publicOptions[v]=b[v]}blur(){this._core.blur()}focus(){this._core.focus()}input(b,v=!0){this._core.input(b,v)}resize(b,v){this._verifyIntegers(b,v),this._core.resize(b,v)}open(b){this._core.open(b)}attachCustomKeyEventHandler(b){this._core.attachCustomKeyEventHandler(b)}attachCustomWheelEventHandler(b){this._core.attachCustomWheelEventHandler(b)}registerLinkProvider(b){return this._core.registerLinkProvider(b)}registerCharacterJoiner(b){return this._checkProposedApi(),this._core.registerCharacterJoiner(b)}deregisterCharacterJoiner(b){this._checkProposedApi(),this._core.deregisterCharacterJoiner(b)}registerMarker(b=0){return this._verifyIntegers(b),this._core.registerMarker(b)}registerDecoration(b){return this._checkProposedApi(),this._verifyPositiveIntegers(b.x??0,b.width??0,b.height??0),this._core.registerDecoration(b)}hasSelection(){return this._core.hasSelection()}select(b,v,y){this._verifyIntegers(b,v,y),this._core.select(b,v,y)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(b,v){this._verifyIntegers(b,v),this._core.selectLines(b,v)}dispose(){super.dispose()}scrollLines(b){this._verifyIntegers(b),this._core.scrollLines(b)}scrollPages(b){this._verifyIntegers(b),this._core.scrollPages(b)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(b){this._verifyIntegers(b),this._core.scrollToLine(b)}clear(){this._core.clear()}write(b,v){this._core.write(b,v)}writeln(b,v){this._core.write(b),this._core.write(`\r
92
- `,v)}paste(b){this._core.paste(b)}refresh(b,v){this._verifyIntegers(b,v),this._core.refresh(b,v)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(b){this._addonManager.loadAddon(this,b)}static get strings(){return o}_verifyIntegers(...b){for(const v of b)if(v===1/0||isNaN(v)||v%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...b){for(const v of b)if(v&&(v===1/0||isNaN(v)||v%1!=0||v<0))throw new Error("This API only accepts positive integers")}}f.Terminal=w})(),u})()))})(ud)),ud.exports}var hO=uO(),hd={exports:{}},Pv;function dO(){return Pv||(Pv=1,(function(e,n){(function(r,a){e.exports=a()})(self,(()=>(()=>{var r={};return(()=>{var a=r;Object.defineProperty(a,"__esModule",{value:!0}),a.FitAddon=void 0,a.FitAddon=class{activate(l){this._terminal=l}dispose(){}fit(){const l=this.proposeDimensions();if(!l||!this._terminal||isNaN(l.cols)||isNaN(l.rows))return;const u=this._terminal._core;this._terminal.rows===l.rows&&this._terminal.cols===l.cols||(u._renderService.clear(),this._terminal.resize(l.cols,l.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const l=this._terminal._core,u=l._renderService.dimensions;if(u.css.cell.width===0||u.css.cell.height===0)return;const f=this._terminal.options.scrollback===0?0:l.viewport.scrollBarWidth,o=window.getComputedStyle(this._terminal.element.parentElement),h=parseInt(o.getPropertyValue("height")),d=Math.max(0,parseInt(o.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),p=h-(parseInt(m.getPropertyValue("padding-top"))+parseInt(m.getPropertyValue("padding-bottom"))),x=d-(parseInt(m.getPropertyValue("padding-right"))+parseInt(m.getPropertyValue("padding-left")))-f;return{cols:Math.max(2,Math.floor(x/u.css.cell.width)),rows:Math.max(1,Math.floor(p/u.css.cell.height))}}}})(),r})()))})(hd)),hd.exports}var fO=dO();function as(e,n){const r=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return r?`rgb(${r})`:n}function pO(e,n,r){const a=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return a?`rgb(${a} / ${n})`:r}function zv(){return{background:as("--c-canvas","#0b0d0f"),foreground:as("--c-content-primary","#e6e8eb"),cursor:as("--c-accent","#2dd4bf"),selectionBackground:pO("--c-accent",.22,"rgba(45,212,191,0.25)"),black:as("--c-content-faint","#4e535a"),brightBlack:as("--c-content-muted","#70767e"),white:as("--c-content-secondary","#9ea5ad"),brightWhite:as("--c-content-primary","#e9ebee")}}function mO(e,n){const r=ie.useRef(null),a=ie.useRef(null),l=ie.useRef(null);return ie.useEffect(()=>{if(!r.current||!e)return;const u=new hO.Terminal({fontFamily:"JetBrains Mono, ui-monospace, monospace",fontSize:13,cursorBlink:!0,theme:zv(),scrollback:5e3}),f=new fO.FitAddon;u.loadAddon(f),u.open(r.current),f.fit(),a.current=u,l.current=f;const o=e.terminalBuffer(n);o&&u.write(o);const h=u.onData(S=>e.sendInput(n,S)),d=u.onResize(({cols:S,rows:C})=>e.sendResize(n,S,C)),m=e.onEvent(S=>{if(S.type==="terminal.reset"&&S.terminalId===n){u.reset();return}S.type==="terminal.output"&&S.terminalId===n&&u.write(S.data)}),p=new ResizeObserver(()=>{try{f.fit(),e.sendResize(n,u.cols,u.rows)}catch{}});p.observe(r.current);const x=new MutationObserver(()=>{u.options.theme=zv()});return x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),e.sendResize(n,u.cols,u.rows),()=>{h.dispose(),d.dispose(),m(),p.disconnect(),x.disconnect(),u.dispose(),a.current=null,l.current=null}},[e,n]),{containerRef:r}}function jv(e,n){return e==="default"?"默认":n||e.slice(0,8)}const Zy=e=>`linkshell:web:lastTerminal:${e}`;function gO(e){if(!e)return null;try{return localStorage.getItem(Zy(e))}catch{return null}}function _O(e,n){if(e)try{localStorage.setItem(Zy(e),n)}catch{}}function vO(e,n){if(e.length===0)return null;if(n&&e.includes(n))return n;const r=e.filter(a=>a!=="default");return r.length>0?r[r.length-1]:e[0]}function bO({bridge:e,terminalId:n}){const{containerRef:r}=mO(e,n);return k.jsx("div",{ref:r,className:"xterm-host min-h-0 flex-1 bg-canvas p-2"})}function yO({bridge:e,onNewTerminal:n}){const r=e==null?void 0:e.sessionId,[a,l]=ie.useState([]),[u,f]=ie.useState("default"),o=ie.useRef(!1),h=ie.useRef(!1),d=ie.useCallback((x,S)=>{l(C=>C.some(w=>w.id===x)?C:[...C,{id:x,label:jv(x,S)}])},[]);ie.useEffect(()=>{if(!e)return;o.current=!1,h.current=!1;const x=gO(r);return e.requestTerminalList(),e.onEvent(C=>{if(C.type==="terminal.output"){d(C.terminalId);return}if(C.type==="terminal.list"){const w=C.envelope,_=w.payload;if(w.type==="terminal.spawned"){const b=_==null?void 0:_.terminalId;b&&(d(b,_==null?void 0:_.projectName),f(b));return}if(w.type==="terminal.list"){const y=(Array.isArray(_==null?void 0:_.terminals)?_.terminals:[]).filter(A=>typeof A.terminalId=="string"&&A.status!=="exited").map(A=>({id:A.terminalId,label:jv(A.terminalId,A.projectName)}));if(l(y),!o.current){o.current=!0;const A=y.map(R=>R.id),M=vO(A,x);M?f(M):h.current||(h.current=!0,n==null||n())}}}})},[e,d,n]),ie.useEffect(()=>{o.current&&u&&_O(r,u)},[r,u]);const m=()=>n==null?void 0:n(),p=x=>{e==null||e.killTerminal(x),l(S=>{var w;const C=S.filter(_=>_.id!==x);return x===u&&f(((w=C[C.length-1])==null?void 0:w.id)??"default"),C})};return k.jsxs("div",{className:"flex h-full flex-col bg-canvas",children:[k.jsxs("div",{className:"flex items-center gap-0.5 border-b border-border bg-surface-raised px-1.5 py-1",children:[k.jsx(_d,{size:13,className:"mx-1 shrink-0 text-content-faint"}),k.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto",children:a.map(x=>k.jsxs("div",{className:`group flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-2xs transition-colors ${x.id===u?"bg-surface-overlay text-content-primary":"text-content-muted hover:bg-surface-overlay/60"}`,children:[k.jsx("button",{onClick:()=>f(x.id),className:"cursor-pointer font-mono",children:x.label}),a.length>1&&k.jsx("button",{onClick:()=>p(x.id),className:"cursor-pointer rounded text-content-faint opacity-0 transition hover:text-danger group-hover:opacity-100","aria-label":"关闭终端",children:k.jsx(gi,{size:11})})]},x.id))}),k.jsx("button",{onClick:m,className:"ml-1 shrink-0 cursor-pointer rounded-md p-1 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"新建终端","aria-label":"新建终端",children:k.jsx(Ro,{size:14})})]}),k.jsx(bO,{bridge:e,terminalId:u},u)]})}function Xy(e){if(!e||e==="—")return"(未知目录)";const n=e.replace(/\/+$/,"").split("/");return n[n.length-1]||e}function Uv(e,n){return e.status==="waiting_permission"?0:e.status==="running"?1:e.status==="error"?2:e.id===n?3:4}function xO(e){return(n,r)=>{const a=Uv(n,e)-Uv(r,e);return a!==0?a:r.lastActivityAt-n.lastActivityAt}}function SO(e){return e.status==="waiting_permission"||e.status==="running"||e.status==="error"}function EO(e){const n=new Map;for(const r of e){const a=r.cwd||"—";let l=n.get(a);l||(l={cwd:a,label:Xy(a),providers:new Map},n.set(a,l));const u=l.providers.get(r.provider)??[];u.push(r),l.providers.set(r.provider,u)}for(const r of n.values())for(const a of r.providers.values())a.sort((l,u)=>u.lastActivityAt-l.lastActivityAt);return[...n.values()].sort((r,a)=>r.label.localeCompare(a.label))}function wO(e){return[...e.providers.entries()].map(([n,r])=>({provider:n,conversations:r})).sort((n,r)=>qd(n.provider).localeCompare(qd(r.provider)))}function qd(e){return e==="claude"?"Claude":e==="codex"?"Codex":e}function dd(e){switch(e){case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"waiting_permission":return{text:"等待授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};case"unavailable":return{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"};case"idle":default:return{text:"空闲",className:"border-border bg-surface-overlay text-content-muted"}}}function Hv({deviceLabel:e,conversations:n,capabilities:r,activeConversationId:a,externalAgentStatus:l,externalAgentTitle:u,externalAgentProvider:f,store:o,onSelect:h,onNewConversation:d,onOpenExternalTerminal:m}){const x=((r==null?void 0:r.providers)??[]).filter(T=>T.enabled),[S,C]=ie.useState(!1),w=ie.useMemo(()=>n.filter(T=>T.archived).length,[n]),_=ie.useMemo(()=>S?n:n.filter(T=>!T.archived),[n,S]),b=ie.useMemo(()=>_.filter(SO).sort(xO(a)),[_,a]),v=l==="running"||l==="waiting_permission"||l==="error",y=v||b.length>0,A=ie.useMemo(()=>EO(_),[_]),[M,R]=ie.useState(new Set),O=T=>R(z=>{const F=new Set(z);return F.has(T)?F.delete(T):F.add(T),F}),[N,L]=ie.useState(null),[P,H]=ie.useState(null),[$,q]=ie.useState(null),[Z,K]=ie.useState(""),G=ie.useRef(!1),te=()=>{L(null),H(null)},ee=T=>{te(),q(T.id),K(T.title&&T.title.trim()||"")},I=T=>{o.renameConversation(T.id,Z),q(null)};return k.jsxs("div",{className:"flex h-full flex-col",children:[k.jsxs("div",{className:"flex items-center gap-2.5 border-b border-border px-3 py-3",children:[k.jsx(vS,{size:14,className:"shrink-0 text-content-faint"}),k.jsx("span",{className:"truncate font-mono text-[13px] font-semibold text-content-secondary",children:e})]}),k.jsxs("div",{className:"space-y-2 border-b border-border px-3 py-3",children:[k.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"新建对话"}),x.length===0?k.jsx("span",{className:"text-2xs text-content-faint",children:"等待能力…"}):k.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(T=>k.jsxs("button",{onClick:()=>d(T.id),className:"codex-btn-outline text-2xs","aria-label":`新建 ${T.label} 对话`,children:[k.jsx(ea,{provider:T.id,size:13})," ",T.label]},T.id))})]}),y&&k.jsxs("div",{className:"border-b border-border px-3 py-3",children:[k.jsx("p",{className:"mb-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"活跃会话"}),k.jsxs("div",{className:"space-y-1",children:[v&&l&&k.jsxs("button",{onClick:m,className:"flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay",title:"打开终端面板",children:[k.jsx(ea,{provider:f??"custom",size:14}),k.jsxs("span",{className:"min-w-0 flex-1",children:[k.jsxs("span",{className:"flex items-center gap-2",children:[k.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:u??"外部终端"}),(()=>{const T=dd(l);return k.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${T.className}`,children:[T.pulsing&&k.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),T.text]})})()]}),k.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:e})]})]},"active:external-terminal"),b.map(T=>{const z=T.title&&T.title.trim()||T.lastMessagePreview&&T.lastMessagePreview.trim().slice(0,40)||`对话 ${T.id.slice(-6)}`,F=dd(T.status);return k.jsxs("button",{onClick:()=>h(T.id),className:`flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay ${T.id===a?"tree-row-active":""}`,title:T.cwd,children:[k.jsx(ea,{provider:T.provider,size:14}),k.jsxs("span",{className:"min-w-0 flex-1",children:[k.jsxs("span",{className:"flex items-center gap-2",children:[k.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:z}),k.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${F.className}`,children:[F.pulsing&&k.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),F.text]})]}),k.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:Xy(T.cwd)})]})]},`active:${T.id}`)})]})]}),k.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:A.length===0?k.jsx("p",{className:"px-3 py-2 text-2xs text-content-faint",children:S||w===0?"还没有对话":"没有未归档的对话"}):A.map(T=>{const z=`folder:${T.cwd}`,F=M.has(z);return k.jsxs("div",{className:"py-1",children:[k.jsxs("button",{onClick:()=>O(z),className:"tree-row",title:T.cwd,children:[F?k.jsx(vi,{size:12,className:"shrink-0 text-content-faint"}):k.jsx(Mr,{size:12,className:"shrink-0 text-content-faint"}),k.jsx(Nr,{size:13,className:"shrink-0 text-content-faint"}),k.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-content-faint",children:T.label})]}),!F&&wO(T).map(({provider:B,conversations:le})=>{const xe=`prov:${T.cwd}:${B}`,fe=M.has(xe);return k.jsxs("div",{className:"pl-3",children:[k.jsxs("div",{className:"flex items-center gap-1",children:[k.jsxs("button",{onClick:()=>O(xe),className:"tree-row flex-1",children:[fe?k.jsx(vi,{size:12,className:"shrink-0 text-content-faint"}):k.jsx(Mr,{size:12,className:"shrink-0 text-content-faint"}),k.jsx(ea,{provider:B,size:13}),k.jsx("span",{className:"text-[13px] font-medium text-content-secondary",children:qd(B)}),k.jsxs("span",{className:"text-2xs text-content-faint",children:["(",le.length,")"]})]}),k.jsx("button",{onClick:()=>d(B,T.cwd==="—"?void 0:T.cwd),className:"cursor-pointer rounded-lg p-1.5 text-content-faint transition-colors hover:bg-surface-overlay hover:text-accent",title:"在此目录新建对话","aria-label":"新建对话",children:k.jsx(Ro,{size:13})})]}),!fe&&le.map(Y=>{const U=Y.title&&Y.title.trim()||Y.lastMessagePreview&&Y.lastMessagePreview.trim().slice(0,40)||`对话 ${Y.id.slice(-6)}`,me=$===Y.id,oe=N===Y.id,J=dd(Y.status);return k.jsxs("div",{className:"group relative",children:[me?k.jsx("input",{autoFocus:!0,value:Z,onChange:ae=>K(ae.target.value),onKeyDown:ae=>{ae.key==="Enter"?(ae.preventDefault(),ae.currentTarget.blur()):ae.key==="Escape"&&(G.current=!0,ae.currentTarget.blur())},onBlur:()=>{if(G.current){G.current=!1,q(null);return}I(Y)},placeholder:"对话名称",className:"block w-full rounded-lg border border-accent bg-surface py-2 pl-7 pr-3 text-[13px] text-content-primary outline-none"}):k.jsxs("button",{onClick:()=>h(Y.id),className:`block w-full cursor-pointer rounded-lg py-2 pl-7 pr-9 text-left transition-colors duration-150 hover:bg-surface-overlay ${Y.id===a?"tree-row-active":""}`,children:[k.jsxs("p",{className:"flex items-center gap-2",children:[k.jsx("span",{className:"truncate text-[13px] text-content-primary",children:U}),k.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${J.className}`,children:[J.pulsing&&k.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),J.text]}),Y.archived&&k.jsx("span",{className:"shrink-0 rounded bg-surface-overlay px-1 text-2xs text-content-faint",children:"已归档"})]}),Y.lastMessagePreview&&Y.lastMessagePreview.trim()!==U&&k.jsx("p",{className:"mt-0.5 truncate text-2xs text-content-muted",children:Y.lastMessagePreview})]}),!me&&k.jsx("button",{onClick:ae=>{ae.stopPropagation(),H(null),L(oe?null:Y.id)},className:`absolute right-1.5 top-1.5 cursor-pointer rounded-md p-1 text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-primary ${oe?"opacity-100":"opacity-0 group-hover:opacity-100"}`,title:"更多操作","aria-label":"更多操作",children:k.jsx(kS,{size:14})}),oe&&k.jsxs(k.Fragment,{children:[k.jsx("button",{className:"fixed inset-0 z-10 cursor-default",onClick:te,"aria-label":"关闭菜单"}),k.jsxs("div",{className:"absolute right-1.5 top-9 z-20 w-36 overflow-hidden rounded-lg border border-border bg-surface py-1 shadow-xl",children:[k.jsxs("button",{onClick:()=>ee(Y),className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[k.jsx(ef,{size:13})," 改名"]}),k.jsxs("button",{onClick:()=>{o.setConversationArchived(Y.id,!Y.archived),te()},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[k.jsx(c_,{size:13})," ",Y.archived?"取消归档":"归档"]}),k.jsxs("button",{onClick:()=>{P===Y.id?(o.deleteConversation(Y.id),te()):H(Y.id)},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-danger transition-colors hover:bg-danger/10",children:[k.jsx(CS,{size:13})," ",P===Y.id?"确认删除?":"删除"]})]})]})]},Y.id)})]},B)})]},T.cwd)})}),w>0&&k.jsxs("button",{onClick:()=>C(T=>!T),className:"flex items-center gap-2 border-t border-border px-3 py-2.5 text-left text-2xs text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-secondary",children:[k.jsx(c_,{size:13,className:"shrink-0"}),S?"隐藏已归档":`显示已归档 (${w})`]})]})}const CO={none:"无",minimal:"极简",low:"低",medium:"中",high:"高",xhigh:"极高"},kO={read_only:"只读",workspace_write:"工作区写",full_access:"完全访问"};function fd({icon:e,value:n,options:r,render:a,onChange:l,title:u}){const[f,o]=ie.useState(!1),h=ie.useRef(null);if(ie.useEffect(()=>{if(!f)return;const m=p=>{h.current&&!h.current.contains(p.target)&&o(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[f]),r.length===0)return null;const d=n??r[0];return k.jsxs("div",{ref:h,className:"relative",children:[k.jsxs("button",{type:"button",onClick:()=>o(m=>!m),title:u,className:"flex cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium text-content-secondary transition-colors hover:bg-surface-overlay hover:text-content-primary",children:[e,k.jsx("span",{className:"max-w-[7rem] truncate",children:a(d)}),k.jsx(Mr,{size:11,className:"text-content-faint"})]}),f&&k.jsx("div",{className:"codex-card-raised absolute bottom-full left-0 z-20 mb-1.5 min-w-[8rem] overflow-hidden p-1 animate-fade-in",children:r.map(m=>k.jsxs("button",{type:"button",onClick:()=>{l(m),o(!1)},className:`flex w-full cursor-pointer items-center justify-between gap-3 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors hover:bg-surface-overlay ${m===d?"text-content-primary":"text-content-secondary"}`,children:[k.jsx("span",{className:"truncate",children:a(m)}),m===d&&k.jsx(No,{size:13,className:"shrink-0 text-accent"})]},m))})]})}function TO({conversation:e,capability:n,onChange:r}){var d;const l=((n==null?void 0:n.models)??[]).filter(m=>m.id!=="default"),u=(n==null?void 0:n.reasoningEfforts)??[],f=(n==null?void 0:n.permissionModes)??[],o=(n==null?void 0:n.supportsPlan)??!1,h=e.collaborationMode==="plan";return k.jsxs(k.Fragment,{children:[l.length>0&&k.jsx(fd,{title:"模型",value:e.model??(n==null?void 0:n.defaultModel)??((d=l[0])==null?void 0:d.id),options:l.map(m=>m.id),render:m=>{var p;return((p=l.find(x=>x.id===m))==null?void 0:p.label)??m},onChange:m=>r({model:m})}),k.jsx(fd,{title:"推理强度",value:e.reasoningEffort,options:u,render:m=>CO[m]??m,onChange:m=>r({reasoningEffort:m})}),k.jsx(fd,{title:"权限",value:e.permissionMode,options:f,render:m=>kO[m]??m,onChange:m=>r({permissionMode:m})}),o&&k.jsxs("button",{type:"button",onClick:()=>r({collaborationMode:h?"default":"plan"}),className:`inline-flex cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium transition-colors ${h?"bg-accent-dim text-white":"text-content-secondary hover:bg-surface-overlay hover:text-content-primary"}`,title:"计划模式",children:[h&&k.jsx(No,{size:11}),"计划"]})]})}function AO({store:e,initialPath:n,onClose:r}){const[a,l]=ie.useState(n||"."),[u,f]=ie.useState([]),[o,h]=ie.useState(!1),[d,m]=ie.useState(null),[p,x]=ie.useState(null),S=ie.useCallback(async _=>{h(!0),m(null),x(null);try{const b=await e.browse(_,!0);b.error?m(b.error):(l(b.path),f([...b.entries].sort((v,y)=>v.isDirectory!==y.isDirectory?v.isDirectory?-1:1:v.name.localeCompare(y.name))))}catch(b){m(b.message||"浏览失败")}finally{h(!1)}},[e]);ie.useEffect(()=>{S(n||".")},[S,n]);const C=async _=>{h(!0),m(null);try{const b=await e.readFile(_.path);b.error?m(b.error):x({path:b.path,content:b.content,truncated:b.truncated})}catch(b){m(b.message||"读取失败")}finally{h(!1)}},w=a.replace(/\/+$/,"").split("/").slice(0,-1).join("/")||"/";return k.jsxs("div",{className:"flex h-full flex-col bg-surface",children:[k.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[k.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-2xs text-content-secondary",children:[k.jsx(Nr,{size:13,className:"text-content-faint"})," 文件"]}),k.jsx("button",{onClick:r,className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭文件面板",children:k.jsx(gi,{size:15})})]}),k.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-2 py-1.5",children:[k.jsx("button",{onClick:()=>S(w),disabled:o,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"上级目录","aria-label":"上级目录",children:k.jsx(Xd,{size:14})}),k.jsx("input",{value:a,onChange:_=>l(_.target.value),onKeyDown:_=>_.key==="Enter"&&S(a),className:"flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none"}),k.jsx("button",{onClick:()=>S(a),disabled:o,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"刷新","aria-label":"刷新",children:k.jsx(Sc,{size:14})})]}),d&&k.jsx("p",{className:"px-3 py-1.5 text-2xs text-danger",children:d}),k.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[o&&k.jsx("p",{className:"px-3 py-2 text-2xs text-content-muted",children:"加载中…"}),!o&&p?k.jsxs("div",{children:[k.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[k.jsx("span",{className:"truncate font-mono text-2xs text-content-secondary",children:p.path}),k.jsx("button",{onClick:()=>x(null),className:"codex-btn-ghost text-2xs",children:"返回"})]}),k.jsxs("pre",{className:"whitespace-pre-wrap px-3 py-2 font-mono text-2xs leading-relaxed text-content-secondary",children:[p.content,p.truncated&&k.jsx("span",{className:"text-warning",children:`
92
+ `,v)}paste(b){this._core.paste(b)}refresh(b,v){this._verifyIntegers(b,v),this._core.refresh(b,v)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(b){this._addonManager.loadAddon(this,b)}static get strings(){return o}_verifyIntegers(...b){for(const v of b)if(v===1/0||isNaN(v)||v%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...b){for(const v of b)if(v&&(v===1/0||isNaN(v)||v%1!=0||v<0))throw new Error("This API only accepts positive integers")}}f.Terminal=w})(),u})()))})(ud)),ud.exports}var hO=uO(),hd={exports:{}},Pv;function dO(){return Pv||(Pv=1,(function(e,n){(function(r,a){e.exports=a()})(self,(()=>(()=>{var r={};return(()=>{var a=r;Object.defineProperty(a,"__esModule",{value:!0}),a.FitAddon=void 0,a.FitAddon=class{activate(l){this._terminal=l}dispose(){}fit(){const l=this.proposeDimensions();if(!l||!this._terminal||isNaN(l.cols)||isNaN(l.rows))return;const u=this._terminal._core;this._terminal.rows===l.rows&&this._terminal.cols===l.cols||(u._renderService.clear(),this._terminal.resize(l.cols,l.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const l=this._terminal._core,u=l._renderService.dimensions;if(u.css.cell.width===0||u.css.cell.height===0)return;const f=this._terminal.options.scrollback===0?0:l.viewport.scrollBarWidth,o=window.getComputedStyle(this._terminal.element.parentElement),h=parseInt(o.getPropertyValue("height")),d=Math.max(0,parseInt(o.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),p=h-(parseInt(m.getPropertyValue("padding-top"))+parseInt(m.getPropertyValue("padding-bottom"))),x=d-(parseInt(m.getPropertyValue("padding-right"))+parseInt(m.getPropertyValue("padding-left")))-f;return{cols:Math.max(2,Math.floor(x/u.css.cell.width)),rows:Math.max(1,Math.floor(p/u.css.cell.height))}}}})(),r})()))})(hd)),hd.exports}var fO=dO();function as(e,n){const r=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return r?`rgb(${r})`:n}function pO(e,n,r){const a=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return a?`rgb(${a} / ${n})`:r}function zv(){return{background:as("--c-canvas","#0b0d0f"),foreground:as("--c-content-primary","#e6e8eb"),cursor:as("--c-accent","#2dd4bf"),selectionBackground:pO("--c-accent",.22,"rgba(45,212,191,0.25)"),black:as("--c-content-faint","#4e535a"),brightBlack:as("--c-content-muted","#70767e"),white:as("--c-content-secondary","#9ea5ad"),brightWhite:as("--c-content-primary","#e9ebee")}}function mO(e,n){const r=ie.useRef(null),a=ie.useRef(null),l=ie.useRef(null);return ie.useEffect(()=>{if(!r.current||!e)return;const u=new hO.Terminal({fontFamily:"JetBrains Mono, ui-monospace, monospace",fontSize:13,cursorBlink:!0,theme:zv(),scrollback:5e3}),f=new fO.FitAddon;u.loadAddon(f),u.open(r.current),f.fit(),a.current=u,l.current=f;const o=e.terminalBuffer(n);o&&u.write(o);const h=u.onData(S=>e.sendInput(n,S)),d=u.onResize(({cols:S,rows:C})=>e.sendResize(n,S,C)),m=e.onEvent(S=>{if(S.type==="terminal.reset"&&S.terminalId===n){u.reset();return}S.type==="terminal.output"&&S.terminalId===n&&u.write(S.data)}),p=new ResizeObserver(()=>{try{f.fit(),e.sendResize(n,u.cols,u.rows)}catch{}});p.observe(r.current);const x=new MutationObserver(()=>{u.options.theme=zv()});return x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),e.sendResize(n,u.cols,u.rows),()=>{h.dispose(),d.dispose(),m(),p.disconnect(),x.disconnect(),u.dispose(),a.current=null,l.current=null}},[e,n]),{containerRef:r}}function jv(e,n){return e==="default"?"默认":n||e.slice(0,8)}const Zy=e=>`linkshell:web:lastTerminal:${e}`;function gO(e){if(!e)return null;try{return localStorage.getItem(Zy(e))}catch{return null}}function _O(e,n){if(e)try{localStorage.setItem(Zy(e),n)}catch{}}function vO(e,n){if(e.length===0)return null;if(n&&e.includes(n))return n;const r=e.filter(a=>a!=="default");return r.length>0?r[r.length-1]:e[0]}function bO({bridge:e,terminalId:n}){const{containerRef:r}=mO(e,n);return k.jsx("div",{ref:r,className:"xterm-host min-h-0 flex-1 bg-canvas p-2"})}function yO({bridge:e,onNewTerminal:n}){const r=e==null?void 0:e.sessionId,[a,l]=ie.useState([]),[u,f]=ie.useState("default"),o=ie.useRef(!1),h=ie.useRef(!1),d=ie.useCallback((x,S)=>{l(C=>C.some(w=>w.id===x)?C:[...C,{id:x,label:jv(x,S)}])},[]);ie.useEffect(()=>{if(!e)return;o.current=!1,h.current=!1;const x=gO(r);return e.requestTerminalList(),e.onEvent(C=>{if(C.type==="terminal.output"){d(C.terminalId);return}if(C.type==="terminal.list"){const w=C.envelope,_=w.payload;if(w.type==="terminal.spawned"){const b=_==null?void 0:_.terminalId;b&&(d(b,_==null?void 0:_.projectName),f(b));return}if(w.type==="terminal.list"){const y=(Array.isArray(_==null?void 0:_.terminals)?_.terminals:[]).filter(A=>typeof A.terminalId=="string"&&A.status!=="exited").map(A=>({id:A.terminalId,label:jv(A.terminalId,A.projectName)}));if(l(y),!o.current){o.current=!0;const A=y.map(R=>R.id),M=vO(A,x);M?f(M):h.current||(h.current=!0,n==null||n())}}}})},[e,d,n]),ie.useEffect(()=>{o.current&&u&&_O(r,u)},[r,u]);const m=()=>n==null?void 0:n(),p=x=>{e==null||e.killTerminal(x),l(S=>{var w;const C=S.filter(_=>_.id!==x);return x===u&&f(((w=C[C.length-1])==null?void 0:w.id)??"default"),C})};return k.jsxs("div",{className:"flex h-full flex-col bg-canvas",children:[k.jsxs("div",{className:"flex items-center gap-0.5 border-b border-border bg-surface-raised px-1.5 py-1",children:[k.jsx(_d,{size:13,className:"mx-1 shrink-0 text-content-faint"}),k.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto",children:a.map(x=>k.jsxs("div",{className:`group flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-2xs transition-colors ${x.id===u?"bg-surface-overlay text-content-primary":"text-content-muted hover:bg-surface-overlay/60"}`,children:[k.jsx("button",{onClick:()=>f(x.id),className:"cursor-pointer font-mono",children:x.label}),a.length>1&&k.jsx("button",{onClick:()=>p(x.id),className:"cursor-pointer rounded text-content-faint opacity-0 transition hover:text-danger group-hover:opacity-100","aria-label":"关闭终端",children:k.jsx(gi,{size:11})})]},x.id))}),k.jsx("button",{onClick:m,className:"ml-1 shrink-0 cursor-pointer rounded-md p-1 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"新建终端","aria-label":"新建终端",children:k.jsx(Ro,{size:14})})]}),k.jsx(bO,{bridge:e,terminalId:u},u)]})}function Xy(e){if(!e||e==="—")return"(未知目录)";const n=e.replace(/\/+$/,"").split("/");return n[n.length-1]||e}function Uv(e,n){return e.status==="waiting_permission"?0:e.status==="running"?1:e.status==="error"?2:e.id===n?3:4}function xO(e){return(n,r)=>{const a=Uv(n,e)-Uv(r,e);return a!==0?a:r.lastActivityAt-n.lastActivityAt}}function SO(e){return e.status==="waiting_permission"||e.status==="running"||e.status==="error"}function EO(e){const n=new Map;for(const a of e){const l=a.cwd||"—";let u=n.get(l);u||(u={cwd:l,label:Xy(l),providers:new Map},n.set(l,u));const f=u.providers.get(a.provider)??[];f.push(a),u.providers.set(a.provider,f)}for(const a of n.values())for(const l of a.providers.values())l.sort((u,f)=>f.lastActivityAt-u.lastActivityAt);const r=a=>{let l=0;for(const u of a.providers.values())for(const f of u)l=Math.max(l,f.lastActivityAt);return l};return[...n.values()].sort((a,l)=>r(l)-r(a))}function wO(e){return[...e.providers.entries()].map(([n,r])=>({provider:n,conversations:r})).sort((n,r)=>qd(n.provider).localeCompare(qd(r.provider)))}function qd(e){return e==="claude"?"Claude":e==="codex"?"Codex":e}function dd(e){switch(e){case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"waiting_permission":return{text:"等待授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};case"unavailable":return{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"};case"idle":default:return{text:"空闲",className:"border-border bg-surface-overlay text-content-muted"}}}function Hv({deviceLabel:e,conversations:n,capabilities:r,activeConversationId:a,externalAgentStatus:l,externalAgentTitle:u,externalAgentProvider:f,store:o,onSelect:h,onNewConversation:d,onOpenExternalTerminal:m}){const x=((r==null?void 0:r.providers)??[]).filter(T=>T.enabled),[S,C]=ie.useState(!1),w=ie.useMemo(()=>n.filter(T=>T.archived).length,[n]),_=ie.useMemo(()=>S?n:n.filter(T=>!T.archived),[n,S]),b=ie.useMemo(()=>_.filter(SO).sort(xO(a)),[_,a]),v=l==="running"||l==="waiting_permission"||l==="error",y=v||b.length>0,A=ie.useMemo(()=>EO(_),[_]),[M,R]=ie.useState(new Set),O=T=>R(z=>{const F=new Set(z);return F.has(T)?F.delete(T):F.add(T),F}),[N,L]=ie.useState(null),[P,H]=ie.useState(null),[$,q]=ie.useState(null),[Z,K]=ie.useState(""),G=ie.useRef(!1),te=()=>{L(null),H(null)},ee=T=>{te(),q(T.id),K(T.title&&T.title.trim()||"")},I=T=>{o.renameConversation(T.id,Z),q(null)};return k.jsxs("div",{className:"flex h-full flex-col",children:[k.jsxs("div",{className:"flex items-center gap-2.5 border-b border-border px-3 py-3",children:[k.jsx(vS,{size:14,className:"shrink-0 text-content-faint"}),k.jsx("span",{className:"truncate font-mono text-[13px] font-semibold text-content-secondary",children:e})]}),k.jsxs("div",{className:"space-y-2 border-b border-border px-3 py-3",children:[k.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"新建对话"}),x.length===0?k.jsx("span",{className:"text-2xs text-content-faint",children:"等待能力…"}):k.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(T=>k.jsxs("button",{onClick:()=>d(T.id),className:"codex-btn-outline text-2xs","aria-label":`新建 ${T.label} 对话`,children:[k.jsx(ea,{provider:T.id,size:13})," ",T.label]},T.id))})]}),y&&k.jsxs("div",{className:"border-b border-border px-3 py-3",children:[k.jsx("p",{className:"mb-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"活跃会话"}),k.jsxs("div",{className:"space-y-1",children:[v&&l&&k.jsxs("button",{onClick:m,className:"flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay",title:"打开终端面板",children:[k.jsx(ea,{provider:f??"custom",size:14}),k.jsxs("span",{className:"min-w-0 flex-1",children:[k.jsxs("span",{className:"flex items-center gap-2",children:[k.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:u??"外部终端"}),(()=>{const T=dd(l);return k.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${T.className}`,children:[T.pulsing&&k.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),T.text]})})()]}),k.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:e})]})]},"active:external-terminal"),b.map(T=>{const z=T.title&&T.title.trim()||T.lastMessagePreview&&T.lastMessagePreview.trim().slice(0,40)||`对话 ${T.id.slice(-6)}`,F=dd(T.status);return k.jsxs("button",{onClick:()=>h(T.id),className:`flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay ${T.id===a?"tree-row-active":""}`,title:T.cwd,children:[k.jsx(ea,{provider:T.provider,size:14}),k.jsxs("span",{className:"min-w-0 flex-1",children:[k.jsxs("span",{className:"flex items-center gap-2",children:[k.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:z}),k.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${F.className}`,children:[F.pulsing&&k.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),F.text]})]}),k.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:Xy(T.cwd)})]})]},`active:${T.id}`)})]})]}),k.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:A.length===0?k.jsx("p",{className:"px-3 py-2 text-2xs text-content-faint",children:S||w===0?"还没有对话":"没有未归档的对话"}):A.map(T=>{const z=`folder:${T.cwd}`,F=M.has(z);return k.jsxs("div",{className:"py-1",children:[k.jsxs("button",{onClick:()=>O(z),className:"tree-row",title:T.cwd,children:[F?k.jsx(vi,{size:12,className:"shrink-0 text-content-faint"}):k.jsx(Mr,{size:12,className:"shrink-0 text-content-faint"}),k.jsx(Nr,{size:13,className:"shrink-0 text-content-faint"}),k.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-content-faint",children:T.label})]}),!F&&wO(T).map(({provider:B,conversations:le})=>{const xe=`prov:${T.cwd}:${B}`,fe=M.has(xe);return k.jsxs("div",{className:"pl-3",children:[k.jsxs("div",{className:"flex items-center gap-1",children:[k.jsxs("button",{onClick:()=>O(xe),className:"tree-row flex-1",children:[fe?k.jsx(vi,{size:12,className:"shrink-0 text-content-faint"}):k.jsx(Mr,{size:12,className:"shrink-0 text-content-faint"}),k.jsx(ea,{provider:B,size:13}),k.jsx("span",{className:"text-[13px] font-medium text-content-secondary",children:qd(B)}),k.jsxs("span",{className:"text-2xs text-content-faint",children:["(",le.length,")"]})]}),k.jsx("button",{onClick:()=>d(B,T.cwd==="—"?void 0:T.cwd),className:"cursor-pointer rounded-lg p-1.5 text-content-faint transition-colors hover:bg-surface-overlay hover:text-accent",title:"在此目录新建对话","aria-label":"新建对话",children:k.jsx(Ro,{size:13})})]}),!fe&&le.map(Y=>{const U=Y.title&&Y.title.trim()||Y.lastMessagePreview&&Y.lastMessagePreview.trim().slice(0,40)||`对话 ${Y.id.slice(-6)}`,me=$===Y.id,oe=N===Y.id,J=dd(Y.status);return k.jsxs("div",{className:"group relative",children:[me?k.jsx("input",{autoFocus:!0,value:Z,onChange:ae=>K(ae.target.value),onKeyDown:ae=>{ae.key==="Enter"?(ae.preventDefault(),ae.currentTarget.blur()):ae.key==="Escape"&&(G.current=!0,ae.currentTarget.blur())},onBlur:()=>{if(G.current){G.current=!1,q(null);return}I(Y)},placeholder:"对话名称",className:"block w-full rounded-lg border border-accent bg-surface py-2 pl-7 pr-3 text-[13px] text-content-primary outline-none"}):k.jsxs("button",{onClick:()=>h(Y.id),className:`block w-full cursor-pointer rounded-lg py-2 pl-7 pr-9 text-left transition-colors duration-150 hover:bg-surface-overlay ${Y.id===a?"tree-row-active":""}`,children:[k.jsxs("p",{className:"flex items-center gap-2",children:[k.jsx("span",{className:"truncate text-[13px] text-content-primary",children:U}),k.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${J.className}`,children:[J.pulsing&&k.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),J.text]}),Y.archived&&k.jsx("span",{className:"shrink-0 rounded bg-surface-overlay px-1 text-2xs text-content-faint",children:"已归档"})]}),Y.lastMessagePreview&&Y.lastMessagePreview.trim()!==U&&k.jsx("p",{className:"mt-0.5 truncate text-2xs text-content-muted",children:Y.lastMessagePreview})]}),!me&&k.jsx("button",{onClick:ae=>{ae.stopPropagation(),H(null),L(oe?null:Y.id)},className:`absolute right-1.5 top-1.5 cursor-pointer rounded-md p-1 text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-primary ${oe?"opacity-100":"opacity-0 group-hover:opacity-100"}`,title:"更多操作","aria-label":"更多操作",children:k.jsx(kS,{size:14})}),oe&&k.jsxs(k.Fragment,{children:[k.jsx("button",{className:"fixed inset-0 z-10 cursor-default",onClick:te,"aria-label":"关闭菜单"}),k.jsxs("div",{className:"absolute right-1.5 top-9 z-20 w-36 overflow-hidden rounded-lg border border-border bg-surface py-1 shadow-xl",children:[k.jsxs("button",{onClick:()=>ee(Y),className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[k.jsx(ef,{size:13})," 改名"]}),k.jsxs("button",{onClick:()=>{o.setConversationArchived(Y.id,!Y.archived),te()},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[k.jsx(c_,{size:13})," ",Y.archived?"取消归档":"归档"]}),k.jsxs("button",{onClick:()=>{P===Y.id?(o.deleteConversation(Y.id),te()):H(Y.id)},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-danger transition-colors hover:bg-danger/10",children:[k.jsx(CS,{size:13})," ",P===Y.id?"确认删除?":"删除"]})]})]})]},Y.id)})]},B)})]},T.cwd)})}),w>0&&k.jsxs("button",{onClick:()=>C(T=>!T),className:"flex items-center gap-2 border-t border-border px-3 py-2.5 text-left text-2xs text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-secondary",children:[k.jsx(c_,{size:13,className:"shrink-0"}),S?"隐藏已归档":`显示已归档 (${w})`]})]})}const CO={none:"无",minimal:"极简",low:"低",medium:"中",high:"高",xhigh:"极高"},kO={read_only:"只读",workspace_write:"工作区写",full_access:"完全访问"};function fd({icon:e,value:n,options:r,render:a,onChange:l,title:u}){const[f,o]=ie.useState(!1),h=ie.useRef(null);if(ie.useEffect(()=>{if(!f)return;const m=p=>{h.current&&!h.current.contains(p.target)&&o(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[f]),r.length===0)return null;const d=n??r[0];return k.jsxs("div",{ref:h,className:"relative",children:[k.jsxs("button",{type:"button",onClick:()=>o(m=>!m),title:u,className:"flex cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium text-content-secondary transition-colors hover:bg-surface-overlay hover:text-content-primary",children:[e,k.jsx("span",{className:"max-w-[7rem] truncate",children:a(d)}),k.jsx(Mr,{size:11,className:"text-content-faint"})]}),f&&k.jsx("div",{className:"codex-card-raised absolute bottom-full left-0 z-20 mb-1.5 min-w-[8rem] overflow-hidden p-1 animate-fade-in",children:r.map(m=>k.jsxs("button",{type:"button",onClick:()=>{l(m),o(!1)},className:`flex w-full cursor-pointer items-center justify-between gap-3 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors hover:bg-surface-overlay ${m===d?"text-content-primary":"text-content-secondary"}`,children:[k.jsx("span",{className:"truncate",children:a(m)}),m===d&&k.jsx(No,{size:13,className:"shrink-0 text-accent"})]},m))})]})}function TO({conversation:e,capability:n,onChange:r}){var d;const l=((n==null?void 0:n.models)??[]).filter(m=>m.id!=="default"),u=(n==null?void 0:n.reasoningEfforts)??[],f=(n==null?void 0:n.permissionModes)??[],o=(n==null?void 0:n.supportsPlan)??!1,h=e.collaborationMode==="plan";return k.jsxs(k.Fragment,{children:[l.length>0&&k.jsx(fd,{title:"模型",value:e.model??(n==null?void 0:n.defaultModel)??((d=l[0])==null?void 0:d.id),options:l.map(m=>m.id),render:m=>{var p;return((p=l.find(x=>x.id===m))==null?void 0:p.label)??m},onChange:m=>r({model:m})}),k.jsx(fd,{title:"推理强度",value:e.reasoningEffort,options:u,render:m=>CO[m]??m,onChange:m=>r({reasoningEffort:m})}),k.jsx(fd,{title:"权限",value:e.permissionMode,options:f,render:m=>kO[m]??m,onChange:m=>r({permissionMode:m})}),o&&k.jsxs("button",{type:"button",onClick:()=>r({collaborationMode:h?"default":"plan"}),className:`inline-flex cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium transition-colors ${h?"bg-accent-dim text-white":"text-content-secondary hover:bg-surface-overlay hover:text-content-primary"}`,title:"计划模式",children:[h&&k.jsx(No,{size:11}),"计划"]})]})}function AO({store:e,initialPath:n,onClose:r}){const[a,l]=ie.useState(n||"."),[u,f]=ie.useState([]),[o,h]=ie.useState(!1),[d,m]=ie.useState(null),[p,x]=ie.useState(null),S=ie.useCallback(async _=>{h(!0),m(null),x(null);try{const b=await e.browse(_,!0);b.error?m(b.error):(l(b.path),f([...b.entries].sort((v,y)=>v.isDirectory!==y.isDirectory?v.isDirectory?-1:1:v.name.localeCompare(y.name))))}catch(b){m(b.message||"浏览失败")}finally{h(!1)}},[e]);ie.useEffect(()=>{S(n||".")},[S,n]);const C=async _=>{h(!0),m(null);try{const b=await e.readFile(_.path);b.error?m(b.error):x({path:b.path,content:b.content,truncated:b.truncated})}catch(b){m(b.message||"读取失败")}finally{h(!1)}},w=a.replace(/\/+$/,"").split("/").slice(0,-1).join("/")||"/";return k.jsxs("div",{className:"flex h-full flex-col bg-surface",children:[k.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[k.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-2xs text-content-secondary",children:[k.jsx(Nr,{size:13,className:"text-content-faint"})," 文件"]}),k.jsx("button",{onClick:r,className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭文件面板",children:k.jsx(gi,{size:15})})]}),k.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-2 py-1.5",children:[k.jsx("button",{onClick:()=>S(w),disabled:o,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"上级目录","aria-label":"上级目录",children:k.jsx(Xd,{size:14})}),k.jsx("input",{value:a,onChange:_=>l(_.target.value),onKeyDown:_=>_.key==="Enter"&&S(a),className:"flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none"}),k.jsx("button",{onClick:()=>S(a),disabled:o,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"刷新","aria-label":"刷新",children:k.jsx(Sc,{size:14})})]}),d&&k.jsx("p",{className:"px-3 py-1.5 text-2xs text-danger",children:d}),k.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[o&&k.jsx("p",{className:"px-3 py-2 text-2xs text-content-muted",children:"加载中…"}),!o&&p?k.jsxs("div",{children:[k.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[k.jsx("span",{className:"truncate font-mono text-2xs text-content-secondary",children:p.path}),k.jsx("button",{onClick:()=>x(null),className:"codex-btn-ghost text-2xs",children:"返回"})]}),k.jsxs("pre",{className:"whitespace-pre-wrap px-3 py-2 font-mono text-2xs leading-relaxed text-content-secondary",children:[p.content,p.truncated&&k.jsx("span",{className:"text-warning",children:`
93
93
  …(已截断)`})]})]}):!o&&u.map(_=>k.jsxs("button",{onClick:()=>_.isDirectory?S(_.path):C(_),className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-surface-overlay",children:[_.isDirectory?k.jsx(Nr,{size:13,className:"shrink-0 text-content-faint"}):k.jsx(na,{size:13,className:"shrink-0 text-content-faint"}),k.jsx("span",{className:"truncate font-mono text-2xs text-content-primary",children:_.name}),!_.isDirectory&&_.size!=null&&k.jsxs("span",{className:"ml-auto font-mono text-2xs text-content-faint",children:[_.size,"B"]})]},_.path))]})]})}function RO({store:e,initialPath:n,providerLabel:r,onCancel:a,onConfirm:l}){const[u,f]=ie.useState(n||"."),[o,h]=ie.useState([]),[d,m]=ie.useState(!1),[p,x]=ie.useState(null),S=ie.useCallback(async w=>{m(!0),x(null);try{const _=await e.browse(w,!1);_.error?x(_.error):(f(_.path),h(_.entries.filter(b=>b.isDirectory).sort((b,v)=>b.name.localeCompare(v.name))))}catch(_){x(_.message||"无法读取目录")}finally{m(!1)}},[e]);ie.useEffect(()=>{S(n||".")},[S,n]);const C=u.replace(/\/+$/,"").split("/").slice(0,-1).join("/")||"/";return k.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:a,children:k.jsxs("div",{className:"codex-card flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden",onClick:w=>w.stopPropagation(),children:[k.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[k.jsxs("h3",{className:"text-sm font-semibold",children:["选择工作目录 · ",r]}),k.jsx("button",{onClick:a,className:"codex-btn-ghost px-2 py-1.5","aria-label":"取消",children:k.jsx(gi,{size:15})})]}),k.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-3 py-2",children:[k.jsx("button",{onClick:()=>S(C),disabled:d,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"上级目录","aria-label":"上级目录",children:k.jsx(Xd,{size:14})}),k.jsx("input",{value:u,onChange:w=>f(w.target.value),onKeyDown:w=>w.key==="Enter"&&S(u),className:"flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none"}),k.jsx("button",{onClick:()=>S(u),disabled:d,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"刷新","aria-label":"刷新",children:k.jsx(Sc,{size:14})})]}),p&&k.jsx("p",{className:"px-4 py-2 text-2xs text-danger",children:p}),k.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d?k.jsx("p",{className:"px-4 py-3 text-2xs text-content-muted",children:"加载中…"}):o.length===0?k.jsx("p",{className:"px-4 py-3 text-2xs text-content-faint",children:"(无子目录)"}):o.map(w=>k.jsxs("button",{onClick:()=>S(w.path),className:"flex w-full cursor-pointer items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-surface-overlay",children:[k.jsx(Nr,{size:13,className:"shrink-0 text-content-faint"}),k.jsx("span",{className:"truncate font-mono text-2xs text-content-primary",children:w.name})]},w.path))}),k.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border px-4 py-3",children:[k.jsxs("span",{className:"truncate font-mono text-2xs text-content-muted",title:u,children:["将在此创建:",u]}),k.jsx("button",{onClick:()=>l(u),disabled:d,className:"codex-btn-primary text-2xs",children:"在此新建"})]})]})})}const Qy=[{cssProp:"color",label:"文本颜色"},{cssProp:"background-color",label:"背景"},{cssProp:"font-size",label:"字号"},{cssProp:"font-weight",label:"字重"},{cssProp:"padding",label:"内边距"},{cssProp:"border-radius",label:"圆角"}];function NO(e){var a;const n=(a=e.ownerDocument.defaultView)==null?void 0:a.getComputedStyle(e),r={};for(const{cssProp:l}of Qy)r[l]=(n==null?void 0:n.getPropertyValue(l).trim())??"";return r}function MO(e){const n=/^\s*(\d{1,5})(.*)$/.exec(e);if(!n)return null;const r=n[1];if(Number(r)<1||Number(r)>65535)return null;let a=n[2]||"/";return a.startsWith("/")||(a=`/${a}`),{port:r,path:a}}function OO(e){if(e.id)return`#${CSS.escape(e.id)}`;const n=[];let r=e,a=0;for(;r&&r.nodeType===1&&a<4;){let l=r.tagName.toLowerCase();const u=(r.getAttribute("class")||"").trim().split(/\s+/).filter(Boolean).slice(0,2).map(o=>`.${CSS.escape(o)}`).join("");l+=u;const f=r.parentElement;if(f){const o=[...f.children].filter(h=>h.tagName===r.tagName);o.length>1&&(l+=`:nth-of-type(${o.indexOf(r)+1})`)}if(n.unshift(l),r.id){n[0]=`#${CSS.escape(r.id)}`;break}r=f,a+=1}return n.join(" > ")}function DO({gatewayUrl:e,sessionId:n,initialAuthToken:r,defaultPort:a,isMobile:l,onClose:u,onAnnotate:f}){const[o,h]=ie.useState(a||"3000"),[d,m]=ie.useState(null),[p,x]=ie.useState(r??null),[S,C]=ie.useState(!1),[w,_]=ie.useState("desktop"),[b,v]=ie.useState(0),[y,A]=ie.useState(!1),[M,R]=ie.useState(null),[O,N]=ie.useState(null),[L,P]=ie.useState(null),[H,$]=ie.useState(""),[q,Z]=ie.useState(!1),[K,G]=ie.useState({}),[te,ee]=ie.useState({}),I=ie.useRef(null),T=ie.useRef(null),z=ie.useMemo(()=>Jv(),[]);ie.useEffect(()=>{let Te=!1;return C(!1),Zd().then(ke=>{Te||x((ke==null?void 0:ke.accessToken)??null)}).finally(()=>{Te||C(!0)}),()=>{Te=!0}},[r]);const F=ie.useMemo(()=>{if(!d||r&&!S)return null;const Te=`${e.replace(/\/+$/,"")}/tunnel/${encodeURIComponent(n)}/${d.port}${d.path}`,ke=[];if(z&&ke.push(`token=${encodeURIComponent(z)}`),p&&ke.push(`auth_token=${encodeURIComponent(p)}`),ke.length===0)return Te;const pe=d.path.includes("?")?"&":"?";return`${Te}${pe}${ke.join("&")}`},[d,e,n,z,p,S]),B=()=>{const Te=MO(o);Te&&(m(Te),v(ke=>ke+1))},le=()=>v(Te=>Te+1),xe=()=>{var Te;if(d)try{const ke=(Te=I.current)==null?void 0:Te.contentWindow;if(!ke)return;const pe=`/tunnel/${encodeURIComponent(n)}/${d.port}`;let lt=ke.location.pathname;lt.startsWith(pe)&&(lt=lt.slice(pe.length)||"/");const Ae=new URLSearchParams(ke.location.search);Ae.delete("token"),Ae.delete("auth_token");const Ft=Ae.toString();h(`${d.port}${lt}${Ft?`?${Ft}`:""}`)}catch{}},fe=(Te,ke)=>{const pe=I.current,lt=pe==null?void 0:pe.contentDocument;if(!pe||!lt)return null;const Ae=pe.getBoundingClientRect();return lt.elementFromPoint(Te-Ae.left,ke-Ae.top)},Y=Te=>{const ke=Te.getBoundingClientRect();return{top:ke.top,left:ke.left,width:ke.width,height:ke.height}},U=Te=>{try{const ke=fe(Te.clientX,Te.clientY);N(ke?Y(ke):null)}catch{N(null),R("此页面跨域,无法读取元素(生产环境同源可用)"),A(!1)}},me=Te=>{Te.preventDefault();try{const ke=fe(Te.clientX,Te.clientY);if(!ke||!("style"in ke))return;const pe=ke;P({el:pe,selector:OO(pe),text:(pe.textContent||"").replace(/\s+/g," ").trim().slice(0,120),rect:Y(pe)}),G(NO(pe)),ee({}),$("")}catch{R("此页面跨域,无法读取元素(生产环境同源可用)"),A(!1)}},oe=(Te,ke)=>{if(L){try{L.el.style.setProperty(Te,ke)}catch{}ee(pe=>({...pe,[Te]:ke}))}},J=()=>Object.entries(te).filter(([Te,ke])=>ke!==(K[Te]??"")).map(([Te,ke])=>({cssProp:Te,from:K[Te]??"",to:ke})),ae=()=>{if(!L)return;const Te=J(),ke=["关于预览页面中的这个元素:",`- 选择器: \`${L.selector}\``,L.text?`- 文本: "${L.text}"`:"",`- 路径: localhost:${o}`,H.trim()?`- 批注: ${H.trim()}`:""];if(Te.length>0){ke.push("- 请把以下样式改动应用到源码:");for(const pe of Te)ke.push(` - ${pe.cssProp}: ${pe.from||"(默认)"} → ${pe.to}`)}f==null||f(ke.filter(Boolean).join(`
94
94
  `)),P(null),$(""),G({}),ee({}),Z(!1),N(null),A(!1)},Me=()=>{P(null),$(""),G({}),ee({}),Z(!1)},He=()=>{R(null),Me(),N(null),A(Te=>!Te)};return k.jsxs("div",{className:"flex h-full flex-col bg-canvas",children:[k.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-surface px-2 py-1.5",children:[l&&k.jsx("button",{onClick:u,className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭预览",children:k.jsx(gi,{size:15})}),k.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 rounded-lg border border-border bg-surface-raised px-2 py-1",children:[k.jsx("span",{className:"shrink-0 font-mono text-2xs text-content-faint",children:"localhost:"}),k.jsx("input",{value:o,onChange:Te=>h(Te.target.value),onKeyDown:Te=>Te.key==="Enter"&&B(),placeholder:"3000",spellCheck:!1,className:"min-w-0 flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none","aria-label":"端口与路径"}),k.jsx("button",{onClick:B,className:"shrink-0 cursor-pointer rounded bg-accent-dim px-2 py-0.5 text-2xs font-medium text-white transition-colors hover:bg-accent",children:"前往"})]}),k.jsx("button",{onClick:He,disabled:!d,className:`shrink-0 cursor-pointer rounded-md p-1.5 transition-colors disabled:opacity-40 ${y?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-accent"}`,title:"标注元素","aria-label":"标注元素",children:k.jsx(RS,{size:14})}),k.jsxs("div",{className:"flex shrink-0 items-center rounded-lg border border-border bg-surface-raised p-0.5",children:[k.jsx("button",{onClick:()=>_("desktop"),className:`cursor-pointer rounded p-1 transition-colors ${w==="desktop"?"bg-surface-overlay text-content-primary":"text-content-muted hover:text-content-primary"}`,title:"桌面视口","aria-label":"桌面视口",children:k.jsx(Wv,{size:13})}),k.jsx("button",{onClick:()=>_("mobile"),className:`cursor-pointer rounded p-1 transition-colors ${w==="mobile"?"bg-surface-overlay text-content-primary":"text-content-muted hover:text-content-primary"}`,title:"移动视口","aria-label":"移动视口",children:k.jsx(AS,{size:13})})]}),k.jsx("button",{onClick:le,disabled:!d,className:"shrink-0 cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent disabled:opacity-40",title:"刷新","aria-label":"刷新",children:k.jsx(Sc,{size:14})}),k.jsx("button",{onClick:()=>F&&window.open(F,"_blank","noopener,noreferrer"),disabled:!F,className:"shrink-0 cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent disabled:opacity-40",title:"在新窗口打开","aria-label":"在新窗口打开",children:k.jsx(TS,{size:14})})]}),M&&k.jsx("p",{className:"border-b border-border bg-warning/10 px-3 py-1.5 text-2xs text-warning",children:M}),y&&!L&&k.jsx("p",{className:"border-b border-border bg-accent/10 px-3 py-1.5 text-2xs text-accent",children:"标注模式:移动鼠标高亮元素,点击选择并添加批注。"}),k.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-surface-raised",children:F?k.jsx("div",{className:w==="mobile"?"mx-auto h-full w-[390px] max-w-full border-x border-border":"h-full w-full",children:k.jsxs("div",{className:"relative h-full w-full",children:[k.jsx("iframe",{ref:I,src:F,title:"端口预览",onLoad:xe,className:"h-full w-full bg-white"},`${F}-${b}`),y&&k.jsx("div",{className:"absolute inset-0 cursor-crosshair",onMouseMove:U,onMouseLeave:()=>N(null),onClick:me,children:O&&!L&&k.jsx("div",{className:"pointer-events-none absolute border-2 border-accent bg-accent/10",style:{top:O.top,left:O.left,width:O.width,height:O.height}})}),L&&(()=>{var Yt,$t;const pe=((Yt=T.current)==null?void 0:Yt.clientHeight)??600,lt=L.rect.top+L.rect.height+8,Ae=L.rect.top-8,Ft=q?340:140,Wt=lt+Ft>pe&&Ae-Ft>0?Math.max(4,Ae-Ft):lt,xt=Math.max(4,Math.min(L.rect.left,((($t=T.current)==null?void 0:$t.clientWidth)??800)-280-4));return k.jsxs("div",{className:"absolute z-20 flex flex-col gap-2 rounded-xl border border-accent-dim/40 bg-surface-raised px-3 py-2.5 shadow-2xl animate-fade-in",style:{top:Wt,left:xt,width:280,maxHeight:pe-Wt-8},children:[k.jsx("p",{className:"truncate font-mono text-2xs text-content-faint",title:L.selector,children:L.selector}),L.text&&k.jsxs("p",{className:"-mt-1 truncate text-2xs text-content-muted",children:['"',L.text,'"']}),k.jsx("input",{value:H,onChange:ce=>$(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&ae(),autoFocus:!0,placeholder:"添加批注…",className:"w-full rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-content-primary placeholder-content-muted outline-none focus:border-accent-dim"}),k.jsxs("button",{onClick:()=>Z(ce=>!ce),className:`flex cursor-pointer items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-2xs transition-colors ${q?"text-accent":"text-content-muted hover:text-content-secondary"}`,children:[k.jsx("svg",{width:10,height:10,viewBox:"0 0 10 10",className:`shrink-0 transition-transform ${q?"rotate-180":""}`,children:k.jsx("path",{d:"M2 3.5 L5 6.5 L8 3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}),"调整样式"]}),q&&k.jsx("div",{className:"grid grid-cols-2 gap-x-2 gap-y-1.5 animate-fade-in",children:Qy.map(({cssProp:ce,label:Se})=>{const Be=te[ce]??K[ce]??"",Fe=ce in te&&te[ce]!==(K[ce]??"");return k.jsxs("label",{className:"flex flex-col gap-0.5",children:[k.jsx("span",{className:`text-2xs ${Fe?"text-accent":"text-content-faint"}`,children:Se}),k.jsx("input",{value:Be,onChange:it=>oe(ce,it.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-2xs text-content-primary outline-none focus:border-accent-dim"})]},ce)})}),k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("button",{onClick:Me,className:"codex-btn-ghost flex-1 text-2xs",children:"取消"}),k.jsx("button",{onClick:ae,className:"codex-btn-primary flex-1 text-2xs",children:"发送给 Agent"})]})]})})()]})}):k.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[k.jsx(oc,{size:34,className:"text-content-faint"}),k.jsx("p",{className:"text-sm leading-6 text-content-muted",children:d&&!S?"正在准备预览认证...":"输入主机上服务的端口号,预览远程本地服务"})]})})]})}const Jy="linkshell_theme",yc=new Set;let Bc=LO();function LO(){try{const e=localStorage.getItem(Jy);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"dark"}function IO(){return typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!0}function BO(e=Bc){return e==="system"?IO()?"dark":"light":e}function $d(){typeof document>"u"||document.documentElement.setAttribute("data-theme",BO())}function Fv(){return Bc}function Nf(e){Bc=e;try{localStorage.setItem(Jy,e)}catch{}$d();for(const n of yc)n()}function PO(e){return yc.add(e),()=>yc.delete(e)}function zO(){var e;if($d(),typeof window<"u"&&window.matchMedia){const n=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{if(Bc==="system"){$d();for(const a of yc)a()}};(e=n.addEventListener)==null||e.call(n,"change",r)}}const pd=["light","dark","system"],qv={light:"浅色",dark:"深色",system:"跟随系统"};function jO(){const e=ie.useSyncExternalStore(PO,Fv,Fv),n=()=>Nf(pd[(pd.indexOf(e)+1)%pd.length]),r=e==="light"?xS:e==="dark"?SS:Wv;return k.jsx("button",{onClick:n,className:"codex-btn-ghost px-2 py-1.5",title:`主题:${qv[e]}(点击切换)`,"aria-label":`主题:${qv[e]}`,children:k.jsx(r,{size:15})})}function UO(){try{const e=new URLSearchParams(window.location.search),n=e.get("embed")==="1",r=e.get("theme");return{embed:n,sessionId:e.get("session"),gateway:e.get("gateway"),token:e.get("token"),theme:r==="dark"||r==="light"?r:null}}catch{return{embed:!1,sessionId:null,gateway:null,token:null,theme:null}}}function HO(e){return!e.embed||!e.sessionId||!e.token||!e.gateway?null:(Xv(e.gateway),rf(e.token),e.theme&&Nf(e.theme),bd([{id:e.sessionId,state:"active",hasHost:!0,clientCount:1,provider:null,machineId:null,hostname:null,platform:null,projectName:null,cwd:null,lastActivity:Date.now()}]),{name:"console",sessionId:e.sessionId})}function FO(){try{const e=window.ReactNativeWebView;e==null||e.postMessage(JSON.stringify({type:"requestClose"}))}catch{}}const qO="linkshell_embed";function e0(){try{return new URLSearchParams(window.location.search).get("embed")==="1"?!0:localStorage.getItem(qO)==="1"}catch{return!1}}function $O(e,n){if(!e)return 0;const r=e.toLowerCase(),a=n.toLowerCase();let l=0,u=0,f=-1;for(let o=0;o<r.length;o++){const h=r[o],d=a.indexOf(h,l);if(d===-1)return null;f>=0?u+=d-f-1:u+=d,f=d,l=d+1}return u}function GO({open:e,onClose:n,actions:r,placeholder:a="搜索命令、对话…"}){const[l,u]=ie.useState(""),[f,o]=ie.useState(0),h=ie.useRef(null);ie.useEffect(()=>{e&&(u(""),o(0),requestAnimationFrame(()=>{var C;return(C=h.current)==null?void 0:C.focus()}))},[e]);const d=ie.useMemo(()=>r.map(w=>({a:w,score:$O(l,`${w.label} ${w.hint??""} ${w.keywords??""}`)})).filter(w=>w.score!==null).sort((w,_)=>w.score-_.score).map(w=>w.a),[r,l]);if(ie.useEffect(()=>{o(C=>Math.min(C,Math.max(0,d.length-1)))},[d.length]),!e)return null;const m=C=>{const w=d[C];w&&(n(),w.run())},p=C=>{C.key==="ArrowDown"?(C.preventDefault(),o(w=>Math.min(w+1,d.length-1))):C.key==="ArrowUp"?(C.preventDefault(),o(w=>Math.max(w-1,0))):C.key==="Enter"?(C.preventDefault(),m(f)):C.key==="Escape"&&(C.preventDefault(),n())};let x=-1;const S=new Map;for(const C of d){const w=C.group??"",_=S.get(w)??[];_.push(C),S.set(w,_)}return k.jsx("div",{className:"fixed inset-0 z-[60] flex items-start justify-center bg-canvas/60 px-4 pt-[12vh] backdrop-blur-sm animate-fade-in",onClick:n,children:k.jsxs("div",{className:"codex-card-raised w-full max-w-xl overflow-hidden",onClick:C=>C.stopPropagation(),children:[k.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3.5 py-3",children:[k.jsx(os,{size:16,className:"shrink-0 text-content-faint"}),k.jsx("input",{ref:h,value:l,onChange:C=>u(C.target.value),onKeyDown:p,placeholder:a,className:"min-w-0 flex-1 bg-transparent text-[15px] text-content-primary placeholder-content-muted outline-none"}),k.jsx("kbd",{className:"shrink-0 rounded border border-border px-1.5 py-0.5 font-mono text-2xs text-content-faint",children:"esc"})]}),k.jsx("div",{className:"max-h-[50vh] overflow-y-auto p-1.5",children:d.length===0?k.jsx("p",{className:"px-3 py-6 text-center text-sm text-content-muted",children:"没有匹配项"}):[...S.entries()].map(([C,w])=>k.jsxs("div",{className:"mb-1",children:[C&&k.jsx("p",{className:"px-2.5 pb-1 pt-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:C}),w.map(_=>{x+=1;const b=x;return k.jsxs("button",{onMouseEnter:()=>o(b),onClick:()=>m(b),className:`flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors ${b===f?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[_.icon&&k.jsx("span",{className:"shrink-0 text-content-muted",children:_.icon}),k.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-content-primary",children:_.label}),_.hint&&k.jsx("span",{className:"shrink-0 text-2xs text-content-faint",children:_.hint})]},_.id)})]},C||"_"))})]})})}function KO(e){return e==="connected"?{text:"已连接",color:"text-success"}:e==="connecting"||e==="reconnecting"||e==="claiming"?{text:"连接中",color:"text-warning"}:e==="host_disconnected"?{text:"主机离线",color:"text-warning"}:e.startsWith("error")?{text:"错误",color:"text-danger"}:{text:"未连接",color:"text-content-muted"}}function $v(e){switch(e){case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"waiting_permission":return{text:"等待授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};case"idle":return{text:"空闲",className:"border-border bg-surface-overlay text-content-muted"};case"unavailable":return{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"};default:return null}}function md(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function VO(e){if(!e)return null;const n=e.inputTokens!=null||e.cacheReadTokens!=null?(e.inputTokens??0)+(e.cacheReadTokens??0):null,r=[];let a="";if(n!=null&&e.contextWindow&&e.contextWindow>0){const l=Math.min(100,Math.round(n/e.contextWindow*100));r.push(`${l}%`),a=`上下文 ${md(n)} / ${md(e.contextWindow)} tokens`}else{const l=e.totalTokens??n??e.outputTokens??null;l!=null&&(r.push(md(l)),a=`${l.toLocaleString()} tokens`)}return typeof e.totalCostUsd=="number"&&e.totalCostUsd>0&&(r.push(`$${e.totalCostUsd.toFixed(e.totalCostUsd<1?3:2)}`),a=a?`${a} · $${e.totalCostUsd.toFixed(4)}`:`$${e.totalCostUsd.toFixed(4)}`),r.length===0?null:{text:r.join(" · "),title:a}}function WO(e){const n=Math.max(0,Math.floor(e)),r=Math.floor(n/3600),a=Math.floor(n%3600/60),l=n%60;return r>0?`${r}h ${String(a).padStart(2,"0")}m ${String(l).padStart(2,"0")}s`:a>0?`${a}m ${String(l).padStart(2,"0")}s`:`${l}s`}function YO(e){const[n,r]=ie.useState(0),a=ie.useRef(null);return ie.useEffect(()=>{if(!e){a.current=null,r(0);return}a.current=Date.now(),r(0);const l=setInterval(()=>{a.current!=null&&r(Math.floor((Date.now()-a.current)/1e3))},1e3);return()=>clearInterval(l)},[e]),n}function ZO(e,n,r){const[a,l]=ie.useState(()=>({render:e,className:e?n:""})),u=ie.useRef(e);ie.useEffect(()=>{e&&!u.current?l({render:!0,className:n}):!e&&u.current&&l({render:!0,className:r}),u.current=e},[e,n,r]);const f=ie.useCallback(()=>{u.current||l({render:!1,className:""})},[]);return{render:a.render,className:a.className,onAnimationEnd:f}}function XO(e,n){var l,u,f,o,h,d,m,p;const r=n.toLowerCase();return[e.text,(l=e.commandExecution)==null?void 0:l.command,(u=e.commandExecution)==null?void 0:u.output,(f=e.toolCall)==null?void 0:f.name,(o=e.toolCall)==null?void 0:o.input,(h=e.toolCall)==null?void 0:h.output,(d=e.fileChange)==null?void 0:d.summary,...((p=(m=e.fileChange)==null?void 0:m.entries)==null?void 0:p.map(x=>x.path))??[],e.error].some(x=>typeof x=="string"&&x.toLowerCase().includes(r))}function QO({sessionId:e,session:n,onBack:r}){var Le,We;const a=ie.useMemo(()=>Zv(),[]),l=ie.useMemo(()=>e0(),[]),{store:u,snapshot:f}=Ow(a,e),o=Wy(),[h,d]=ie.useState("none"),[m,p]=ie.useState(!1),[x,S]=ie.useState(!1),[C,w]=ie.useState(()=>{const he=Number(localStorage.getItem("linkshell_terminal_h"));return he>=120&&he<=600?he:320}),_=ie.useRef(!1),b=ie.useRef(C);b.current=C;const v=ie.useRef(m);v.current=m;const y=ie.useCallback(()=>{v.current?S(!0):p(!0)},[]),A=ie.useCallback(()=>{S(!1),p(!0)},[]),[M,R]=ie.useState(!1),[O,N]=ie.useState(null),[L,P]=ie.useState(null),[H,$]=ie.useState(null),[q,Z]=ie.useState({text:"",nonce:0}),[K,G]=ie.useState(!1),[te,ee]=ie.useState(""),[I,T]=ie.useState(!1),z=ie.useRef(null),[F,B]=ie.useState(()=>{const he=Number(localStorage.getItem("linkshell_sidebar_w"));return he>=180&&he<=520?he:256}),[le,xe]=ie.useState(()=>localStorage.getItem("linkshell_sidebar_collapsed")==="1"),[fe,Y]=ie.useState(()=>{const he=Number(localStorage.getItem("linkshell_rightpanel_w"));return he>=320&&he<=1100?he:560}),U=ie.useRef(!1),me=ie.useRef(!1),oe=ie.useRef(null),J=()=>{xe(he=>(localStorage.setItem("linkshell_sidebar_collapsed",he?"0":"1"),!he))},ae=he=>{he.preventDefault(),U.current=!0;const we=be=>{if(!U.current)return;const Oe=Math.min(520,Math.max(180,be.clientX));B(Oe)},Ee=()=>{U.current=!1,localStorage.setItem("linkshell_sidebar_w",String(Me.current)),window.removeEventListener("pointermove",we),window.removeEventListener("pointerup",Ee)};window.addEventListener("pointermove",we),window.addEventListener("pointerup",Ee)},Me=ie.useRef(F);Me.current=F;const He=ie.useRef(fe);He.current=fe;const Te=he=>{he.preventDefault(),me.current=!0;const we=be=>{if(!me.current)return;const Oe=Math.min(1100,Math.max(320,window.innerWidth-be.clientX));Y(Oe)},Ee=()=>{me.current=!1,localStorage.setItem("linkshell_rightpanel_w",String(He.current)),window.removeEventListener("pointermove",we),window.removeEventListener("pointerup",Ee)};window.addEventListener("pointermove",we),window.addEventListener("pointerup",Ee)},ke=he=>{he.preventDefault(),_.current=!0;const we=he.clientY,Ee=b.current,be=_t=>{if(!_.current)return;const Qe=Math.min(600,Math.max(120,Ee+(we-_t.clientY)));w(Qe)},Oe=()=>{_.current=!1,localStorage.setItem("linkshell_terminal_h",String(b.current)),window.removeEventListener("pointermove",be),window.removeEventListener("pointerup",Oe)};window.addEventListener("pointermove",be),window.addEventListener("pointerup",Oe)},pe=f.activeConversationId,lt=pe?f.timelines.get(pe)??[]:[],Ae=f.conversations.find(he=>he.id===pe),Ft=((Le=f.capabilities)==null?void 0:Le.providers)??[],Qt=Ae?Ft.find(he=>he.id===Ae.provider):void 0,Wt=(Ae==null?void 0:Ae.status)==="running",xt=pe?f.history.get(pe):void 0,Yt=ie.useMemo(()=>{for(let he=lt.length-1;he>=0;he--){const we=lt[he];if(we.role==="user"&&we.text)return we.text}},[lt]),$t=he=>{Z(we=>({text:he,nonce:we.nonce+1}))},ce=ie.useMemo(()=>{if((Ae==null?void 0:Ae.collaborationMode)!=="plan"||Wt||(Ae==null?void 0:Ae.status)==="waiting_permission")return!1;const he=[...lt].reverse().find(we=>!sc(we));return he!=null&&he.role!=="user"},[Ae==null?void 0:Ae.collaborationMode,Ae==null?void 0:Ae.status,Wt,lt]),Se=()=>{pe&&u.sendPrompt({conversationId:pe,text:"请按上面的计划开始执行。",collaborationMode:"default",model:Ae==null?void 0:Ae.model,reasoningEffort:Ae==null?void 0:Ae.reasoningEffort,permissionMode:Ae==null?void 0:Ae.permissionMode})};ie.useEffect(()=>{const he=we=>{const Ee=we.metaKey||we.ctrlKey;Ee&&we.shiftKey&&we.key.toLowerCase()==="p"?(we.preventDefault(),T(be=>!be)):Ee&&!we.shiftKey&&we.key.toLowerCase()==="k"?(we.preventDefault(),T(be=>!be)):Ee&&!we.shiftKey&&we.key.toLowerCase()==="j"?(we.preventDefault(),y()):Ee&&!we.shiftKey&&we.key.toLowerCase()==="f"?(we.preventDefault(),G(!0),requestAnimationFrame(()=>{var be;return(be=z.current)==null?void 0:be.focus()})):we.key==="Escape"&&G(!1)};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[]),ie.useEffect(()=>{G(!1),ee("")},[pe]);const Be=ie.useRef(0),Fe=ie.useRef(!0),it=()=>{const he=oe.current;he&&(Fe.current=he.scrollHeight-he.scrollTop-he.clientHeight<80,he.scrollTop<60&&pe&&(xt!=null&&xt.hasMore)&&!xt.loading&&(Be.current=he.scrollHeight,u.loadOlderHistory(pe)))};ie.useLayoutEffect(()=>{const he=oe.current;he&&(Be.current>0?(he.scrollTop=he.scrollHeight-Be.current,Be.current=0):Fe.current&&(he.scrollTop=he.scrollHeight))},[lt.length,pe]);const Ut=(he,we)=>{we?ht(he,we):$(he)},ht=(he,we)=>{const Ee=Ft.find(Oe=>Oe.id===he),be=u.openConversation({provider:he,cwd:we,model:Ee==null?void 0:Ee.defaultModel});u.setActiveConversation(be),$(null)},nn=(he,we)=>{pe&&u.sendPrompt({conversationId:pe,text:he,images:we.map(Ee=>({data:Ee.data,mimeType:Ee.mimeType})),model:Ae==null?void 0:Ae.model,reasoningEffort:Ae==null?void 0:Ae.reasoningEffort,permissionMode:Ae==null?void 0:Ae.permissionMode,collaborationMode:Ae==null?void 0:Ae.collaborationMode})},xn=KO(f.status),Jt=f.externalAgentStatus==="running"||f.externalAgentStatus==="waiting_permission"||f.externalAgentStatus==="error",Ht=$v(Jt?f.externalAgentStatus??void 0:Ae==null?void 0:Ae.status),dn=Jt?f.externalAgentTitle??"外部终端":Ae==null?void 0:Ae.provider,fn=Jt?f.externalAgentStatus==="running":(Ae==null?void 0:Ae.status)==="running",Lr=YO(fn),Oi=Jt?null:VO(Ae==null?void 0:Ae.usage),er=`CLI 设备 · ${e.slice(0,8)}`,li=Ae==null?void 0:Ae.cwd,bi=ie.useCallback(()=>{u.client.spawnTerminal(li||".")},[u,li]),X=Ft.filter(he=>he.enabled),_e=ie.useMemo(()=>{const he=[];for(const we of X)he.push({id:`new-${we.id}`,label:`新建 ${we.label} 对话`,group:"新建",keywords:`new conversation ${we.id}`,icon:k.jsx(Ro,{size:15}),run:()=>Ut(we.id)});for(const we of f.conversations.filter(Ee=>!Ee.archived)){const Ee=we.title&&we.title.trim()||we.lastMessagePreview&&we.lastMessagePreview.trim().slice(0,40)||`对话 ${we.id.slice(-6)}`;he.push({id:`conv-${we.id}`,label:Ee,group:"对话",hint:we.cwd?we.cwd.split("/").slice(-1)[0]:void 0,keywords:`${we.provider} ${we.cwd??""}`,icon:k.jsx(ea,{provider:we.provider,size:15}),run:()=>u.setActiveConversation(we.id)})}return pe&&Wt&&he.push({id:"cancel",label:"停止当前回合",group:"操作",keywords:"cancel stop interrupt",icon:k.jsx(Vv,{size:15}),run:()=>u.cancel(pe)}),pe&&he.push({id:"search",label:"在对话中搜索",group:"操作",hint:"⌘F",keywords:"search find filter",icon:k.jsx(os,{size:15}),run:()=>{G(!0),requestAnimationFrame(()=>{var we;return(we=z.current)==null?void 0:we.focus()})}}),he.push({id:"panel-terminal",label:"切换终端",group:"操作",hint:"⌘J",keywords:"terminal shell",icon:k.jsx(_d,{size:15}),run:y},{id:"panel-files",label:"打开文件浏览器",group:"操作",keywords:"files browse",icon:k.jsx(Nr,{size:15}),run:()=>d(we=>we==="files"?"none":"files")},{id:"panel-preview",label:"打开端口预览",group:"操作",keywords:"preview port browser localhost tunnel",icon:k.jsx(oc,{size:15}),run:()=>d(we=>we==="preview"?"none":"preview")}),he},[X,f.conversations,pe,Wt]);return k.jsxs("div",{className:"flex h-[100dvh] flex-col overflow-hidden",children:[k.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-2",style:{paddingTop:"max(0.5rem, env(safe-area-inset-top))"},children:[k.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o&&k.jsx("button",{onClick:()=>R(!0),className:"codex-btn-ghost shrink-0 px-2 py-1.5","aria-label":"打开会话列表",children:k.jsx(bS,{size:17})}),k.jsx("button",{onClick:r,className:"codex-btn-ghost shrink-0 text-2xs","aria-label":"返回会话列表",children:"← 会话"}),k.jsxs("span",{className:`flex shrink-0 items-center gap-1 text-2xs ${xn.color}`,children:[k.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),!o&&xn.text]}),Ht&&k.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium ${Ht.className}`,title:Jt?"外部终端状态":"当前对话状态",children:[Ht.pulsing&&k.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current animate-pulse-dot"}),dn&&k.jsx("span",{className:"min-w-0 truncate",children:dn}),k.jsxs("span",{className:"shrink-0",children:[dn?"· ":"",Ht.text]}),fn&&k.jsx("span",{className:"shrink-0 font-mono tabular-nums opacity-70",children:WO(Lr)})]}),Oi&&k.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border bg-surface-overlay px-2 py-0.5 font-mono text-2xs tabular-nums text-content-muted",title:Oi.title,children:Oi.text}),f.lastError&&k.jsx("button",{onClick:()=>u.dismissError(),className:"min-w-0 truncate rounded-full border border-danger/30 bg-danger/10 px-2 py-0.5 text-2xs text-danger",title:`${f.lastError.message}(点击关闭)`,children:f.lastError.code})]}),k.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[k.jsx("button",{onClick:()=>{pe&&(G(!0),requestAnimationFrame(()=>{var he;return(he=z.current)==null?void 0:he.focus()}))},disabled:!pe,className:"codex-btn-ghost px-2 py-1.5 disabled:opacity-40",title:"在对话中搜索 (⌘/Ctrl+F)","aria-label":"在对话中搜索",children:k.jsx(os,{size:16})}),!l&&k.jsx(jO,{}),k.jsx("button",{onClick:()=>d(he=>he==="preview"?"none":"preview"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${h==="preview"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"端口预览","aria-label":"端口预览",children:k.jsx(oc,{size:16})}),k.jsx("button",{onClick:()=>d(he=>he==="files"?"none":"files"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${h==="files"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"文件","aria-label":"文件",children:k.jsx(Nr,{size:16})}),k.jsx("button",{onClick:y,className:`cursor-pointer rounded-md p-1.5 transition-colors ${m?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"终端 (⌘J)","aria-label":"终端",children:k.jsx(_d,{size:16})})]})]}),k.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[f.status==="host_disconnected"&&k.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-canvas/80 backdrop-blur-sm",children:k.jsxs("div",{className:"codex-card-raised mx-4 flex max-w-sm flex-col items-center gap-3 px-6 py-8 text-center animate-fade-in",children:[k.jsx("span",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-warning/15 text-warning",children:k.jsx(ES,{size:24})}),k.jsx("h2",{className:"text-base font-semibold text-content-primary",children:"主机已离线"}),k.jsxs("p",{className:"text-sm leading-relaxed text-content-muted",children:["与该会话的主机连接已断开。请确认主机上的"," ",k.jsx("code",{className:"font-mono text-accent",children:"linkshell"})," 仍在运行。正在自动尝试重新连接…"]}),k.jsx("button",{onClick:r,className:"codex-btn-outline mt-1 text-2xs",children:"返回会话列表"})]})}),o?M&&k.jsxs("div",{className:"absolute inset-0 z-30 flex animate-fade-in",children:[k.jsxs("aside",{className:"flex w-[82%] max-w-xs flex-col border-r border-border bg-surface shadow-2xl animate-drawer-in",children:[k.jsx("div",{className:"flex items-center border-b border-border px-3 py-2",children:k.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"})}),k.jsx("div",{className:"min-h-0 flex-1",children:k.jsx(Hv,{deviceLabel:er,conversations:f.conversations,capabilities:f.capabilities,activeConversationId:pe,externalAgentStatus:f.externalAgentStatus,externalAgentTitle:f.externalAgentTitle,externalAgentProvider:f.externalAgentProvider,store:u,onSelect:he=>{u.setActiveConversation(he),R(!1)},onNewConversation:(he,we)=>{R(!1),Ut(he,we)},onOpenExternalTerminal:()=>{R(!1),A()}})})]}),k.jsx("button",{className:"flex-1 bg-canvas/60 backdrop-blur-sm",onClick:()=>R(!1),"aria-label":"关闭"})]}):le?k.jsx("div",{className:"flex w-9 shrink-0 flex-col items-center border-r border-border bg-surface py-2",children:k.jsx("button",{onClick:J,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"展开侧边栏","aria-label":"展开侧边栏",children:k.jsx(vi,{size:16})})}):k.jsxs("aside",{className:"relative flex shrink-0 flex-col border-r border-border bg-surface",style:{width:F},children:[k.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1",children:[k.jsx("span",{className:"pl-1 text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"}),k.jsx("button",{onClick:J,className:"cursor-pointer rounded-md p-1 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"收起侧边栏","aria-label":"收起侧边栏",children:k.jsx(yS,{size:15})})]}),k.jsx("div",{className:"min-h-0 flex-1",children:k.jsx(Hv,{deviceLabel:er,conversations:f.conversations,capabilities:f.capabilities,activeConversationId:pe,externalAgentStatus:f.externalAgentStatus,externalAgentTitle:f.externalAgentTitle,externalAgentProvider:f.externalAgentProvider,store:u,onSelect:he=>u.setActiveConversation(he),onNewConversation:Ut,onOpenExternalTerminal:A})}),k.jsx("div",{onPointerDown:ae,className:"absolute right-0 top-0 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"})]}),k.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:!pe||!Ae?k.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[k.jsx(tf,{size:44,className:"opacity-40"}),k.jsx("p",{className:"text-[15px] leading-7 text-content-muted",children:o?"点击左上角菜单选择对话,或新建一个开始":"从左侧选择一个对话,或新建一个开始"})]}):k.jsxs(k.Fragment,{children:[K&&k.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-surface px-4 py-2",children:[k.jsx(os,{size:15,className:"shrink-0 text-content-faint"}),k.jsx("input",{ref:z,value:te,onChange:he=>ee(he.target.value),onKeyDown:he=>he.key==="Escape"&&(G(!1),ee("")),placeholder:"在此对话中搜索…",className:"min-w-0 flex-1 bg-transparent text-sm text-content-primary placeholder-content-muted outline-none"}),k.jsx("button",{onClick:()=>{G(!1),ee("")},className:"codex-btn-ghost px-2 py-1","aria-label":"关闭搜索",children:k.jsx(gi,{size:14})})]}),k.jsx("div",{ref:oe,onScroll:it,className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-8",children:k.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-6",children:[(xt==null?void 0:xt.loading)&&k.jsx("p",{className:"text-center text-2xs text-content-muted",children:"加载更早的消息…"}),K&&te.trim()?(()=>{const he=te.trim(),we=lt.filter(Ee=>!sc(Ee)&&XO(Ee,he));return we.length===0?k.jsxs("p",{className:"py-12 text-center text-sm text-content-muted",children:["没有匹配「",he,"」的消息"]}):k.jsxs(k.Fragment,{children:[k.jsxs("p",{className:"text-center text-2xs text-content-faint",children:[we.length," 条匹配"]}),we.map(Ee=>k.jsx("div",{className:"min-w-0 animate-fade-in",children:k.jsx(Iv,{item:Ee,canSteer:!1,onPermission:(be,Oe,_t)=>u.respondPermission(pe,be,Oe,_t),onStructuredInput:(be,Oe)=>u.respondStructuredInput(pe,be,Oe),onOpenDiff:be=>{N(be),d("none")},onOpenAgent:be=>{P(be),N(null),d("none")},onEditMessage:$t,highlightQuery:he})},Ee.id))]})})():(()=>{const he=[];let we=[];const Ee=()=>{we.length&&(he.push({k:"group",key:`grp-${we[0].id}`,items:we}),we=[])};for(const Oe of lt)sc(Oe)||(rO(Oe)?we.push(Oe):(Ee(),he.push({k:"item",item:Oe})));Ee();let be=-1;return he.forEach((Oe,_t)=>{Oe.k==="group"&&(be=_t)}),he.map((Oe,_t)=>Oe.k==="item"?k.jsx("div",{className:"min-w-0 animate-fade-in",children:k.jsx(Iv,{item:Oe.item,canSteer:Ae.provider==="codex"&&Wt,onPermission:(Qe,ci,Ir)=>u.respondPermission(pe,Qe,ci,Ir),onStructuredInput:(Qe,ci)=>u.respondStructuredInput(pe,Qe,ci),onSendQueued:Qe=>u.sendQueuedFollowUp(pe,Qe,"new_turn"),onSteerQueued:Qe=>u.sendQueuedFollowUp(pe,Qe,"steer"),onDiscardQueued:Qe=>u.discardQueuedFollowUp(pe,Qe),onOpenDiff:Qe=>{N(Qe),d("none")},onOpenAgent:Qe=>{P(Qe),N(null),d("none")},onEditMessage:$t})},Oe.item.id):k.jsx("div",{className:"min-w-0 animate-fade-in",children:k.jsx(oO,{items:Oe.items,live:Wt&&_t===be,onOpenDiff:Qe=>{N(Qe),d("none")},onOpenAgent:Qe=>{P(Qe),N(null),d("none")}})},Oe.key))})(),lt.length===0&&(Ae!=null&&Ae.lastMessagePreview||xt!=null&&xt.loading?k.jsxs("div",{className:"flex flex-col items-center gap-2 py-16 text-content-muted",children:[k.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-content-faint border-t-accent"}),k.jsx("p",{className:"text-sm",children:"加载对话记录…"})]}):k.jsx("p",{className:"py-12 text-center text-sm text-content-muted",children:"发送第一条指令…"}))]})}),k.jsxs("div",{className:"mx-auto w-full min-w-0 max-w-3xl px-4 pb-4",children:[ce&&k.jsxs("div",{className:"mb-2 flex items-center gap-3 rounded-xl border border-accent-dim/40 bg-surface px-3.5 py-2.5 animate-slide-in",children:[k.jsx("span",{className:"min-w-0 flex-1 text-sm text-content-secondary",children:"计划已就绪。执行它,或在下方继续补充。"}),k.jsx("button",{onClick:Se,className:"codex-btn-primary shrink-0 text-xs",children:"执行计划"})]}),k.jsx(sO,{items:lt.filter(sc),canSteer:Ae.provider==="codex"&&Wt,onSend:he=>u.sendQueuedFollowUp(pe,he,"new_turn"),onSteer:he=>u.sendQueuedFollowUp(pe,he,"steer"),onDiscard:he=>u.discardQueuedFollowUp(pe,he)}),k.jsx(cO,{disabled:f.status!=="connected",running:Wt,supportsImages:Qt==null?void 0:Qt.supportsImages,commands:Qt==null?void 0:Qt.commands,conversationId:pe,lastUserText:Yt,cwd:Ae.cwd,onBrowse:he=>u.browse(he,!0),seedText:q,controls:k.jsx(TO,{conversation:Ae,capability:Qt,onChange:he=>u.updateConversationSettings(pe,he)}),onSend:nn,onCancel:()=>u.cancel(pe),onExecuteCommand:(he,we)=>u.executeCommand(pe,he,we)})]}),(m||x)&&k.jsxs("div",{className:`relative shrink-0 overflow-hidden border-t border-border bg-surface ${x?"animate-panel-out-down":"animate-panel-in-up"}`,style:{height:C},onAnimationEnd:()=>{x&&(S(!1),p(!1))},children:[k.jsx("div",{onPointerDown:ke,className:"absolute left-0 right-0 top-0 z-10 h-1 cursor-row-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整终端高度"}),k.jsx(yO,{bridge:u.client,onNewTerminal:bi})]})]})}),(()=>{let he=null;L?he=k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[k.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"子 Agent"}),k.jsx("button",{onClick:()=>P(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭",children:k.jsx(gi,{size:15})})]}),k.jsx("div",{className:"min-h-0 flex-1",children:k.jsx(nO,{detail:L})})]}):O?he=k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[k.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"文件差异"}),k.jsx("button",{onClick:()=>N(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭差异",children:k.jsx(gi,{size:15})})]}),k.jsx("div",{className:"min-h-0 flex-1",children:k.jsx(VM,{item:O})})]}):h==="files"?he=k.jsx(AO,{store:u,initialPath:(Ae==null?void 0:Ae.cwd)||".",onClose:()=>d("none")}):h==="preview"&&(he=k.jsx(DO,{gatewayUrl:a.httpUrl,sessionId:e,initialAuthToken:(n==null?void 0:n.accessToken)??null,isMobile:o,onClose:()=>d("none"),onAnnotate:_t=>{Z(Qe=>({text:_t,nonce:Qe.nonce+1})),o&&d("none")}}));const we=ie.useRef(null);he!==null&&(we.current=he);const Ee=he!==null,be=ZO(Ee,"animate-panel-in-right","animate-panel-out-right");if(!be.render&&!Ee)return null;const Oe=Ee?he:we.current;return o?k.jsx("aside",{className:`absolute inset-0 z-30 flex flex-col bg-canvas ${be.className||"animate-fade-in"}`,onAnimationEnd:be.onAnimationEnd,children:Oe}):k.jsxs("aside",{className:`relative flex shrink-0 flex-col border-l border-border ${be.className}`,style:{width:fe},onAnimationEnd:be.onAnimationEnd,children:[k.jsx("div",{onPointerDown:Te,className:"absolute left-0 top-0 z-10 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"}),Oe]})})()]}),H&&k.jsx(RO,{store:u,initialPath:(Ae==null?void 0:Ae.cwd)||".",providerLabel:((We=Ft.find(he=>he.id===H))==null?void 0:We.label)??H,onCancel:()=>$(null),onConfirm:he=>ht(H,he)}),f.notices.length>0&&k.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex w-80 flex-col gap-2",children:f.notices.map(he=>k.jsxs("button",{onClick:()=>u.dismissNotice(he.id),className:`codex-card-raised pointer-events-auto animate-fade-in cursor-pointer px-3 py-2 text-left ${he.kind==="warning"?"border-warning/40":""}`,children:[k.jsxs("p",{className:"flex items-center gap-1.5 text-xs font-medium text-content-primary",children:[k.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${he.kind==="warning"?"bg-warning":"bg-accent"}`}),he.title]}),he.detail&&k.jsx("p",{className:"mt-0.5 pl-3 text-2xs text-content-muted",children:he.detail})]},he.id))}),k.jsx(GO,{open:I,onClose:()=>T(!1),actions:_e})]})}zO();function JO(){const[e,n]=ie.useState(null),[r,a]=ie.useState(!1),[l,u]=ie.useState(!1),f=ie.useMemo(()=>HO(UO()),[]),o=ie.useMemo(()=>e0(),[]),[h,d]=ie.useState(()=>f??HS()),m=p=>{d(p),h_(p)};return ie.useEffect(()=>{const p=xc();p&&n(p),a(!0),p&&Zd().then(x=>{x&&n(x)})},[]),ie.useEffect(()=>{if(!o)return;const p=window;return p.__linkshellSetTheme=x=>{(x==="dark"||x==="light")&&Nf(x)},()=>{delete p.__linkshellSetTheme}},[o]),ie.useEffect(()=>hS(()=>{n(null),u(!1),d(p=>p.name==="list"?p:{name:"list"}),h_({name:"list"})}),[]),r?l?k.jsx(NS,{onLogin:p=>{n(p),u(!1)},onCancel:()=>u(!1)}):h.name==="console"?k.jsx(QO,{sessionId:h.sessionId,session:e,onBack:o?FO:()=>m({name:"list"})}):k.jsx(ZS,{session:e,onLogin:()=>u(!0),onLogout:()=>{n(null),m({name:"list"})},onOpenSession:p=>m({name:"console",sessionId:p})}):null}uS.createRoot(document.getElementById("root")).render(k.jsx(JO,{}));