tmux-weblink 2.2.29 → 2.2.31
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.
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var us=Object.defineProperty,_s=Object.getOwnPropertyDescriptor,gs=(e,t,i,r)=>{for(var s=r>1?void 0:r?_s(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(s=(r?n(t,i,s):n(s))||s);return r&&s&&us(t,i,s),s},fs=(e,t)=>(i,r)=>t(i,r,e),vs=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ht.isErrorNoTelemetry(e)?new Ht(e.message+`
|
|
2
|
+
|
|
3
|
+
`+e.stack):new Error(e.message+`
|
|
4
|
+
|
|
5
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},ps=new vs;function Ye(e){ms(e)||ps.onUnexpectedError(e)}var ut="Canceled";function ms(e){return e instanceof ws?!0:e instanceof Error&&e.name===ut&&e.message===ut}var ws=class extends Error{constructor(){super(ut),this.name=this.message}},Ht=class Ot extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Ot)return t;let i=new Ot;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}};function Cs(e,t,i=0,r=e.length){let s=i,o=r;for(;s<o;){let n=Math.floor((s+o)/2);t(e[n])?s=n+1:o=n}return s-1}var xs=class Ji{constructor(t){this._array=t,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(Ji.assertInvariants){if(this._prevFindLastPredicate){for(let r of this._array)if(this._prevFindLastPredicate(r)&&!t(r))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=t}let i=Cs(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=i+1,i===-1?void 0:this._array[i]}};xs.assertInvariants=!1;var Vt;(e=>{function t(o){return o<0}e.isLessThan=t;function i(o){return o<=0}e.isLessThanOrEqual=i;function r(o){return o>0}e.isGreaterThan=r;function s(o){return o===0}e.isNeitherLessOrGreaterThan=s,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Vt||={});function bs(e,t){return(i,r)=>t(e(i),e(r))}var Ls=(e,t)=>e-t,jt=class Wt{constructor(t){this.iterate=t}forEach(t){this.iterate(i=>(t(i),!0))}toArray(){let t=[];return this.iterate(i=>(t.push(i),!0)),t}filter(t){return new Wt(i=>this.iterate(r=>t(r)?i(r):!0))}map(t){return new Wt(i=>this.iterate(r=>i(t(r))))}some(t){let i=!1;return this.iterate(r=>(i=t(r),!i)),i}findFirst(t){let i;return this.iterate(r=>t(r)?(i=r,!1):!0),i}findLast(t){let i;return this.iterate(r=>(t(r)&&(i=r),!0)),i}findLastMaxBy(t){let i,r=!0;return this.iterate(s=>((r||Vt.isGreaterThan(t(s,i)))&&(r=!1,i=s),!0)),i}};jt.empty=new jt(e=>{});function ys(e,t){let i=Object.create(null);for(let r of e){let s=t(r),o=i[s];o||(o=i[s]=[]),o.push(r)}return i}var Yt,Kt,Mn=class{constructor(e,t){this.toKey=t,this._map=new Map,this[Yt]="SetWithKey";for(let i of e)this.add(i)}get size(){return this._map.size}add(e){let t=this.toKey(e);return this._map.set(t,e),this}delete(e){return this._map.delete(this.toKey(e))}has(e){return this._map.has(this.toKey(e))}*entries(){for(let e of this._map.values())yield[e,e]}keys(){return this.values()}*values(){for(let e of this._map.values())yield e}clear(){this._map.clear()}forEach(e,t){this._map.forEach(i=>e.call(t,i,i,this))}[(Kt=Symbol.iterator,Yt=Symbol.toStringTag,Kt)](){return this.values()}},Ms=class{constructor(){this.map=new Map}add(e,t){let i=this.map.get(e);i||(i=new Set,this.map.set(e,i)),i.add(t)}delete(e,t){let i=this.map.get(e);i&&(i.delete(t),i.size===0&&this.map.delete(e))}forEach(e,t){let i=this.map.get(e);i&&i.forEach(t)}get(e){return this.map.get(e)||new Set}};function Ss(e,t){let i=this,r=!1,s;return function(){if(r)return s;if(r=!0,t)try{s=e.apply(i,arguments)}finally{t()}else s=e.apply(i,arguments);return s}}var Xt;(e=>{function t(b){return b&&typeof b=="object"&&typeof b[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function r(){return i}e.empty=r;function*s(b){yield b}e.single=s;function o(b){return t(b)?b:s(b)}e.wrap=o;function n(b){return b||i}e.from=n;function*a(b){for(let y=b.length-1;y>=0;y--)yield b[y]}e.reverse=a;function l(b){return!b||b[Symbol.iterator]().next().done===!0}e.isEmpty=l;function h(b){return b[Symbol.iterator]().next().value}e.first=h;function c(b,y){let T=0;for(let W of b)if(y(W,T++))return!0;return!1}e.some=c;function d(b,y){for(let T of b)if(y(T))return T}e.find=d;function*u(b,y){for(let T of b)y(T)&&(yield T)}e.filter=u;function*g(b,y){let T=0;for(let W of b)yield y(W,T++)}e.map=g;function*L(b,y){let T=0;for(let W of b)yield*y(W,T++)}e.flatMap=L;function*A(...b){for(let y of b)yield*y}e.concat=A;function B(b,y,T){let W=T;for(let Y of b)W=y(W,Y);return W}e.reduce=B;function*j(b,y,T=b.length){for(y<0&&(y+=b.length),T<0?T+=b.length:T>b.length&&(T=b.length);y<T;y++)yield b[y]}e.slice=j;function R(b,y=Number.POSITIVE_INFINITY){let T=[];if(y===0)return[T,b];let W=b[Symbol.iterator]();for(let Y=0;Y<y;Y++){let ae=W.next();if(ae.done)return[T,e.empty()];T.push(ae.value)}return[T,{[Symbol.iterator](){return W}}]}e.consume=R;async function M(b){let y=[];for await(let T of b)y.push(T);return Promise.resolve(y)}e.asyncToArray=M})(Xt||={});var As=!1,Te=null,Rs=class es{constructor(){this.livingDisposables=new Map}getDisposableData(t){let i=this.livingDisposables.get(t);return i||(i={parent:null,source:null,isSingleton:!1,value:t,idx:es.idx++},this.livingDisposables.set(t,i)),i}trackDisposable(t){let i=this.getDisposableData(t);i.source||(i.source=new Error().stack)}setParent(t,i){let r=this.getDisposableData(t);r.parent=i}markAsDisposed(t){this.livingDisposables.delete(t)}markAsSingleton(t){this.getDisposableData(t).isSingleton=!0}getRootParent(t,i){let r=i.get(t);if(r)return r;let s=t.parent?this.getRootParent(this.getDisposableData(t.parent),i):t;return i.set(t,s),s}getTrackedDisposables(){let t=new Map;return[...this.livingDisposables.entries()].filter(([,i])=>i.source!==null&&!this.getRootParent(i,t).isSingleton).flatMap(([i])=>i)}computeLeakingDisposables(t=10,i){let r;if(i)r=i;else{let l=new Map,h=[...this.livingDisposables.values()].filter(d=>d.source!==null&&!this.getRootParent(d,l).isSingleton);if(h.length===0)return;let c=new Set(h.map(d=>d.value));if(r=h.filter(d=>!(d.parent&&c.has(d.parent))),r.length===0)throw new Error("There are cyclic diposable chains!")}if(!r)return;function s(l){function h(d,u){for(;d.length>0&&u.some(g=>typeof g=="string"?g===d[0]:d[0].match(g));)d.shift()}let c=l.source.split(`
|
|
6
|
+
`).map(d=>d.trim().replace("at ","")).filter(d=>d!=="");return h(c,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),c.reverse()}let o=new Ms;for(let l of r){let h=s(l);for(let c=0;c<=h.length;c++)o.add(h.slice(0,c).join(`
|
|
7
|
+
`),l)}r.sort(bs(l=>l.idx,Ls));let n="",a=0;for(let l of r.slice(0,t)){a++;let h=s(l),c=[];for(let d=0;d<h.length;d++){let u=h[d];u=`(shared with ${o.get(h.slice(0,d+1).join(`
|
|
8
|
+
`)).size}/${r.length} leaks) at ${u}`;let g=o.get(h.slice(0,d).join(`
|
|
9
|
+
`)),L=ys([...g].map(A=>s(A)[d]),A=>A);delete L[h[d]];for(let[A,B]of Object.entries(L))c.unshift(` - stacktraces of ${B.length} other leaks continue with ${A}`);c.unshift(u)}n+=`
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
==================== Leaking disposable ${a}/${r.length}: ${l.value.constructor.name} ====================
|
|
13
|
+
${c.join(`
|
|
14
|
+
`)}
|
|
15
|
+
============================================================
|
|
16
|
+
|
|
17
|
+
`}return r.length>t&&(n+=`
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
... and ${r.length-t} more leaking disposables
|
|
21
|
+
|
|
22
|
+
`),{leaks:r,details:n}}};Rs.idx=0;function Ts(e){Te=e}if(As){let e="__is_disposable_tracked__";Ts(new class{trackDisposable(t){let i=new Error("Potentially leaked disposable").stack;setTimeout(()=>{t[e]||console.log(i)},3e3)}setParent(t,i){if(t&&t!==ee.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==ee.None)try{t[e]=!0}catch{}}markAsSingleton(t){}})}function Ke(e){return Te?.trackDisposable(e),e}function Xe(e){Te?.markAsDisposed(e)}function $e(e,t){Te?.setParent(e,t)}function Es(e,t){if(Te)for(let i of e)Te.setParent(i,t)}function Zt(e){if(Xt.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Qt(...e){let t=H(()=>Zt(e));return Es(e,t),t}function H(e){let t=Ke({dispose:Ss(()=>{Xe(t),e()})});return t}var Jt=class ts{constructor(){this._toDispose=new Set,this._isDisposed=!1,Ke(this)}dispose(){this._isDisposed||(Xe(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Zt(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return $e(t,this),this._isDisposed?ts.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),$e(t,null))}};Jt.DISABLE_DISPOSED_WARNING=!1;var Ee=Jt,ee=class{constructor(){this._store=new Ee,Ke(this),$e(this._store,this)}dispose(){Xe(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ee.None=Object.freeze({dispose(){}});var Ie=class{constructor(){this._isDisposed=!1,Ke(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&$e(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,Xe(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&$e(e,null),e}},_t=typeof process<"u"&&"title"in process,Oe=_t?"node":navigator.userAgent,gt=_t?"node":navigator.platform,ks=Oe.includes("Firefox"),Bs=Oe.includes("Edge"),ei=/^((?!chrome|android).)*safari/i.test(Oe);function Ds(){if(!ei)return 0;let e=Oe.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Sn=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(gt),An=["Windows","Win16","Win32","WinCE"].includes(gt),Rn=gt.indexOf("Linux")>=0,Tn=/\bCrOS\b/.test(Oe),Ps="",U=0,N=0,G=0,$=0,se={css:"#00000000",rgba:0},K;(e=>{function t(s,o,n,a){return a!==void 0?`#${Re(s)}${Re(o)}${Re(n)}${Re(a)}`:`#${Re(s)}${Re(o)}${Re(n)}`}e.toCss=t;function i(s,o,n,a=255){return(s<<24|o<<16|n<<8|a)>>>0}e.toRgba=i;function r(s,o,n,a){return{css:e.toCss(s,o,n,a),rgba:e.toRgba(s,o,n,a)}}e.toColor=r})(K||={});var We;(e=>{function t(l,h){if($=(h.rgba&255)/255,$===1)return{css:h.css,rgba:h.rgba};let c=h.rgba>>24&255,d=h.rgba>>16&255,u=h.rgba>>8&255,g=l.rgba>>24&255,L=l.rgba>>16&255,A=l.rgba>>8&255;U=g+Math.round((c-g)*$),N=L+Math.round((d-L)*$),G=A+Math.round((u-A)*$);let B=K.toCss(U,N,G),j=K.toRgba(U,N,G);return{css:B,rgba:j}}e.blend=t;function i(l){return(l.rgba&255)===255}e.isOpaque=i;function r(l,h,c){let d=Ae.ensureContrastRatio(l.rgba,h.rgba,c);if(d)return K.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=r;function s(l){let h=(l.rgba|255)>>>0;return[U,N,G]=Ae.toChannels(h),{css:K.toCss(U,N,G),rgba:h}}e.opaque=s;function o(l,h){return $=Math.round(h*255),[U,N,G]=Ae.toChannels(l.rgba),{css:K.toCss(U,N,G,$),rgba:K.toRgba(U,N,G,$)}}e.opacity=o;function n(l,h){return $=l.rgba&255,o(l,$*h/255)}e.multiplyOpacity=n;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=a})(We||={});var Fs;(e=>{let t,i;try{let s=document.createElement("canvas");s.width=1,s.height=1;let o=s.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function r(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return U=parseInt(s.slice(1,2).repeat(2),16),N=parseInt(s.slice(2,3).repeat(2),16),G=parseInt(s.slice(3,4).repeat(2),16),K.toColor(U,N,G);case 5:return U=parseInt(s.slice(1,2).repeat(2),16),N=parseInt(s.slice(2,3).repeat(2),16),G=parseInt(s.slice(3,4).repeat(2),16),$=parseInt(s.slice(4,5).repeat(2),16),K.toColor(U,N,G,$);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let o=s.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 U=parseInt(o[1]),N=parseInt(o[2]),G=parseInt(o[3]),$=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),K.toColor(U,N,G,$);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=s,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[U,N,G,$]=t.getImageData(0,0,1,1).data,$!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:K.toRgba(U,N,G,$),css:s}}e.toColor=r})(Fs||={});var X;(e=>{function t(r){return i(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function i(r,s,o){let n=r/255,a=s/255,l=o/255,h=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return h*.2126+c*.7152+d*.0722}e.relativeLuminance2=i})(X||={});var Ae;(e=>{function t(n,a){if($=(a&255)/255,$===1)return a;let l=a>>24&255,h=a>>16&255,c=a>>8&255,d=n>>24&255,u=n>>16&255,g=n>>8&255;return U=d+Math.round((l-d)*$),N=u+Math.round((h-u)*$),G=g+Math.round((c-g)*$),K.toRgba(U,N,G)}e.blend=t;function i(n,a,l){let h=X.relativeLuminance(n>>8),c=X.relativeLuminance(a>>8);if(ue(h,c)<l){if(c<h){let g=r(n,a,l),L=ue(h,X.relativeLuminance(g>>8));if(L<l){let A=s(n,a,l),B=ue(h,X.relativeLuminance(A>>8));return L>B?g:A}return g}let d=s(n,a,l),u=ue(h,X.relativeLuminance(d>>8));if(u<l){let g=r(n,a,l),L=ue(h,X.relativeLuminance(g>>8));return u>L?d:g}return d}}e.ensureContrastRatio=i;function r(n,a,l){let h=n>>24&255,c=n>>16&255,d=n>>8&255,u=a>>24&255,g=a>>16&255,L=a>>8&255,A=ue(X.relativeLuminance2(u,g,L),X.relativeLuminance2(h,c,d));for(;A<l&&(u>0||g>0||L>0);)u-=Math.max(0,Math.ceil(u*.1)),g-=Math.max(0,Math.ceil(g*.1)),L-=Math.max(0,Math.ceil(L*.1)),A=ue(X.relativeLuminance2(u,g,L),X.relativeLuminance2(h,c,d));return(u<<24|g<<16|L<<8|255)>>>0}e.reduceLuminance=r;function s(n,a,l){let h=n>>24&255,c=n>>16&255,d=n>>8&255,u=a>>24&255,g=a>>16&255,L=a>>8&255,A=ue(X.relativeLuminance2(u,g,L),X.relativeLuminance2(h,c,d));for(;A<l&&(u<255||g<255||L<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),g=Math.min(255,g+Math.ceil((255-g)*.1)),L=Math.min(255,L+Math.ceil((255-L)*.1)),A=ue(X.relativeLuminance2(u,g,L),X.relativeLuminance2(h,c,d));return(u<<24|g<<16|L<<8|255)>>>0}e.increaseLuminance=s;function o(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]}e.toChannels=o})(Ae||={});function Re(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ue(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function O(e){if(!e)throw new Error("value must not be falsy");return e}function ft(e){return 57508<=e&&e<=57558}function $s(e){return 57520<=e&&e<=57527}function Is(e){return 57344<=e&&e<=63743}function Os(e){return 9472<=e&&e<=9631}function Ws(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function zs(e,t,i,r){return t===1&&i>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!Ws(e)&&!ft(e)&&!Is(e)}function ti(e){return ft(e)||Os(e)}function Us(){return{css:{canvas:Ze(),cell:Ze()},device:{canvas:Ze(),cell:Ze(),char:{width:0,height:0,left:0,top:0}}}}function Ze(){return{width:0,height:0}}function Ns(e,t,i=0){return(e-(Math.round(t)*2-i))%(Math.round(t)*2)}var V=0,q=0,he=!1,_e=!1,Qe=!1,Z,vt=0,Gs=class{constructor(e,t,i,r,s,o){this._terminal=e,this._optionService=t,this._selectionRenderModel=i,this._decorationService=r,this._coreBrowserService=s,this._themeService=o,this.result={fg:0,bg:0,ext:0}}resolve(e,t,i,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,q=0,V=0,_e=!1,he=!1,Qe=!1,Z=this._themeService.colors,vt=0,e.getCode()!==0&&e.extended.underlineStyle===4){let s=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));vt=t*r%(Math.round(s)*2)}if(this._decorationService.forEachDecorationAtCell(t,i,"bottom",s=>{s.backgroundColorRGB&&(q=s.backgroundColorRGB.rgba>>8&16777215,_e=!0),s.foregroundColorRGB&&(V=s.foregroundColorRGB.rgba>>8&16777215,he=!0)}),Qe=this._selectionRenderModel.isCellSelected(this._terminal,t,i),Qe){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:q=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:q=(this.result.fg&16777215)<<8|255;break;case 0:default:q=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:q=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:q=(this.result.bg&16777215)<<8|255;break}q=Ae.blend(q,(this._coreBrowserService.isFocused?Z.selectionBackgroundOpaque:Z.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else q=(this._coreBrowserService.isFocused?Z.selectionBackgroundOpaque:Z.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(_e=!0,Z.selectionForeground&&(V=Z.selectionForeground.rgba>>8&16777215,he=!0),ti(e.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)V=(this._coreBrowserService.isFocused?Z.selectionBackgroundOpaque:Z.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:V=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:V=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:V=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:V=(this.result.fg&16777215)<<8|255;break;case 0:default:V=this._themeService.colors.foreground.rgba}V=Ae.blend(V,(this._coreBrowserService.isFocused?Z.selectionBackgroundOpaque:Z.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}he=!0}}this._decorationService.forEachDecorationAtCell(t,i,"top",s=>{s.backgroundColorRGB&&(q=s.backgroundColorRGB.rgba>>8&16777215,_e=!0),s.foregroundColorRGB&&(V=s.foregroundColorRGB.rgba>>8&16777215,he=!0)}),_e&&(Qe?q=e.bg&-16777216&-134217729|q|50331648:q=e.bg&-16777216|q|50331648),he&&(V=e.fg&-16777216&-67108865|V|50331648),this.result.fg&67108864&&(_e&&!he&&((this.result.bg&50331648)===0?V=this.result.fg&-134217728|Z.background.rgba>>8&16777215&16777215|50331648:V=this.result.fg&-134217728|this.result.bg&67108863,he=!0),!_e&&he&&((this.result.fg&50331648)===0?q=this.result.bg&-67108864|Z.foreground.rgba>>8&16777215&16777215|50331648:q=this.result.bg&-67108864|this.result.fg&67108863,_e=!0)),Z=void 0,this.result.bg=_e?q:this.result.bg,this.result.fg=he?V:this.result.fg,this.result.ext&=536870911,this.result.ext|=vt<<29&3758096384}},qs=.5,ii=ks||Bs?"bottom":"ideographic",Hs={"\u2580":[{x:0,y:0,w:8,h:4}],"\u2581":[{x:0,y:7,w:8,h:1}],"\u2582":[{x:0,y:6,w:8,h:2}],"\u2583":[{x:0,y:5,w:8,h:3}],"\u2584":[{x:0,y:4,w:8,h:4}],"\u2585":[{x:0,y:3,w:8,h:5}],"\u2586":[{x:0,y:2,w:8,h:6}],"\u2587":[{x:0,y:1,w:8,h:7}],"\u2588":[{x:0,y:0,w:8,h:8}],"\u2589":[{x:0,y:0,w:7,h:8}],"\u258A":[{x:0,y:0,w:6,h:8}],"\u258B":[{x:0,y:0,w:5,h:8}],"\u258C":[{x:0,y:0,w:4,h:8}],"\u258D":[{x:0,y:0,w:3,h:8}],"\u258E":[{x:0,y:0,w:2,h:8}],"\u258F":[{x:0,y:0,w:1,h:8}],"\u2590":[{x:4,y:0,w:4,h:8}],"\u2594":[{x:0,y:0,w:8,h:1}],"\u2595":[{x:7,y:0,w:1,h:8}],"\u2596":[{x:0,y:4,w:4,h:4}],"\u2597":[{x:4,y:4,w:4,h:4}],"\u2598":[{x:0,y:0,w:4,h:4}],"\u2599":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"\u259A":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"\u259B":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"\u259C":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"\u259D":[{x:4,y:0,w:4,h:4}],"\u259E":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"\u259F":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"\u{1FB70}":[{x:1,y:0,w:1,h:8}],"\u{1FB71}":[{x:2,y:0,w:1,h:8}],"\u{1FB72}":[{x:3,y:0,w:1,h:8}],"\u{1FB73}":[{x:4,y:0,w:1,h:8}],"\u{1FB74}":[{x:5,y:0,w:1,h:8}],"\u{1FB75}":[{x:6,y:0,w:1,h:8}],"\u{1FB76}":[{x:0,y:1,w:8,h:1}],"\u{1FB77}":[{x:0,y:2,w:8,h:1}],"\u{1FB78}":[{x:0,y:3,w:8,h:1}],"\u{1FB79}":[{x:0,y:4,w:8,h:1}],"\u{1FB7A}":[{x:0,y:5,w:8,h:1}],"\u{1FB7B}":[{x:0,y:6,w:8,h:1}],"\u{1FB7C}":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"\u{1FB7D}":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"\u{1FB7E}":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"\u{1FB7F}":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"\u{1FB80}":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"\u{1FB81}":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"\u{1FB82}":[{x:0,y:0,w:8,h:2}],"\u{1FB83}":[{x:0,y:0,w:8,h:3}],"\u{1FB84}":[{x:0,y:0,w:8,h:5}],"\u{1FB85}":[{x:0,y:0,w:8,h:6}],"\u{1FB86}":[{x:0,y:0,w:8,h:7}],"\u{1FB87}":[{x:6,y:0,w:2,h:8}],"\u{1FB88}":[{x:5,y:0,w:3,h:8}],"\u{1FB89}":[{x:3,y:0,w:5,h:8}],"\u{1FB8A}":[{x:2,y:0,w:6,h:8}],"\u{1FB8B}":[{x:1,y:0,w:7,h:8}],"\u{1FB95}":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"\u{1FB96}":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"\u{1FB97}":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Vs={"\u2591":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"\u2592":[[1,0],[0,0],[0,1],[0,0]],"\u2593":[[0,1],[1,1],[1,0],[1,1]]},js={"\u2500":{1:"M0,.5 L1,.5"},"\u2501":{3:"M0,.5 L1,.5"},"\u2502":{1:"M.5,0 L.5,1"},"\u2503":{3:"M.5,0 L.5,1"},"\u250C":{1:"M0.5,1 L.5,.5 L1,.5"},"\u250F":{3:"M0.5,1 L.5,.5 L1,.5"},"\u2510":{1:"M0,.5 L.5,.5 L.5,1"},"\u2513":{3:"M0,.5 L.5,.5 L.5,1"},"\u2514":{1:"M.5,0 L.5,.5 L1,.5"},"\u2517":{3:"M.5,0 L.5,.5 L1,.5"},"\u2518":{1:"M.5,0 L.5,.5 L0,.5"},"\u251B":{3:"M.5,0 L.5,.5 L0,.5"},"\u251C":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"\u2523":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"\u2524":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"\u252B":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"\u252C":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"\u2533":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"\u2534":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"\u253B":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"\u253C":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"\u254B":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"\u2574":{1:"M.5,.5 L0,.5"},"\u2578":{3:"M.5,.5 L0,.5"},"\u2575":{1:"M.5,.5 L.5,0"},"\u2579":{3:"M.5,.5 L.5,0"},"\u2576":{1:"M.5,.5 L1,.5"},"\u257A":{3:"M.5,.5 L1,.5"},"\u2577":{1:"M.5,.5 L.5,1"},"\u257B":{3:"M.5,.5 L.5,1"},"\u2550":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"\u2551":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"\u2552":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"\u2553":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"\u2554":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"\u2555":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"\u2556":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"\u2557":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"\u2558":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"\u2559":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"\u255A":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"\u255B":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"\u255C":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"\u255D":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"\u255E":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"\u255F":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"\u2560":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"\u2561":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"\u2562":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"\u2563":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"\u2564":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"\u2565":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"\u2566":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"\u2567":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"\u2568":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"\u2569":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"\u256A":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"\u256B":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"\u256C":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"\u2571":{1:"M1,0 L0,1"},"\u2572":{1:"M0,0 L1,1"},"\u2573":{1:"M1,0 L0,1 M0,0 L1,1"},"\u257C":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"\u257D":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"\u257E":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"\u257F":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"\u250D":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"\u250E":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"\u2511":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"\u2512":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"\u2515":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"\u2516":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"\u2519":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"\u251A":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"\u251D":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"\u251E":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"\u251F":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"\u2520":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"\u2521":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"\u2522":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"\u2525":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"\u2526":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"\u2527":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"\u2528":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"\u2529":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"\u252A":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"\u252D":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"\u252E":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"\u252F":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"\u2530":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"\u2531":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"\u2532":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"\u2535":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"\u2536":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"\u2537":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"\u2538":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"\u2539":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"\u253A":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"\u253D":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"\u253E":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"\u253F":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"\u2540":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"\u2541":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"\u2542":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"\u2543":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"\u2544":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"\u2545":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"\u2546":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"\u2547":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"\u2548":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"\u2549":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"\u254A":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"\u254C":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"\u254D":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"\u2504":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"\u2505":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"\u2508":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"\u2509":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"\u254E":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"\u254F":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"\u2506":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"\u2507":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"\u250A":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"\u250B":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"\u256D":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"\u256E":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"\u256F":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"\u2570":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},ze={"\uE0A0":{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0},"\uE0A1":{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0},"\uE0A2":{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0},"\uE0B0":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"\uE0B1":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"\uE0B2":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"\uE0B3":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"\uE0B4":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"\uE0B5":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"\uE0B6":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"\uE0B7":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"\uE0B8":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"\uE0B9":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"\uE0BA":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"\uE0BC":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"\uE0BD":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"\uE0BE":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};ze["\uE0BB"]=ze["\uE0BD"],ze["\uE0BF"]=ze["\uE0B9"];function Ys(e,t,i,r,s,o,n,a){let l=Hs[t];if(l)return Ks(e,l,i,r,s,o),!0;let h=Vs[t];if(h)return Xs(e,h,i,r,s,o),!0;let c=js[t];if(c)return Zs(e,c,i,r,s,o,a),!0;let d=ze[t];return d?(Qs(e,d,i,r,s,o,n,a),!0):!1}function Ks(e,t,i,r,s,o){for(let n=0;n<t.length;n++){let a=t[n],l=s/8,h=o/8;e.fillRect(i+a.x*l,r+a.y*h,a.w*l,a.h*h)}}var si=new Map;function Xs(e,t,i,r,s,o){let n=si.get(t);n||(n=new Map,si.set(t,n));let a=e.fillStyle;if(typeof a!="string")throw new Error(`Unexpected fillStyle type "${a}"`);let l=n.get(a);if(!l){let h=t[0].length,c=t.length,d=e.canvas.ownerDocument.createElement("canvas");d.width=h,d.height=c;let u=O(d.getContext("2d")),g=new ImageData(h,c),L,A,B,j;if(a.startsWith("#"))L=parseInt(a.slice(1,3),16),A=parseInt(a.slice(3,5),16),B=parseInt(a.slice(5,7),16),j=a.length>7&&parseInt(a.slice(7,9),16)||1;else if(a.startsWith("rgba"))[L,A,B,j]=a.substring(5,a.length-1).split(",").map(R=>parseFloat(R));else throw new Error(`Unexpected fillStyle color format "${a}" when drawing pattern glyph`);for(let R=0;R<c;R++)for(let M=0;M<h;M++)g.data[(R*h+M)*4]=L,g.data[(R*h+M)*4+1]=A,g.data[(R*h+M)*4+2]=B,g.data[(R*h+M)*4+3]=t[R][M]*(j*255);u.putImageData(g,0,0),l=O(e.createPattern(d,null)),n.set(a,l)}e.fillStyle=l,e.fillRect(i,r,s,o)}function Zs(e,t,i,r,s,o,n){e.strokeStyle=e.fillStyle;for(let[a,l]of Object.entries(t)){e.beginPath(),e.lineWidth=n*Number.parseInt(a);let h;if(typeof l=="function"){let c=.15/o*s;h=l(.15,c)}else h=l;for(let c of h.split(" ")){let d=c[0],u=ni[d];if(!u){console.error(`Could not find drawing instructions for "${d}"`);continue}let g=c.substring(1).split(",");!g[0]||!g[1]||u(e,oi(g,s,o,i,r,!0,n))}e.stroke(),e.closePath()}}function Qs(e,t,i,r,s,o,n,a){let l=new Path2D;l.rect(i,r,s,o),e.clip(l),e.beginPath();let h=n/12;e.lineWidth=a*h;for(let c of t.d.split(" ")){let d=c[0],u=ni[d];if(!u){console.error(`Could not find drawing instructions for "${d}"`);continue}let g=c.substring(1).split(",");!g[0]||!g[1]||u(e,oi(g,s,o,i,r,!1,a,(t.leftPadding??0)*(h/2),(t.rightPadding??0)*(h/2)))}t.type===1?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}function ri(e,t,i=0){return Math.max(Math.min(e,t),i)}var ni={C:(e,t)=>e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function oi(e,t,i,r,s,o,n,a=0,l=0){let h=e.map(c=>parseFloat(c)||parseInt(c));if(h.length<2)throw new Error("Too few arguments for instruction");for(let c=0;c<h.length;c+=2)h[c]*=t-a*n-l*n,o&&h[c]!==0&&(h[c]=ri(Math.round(h[c]+.5)-.5,t,0)),h[c]+=r+a*n;for(let c=1;c<h.length;c+=2)h[c]*=i,o&&h[c]!==0&&(h[c]=ri(Math.round(h[c]+.5)-.5,i,0)),h[c]+=s;return h}var ai=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},hi=class{constructor(){this._data=new ai}set(e,t,i,r,s){this._data.get(e,t)||this._data.set(e,t,new ai),this._data.get(e,t).set(i,r,s)}get(e,t,i,r){return this._data.get(e,t)?.get(i,r)}clear(){this._data.clear()}},li=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,r=e.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),s=e.timeRemaining(),i*1.5>s){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=s}this.clear()}},Js=class extends li{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},er=class extends li{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},tr=!_t&&"requestIdleCallback"in window?er:Js,ke=class is{constructor(){this.fg=0,this.bg=0,this.extended=new ci}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new is;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ci=class ss{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new ss(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},di=class zt{constructor(t){this.element=t,this.next=zt.Undefined,this.prev=zt.Undefined}};di.Undefined=new di(void 0);var ir=globalThis.performance&&typeof globalThis.performance.now=="function",sr=class rs{static create(t){return new rs(t)}constructor(t){this._now=ir&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},rr=!1,ui=!1,nr=!1,ge;(e=>{e.None=()=>ee.None;function t(C){if(nr){let{onDidAddListener:_}=C,x=mt.create(),p=0;C.onDidAddListener=()=>{++p===2&&(console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"),x.print()),_?.()}}}function i(C,_){return u(C,()=>{},0,void 0,!0,void 0,_)}e.defer=i;function r(C){return(_,x=null,p)=>{let f=!1,v;return v=C(m=>{if(!f)return v?v.dispose():f=!0,_.call(x,m)},null,p),f&&v.dispose(),v}}e.once=r;function s(C,_,x){return c((p,f=null,v)=>C(m=>p.call(f,_(m)),null,v),x)}e.map=s;function o(C,_,x){return c((p,f=null,v)=>C(m=>{_(m),p.call(f,m)},null,v),x)}e.forEach=o;function n(C,_,x){return c((p,f=null,v)=>C(m=>_(m)&&p.call(f,m),null,v),x)}e.filter=n;function a(C){return C}e.signal=a;function l(...C){return(_,x=null,p)=>{let f=Qt(...C.map(v=>v(m=>_.call(x,m))));return d(f,p)}}e.any=l;function h(C,_,x,p){let f=x;return s(C,v=>(f=_(f,v),f),p)}e.reduce=h;function c(C,_){let x,p={onWillAddFirstListener(){x=C(f.fire,f)},onDidRemoveLastListener(){x?.dispose()}};_||t(p);let f=new k(p);return _?.add(f),f.event}function d(C,_){return _ instanceof Array?_.push(C):_&&_.add(C),C}function u(C,_,x=100,p=!1,f=!1,v,m){let w,S,z,P=0,oe,be={leakWarningThreshold:v,onWillAddFirstListener(){w=C(Q=>{P++,S=_(S,Q),p&&!z&&(ie.fire(S),S=void 0),oe=()=>{let F=S;S=void 0,z=void 0,(!p||P>1)&&ie.fire(F),P=0},typeof x=="number"?(clearTimeout(z),z=setTimeout(oe,x)):z===void 0&&(z=0,queueMicrotask(oe))})},onWillRemoveListener(){f&&P>0&&oe?.()},onDidRemoveLastListener(){oe=void 0,w.dispose()}};m||t(be);let ie=new k(be);return m?.add(ie),ie.event}e.debounce=u;function g(C,_=0,x){return e.debounce(C,(p,f)=>p?(p.push(f),p):[f],_,void 0,!0,void 0,x)}e.accumulate=g;function L(C,_=(p,f)=>p===f,x){let p=!0,f;return n(C,v=>{let m=p||!_(v,f);return p=!1,f=v,m},x)}e.latch=L;function A(C,_,x){return[e.filter(C,_,x),e.filter(C,p=>!_(p),x)]}e.split=A;function B(C,_=!1,x=[],p){let f=x.slice(),v=C(S=>{f?f.push(S):w.fire(S)});p&&p.add(v);let m=()=>{f?.forEach(S=>w.fire(S)),f=null},w=new k({onWillAddFirstListener(){v||(v=C(S=>w.fire(S)),p&&p.add(v))},onDidAddFirstListener(){f&&(_?setTimeout(m):m())},onDidRemoveLastListener(){v&&v.dispose(),v=null}});return p&&p.add(w),w.event}e.buffer=B;function j(C,_){return(x,p,f)=>{let v=_(new M);return C(function(m){let w=v.evaluate(m);w!==R&&x.call(p,w)},void 0,f)}}e.chain=j;let R=Symbol("HaltChainable");class M{constructor(){this.steps=[]}map(_){return this.steps.push(_),this}forEach(_){return this.steps.push(x=>(_(x),x)),this}filter(_){return this.steps.push(x=>_(x)?x:R),this}reduce(_,x){let p=x;return this.steps.push(f=>(p=_(p,f),p)),this}latch(_=(x,p)=>x===p){let x=!0,p;return this.steps.push(f=>{let v=x||!_(f,p);return x=!1,p=f,v?f:R}),this}evaluate(_){for(let x of this.steps)if(_=x(_),_===R)break;return _}}function b(C,_,x=p=>p){let p=(...w)=>m.fire(x(...w)),f=()=>C.on(_,p),v=()=>C.removeListener(_,p),m=new k({onWillAddFirstListener:f,onDidRemoveLastListener:v});return m.event}e.fromNodeEventEmitter=b;function y(C,_,x=p=>p){let p=(...w)=>m.fire(x(...w)),f=()=>C.addEventListener(_,p),v=()=>C.removeEventListener(_,p),m=new k({onWillAddFirstListener:f,onDidRemoveLastListener:v});return m.event}e.fromDOMEventEmitter=y;function T(C){return new Promise(_=>r(C)(_))}e.toPromise=T;function W(C){let _=new k;return C.then(x=>{_.fire(x)},()=>{_.fire(void 0)}).finally(()=>{_.dispose()}),_.event}e.fromPromise=W;function Y(C,_){return C(x=>_.fire(x))}e.forward=Y;function ae(C,_,x){return _(x),C(p=>_(p))}e.runAndSubscribe=ae;class Ce{constructor(_,x){this._observable=_,this._counter=0,this._hasChanged=!1;let p={onWillAddFirstListener:()=>{_.addObserver(this)},onDidRemoveLastListener:()=>{_.removeObserver(this)}};x||t(p),this.emitter=new k(p),x&&x.add(this.emitter)}beginUpdate(_){this._counter++}handlePossibleChange(_){}handleChange(_,x){this._hasChanged=!0}endUpdate(_){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(C,_){return new Ce(C,_).emitter.event}e.fromObservable=E;function xe(C){return(_,x,p)=>{let f=0,v=!1,m={beginUpdate(){f++},endUpdate(){f--,f===0&&(C.reportChanges(),v&&(v=!1,_.call(x)))},handlePossibleChange(){},handleChange(){v=!0}};C.addObserver(m),C.reportChanges();let w={dispose(){C.removeObserver(m)}};return p instanceof Ee?p.add(w):Array.isArray(p)&&p.push(w),w}}e.fromObservableLight=xe})(ge||={});var pt=class Ut{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Ut._idPool++}`,Ut.all.add(this)}start(t){this._stopWatch=new sr,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};pt.all=new Set,pt._idPool=0;var or=pt,_i=-1,gi=class ns{constructor(t,i,r=(ns._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let r=this.threshold;if(r<=0||i<r)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[o,n]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${n}):`;console.warn(a),console.warn(o);let l=new hr(a,o);this._errorHandler(l)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[r,s]of this._stacks)(!t||i<s)&&(t=[r,s],i=s);return t}};gi._idPool=1;var ar=gi,mt=class os{constructor(t){this.value=t}static create(){let t=new Error;return new os(t.stack??"")}print(){console.warn(this.value.split(`
|
|
23
|
+
`).slice(2).join(`
|
|
24
|
+
`))}},hr=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},lr=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},cr=0,Je=class{constructor(e){this.value=e,this.id=cr++}},dr=2,ur=(e,t)=>{if(e instanceof Je)t(e);else for(let i=0;i<e.length;i++){let r=e[i];r&&t(r)}},et;if(rr){let e=[];setInterval(()=>{e.length!==0&&(console.warn("[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:"),console.warn(e.join(`
|
|
25
|
+
`)),e.length=0)},3e3),et=new FinalizationRegistry(t=>{typeof t=="string"&&e.push(t)})}var k=class{constructor(e){this._size=0,this._options=e,this._leakageMon=_i>0||this._options?.leakWarningThreshold?new ar(e?.onListenerError??Ye,this._options?.leakWarningThreshold??_i):void 0,this._perfMon=this._options?._profName?new or(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(ui){let e=this._listeners;queueMicrotask(()=>{ur(e,t=>t.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],h=new lr(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Ye)(h),ee.None}if(this._disposed)return ee.None;t&&(e=e.bind(t));let r=new Je(e),s,o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=mt.create(),s=this._leakageMon.check(r.stack,this._size+1)),ui&&(r.stack=o??mt.create()),this._listeners?this._listeners instanceof Je?(this._deliveryQueue??=new _r,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=H(()=>{et?.unregister(n),s?.(),this._removeListener(r)});if(i instanceof Ee?i.add(n):Array.isArray(i)&&i.push(n),et){let a=new Error().stack.split(`
|
|
26
|
+
`).slice(2,3).join(`
|
|
27
|
+
`).trim(),l=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);et.register(n,l?.[2]??a,n)}return n},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*dr<=t.length){let s=0;for(let o=0;o<t.length;o++)t[o]?t[s++]=t[o]:r&&(this._deliveryQueue.end--,s<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=s}}_deliver(e,t){if(!e)return;let i=this._options?.onListenerError||Ye;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Je)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},_r=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},fi={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},Ue=2,Ne,Le=class Fe{constructor(t,i,r){this._document=t,this._config=i,this._unicodeService=r,this._didWarmUp=!1,this._cacheMap=new hi,this._cacheMapCombined=new hi,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new ke,this._textureSize=512,this._onAddTextureAtlasCanvas=new k,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new k,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=vi(t,this._config.deviceCellWidth*4+Ue*2,this._config.deviceCellHeight+Ue*2),this._tmpCtx=O(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let t of this.pages)t.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let t=new tr;for(let i=33;i<126;i++)t.enqueue(()=>{if(!this._cacheMap.get(i,0,0,0)){let r=this._drawToCache(i,0,0,0,!1,void 0);this._cacheMap.set(i,0,0,0,r)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let t of this._pages)t.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Fe.maxAtlasPages&&this._pages.length>=Math.max(4,Fe.maxAtlasPages)){let i=this._pages.filter(h=>h.canvas.width*2<=(Fe.maxTextureSize||4096)).sort((h,c)=>c.canvas.width!==h.canvas.width?c.canvas.width-h.canvas.width:c.percentageUsed-h.percentageUsed),r=-1,s=0;for(let h=0;h<i.length;h++)if(i[h].canvas.width!==s)r=h,s=i[h].canvas.width;else if(h-r===3)break;let o=i.slice(r,r+4),n=o.map(h=>h.glyphs[0].texturePage).sort((h,c)=>h>c?1:-1),a=this.pages.length-o.length,l=this._mergePages(o,a);l.version++;for(let h=n.length-1;h>=0;h--)this._deletePage(n[h]);this.pages.push(l),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(l.canvas)}let t=new wt(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(t,i){let r=t[0].canvas.width*2,s=new wt(this._document,r,t);for(let[o,n]of t.entries()){let a=o*n.canvas.width%r,l=Math.floor(o/2)*n.canvas.height;s.ctx.drawImage(n.canvas,a,l);for(let c of n.glyphs)c.texturePage=i,c.sizeClipSpace.x=c.size.x/r,c.sizeClipSpace.y=c.size.y/r,c.texturePosition.x+=a,c.texturePosition.y+=l,c.texturePositionClipSpace.x=c.texturePosition.x/r,c.texturePositionClipSpace.y=c.texturePosition.y/r;this._onRemoveTextureAtlasCanvas.fire(n.canvas);let h=this._activePages.indexOf(n);h!==-1&&this._activePages.splice(h,1)}return s}_deletePage(t){this._pages.splice(t,1);for(let i=t;i<this._pages.length;i++){let r=this._pages[i];for(let s of r.glyphs)s.texturePage--;r.version++}}getRasterizedGlyphCombinedChar(t,i,r,s,o,n){return this._getFromCacheMap(this._cacheMapCombined,t,i,r,s,o,n)}getRasterizedGlyph(t,i,r,s,o,n){return this._getFromCacheMap(this._cacheMap,t,i,r,s,o,n)}_getFromCacheMap(t,i,r,s,o,n,a){return Ne=t.get(i,r,s,o),Ne||(Ne=this._drawToCache(i,r,s,o,n,a),t.set(i,r,s,o,Ne)),Ne}_getColorFromAnsiIndex(t){if(t>=this._config.colors.ansi.length)throw new Error("No color found for idx "+t);return this._config.colors.ansi[t]}_getBackgroundColor(t,i,r,s){if(this._config.allowTransparency)return se;let o;switch(t){case 16777216:case 33554432:o=this._getColorFromAnsiIndex(i);break;case 50331648:let n=ke.toColorRGB(i);o=K.toColor(n[0],n[1],n[2]);break;case 0:default:r?o=We.opaque(this._config.colors.foreground):o=this._config.colors.background;break}return this._config.allowTransparency||(o=We.opaque(o)),o}_getForegroundColor(t,i,r,s,o,n,a,l,h,c){let d=this._getMinimumContrastColor(t,i,r,s,o,n,a,h,l,c);if(d)return d;let u;switch(o){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&h&&n<8&&(n+=8),u=this._getColorFromAnsiIndex(n);break;case 50331648:let g=ke.toColorRGB(n);u=K.toColor(g[0],g[1],g[2]);break;case 0:default:a?u=this._config.colors.background:u=this._config.colors.foreground}return this._config.allowTransparency&&(u=We.opaque(u)),l&&(u=We.multiplyOpacity(u,qs)),u}_resolveBackgroundRgba(t,i,r){switch(t){case 16777216:case 33554432:return this._getColorFromAnsiIndex(i).rgba;case 50331648:return i<<8;case 0:default:return r?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(t,i,r,s){switch(t){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&s&&i<8&&(i+=8),this._getColorFromAnsiIndex(i).rgba;case 50331648:return i<<8;case 0:default:return r?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(t,i,r,s,o,n,a,l,h,c){if(this._config.minimumContrastRatio===1||c)return;let d=this._getContrastCache(h),u=d.getColor(t,s);if(u!==void 0)return u||void 0;let g=this._resolveBackgroundRgba(i,r,a),L=this._resolveForegroundRgba(o,n,a,l),A=Ae.ensureContrastRatio(g,L,this._config.minimumContrastRatio/(h?2:1));if(!A){d.setColor(t,s,null);return}let B=K.toColor(A>>24&255,A>>16&255,A>>8&255);return d.setColor(t,s,B),B}_getContrastCache(t){return t?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,i,r,s,o,n){let a=typeof t=="number"?String.fromCharCode(t):t;n&&this._tmpCanvas.parentElement!==n&&(this._tmpCanvas.style.display="none",n.append(this._tmpCanvas));let l=Math.min(this._config.deviceCellWidth*Math.max(a.length,2)+Ue*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<l&&(this._tmpCanvas.width=l);let h=Math.min(this._config.deviceCellHeight+Ue*4,this._textureSize);if(this._tmpCanvas.height<h&&(this._tmpCanvas.height=h),this._tmpCtx.save(),this._workAttributeData.fg=r,this._workAttributeData.bg=i,this._workAttributeData.extended.ext=s,!!this._workAttributeData.isInvisible())return fi;let c=!!this._workAttributeData.isBold(),d=!!this._workAttributeData.isInverse(),u=!!this._workAttributeData.isDim(),g=!!this._workAttributeData.isItalic(),L=!!this._workAttributeData.isUnderline(),A=!!this._workAttributeData.isStrikethrough(),B=!!this._workAttributeData.isOverline(),j=this._workAttributeData.getFgColor(),R=this._workAttributeData.getFgColorMode(),M=this._workAttributeData.getBgColor(),b=this._workAttributeData.getBgColorMode();if(d){let w=j;j=M,M=w;let S=R;R=b,b=S}let y=this._getBackgroundColor(b,M,d,u);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=y.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let T=c?this._config.fontWeightBold:this._config.fontWeight,W=g?"italic":"";this._tmpCtx.font=`${W} ${T} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=ii;let Y=a.length===1&&ft(a.charCodeAt(0)),ae=a.length===1&&$s(a.charCodeAt(0)),Ce=this._getForegroundColor(i,b,M,r,R,j,d,u,c,ti(a.charCodeAt(0)));this._tmpCtx.fillStyle=Ce.css;let E=ae?0:Ue*2,xe=!1;this._config.customGlyphs!==!1&&(xe=Ys(this._tmpCtx,a,E,E,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let C=!Y,_;if(typeof t=="number"?_=this._unicodeService.wcwidth(t):_=this._unicodeService.getStringCellWidth(t),L){this._tmpCtx.save();let w=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),S=w%2===1?.5:0;if(this._tmpCtx.lineWidth=w,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())C=!1,this._tmpCtx.strokeStyle=`rgb(${ke.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{C=!1;let Q=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&Q<8&&(Q+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(Q).css}this._tmpCtx.beginPath();let z=E,P=Math.ceil(E+this._config.deviceCharHeight)-S-(o?w*2:0),oe=P+w,be=P+w*2,ie=this._workAttributeData.getUnderlineVariantOffset();for(let Q=0;Q<_;Q++){this._tmpCtx.save();let F=z+Q*this._config.deviceCellWidth,J=z+(Q+1)*this._config.deviceCellWidth,ct=F+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(F,P),this._tmpCtx.lineTo(J,P),this._tmpCtx.moveTo(F,be),this._tmpCtx.lineTo(J,be);break;case 3:let He=w<=1?be:Math.ceil(E+this._config.deviceCharHeight-w/2)-S,Ve=w<=1?P:Math.ceil(E+this._config.deviceCharHeight+w/2)-S,Nt=new Path2D;Nt.rect(F,P,this._config.deviceCellWidth,be-P),this._tmpCtx.clip(Nt),this._tmpCtx.moveTo(F-this._config.deviceCellWidth/2,oe),this._tmpCtx.bezierCurveTo(F-this._config.deviceCellWidth/2,Ve,F,Ve,F,oe),this._tmpCtx.bezierCurveTo(F,He,ct,He,ct,oe),this._tmpCtx.bezierCurveTo(ct,Ve,J,Ve,J,oe),this._tmpCtx.bezierCurveTo(J,He,J+this._config.deviceCellWidth/2,He,J+this._config.deviceCellWidth/2,oe);break;case 4:let je=ie===0?0:ie>=w?w*2-ie:w-ie;ie>=w||je===0?(this._tmpCtx.setLineDash([Math.round(w),Math.round(w)]),this._tmpCtx.moveTo(F+je,P),this._tmpCtx.lineTo(J,P)):(this._tmpCtx.setLineDash([Math.round(w),Math.round(w)]),this._tmpCtx.moveTo(F,P),this._tmpCtx.lineTo(F+je,P),this._tmpCtx.moveTo(F+je+w,P),this._tmpCtx.lineTo(J,P)),ie=Ns(J-F,w,ie);break;case 5:let ls=.6,cs=.3,dt=J-F,Gt=Math.floor(ls*dt),qt=Math.floor(cs*dt),ds=dt-Gt-qt;this._tmpCtx.setLineDash([Gt,qt,ds]),this._tmpCtx.moveTo(F,P),this._tmpCtx.lineTo(J,P);break;case 1:default:this._tmpCtx.moveTo(F,P),this._tmpCtx.lineTo(J,P);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!xe&&this._config.fontSize>=12&&!this._config.allowTransparency&&a!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let Q=this._tmpCtx.measureText(a);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in Q&&Q.actualBoundingBoxDescent>0){this._tmpCtx.save();let F=new Path2D;F.rect(z,P-Math.ceil(w/2),this._config.deviceCellWidth*_,be-P+Math.ceil(w/2)),this._tmpCtx.clip(F),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=y.css,this._tmpCtx.strokeText(a,E,E+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(B){let w=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),S=w%2===1?.5:0;this._tmpCtx.lineWidth=w,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(E,E+S),this._tmpCtx.lineTo(E+this._config.deviceCharWidth*_,E+S),this._tmpCtx.stroke()}if(xe||this._tmpCtx.fillText(a,E,E+this._config.deviceCharHeight),a==="_"&&!this._config.allowTransparency){let w=Ct(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),y,Ce,C);if(w)for(let S=1;S<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=y.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(a,E,E+this._config.deviceCharHeight-S),w=Ct(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),y,Ce,C),!!w);S++);}if(A){let w=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),S=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=w,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(E,E+Math.floor(this._config.deviceCharHeight/2)-S),this._tmpCtx.lineTo(E+this._config.deviceCharWidth*_,E+Math.floor(this._config.deviceCharHeight/2)-S),this._tmpCtx.stroke()}this._tmpCtx.restore();let x=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),p;if(this._config.allowTransparency?p=gr(x):p=Ct(x,y,Ce,C),p)return fi;let f=this._findGlyphBoundingBox(x,this._workBoundingBox,l,ae,xe,E),v,m;for(;;){if(this._activePages.length===0){let w=this._createNewPage();v=w,m=w.currentRow,m.height=f.size.y;break}v=this._activePages[this._activePages.length-1],m=v.currentRow;for(let w of this._activePages)f.size.y<=w.currentRow.height&&(v=w,m=w.currentRow);for(let w=this._activePages.length-1;w>=0;w--)for(let S of this._activePages[w].fixedRows)S.height<=m.height&&f.size.y<=S.height&&(v=this._activePages[w],m=S);if(f.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new wt(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),v=this._overflowSizePage,m=this._overflowSizePage.currentRow,m.x+f.size.x>=v.canvas.width&&(m.x=0,m.y+=m.height,m.height=0);break}if(m.y+f.size.y>=v.canvas.height||m.height>f.size.y+2){let w=!1;if(v.currentRow.y+v.currentRow.height+f.size.y>=v.canvas.height){let S;for(let z of this._activePages)if(z.currentRow.y+z.currentRow.height+f.size.y<z.canvas.height){S=z;break}if(S)v=S;else if(Fe.maxAtlasPages&&this._pages.length>=Fe.maxAtlasPages&&m.y+f.size.y<=v.canvas.height&&m.height>=f.size.y&&m.x+f.size.x<=v.canvas.width)w=!0;else{let z=this._createNewPage();v=z,m=z.currentRow,m.height=f.size.y,w=!0}}w||(v.currentRow.height>0&&v.fixedRows.push(v.currentRow),m={x:0,y:v.currentRow.y+v.currentRow.height,height:f.size.y},v.fixedRows.push(m),v.currentRow={x:0,y:m.y+m.height,height:0})}if(m.x+f.size.x<=v.canvas.width)break;m===v.currentRow?(m.x=0,m.y+=m.height,m.height=0):v.fixedRows.splice(v.fixedRows.indexOf(m),1)}return f.texturePage=this._pages.indexOf(v),f.texturePosition.x=m.x,f.texturePosition.y=m.y,f.texturePositionClipSpace.x=m.x/v.canvas.width,f.texturePositionClipSpace.y=m.y/v.canvas.height,f.sizeClipSpace.x/=v.canvas.width,f.sizeClipSpace.y/=v.canvas.height,m.height=Math.max(m.height,f.size.y),m.x+=f.size.x,v.ctx.putImageData(x,f.texturePosition.x-this._workBoundingBox.left,f.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,f.size.x,f.size.y),v.addGlyph(f),v.version++,f}_findGlyphBoundingBox(t,i,r,s,o,n){i.top=0;let a=s?this._config.deviceCellHeight:this._tmpCanvas.height,l=s?this._config.deviceCellWidth:r,h=!1;for(let c=0;c<a;c++){for(let d=0;d<l;d++){let u=c*this._tmpCanvas.width*4+d*4+3;if(t.data[u]!==0){i.top=c,h=!0;break}}if(h)break}i.left=0,h=!1;for(let c=0;c<n+l;c++){for(let d=0;d<a;d++){let u=d*this._tmpCanvas.width*4+c*4+3;if(t.data[u]!==0){i.left=c,h=!0;break}}if(h)break}i.right=l,h=!1;for(let c=n+l-1;c>=n;c--){for(let d=0;d<a;d++){let u=d*this._tmpCanvas.width*4+c*4+3;if(t.data[u]!==0){i.right=c,h=!0;break}}if(h)break}i.bottom=a,h=!1;for(let c=a-1;c>=0;c--){for(let d=0;d<l;d++){let u=c*this._tmpCanvas.width*4+d*4+3;if(t.data[u]!==0){i.bottom=c,h=!0;break}}if(h)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:i.right-i.left+1,y:i.bottom-i.top+1},sizeClipSpace:{x:i.right-i.left+1,y:i.bottom-i.top+1},offset:{x:-i.left+n+(s||o?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-i.top+n+(s||o?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},wt=class{constructor(e,t,i){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],i)for(let r of i)this._glyphs.push(...r.glyphs),this._usedPixels+=r._usedPixels;this.canvas=vi(e,t,t),this.ctx=O(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(e){this._glyphs.push(e),this._usedPixels+=e.size.x*e.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function Ct(e,t,i,r){let s=t.rgba>>>24,o=t.rgba>>>16&255,n=t.rgba>>>8&255,a=i.rgba>>>24,l=i.rgba>>>16&255,h=i.rgba>>>8&255,c=Math.floor((Math.abs(s-a)+Math.abs(o-l)+Math.abs(n-h))/12),d=!0;for(let u=0;u<e.data.length;u+=4)e.data[u]===s&&e.data[u+1]===o&&e.data[u+2]===n||r&&Math.abs(e.data[u]-s)+Math.abs(e.data[u+1]-o)+Math.abs(e.data[u+2]-n)<c?e.data[u+3]=0:d=!1;return d}function gr(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function vi(e,t,i){let r=e.createElement("canvas");return r.width=t,r.height=i,r}function fr(e,t,i,r,s,o,n,a){let l={foreground:o.foreground,background:o.background,cursor:se,cursorAccent:se,selectionForeground:se,selectionBackgroundTransparent:se,selectionBackgroundOpaque:se,selectionInactiveBackgroundTransparent:se,selectionInactiveBackgroundOpaque:se,overviewRulerBorder:se,scrollbarSliderBackground:se,scrollbarSliderHoverBackground:se,scrollbarSliderActiveBackground:se,ansi:o.ansi.slice(),contrastCache:o.contrastCache,halfContrastCache:o.halfContrastCache};return{customGlyphs:s.customGlyphs,devicePixelRatio:n,deviceMaxTextureSize:a,letterSpacing:s.letterSpacing,lineHeight:s.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:i,deviceCharHeight:r,fontFamily:s.fontFamily,fontSize:s.fontSize,fontWeight:s.fontWeight,fontWeightBold:s.fontWeightBold,allowTransparency:s.allowTransparency,drawBoldTextInBrightColors:s.drawBoldTextInBrightColors,minimumContrastRatio:s.minimumContrastRatio,colors:l}}function pi(e,t){for(let i=0;i<e.colors.ansi.length;i++)if(e.colors.ansi[i].rgba!==t.colors.ansi[i].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba}function vr(e){return(e&50331648)===16777216||(e&50331648)===33554432}var re=[];function mi(e,t,i,r,s,o,n,a,l){let h=fr(r,s,o,n,t,i,a,l);for(let u=0;u<re.length;u++){let g=re[u],L=g.ownedBy.indexOf(e);if(L>=0){if(pi(g.config,h))return g.atlas;g.ownedBy.length===1?(g.atlas.dispose(),re.splice(u,1)):g.ownedBy.splice(L,1);break}}for(let u=0;u<re.length;u++){let g=re[u];if(pi(g.config,h))return g.ownedBy.push(e),g.atlas}let c=e._core,d={atlas:new Le(document,h,c.unicodeService),config:h,ownedBy:[e]};return re.push(d),d.atlas}function wi(e){for(let t=0;t<re.length;t++){let i=re[t].ownedBy.indexOf(e);if(i!==-1){re[t].ownedBy.length===1?(re[t].atlas.dispose(),re.splice(t,1)):re[t].ownedBy.splice(i,1);break}}}var tt=600,pr=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(e=tt){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let t=tt-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,t>0){this._restartInterval(t);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let t=tt-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(t);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},tt)},e)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function Ci(e,t,i){let r=new t.ResizeObserver(s=>{let o=s.find(l=>l.target===e);if(!o)return;if(!("devicePixelContentBoxSize"in o)){r?.disconnect(),r=void 0;return}let n=o.devicePixelContentBoxSize[0].inlineSize,a=o.devicePixelContentBoxSize[0].blockSize;n>0&&a>0&&i(n,a)});try{r.observe(e,{box:["device-pixel-content-box"]})}catch{r.disconnect(),r=void 0}return H(()=>r?.disconnect())}function mr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var xi=class as extends ke{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ci,this.combinedData=""}static fromCharData(t){let i=new as;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?mr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=t[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},bi=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function Li(e,t,i){let r=O(e.createProgram());if(e.attachShader(r,O(yi(e,e.VERTEX_SHADER,t))),e.attachShader(r,O(yi(e,e.FRAGMENT_SHADER,i))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function yi(e,t,i){let r=O(e.createShader(t));if(e.shaderSource(r,i),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}function wr(e,t){let i=Math.min(e.length*2,t),r=new Float32Array(i);for(let s=0;s<e.length;s++)r[s]=e[s];return r}var Cr=class{constructor(e){this.texture=e,this.version=-1}},xr=`#version 300 es
|
|
28
|
+
layout (location = 0) in vec2 a_unitquad;
|
|
29
|
+
layout (location = 1) in vec2 a_cellpos;
|
|
30
|
+
layout (location = 2) in vec2 a_offset;
|
|
31
|
+
layout (location = 3) in vec2 a_size;
|
|
32
|
+
layout (location = 4) in float a_texpage;
|
|
33
|
+
layout (location = 5) in vec2 a_texcoord;
|
|
34
|
+
layout (location = 6) in vec2 a_texsize;
|
|
35
|
+
|
|
36
|
+
uniform mat4 u_projection;
|
|
37
|
+
uniform vec2 u_resolution;
|
|
38
|
+
|
|
39
|
+
out vec2 v_texcoord;
|
|
40
|
+
flat out int v_texpage;
|
|
41
|
+
|
|
42
|
+
void main() {
|
|
43
|
+
vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);
|
|
44
|
+
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
45
|
+
v_texpage = int(a_texpage);
|
|
46
|
+
v_texcoord = a_texcoord + a_unitquad * a_texsize;
|
|
47
|
+
}`;function br(e){let t="";for(let i=1;i<e;i++)t+=` else if (v_texpage == ${i}) { outColor = texture(u_texture[${i}], v_texcoord); }`;return`#version 300 es
|
|
48
|
+
precision lowp float;
|
|
49
|
+
|
|
50
|
+
in vec2 v_texcoord;
|
|
51
|
+
flat in int v_texpage;
|
|
52
|
+
|
|
53
|
+
uniform sampler2D u_texture[${e}];
|
|
54
|
+
|
|
55
|
+
out vec4 outColor;
|
|
56
|
+
|
|
57
|
+
void main() {
|
|
58
|
+
if (v_texpage == 0) {
|
|
59
|
+
outColor = texture(u_texture[0], v_texcoord);
|
|
60
|
+
} ${t}
|
|
61
|
+
}`}var ye=11,Be=ye*Float32Array.BYTES_PER_ELEMENT,Lr=2,I=0,D,xt=0,Ge=0,yr=class extends ee{constructor(e,t,i,r){super(),this._terminal=e,this._gl=t,this._dimensions=i,this._optionsService=r,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let s=this._gl;Le.maxAtlasPages===void 0&&(Le.maxAtlasPages=Math.min(32,O(s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS))),Le.maxTextureSize=O(s.getParameter(s.MAX_TEXTURE_SIZE))),this._program=O(Li(s,xr,br(Le.maxAtlasPages))),this._register(H(()=>s.deleteProgram(this._program))),this._projectionLocation=O(s.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=O(s.getUniformLocation(this._program,"u_resolution")),this._textureLocation=O(s.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let o=new Float32Array([0,0,1,0,0,1,1,1]),n=s.createBuffer();this._register(H(()=>s.deleteBuffer(n))),s.bindBuffer(s.ARRAY_BUFFER,n),s.bufferData(s.ARRAY_BUFFER,o,s.STATIC_DRAW),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=s.createBuffer();this._register(H(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=O(s.createBuffer()),this._register(H(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,2,s.FLOAT,!1,Be,0),s.vertexAttribDivisor(2,1),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,s.FLOAT,!1,Be,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(3,1),s.enableVertexAttribArray(4),s.vertexAttribPointer(4,1,s.FLOAT,!1,Be,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(4,1),s.enableVertexAttribArray(5),s.vertexAttribPointer(5,2,s.FLOAT,!1,Be,5*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(5,1),s.enableVertexAttribArray(6),s.vertexAttribPointer(6,2,s.FLOAT,!1,Be,7*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(6,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,Be,9*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.useProgram(this._program);let h=new Int32Array(Le.maxAtlasPages);for(let c=0;c<Le.maxAtlasPages;c++)h[c]=c;s.uniform1iv(this._textureLocation,h),s.uniformMatrix4fv(this._projectionLocation,!1,bi),this._atlasTextures=[];for(let c=0;c<Le.maxAtlasPages;c++){let d=new Cr(O(s.createTexture()));this._register(H(()=>s.deleteTexture(d.texture))),s.activeTexture(s.TEXTURE0+c),s.bindTexture(s.TEXTURE_2D,d.texture),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[c]=d}s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(e,t,i,r,s,o,n,a,l){this._updateCell(this._vertices.attributes,e,t,i,r,s,o,n,a,l)}_updateCell(e,t,i,r,s,o,n,a,l,h){if(I=(i*this._terminal.cols+t)*ye,r===0||r===void 0){e.fill(0,I,I+ye-1-Lr);return}this._atlas&&(a&&a.length>1?D=this._atlas.getRasterizedGlyphCombinedChar(a,s,o,n,!1,this._terminal.element):D=this._atlas.getRasterizedGlyph(r,s,o,n,!1,this._terminal.element),xt=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),s!==h&&D.offset.x>xt?(Ge=D.offset.x-xt,e[I]=-(D.offset.x-Ge)+this._dimensions.device.char.left,e[I+1]=-D.offset.y+this._dimensions.device.char.top,e[I+2]=(D.size.x-Ge)/this._dimensions.device.canvas.width,e[I+3]=D.size.y/this._dimensions.device.canvas.height,e[I+4]=D.texturePage,e[I+5]=D.texturePositionClipSpace.x+Ge/this._atlas.pages[D.texturePage].canvas.width,e[I+6]=D.texturePositionClipSpace.y,e[I+7]=D.sizeClipSpace.x-Ge/this._atlas.pages[D.texturePage].canvas.width,e[I+8]=D.sizeClipSpace.y):(e[I]=-D.offset.x+this._dimensions.device.char.left,e[I+1]=-D.offset.y+this._dimensions.device.char.top,e[I+2]=D.size.x/this._dimensions.device.canvas.width,e[I+3]=D.size.y/this._dimensions.device.canvas.height,e[I+4]=D.texturePage,e[I+5]=D.texturePositionClipSpace.x,e[I+6]=D.texturePositionClipSpace.y,e[I+7]=D.sizeClipSpace.x,e[I+8]=D.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&zs(r,l,D.size.x,this._dimensions.device.cell.width)&&(e[I+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*ye;this._vertices.count!==t?this._vertices.attributes=new Float32Array(t):this._vertices.attributes.fill(0);let i=0;for(;i<this._vertices.attributesBuffers.length;i++)this._vertices.count!==t?this._vertices.attributesBuffers[i]=new Float32Array(t):this._vertices.attributesBuffers[i].fill(0);this._vertices.count=t,i=0;for(let r=0;r<e.rows;r++)for(let s=0;s<e.cols;s++)this._vertices.attributes[i+9]=s/e.cols,this._vertices.attributes[i+10]=r/e.rows,i+=ye}handleResize(){let e=this._gl;e.useProgram(this._program),e.viewport(0,0,e.canvas.width,e.canvas.height),e.uniform2f(this._resolutionLocation,e.canvas.width,e.canvas.height),this.clear()}render(e){if(!this._atlas)return;let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let i=this._vertices.attributesBuffers[this._activeBuffer],r=0;for(let s=0;s<e.lineLengths.length;s++){let o=s*this._terminal.cols*ye,n=this._vertices.attributes.subarray(o,o+e.lineLengths[s]*ye);i.set(n,r),r+=n.length}t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,i.subarray(0,r),t.STREAM_DRAW);for(let s=0;s<this._atlas.pages.length;s++)this._atlas.pages[s].version!==this._atlasTextures[s].version&&this._bindAtlasPageTexture(t,this._atlas,s);t.drawElementsInstanced(t.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,r/ye)}setAtlas(e){this._atlas=e;for(let t of this._atlasTextures)t.version=-1}_bindAtlasPageTexture(e,t,i){e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_2D,this._atlasTextures[i].texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.pages[i].canvas),e.generateMipmap(e.TEXTURE_2D),this._atlasTextures[i].version=t.pages[i].version}setDimensions(e){this._dimensions=e}},Mr=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,r=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let s=e.buffers.active.ydisp,o=t[1]-s,n=i[1]-s,a=Math.max(o,0),l=Math.min(n,e.rows-1);if(a>=e.rows||l<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=n,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function Sr(){return new Mr}var it=4,st=1,rt=2,bt=3,Ar=2147483648,Rr=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=Sr()}resize(e,t){let i=e*t*it;i!==this.cells.length&&(this.cells=new Uint32Array(i),this.lineLengths=new Uint32Array(t))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},Tr=`#version 300 es
|
|
62
|
+
layout (location = 0) in vec2 a_position;
|
|
63
|
+
layout (location = 1) in vec2 a_size;
|
|
64
|
+
layout (location = 2) in vec4 a_color;
|
|
65
|
+
layout (location = 3) in vec2 a_unitquad;
|
|
66
|
+
|
|
67
|
+
uniform mat4 u_projection;
|
|
68
|
+
|
|
69
|
+
out vec4 v_color;
|
|
70
|
+
|
|
71
|
+
void main() {
|
|
72
|
+
vec2 zeroToOne = a_position + (a_unitquad * a_size);
|
|
73
|
+
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
74
|
+
v_color = a_color;
|
|
75
|
+
}`,Er=`#version 300 es
|
|
76
|
+
precision lowp float;
|
|
77
|
+
|
|
78
|
+
in vec4 v_color;
|
|
79
|
+
|
|
80
|
+
out vec4 outColor;
|
|
81
|
+
|
|
82
|
+
void main() {
|
|
83
|
+
outColor = v_color;
|
|
84
|
+
}`,fe=8,Lt=fe*Float32Array.BYTES_PER_ELEMENT,kr=20*fe,Mi=class{constructor(){this.attributes=new Float32Array(kr),this.count=0}},ve=0,Si=0,Ai=0,Ri=0,Ti=0,Ei=0,ki=0,Br=class extends ee{constructor(e,t,i,r){super(),this._terminal=e,this._gl=t,this._dimensions=i,this._themeService=r,this._vertices=new Mi,this._verticesCursor=new Mi;let s=this._gl;this._program=O(Li(s,Tr,Er)),this._register(H(()=>s.deleteProgram(this._program))),this._projectionLocation=O(s.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let o=new Float32Array([0,0,1,0,0,1,1,1]),n=s.createBuffer();this._register(H(()=>s.deleteBuffer(n))),s.bindBuffer(s.ARRAY_BUFFER,n),s.bufferData(s.ARRAY_BUFFER,o,s.STATIC_DRAW),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=s.createBuffer();this._register(H(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=O(s.createBuffer()),this._register(H(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,Lt,0),s.vertexAttribDivisor(0,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,Lt,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,4,s.FLOAT,!1,Lt,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(h=>{this._updateCachedColors(h),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,bi),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,i=this._vertices,r=1,s,o,n,a,l,h,c,d,u,g,L;for(s=0;s<t.rows;s++){for(n=-1,a=0,l=0,h=!1,o=0;o<t.cols;o++)c=(s*t.cols+o)*it,d=e.cells[c+st],u=e.cells[c+rt],g=!!(u&67108864),(d!==a||u!==l&&(h||g))&&((a!==0||h&&l!==0)&&(L=r++*fe,this._updateRectangle(i,L,l,a,n,o,s)),n=o,a=d,l=u,h=g);(a!==0||h&&l!==0)&&(L=r++*fe,this._updateRectangle(i,L,l,a,n,t.cols,s))}i.count=r}updateCursor(e){let t=this._verticesCursor,i=e.cursor;if(!i||i.style==="block"){t.count=0;return}let r,s=0;(i.style==="bar"||i.style==="outline")&&(r=s++*fe,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.style==="bar"?i.dpr*i.cursorWidth:i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(i.style==="underline"||i.style==="outline")&&(r=s++*fe,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,(i.y+1)*this._dimensions.device.cell.height-i.dpr,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat)),i.style==="outline"&&(r=s++*fe,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat),r=s++*fe,this._addRectangleFloat(t.attributes,r,(i.x+i.width)*this._dimensions.device.cell.width-i.dpr,i.y*this._dimensions.device.cell.height,i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),t.count=s}_updateRectangle(e,t,i,r,s,o,n){if(i&67108864)switch(i&50331648){case 16777216:case 33554432:ve=this._themeService.colors.ansi[i&255].rgba;break;case 50331648:ve=(i&16777215)<<8;break;case 0:default:ve=this._themeService.colors.foreground.rgba}else switch(r&50331648){case 16777216:case 33554432:ve=this._themeService.colors.ansi[r&255].rgba;break;case 50331648:ve=(r&16777215)<<8;break;case 0:default:ve=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=wr(e.attributes,this._terminal.rows*this._terminal.cols*fe)),Si=s*this._dimensions.device.cell.width,Ai=n*this._dimensions.device.cell.height,Ri=(ve>>24&255)/255,Ti=(ve>>16&255)/255,Ei=(ve>>8&255)/255,ki=1,this._addRectangle(e.attributes,t,Si,Ai,(o-s)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Ri,Ti,Ei,ki)}_addRectangle(e,t,i,r,s,o,n,a,l,h){e[t]=i/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=s/this._dimensions.device.canvas.width,e[t+3]=o/this._dimensions.device.canvas.height,e[t+4]=n,e[t+5]=a,e[t+6]=l,e[t+7]=h}_addRectangleFloat(e,t,i,r,s,o,n){e[t]=i/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=s/this._dimensions.device.canvas.width,e[t+3]=o/this._dimensions.device.canvas.height,e[t+4]=n[0],e[t+5]=n[1],e[t+6]=n[2],e[t+7]=n[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},Dr=class extends ee{constructor(e,t,i,r,s,o,n,a){super(),this._container=t,this._alpha=s,this._coreBrowserService=o,this._optionsService=n,this._themeService=a,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${i}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(l=>{this._refreshCharAtlas(e,l),this.reset(e)})),this._register(H(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=O(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,i){}handleSelectionChanged(e,t,i,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let i=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,i),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=mi(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,i=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,i*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,i,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,i*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,i*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,i,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=ii,this._clipCell(i,r,t.getWidth()),this._ctx.fillText(t.getChars(),i*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,i){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,i*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,i){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${i?"italic":""} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},Pr=class extends Dr{constructor(e,t,i,r,s,o,n){super(i,e,"link",t,!0,s,o,n),this._register(r.onShowLinkUnderline(a=>this._handleShowLinkUnderline(a))),this._register(r.onHideLinkUnderline(a=>this._handleHideLinkUnderline(a)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&vr(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e}_handleHideLinkUnderline(e){this._clearCurrentLink()}},le=typeof window=="object"?window:globalThis,yt=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new k,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new k,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};yt.INSTANCE=new yt;var Bi=yt;function Fr(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}var En=Bi.INSTANCE.onDidChangeZoomLevel,kn=Bi.INSTANCE.onDidChangeFullscreen,De=typeof navigator=="object"?navigator.userAgent:"",Bn=De.indexOf("Firefox")>=0,Mt=De.indexOf("AppleWebKit")>=0,$r=De.indexOf("Chrome")>=0,Ir=!$r&&De.indexOf("Safari")>=0,Dn=De.indexOf("Electron/")>=0,Pn=De.indexOf("Android")>=0,nt=!1;if(typeof le.matchMedia=="function"){let e=le.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=le.matchMedia("(display-mode: fullscreen)");nt=e.matches,Fr(le,e,({matches:i})=>{nt&&t.matches||(nt=i)})}function Or(){return nt}var Pe="en",St=!1,At=!1,ot=!1,Wr=!1,Di=!1,Pi=!1,zr=!1,Ur=!1,Nr=!1,Gr=!1,at,ht=Pe,Fi=Pe,qr,pe,me=globalThis,te;typeof me.vscode<"u"&&typeof me.vscode.process<"u"?te=me.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(te=process);var $i=typeof te?.versions?.electron=="string",Hr=$i&&te?.type==="renderer";if(typeof te=="object"){St=te.platform==="win32",At=te.platform==="darwin",ot=te.platform==="linux",Wr=ot&&!!te.env.SNAP&&!!te.env.SNAP_REVISION,zr=$i,Nr=!!te.env.CI||!!te.env.BUILD_ARTIFACTSTAGINGDIRECTORY,at=Pe,ht=Pe;let e=te.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);at=t.userLocale,Fi=t.osLocale,ht=t.resolvedLanguage||Pe,qr=t.languagePack?.translationsConfigFile}catch{}Di=!0}else typeof navigator=="object"&&!Hr?(pe=navigator.userAgent,St=pe.indexOf("Windows")>=0,At=pe.indexOf("Macintosh")>=0,Ur=(pe.indexOf("Macintosh")>=0||pe.indexOf("iPad")>=0||pe.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ot=pe.indexOf("Linux")>=0,Gr=pe?.indexOf("Mobi")>=0,Pi=!0,ht=globalThis._VSCODE_NLS_LANGUAGE||Pe,at=navigator.language.toLowerCase(),Fi=at):console.error("Unable to resolve platform.");var Rt=0;At?Rt=1:St?Rt=3:ot&&(Rt=2);var Tt=Di,Vr=Pi&&typeof me.importScripts=="function",Fn=Vr?me.origin:void 0,ce=pe,Me=ht,jr;(e=>{function t(){return Me}e.value=t;function i(){return Me.length===2?Me==="en":Me.length>=3?Me[0]==="e"&&Me[1]==="n"&&Me[2]==="-":!1}e.isDefaultVariant=i;function r(){return Me==="en"}e.isDefault=r})(jr||={});var Yr=typeof me.postMessage=="function"&&!me.importScripts,Kr=(()=>{if(Yr){let e=[];me.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let r=0,s=e.length;r<s;r++){let o=e[r];if(o.id===i.data.vscodeScheduleAsyncWork){e.splice(r,1),o.callback();return}}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),me.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})(),Xr=!!(ce&&ce.indexOf("Chrome")>=0),$n=!!(ce&&ce.indexOf("Firefox")>=0),In=!!(!Xr&&ce&&ce.indexOf("Safari")>=0),On=!!(ce&&ce.indexOf("Edg/")>=0),Wn=!!(ce&&ce.indexOf("Android")>=0),Se=typeof navigator=="object"?navigator:{},zn={clipboard:{writeText:Tt||document.queryCommandSupported&&document.queryCommandSupported("copy")||!!(Se&&Se.clipboard&&Se.clipboard.writeText),readText:Tt||!!(Se&&Se.clipboard&&Se.clipboard.readText)},keyboard:Tt||Or()?0:Se.keyboard||Ir?1:2,touch:"ontouchstart"in le||Se.maxTouchPoints>0,pointerEvents:le.PointerEvent&&("ontouchstart"in le||navigator.maxTouchPoints>0)},Et=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},kt=new Et,Ii=new Et,Oi=new Et,Un=new Array(230),Zr;(e=>{function t(a){return kt.keyCodeToStr(a)}e.toString=t;function i(a){return kt.strToKeyCode(a)}e.fromString=i;function r(a){return Ii.keyCodeToStr(a)}e.toUserSettingsUS=r;function s(a){return Oi.keyCodeToStr(a)}e.toUserSettingsGeneral=s;function o(a){return Ii.strToKeyCode(a)||Oi.strToKeyCode(a)}e.fromUserSettings=o;function n(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return kt.keyCodeToStr(a)}e.toElectronAccelerator=n})(Zr||={});var Wi=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Qr;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Jr?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ge.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Wi})})(Qr||={});var Jr=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Wi:(this._emitter||(this._emitter=new k),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Nn=Symbol("MicrotaskDelay"),en,Bt;(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?Bt=(e,t)=>{Kr(()=>{if(i)return;let r=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,r-Date.now())}}))});let i=!1;return{dispose(){i||(i=!0)}}}:Bt=(e,t,i)=>{let r=e.requestIdleCallback(t,typeof i=="number"?{timeout:i}:void 0),s=!1;return{dispose(){s||(s=!0,e.cancelIdleCallback(r))}}},en=e=>Bt(globalThis,e)})();var tn;(e=>{async function t(r){let s,o=await Promise.all(r.map(n=>n.then(a=>a,a=>{s||(s=a)})));if(typeof s<"u")throw s;return o}e.settled=t;function i(r){return new Promise(async(s,o)=>{try{await r(s,o)}catch(n){o(n)}})}e.withAsyncBody=i})(tn||={});var zi=class ne{static fromArray(t){return new ne(i=>{i.emitMany(t)})}static fromPromise(t){return new ne(async i=>{i.emitMany(await t)})}static fromPromises(t){return new ne(async i=>{await Promise.all(t.map(async r=>i.emitOne(await r)))})}static merge(t){return new ne(async i=>{await Promise.all(t.map(async r=>{for await(let s of r)i.emitOne(s)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new k,queueMicrotask(async()=>{let r={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(t(r)),this.resolve()}catch(s){this.reject(s)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await ge.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new ne(async r=>{for await(let s of t)r.emitOne(i(s))})}map(t){return ne.map(this,t)}static filter(t,i){return new ne(async r=>{for await(let s of t)i(s)&&r.emitOne(s)})}filter(t){return ne.filter(this,t)}static coalesce(t){return ne.filter(t,i=>!!i)}coalesce(){return ne.coalesce(this)}static async toPromise(t){let i=[];for await(let r of t)i.push(r);return i}toPromise(){return ne.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};zi.EMPTY=zi.fromArray([]);function sn(e){return 55296<=e&&e<=56319}function Ui(e){return 56320<=e&&e<=57343}function rn(e,t){return(e-55296<<10)+(t-56320)+65536}function nn(e){return Dt(e,0)}function Dt(e,t){switch(typeof e){case"object":return e===null?we(349,t):Array.isArray(e)?an(e,t):hn(e,t);case"string":return Ni(e,t);case"boolean":return on(e,t);case"number":return we(e,t);case"undefined":return we(937,t);default:return we(617,t)}}function we(e,t){return(t<<5)-t+e|0}function on(e,t){return we(e?433:863,t)}function Ni(e,t){t=we(149417,t);for(let i=0,r=e.length;i<r;i++)t=we(e.charCodeAt(i),t);return t}function an(e,t){return t=we(104579,t),e.reduce((i,r)=>Dt(r,i),t)}function hn(e,t){return t=we(181387,t),Object.keys(e).sort().reduce((i,r)=>(i=Ni(r,i),Dt(e[r],i)),t)}function Pt(e,t,i=32){let r=i-t,s=~((1<<r)-1);return(e<<t|(s&e)>>>r)>>>0}function Gi(e,t=0,i=e.byteLength,r=0){for(let s=0;s<i;s++)e[t+s]=r}function ln(e,t,i="0"){for(;e.length<t;)e=i+e;return e}function qe(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(i=>i.toString(16).padStart(2,"0")).join(""):ln((e>>>0).toString(16),t/4)}var cn=class hs{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(t){let i=t.length;if(i===0)return;let r=this._buff,s=this._buffLen,o=this._leftoverHighSurrogate,n,a;for(o!==0?(n=o,a=-1,o=0):(n=t.charCodeAt(0),a=0);;){let l=n;if(sn(n))if(a+1<i){let h=t.charCodeAt(a+1);Ui(h)?(a++,l=rn(n,h)):l=65533}else{o=n;break}else Ui(n)&&(l=65533);if(s=this._push(r,s,l),a++,a<i)n=t.charCodeAt(a);else break}this._buffLen=s,this._leftoverHighSurrogate=o}_push(t,i,r){return r<128?t[i++]=r:r<2048?(t[i++]=192|(r&1984)>>>6,t[i++]=128|(r&63)>>>0):r<65536?(t[i++]=224|(r&61440)>>>12,t[i++]=128|(r&4032)>>>6,t[i++]=128|(r&63)>>>0):(t[i++]=240|(r&1835008)>>>18,t[i++]=128|(r&258048)>>>12,t[i++]=128|(r&4032)>>>6,t[i++]=128|(r&63)>>>0),i>=64&&(this._step(),i-=64,this._totalLen+=64,t[0]=t[64],t[1]=t[65],t[2]=t[66]),i}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),qe(this._h0)+qe(this._h1)+qe(this._h2)+qe(this._h3)+qe(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Gi(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Gi(this._buff));let t=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(t/4294967296),!1),this._buffDV.setUint32(60,t%4294967296,!1),this._step()}_step(){let t=hs._bigBlock32,i=this._buffDV;for(let d=0;d<64;d+=4)t.setUint32(d,i.getUint32(d,!1),!1);for(let d=64;d<320;d+=4)t.setUint32(d,Pt(t.getUint32(d-12,!1)^t.getUint32(d-32,!1)^t.getUint32(d-56,!1)^t.getUint32(d-64,!1),1),!1);let r=this._h0,s=this._h1,o=this._h2,n=this._h3,a=this._h4,l,h,c;for(let d=0;d<80;d++)d<20?(l=s&o|~s&n,h=1518500249):d<40?(l=s^o^n,h=1859775393):d<60?(l=s&o|s&n|o&n,h=2400959708):(l=s^o^n,h=3395469782),c=Pt(r,5)+l+a+h+t.getUint32(d*4,!1)&4294967295,a=n,n=o,o=Pt(s,30),s=r,r=c;this._h0=this._h0+r&4294967295,this._h1=this._h1+s&4294967295,this._h2=this._h2+o&4294967295,this._h3=this._h3+n&4294967295,this._h4=this._h4+a&4294967295}};cn._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:Gn,getWindow:dn,getDocument:qn,getWindows:Hn,getWindowsCount:Vn,getWindowId:qi,getWindowById:jn,hasWindow:Yn,onDidRegisterWindow:Kn,onWillUnregisterWindow:Xn,onDidUnregisterWindow:Zn}=(function(){let e=new Map,t={window:le,disposables:new Ee};e.set(le.vscodeWindowId,t);let i=new k,r=new k,s=new k;function o(n,a){return(typeof n=="number"?e.get(n):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(n){if(e.has(n.vscodeWindowId))return ee.None;let a=new Ee,l={window:n,disposables:a.add(new Ee)};return e.set(n.vscodeWindowId,l),a.add(H(()=>{e.delete(n.vscodeWindowId),r.fire(n)})),a.add(Ft(n,gn.BEFORE_UNLOAD,()=>{s.fire(n)})),i.fire(l),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(n){return n.vscodeWindowId},hasWindow(n){return e.has(n)},getWindowById:o,getWindow(n){let a=n;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let l=n;return l?.view?l.view.window:le},getDocument(n){return dn(n).document}}})(),un=class{constructor(e,t,i,r){this._node=e,this._type=t,this._handler=i,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ft(e,t,i,r){return new un(e,t,i,r)}var _n,Hi,$t=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Ye(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,r=new Map,s=o=>{i.set(o,!1);let n=e.get(o)??[];for(t.set(o,n),e.set(o,[]),r.set(o,!0);n.length>0;)n.sort($t.sort),n.shift().execute();r.set(o,!1)};Hi=(o,n,a=0)=>{let l=qi(o),h=new $t(n,a),c=e.get(l);return c||(c=[],e.set(l,c)),c.push(h),i.get(l)||(i.set(l,!0),o.requestAnimationFrame(()=>s(l))),h},_n=(o,n,a)=>{let l=qi(o);if(r.get(l)){let h=new $t(n,a),c=t.get(l);return c||(c=[],t.set(l,c)),c.push(h),h}else return Hi(o,n,a)}})();var Vi=class lt{constructor(t,i){this.width=t,this.height=i}with(t=this.width,i=this.height){return t!==this.width||i!==this.height?new lt(t,i):this}static is(t){return typeof t=="object"&&typeof t.height=="number"&&typeof t.width=="number"}static lift(t){return t instanceof lt?t:new lt(t.width,t.height)}static equals(t,i){return t===i?!0:!t||!i?!1:t.width===i.width&&t.height===i.height}};Vi.None=new Vi(0,0);var Qn=new class{constructor(){this.mutationObservers=new Map}observe(e,t,i){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let s=nn(i),o=r.get(s);if(o)o.users+=1;else{let n=new k,a=new MutationObserver(h=>n.fire(h));a.observe(e,i);let l=o={users:1,observer:a,onDidMutate:n.event};t.add(H(()=>{l.users-=1,l.users===0&&(n.dispose(),a.disconnect(),r?.delete(s),r?.size===0&&this.mutationObservers.delete(e))})),r.set(s,o)}return o.onDidMutate}},gn={CLICK:"click",AUXCLICK:"auxclick",DBLCLICK:"dblclick",MOUSE_UP:"mouseup",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_MOVE:"mousemove",MOUSE_OUT:"mouseout",MOUSE_ENTER:"mouseenter",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",POINTER_LEAVE:"pointerleave",CONTEXT_MENU:"contextmenu",WHEEL:"wheel",KEY_DOWN:"keydown",KEY_PRESS:"keypress",KEY_UP:"keyup",LOAD:"load",BEFORE_UNLOAD:"beforeunload",UNLOAD:"unload",PAGE_SHOW:"pageshow",PAGE_HIDE:"pagehide",PASTE:"paste",ABORT:"abort",ERROR:"error",RESIZE:"resize",SCROLL:"scroll",FULLSCREEN_CHANGE:"fullscreenchange",WK_FULLSCREEN_CHANGE:"webkitfullscreenchange",SELECT:"select",CHANGE:"change",SUBMIT:"submit",RESET:"reset",FOCUS:"focus",FOCUS_IN:"focusin",FOCUS_OUT:"focusout",BLUR:"blur",INPUT:"input",STORAGE:"storage",DRAG_START:"dragstart",DRAG:"drag",DRAG_ENTER:"dragenter",DRAG_LEAVE:"dragleave",DRAG_OVER:"dragover",DROP:"drop",DRAG_END:"dragend",ANIMATION_START:Mt?"webkitAnimationStart":"animationstart",ANIMATION_END:Mt?"webkitAnimationEnd":"animationend",ANIMATION_ITERATION:Mt?"webkitAnimationIteration":"animationiteration"},fn=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function ji(e,t,i,...r){let s=fn.exec(t);if(!s)throw new Error("Bad use of emmet");let o=s[1]||"div",n;return e!=="http://www.w3.org/1999/xhtml"?n=document.createElementNS(e,o):n=document.createElement(o),s[3]&&(n.id=s[3]),s[4]&&(n.className=s[4].replace(/\./g," ").trim()),i&&Object.entries(i).forEach(([a,l])=>{typeof l>"u"||(/^on\w+$/.test(a)?n[a]=l:a==="selected"?l&&n.setAttribute(a,"true"):n.setAttribute(a,l))}),n.append(...r),n}function vn(e,t,...i){return ji("http://www.w3.org/1999/xhtml",e,t,...i)}vn.SVG=function(e,t,...i){return ji("http://www.w3.org/2000/svg",e,t,...i)};var pn=class extends ee{constructor(e,t,i,r,s,o,n,a,l){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=i,this._coreBrowserService=r,this._coreService=s,this._decorationService=o,this._optionsService=n,this._themeService=a,this._cursorBlinkStateManager=new Ie,this._charAtlasDisposable=this._register(new Ie),this._observerDisposable=this._register(new Ie),this._model=new Rr,this._workCell=new xi,this._workCell2=new xi,this._rectangleRenderer=this._register(new Ie),this._glyphRenderer=this._register(new Ie),this._onChangeTextureAtlas=this._register(new k),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new k),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new k),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new k),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new k),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let h={antialias:!1,depth:!1,preserveDrawingBuffer:l};if(this._gl=this._canvas.getContext("webgl2",h),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Gs(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Pr(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,n,this._themeService)],this.dimensions=Us(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(n.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Ft(this._canvas,"webglcontextlost",c=>{console.log("webglcontextlost event received"),c.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(c)},3e3)})),this._register(Ft(this._canvas,"webglcontextrestored",c=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,wi(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=Ci(this._canvas,this._coreBrowserService.window,(c,d)=>this._setCanvasDevicePixelDimensions(c,d)),this._register(this._coreBrowserService.onWindowChange(c=>{this._observerDisposable.value=Ci(this._canvas,c,(d,u)=>this._setCanvasDevicePixelDimensions(d,u))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(H(()=>{for(let c of this._renderLayers)c.dispose();this._canvas.parentElement?.removeChild(this._canvas),wi(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let i of this._renderLayers)i.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,i){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,i);this._model.selection.update(this._core,e,t,i),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new Br(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new yr(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=mi(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=Qt(ge.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),ge.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let i of this._renderLayers)i.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new pr(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let i=this._core,r=this._workCell,s,o,n,a,l,h,c=0,d=!0,u,g,L,A,B,j,R,M,b;e=Yi(e,i.rows-1,0),t=Yi(t,i.rows-1,0);let y=this._coreService.decPrivateModes.cursorStyle??i.options.cursorStyle??"block",T=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,W=T-i.buffer.ydisp,Y=Math.min(this._terminal.buffer.active.cursorX,i.cols-1),ae=-1,Ce=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let E=!1;for(o=e;o<=t;o++)for(n=o+i.buffer.ydisp,a=i.buffer.lines.get(n),this._model.lineLengths[o]=0,L=T===n,c=0,l=this._characterJoinerService.getJoinedCharacters(n),M=0;M<i.cols;M++){if(s=this._cellColorResolver.result.bg,a.loadCell(M,r),M===0&&(s=this._cellColorResolver.result.bg),h=!1,d=M>=c,u=M,l.length>0&&M===l[0][0]&&d){g=l.shift();let xe=this._model.selection.isCellSelected(this._terminal,g[0],n);for(R=g[0]+1;R<g[1];R++)d&&=xe===this._model.selection.isCellSelected(this._terminal,R,n);d&&=!L||Y<g[0]||Y>=g[1],d?(h=!0,r=new mn(r,a.translateToString(!0,g[0],g[1]),g[1]-g[0]),u=g[1]-1):c=g[1]}if(A=r.getChars(),B=r.getCode(),R=(o*i.cols+M)*it,this._cellColorResolver.resolve(r,M,n,this.dimensions.device.cell.width),Ce&&n===T&&(M===Y&&(this._model.cursor={x:Y,y:W,width:r.getWidth(),style:this._coreBrowserService.isFocused?y:i.options.cursorInactiveStyle,cursorWidth:i.options.cursorWidth,dpr:this._devicePixelRatio},ae=Y+r.getWidth()-1),M>=Y&&M<=ae&&(this._coreBrowserService.isFocused&&y==="block"||this._coreBrowserService.isFocused===!1&&i.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),B!==0&&(this._model.lineLengths[o]=M+1),!(this._model.cells[R]===B&&this._model.cells[R+st]===this._cellColorResolver.result.bg&&this._model.cells[R+rt]===this._cellColorResolver.result.fg&&this._model.cells[R+bt]===this._cellColorResolver.result.ext)&&(E=!0,A.length>1&&(B|=Ar),this._model.cells[R]=B,this._model.cells[R+st]=this._cellColorResolver.result.bg,this._model.cells[R+rt]=this._cellColorResolver.result.fg,this._model.cells[R+bt]=this._cellColorResolver.result.ext,j=r.getWidth(),this._glyphRenderer.value.updateCell(M,o,B,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,A,j,s),h)){for(r=this._workCell,M++;M<=u;M++)b=(o*i.cols+M)*it,this._glyphRenderer.value.updateCell(M,o,0,0,0,0,Ps,0,0),this._model.cells[b]=0,this._model.cells[b+st]=this._cellColorResolver.result.bg,this._model.cells[b+rt]=this._cellColorResolver.result.fg,this._model.cells[b+bt]=this._cellColorResolver.result.ext;M--}}E&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},mn=class extends ke{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Yi(e,t,i=0){return Math.max(Math.min(e,t),i)}var Ki="di$target",Xi="di$dependencies",It=new Map;function de(e){if(It.has(e))return It.get(e);let t=function(i,r,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");wn(t,i,s)};return t._id=e,It.set(e,t),t}function wn(e,t,i){t[Ki]===t?t[Xi].push({id:e,index:i}):(t[Xi]=[{id:e,index:i}],t[Ki]=t)}var Jn=de("BufferService"),eo=de("CoreMouseService"),to=de("CoreService"),io=de("CharsetService"),so=de("InstantiationService"),ro=de("LogService"),Cn=de("OptionsService"),no=de("OscLinkService"),oo=de("UnicodeService"),ao=de("DecorationService"),xn={trace:0,debug:1,info:2,warn:3,error:4,off:5},bn="xterm.js: ",Zi=class extends ee{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),Qi=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=xn[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":bn)+t,...i)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Zi=gs([fs(0,Cn)],Zi);var Qi;function Ln(e){Qi=e}var yn=class extends ee{constructor(e){if(ei&&Ds()<16){let t={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",t))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new k),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new k),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new k),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new k),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let i=t.coreService,r=t.optionsService,s=t,o=s._renderService,n=s._characterJoinerService,a=s._charSizeService,l=s._coreBrowserService,h=s._decorationService,c=s._logService,d=s._themeService;Ln(c),this._renderer=this._register(new pn(e,n,a,l,i,h,r,d,this._preserveDrawingBuffer)),this._register(ge.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(ge.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(ge.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(ge.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),o.setRenderer(this._renderer),this._register(H(()=>{if(this._terminal._core._store._isDisposed)return;let u=this._terminal._core._renderService;u.setRenderer(this._terminal._core._createRenderer()),u.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};/*! Bundled license information:
|
|
85
|
+
|
|
86
|
+
@xterm/addon-webgl/lib/addon-webgl.mjs:
|
|
87
|
+
(**
|
|
88
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
89
|
+
* @license MIT
|
|
90
|
+
*
|
|
91
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
92
|
+
* @license MIT
|
|
93
|
+
*
|
|
94
|
+
* Originally forked from (with the author's permission):
|
|
95
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
96
|
+
* http://bellard.org/jslinux/
|
|
97
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
98
|
+
*)
|
|
99
|
+
*/export{yn as WebglAddon};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
var bn=/\x1b\](?:10|11|110|111|104)(?:;[^\x07\x1b]*)?\x1b?(?:\\|\x07)/g;function
|
|
2
|
-
`)}selectRows(t,s){let n=this.terminal.buffer.active,[
|
|
3
|
-
`)}getSelection(){return this.terminal.getSelection()}clearSelection(){this.terminal.clearSelection()}hasSelectionSupport(){return!0}};function
|
|
1
|
+
var bn=/\x1b\](?:10|11|110|111|104)(?:;[^\x07\x1b]*)?\x1b?(?:\\|\x07)/g;function Qe(e){return e.replace(/\x1b\[\?1049[hl]/g,"")}function me(e){return e.replace(bn,"")}var Fe;function Ln(){return Fe||(document.querySelector("link[data-tmux-web-xterm-css]")?Fe=Promise.resolve():(Fe=new Promise(e=>{let t=document.createElement("link");t.rel="stylesheet",t.href="/assets/xterm.css",t.setAttribute("data-tmux-web-xterm-css",""),t.addEventListener("load",()=>e(),{once:!0}),t.addEventListener("error",()=>e(),{once:!0}),document.head.appendChild(t)}),Fe))}var En=class Kt{terminal;fitAddon;container;verifyRaf=0;verifyRounds=0;shrinkCols=0;lastLimit=0;lastCheckAt=0;webglActive=!1;webglAddon=null;constructor(t,s,n){this.container=t,this.terminal=s,this.fitAddon=n,this.terminal.loadAddon(this.fitAddon),this.terminal.open(t),this.enableWebglRenderer()}enableWebglRenderer(){import("./addon-webgl-B45EJ6AW.js").then(({WebglAddon:t})=>{let s=new t;s.onContextLoss(()=>{this.webglActive=!1,this.webglAddon=null;try{s.dispose()}catch{}this.lastLimit>0&&this.scheduleColumnCheck(this.lastLimit,!0)});try{this.terminal.loadAddon(s)}catch{return}this.webglAddon=s,this.webglActive=!0,this.fit()}).catch(()=>{})}static async create(t,s,n){let[{Terminal:a},{FitAddon:r}]=await Promise.all([import("./xterm-BXEES47M.js"),import("./addon-fit-D5N335P2.js"),Ln()]),c=new a({fontSize:14,fontFamily:"'JetBrains Mono', 'SF Mono', 'Menlo', monospace",cursorBlink:!0,cursorStyle:"bar",scrollback:s,convertEol:!1,smoothScrollDuration:120,theme:n});return new Kt(t,c,new r)}get cols(){return this.terminal.cols}get rows(){return this.terminal.rows}write(t){return new Promise(s=>this.terminal.write(t,()=>{this.lastLimit>0&&this.scheduleColumnCheck(this.lastLimit),s()}))}reset(){this.terminal.reset()}scrollToBottom(){this.terminal.scrollToBottom()}scrollToLine(t,s=!1){this.terminal.scrollToLine(Math.max(0,t),s)}scrollLines(t){let s=this.terminal.buffer?.active;this.terminal.scrollLines(t)}isNearScrollbackTop(){return this.terminal.buffer.active.viewportY<=1}viewportY(){return this.terminal.buffer.active.viewportY}baseY(){return this.terminal.buffer.active.baseY}cellHeight(){let t=this.terminal.element?.querySelector(".xterm-screen")?.getBoundingClientRect().height??0,s=this.terminal.rows;return t>0&&s>0?t/s:16}fit(){let t=Cn(this.container);if(t.width<=0||t.height<=0)return!1;this.fitAddon.fit();let s=this.terminal.element?.querySelector(".xterm-viewport"),n=s?Math.max(0,s.offsetWidth-s.clientWidth):0,a=this.terminal.element?.querySelector(".vertical.scrollbar"),r=a?Math.max(0,Math.round(a.getBoundingClientRect().width)):0,c=this.container.getBoundingClientRect().left+t.width-n-r-1;if(this.lastLimit=c,this.webglActive){if(this.shrinkCols>0){let o=Math.max(10,this.terminal.cols-this.shrinkCols);o!==this.terminal.cols&&this.terminal.resize(o,this.terminal.rows)}return!0}return this.shrinkCols=0,this.verifyRounds=0,this.scheduleColumnCheck(c,!0),!0}scheduleColumnCheck(t,s=!1){if(this.lastLimit=t,this.verifyRaf)return;let n=Date.now();!s&&n-this.lastCheckAt<250||(this.lastCheckAt=n,this.verifyRaf=requestAnimationFrame(()=>{this.verifyRaf=0;try{this.recheckColumns(this.lastLimit)&&this.verifyRounds<8?(this.verifyRounds++,this.scheduleColumnCheck(this.lastLimit,!0)):this.verifyRounds=0}catch{}}))}recheckColumns(t){let s=this.terminal.element?.querySelector(".xterm-rows");if(!s)return!1;let n=0;for(let o of Array.from(s.children)){let u=o.children;for(let p=u.length-1;p>=0;p--){let E=u[p];if(!E.textContent)continue;let b=E.getBoundingClientRect().right;b>n&&(n=b);break}}if(n===0)return!1;let a=this.terminal.cols,r=this.terminal.element?.querySelector(".xterm-screen")?.getBoundingClientRect().width??0,c=a>0&&r>0?r/a:0;if(n>t){let o=n-t,u=c>0?Math.min(8,Math.ceil(o/c)):1,p=Math.max(10,a-Math.max(1,u));return p>=a?!1:(this.shrinkCols+=a-p,this.terminal.resize(p,this.terminal.rows),!0)}return!1}focus(){this.terminal.focus()}pasteText(t){this.terminal.paste(t)}input(t){this.terminal.input(t,!1)}onData(t){this.terminal.onData(t),this.terminal.onBinary(t)}onResize(t){this.terminal.onResize(t)}onScroll(t){this.terminal.onScroll(t)}attachCustomKeyEventHandler(t){this.terminal.attachCustomKeyEventHandler(t)}isFocused(){let t=document.activeElement;return t?t===this.container||t===this.terminal.textarea||this.container.contains(t)||!!t.closest?.(".xterm"):!1}getScreenText(){return this.getRowsText(0,this.terminal.rows-1)}getRowsText(t,s){let n=this.terminal.buffer.active,[a,r]=t<=s?[t,s]:[s,t],c=n.viewportY,o=[];for(let u=a;u<=r;u++){let p=n.getLine(c+u);o.push(p?p.translateToString(!0):"")}return o.join(`
|
|
2
|
+
`)}selectRows(t,s){let n=this.terminal.buffer.active,[a,r]=t<=s?[t,s]:[s,t];this.terminal.selectLines(n.viewportY+a,n.viewportY+r)}selectCells(t,s,n,a){let r=this.terminal.buffer.active,c=Math.min(s,a),o=Math.max(s,a);if(c===o){let u=Math.min(t,n),p=Math.max(t,n);this.terminal.select(u,r.viewportY+c,p-u+1)}else this.terminal.selectLines(r.viewportY+c,r.viewportY+o)}getCellsText(t,s,n,a){let r=this.terminal.buffer.active,c=Math.min(s,a),o=Math.max(s,a),u=s<a?t:s>a?n:Math.min(t,n),p=s<a?n:s>a?t:Math.max(t,n),E=r.viewportY,b=[];for(let A=c;A<=o;A++){let M=r.getLine(E+A);if(!M){b.push("");continue}let L=A===c?u:0,O=A===o?p:this.terminal.cols-1,ae="";for(let xe=L;xe<=O;xe++){let K=M.getCell(xe);K&&(ae+=K.getChars())}b.push(ae.replace(/\s+$/,""))}return b.join(`
|
|
3
|
+
`)}getSelection(){return this.terminal.getSelection()}clearSelection(){this.terminal.clearSelection()}hasSelectionSupport(){return!0}};function Cn(e){let t=e.getBoundingClientRect(),s=window.visualViewport;return s?{width:Math.min(t.width,s.width),height:Math.max(0,Math.min(t.height,s.height-Math.max(0,t.top)))}:t}function xn(e,t,s){return e.innerHTML="",e.classList.add("terminal-pending"),(async()=>{let n=await En.create(e,s.scrollback,s.theme),a,r=0,c,o=null,u=0,p=0,E=.2,b=10,A=.95,M=.04,L=null,O=null;function ae(i){L||(L=document.createElement("div"),L.style.cssText=["position:absolute","left:0","width:40%","padding:10px 0","text-align:center","font:600 14px/1.4 system-ui, -apple-system, sans-serif","color:rgba(255,255,255,0.95)","background:rgba(20,30,50,0.55)","border:1px solid rgba(255,255,255,0.25)","border-radius:10px","pointer-events:none","opacity:0","transition:opacity 0.15s ease","z-index:6"].join(";"),e.appendChild(L)),L.textContent=i?"\u2191 \u4E0A\u7FFB\u4E00\u9875 (PgUp)":"\u2193 \u4E0B\u7FFB\u4E00\u9875 (PgDn)",L.style.top=i?"10%":"auto",L.style.bottom=i?"auto":"10%",L.style.opacity="1",O&&clearTimeout(O),O=setTimeout(()=>{L&&(L.style.opacity="0")},900)}function xe(){O&&clearTimeout(O),L&&(L.style.opacity="0")}function K(){u&&(cancelAnimationFrame(u),u=0),p=0}function Vt(i){if(K(),Math.abs(i)<E)return;p=Math.max(-b,Math.min(b,i));let l=()=>{if(q){u=0;return}let d=n.cellHeight(),m=d>0?Math.round(p*16/d):p>0?1:-1;m===0&&(m=p>0?1:-1);let v=n.viewportY()-m,N=n.baseY(),W=Math.max(0,Math.min(v,N));if(n.scrollToLine(W,!0),p*=A,W!==v){u=0;return}if(Math.abs(p)<M){u=0;return}u=requestAnimationFrame(l)};u=requestAnimationFrame(l)}let ke=0,$="connecting",Se=0,oe=!1,Be=[],Q="",q=!1,le=1e3,Xt=location.protocol==="https:"?"wss:":"ws:",ct=s.wsBase||"/ws",Jt=Xt+"//"+location.host+ct+"/"+encodeURIComponent(t),Zt=(ct.replace(/^\/ws/,"")||"")+"/api/session/"+encodeURIComponent(t)+"/upload",Gt=/^((?!chrome|android|crios|fxios|edgios).)*safari/i.test(navigator.userAgent);function Qt(){return Be.join("")+Q}async function en(i,l=0){let d=i?n.viewportY():0,m=me(Qt());if(n.reset(),!m){i||n.scrollToBottom();return}await n.write(m),i?n.scrollToLine(l+d):n.scrollToBottom()}function V(i){a?.readyState===WebSocket.OPEN&&a.send(JSON.stringify(i))}function tn(i){let l;try{l=JSON.parse(i)}catch{$==="live"&&(Q+=i,n.write(me(i)));return}if(l.type==="auth.required"){let d=localStorage.getItem("tmux-web-token");d?V({type:"auth.token",token:d}):location.href="/login?returnTo="+encodeURIComponent(location.pathname+location.search);return}if(l.type==="attach_failed"&&typeof l.message=="string"){Te=!0,$="dead",n.reset(),n.write(`\r
|
|
4
4
|
\x1B[31m`+me(l.message)+`\x1B[0m\r
|
|
5
|
-
`).then(()=>{
|
|
5
|
+
`).then(()=>{Me();try{a?.close()}catch{}});return}if(l.type==="auth.ok"){l.token&&localStorage.setItem("tmux-web-token",l.token),le=1e3,X(),V({type:"resize",cols:n.cols,rows:n.rows}),T();return}if(l.type==="auth.failed"){if(l.permanentLock||l.retryAfterMs&&l.retryAfterMs>6e4){localStorage.removeItem("tmux-web-token"),location.href="/login?error="+encodeURIComponent(l.message);return}return}if(l.type==="snapshot"&&typeof l.data=="string"){let d=Qe(me(l.data));Be=[d],Q="",Se=typeof l.lines=="number"?l.lines:s.terminal.initialLines,$="live",n.reset(),X(),V({type:"resize",cols:n.cols,rows:n.rows}),n.write(d).then(()=>n.scrollToBottom());return}if(l.type==="window_changed"&&typeof l.activeIndex=="number"){let d=new URL(location.href);d.searchParams.get("window")!==String(l.activeIndex)&&(d.searchParams.set("window",String(l.activeIndex)),history.replaceState(history.state,"",d)),window.dispatchEvent(new CustomEvent("tmux:windows",{detail:l.windows}));return}if(l.type==="history"&&typeof l.data=="string"){l.lines>0&&l.data?(Be.unshift(Qe(l.data)),Se+=l.lines,en(!0,l.lines).finally(()=>{oe=!1})):oe=!1;return}if(l.type==="data"&&typeof l.data=="string"){let d=Qe(me(l.data));if($==="connecting"){$="live",Q=d,n.write(d);return}$==="live"&&(Q+=d,n.write(d))}}let Te=!1;function dt(){if(Te)return;let i=Jt,l=localStorage.getItem("tmux-web-token");l&&(i+=(i.includes("?")?"&":"?")+"token="+encodeURIComponent(l)),i+=(i.includes("?")?"&":"?")+"cols="+n.cols+"&rows="+n.rows,a=new WebSocket(i),a.onopen=()=>{$="connecting",Se=0,oe=!1,Be=[],Q="",n.reset(),le=1e3},a.onmessage=d=>{typeof d.data=="string"&&tn(d.data)},a.onclose=()=>{q||($="connecting",!Te&&setTimeout(()=>{le=Math.min(le*2,1e4),!q&&!Te&&dt()},le))},a.onerror=()=>a?.close()}function ee(i){V({type:"input",data:i})}function X(){return n.fit()}function Me(){e.classList.remove("terminal-pending")}function T(){r&&cancelAnimationFrame(r),c&&clearTimeout(c),X(),r=requestAnimationFrame(()=>{r=0,X()&&Me()}),c=setTimeout(()=>{X()&&Me()},120)}function nn(){T(),setTimeout(T,50),setTimeout(T,150),setTimeout(T,300)}function ut(i){return typeof i=="string"&&i.startsWith("image/")}function pt(i){return i?.files?.length?i.files[0]??null:null}function sn(i){if(!i?.items)return null;for(let l=0;l<i.items.length;l++){let d=i.items[l];if(d?.kind==="file"&&ut(d.type))return d.getAsFile()}return null}async function an(i){let l=new FormData,d=i instanceof File&&i.name?i.name:"upload";l.append("file",i,d);let m=localStorage.getItem("tmux-web-token"),v={};m&&(v.Authorization="Bearer "+m);let N=await fetch(Zt,{method:"POST",body:l,headers:v});if(!N.ok){let wt="upload failed";try{let bt=await N.json();bt.error&&(wt=bt.error)}catch{}throw new Error(wt)}let W=await N.json();if(!W.path)throw new Error("no path in response");return W.path}async function Je(i){try{let l=await an(i);ee(l)}catch{}}n.onData(i=>ee(i)),n.onResize(({cols:i,rows:l})=>V({type:"resize",cols:i,rows:l})),n.onScroll(()=>{$!=="live"||oe||!n.isNearScrollbackTop()||(oe=!0,V({type:"load_history",before:Se}))});let re=!1,ce=!1,C=null,x=null,de=document.createElement("div");de.className="terminal-copy-banner",de.innerHTML='<strong>Copy mode</strong><span class="hint">drag to copy \xB7 Esc exits</span>',de.hidden=!0,e.appendChild(de);let z=document.createElement("div");z.className="terminal-copy-banner terminal-copy-toast",z.textContent="Copied",z.hidden=!0,e.appendChild(z);function mt(i,l){let d=e.querySelector(".xterm-screen, canvas"),m=(d&&d.getBoundingClientRect().width>0?d:e).getBoundingClientRect(),v=m.height>0&&n.rows>0?m.height/n.rows:18,N=m.width>0&&n.cols>0?m.width/n.cols:9;return{row:Math.max(0,Math.min(n.rows-1,Math.floor((l-m.top)/v))),col:Math.max(0,Math.min(n.cols-1,Math.floor((i-m.left)/N)))}}async function Ie(i){if(!i)return;try{if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(i);return}}catch{}let l=document.createElement("textarea");l.value=i,l.style.position="fixed",l.style.opacity="0",l.style.pointerEvents="none",document.body.appendChild(l),l.focus(),l.select();try{document.execCommand("copy")}catch{}l.remove()}let ue;function De(){z.hidden=!1,ue&&clearTimeout(ue),ue=setTimeout(()=>{z.hidden=!0},1e3)}function te(i){re=i,de.hidden=!i,e.classList.toggle("terminal-copy-mode-active",i),i&&n.focus()}function ft(){te(!re)}function on(i){q||i.button!==0||ce||(re||i.shiftKey)&&(i.preventDefault(),i.stopPropagation(),ce=!0,C=mt(i.clientX,i.clientY),x=C,n.selectCells(C.col,C.row,x.col,x.row),document.addEventListener("mousemove",Ze,!0),document.addEventListener("mouseup",Ge,!0))}function Ze(i){q||!ce||!C||(i.preventDefault(),i.stopPropagation(),x=mt(i.clientX,i.clientY),n.selectCells(C.col,C.row,x.col,x.row))}function Ge(i){if(q||!ce||!C||!x)return;i.preventDefault(),i.stopPropagation(),document.removeEventListener("mousemove",Ze,!0),document.removeEventListener("mouseup",Ge,!0),ce=!1;let l=n.getCellsText(C.col,C.row,x.col,x.row);C=null,x=null,n.clearSelection(),te(!1),l&&(z.textContent="\u5DF2\u590D\u5236",Ie(l).then(De)),n.focus()}e.addEventListener("mousedown",on,!0),document.addEventListener("keydown",ln,!0);function ln(i){if(!(q||!n.isFocused()||i.defaultPrevented||i.isComposing)){if(re){if(i.key==="Escape"){i.preventDefault(),i.stopPropagation(),C=null,x=null,n.clearSelection(),te(!1);return}if(i.key==="Enter"||(i.ctrlKey||i.metaKey)&&i.code==="KeyC"){i.preventDefault(),i.stopPropagation(),Ie(n.getScreenText()).then(De),te(!1);return}}if(i.altKey&&i.code==="KeyC"&&!i.ctrlKey&&!i.metaKey){if(i.preventDefault(),i.stopPropagation(),C&&x){let l=n.getCellsText(C.col,C.row,x.col,x.row);C=null,x=null,n.clearSelection(),te(!1),l&&(z.textContent="Copied",Ie(l).then(De))}else{let l=n.getSelection();l?(n.clearSelection(),z.textContent="Copied",Ie(l).then(De)):ft()}return}if((i.ctrlKey||i.metaKey)&&i.code==="KeyV"){i.preventDefault(),i.stopPropagation(),(async()=>{try{if(navigator.clipboard?.read){let l=await navigator.clipboard.read();for(let d of l)for(let m of d.types)if(ut(m)){let v=await d.getType(m);await Je(v);return}}}catch{}try{let l=await navigator.clipboard?.readText();l&&n.pasteText(ht(l))}catch{}})();return}}}let Ae=0;function ht(i){return i.split(`\r
|
|
6
6
|
`).join(`
|
|
7
7
|
`).split(`
|
|
8
|
-
`).join("\r")}async function rn(
|
|
8
|
+
`).join("\r")}async function rn(i){let l=sn(i.clipboardData);if(l){i.preventDefault(),i.stopPropagation();let v=Date.now();if(v-Ae<50)return;Ae=v,await Je(l);return}let d=i.clipboardData?.getData("text/plain");if(!d)return;i.preventDefault(),i.stopPropagation();let m=Date.now();m-Ae<50||(Ae=m,n.pasteText(ht(d)))}let pe=0;function cn(i){i.preventDefault(),pe++,pt(i.dataTransfer)&&e.classList.add("terminal-drag-over")}function dn(i){i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="copy")}function un(i){i.preventDefault(),pe--,pe<=0&&(pe=0,e.classList.remove("terminal-drag-over"))}async function pn(i){i.preventDefault(),pe=0,e.classList.remove("terminal-drag-over");let l=pt(i.dataTransfer);l&&await Je(l)}function vt(i){!Gt||i.key!=="Escape"||re||i.defaultPrevented||i.repeat||i.metaKey||i.ctrlKey||i.altKey||n.isFocused()&&(i.preventDefault(),i.stopPropagation(),ee("\x1B"))}e.addEventListener("paste",rn),e.addEventListener("dragenter",cn),e.addEventListener("dragover",dn),e.addEventListener("dragleave",un),e.addEventListener("drop",pn),document.addEventListener("keydown",vt,!0);function mn(i){if(i.touches.length!==1){o=null;return}let l=i.touches[0];if(!l)return;K();let d=e.getBoundingClientRect(),m=l.clientX-d.left<d.width*.4?"tui":"history",v=l.clientY-d.top<d.height*.5;o={startX:l.clientX,startY:l.clientY,lastX:l.clientX,lastY:l.clientY,lastT:performance.now(),velocity:0,scrolling:!1,zone:m,tuiUp:v,sent:!1},i.stopPropagation()}function fn(i){if(!o||i.touches.length!==1)return;let l=i.touches[0];if(!l)return;let d=l.clientY-o.startY,m=l.clientX-o.startX;if(!o.scrolling){if(Math.abs(d)<8||Math.abs(d)<Math.abs(m))return;o.scrolling=!0,ke=Date.now()+500}i.preventDefault(),i.stopPropagation();let v=performance.now(),N=l.clientY-o.lastY;if(o.zone==="tui"){o.sent||(o.sent=!0,ee(o.tuiUp?"\x1B[5~":"\x1B[6~"),ae(o.tuiUp)),o.lastX=l.clientX,o.lastY=l.clientY,o.lastT=v;return}let W=v-o.lastT;W>0&&(o.velocity=N/W),yn(-N),o.lastX=l.clientX,o.lastY=l.clientY,o.lastT=v}function hn(i){if(!o)return;let l=o.scrolling,d=o.zone,m=o.tuiUp,v=o.velocity;if(o=null,i.stopPropagation(),d==="tui"){l||(ee(m?"\x1B[5~":"\x1B[6~"),ae(m),ke=Date.now()+500,i.preventDefault());return}if(!l){n.focus();return}ke=Date.now()+500,i.preventDefault(),v&&Vt(v)}function vn(i){o=null,K(),i.stopPropagation()}function gn(i){i.pointerType==="touch"&&Date.now()<ke&&(i.preventDefault(),i.stopPropagation())}function yn(i){let l=n.cellHeight(),d=l>0?Math.round(i/l):i>0?1:-1;d===0&&(d=i>0?1:-1),n.scrollLines(d)}e.addEventListener("touchstart",mn,{passive:!0,capture:!0}),e.addEventListener("touchmove",fn,{passive:!1,capture:!0}),e.addEventListener("touchend",hn,{passive:!1,capture:!0}),e.addEventListener("touchcancel",vn,{passive:!0,capture:!0}),e.addEventListener("pointerup",gn,!0);function gt(){T()}window.addEventListener("resize",gt),window.visualViewport?.addEventListener("resize",T),window.visualViewport?.addEventListener("scroll",T);let yt=new ResizeObserver(()=>T());yt.observe(e),document.fonts?.ready.then(()=>{T(),setTimeout(T,50),setTimeout(T,200)}),e.addEventListener("focusin",nn,!0);async function wn(){if(document.fonts?.ready)try{await Promise.race([document.fonts.ready,new Promise(i=>setTimeout(i,1e3))])}catch{}}return requestAnimationFrame(()=>{X()&&Me(),(async()=>(await wn(),X()&&V({type:"resize",cols:n.cols,rows:n.rows}),dt(),T()))()}),{destroy(){if(q=!0,K(),te(!1),ue&&clearTimeout(ue),document.removeEventListener("mousemove",Ze,!0),document.removeEventListener("mouseup",Ge,!0),a){try{a.close(1e3,"session switch")}catch{}a=void 0}e.innerHTML="",e.classList.remove("terminal-pending"),window.removeEventListener("resize",gt),yt.disconnect(),document.removeEventListener("keydown",vt,!0)},focus(){n.focus()},sendInput(i){ee(i)},toggleCopyMode(){ft()}}})()}var fe=window.__TMUX_WEB_SHELL__,g=null,y=null,he=typeof window.__TMUX_WEB_SCOPE__?.agentId=="string"?window.__TMUX_WEB_SCOPE__.agentId:null,k=he;window.__tmuxWebScopeAgent=he;var et="sessions",_="",He="",Re="",Lt="";function S(e){return k?"/a/"+encodeURIComponent(k)+e:e}var f=document.getElementById("sidebar-content"),J=document.getElementById("main-placeholder"),I=document.getElementById("terminal-container"),ve=document.getElementById("file-editor"),kn=document.getElementById("fe-path"),F=document.getElementById("fe-status"),ge=document.getElementById("fe-content"),Z=document.getElementById("fe-save"),Sn=document.getElementById("fe-delete"),Bn=document.getElementById("fe-back"),Et=document.getElementById("fe-new-name"),Tn=document.getElementById("fe-new-btn"),tt=document.getElementById("settings-backdrop"),Ct=document.getElementById("settings-popover"),xt=document.querySelector(".sidebar"),kt="tmux-web-force-narrow";function Ne(){try{return localStorage.getItem(kt)==="1"}catch{return!1}}function St(){document.documentElement.classList.toggle("force-narrow",Ne()),Ne()&&Bt()&&Pe()}function Bt(){return Ne()?!0:window.matchMedia("(max-width: 640px)").matches}function Pe(){Bt()&&xt.classList.add("collapsed")}function Tt(){xt.classList.remove("collapsed")}document.getElementById("mode-sessions").addEventListener("click",()=>{Tt(),Mt("sessions")}),document.getElementById("mode-files").addEventListener("click",()=>{Tt(),Mt("files")});function Mt(e){et=e,document.querySelectorAll(".mode-btn").forEach(s=>s.classList.remove("active"));let t=document.getElementById(e==="sessions"?"mode-sessions":"mode-files");t&&t.classList.add("active"),e==="sessions"?(nt="",j()):qn()}var nt="";async function j(){if(et!=="sessions")return;try{let t=await(await fetch("/api/sidebar/sessions")).json(),s=JSON.stringify({recent:t.recent,agents:t.agents,tombstones:t.tombstones});if(s===nt)return;nt=s,Fn(t)}catch{f.innerHTML+='<div class="file-tree-empty">Failed to load sessions</div>'}let e=document.getElementById("ns-btn");e&&e.addEventListener("click",()=>{let t=window.__openNewSessionModal;typeof t=="function"?t():document.getElementById("new-session-modal")?.classList.add("open")}),rt()}var It="tmux-web-sidebar-group-collapsed";function Dt(){try{return new Set(JSON.parse(localStorage.getItem(It)||"[]"))}catch{return new Set}}function Mn(e){try{localStorage.setItem(It,JSON.stringify([...e]))}catch{}}function In(e,t,s){if(!e)return"\u2026";let n=s&&(e===s||e.startsWith(s+"/"))?"~"+e.slice(s.length):e,a=n.split("/").filter(Boolean);if(a.length===0)return e;for(let r=1;r<=a.length;r++){let c=a.slice(-r).join("/");if(!t.some(o=>!o||o===e?!1:(s&&(o===s||o.startsWith(s+"/"))?"~"+o.slice(s.length):o).split("/").filter(Boolean).slice(-r).join("/")===c))return c}return n}function At(e,t,s,n=!0){let a=new Map;for(let o of e){let u=o.path||"";a.has(u)||a.set(u,[]),a.get(u).push(o)}let r=[...a.keys()],c=Dt();for(let[o,u]of a){let p=In(o,r,t),E=c.has(o),b=document.createElement("div");b.className="session-group-header"+(E?" collapsed":""),b.title=o||"No working directory",b.innerHTML=`<span class="sg-folder">📁</span><span class="sg-label">${h(p)}</span>`,b.addEventListener("click",()=>{let M=Dt(),L=b.nextElementSibling;M.has(o)?(M.delete(o),b.classList.remove("collapsed"),L?.classList.remove("collapsed")):(M.add(o),b.classList.add("collapsed"),L?.classList.add("collapsed")),Mn(M)});let A=document.createElement("div");A.className="session-group-body"+(E?" collapsed":"");for(let M of u)A.appendChild(s?Dn(M,s,n):An(M));f.appendChild(b),f.appendChild(A)}}function Dn(e,t,s){let n=document.createElement("div");n.className="session-item"+(e.name===y&&k===t?" active":"")+(s?"":" session-offline"),n.setAttribute("data-session",e.name),n.setAttribute("data-agent",t),n.innerHTML=`<svg viewBox="0 0 24 24" fill="currentColor"><path d="${e.attached?"M19 4H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 14H5V6h14v12z":"M4 6h16v2H4V6zm0 5h16v2H4v-2zm0 5h16v2H4v-2z"}"></svg>
|
|
9
9
|
<span>${h(e.name)}</span>${s?"":'<span class="meta">offline</span>'}
|
|
10
|
-
<button class="session-edit-btn" data-session="${h(e.name)}" title="Edit session"><svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 000-1.41l-2.34-2.34a1 1 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg></button>`,s&&n.addEventListener("click",r=>{r.target.closest(".session-edit-btn")||
|
|
10
|
+
<button class="session-edit-btn" data-session="${h(e.name)}" title="Edit session"><svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 000-1.41l-2.34-2.34a1 1 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg></button>`,s&&n.addEventListener("click",r=>{r.target.closest(".session-edit-btn")||ye(e.name,t)});let a=n.querySelector(".session-edit-btn");return a&&a.addEventListener("click",r=>{r.stopPropagation(),Ke(e.name,a,{agentId:t})}),n}function An(e){let t=document.createElement("div");t.className="session-item"+(e.name===y&&!k?" active":""),t.setAttribute("data-session",e.name),t.innerHTML=`<svg viewBox="0 0 24 24" fill="currentColor"><path d="${e.attached?"M19 4H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 14H5V6h14v12z":"M4 6h16v2H4V6zm0 5h16v2H4v-2zm0 5h16v2H4v-2z"}"></svg>
|
|
11
11
|
<span>${h(e.name)}</span>
|
|
12
12
|
<button class="session-edit-btn" data-session="${h(e.name)}" title="Edit session"><svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 000-1.41l-2.34-2.34a1 1 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg></button>
|
|
13
|
-
`,t.addEventListener("click",n=>{n.target.closest(".session-edit-btn")||
|
|
13
|
+
`,t.addEventListener("click",n=>{n.target.closest(".session-edit-btn")||ye(e.name)});let s=t.querySelector(".session-edit-btn");return s&&s.addEventListener("click",n=>{n.stopPropagation(),Ke(e.name,s)}),t}function Fn(e){f.innerHTML='<button class="new-session-sidebar-btn" id="ns-btn">+ New Session</button>';let t=e.recent||[],s=document.createElement("div");s.className="sidebar-section-label"+(he?" clickable":""),s.textContent=he?"\u2190 \u8FD4\u56DE\u672C\u673A":"\u672C\u673A",he&&(s.title="Back to hub",s.addEventListener("click",()=>{window.location.href="/"})),f.appendChild(s),At(t,e.home);let n=e.agents||[];for(let r of n){if(!r.sessions||r.sessions.length===0)continue;let c=r.agentId===k,o=document.createElement("div");o.className="sidebar-section-label machine-label"+(r.online?"":" agent-offline-label")+(!c&&r.online?" clickable":""),o.textContent=r.agentName+(r.online?"":" (offline)"),!c&&r.online&&(o.title="\u6253\u5F00 "+r.agentName,o.addEventListener("click",()=>{window.location.href="/a/"+encodeURIComponent(r.agentId)+"/"})),f.appendChild(o),At(r.sessions,e.home,r.agentId,r.online)}let a=e.tombstones||[];if(a.length>0){let r=document.createElement("div");r.className="sidebar-section-label tombstone-label",r.textContent="\u5931\u6548\u4F1A\u8BDD",f.appendChild(r);for(let c of a){let o=document.createElement("div");o.className="session-item session-tombstone",o.setAttribute("data-session",c.name),c.agentId&&o.setAttribute("data-agent",c.agentId);let u=c.agentId?c.agentOnline?" (agent)":" (agent \u79BB\u7EBF)":"";o.innerHTML=`<svg viewBox="0 0 24 24" fill="currentColor"><path d="M4 6h16v2H4V6zm0 5h16v2H4v-2zm0 5h16v2H4v-2z"></svg>
|
|
14
14
|
<span>${h(c.name)}</span><span class="meta">\u5931\u6548${u}</span>
|
|
15
|
-
<button class="session-edit-btn" data-session="${h(c.name)}" title="\u6062\u590D\u4F1A\u8BDD"><svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 000-1.41l-2.34-2.34a1 1 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg></button>`,o.title="\u5931\u6548\u4F1A\u8BDD\uFF1A\u70B9\u51FB\u7BA1\u7406\uFF08\u91CD\u5EFA/\u91CD\u547D\u540D/\u5220\u9664\uFF09",o.addEventListener("click",()=>{
|
|
15
|
+
<button class="session-edit-btn" data-session="${h(c.name)}" title="\u6062\u590D\u4F1A\u8BDD"><svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 000-1.41l-2.34-2.34a1 1 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg></button>`,o.title="\u5931\u6548\u4F1A\u8BDD\uFF1A\u70B9\u51FB\u7BA1\u7406\uFF08\u91CD\u5EFA/\u91CD\u547D\u540D/\u5220\u9664\uFF09",o.addEventListener("click",()=>{Ke(c.name,o,{tombstone:!0,agentId:c.agentId})});let p=o.querySelector(".session-edit-btn");p&&p.addEventListener("click",E=>{E.stopPropagation(),Ke(c.name,p,{tombstone:!0,agentId:c.agentId})}),f.appendChild(o)}}}function h(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function ye(e,t){if(y===e&&g&&k===(t||null))return;ve.style.display="none",J.style.display="none",I.style.display="",I.classList.add("terminal-pending"),Pe(),g&&(Ye(),g.destroy(),g=null),y=e,k=t||null,window.__tmuxWebScopeAgent=k,window.__tmuxWebCurrentSession=y,ts(e,t);let s=lt(e,t);Yt.set(s,Date.now()+Qn);let n=ie.get(s);if(n&&n.state==="working"){n.state="idle",n.doneUntil=void 0,n.unread=!1;let a=f.querySelector(t?'.session-item[data-agent="'+CSS.escape(t)+'"][data-session="'+CSS.escape(e)+'"]':'.session-item[data-session="'+CSS.escape(e)+'"]:not([data-agent])');a&&Xe(a,s,n)}for(let a of f.querySelectorAll(".session-item"))a.classList.toggle("active",a.getAttribute("data-session")===e&&(a.getAttribute("data-agent")||null)===k);try{g=await xn(I,e,{terminal:fe.terminal,scrollback:fe.scrollback,theme:fe.theme,wsBase:k?"/ws/a/"+encodeURIComponent(k):fe.wsBase||"/ws"}),qt()}catch(a){console.error("[shell] terminal init failed:",a);let r=a&&typeof a=="object"&&"message"in a?a.message:String(a);I.textContent="Failed to open terminal for "+e+": "+r,I.classList.remove("terminal-pending")}}var $e=[],w=null,Ft=!1;function Hn(e){if(!w||!w.files.length)return null;let t=w.repoRoot;if(!t||!e.startsWith(t))return null;let s=e.slice(t.length+1);for(let n of w.files)if(n.path===s)return n.status;return null}async function Rn(e){Ft=!0;try{let t=await fetch(S("/api/git/status?path="+encodeURIComponent(e)));t.ok?w=await t.json():w=null}catch{w=null}finally{Ft=!1}}function Nn(){if(!w||!w.branch)return"";let{branch:e,linesAdded:t,linesRemoved:s}=w,n=`<div class="sidebar-git"><div class="git-branch-badge">
|
|
16
16
|
<svg viewBox="0 0 16 16" fill="currentColor"><path d="M11.63 1.22a.75.75 0 00-1.06 0L5.99 5.8 4.12 3.93a.75.75 0 10-1.06 1.06L4.93 6.87A3.5 3.5 0 003 10.09v3.16a.75.75 0 001 0v-3.16a2.5 2.5 0 012.5-2.5h.27l-1.06 1.06a.75.75 0 001.06 1.06l2.37-2.38a.75.75 0 000-1.06L7.59 5.27l4.04-4.05a.75.75 0 000-1.06L11.63 1.22zM3.25 13.94a.75.75 0 01-.75-.75v-.69a.75.75 0 011.5 0v.69c0 .414-.336.75-.75.75z"/></svg>
|
|
17
|
-
${h(e)}</div>`;return(t>0||s>0)&&(n+=`<div class="git-diff-stats">+<span class="add">${t}</span> <span class="del">-${s}</span></div>`),n+"</div>"}
|
|
18
|
-
<div class="git-popover-footer"><button id="git-popover-browse">Browse repository \u2192</button></div>`;else{let t=`<div class="git-popover-header">${e.length} file${e.length>1?"s":""} changed</div>`;for(let s=0;s<e.length;s++){let n=e[s],
|
|
17
|
+
${h(e)}</div>`;return(t>0||s>0)&&(n+=`<div class="git-diff-stats">+<span class="add">${t}</span> <span class="del">-${s}</span></div>`),n+"</div>"}f.addEventListener("click",e=>{e.target.closest(".sidebar-git")&&ne&&w&&(e.stopPropagation(),$t())});var we=document.getElementById("header-git"),Ht=document.getElementById("git-diff-view"),Rt=document.getElementById("gd-path"),ze=document.getElementById("gd-status"),je=document.getElementById("gd-content"),Pn=document.getElementById("gd-back"),ne=null;function be(e){if(!e||!e.branch){we.style.display="none",ne=null;return}ne=e.repoRoot;let{branch:t,linesAdded:s,linesRemoved:n}=e,a=`<span class="branch">${h(t)}</span>`;(s>0||n>0)&&(a+=`<span class="sep">\xB7</span>+<span class="diff-add">${s}</span> <span class="diff-del">-${n}</span>`),we.innerHTML=a,we.style.display="block"}we.addEventListener("click",e=>{ne&&w&&(e.stopPropagation(),$t())});var B=document.getElementById("git-popover"),Ue=document.getElementById("git-popover-backdrop");function st(){let e=we.getBoundingClientRect();B.style.top=e.bottom+4+"px",B.style.left=Math.max(8,Math.min(e.left,window.innerWidth-400))+"px"}function Nt(){let e=ne,t=document.getElementById("git-popover-browse");t&&t.addEventListener("click",()=>{if(We(),e){et="files",document.querySelectorAll(".mode-btn").forEach(n=>n.classList.remove("active"));let s=document.getElementById("mode-files");s&&s.classList.add("active"),Y(e)}})}var Pt="";function $t(){if(!w)return;let e=w.files||[];if(!e.length)B.innerHTML=`<div class="git-popover-header">No changes \u2014 clean working tree</div>
|
|
18
|
+
<div class="git-popover-footer"><button id="git-popover-browse">Browse repository \u2192</button></div>`;else{let t=`<div class="git-popover-header">${e.length} file${e.length>1?"s":""} changed</div>`;for(let s=0;s<e.length;s++){let n=e[s],a=n.additions||0,r=n.deletions||0,c="";switch(n.status){case"M":c='<span class="git-file-status M">M</span>';break;case"A":c='<span class="git-file-status A">A</span>';break;case"D":c='<span class="git-file-status D">D</span>';break;case"?":c='<span class="git-file-status ?">?</span>';break;case"R":c='<span class="git-file-status R">R</span>';break}t+=`<div class="git-popover-item" data-idx="${s}">
|
|
19
19
|
${c}<span class="file-path">${h(n.path)}</span>
|
|
20
|
-
<span class="file-add">${
|
|
20
|
+
<span class="file-add">${a>0?"+"+a:""}</span>
|
|
21
21
|
<span class="file-del">${r>0?"-"+r:""}</span>
|
|
22
|
-
</div>`}t+='<div class="git-popover-footer"><button id="git-popover-browse">Browse repository \u2192</button></div>',Pt=t,B.innerHTML=t,B.querySelectorAll(".git-popover-item").forEach(s=>{let n=parseInt(s.dataset.idx||"0",10),
|
|
22
|
+
</div>`}t+='<div class="git-popover-footer"><button id="git-popover-browse">Browse repository \u2192</button></div>',Pt=t,B.innerHTML=t,B.querySelectorAll(".git-popover-item").forEach(s=>{let n=parseInt(s.dataset.idx||"0",10),a=e[n];!a||a.status==="D"||(s.classList.add("clickable"),s.style.cursor="pointer",s.addEventListener("click",()=>jt(a.path)))})}st(),B.classList.add("open"),Ue.classList.add("open"),Nt()}function $n(){return window.innerWidth>=1024}function zt(e,t){let s=(e+(t&&e?`
|
|
23
23
|
`:"")+t).split(`
|
|
24
|
-
`),n="",
|
|
24
|
+
`),n="",a=0,r=0;for(let c of s){let o=c;if(o.startsWith("@@")){let u=o.match(/@@\s+-(\d+)[^+]*\+(\d+)/);u&&(a=parseInt(u[1],10)-1,r=parseInt(u[2],10)-1),n+=`<div class="diff-line hunk"><span class="ln-body">${h(o)}</span></div>`;continue}if(o.startsWith("diff --git")||o.startsWith("index ")||o.startsWith("--- ")||o.startsWith("+++ ")||o.startsWith("new file")||o.startsWith("deleted file")){o.startsWith("diff --git")&&(n+=`<div class="diff-line header"><span class="ln-body">${h(o)}</span></div>`);continue}if(o.startsWith("+"))r++,n+=`<div class="diff-line add"><span class="ln-no">${r}</span><span class="ln-body">${h(o)}</span></div>`;else if(o.startsWith("-"))a++,n+=`<div class="diff-line del"><span class="ln-no">${a}</span><span class="ln-body">${h(o)}</span></div>`;else if(o.startsWith("\\"))n+=`<div class="diff-line"><span class="ln-body">${h(o)}</span></div>`;else{if(!o&&!a&&!r)continue;a++,r++,n+=`<div class="diff-line"><span class="ln-no">${a}</span><span class="ln-no" style="margin-right:12px">${r}</span><span class="ln-body">${h(o)}</span></div>`}}return{html:n,lineCount:s.length}}var qe=null;async function jt(e){let t=ne;if(t)if(We(),$n()){I.style.display="none",g&&(Ye(),g.destroy(),g=null,qe=y,y=null),be(null),ve.style.display="none",J.style.display="none",Ht.style.display="flex",Rt.textContent=e,ze.textContent="Loading\u2026",je.innerHTML="";try{let s=await fetch(S("/api/git/diff?path="+encodeURIComponent(t)+"&file="+encodeURIComponent(e)));if(!s.ok)throw new Error(await s.text());let n=await s.json();jn(e,n.diff,n.stagedDiff)}catch(s){let n=s instanceof Error?s.message:String(s);ze.textContent="Error",je.innerHTML=`<div class="diff-empty" style="padding:24px;text-align:center;color:var(--panel-muted)">Error: ${h(n)}</div>`}}else{B.innerHTML=`<div class="git-diff-view"><div class="diff-header">
|
|
25
25
|
<button class="diff-back">\u2190 Back</button>
|
|
26
26
|
<span class="diff-filename">${h(e)}</span>
|
|
27
27
|
<span class="diff-loading">Loading\u2026</span>
|
|
28
|
-
</div></div>`,
|
|
28
|
+
</div></div>`,st(),B.classList.add("open"),Ue.classList.add("open");try{let s=await fetch(S("/api/git/diff?path="+encodeURIComponent(t)+"&file="+encodeURIComponent(e)));if(!s.ok)throw new Error(await s.text());let n=await s.json();zn(e,n.diff,n.stagedDiff)}catch(s){let n=s instanceof Error?s.message:String(s);B.innerHTML=`<div class="git-diff-view"><div class="diff-header">
|
|
29
29
|
<button class="diff-back">\u2190 Back</button>
|
|
30
30
|
<span class="diff-filename">${h(e)}</span>
|
|
31
31
|
</div><div class="diff-empty">Error loading diff: ${h(n)}</div></div>`}}}function zn(e,t,s){if(!t&&!s){B.innerHTML=`<div class="git-diff-view"><div class="diff-header">
|
|
32
32
|
<button class="diff-back">\u2190 Back</button>
|
|
33
33
|
<span class="diff-filename">${h(e)}</span>
|
|
34
|
-
</div><div class="diff-empty">No diff content available</div></div>`;return}let{html:n,lineCount:
|
|
34
|
+
</div><div class="diff-empty">No diff content available</div></div>`;return}let{html:n,lineCount:a}=zt(t,s);B.innerHTML=`<div class="git-diff-view"><div class="diff-header">
|
|
35
35
|
<button class="diff-back">\u2190 Back</button>
|
|
36
36
|
<span class="diff-filename">${h(e)}</span>
|
|
37
|
-
<span class="diff-filesize">${
|
|
38
|
-
</div><div class="diff-content">${n}</div></div>`,B.querySelector(".diff-back")?.addEventListener("click",()=>{B.innerHTML=Pt,
|
|
37
|
+
<span class="diff-filesize">${a} lines</span>
|
|
38
|
+
</div><div class="diff-content">${n}</div></div>`,B.querySelector(".diff-back")?.addEventListener("click",()=>{B.innerHTML=Pt,st(),w&&B.querySelectorAll(".git-popover-item").forEach(r=>{let c=parseInt(r.dataset.idx||"0",10),o=w.files[c];!o||o.status==="D"||(r.style.cursor="pointer",r.addEventListener("click",()=>jt(o.path)))}),Nt()})}function jn(e,t,s){if(!t&&!s){ze.textContent="No diff",je.innerHTML='<div class="diff-empty" style="padding:24px;text-align:center;color:var(--panel-muted)">No diff content available</div>';return}let{html:n,lineCount:a}=zt(t,s);Rt.textContent=e,ze.textContent=a+" lines",je.innerHTML=n}function Un(){Ht.style.display="none",qe?(I.style.display="",I.classList.add("terminal-pending"),ye(qe),qe=null):y?(I.style.display="",I.classList.add("terminal-pending"),qt()):J.style.display="flex"}Pn.addEventListener("click",Un);function We(){B.classList.remove("open"),Ue.classList.remove("open")}Ue.addEventListener("click",We),document.addEventListener("keydown",e=>{e.key==="Escape"&&(We(),Ve())});async function Ut(e){try{let t=await(await fetch("/api/fs/session-path?session="+encodeURIComponent(e))).json();if(t.path){let s=await fetch("/api/git/status?path="+encodeURIComponent(t.path));if(s.ok){let n=await s.json();w=n,be(n);return}}}catch{}w=null,be(null)}var _e=null;function qt(){Ye(),y&&(Ut(y),_e=setInterval(()=>{y&&Ut(y)},3e4))}function Ye(){_e&&(clearInterval(_e),_e=null)}function qn(){if($e=fe.fsRoots||[],$e.length===0){if(y){Wn(y);return}f.innerHTML='<div class="file-tree-info">Open a session first, then switch to Files to browse its directory.</div>';return}f.innerHTML="";for(let e of $e){let t=document.createElement("div");t.className="file-tree-item",t.innerHTML=`<svg viewBox="0 0 24 24" fill="currentColor" class="file-icon"><path d="M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"/></svg> ${h(e)}`,t.addEventListener("click",()=>Y(e)),f.appendChild(t)}}async function Wn(e){f.innerHTML='<div class="file-tree-empty">Loading...</div>';try{let t=await(await fetch(S("/api/fs/session-path?session="+encodeURIComponent(e)))).json();t.path?Y(t.path):f.innerHTML='<div class="file-tree-info">Could not determine session directory.</div>'}catch{f.innerHTML='<div class="file-tree-error">Failed to get session directory</div>'}}async function Y(e){_=e,f.innerHTML='<div class="file-tree-empty">Loading...</div>';let t=Rn(e);try{let s=await(await fetch(S("/api/fs/list?path="+encodeURIComponent(e)))).json();await t,f.innerHTML="",be(w),f.innerHTML+=Nn();let n=_n(e);if(n&&!$e.some(r=>e===r)){let r=document.createElement("div");r.className="file-tree-item",r.innerHTML="..",r.addEventListener("click",()=>Y(n)),f.appendChild(r)}if(s.dirs)for(let r of s.dirs){let c=r.split("/").pop()||r.split("\\").pop(),o=document.createElement("div");o.className="file-tree-item",o.innerHTML=`<svg viewBox="0 0 24 24" fill="currentColor" class="file-icon"><path d="M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"/></svg> ${h(c)}`,o.addEventListener("click",()=>Y(r)),f.appendChild(o)}else f.innerHTML="";let a=s.files||[];for(let r of a){let c=r.split("/").pop()||r.split("\\").pop(),o=Hn(r),u="",p="";if(o)switch(o){case"M":u="git-mod",p='<span class="git-file-status M">M</span>';break;case"A":u="git-add",p='<span class="git-file-status A">A</span>';break;case"D":u="git-del",p='<span class="git-file-status D">D</span>';break;case"?":u="git-untracked",p='<span class="git-file-status ?">?</span>';break;case"R":u="git-mod",p='<span class="git-file-status R">R</span>';break}let E=document.createElement("div");E.className="file-tree-item file"+(u?" "+u:""),E.innerHTML=`<span class="file-icon">\u{1F4C4}</span> ${p}${h(c)}`,E.addEventListener("click",()=>Yn(r)),f.appendChild(E)}}catch{f.innerHTML='<div class="file-tree-error">Failed to load directory</div>'}}function _n(e){let t=e.lastIndexOf("/");return t<=0?null:e.substring(0,t)}async function Yn(e){He=e,I.style.display="none",g&&(Ye(),g.destroy(),g=null,y=null),be(null),Pe(),J.style.display="none",ve.style.display="flex",kn.textContent=e,F.textContent="Loading...",Z.style.display="none";try{let t=await fetch(S("/api/file?path="+encodeURIComponent(e)));if(!t.ok){let n=await t.json();F.textContent=n.error||"Failed to load",ge.value="";return}let s=await t.json();ge.value=s.content,Re=s.content,Lt=s.content,F.textContent=s.size+" bytes",Z.style.display=""}catch{F.textContent="Failed to load",ge.value=""}}ge.addEventListener("input",()=>{Re=ge.value}),Z.addEventListener("click",async()=>{Z.textContent="Saving...",Z.disabled=!0;try{let e=await fetch(S("/api/file"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:He,content:Re})});if(!e.ok){let t=await e.json();F.textContent=t.error||"Save failed";return}Lt=Re,F.textContent="Saved"}catch{F.textContent="Save failed"}finally{Z.disabled=!1,Z.textContent="Save"}}),Sn.addEventListener("click",async()=>{if(confirm("Delete "+He+"?"))try{let e=await fetch(S("/api/file/delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:He})});if(!e.ok){let t=await e.json();F.textContent=t.error||"Delete failed";return}ve.style.display="none",J.style.display="flex",_&&Y(_)}catch{F.textContent="Delete failed"}}),Bn.addEventListener("click",()=>{ve.style.display="none",J.style.display="flex",_&&Y(_)}),Tn.addEventListener("click",async()=>{let e=Et.value.trim();if(!e)return;let t=_+"/"+e;try{let s=await fetch(S("/api/file/touch"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!s.ok){let n=await s.json();F.textContent=n.error||"Create failed";return}Et.value="",_&&Y(_)}catch{F.textContent="Create failed"}});var Oe=document.getElementById("force-narrow-toggle");Oe&&(Oe.checked=Ne(),Oe.addEventListener("change",()=>{try{localStorage.setItem(kt,Oe.checked?"1":"0")}catch{}St(),j()})),St(),document.getElementById("mode-settings").addEventListener("click",()=>{let e=Ct.classList.toggle("open");tt.classList.toggle("open",e)}),tt.addEventListener("click",()=>{Ct.classList.remove("open"),tt.classList.remove("open")});var D="",U=!1,H,Le=document.createElement("div");Le.className="session-popover-backdrop",document.body.appendChild(Le);var R=document.createElement("div");R.id="session-popover",R.className="session-popover",R.style.display="none",R.innerHTML=`<div class="sp-field">
|
|
39
39
|
<label>Rename session</label>
|
|
40
40
|
<input type="text" id="sp-name" />
|
|
41
41
|
</div>
|
|
@@ -45,5 +45,5 @@ var bn=/\x1b\](?:10|11|110|111|104)(?:;[^\x07\x1b]*)?\x1b?(?:\\|\x07)/g;function
|
|
|
45
45
|
</div>
|
|
46
46
|
<hr class="sp-divider" />
|
|
47
47
|
<button class="btn primary" id="sp-rebuild" style="display:none">\u91CD\u5EFA\u540C\u540D\u540C\u8DEF\u5F84 session</button>
|
|
48
|
-
<button class="btn danger" id="sp-delete">Delete session</button>`,document.body.appendChild(R);function
|
|
49
|
-
`).length;P.rows=Math.min(e,4)}),P.addEventListener("keydown",e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),
|
|
48
|
+
<button class="btn danger" id="sp-delete">Delete session</button>`,document.body.appendChild(R);function On(e){let t=e.getBoundingClientRect(),s=window.innerHeight,n=R.offsetHeight||240,a=t.bottom+4;a+n>s-8&&(a=Math.max(8,t.top-n-4)),R.style.top=a+"px",R.style.left=Math.max(8,Math.min(t.left,window.innerWidth-240))+"px"}function Ke(e,t,s){D=e,U=!!s?.tombstone,H=s?.agentId;let n=document.getElementById("sp-name");n.value=e;let a=R.querySelector(".sp-field label");a.textContent=U?"\u91CD\u547D\u540D (\u4EC5\u8BB0\u5F55\uFF0C\u4E0D\u91CD\u5EFA)":"Rename session";let r=document.getElementById("sp-rebuild");r.style.display=U?"":"none";let c=document.getElementById("sp-delete");c.textContent=U?"\u5220\u9664\u5931\u6548\u8BB0\u5F55 (\u5893\u7891\u6D88\u5931)":"Delete session";let o=document.getElementById("sp-save");o.textContent=U?"\u91CD\u547D\u540D":"Save",Le.classList.add("open"),R.style.display="block",On(t),setTimeout(()=>n.focus(),50)}function G(){Le.classList.remove("open"),R.style.display="none"}Le.addEventListener("click",G),document.getElementById("sp-save").addEventListener("click",async()=>{let e=document.getElementById("sp-name").value.trim();if(!e||e===D){G();return}try{let t=U?{oldName:D,newName:e,agentId:H}:{oldName:D,newName:e,...H?{agentId:H}:{}};if(!(await fetch(S(U?"/api/sessions/rename-tombstone":"/api/sessions/rename"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok)return;G(),j(),!U&&y===D&&(H??null)===k&&ye(e,H)}catch{}}),document.getElementById("sp-rebuild").addEventListener("click",async()=>{if(confirm('\u91CD\u5EFA\u4F1A\u8BDD "'+D+'" (\u540C\u540D\u540C\u8DEF\u5F84\uFF0C\u5185\u5BB9\u4E3A\u7A7A)\uFF1F'))try{let e=await fetch(S("/api/sessions/rebuild"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:D,agentId:H})});if(!e.ok){let t=await e.json();alert(t.error||"\u91CD\u5EFA\u5931\u8D25");return}G(),j()}catch{}}),document.getElementById("sp-delete").addEventListener("click",async()=>{if(U){if(!confirm('\u5220\u9664\u5931\u6548\u8BB0\u5F55 "'+D+'"\uFF1F'))return;try{if(!(await fetch(S("/api/sessions/dismiss"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:D,agentId:H})})).ok)return;G(),j()}catch{}return}if(confirm('Delete session "'+D+'"?'))try{if(!(await fetch(S("/api/sessions/kill"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:D,...H?{agentId:H}:{}})})).ok)return;G(),y===D&&(H??null)===k&&(g&&(g.destroy(),g=null),y=null,I.style.display="none",J.style.display="flex"),j()}catch{}}),document.getElementById("sp-cancel").addEventListener("click",G);var Kn={esc:"\x1B",tab:" ","s-tab":"\x1B[Z",up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C",space:" ",enter:"\r","ctrl-r":"","ctrl-c":"",btw:"/btw ",yes:"yes\r"};document.getElementById("mobile-keys").addEventListener("click",e=>{let t=e.target.closest("button[data-key]");if(!t||!g)return;let s=Kn[t.dataset.key];s&&(g.sendInput(s),g.focus())});var P=document.getElementById("mk-input"),Wt=document.getElementById("mk-send");function _t(){if(!P||!g)return;let e=P.value;e&&(g.sendInput(e+"\r"),P.value="",P.rows=1,g.focus())}if(P&&(P.addEventListener("input",()=>{P.rows=1;let e=P.value.split(`
|
|
49
|
+
`).length;P.rows=Math.min(e,4)}),P.addEventListener("keydown",e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),_t())})),Wt&&Wt.addEventListener("click",_t),window.visualViewport){let e=document.querySelector(".app-layout"),t=()=>{e&&(e.style.height=window.visualViewport.height+"px"),window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0};window.visualViewport.addEventListener("resize",t),window.addEventListener("orientationchange",()=>setTimeout(t,100)),document.addEventListener("touchstart",()=>{(window.scrollY>0||document.documentElement.scrollTop>0)&&window.scrollTo(0,0)},{passive:!0})}var it=document.getElementById("process-panel"),Ee=document.getElementById("proc-list"),Vn=document.getElementById("proc-close"),at=document.getElementById("proc-backdrop"),Xn=document.getElementById("header-ram");function Jn(){Ee.innerHTML='<div class="proc-empty">Loading\u2026</div>',fetch(S("/api/system/processes")).then(e=>e.json()).then(e=>{if(!Array.isArray(e)||!e.length){Ee.innerHTML='<div class="proc-empty">No processes</div>';return}let t="";for(let s of e){let n=s.rss,a=n<1048576?(n/1024).toFixed(0)+"K":(n/1048576).toFixed(1)+"M";t+='<div class="proc-row" data-pid="'+s.pid+'"><span class="proc-mem">'+s.mem+'%</span><span class="proc-rss">'+a+'</span><span class="proc-cmd" title="'+h(s.command)+'">'+h(s.command)+'</span><button class="proc-kill" title="Kill PID '+s.pid+'">×</button></div>'}Ee.innerHTML=t;for(let s of Ee.querySelectorAll(".proc-row")){let n=s.querySelector(".proc-kill");n&&n.addEventListener("click",a=>{let r=a.target.closest(".proc-row");!r||!confirm("Kill PID "+r.dataset.pid+"?")||fetch(S("/api/system/kill"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:parseInt(r.dataset.pid,10)})}).then(c=>c.json()).then(c=>{c.ok?r.style.opacity="0.3":alert("Failed: "+(c.error||"unknown"))}).catch(()=>alert("Network error"))})}}).catch(()=>{Ee.innerHTML='<div class="proc-empty">Failed to load</div>'})}function Zn(){it.classList.add("open"),at.classList.add("open"),Jn()}function Ve(){it.classList.remove("open"),at.classList.remove("open")}Xn.addEventListener("click",e=>{e.stopPropagation(),it.classList.contains("open")?Ve():Zn()}),Vn.addEventListener("click",Ve),at.addEventListener("click",Ve);var Gn=2e3,Ce=null,ot=null,se=new Map,ie=new Map,Qn=5e3,Yt=new Map;function lt(e,t){return(t?"a:"+t+":":"l:")+e}function es(e,t,s){let n=lt(e,t);if(s==="working"){let p=Yt.get(n);if(p&&Date.now()<p)return}let a=ie.get(n),r=e===y&&(t??null)===k,c=s==="idle"&&a?.state==="working";ie.set(n,{session:e,agentId:t,state:s,doneUntil:c?Date.now()+Gn:void 0,unread:c?!r:!1});let o=t?'.session-item[data-agent="'+CSS.escape(t)+'"][data-session="'+CSS.escape(e)+'"]':'.session-item[data-session="'+CSS.escape(e)+'"]:not([data-agent])',u=f.querySelector(o);u&&Xe(u,n,ie.get(n))}function Xe(e,t,s){let n=se.get(t);n&&(clearTimeout(n),se.delete(t)),e.classList.remove("working","just-done");let a=s.session===y&&(s.agentId??null)===k;s.state==="working"?e.classList.add("working"):a&&s.doneUntil&&Date.now()<s.doneUntil?(e.classList.add("just-done"),se.set(t,setTimeout(()=>{e.classList.remove("just-done"),se.delete(t)},Math.max(0,s.doneUntil-Date.now())))):!a&&s.unread&&e.classList.add("just-done")}function rt(){for(let[e,t]of ie){let s=t.agentId?'.session-item[data-agent="'+CSS.escape(t.agentId)+'"][data-session="'+CSS.escape(t.session)+'"]':'.session-item[data-session="'+CSS.escape(t.session)+'"]:not([data-agent])',n=f.querySelector(s);n&&Xe(n,e,t)}}function ts(e,t){let s=lt(e,t),n=ie.get(s);if(!n)return;let a=se.get(s);a&&(clearTimeout(a),se.delete(s)),n.doneUntil=void 0,n.unread=!1;let r=t?'.session-item[data-agent="'+CSS.escape(t)+'"][data-session="'+CSS.escape(e)+'"]':'.session-item[data-session="'+CSS.escape(e)+'"]:not([data-agent])',c=f.querySelector(r);c&&Xe(c,s,n)}function Ot(){if(Ce||ot)return;let e=localStorage.getItem("tmux-web-token"),t=(location.protocol==="https:"?"wss:":"ws:")+"//"+location.host+"/ws/activity";e&&(t+="?token="+encodeURIComponent(e));try{let s=new WebSocket(t);Ce=s,s.onmessage=n=>{try{let a=JSON.parse(String(n.data));a&&a.type==="session.activity"&&typeof a.session=="string"&&es(a.session,a.agentId||void 0,a.state==="working"?"working":"idle")}catch{}},s.onclose=()=>{Ce===s&&(Ce=null,ot=setTimeout(()=>{ot=null,Ot()},5e3))},s.onerror=()=>{try{s.close()}catch{}}}catch{Ce=null}}window.__openSession=ye,window.__refreshSidebar=j,j(),Pe(),rt(),Ot(),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&rt()}),setInterval(()=>{document.visibilityState==="visible"&&j()},1e4);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
`)}selectRows(o
|
|
3
|
-
`)}getSelection(){return this.terminal.getSelection()}clearSelection(){this.terminal.clearSelection()}hasSelectionSupport(){return!0}}function Nt(
|
|
4
|
-
\x1B[31m`+
|
|
5
|
-
`).then(()=>{$();try{
|
|
1
|
+
const Ht=/\x1b\](?:10|11|110|111|104)(?:;[^\x07\x1b]*)?\x1b?(?:\\|\x07)/g;function ot(l){return l.replace(/\x1b\[\?1049[hl]/g,"")}function O(l){return l.replace(Ht,"")}let N;function Ot(){return N||(document.querySelector("link[data-tmux-web-xterm-css]")?N=Promise.resolve():(N=new Promise(i=>{const o=document.createElement("link");o.rel="stylesheet",o.href="/assets/xterm.css",o.setAttribute("data-tmux-web-xterm-css",""),o.addEventListener("load",()=>i(),{once:!0}),o.addEventListener("error",()=>i(),{once:!0}),document.head.appendChild(o)}),N))}class rt{terminal;fitAddon;container;verifyRaf=0;verifyRounds=0;shrinkCols=0;lastLimit=0;lastCheckAt=0;webglActive=!1;webglAddon=null;constructor(i,o,n){this.container=i,this.terminal=o,this.fitAddon=n,this.terminal.loadAddon(this.fitAddon),this.terminal.open(i),this.enableWebglRenderer()}enableWebglRenderer(){import("@xterm/addon-webgl").then(({WebglAddon:i})=>{const o=new i;o.onContextLoss(()=>{this.webglActive=!1,this.webglAddon=null;try{o.dispose()}catch{}this.lastLimit>0&&this.scheduleColumnCheck(this.lastLimit,!0)});try{this.terminal.loadAddon(o)}catch{return}this.webglAddon=o,this.webglActive=!0,this.fit()}).catch(()=>{})}static async create(i,o,n){const[{Terminal:a},{FitAddon:d}]=await Promise.all([import("@xterm/xterm"),import("@xterm/addon-fit"),Ot()]),h=new a({fontSize:14,fontFamily:"'JetBrains Mono', 'SF Mono', 'Menlo', monospace",cursorBlink:!0,cursorStyle:"bar",scrollback:o,convertEol:!1,smoothScrollDuration:120,theme:n});return new rt(i,h,new d)}get cols(){return this.terminal.cols}get rows(){return this.terminal.rows}write(i){return new Promise(o=>this.terminal.write(i,()=>{this.lastLimit>0&&this.scheduleColumnCheck(this.lastLimit),o()}))}reset(){this.terminal.reset()}scrollToBottom(){this.terminal.scrollToBottom()}scrollToLine(i,o=!1){this.terminal.scrollToLine(Math.max(0,i),o)}scrollLines(i){const o=this.terminal.buffer?.active;this.terminal.scrollLines(i)}isNearScrollbackTop(){return this.terminal.buffer.active.viewportY<=1}viewportY(){return this.terminal.buffer.active.viewportY}baseY(){return this.terminal.buffer.active.baseY}cellHeight(){const o=this.terminal.element?.querySelector(".xterm-screen")?.getBoundingClientRect().height??0,n=this.terminal.rows;return o>0&&n>0?o/n:16}fit(){const i=Nt(this.container);if(i.width<=0||i.height<=0)return!1;this.fitAddon.fit();const o=this.terminal.element?.querySelector(".xterm-viewport"),n=o?Math.max(0,o.offsetWidth-o.clientWidth):0,a=this.terminal.element?.querySelector(".vertical.scrollbar"),d=a?Math.max(0,Math.round(a.getBoundingClientRect().width)):0,h=this.container.getBoundingClientRect().left+i.width-n-d-1;if(this.lastLimit=h,this.webglActive){if(this.shrinkCols>0){const s=Math.max(10,this.terminal.cols-this.shrinkCols);s!==this.terminal.cols&&this.terminal.resize(s,this.terminal.rows)}return!0}return this.shrinkCols=0,this.verifyRounds=0,this.scheduleColumnCheck(h,!0),!0}scheduleColumnCheck(i,o=!1){if(this.lastLimit=i,this.verifyRaf)return;const n=Date.now();!o&&n-this.lastCheckAt<250||(this.lastCheckAt=n,this.verifyRaf=requestAnimationFrame(()=>{this.verifyRaf=0;try{this.recheckColumns(this.lastLimit)&&this.verifyRounds<8?(this.verifyRounds++,this.scheduleColumnCheck(this.lastLimit,!0)):this.verifyRounds=0}catch{}}))}recheckColumns(i){const o=this.terminal.element?.querySelector(".xterm-rows");if(!o)return!1;let n=0;for(const f of Array.from(o.children)){const m=f.children;for(let v=m.length-1;v>=0;v--){const T=m[v];if(!T.textContent)continue;const b=T.getBoundingClientRect().right;b>n&&(n=b);break}}if(n===0)return!1;const a=this.terminal.cols,h=this.terminal.element?.querySelector(".xterm-screen")?.getBoundingClientRect().width??0,s=a>0&&h>0?h/a:0;if(n>i){const f=n-i,m=s>0?Math.min(8,Math.ceil(f/s)):1,v=Math.max(10,a-Math.max(1,m));return v>=a?!1:(this.shrinkCols+=a-v,this.terminal.resize(v,this.terminal.rows),!0)}return!1}focus(){this.terminal.focus()}pasteText(i){this.terminal.paste(i)}input(i){this.terminal.input(i,!1)}onData(i){this.terminal.onData(i),this.terminal.onBinary(i)}onResize(i){this.terminal.onResize(i)}onScroll(i){this.terminal.onScroll(i)}attachCustomKeyEventHandler(i){this.terminal.attachCustomKeyEventHandler(i)}isFocused(){const i=document.activeElement;return i?i===this.container||i===this.terminal.textarea||this.container.contains(i)||!!i.closest?.(".xterm"):!1}getScreenText(){return this.getRowsText(0,this.terminal.rows-1)}getRowsText(i,o){const n=this.terminal.buffer.active,[a,d]=i<=o?[i,o]:[o,i],h=n.viewportY,s=[];for(let f=a;f<=d;f++){const m=n.getLine(h+f);s.push(m?m.translateToString(!0):"")}return s.join(`
|
|
2
|
+
`)}selectRows(i,o){const n=this.terminal.buffer.active,[a,d]=i<=o?[i,o]:[o,i];this.terminal.selectLines(n.viewportY+a,n.viewportY+d)}selectCells(i,o,n,a){const d=this.terminal.buffer.active,h=Math.min(o,a),s=Math.max(o,a);if(h===s){const f=Math.min(i,n),m=Math.max(i,n);this.terminal.select(f,d.viewportY+h,m-f+1)}else this.terminal.selectLines(d.viewportY+h,d.viewportY+s)}getCellsText(i,o,n,a){const d=this.terminal.buffer.active,h=Math.min(o,a),s=Math.max(o,a),f=o<a?i:o>a?n:Math.min(i,n),m=o<a?n:o>a?i:Math.max(i,n),v=d.viewportY,T=[];for(let b=h;b<=s;b++){const W=d.getLine(v+b);if(!W){T.push("");continue}const y=b===h?f:0,S=b===s?m:this.terminal.cols-1;let R="";for(let _=y;_<=S;_++){const k=W.getCell(_);k&&(R+=k.getChars())}T.push(R.replace(/\s+$/,""))}return T.join(`
|
|
3
|
+
`)}getSelection(){return this.terminal.getSelection()}clearSelection(){this.terminal.clearSelection()}hasSelectionSupport(){return!0}}function Nt(l){const i=l.getBoundingClientRect(),o=window.visualViewport;return o?{width:Math.min(i.width,o.width),height:Math.max(0,Math.min(i.height,o.height-Math.max(0,i.top)))}:i}function _t(l,i,o){return l.innerHTML="",l.classList.add("terminal-pending"),(async()=>{const n=await rt.create(l,o.scrollback,o.theme);let a,d=0,h,s=null,f=0,m=0;const v=.2,T=10,b=.95,W=.04;let y=null,S=null;function R(t){y||(y=document.createElement("div"),y.style.cssText=["position:absolute","left:0","width:40%","padding:10px 0","text-align:center","font:600 14px/1.4 system-ui, -apple-system, sans-serif","color:rgba(255,255,255,0.95)","background:rgba(20,30,50,0.55)","border:1px solid rgba(255,255,255,0.25)","border-radius:10px","pointer-events:none","opacity:0","transition:opacity 0.15s ease","z-index:6"].join(";"),l.appendChild(y)),y.textContent=t?"\u2191 \u4E0A\u7FFB\u4E00\u9875 (PgUp)":"\u2193 \u4E0B\u7FFB\u4E00\u9875 (PgDn)",y.style.top=t?"10%":"auto",y.style.bottom=t?"auto":"10%",y.style.opacity="1",S&&clearTimeout(S),S=setTimeout(()=>{y&&(y.style.opacity="0")},900)}function _(){S&&clearTimeout(S),y&&(y.style.opacity="0")}function k(){f&&(cancelAnimationFrame(f),f=0),m=0}function yt(t){if(k(),Math.abs(t)<v)return;m=Math.max(-T,Math.min(T,t));const e=()=>{if(M){f=0;return}const r=n.cellHeight();let u=r>0?Math.round(m*16/r):m>0?1:-1;u===0&&(u=m>0?1:-1);const x=n.viewportY()-u,E=n.baseY(),H=Math.max(0,Math.min(x,E));if(n.scrollToLine(H,!0),m*=b,H!==x){f=0;return}if(Math.abs(m)<W){f=0;return}f=requestAnimationFrame(e)};f=requestAnimationFrame(e)}let j=0,C="connecting",V=0,F=!1,J=[],P="",M=!1,B=1e3;const wt=location.protocol==="https:"?"wss:":"ws:",st=o.wsBase||"/ws",vt=wt+"//"+location.host+st+"/"+encodeURIComponent(i),xt=(st.replace(/^\/ws/,"")||"")+"/api/session/"+encodeURIComponent(i)+"/upload",bt=/^((?!chrome|android|crios|fxios|edgios).)*safari/i.test(navigator.userAgent);function Tt(){return J.join("")+P}async function Ct(t,e=0){const r=t?n.viewportY():0,u=O(Tt());if(n.reset(),!u){t||n.scrollToBottom();return}await n.write(u),t?n.scrollToLine(e+r):n.scrollToBottom()}function D(t){a?.readyState===WebSocket.OPEN&&a.send(JSON.stringify(t))}function Lt(t){let e;try{e=JSON.parse(t)}catch{C==="live"&&(P+=t,n.write(O(t)));return}if(e.type==="auth.required"){const r=localStorage.getItem("tmux-web-token");r?D({type:"auth.token",token:r}):location.href="/login?returnTo="+encodeURIComponent(location.pathname+location.search);return}if(e.type==="attach_failed"&&typeof e.message=="string"){G=!0,C="dead",n.reset(),n.write(`\r
|
|
4
|
+
\x1B[31m`+O(e.message)+`\x1B[0m\r
|
|
5
|
+
`).then(()=>{$();try{a?.close()}catch{}});return}if(e.type==="auth.ok"){e.token&&localStorage.setItem("tmux-web-token",e.token),B=1e3,A(),D({type:"resize",cols:n.cols,rows:n.rows}),w();return}if(e.type==="auth.failed"){if(e.permanentLock||e.retryAfterMs&&e.retryAfterMs>6e4){localStorage.removeItem("tmux-web-token"),location.href="/login?error="+encodeURIComponent(e.message);return}return}if(e.type==="snapshot"&&typeof e.data=="string"){const r=ot(O(e.data));J=[r],P="",V=typeof e.lines=="number"?e.lines:o.terminal.initialLines,C="live",n.reset(),A(),D({type:"resize",cols:n.cols,rows:n.rows}),n.write(r).then(()=>n.scrollToBottom());return}if(e.type==="window_changed"&&typeof e.activeIndex=="number"){const r=new URL(location.href);r.searchParams.get("window")!==String(e.activeIndex)&&(r.searchParams.set("window",String(e.activeIndex)),history.replaceState(history.state,"",r)),window.dispatchEvent(new CustomEvent("tmux:windows",{detail:e.windows}));return}if(e.type==="history"&&typeof e.data=="string"){e.lines>0&&e.data?(J.unshift(ot(e.data)),V+=e.lines,Ct(!0,e.lines).finally(()=>{F=!1})):F=!1;return}if(e.type==="data"&&typeof e.data=="string"){const r=ot(O(e.data));if(C==="connecting"){C="live",P=r,n.write(r);return}C==="live"&&(P+=r,n.write(r))}}let G=!1;function at(){if(G)return;let t=vt;const e=localStorage.getItem("tmux-web-token");e&&(t+=(t.includes("?")?"&":"?")+"token="+encodeURIComponent(e)),t+=(t.includes("?")?"&":"?")+"cols="+n.cols+"&rows="+n.rows,a=new WebSocket(t),a.onopen=()=>{C="connecting",V=0,F=!1,J=[],P="",n.reset(),B=1e3},a.onmessage=r=>{typeof r.data=="string"&&Lt(r.data)},a.onclose=()=>{M||(C="connecting",!G&&setTimeout(()=>{B=Math.min(B*2,1e4),!M&&!G&&at()},B))},a.onerror=()=>a?.close()}function I(t){D({type:"input",data:t})}function A(){return n.fit()}function $(){l.classList.remove("terminal-pending")}function w(){d&&cancelAnimationFrame(d),h&&clearTimeout(h),A(),d=requestAnimationFrame(()=>{d=0,A()&&$()}),h=setTimeout(()=>{A()&&$()},120)}function Et(){w(),setTimeout(w,50),setTimeout(w,150),setTimeout(w,300)}function lt(t){return typeof t=="string"&&t.startsWith("image/")}function ct(t){return t?.files?.length?t.files[0]??null:null}function Mt(t){if(!t?.items)return null;for(let e=0;e<t.items.length;e++){const r=t.items[e];if(r?.kind==="file"&<(r.type))return r.getAsFile()}return null}async function St(t){const e=new FormData,r=t instanceof File&&t.name?t.name:"upload";e.append("file",t,r);const u=localStorage.getItem("tmux-web-token"),c={};u&&(c.Authorization="Bearer "+u);const x=await fetch(xt,{method:"POST",body:e,headers:c});if(!x.ok){let H="upload failed";try{const gt=await x.json();gt.error&&(H=gt.error)}catch{}throw new Error(H)}const E=await x.json();if(!E.path)throw new Error("no path in response");return E.path}async function et(t){try{const e=await St(t);I(e)}catch{}}n.onData(t=>I(t)),n.onResize(({cols:t,rows:e})=>D({type:"resize",cols:t,rows:e})),n.onScroll(()=>{C!=="live"||F||!n.isNearScrollbackTop()||(F=!0,D({type:"load_history",before:V}))});let z=!1,K=!1,p=null,g=null;const U=document.createElement("div");U.className="terminal-copy-banner",U.innerHTML='<strong>Copy mode</strong><span class="hint">drag to copy \xB7 Esc exits</span>',U.hidden=!0,l.appendChild(U);const L=document.createElement("div");L.className="terminal-copy-banner terminal-copy-toast",L.textContent="Copied",L.hidden=!0,l.appendChild(L);function ut(t,e){const r=l.querySelector(".xterm-screen, canvas"),c=(r&&r.getBoundingClientRect().width>0?r:l).getBoundingClientRect(),x=c.height>0&&n.rows>0?c.height/n.rows:18,E=c.width>0&&n.cols>0?c.width/n.cols:9;return{row:Math.max(0,Math.min(n.rows-1,Math.floor((e-c.top)/x))),col:Math.max(0,Math.min(n.cols-1,Math.floor((t-c.left)/E)))}}async function Q(t){if(!t)return;try{if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(t);return}}catch{}const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e.focus(),e.select();try{document.execCommand("copy")}catch{}e.remove()}let X;function Z(){L.hidden=!1,X&&clearTimeout(X),X=setTimeout(()=>{L.hidden=!0},1e3)}function Y(t){z=t,U.hidden=!t,l.classList.toggle("terminal-copy-mode-active",t),t&&n.focus()}function ft(){Y(!z)}function kt(t){M||t.button!==0||K||(z||t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),K=!0,p=ut(t.clientX,t.clientY),g=p,n.selectCells(p.col,p.row,g.col,g.row),document.addEventListener("mousemove",nt,!0),document.addEventListener("mouseup",it,!0))}function nt(t){M||!K||!p||(t.preventDefault(),t.stopPropagation(),g=ut(t.clientX,t.clientY),n.selectCells(p.col,p.row,g.col,g.row))}function it(t){if(M||!K||!p||!g)return;t.preventDefault(),t.stopPropagation(),document.removeEventListener("mousemove",nt,!0),document.removeEventListener("mouseup",it,!0),K=!1;const e=n.getCellsText(p.col,p.row,g.col,g.row);p=null,g=null,n.clearSelection(),Y(!1),e&&(L.textContent="\u5DF2\u590D\u5236",Q(e).then(Z)),n.focus()}l.addEventListener("mousedown",kt,!0),document.addEventListener("keydown",Dt,!0);function Dt(t){if(!(M||!n.isFocused()||t.defaultPrevented||t.isComposing)){if(z){if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),p=null,g=null,n.clearSelection(),Y(!1);return}if(t.key==="Enter"||(t.ctrlKey||t.metaKey)&&t.code==="KeyC"){t.preventDefault(),t.stopPropagation(),Q(n.getScreenText()).then(Z),Y(!1);return}}if(t.altKey&&t.code==="KeyC"&&!t.ctrlKey&&!t.metaKey){if(t.preventDefault(),t.stopPropagation(),p&&g){const e=n.getCellsText(p.col,p.row,g.col,g.row);p=null,g=null,n.clearSelection(),Y(!1),e&&(L.textContent="Copied",Q(e).then(Z))}else{const e=n.getSelection();e?(n.clearSelection(),L.textContent="Copied",Q(e).then(Z)):ft()}return}if((t.ctrlKey||t.metaKey)&&t.code==="KeyV"){t.preventDefault(),t.stopPropagation(),(async()=>{try{if(navigator.clipboard?.read){const e=await navigator.clipboard.read();for(const r of e)for(const u of r.types)if(lt(u)){const c=await r.getType(u);await et(c);return}}}catch{}try{const e=await navigator.clipboard?.readText();e&&n.pasteText(dt(e))}catch{}})();return}}}let tt=0;function dt(t){return t.split(`\r
|
|
6
6
|
`).join(`
|
|
7
7
|
`).split(`
|
|
8
|
-
`).join("\r")}async function
|
|
8
|
+
`).join("\r")}async function At(t){const e=Mt(t.clipboardData);if(e){t.preventDefault(),t.stopPropagation();const c=Date.now();if(c-tt<50)return;tt=c,await et(e);return}const r=t.clipboardData?.getData("text/plain");if(!r)return;t.preventDefault(),t.stopPropagation();const u=Date.now();u-tt<50||(tt=u,n.pasteText(dt(r)))}let q=0;function Pt(t){t.preventDefault(),q++,ct(t.dataTransfer)&&l.classList.add("terminal-drag-over")}function It(t){t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="copy")}function Yt(t){t.preventDefault(),q--,q<=0&&(q=0,l.classList.remove("terminal-drag-over"))}async function Rt(t){t.preventDefault(),q=0,l.classList.remove("terminal-drag-over");const e=ct(t.dataTransfer);e&&await et(e)}function ht(t){!bt||t.key!=="Escape"||z||t.defaultPrevented||t.repeat||t.metaKey||t.ctrlKey||t.altKey||n.isFocused()&&(t.preventDefault(),t.stopPropagation(),I("\x1B"))}l.addEventListener("paste",At),l.addEventListener("dragenter",Pt),l.addEventListener("dragover",It),l.addEventListener("dragleave",Yt),l.addEventListener("drop",Rt),document.addEventListener("keydown",ht,!0);function Ft(t){if(t.touches.length!==1){s=null;return}const e=t.touches[0];if(!e)return;k();const r=l.getBoundingClientRect(),u=e.clientX-r.left<r.width*.4?"tui":"history",c=e.clientY-r.top<r.height*.5;s={startX:e.clientX,startY:e.clientY,lastX:e.clientX,lastY:e.clientY,lastT:performance.now(),velocity:0,scrolling:!1,zone:u,tuiUp:c,sent:!1},t.stopPropagation()}function Bt(t){if(!s||t.touches.length!==1)return;const e=t.touches[0];if(!e)return;const r=e.clientY-s.startY,u=e.clientX-s.startX;if(!s.scrolling){if(Math.abs(r)<8||Math.abs(r)<Math.abs(u))return;s.scrolling=!0,j=Date.now()+500}t.preventDefault(),t.stopPropagation();const c=performance.now(),x=e.clientY-s.lastY;if(s.zone==="tui"){s.sent||(s.sent=!0,I(s.tuiUp?"\x1B[5~":"\x1B[6~"),R(s.tuiUp)),s.lastX=e.clientX,s.lastY=e.clientY,s.lastT=c;return}const E=c-s.lastT;E>0&&(s.velocity=x/E),Xt(-x),s.lastX=e.clientX,s.lastY=e.clientY,s.lastT=c}function zt(t){if(!s)return;const e=s.scrolling,r=s.zone,u=s.tuiUp,c=s.velocity;if(s=null,t.stopPropagation(),r==="tui"){e||(I(u?"\x1B[5~":"\x1B[6~"),R(u),j=Date.now()+500,t.preventDefault());return}if(!e){n.focus();return}j=Date.now()+500,t.preventDefault(),c&&yt(c)}function Kt(t){s=null,k(),t.stopPropagation()}function Ut(t){t.pointerType==="touch"&&Date.now()<j&&(t.preventDefault(),t.stopPropagation())}function Xt(t){const e=n.cellHeight();let r=e>0?Math.round(t/e):t>0?1:-1;r===0&&(r=t>0?1:-1),n.scrollLines(r)}l.addEventListener("touchstart",Ft,{passive:!0,capture:!0}),l.addEventListener("touchmove",Bt,{passive:!1,capture:!0}),l.addEventListener("touchend",zt,{passive:!1,capture:!0}),l.addEventListener("touchcancel",Kt,{passive:!0,capture:!0}),l.addEventListener("pointerup",Ut,!0);function mt(){w()}window.addEventListener("resize",mt),window.visualViewport?.addEventListener("resize",w),window.visualViewport?.addEventListener("scroll",w);const pt=new ResizeObserver(()=>w());pt.observe(l),document.fonts?.ready.then(()=>{w(),setTimeout(w,50),setTimeout(w,200)}),l.addEventListener("focusin",Et,!0);async function qt(){if(document.fonts?.ready)try{await Promise.race([document.fonts.ready,new Promise(t=>setTimeout(t,1e3))])}catch{}}return requestAnimationFrame(()=>{A()&&$(),(async()=>(await qt(),A()&&D({type:"resize",cols:n.cols,rows:n.rows}),at(),w()))()}),{destroy(){if(M=!0,k(),Y(!1),X&&clearTimeout(X),document.removeEventListener("mousemove",nt,!0),document.removeEventListener("mouseup",it,!0),a){try{a.close(1e3,"session switch")}catch{}a=void 0}l.innerHTML="",l.classList.remove("terminal-pending"),window.removeEventListener("resize",mt),pt.disconnect(),document.removeEventListener("keydown",ht,!0)},focus(){n.focus()},sendInput(t){I(t)},toggleCopyMode(){ft()}}})()}export{_t as initTerminal,ot as stripAltScreenSequences};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tmux-weblink",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.31",
|
|
4
4
|
"description": "Access your tmux sessions from the browser. A continuation of tmux-web and persalink.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@hono/node-server": "^1.19.12",
|
|
49
49
|
"@xterm/addon-fit": "^0.11.0",
|
|
50
|
+
"@xterm/addon-webgl": "^0.19.0",
|
|
50
51
|
"@xterm/xterm": "^6.0.0",
|
|
51
52
|
"hono": "^4.7.0",
|
|
52
53
|
"lowdb": "^7.0.1",
|